@mediapipe/tasks-genai 0.10.15 → 0.10.16

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/genai.d.ts CHANGED
@@ -214,41 +214,49 @@ export declare class LlmInference extends TaskRunner {
214
214
  */
215
215
  generateResponse(text: string, loraModel: LoraModel, progressListener: ProgressListener): Promise<string>;
216
216
  /**
217
- * Similar with generateResponse() but returns multiple responses.
217
+ * Similar to `generateResponse()` but can return multiple responses for the
218
+ * given prompt if the task is initialized with a value for `numResponses`
219
+ * greater than 1.
218
220
  *
219
221
  * @export
220
222
  * @param text The text to process.
221
- * @return The generated text result.
223
+ * @return The generated results.
222
224
  */
223
225
  generateResponses(text: string): Promise<string[]>;
224
226
  /**
225
- * Similar with generateResponse() but returns multiple responses.
227
+ * Similar to `generateResponse()` but can return multiple responses for the
228
+ * given prompt if the task is initialized with a value for `numResponses`
229
+ * greater than 1.
226
230
  *
227
231
  * @export
228
232
  * @param text The text to process.
229
233
  * @param progressListener A listener that will be triggered when the task has
230
234
  * new partial response generated.
231
- * @return The generated text result.
235
+ * @return The generated results.
232
236
  */
233
237
  generateResponses(text: string, progressListener: MultiResponseProgressListener): Promise<string[]>;
234
238
  /**
235
- * Similar with generateResponse() but returns multiple responses.
239
+ * Similar to `generateResponse()` but can return multiple responses for the
240
+ * given prompt if the task is initialized with a value for `numResponses`
241
+ * greater than 1.
236
242
  *
237
243
  * @export
238
244
  * @param text The text to process.
239
245
  * @param loraModel The LoRA model to apply on the text generation.
240
- * @return The generated text result.
246
+ * @return The generated results.
241
247
  */
242
248
  generateResponses(text: string, loraModel: LoraModel): Promise<string[]>;
243
249
  /**
244
- * Similar with generateResponse() but returns multiple responses.
250
+ * Similar to `generateResponse()` but can return multiple responses for the
251
+ * given prompt if the task is initialized with a value for `numResponses`
252
+ * greater than 1.
245
253
  *
246
254
  * @export
247
255
  * @param text The text to process.
248
256
  * @param loraModel The LoRA model to apply on the text generation.
249
257
  * @param progressListener A listener that will be triggered when the task has
250
258
  * new partial response generated.
251
- * @return The generated text result.
259
+ * @return The generated results.
252
260
  */
253
261
  generateResponses(text: string, loraModel: LoraModel, progressListener: MultiResponseProgressListener): Promise<string[]>;
254
262
  /**
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,r){t:{for(var n=["CLOSURE_FLAGS"],i=t,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(e=n&&n[e])?e:r}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(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){const o=t.charCodeAt(++i);if(o>=56320&&o<=57343){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,!1),a=e(645172343,e(1,!0)),u=e(660014094,!1);const l=t.navigator;function c(t){return!!s&&(!!o&&o.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function h(e){var r;return(r=t.navigator)&&(r=r.userAgent)||(r=""),-1!=r.indexOf(e)}function f(){return!!s&&(!!o&&o.brands.length>0)}function d(){return f()?c("Chromium"):(h("Chrome")||h("CriOS"))&&!(!f()&&h("Edge"))||h("Silk")}o=l&&l.userAgentData||null;var p=!f()&&(h("Trident")||h("MSIE"));!h("Android")||d(),d(),h("Safari")&&(d()||!f()&&h("Coast")||!f()&&h("Opera")||!f()&&h("Edge")||(f()?c("Microsoft Edge"):h("Edg/"))||f()&&c("Opera"));var g={},m=null;function _(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=m[r];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(r))throw Error("Unknown base64 encoding at char: "+r)}return e}v();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 v(){if(!m){m={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],r=0;r<5;r++){var n=t.concat(e[r].split(""));g[r]=n;for(var i=0;i<n.length;i++){var o=n[i];void 0===m[o]&&(m[o]=i)}}}}var y="undefined"!=typeof Uint8Array,b=!p&&"function"==typeof btoa;function w(t){if(!b){var e;void 0===e&&(e=0),v(),e=g[e];var r=Array(Math.floor(t.length/3)),n=e[64]||"";let u=0,l=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[l++]=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[l]=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 S=/[-_.]/g,A={"-":"+",_:"/",".":"="};function T(t){return A[t]||""}function E(t){if(!b)return _(t);S.test(t)&&(t=t.replace(S,T)),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 I(t){return y&&null!=t&&t instanceof Uint8Array}var P={};let O;function L(t){if(t!==P)throw Error("illegal external caller")}function x(){return O||=new U(null,P)}var U=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 B(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}let N;function k(){const e=Error();B(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function j(t){return B(t=Error(t),"warning"),t}function F(){return"function"==typeof BigInt}function D(t){return Array.prototype.slice.call(t)}var V="function"==typeof Symbol&&"symbol"==typeof Symbol();function M(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var C=M(),G=M("2ex"),R=M("1oa"),z=M("0dg"),W=V?(t,e)=>{t[C]|=e}:(t,e)=>{void 0!==t.i?t.i|=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}})},H=V?(t,e)=>{t[C]&=~e}:(t,e)=>{void 0!==t.i&&(t.i&=~e)},$=V?t=>0|t[C]:t=>0|t.i,q=V?t=>t[C]:t=>t.i,K=V?(t,e)=>{t[C]=e}:(t,e)=>{void 0!==t.i?t.i=e:Object.defineProperties(t,{i:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Y(t,e){K(e,-14591&(0|t))}function J(t,e){K(e,-14557&(34|t))}var X,Z={},Q={};function tt(t){return!(!t||"object"!=typeof t||t.i!==Q)}function et(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function rt(t){return!(!Array.isArray(t)||t.length)&&!!(1&$(t))}const nt=[];function it(t){if(2&t)throw Error()}K(nt,55),X=Object.freeze(nt);var ot=Object.freeze({});Object.freeze({});var st=Object.freeze({});let at,ut=0,lt=0;function ct(t){const e=t>>>0;ut=e,lt=(t-e)/4294967296>>>0}function ht(t){if(t<0){ct(-t);const[e,r]=gt(ut,lt);ut=e>>>0,lt=r>>>0}else ct(t)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else F()?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,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(e+=r/1e7>>>0,r%=1e7),r=e+dt(r)+dt(t));return r}function dt(t){return t=String(t),"0000000".slice(t.length)+t}function pt(t){if(t.length<16)ht(Number(t));else if(F())t=BigInt(t),ut=Number(t&BigInt(4294967295))>>>0,lt=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);lt=ut=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));lt*=1e6,ut=1e6*ut+e,ut>=4294967296&&(lt+=Math.trunc(ut/4294967296),lt>>>=0,ut>>>=0)}if(e){const[t,e]=gt(ut,lt);ut=t,lt=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);const _t=Number.MIN_SAFE_INTEGER.toString(),vt=mt?BigInt(Number.MIN_SAFE_INTEGER):void 0,yt=Number.MAX_SAFE_INTEGER.toString(),bt=mt?BigInt(Number.MAX_SAFE_INTEGER):void 0;function wt(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){const n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}function St(t){if(null!=t&&"number"!=typeof t)throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}const Tt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){const e=typeof t;switch(e){case"bigint":return!0;case"number":return Number.isFinite(t)}return"string"===e&&Tt.test(t)}function It(t){if("number"!=typeof t)throw j("int32");if(!Number.isFinite(t))throw j("int32");return 0|t}function Pt(t){return null==t?t:It(t)}function Ot(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 Lt(t){if(null!=t){if("number"!=typeof t)throw j("uint32");if(!Number.isFinite(t))throw j("uint32");t>>>=0}return t}function xt(t){return"-"!==t[0]&&(t.length<20||20===t.length&&Number(t.substring(0,6))<184467)}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asUintN(64,t));if(Et(t)){if("string"===e)return e=Math.trunc(Number(t)),Number.isSafeInteger(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),xt(t)||(pt(t),t=ft(ut,lt))),t;if("number"===e)return(t=Math.trunc(t))>=0&&Number.isSafeInteger(t)?t:function(t){if(t<0){ht(t);const e=ft(ut,lt);return t=Number(e),Number.isSafeInteger(t)?t:e}return xt(String(t))?t:(ht(t),4294967296*lt+(ut>>>0))}(t)}}function Bt(t){return null==t||"string"==typeof t?t:void 0}function Nt(t,e,r){if(null!=t&&"object"==typeof t&&t.M===Z)return t;if(Array.isArray(t)){var n=$(t),i=n;return 0===i&&(i|=32&r),(i|=2&r)!==n&&K(t,i),new e(t)}}function kt(t){var e=jt?.get(t);if(e)return e;if(Math.random()>.01)return t;if(void 0===Dt)if("function"!=typeof Proxy)Dt=null;else try{Dt=-1!==Proxy.toString().indexOf("[native code]")?Proxy:null}catch{Dt=null}return(e=Dt)?(function(t,e){(jt||=new WeakMap).set(t,e),(Ft||=new WeakMap).set(e,t)}(t,e=new e(t,{set:(t,e,r)=>(k(),t[e]=r,!0)})),e):t}let jt,Ft,Dt,Vt,Mt,Ct,Gt;function Rt(t,e,r){if(null==t&&(t=Vt),Vt=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=$(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(et(r[t])){if((e=t-(+!!(512&(n|=256))-1))>=1024)throw Error("pvtlmt");n=-16760833&n|(1023&e)<<14;break t}}if(e){if((e=Math.max(e,i-(+!!(512&n)-1)))>1024)throw Error("spvt");n=-16760833&n|(1023&e)<<14}}}return K(t,n),t}function zt(t,e,r,n,i){if(null!=t){if(Array.isArray(t))t=rt(t)?void 0:i&&2&$(t)?t:Wt(t,e,r,void 0!==n,i);else if(et(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?$(t):0;n=n?!!(32&o):void 0,t=D(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.M===Z?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return(mt?t>=vt&&t<=bt:"-"===t[0]?wt(t,_t):wt(t,yt))?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(rt(t))return}else{if(I(t))return w(t);if(t instanceof U){const e=t.i;return null==e?"":"string"==typeof e?e:t.i=w(e)}}}return t}(t)}function $t(t,e,r=J){if(null!=t){if(y&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var n=$(t);return 2&n?t:(e&&=0===n||!!(32&n)&&!(64&n||!(16&n)),e?(K(t,-12293&(34|n)),t):Wt(t,$t,4&n?J:r,!0,!0))}return t.M===Z&&(r=t.m,t=2&(n=q(r))?t:qt(t,r,n,!0)),t}}function qt(t,e,r,n){return t=t.constructor,Vt=e=function(t,e,r){const n=r||2&e?J:Y,i=!!(32&e);return t=function(t,e,r){var n=(t=D(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))),W(t,32|(r?2:0)),t}(e,r,n),e=new t(e),Vt=void 0,e}function Kt(t){const e=t.m,r=q(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)&&(t.constructor[z]=1+(0|t.constructor[z]))<5&&k(),0!==r&&!(r&e))}function Jt(t,e){return Zt(t=t.m,q(t),e)}function Xt(t,e,r,n){if(!((e=n+(+!!(512&e)-1))<0||e>=t.length||e>=r))return t[e]}function Zt(t,e,r,n){if(-1===r)return null;const i=e>>14&1023||536870912;if(!(r>=i)){var o=t.length;return n&&256&e&&null!=(n=t[o-1][r])?(Xt(t,e,i,r)&&null!=G&&((e=(t=N??={})[G]||0)>=4||(t[G]=e+1,k())),n):Xt(t,e,i,r)}return 256&e?t[t.length-1][r]:void 0}function Qt(t,e,r){const n=t.m;let i=q(n);return it(i),te(n,i,e,r),t}function te(t,e,r,n,i){const o=e>>14&1023||536870912;if(r>=o||i&&!a){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&&K(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=Zt(t,e,r),Array.isArray(t)?t:X}function re(t,e){return 0===t&&(t=le(t,e)),1|t}function ne(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ie(t,e,r,n){t=t.m;let i=q(t);it(i),te(t,i,e,("0"===n?0===Number(r):r===n)?void 0:r)}function oe(t){if(V)return t[R]??(t[R]=new Map);if(R in t)return t[R];const e=new Map;return Object.defineProperty(t,R,{value:e}),e}function se(t,e,r){var n=yn;let i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){const o=n[t];null!=Zt(e,r,o)&&(0!==i&&(r=te(e,r,i)),i=o)}return t.set(n,i),i}function ae(t,e,r){var n=t.m,i=q(n),o=Zt(n,i,r,!1);return(e=Nt(o,e,i))!==o&&null!=e&&te(n,i,r,e,!1),null==(n=e)||(t=t.m,2&(i=q(t))||(o=Kt(n))!==n&&te(t,i,r,n=o,!1)),n}function ue(t,e,r){return null==r&&(r=void 0),Qt(t,e,r)}function le(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function ce(t,e,r){return 32&e&&r||(t&=-33),t}function he(t,e,r,n){t=t.m;var i=q(t);it(i);var o,s=!!(2&i);const a=s?1:2;d&&=!s,s=ee(t,i,e);var u=$(s),l=!!(4&u);if(!l){var c=s,h=i,f=!!(2&(u=re(u,i)));f&&(h|=2);let t=!f,e=!0,n=0,o=0;for(;n<c.length;n++){const i=Nt(c[n],r,h);if(i instanceof r){if(!f){const r=!!(2&$(i.m));t&&=!r,e&&=r}c[o++]=i}}o<n&&(c.length=o),u|=4,u=e?16|u:-17&u,K(c,u=t?8|u:-9&u),f&&Object.freeze(c)}if(d&&!(8&u||!s.length&&(1===a||4===a&&32&u))){ne(u)&&(s=D(s),u=le(u,i),i=te(t,i,e,s));var d=s;for(c=u,u=0;u<d.length;u++)(h=d[u])!==(f=Kt(h))&&(d[u]=f);c|=8,c=d.length?-17&c:16|c,K(d,c),u=c}1===a||4===a&&32&u?ne(u)||(e=u,(u|=!s.length||16&u&&(!l||32&u)?2:2048)!==e&&K(s,u),Object.freeze(s)):(l=5===a&&(!!(32&u)||ne(u)||!!jt?.get(s)),(2===a||l)&&ne(u)&&(s=D(s),u=ce(u=le(u,i),i,!0),K(s,u),i=te(t,i,e,s)),ne(u)||(e=u,(u=ce(u,i,!0))!==e&&K(s,u)),l&&(o=kt(s))),o=o||s,r=null!=n?n:new r,o.push(r),2&$(r.m)?H(o,8):H(o,16)}function fe(t){return t??0}function de(t,e){return fe(function(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}(Jt(t,e)))}function pe(t,e,r){ie(t,e,Pt(r),0)}function ge(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();ie(t,e,r,"")}function me(t,e,r){{const a=t.m;let u=q(a);if(it(u),null==r)te(a,u,e);else{r=Ft?.get(r)||r;var n,i=$(r),o=i,s=!!(2&i)||Object.isFrozen(r);if((n=!s)&&(n=void 0===st||!1),Yt(t,i))for(i=21,s&&(r=D(r),o=0,i=ce(i=le(i,u),u,!0)),t=0;t<r.length;t++)r[t]=It(r[t]);n&&(r=D(r),o=0,i=ce(i=le(i,u),u,!0)),i!==o&&K(r,i),te(a,u,e,r)}}}function _e(t,e,r){t=t.m;const n=q(t);it(n);var i=2&n;let o=Zt(t,n,e);Array.isArray(o)||(o=X);const s=!!(32&n);let a=$(o);if(0===a&&s&&!i?(a|=33,K(o,a)):1&a||(a|=1,K(o,a)),i?(2&a||W(o,34),Object.freeze(o)):(2&a||2048&a)&&(o=D(o),i=1,s&&(i|=32),K(o,i),te(t,n,e,o)),"string"!=typeof r)throw Error();o.push(r)}function ve(t){if("string"==typeof t)return{buffer:E(t),B:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),B:!1};if(t.constructor===Uint8Array)return{buffer:t,B:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),B:!1};if(t.constructor===U){L(P);var e=t.i;return{buffer:(null==(e=null==e||I(e)?e:"string"==typeof e?E(e):null)?e:t.i=e)||new Uint8Array(0),B:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),B:!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")}var ye=class{constructor(t,e){this.m=Rt(t,e)}toJSON(){return be(this)}B(){return!!(2&$(this.m))}};function be(t){t=Gt?t.m:Wt(t.m,Ht,void 0,void 0,!1);{var e=!Gt;let l=t.length;if(l){var r=t[l-1],n=et(r);n?l--:r=void 0;var i=t;if(n){t:{var o=r,s={};if(n=!1,o)for(var a in o){if(isNaN(+a)){s[a]=o[a];continue}let t=o[a];Array.isArray(t)&&(rt(t)||tt(t)&&0===t.size)&&(t=null),null==t&&(n=!0),null!=t&&(s[a]=t)}if(n){for(let t in s)break t;s=null}else s=o}o=null==s?null!=r:s!==r}for(;l>0&&(null==(a=i[l-1])||rt(a)||tt(a)&&0===a.size);l--)var u=!0;(i!==t||o||u)&&(e?(u||o||s)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),s&&i.push(s)),u=i}else u=t}return u}function we(t){return t?/^\d+$/.test(t)?(pt(t),new Se(ut,lt)):null:Ae||=new Se(0,0)}ye.prototype.M=Z,ye.prototype.toString=function(){try{return Gt=!0,be(this).toString()}finally{Gt=!1}};var Se=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Ae;function Te(t){return t?/^-?\d+$/.test(t)?(pt(t),new Ee(ut,lt)):null:Ie||=new Ee(0,0)}var Ee=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Ie;function Pe(t,e,r){for(;r>0||e>127;)t.i.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.i.push(e)}function Oe(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Le(t,e){if(e>=0)Oe(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function xe(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Ue(t,e){return Oe(t.i,8*e+2),e=t.i.end(),xe(t,e),e.push(t.j),e}function Be(t,e){var r=e.pop();for(r=t.j+t.i.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.j++;e.push(r),t.j++}function Ne(t,e,r){Oe(t.i,8*e+2),Oe(t.i,r.length),xe(t,t.i.end()),xe(t,r)}class ke{constructor(t,e){this.i=t,this.P=e}}function je(t,e){if(Array.isArray(e)){var r=$(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),K(e,-12289&(5|r)),2&r&&Object.freeze(e),e}}const Fe=Symbol(),De=Symbol();function Ve(t){let e=t[De];if(!e){const r=Re(t);e=(t,e)=>He(t,e,r),t[De]=e}return e}const Me=Symbol();function Ce(t){return t.i}function Ge(t,e){let r,n;const i=t.i;return(t,o,s)=>i(t,o,s,n||=Re(e).i,r||=Ve(e))}function Re(t){var e=t[Me];if(e)return e;var r=Ce,n=Ge;(e=t[Me]={}).i=function(t){switch(typeof t){case"boolean":return Mt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Ct||=[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.L=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]&&o[0]>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 ke?f=o:(f=pr,i--),f.P){o=t[++i],u=t;var l=i;"function"==typeof o&&(o=o(),u[l]=o),u=o}let d=a+1;for("number"==typeof(o=t[++i])&&o<0&&(d-=o,o=t[++i]);a<d;a++){var c=s[a];l=e;var h=a;c=u?n(f,u):r(f),l[h]=c}}return ze in t&&Fe in t&&Me in t&&(t.length=0),e}const ze=Symbol();function We(t,e){var r=t[e];if(r)return r;if(r=t.L){var n=r[e];if(n){var i=(n=Array.isArray(n)?n[0]instanceof ke?n:[dr,n]:[n,void 0])[0].i;if(n=n[1],r=r.C?.[e],!u||r){if(n){const e=Ve(n),o=Re(n).i;r=(r=t.j)?r(o,e):(t,r,n)=>i(t,r,n,o,e)}else r=i;return t[e]=r}}}}function He(t,e,r){for(var n=q(t),i=+!!(512&n)-1,o=t.length,s=512&n?1:0,a=o+(256&n?-1:0);s<a;s++){const n=t[s];if(null==n)continue;const o=s-i,a=We(r,o);if(!a)continue;const u=r.L;u?.[o]&&!u?.C?.[o]&&qe++<5&&k(),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=We(r,n)))&&((a=r.L)?.[n]&&!a?.C?.[n]&&qe++<5&&k(),o(e,i,n))}}function $e(t){return new ke(t,!1)}let qe=0;function Ke(t,e,r){null!=(e=Ot(e))&&null!=e&&(Oe(t.i,8*r),Le(t.i,e))}function Ye(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Oe(t.i,8*r),t.i.i.push(e?1:0))}function Je(t,e,r){null!=(e=Bt(e))&&Ne(t,r,i(e))}function Xe(t,e,r,n,i){null!=(e=e instanceof ye?e.m:Array.isArray(e)?Rt(e,n[0],n[1]):void 0)&&(r=Ue(t,r),i(e,t),Be(t,r))}function Ze(t,e,r){null!=(e=Ot(e))&&(e=parseInt(e,10),Oe(t.i,8*r),Le(t.i,e))}var Qe,tr=$e((function(t,e,r){null!=(e=At(e))&&(Oe(t.i,8*r+5),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),lt=0,e=ut=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))})),er=$e((function(t,e,r){e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asIntN(64,t));if(Et(t)){if("string"===e){if(e=Math.trunc(Number(t)),Number.isSafeInteger(e))t=String(e);else if(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),!("-"===t[0]?t.length<20||20===t.length&&Number(t.substring(0,7))>-922337:t.length<19||19===t.length&&Number(t.substring(0,6))<922337))if(pt(t),t=ut,2147483648&(e=lt))if(F())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[r,n]=gt(t,e);t="-"+ft(r,n)}else t=ft(t,e);return t}if("number"===e){if(t=Math.trunc(t),!Number.isSafeInteger(t)){ht(t),e=ut;var r=lt;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),e=4294967296*r+(e>>>0),t=t?-e:e}return t}}}(e),null!=e&&("string"==typeof e&&Te(e),null!=e&&(Oe(t.i,8*r),"number"==typeof e?(t=t.i,ht(e),Pe(t,ut,lt)):(r=Te(e),Pe(t.i,r.j,r.i))))})),rr=$e((function(t,e,r){null!=(e=Ut(e))&&("string"==typeof e&&we(e),null!=e&&(Oe(t.i,8*r),"number"==typeof e?(t=t.i,ht(e),Pe(t,ut,lt)):(r=we(e),Pe(t.i,r.j,r.i))))})),nr=$e(Ke),ir=new ke((function(t,e,r){if(null!=(e=je(Ot,e))&&e.length){r=Ue(t,r);for(let r=0;r<e.length;r++)Le(t.i,e[r]);Be(t,r)}}),!1),or=$e(Ke),sr=$e(Ke),ar=$e(Ye),ur=$e(Ye),lr=new ke((function(t,e,r){if(null!=(e=je(Bt,e)))for(let a=0;a<e.length;a++){var n=t,o=r,s=e[a];null!=s&&Ne(n,o,i(s))}}),!1),cr=$e(Je),hr=$e(Je),fr=$e(Je),dr=new ke(Xe,!0),pr=new ke(Xe,!0);Qe=new ke((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 gr=new ke(Xe,!0),mr=$e(Ze),_r=new ke((function(t,e,r){if(null!=(e=je(Ot,e))&&e.length){r=Ue(t,r);for(let r=0;r<e.length;r++)Le(t.i,e[r]);Be(t,r)}}),!1),vr=$e(Ze);function yr(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}}}};He(this.m,e,Re(t)),xe(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 br(t,e){if(null!=e)if(Array.isArray(e))Qt(t,2,Wt(e,Ht,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof U||I(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 U(e,P):x();else if(e.constructor!==U){if(!I(e))throw Error();e=e.length?new U(new Uint8Array(e),P):x()}ie(t,2,e,x())}}var wr=class extends ye{constructor(t){super(t)}},Sr=[0,cr,$e((function(t,e,r){if(null!=e){if(e instanceof ye){const n=e.aa;return void(n&&(e=n(e),null!=e&&Ne(t,r,ve(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||I(e)||e instanceof U?e:void 0)&&Ne(t,r,ve(e).buffer)}))],Ar=[0,fr,ar,-1,nr,[0,[1,2,3,4,5,6],gr,[0],gr,[0,ar,fr,ar,mr,-1,_r,fr,-1,[0,ar,-1],mr,ar],gr,[0,fr,-2],gr,[0,nr,ar,1,ar,-3],gr,[0,nr,mr,ar,-1,ir,mr,-1],gr,[0,fr,-2]],[0,fr],ar,[0,[1,3],[2,4],gr,[0,ir],-1,gr,[0,lr],-1,Qe,[0,fr,-1]],fr],Tr={},Er=Tr.C={};Tr[336783863]=Ar,Er[336783863]=1;var Ir=class extends ye{constructor(t){super(t)}},Pr=[0,er,-1,ur,-3,er,ir,cr,or,er,-1,ur,or,ur,-2,cr],Or=class extends ye{constructor(t){super(t,500)}K(t){return ue(this,7,t)}},Lr=[-1,{C:{}}],xr=[0,fr,1,Lr],Ur=[0,fr,lr,Lr];function Br(t,e){he(t,1,Or,e)}var Nr=class extends ye{constructor(){super(void 0,500)}K(t){return ue(this,1001,t)}};Nr.prototype.i=yr([-500,Qe,[-500,cr,-1,lr,-3,[-2,Tr,ar],Qe,Sr,or,-1,xr,Ur,Qe,[0,cr,ur],cr,Pr,or,lr,987,lr],4,Qe,[-500,fr,-1,[-1,{C:{}}],998,fr],Qe,[-500,fr,lr,-1,[-2,{C:{}},ar],997,lr,-1],or,Qe,[-500,fr,lr,Lr,998,lr],lr,or,xr,Ur,Qe,[0,cr,-1,Lr],lr,-2,Pr,cr,-1,ur,979,Lr,Qe,Sr]);var kr=class extends ye{constructor(t){super(t)}};let jr;const Fr=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 Dr(){if(void 0===jr)try{await WebAssembly.instantiate(Fr),jr=!0}catch{jr=!1}return jr}async function Vr(t,e=""){const r=await Dr()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var Mr=class{};function Cr(){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/))&&t.length>=1&&Number(t[1])>=17))}async function Gr(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())}Mr.forVisionTasks=function(t){return Vr("vision",t)},Mr.forTextTasks=function(t){return Vr("text",t)},Mr.forGenAiExperimentalTasks=function(t){return Vr("genai_experimental",t)},Mr.forGenAiTasks=function(t){return Vr("genai",t)},Mr.forAudioTasks=function(t){return Vr("audio",t)},Mr.isSimdSupported=function(){return Dr()};function Rr(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 zr(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 Wr(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Hr(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 $r=(qr=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:Cr()?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?'),Rr(this,n||"input_audio",(n=>{Rr(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),Rr(this,n,(t=>{this.h._addAudioToInputStream(this.i,e,r,t,i)}))}addGpuBufferToStream(t,e,r){Rr(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){Rr(this,e,(e=>{this.h._addBoolToInputStream(t,e,r)}))}addDoubleToStream(t,e,r){Rr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,r)}))}addFloatToStream(t,e,r){Rr(this,e,(e=>{this.h._addFloatToInputStream(t,e,r)}))}addIntToStream(t,e,r){Rr(this,e,(e=>{this.h._addIntToInputStream(t,e,r)}))}addUintToStream(t,e,r){Rr(this,e,(e=>{this.h._addUintToInputStream(t,e,r)}))}addStringToStream(t,e,r){Rr(this,e,(e=>{Rr(this,t,(t=>{this.h._addStringToInputStream(t,e,r)}))}))}addStringRecordToStream(t,e,r){Rr(this,e,(e=>{zr(this,Object.keys(t),(n=>{zr(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(n,i,Object.keys(t).length,e,r)}))}))}))}addProtoToStream(t,e,r,n){Rr(this,r,(r=>{Rr(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){Rr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,r){Rr(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){Rr(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){Rr(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){Rr(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){Rr(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){Rr(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)Rr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputStream(n,e,r)}))}addBoolToInputSidePacket(t,e){Rr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){Rr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){Rr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){Rr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){Rr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){Rr(this,e,(e=>{Rr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,r){Rr(this,r,(r=>{Rr(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){Rr(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){Rr(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){Rr(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){Rr(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){Rr(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){Rr(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)Rr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputSidePacket(r,e)}))}attachBoolListener(t,e){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){Hr(this,t,e),Rr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){Hr(this,t,e),Rr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){Hr(this,t,e),Rr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){Hr(this,t,e),Rr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){Hr(this,t,e),Rr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){Hr(this,t,e),Rr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,r){Wr(this,t,e),Rr(this,t,(t=>{this.h._attachProtoListener(t,r||!1)}))}attachProtoVectorListener(t,e,r){Hr(this,t,e),Rr(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?'),Wr(this,t,((t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)})),Rr(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 qr{X(){this.h._registerModelResourcesGraphService()}});var qr;async function Kr(t,e){const r=await(async(t,e,r)=>{var n=Ln;if(t&&await Gr(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Gr(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.K(e),r}async function Yr(t,e){return Kr(t,e)}function Jr(t){try{const e=t.H.length;if(1===e)throw Error(t.H[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.H.map((t=>t.message)).join(", "))}finally{t.H=[]}}function Xr(t,e){t.G=Math.max(t.G,e)}var Zr=class{constructor(t){this.i=t,this.H=[],this.G=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.H.push(Error(e))})),this.i.X(),this.i.setGraph(t,e),Jr(this)}finishProcessing(){this.i.finishProcessing(),Jr(this)}close(){this.i.closeGraph()}};Zr.prototype.close=Zr.prototype.close;var Qr=class extends ye{constructor(t){super(t)}};function tn(t,e){ue(t,1,e)}var en=class extends ye{constructor(){super()}},rn=[0,vr,or,tr,-1,nr];function nn(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}}class on{constructor(t){this.i=[],this.data=t,this.length=t.length}}var sn=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 an(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var un=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))}},ln=class extends ye{constructor(){super()}};ln.prototype.i=yr([0,cr,2,lr,or,ur]);var cn=class extends ye{constructor(){super()}},hn=class extends ye{constructor(){super()}},fn=class extends ye{constructor(){super()}},dn=class extends ye{constructor(){super()}},pn=[0,or,-6,1,or,1,[0,ur,vr,-2],[0,ur,tr],vr,-2,[0,ur,-1,vr,tr,mr,nr],1,ur,or,nr,-1,[0,vr,or],ur,-1],gn=[0,[4,6],pn,or,1,sr,lr,hr,_r,[0,cr,-2],nr,[0,[0,or,-1,Qe,[0,or,[0,or,-1],-1,[0,vr,-1],ur],ur,-2,or,-1],[0,or,-1,ur],pn,ur,or]],mn=[0,Qe,[0,cr,rr,-1,vr],gn,or];dn.prototype.i=yr([0,cr,8,[0,ur,-6],1,or,1,or,mn,[0,or,ur,-3],1,vr,cr,gn,mn,or,5,vr,ir,1,rn]);var _n=class extends ye{constructor(){super()}},vn=class extends ye{constructor(){super()}},yn=[2,4];vn.prototype.i=yr([0,yn,or,hr,or,gr,[0,1,cr]]);const bn=function(t){return class e extends t{static async Y(t,r){let n;r||=await e.O();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 O(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}V(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}S(){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),setTimeout((()=>{t.l()}),0),Promise.resolve(0);for(;t.size<r+n;){var o=await t.j();if(void 0===o)break;t.i.push(new on(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 l=Math.min(n,u.length-r);if(void 0===(r=nn(u,r,l,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(r,o+s),r=0,s+=l,0==(n-=l))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{R(t,e){Rr(this,"lora_model_ref_in",(r=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,r,e)}))}}}(class extends $r{})));class wn extends bn{}var Sn=class{constructor(t){this.j=t,this.i=An,An++}},An=0;class Tn{constructor(){let t,e;this.promise=new Promise(((r,n)=>{t=r,e=n})),this.resolve=t,this.reject=e}}async function En(){const t=await wn.O({powerPreference:"high-performance"});var e=t.limits.maxBufferSize;if(t.limits.maxStorageBufferBindingSize<524550144)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(e>=786825216)e=786825216;else{if(!(e>=524550144))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}e={requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e}};const r=t.features.has("chromium-experimental-subgroups"),n=t.features.has("subgroups");if(r||n){console.warn("Experimental Chromium WGSL subgroup support detected. Enabling this feature in the inference engine.");const i=["shader-f16"];n&&(i.push("subgroups"),t.features.has("subgroups-f16")&&i.push("subgroups-f16")),r&&i.push("chromium-experimental-subgroups"),e.requiredFeatures=i}return wn.Y(e,t)}function In(t){const e=function(t){const e=new Nr;_e(e,10,"text_in"),_e(e,10,"token_cost_in"),_e(e,10,"lora_model_id_to_apply_in"),_e(e,10,"lora_model_ref_in"),_e(e,10,"lora_model_id_to_load_in"),_e(e,16,"streaming_reader"),_e(e,15,"text_out"),_e(e,15,"text_end"),_e(e,15,"token_cost_out");var r=new Or;ge(r,2,"TokenizerInputBuildCalculator"),_e(r,3,"PROMPT:text_in"),_e(r,3,"LORA_ID:lora_model_id_to_apply_in"),_e(r,4,"prompt"),Br(e,r),ge(r=new Or,2,"ModelDataCalculator"),_e(r,6,"MODEL_DATA:__side_packet_1"),_e(r,6,"MODEL_TYPE:model_type"),_e(r,5,"READ_DATA_FN:streaming_reader"),_e(r,3,"LORA_MODEL_SPAN:lora_model_ref_in"),_e(r,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),_e(r,4,"LORA_DATA:lora_model_data"),Br(e,r),ge(r=new Or,2,"Gpt2UnicodeMappingCalculator"),_e(r,5,"MODEL_TYPE:model_type"),_e(r,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Br(e,r),ge(r=new wr,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var n,i=new vn,o=de(t.j,2);pe(i,1,o),ge(o=new _n,2,"spm_vocab_model"),null==o&&(o=void 0);t:{var s=i.m,a=q(s);if(it(a),null==o){var u=oe(s);if(4!==se(u,s,a))break t;u.set(yn,0)}else{var l=oe(u=s),c=se(l,u,a);4!==c&&(c&&(a=te(u,a,c)),l.set(yn,4))}te(s,a,4,o)}if(pe(i,3,2),br(r,i.i()),ge(i=new Or,2,"TokenizerCalculator"),he(i,8,wr,r),_e(i,5,"MODEL_DATA:__side_packet_1"),_e(i,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),_e(i,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),_e(i,6,"PROCESSOR_GETTER:__input_side_1"),_e(i,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),Br(e,i),ge(r=new wr,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),pe(i=new dn,12,3),ge(i,1,"llm.tflite"),pe(i,14,0),o=de(t.j,5),pe(i,22,o),o=ae(t.j,Qr,3),ue(i,31,o),ie(o=new cn,1,!0,!1),ie(o,2,!0,!1),ie(o,5,!0,!1),ue(i,10,o),c=t.j,s=void 0===ot?2:5,u=c.m,o=q(u),l=2&o?1:s,s=ee(u,o,4),a=$(s),Yt(c,a,void 0,!1)){(4&a||Object.isFrozen(s))&&(s=D(s),a=le(a,o),o=te(u,o,4,s));let t=c=0;for(;c<s.length;c++){const e=Ot(s[c]);null!=e&&(s[t++]=e)}t<c&&(s.length=t),a=-4097&(20|(a=re(a,o))),K(s,a&=-8193),2&a&&Object.freeze(s)}return 1===l||4===l&&32&a?ne(a)||(o=a,(a|=2)!==o&&K(s,a),Object.freeze(s)):(c=5===l&&(!!(32&a)||ne(a)||!!jt?.get(s)),(2===l||c)&&ne(a)&&(s=D(s),a=ce(a=le(a,o),o,!1),K(s,a),o=te(u,o,4,s)),ne(a)||(u=a,(a=ce(a,o,!1))!==u&&K(s,a)),c&&(n=kt(s))),me(i,29,n||s),n=new fn,pe(o=new hn,1,1),s=de(t.j,2),pe(o,2,s),ue(n,1,o),ue(i,20,n),br(r,i.i()),ge(n=new Or,2,"LlmGpuCalculator"),he(n,8,wr,r),_e(n,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),_e(n,3,"FINISH:finish"),_e(n,3,"LORA_DATA:lora_model_data"),_e(n,5,"MODEL_DATA:__side_packet_1"),_e(n,4,"DECODED_IDS:__stream_3"),_e(n,4,"OUTPUT_END:__stream_4"),ge(r=new Ir,1,"FINISH"),ie(r,2,!0,!1),he(n,13,Ir,r),Br(e,n),ge(n=new Or,2,"IsPacketPresentCalculator"),_e(n,3,"__stream_4"),_e(n,4,"text_end"),Br(e,n),ge(n=new wr,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),r=new ln,t=de(t.j,5),pe(r,5,t),_e(r,4,"<eos>"),_e(r,4,"<|endoftext|>"),br(n,r.i()),ge(t=new Or,2,"DetokenizerCalculator"),he(t,8,wr,n),_e(t,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),_e(t,5,"PROCESSOR_GETTER:__input_side_1"),_e(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),_e(t,5,"MODEL_DATA:__side_packet_1"),_e(t,4,"FINISH_AND_INPUT_OPTIONS:finish"),_e(t,4,"WORDS:text_out"),Br(e,t),ge(t=new Or,2,"TokenCostCalculator"),_e(t,3,"PROMPT:token_cost_in"),_e(t,5,"PROCESSOR_GETTER:__input_side_1"),_e(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),_e(t,4,"NUM_TOKENS:token_cost_out"),Br(e,t),e}(t);t.i.attachStringVectorListener("text_out",((e,r)=>{e=function(t,e){return null==t||0===t.length?[]:t.map((t=>(t=(t=t.replaceAll("▁"," ")).replaceAll("<0x0A>","\n"),e&&(t=t.trimStart()),t.split("\\[eod\\]",1)[0])))}(e,0===t.D.length),e.forEach(((e,r)=>{t.D[r].push(e)})),t.v&&0===t.A.length&&(t.F?t.v(e,!1):t.v(e[0],!1)),Xr(t,r)})),t.i.attachEmptyPacketListener("text_out",(e=>{Xr(t,e)})),t.i.attachBoolListener("text_end",((e,r)=>{if(t.l=!1,Xr(t,r),Pn(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0),t.v)if(t.F){for(e=[],r=0;r<de(t.j,5);r++)e.push("");t.v(e,!0)}else t.v("",!0);t.F=void 0})),t.i.attachEmptyPacketListener("text_end",(e=>{t.l=!1,t.F=void 0,Xr(t,e),Pn(t),t.o&&(t.o.resolve(t.D.map((t=>t.join("")))),t.o=void 0)})),t.i.attachIntListener("token_cost_out",((e,r)=>{t.N=e,Xr(t,r)})),t.J&&t.i.addStreamingReaderToInputSidePacket(t.J,"streaming_reader");const r=e.i();return t.u?.removeEventListener("uncapturederror",t.I),t.i.S().then((()=>{t.u?.addEventListener("uncapturederror",t.I),t.A.length=0,t.setGraph(new Uint8Array(r),!0),t.finishProcessing()}))}function Pn(t){if(t.A.length>0){const e=[...t.A];if(t.A.length=0,!t.o)throw e;t.o.reject(e),t.o=void 0}}function On(t,e,r,n){if(t.l)throw Error("Previous invocation or loading is still ongoing.");for(t.v="function"==typeof r?r:n,t.l=!0,t.D.length=0,n=0;n<de(t.j,5);n++)t.D[n]=[];if(n=t.G+1,t.i.addStringToStream(e,"text_in",n),r instanceof Sn){if(r.j!==t)throw t.l=!1,t.F=void 0,Error("The LoRA model was not loaded by this LLM Inference task.");t.i.addUintToStream(r.i,"lora_model_id_to_apply_in",n)}else t.i.addEmptyPacketToStream("lora_model_id_to_apply_in",n);return t.finishProcessing(),t.o=new Tn,t.o.promise}var Ln=class extends Zr{constructor(t,e){if(super(new wn(t,e)),this.D=[],this.l=!1,this.A=[],this.I=t=>{const e=(t=t.error).message.match(/exceeds the max buffer size limit \(([0-9]+)\)\./);e&&Number(e[1])>524550144?t=Error(`Failed to run this LLM model, but you could try a smaller LLM model. WebGPU throws: "${t.message}"`):t.message.match(/is larger than the maximum binding size/)&&(t=Error(`Failed to run LLM inference, the supported max binding size is smaller than the required size. WebGPU throws: "${t.message}"`)),this.A.push(t)},this.j=new en,tn(this.j,new kr),this.s=new Qr,ue(this.j,3,this.s),Qt(this.j,2,Lt(512)),t=this.s,!Number.isFinite(2))throw j("enum");ie(t,1,2,0),pe(this.s,2,40),ie(this.s,3,St(1),0),Qt(this.s,5,Pt(0)),ie(this.s,4,St(.8),0),Qt(this.j,5,Lt(1))}K(t){if(this.l)throw Error("Cannot set options while loading or processing.");if(this.l=!0,t.baseOptions?.gpuOptions?.device&&(this.u&&this.u.removeEventListener("uncapturederror",this.I),this.u=t.baseOptions.gpuOptions.device,this.i.V(this.u),this.u.addEventListener("uncapturederror",this.I)),"maxTokens"in t&&Qt(this.j,2,Lt(t.maxTokens??512)),"topK"in t&&pe(this.s,2,t.topK??40),"temperature"in t&&ie(this.s,4,St(t.temperature??.8),0),"randomSeed"in t&&Qt(this.s,5,Pt(t.randomSeed??0)),"loraRanks"in t&&function(t,e){me(t,4,e)}(this.j,t.loraRanks??[]),"numResponses"in t){var e=t.numResponses??1;if(e<1)throw Error("'numResponses' must be at least 1.");Qt(this.j,5,Lt(e));var r=ae(this.j,Qr,3);e>1&&r&&(fe(Ot(Jt(r,2)))<=1||fe(function(t){t=t.m;let e=q(t);const r=Zt(t,e,4),n=At(r);return null!=n&&n!==r&&te(t,e,4,n),n}(r))<=0)&&console.warn("To generate multiple responses, it is expected topK > 1 and temperature > 0; otherwise, all the generated responses may be the same.")}let n;if(e=new Promise((t=>{n=t})),t.baseOptions?.modelAssetPath||t.baseOptions?.modelAssetBuffer){if(t.baseOptions.modelAssetPath&&t.baseOptions.modelAssetBuffer)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");r=!1,t.baseOptions.modelAssetPath?this.J=function(t,e){const r=fetch(t.toString()).then((t=>t?.body?.getReader()));return new sn([],(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();return i?void 0:n}),e)}(t.baseOptions.modelAssetPath,n):t.baseOptions.modelAssetBuffer instanceof Uint8Array?(this.J=function(t,e){return new sn([new on(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,n),r=!0):t.baseOptions.modelAssetBuffer?(this.J=function(t,e){return new sn([],(async()=>{const{value:e,done:r}=await t.read();return r?void 0:e}),e)}(t.baseOptions.modelAssetBuffer,n),r=!0):n(),r&&(t.baseOptions.modelAssetBuffer=void 0)}return t=In(this).then((()=>{})),Promise.all([e,t]).then((()=>{this.l=!1,Pn(this)}))}get baseOptions(){return ae(this.j,kr,1)}set baseOptions(t){tn(this.j,t)}T(t,e,r){return de(this.j,5)>1&&console.warn("'numResponses' is set larger than 1 and this function only returns the first response, so we recommend either using 'generateResponses()' to obtain multiple responses, or else setting 'numResponses' to 1 for better performance."),this.F=!1,On(this,t,e,r).then((t=>t[0]))}U(t,e,r){return this.F=!0,On(this,t,e,r)}Z(t){if(this.l)throw Error("Previous invocation or loading is still ongoing.");return this.l=!0,this.N=void 0,this.i.addStringToStream(t,"token_cost_in",this.G+1),this.finishProcessing(),this.l=!1,this.N}async W(t){if(this.l)throw Error("Cannot load LoRA model while loading or processing.");if(this.l=!0,t instanceof Uint8Array){var e=new un(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 un(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 an(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 Sn(this),this.i.R(t,this.G+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.G+1),this.finishProcessing(),an(t),this.l=!1,e}close(){this.u?.removeEventListener("uncapturederror",this.I),super.close()}};Ln.prototype.loadLoraModel=Ln.prototype.W,Ln.prototype.sizeInTokens=Ln.prototype.Z,Ln.prototype.generateResponses=Ln.prototype.U,Ln.prototype.generateResponse=Ln.prototype.T,Ln.prototype.setOptions=Ln.prototype.K,Ln.createWebGpuDevice=En,Ln.createFromModelPath=async function(t,e){return Yr(t,e={baseOptions:{gpuOptions:{device:await En()},modelAssetPath:e}})},Ln.createFromModelBuffer=async function(t,e){return Yr(t,e={baseOptions:{gpuOptions:{device:await En()},modelAssetBuffer:e}})},Ln.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await En();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return Yr(t,e)},exports.FilesetResolver=Mr,exports.LlmInference=Ln,exports.TaskRunner=Zr;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t="undefined"!=typeof self?self:{};function e(e,n){t:{for(var r=["CLOSURE_FLAGS"],i=t,o=0;o<r.length;o++)if(null==(i=i[r[o]])){r=null;break t}r=i}return null!=(e=r&&r[e])?e:n}let n;const r="undefined"!=typeof TextEncoder;function i(t){if(r)t=(n||=new TextEncoder).encode(t);else{let n=0;const r=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)r[n++]=e;else{if(e<2048)r[n++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){const o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,r[n++]=e>>18|240,r[n++]=e>>12&63|128,r[n++]=e>>6&63|128,r[n++]=63&e|128;continue}i--}e=65533}r[n++]=e>>12|224,r[n++]=e>>6&63|128}r[n++]=63&e|128}}t=n===r.length?r:r.subarray(0,n)}return t}var o,s=e(610401301,!1),a=e(653718497,e(1,!0)),u=e(660014094,!1);const l=t.navigator;function c(t){return!!s&&(!!o&&o.brands.some((({brand:e})=>e&&-1!=e.indexOf(t))))}function h(e){var n;return(n=t.navigator)&&(n=n.userAgent)||(n=""),-1!=n.indexOf(e)}function f(){return!!s&&(!!o&&o.brands.length>0)}function d(){return f()?c("Chromium"):(h("Chrome")||h("CriOS"))&&!(!f()&&h("Edge"))||h("Silk")}o=l&&l.userAgentData||null;var p=!f()&&(h("Trident")||h("MSIE"));!h("Android")||d(),d(),h("Safari")&&(d()||!f()&&h("Coast")||!f()&&h("Opera")||!f()&&h("Edge")||(f()?c("Microsoft Edge"):h("Edg/"))||f()&&c("Opera"));var g={},m=null;function _(t){var e=t.length,n=3*e/4;n%3?n=Math.floor(n):-1!="=.".indexOf(t[e-1])&&(n=-1!="=.".indexOf(t[e-2])?n-2:n-1);var r=new Uint8Array(n),i=0;return function(t,e){function n(e){for(;r<t.length;){var n=t.charAt(r++),i=m[n];if(null!=i)return i;if(!/^[\s\xa0]*$/.test(n))throw Error("Unknown base64 encoding at char: "+n)}return e}v();for(var r=0;;){var i=n(-1),o=n(0),s=n(64),a=n(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){r[i++]=t})),i!==n?r.subarray(0,i):r}function v(){if(!m){m={};for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"],n=0;n<5;n++){var r=t.concat(e[n].split(""));g[n]=r;for(var i=0;i<r.length;i++){var o=r[i];void 0===m[o]&&(m[o]=i)}}}}var b="undefined"!=typeof Uint8Array,y=!p&&"function"==typeof btoa;function w(t){if(!y){var e;void 0===e&&(e=0),v(),e=g[e];var n=Array(Math.floor(t.length/3)),r=e[64]||"";let u=0,l=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],n[l++]=a+i+o+s}switch(a=0,s=r,t.length-u){case 2:s=e[(15&(a=t[u+1]))<<2]||r;case 1:t=t[u],n[l]=e[t>>2]+e[(3&t)<<4|a>>4]+s+r}return n.join("")}for(e="",n=0,r=t.length-10240;n<r;)e+=String.fromCharCode.apply(null,t.subarray(n,n+=10240));return e+=String.fromCharCode.apply(null,n?t.subarray(n):t),btoa(e)}const S=/[-_.]/g,A={"-":"+",_:"/",".":"="};function T(t){return A[t]||""}function E(t){if(!y)return _(t);S.test(t)&&(t=t.replace(S,T)),t=atob(t);const e=new Uint8Array(t.length);for(let n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}function I(t){return b&&null!=t&&t instanceof Uint8Array}var P={};let O;function L(t){if(t!==P)throw Error("illegal external caller")}function N(){return O||=new U(null,P)}var U=class{constructor(t,e){if(L(e),this.M=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function x(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}let B;function k(){const e=Error();x(e,"incident"),function(e){t.setTimeout((()=>{throw e}),0)}(e)}function j(t){return x(t=Error(t),"warning"),t}function F(){return"function"==typeof BigInt}function M(t){return Array.prototype.slice.call(t)}var D="function"==typeof Symbol&&"symbol"==typeof Symbol();function V(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?Symbol():t}var C=V(),G=V("2ex"),R=V("1oa"),z=V("0dg"),W=D?(t,e)=>{t[C]|=e}:(t,e)=>{void 0!==t.s?t.s|=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})},H=D?(t,e)=>{t[C]&=~e}:(t,e)=>{void 0!==t.s&&(t.s&=~e)},$=D?t=>0|t[C]:t=>0|t.s,q=D?t=>t[C]:t=>t.s,K=D?(t,e)=>{t[C]=e}:(t,e)=>{void 0!==t.s?t.s=e:Object.defineProperties(t,{s:{value:e,configurable:!0,writable:!0,enumerable:!1}})};function Y(t,e){K(e,-14591&(0|t))}function J(t,e){K(e,-14557&(34|t))}var X,Z={},Q={};function tt(t){return!(!t||"object"!=typeof t||t.i!==Q)}function et(t){return null!==t&&"object"==typeof t&&!Array.isArray(t)&&t.constructor===Object}function nt(t){return!(!Array.isArray(t)||t.length)&&!!(1&$(t))}const rt=[];function it(t){if(2&t)throw Error()}K(rt,55),X=Object.freeze(rt);var ot=Object.freeze({});Object.freeze({});var st=Object.freeze({}),at="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);const ut=Number.MIN_SAFE_INTEGER.toString(),lt=at?BigInt(Number.MIN_SAFE_INTEGER):void 0,ct=Number.MAX_SAFE_INTEGER.toString(),ht=at?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ft(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let n=0;n<t.length;n++){const r=t[n],i=e[n];if(r>i)return!1;if(r<i)return!0}}let dt,pt=0,gt=0;function mt(t){const e=t>>>0;pt=e,gt=(t-e)/4294967296>>>0}function _t(t){if(t<0){mt(-t);const[e,n]=wt(pt,gt);pt=e>>>0,gt=n>>>0}else mt(t)}function vt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var n=""+(4294967296*e+t);else F()?n=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(n=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),n+=8147497*e,e*=2,t>=1e7&&(n+=t/1e7>>>0,t%=1e7),n>=1e7&&(e+=n/1e7>>>0,n%=1e7),n=e+bt(n)+bt(t));return n}function bt(t){return t=String(t),"0000000".slice(t.length)+t}function yt(t){if(t.length<16)_t(Number(t));else if(F())t=BigInt(t),pt=Number(t&BigInt(4294967295))>>>0,gt=Number(t>>BigInt(32)&BigInt(4294967295));else{const e=+("-"===t[0]);gt=pt=0;const n=t.length;for(let r=e,i=(n-e)%6+e;i<=n;r=i,i+=6){const e=Number(t.slice(r,i));gt*=1e6,pt=1e6*pt+e,pt>=4294967296&&(gt+=Math.trunc(pt/4294967296),gt>>>=0,pt>>>=0)}if(e){const[t,e]=wt(pt,gt);pt=t,gt=e}}}function wt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}function St(t){if(null!=t&&"number"!=typeof t)throw Error(`Value of float/double field must be a number, found ${typeof t}: ${t}`);return t}function At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}const Tt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){const e=typeof t;switch(e){case"bigint":return!0;case"number":return Number.isFinite(t)}return"string"===e&&Tt.test(t)}function It(t){if("number"!=typeof t)throw j("int32");if(!Number.isFinite(t))throw j("int32");return 0|t}function Pt(t){return null==t?t:It(t)}function Ot(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 Lt(t){if(null!=t){if("number"!=typeof t)throw j("uint32");if(!Number.isFinite(t))throw j("uint32");t>>>=0}return t}function Nt(t){return"-"!==t[0]&&(t.length<20||20===t.length&&Number(t.substring(0,6))<184467)}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asUintN(64,t));if(Et(t)){if("string"===e)return e=Math.trunc(Number(t)),Number.isSafeInteger(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),Nt(t)||(yt(t),t=vt(pt,gt))),t;if("number"===e)return(t=Math.trunc(t))>=0&&Number.isSafeInteger(t)?t:function(t){if(t<0){_t(t);const e=vt(pt,gt);return t=Number(e),Number.isSafeInteger(t)?t:e}return Nt(String(t))?t:(_t(t),4294967296*gt+(pt>>>0))}(t)}}function xt(t){return null==t||"string"==typeof t?t:void 0}function Bt(t,e,n){if(null!=t&&"object"==typeof t&&t.O===Z)return t;if(Array.isArray(t)){var r=$(t),i=r;return 0===i&&(i|=32&n),(i|=2&n)!==r&&K(t,i),new e(t)}}function kt(t){if(void 0===Mt&&(Mt="function"==typeof Proxy?$t(Proxy):null),!Mt||!Ht())return t;let e=jt?.get(t);return e||(Math.random()>.01?t:(function(t){if(void 0===Vt){const t=new Mt([],{});Vt=1===Array.prototype.concat.call([],t).length}Vt&&"function"==typeof Symbol&&Symbol.isConcatSpreadable&&(t[Symbol.isConcatSpreadable]=!0)}(t),e=new Mt(t,{set:(t,e,n)=>(k(),t[e]=n,!0)}),function(t,e){(jt||=new Dt).set(t,e),(Ft||=new Dt).set(e,t)}(t,e),e))}let jt,Ft,Mt,Dt,Vt,Ct,Gt,Rt,zt,Wt;function Ht(){return void 0===Dt&&(Dt="function"==typeof WeakMap?$t(WeakMap):null),Dt}function $t(t){try{return-1!==t.toString().indexOf("[native code]")?t:null}catch{return null}}function qt(t,e,n){if(a&&Ht()){if(Ct?.get(e)?.get(t)){if(n)return}else if(Math.random()>.01)return;var r=t.length;n={length:r};for(var i=0;i<Math.min(r,10);i++){if(r<=10)var o=i;else{o=r/10;const t=Math.floor(i*o);o=t+Math.floor(Math.random()*(Math.floor((i+1)*o)-t))}n[o]=t[o]}Yt(t,n)?((i=(r=Ct||=new Dt).get(e))||(i=new Dt,r.set(e,i)),i.set(t,n)):(k(),Xt(t,e))}}function Kt(t,e){const n=Ct?.get(e)?.get(t);n&&!Yt(t,n)&&(k(),Xt(t,e))}function Yt(t,e){if(t.length!==e.length)return!1;for(const i in e){var n,r=Number(i);if((n=Number.isInteger(r))&&(n=t[r],r=e[r],n=!(Number.isNaN(n)?Number.isNaN(r):n===r)),n)return!1}return!0}function Jt(t){if(t&&Ct?.has(t)){var e=t.m;if(e)for(let n=0;n<e.length;n++){const r=e[n];if(n===e.length-1&&et(r))for(const e in r){const n=r[e];Array.isArray(n)&&Kt(n,t)}else Array.isArray(r)&&Kt(r,t)}}}function Xt(t,e){Ct?.get(e)?.delete(t)}function Zt(t,e,n){if(null==t&&(t=Gt),Gt=void 0,null==t){var r=96;n?(t=[n],r|=512):t=[],e&&(r=-33521665&r|(1023&e)<<15)}else{if(!Array.isArray(t))throw Error("narr");if(2048&(r=$(t)))throw Error("farr");if(64&r)return t;if(r|=64,n&&(r|=512,n!==t[0]))throw Error("mid");t:{const i=(n=t).length;if(i){const t=i-1;if(et(n[t])){if((e=t-(+!!(512&(r|=256))-1))>=1024)throw Error("pvtlmt");r=-33521665&r|(1023&e)<<15;break t}}if(e){if((e=Math.max(e,i-(+!!(512&r)-1)))>1024)throw Error("spvt");r=-33521665&r|(1023&e)<<15}}}return K(t,r),t}function Qt(t,e,n,r,i){if(null!=t){if(Array.isArray(t))t=nt(t)?void 0:i&&2&$(t)?t:te(t,e,n,void 0!==r,i);else if(et(t)){const o={};for(let s in t)o[s]=Qt(t[s],e,n,r,i);t=o}else t=e(t,r);return t}}function te(t,e,n,r,i){const o=r||n?$(t):0;r=r?!!(32&o):void 0,t=M(t);for(let o=0;o<t.length;o++)t[o]=Qt(t[o],e,n,r,i);return n&&n(o,t),t}function ee(t){return t.O===Z?t.toJSON():function(t){switch(typeof t){case"number":return isFinite(t)?t:String(t);case"bigint":return(at?t>=lt&&t<=ht:"-"===t[0]?ft(t,ut):ft(t,ct))?Number(t):String(t);case"boolean":return t?1:0;case"object":if(t)if(Array.isArray(t)){if(nt(t))return}else{if(I(t))return w(t);if(t instanceof U){const e=t.M;return null==e?"":"string"==typeof e?e:t.M=w(e)}}}return t}(t)}function ne(t,e,n=J){if(null!=t){if(b&&t instanceof Uint8Array)return e?t:new Uint8Array(t);if(Array.isArray(t)){var r=$(t);return 2&r?t:(e&&=0===r||!!(32&r)&&!(64&r||!(16&r)),e?(K(t,-12293&(34|r)),t):te(t,ne,4&r?J:n,!0,!0))}return t.O===Z&&(n=t.m,t=2&(r=q(n))?t:re(t,n,r,!0)),t}}function re(t,e,n,r){return Jt(t),t=t.constructor,Gt=e=function(t,e,n){const r=n||2&e?J:Y,i=!!(32&e);return t=function(t,e,n){var r=(t=M(t)).length;const i=256&e?t[r-1]:void 0;for(r+=i?-1:0,e=512&e?1:0;e<r;e++)t[e]=n(t[e]);if(i){e=t[e]={};for(const t in i)e[t]=n(i[t])}return t}(t,e,(t=>ne(t,i,r))),W(t,32|(n?2:0)),t}(e,n,r),e=new t(e),Gt=void 0,e}function ie(t){const e=t.m,n=q(e);return 2&n?re(t,e,n,!1):t}function oe(t,e,n,r){return!(4&e)||null!=n&&(!r&&0===n&&(4096&e||8192&e)&&(t.constructor[z]=1+(0|t.constructor[z]))<5&&k(),0!==n&&!(n&e))}function se(t,e){return ue(t=t.m,q(t),e)}function ae(t,e,n,r){if(!((e=r+(+!!(512&e)-1))<0||e>=t.length||e>=n))return t[e]}function ue(t,e,n,r){if(-1===n)return null;const i=e>>15&1023||536870912;if(!(n>=i)){var o=t.length;return r&&256&e&&null!=(r=t[o-1][n])?(ae(t,e,i,n)&&null!=G&&((e=(t=B??={})[G]||0)>=4||(t[G]=e+1,k())),r):ae(t,e,i,n)}return 256&e?t[t.length-1][n]:void 0}function le(t,e,n){const r=t.m;let i=q(r);return it(i),ce(r,i,e,n),t}function ce(t,e,n,r){const i=e>>15&1023||536870912;if(n>=i){let o,s=e;if(256&e)o=t[t.length-1];else{if(null==r)return s;o=t[i+(+!!(512&e)-1)]={},s|=256}return o[n]=r,n<i&&(t[n+(+!!(512&e)-1)]=void 0),s!==e&&K(t,s),s}return t[n+(+!!(512&e)-1)]=r,256&e&&(n in(t=t[t.length-1])&&delete t[n]),e}function he(t,e,n,r,i,o){const s=t.m;let a=q(s);r=2&a?1:r,o=!!o,i=fe(s,a,e,i);var u=$(i),l=i;if(Kt(l,t),2!==r&&1!==r||Xt(l,t),oe(t,u,void 0,o)){4&u&&(i=M(i),u=ye(u,a),a=ce(s,a,e,i));let t=l=0;for(;l<i.length;l++){const e=n(i[l]);null!=e&&(i[t++]=e)}t<l&&(i.length=t),u=-4097&(20|(u=de(u,a))),K(i,u&=-8193),2&u&&Object.freeze(i)}let c;return 1===r||4===r&&32&u?pe(u)||(t=u,(u|=2)!==t&&K(i,u),Object.freeze(i)):(n=5===r&&(!!(32&u)||pe(u)||!!jt?.get(i)),(2===r||n)&&pe(u)&&(i=M(i),u=we(u=ye(u,a),a,o),K(i,u),a=ce(s,a,e,i)),pe(u)||(e=u,(u=we(u,a,o))!==e&&K(i,u)),n?(c=kt(i),qt(i,t,!0)):2!==r||o||jt?.delete(i)),c||i}function fe(t,e,n,r){return t=ue(t,e,n,r),Array.isArray(t)?t:X}function de(t,e){return 0===t&&(t=ye(t,e)),1|t}function pe(t){return!!(2&t)&&!!(4&t)||!!(2048&t)}function ge(t,e,n,r){t=t.m;let i=q(t);it(i),ce(t,i,e,("0"===r?0===Number(n):n===r)?void 0:n)}function me(t){if(D)return t[R]??(t[R]=new Map);if(R in t)return t[R];const e=new Map;return Object.defineProperty(t,R,{value:e}),e}function _e(t,e,n){var r=Nr;let i=t.get(r);if(null!=i)return i;i=0;for(let t=0;t<r.length;t++){const o=r[t];null!=ue(e,n,o)&&(0!==i&&(n=ce(e,n,i)),i=o)}return t.set(r,i),i}function ve(t,e,n){var r=t.m,i=q(r),o=ue(r,i,n,!1);return(e=Bt(o,e,i))!==o&&null!=e&&ce(r,i,n,e),null==(r=e)||(t=t.m,2&(i=q(t))||(o=ie(r))!==r&&ce(t,i,n,r=o)),r}function be(t,e,n){return null==n&&(n=void 0),le(t,e,n)}function ye(t,e){return-2049&(t=32|(2&e?2|t:-3&t))}function we(t,e,n){return 32&e&&n||(t&=-33),t}function Se(t,e,n,r){var i=q(t.m);it(i);const o=t.m;var s=!!(2&i);const a=s?1:2;d&&=!s,s=fe(o,i,e);var u=$(s),l=s;if(Kt(l,t),2!==a&&1!==a||Xt(l,t),!(l=!!(4&u))){var c=s,h=i,f=!!(2&(u=de(u,i)));f&&(h|=2);let t=!f,e=!0,r=0,o=0;for(;r<c.length;r++){const i=Bt(c[r],n,h);if(i instanceof n){if(!f){const n=!!(2&$(i.m));t&&=!n,e&&=n}c[o++]=i}}o<r&&(c.length=o),u|=4,u=e?16|u:-17&u,K(c,u=t?8|u:-9&u),f&&Object.freeze(c)}if(d&&!(8&u||!s.length&&(1===a||4===a&&32&u))){pe(u)?(s=M(s),u=ye(u,i),i=ce(o,i,e,s)):Xt(s,t);var d=s;for(c=u,u=0;u<d.length;u++)(h=d[u])!==(f=ie(h))&&(d[u]=f);c|=8,c=d.length?-17&c:16|c,K(d,c),u=c}if(1===a||4===a&&32&u)pe(u)||(t=u,(u|=!s.length||16&u&&(!l||32&u)?2:2048)!==t&&K(s,u),Object.freeze(s));else if(l=5===a&&(!!(32&u)||pe(u)||!!jt?.get(s)),(2===a||l)&&pe(u)&&(s=M(s),u=we(u=ye(u,i),i,!0),K(s,u),i=ce(o,i,e,s)),pe(u)||(e=u,(u=we(u,i,!0))!==e&&K(s,u)),l){var p=kt(s);qt(s,t,!0)}p=p||s,n=null!=r?r:new n,p.push(n),2&$(n.m)?H(p,8):H(p,16)}function Ae(t){return t??0}function Te(t,e){return Ae(function(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}(se(t,e)))}function Ee(t,e,n){ge(t,e,Pt(n),0)}function Ie(t,e,n){if(null!=n&&"string"!=typeof n)throw Error();ge(t,e,n,"")}function Pe(t,e,n){{const a=t.m;let u=q(a);if(it(u),null==n)ce(a,u,e);else{n=Ft?.get(n)||n;var r,i=$(n),o=i,s=!!(2&i)||Object.isFrozen(n);if((r=!s)&&(r=void 0===st||!1),oe(t,i)){i=21,s&&(n=M(n),o=0,i=we(i=ye(i,u),u,!0));for(let t=0;t<n.length;t++)n[t]=It(n[t])}r?(n=M(n),o=0,i=we(i=ye(i,u),u,!0)):s||qt(n,t),i!==o&&K(n,i),ce(a,u,e,n)}}}function Oe(t,e,n){if(it(q(t.m)),e=(t=he(t,e,xt,2,void 0,!0)).push,"string"!=typeof n)throw Error();e.call(t,n)}function Le(t){if("string"==typeof t)return{buffer:E(t),C:!1};if(Array.isArray(t))return{buffer:new Uint8Array(t),C:!1};if(t.constructor===Uint8Array)return{buffer:t,C:!1};if(t.constructor===ArrayBuffer)return{buffer:new Uint8Array(t),C:!1};if(t.constructor===U){L(P);var e=t.M;return{buffer:(null==(e=null==e||I(e)?e:"string"==typeof e?E(e):null)?e:t.M=e)||new Uint8Array(0),C:!0}}if(t instanceof Uint8Array)return{buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),C:!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")}var Ne=class{constructor(t,e){this.m=Zt(t,e)}toJSON(){return Ue(this)}C(){return!!(2&$(this.m))}};function Ue(t){Jt(t),t=Wt?t.m:te(t.m,ee,void 0,void 0,!1);{var e=!Wt;let l=t.length;if(l){var n=t[l-1],r=et(n);r?l--:n=void 0;var i=t;if(r){t:{var o,s=n,a=!1;if(s)for(let t in s)isNaN(+t)?(o??={})[t]=s[t]:(r=s[t],Array.isArray(r)&&(nt(r)||tt(r)&&0===r.size)&&(r=null),null==r&&(a=!0),null!=r&&((o??={})[t]=r));if(a||(o=s),o)for(let t in o){a=o;break t}a=null}s=null==a?null!=n:a!==n}for(;l>0&&(null==(o=i[l-1])||nt(o)||tt(o)&&0===o.size);l--)var u=!0;(i!==t||s||u)&&(e?(u||s||a)&&(i.length=l):i=Array.prototype.slice.call(i,0,l),a&&i.push(a)),u=i}else u=t}return u}function xe(t){return t?/^\d+$/.test(t)?(yt(t),new Be(pt,gt)):null:ke||=new Be(0,0)}Ne.prototype.O=Z,Ne.prototype.toString=function(){try{return Wt=!0,Ue(this).toString()}finally{Wt=!1}};var Be=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let ke;function je(t){return t?/^-?\d+$/.test(t)?(yt(t),new Fe(pt,gt)):null:Me||=new Fe(0,0)}var Fe=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};let Me;function De(t,e,n){for(;n>0||e>127;)t.i.push(127&e|128),e=(e>>>7|n<<25)>>>0,n>>>=7;t.i.push(e)}function Ve(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Ce(t,e){if(e>=0)Ve(t,e);else{for(let n=0;n<9;n++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ge(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function Re(t,e){return Ve(t.i,8*e+2),e=t.i.end(),Ge(t,e),e.push(t.j),e}function ze(t,e){var n=e.pop();for(n=t.j+t.i.length()-n;n>127;)e.push(127&n|128),n>>>=7,t.j++;e.push(n),t.j++}function We(t,e,n){Ve(t.i,8*e+2),Ve(t.i,n.length),Ge(t,t.i.end()),Ge(t,n)}class He{constructor(t,e){this.i=t,this.S=e}}function $e(t,e){if(Array.isArray(e)){var n=$(e);if(4&n)return e;for(var r=0,i=0;r<e.length;r++){const n=t(e[r]);null!=n&&(e[i++]=n)}return i<r&&(e.length=i),K(e,-12289&(5|n)),2&n&&Object.freeze(e),e}}const qe=Symbol();function Ke(t){let e=t[qe];if(!e){const n=Ze(t);e=(t,e)=>tn(t,e,n),t[qe]=e}return e}const Ye=Symbol();function Je(t){return t.i}function Xe(t,e){let n,r;const i=t.i;return(t,o,s)=>i(t,o,s,r||=Ze(e).i,n||=Ke(e))}function Ze(t){var e=t[Ye];if(e)return e;var n=Je,r=Xe;(e=t[Ye]={}).i=function(t){switch(typeof t){case"boolean":return Rt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?zt||=[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]&&o[0]>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 He?f=o:(f=In,i--),f.S){o=t[++i],u=t;var l=i;"function"==typeof o&&(o=o(),u[l]=o),u=o}let d=a+1;for("number"==typeof(o=t[++i])&&o<0&&(d-=o,o=t[++i]);a<d;a++){var c=s[a];l=e;var h=a;c=u?r(f,u):n(f),l[h]=c}}return e}function Qe(t,e){var n=t[e];if(n)return n;if(n=t.N){var r=n[e];if(r){var i=(r=Array.isArray(r)?r[0]instanceof He?r:[En,r]:[r,void 0])[0].i;if(r=r[1],n=n.D?.[e],!u||n){if(r){const e=Ke(r),o=Ze(r).i;n=(n=t.j)?n(o,e):(t,n,r)=>i(t,n,r,o,e)}else n=i;return t[e]=n}}}}function tn(t,e,n){for(var r=q(t),i=+!!(512&r)-1,o=t.length,s=512&r?1:0,a=o+(256&r?-1:0);s<a;s++){const r=t[s];if(null==r)continue;const o=s-i,a=Qe(n,o);if(!a)continue;const u=n.N;u?.[o]&&!u?.D?.[o]&&nn++<5&&k(),a(e,r,o)}if(256&r){t=t[o-1];for(let s in t)r=+s,!Number.isNaN(r)&&(null!=(i=t[s])&&(o=Qe(n,r)))&&((a=n.N)?.[r]&&!a?.D?.[r]&&nn++<5&&k(),o(e,i,r))}}function en(t){return new He(t,!1)}let nn=0;function rn(t,e,n){null!=(e=At(e))&&(Ve(t.i,8*n+5),t=t.i,(n=dt||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),gt=0,e=pt=n.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))}function on(t,e,n){null!=(e=Ot(e))&&null!=e&&(Ve(t.i,8*n),Ce(t.i,e))}function sn(t,e,n){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Ve(t.i,8*n),t.i.i.push(e?1:0))}function an(t,e,n){null!=(e=xt(e))&&We(t,n,i(e))}function un(t,e,n,r,i){e instanceof Ne?(Jt(e),e=e.m):Array.isArray(e)?(e=Zt(e,r[0],r[1]),W(e,16384)):e=void 0,null!=e&&(n=Re(t,n),i(e,t),ze(t,n))}function ln(t,e,n){null!=(e=Ot(e))&&(e=parseInt(e,10),Ve(t.i,8*n),Ce(t.i,e))}var cn,hn=en(rn),fn=en(rn),dn=en((function(t,e,n){if(e=function(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(BigInt.asIntN(64,t));if(Et(t)){if("string"===e){if(e=Math.trunc(Number(t)),Number.isSafeInteger(e))t=String(e);else if(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),!("-"===t[0]?t.length<20||20===t.length&&Number(t.substring(0,7))>-922337:t.length<19||19===t.length&&Number(t.substring(0,6))<922337))if(yt(t),t=pt,2147483648&(e=gt))if(F())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{const[n,r]=wt(t,e);t="-"+vt(n,r)}else t=vt(t,e);return t}if("number"===e){if(t=Math.trunc(t),!Number.isSafeInteger(t)){_t(t),e=pt;var n=gt;(t=2147483648&n)&&(n=~n>>>0,0==(e=1+~e>>>0)&&(n=n+1>>>0)),e=4294967296*n+(e>>>0),t=t?-e:e}return t}}}(e),null!=e){if("string"==typeof e)je(e);if(null!=e)switch(Ve(t.i,8*n),typeof e){case"number":t=t.i,_t(e),De(t,pt,gt);break;case"bigint":n=BigInt.asUintN(64,e),n=new Fe(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),De(t.i,n.j,n.i);break;default:n=je(e),De(t.i,n.j,n.i)}}})),pn=en((function(t,e,n){if(null!=(e=Ut(e))){if("string"==typeof e)xe(e);if(null!=e)switch(Ve(t.i,8*n),typeof e){case"number":t=t.i,_t(e),De(t,pt,gt);break;case"bigint":n=BigInt.asUintN(64,e),n=new Be(Number(n&BigInt(4294967295)),Number(n>>BigInt(32))),De(t.i,n.j,n.i);break;default:n=xe(e),De(t.i,n.j,n.i)}}})),gn=en(on),mn=new He((function(t,e,n){if(null!=(e=$e(Ot,e))&&e.length){n=Re(t,n);for(let n=0;n<e.length;n++)Ce(t.i,e[n]);ze(t,n)}}),!1),_n=en(on),vn=en(on),bn=en(sn),yn=en(sn),wn=en(an),Sn=new He((function(t,e,n){if(null!=(e=$e(xt,e)))for(let a=0;a<e.length;a++){var r=t,o=n,s=e[a];null!=s&&We(r,o,i(s))}}),!1),An=en(an),Tn=en(an),En=new He(un,!0),In=new He(un,!0);cn=new He((function(t,e,n,r,i){if(Array.isArray(e))for(let o=0;o<e.length;o++)un(t,e[o],n,r,i)}),!0);var Pn=new He(un,!0),On=en(ln),Ln=new He((function(t,e,n){if(null!=(e=$e(Ot,e))&&e.length){n=Re(t,n);for(let n=0;n<e.length;n++)Ce(t.i,e[n]);ze(t,n)}}),!1),Nn=en(ln);function Un(t){return function(){Jt(this);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}}}};tn(this.m,e,Ze(t)),Ge(e,e.i.end());const n=new Uint8Array(e.j),r=e.l,i=r.length;let o=0;for(let t=0;t<i;t++){const e=r[t];n.set(e,o),o+=e.length}return e.l=[n],n}}function xn(t,e){if(null!=e)if(Array.isArray(e))le(t,2,te(e,ee,void 0,void 0,!1));else{if(!("string"==typeof e||e instanceof U||I(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 U(e,P):N();else if(e.constructor!==U){if(!I(e))throw Error();e=e.length?new U(new Uint8Array(e),P):N()}ge(t,2,e,N())}}var Bn=class extends Ne{constructor(t){super(t)}},kn=[0,An,en((function(t,e,n){if(null!=e){if(e instanceof Ne){const r=e.ca;return void(r&&(e=r(e),null!=e&&We(t,n,Le(e).buffer)))}if(Array.isArray(e))return}null!=(e=null==e||"string"==typeof e||I(e)||e instanceof U?e:void 0)&&We(t,n,Le(e).buffer)}))],jn=[0,wn,bn,-1,gn,[0,[1,2,3,4,5,6,7],Pn,[0],Pn,[0,bn,wn,bn,On,-1,Ln,wn,-1,[0,bn,-1],On,bn,-1],Pn,[0,wn,-2],Pn,[0,gn,bn,1,bn,-3],Pn,[0,gn,On,bn,-1,mn,On,-1],Pn,[0,wn,-2],Pn,[0,wn,On]],[0,wn],bn,[0,[1,3],[2,4],Pn,[0,mn],-1,Pn,[0,Sn],-1,cn,[0,wn,-1]],wn],Fn={},Mn=Fn.D={};Fn[336783863]=jn,Mn[336783863]=1;var Dn=class extends Ne{constructor(t){super(t)}},Vn=[0,dn,-1,yn,-3,dn,mn,An,_n,dn,-1,yn,_n,yn,-2,An],Cn=class extends Ne{constructor(t){super(t,500)}L(t){return be(this,7,t)}},Gn=[-1,{D:{}}],Rn=[0,wn,1,Gn],zn=[0,wn,Sn,Gn];function Wn(t,e){Se(t,1,Cn,e)}var Hn=class extends Ne{constructor(){super(void 0,500)}L(t){return be(this,1001,t)}};Hn.prototype.i=Un([-500,cn,[-500,An,-1,Sn,-3,[-2,Fn,bn],cn,kn,_n,-1,Rn,zn,cn,[0,An,yn],An,Vn,_n,Sn,987,Sn],4,cn,[-500,wn,-1,[-1,{D:{}}],998,wn],cn,[-500,wn,Sn,-1,[-2,{D:{}},bn],997,Sn,-1],_n,cn,[-500,wn,Sn,Gn,998,Sn],Sn,_n,Rn,zn,cn,[0,An,-1,Gn],Sn,-2,Vn,An,-1,yn,979,Gn,cn,kn]);var $n=class extends Ne{constructor(t){super(t)}};let qn;const Kn=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 Yn(){if(void 0===qn)try{await WebAssembly.instantiate(Kn),qn=!0}catch{qn=!1}return qn}async function Jn(t,e=""){const n=await Yn()?"wasm_internal":"wasm_nosimd_internal";return{wasmLoaderPath:`${e}/${t}_${n}.js`,wasmBinaryPath:`${e}/${t}_${n}.wasm`}}var Xn=class{};function Zn(){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/))&&t.length>=1&&Number(t[1])>=17))}async function Qn(t){if("function"!=typeof importScripts){const e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise(((t,n)=>{e.addEventListener("load",(()=>{t()}),!1),e.addEventListener("error",(t=>{n(t)}),!1),document.body.appendChild(e)}))}importScripts(t.toString())}Xn.forVisionTasks=function(t){return Jn("vision",t)},Xn.forTextTasks=function(t){return Jn("text",t)},Xn.forGenAiExperimentalTasks=function(t){return Jn("genai_experimental",t)},Xn.forGenAiTasks=function(t){return Jn("genai",t)},Xn.forAudioTasks=function(t){return Jn("audio",t)},Xn.isSimdSupported=function(){return Yn()};function tr(t,e,n){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target"),n(e=t.h.stringToNewUTF8(e)),t.h._free(e)}function er(t,e,n){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");const r=new Uint32Array(e.length);for(let n=0;n<e.length;n++)r[n]=t.h.stringToNewUTF8(e[n]);e=t.h._malloc(4*r.length),t.h.HEAPU32.set(r,e>>2),n(e);for(const e of r)t.h._free(e);t.h._free(e)}function nr(t,e,n){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=n}function rr(t,e,n){let r=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(n(r,i),r=[]):r.push(t)}}const ir=(or=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:Zn()?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 n=t.length,r=this.h._malloc(n);this.h.HEAPU8.set(t,r),e?this.h._changeBinaryGraph(n,r):this.h._changeTextGraph(n,r),this.h._free(r)}configureAudio(t,e,n,r,i){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),tr(this,r||"input_audio",(r=>{tr(this,i=i||"audio_header",(i=>{this.h._configureAudio(r,i,t,e,n)}))}))}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,n){this.addAudioToStreamWithShape(t,0,0,e,n)}addAudioToStreamWithShape(t,e,n,r,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),tr(this,r,(t=>{this.h._addAudioToInputStream(this.i,e,n,t,i)}))}addGpuBufferToStream(t,e,n){tr(this,e,(e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();const r=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!r)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!0),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&r.pixelStorei(r.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,n)}))}addBoolToStream(t,e,n){tr(this,e,(e=>{this.h._addBoolToInputStream(t,e,n)}))}addDoubleToStream(t,e,n){tr(this,e,(e=>{this.h._addDoubleToInputStream(t,e,n)}))}addFloatToStream(t,e,n){tr(this,e,(e=>{this.h._addFloatToInputStream(t,e,n)}))}addIntToStream(t,e,n){tr(this,e,(e=>{this.h._addIntToInputStream(t,e,n)}))}addUintToStream(t,e,n){tr(this,e,(e=>{this.h._addUintToInputStream(t,e,n)}))}addStringToStream(t,e,n){tr(this,e,(e=>{tr(this,t,(t=>{this.h._addStringToInputStream(t,e,n)}))}))}addStringRecordToStream(t,e,n){tr(this,e,(e=>{er(this,Object.keys(t),(r=>{er(this,Object.values(t),(i=>{this.h._addFlatHashMapToInputStream(r,i,Object.keys(t).length,e,n)}))}))}))}addProtoToStream(t,e,n,r){tr(this,n,(n=>{tr(this,e,(e=>{const i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputStream(i,t.length,e,n,r),this.h._free(i)}))}))}addEmptyPacketToStream(t,e){tr(this,t,(t=>{this.h._addEmptyPacketToInputStream(t,e)}))}addBoolVectorToStream(t,e,n){tr(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._addBoolVectorToInputStream(r,e,n)}))}addDoubleVectorToStream(t,e,n){tr(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._addDoubleVectorToInputStream(r,e,n)}))}addFloatVectorToStream(t,e,n){tr(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._addFloatVectorToInputStream(r,e,n)}))}addIntVectorToStream(t,e,n){tr(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._addIntVectorToInputStream(r,e,n)}))}addUintVectorToStream(t,e,n){tr(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._addUintVectorToInputStream(r,e,n)}))}addStringVectorToStream(t,e,n){tr(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)tr(this,e,(t=>{this.h._addStringVectorEntry(r,t)}));this.h._addStringVectorToInputStream(r,e,n)}))}addBoolToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addBoolToInputSidePacket(t,e)}))}addDoubleToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addDoubleToInputSidePacket(t,e)}))}addFloatToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addFloatToInputSidePacket(t,e)}))}addIntToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addIntToInputSidePacket(t,e)}))}addUintToInputSidePacket(t,e){tr(this,e,(e=>{this.h._addUintToInputSidePacket(t,e)}))}addStringToInputSidePacket(t,e){tr(this,e,(e=>{tr(this,t,(t=>{this.h._addStringToInputSidePacket(t,e)}))}))}addProtoToInputSidePacket(t,e,n){tr(this,n,(n=>{tr(this,e,(e=>{const r=this.h._malloc(t.length);this.h.HEAPU8.set(t,r),this.h._addProtoToInputSidePacket(r,t.length,e,n),this.h._free(r)}))}))}addBoolVectorToInputSidePacket(t,e){tr(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._addBoolVectorToInputSidePacket(n,e)}))}addDoubleVectorToInputSidePacket(t,e){tr(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._addDoubleVectorToInputSidePacket(n,e)}))}addFloatVectorToInputSidePacket(t,e){tr(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._addFloatVectorToInputSidePacket(n,e)}))}addIntVectorToInputSidePacket(t,e){tr(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._addIntVectorToInputSidePacket(n,e)}))}addUintVectorToInputSidePacket(t,e){tr(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._addUintVectorToInputSidePacket(n,e)}))}addStringVectorToInputSidePacket(t,e){tr(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)tr(this,e,(t=>{this.h._addStringVectorEntry(n,t)}));this.h._addStringVectorToInputSidePacket(n,e)}))}attachBoolListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachBoolListener(t)}))}attachBoolVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachBoolVectorListener(t)}))}attachIntListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachIntListener(t)}))}attachIntVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachIntVectorListener(t)}))}attachUintListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachUintListener(t)}))}attachUintVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachUintVectorListener(t)}))}attachDoubleListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachDoubleListener(t)}))}attachDoubleVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachDoubleVectorListener(t)}))}attachFloatListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachFloatListener(t)}))}attachFloatVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachFloatVectorListener(t)}))}attachStringListener(t,e){nr(this,t,e),tr(this,t,(t=>{this.h._attachStringListener(t)}))}attachStringVectorListener(t,e){rr(this,t,e),tr(this,t,(t=>{this.h._attachStringVectorListener(t)}))}attachProtoListener(t,e,n){nr(this,t,e),tr(this,t,(t=>{this.h._attachProtoListener(t,n||!1)}))}attachProtoVectorListener(t,e,n){rr(this,t,e),tr(this,t,(t=>{this.h._attachProtoVectorListener(t,n||!1)}))}attachAudioListener(t,e,n){this.h._attachAudioListener||console.warn('Attempting to use attachAudioListener without support for output audio. Is build dep ":gl_graph_runner_audio_out" missing?'),nr(this,t,((t,n)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,n)})),tr(this,t,(t=>{this.h._attachAudioListener(t,n||!1)}))}finishProcessing(){this.h._waitUntilIdle()}closeGraph(){this.h._closeGraph(),this.h.simpleListeners=void 0,this.h.emptyPacketListeners=void 0}},class extends or{Z(){this.h._registerModelResourcesGraphService()}});var or;async function sr(t,e){const n=await(async(t,e,n)=>{var r=Gr;if(t&&await Qn(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Qn(e),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((t=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(t.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new r(n,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return await n.L(e),n}async function ar(t,e){return sr(t,e)}function ur(t){try{const e=t.I.length;if(1===e)throw Error(t.I[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.I.map((t=>t.message)).join(", "))}finally{t.I=[]}}function lr(t,e){t.H=Math.max(t.H,e)}var cr=class{constructor(t){this.i=t,this.I=[],this.H=0,this.i.setAutoRenderToScreen(!1)}setGraph(t,e){this.i.attachErrorListener(((t,e)=>{this.I.push(Error(e))})),this.i.Z(),this.i.setGraph(t,e),ur(this)}finishProcessing(){this.i.finishProcessing(),ur(this)}close(){this.i.closeGraph()}};cr.prototype.close=cr.prototype.close;var hr=class extends Ne{constructor(t){super(t)}};function fr(t,e){be(t,1,e)}var dr=class extends Ne{constructor(){super()}},pr=[0,Nn,_n,fn,-1,gn];function gr(t,e,n,r){if(void 0!==t.data){var i=new Uint8Array(t.data.buffer,e,n);return 1===r&&function(t,e,n){t.i.push([e,n]),t.i.sort(((t,e)=>t[0]-e[0])),e=0;for(const[r,i]of t.i){const t=i;(n=r)<=e&&(e=Math.max(e,n+t))}e===t.length&&(t.data=void 0)}(t,e,n),i}}class mr{constructor(t){this.i=[],this.data=t,this.length=t.length}}var _r=class{constructor(t,e,n){this.i=t,this.j=e,this.l=n}get size(){let t=0;for(let e=0;e<this.i.length;e++)t+=this.i[e].length;return t}};function vr(t){if(t.i)try{t.h._free(t.j)}catch{}finally{t.i=!1}}var br=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))}},yr=class extends Ne{constructor(){super()}};yr.prototype.i=Un([0,An,2,Sn,_n,yn]);var wr=class extends Ne{constructor(){super()}},Sr=class extends Ne{constructor(){super()}},Ar=class extends Ne{constructor(){super()}},Tr=class extends Ne{constructor(){super()}},Er=[0,_n,-6,1,_n,1,[0,yn,Nn,-2],[0,yn,fn],Nn,-2,[0,yn,-1,Nn,fn,On,gn],1,yn,_n,gn,-1,[0,Nn,_n],yn,-1,hn],Ir=[0,[4,6],Er,_n,1,vn,Sn,Tn,Ln,[0,An,-2],gn,[0,[0,_n,-1,cn,[0,_n,[0,_n,-1],-1,[0,Nn,-1],yn],yn,-2,_n,-1],[0,_n,-1,yn],Er,yn,_n],wn,-3],Pr=[0,cn,[0,An,pn,-1,Nn],Ir,_n];Tr.prototype.i=Un([0,An,8,[0,yn,-6],1,_n,1,_n,Pr,[0,_n,yn,-3],1,Nn,An,Ir,Pr,_n,5,Nn,mn,1,pr]);var Or=class extends Ne{constructor(){super()}},Lr=class extends Ne{constructor(){super()}},Nr=[2,4];Lr.prototype.i=Un([0,Nr,_n,Tn,_n,Pn,[0,1,An]]);const Ur=function(t){return class e extends t{static async aa(t,n){let r;n||=await e.R();const i=[];for(const e of t?.requiredFeatures??[])n.features.has(e)?i.push(e):console.warn(`WebGPU feature ${e} is not supported.`);t={...t,requiredFeatures:i};try{r=await n.requestDevice(t)}catch(t){throw console.error("Unable to initialize WebGPU with the requested features."),t}return n=await n.requestAdapterInfo(),r.adapterInfo=n,r}static async R(t){if(!(t=await navigator.gpu.requestAdapter(t)))throw Error("Unable to request adapter from navigator.gpu; Ensure WebGPU is enabled.");return t}X(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}U(){return this.h.ccall("closeGraph","void",[],[],{async:!0})}}}(function(t){return class extends t{addStreamingReaderToInputSidePacket(t,e){this.h.addStreamingReaderToInputSidePacket(((e,n,r)=>async function(t,e,n,r,i){if(2===i)return t.i=[],t.j=()=>Promise.resolve(void 0),setTimeout((()=>{t.l()}),0),Promise.resolve(0);for(;t.size<n+r;){var o=await t.j();if(void 0===o)break;t.i.push(new mr(o))}if(t.size<n+r)throw Error(`Data size is too small: ${t.size}, expected at least ${n+r}.`);o=e._malloc(r)>>>0;let s=0;for(let a=0;a<t.i.length;a++){const u=t.i[a];if(n>=u.length){n-=u.length;continue}const l=Math.min(r,u.length-n);if(void 0===(n=gr(u,n,l,i)))throw Error("Data has already been released.");if(e.HEAPU8.set(n,o+s),n=0,s+=l,0==(r-=l))break}if(0!==r)throw Error("Data not found.");return Promise.resolve(o)}(t,this.h,e,n,r)),e)}}}(function(t){return class extends t{T(t,e){tr(this,"lora_model_ref_in",(n=>{this.h._addRawDataSpanToInputStream(t.offset,t.size,n,e)}))}}}(class extends ir{})));class xr extends Ur{}var Br=class{constructor(t){this.j=t,this.i=kr,kr++}},kr=0;class jr{constructor(){let t,e;this.promise=new Promise(((n,r)=>{t=n,e=r})),this.resolve=t,this.reject=e}}function Fr(t){return 1===t?1:t+t%2}async function Mr(){const t=await xr.R({powerPreference:"high-performance"});var e=t.limits.maxBufferSize;if(t.limits.maxStorageBufferBindingSize<524550144)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(e>=786825216)e=786825216;else{if(!(e>=524550144))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}if(e={requiredFeatures:["shader-f16"],requiredLimits:{maxStorageBufferBindingSize:524550144,maxBufferSize:e}},t.features.has("subgroups")){console.warn("Experimental Chromium WGSL subgroup support detected. Enabling this feature in the inference engine.");const n=["shader-f16","subgroups"];t.features.has("subgroups-f16")&&n.push("subgroups-f16"),e.requiredFeatures=n}return xr.aa(e,t)}function Dr(t){const e=function(t){const e=new Hn;Oe(e,10,"text_in"),Oe(e,10,"token_cost_in"),Oe(e,10,"lora_model_id_to_apply_in"),Oe(e,10,"lora_model_ref_in"),Oe(e,10,"lora_model_id_to_load_in"),Oe(e,16,"streaming_reader"),Oe(e,15,"text_out"),Oe(e,15,"text_end"),Oe(e,15,"token_cost_out");var n=new Cn;Ie(n,2,"TokenizerInputBuildCalculator"),Oe(n,3,"PROMPT:text_in"),Oe(n,3,"LORA_ID:lora_model_id_to_apply_in"),Oe(n,4,"prompt"),Wn(e,n),Ie(n=new Cn,2,"ModelDataCalculator"),Oe(n,6,"MODEL_DATA:__side_packet_1"),Oe(n,6,"MODEL_TYPE:model_type"),Oe(n,5,"READ_DATA_FN:streaming_reader"),Oe(n,3,"LORA_MODEL_SPAN:lora_model_ref_in"),Oe(n,3,"LORA_MODEL_ID:lora_model_id_to_load_in"),Oe(n,4,"LORA_DATA:lora_model_data"),Wn(e,n),Ie(n=new Cn,2,"Gpt2UnicodeMappingCalculator"),Oe(n,5,"MODEL_TYPE:model_type"),Oe(n,6,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Wn(e,n),Ie(n=new Bn,1,"type.googleapis.com/odml.infra.proto.TokenizerCalculatorOptions");var r=new Lr,i=Te(t.j,2);Ee(r,1,i),Ie(i=new Or,2,"spm_vocab_model"),null==i&&(i=void 0);t:{var o=r.m,s=q(o);if(it(s),null==i){var a=me(o);if(4!==_e(a,o,s))break t;a.set(Nr,0)}else{const t=me(a=o),e=_e(t,a,s);4!==e&&(e&&(s=ce(a,s,e)),t.set(Nr,4))}ce(o,s,4,i)}return Ee(r,3,2),xn(n,r.i()),Ie(r=new Cn,2,"TokenizerCalculator"),Se(r,8,Bn,n),Oe(r,5,"MODEL_DATA:__side_packet_1"),Oe(r,3,"PROMPT_AND_INPUT_OPTIONS:prompt"),Oe(r,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Oe(r,6,"PROCESSOR_GETTER:__input_side_1"),Oe(r,4,"IDS_AND_INPUT_OPTIONS:__stream_0"),Wn(e,r),Ie(n=new Bn,1,"type.googleapis.com/odml.infra.proto.LlmGpuCalculatorOptions"),Ee(r=new Tr,12,3),Ie(r,1,"llm.tflite"),Ee(r,14,0),i=Fr(Te(t.j,5)),Ee(r,22,i),i=ve(t.j,hr,3),be(r,31,i),ge(i=new wr,1,!0,!1),ge(i,2,!0,!1),ge(i,5,!0,!1),be(r,10,i),i=he(t.j,4,Ot,void 0===ot?2:5),Pe(r,29,i),i=new Ar,Ee(o=new Sr,1,1),a=Te(t.j,2),Ee(o,2,a),be(i,1,o),be(r,20,i),xn(n,r.i()),Ie(r=new Cn,2,"LlmGpuCalculator"),Se(r,8,Bn,n),Oe(r,3,"IDS_AND_INPUT_OPTIONS:__stream_0"),Oe(r,3,"FINISH:finish"),Oe(r,3,"LORA_DATA:lora_model_data"),Oe(r,5,"MODEL_DATA:__side_packet_1"),Oe(r,4,"DECODED_IDS:__stream_3"),Oe(r,4,"OUTPUT_END:__stream_4"),Ie(n=new Dn,1,"FINISH"),ge(n,2,!0,!1),Se(r,13,Dn,n),Wn(e,r),Ie(n=new Cn,2,"IsPacketPresentCalculator"),Oe(n,3,"__stream_4"),Oe(n,4,"text_end"),Wn(e,n),Ie(n=new Bn,1,"type.googleapis.com/odml.infra.proto.DetokenizerCalculatorOptions"),r=new yr,t=Fr(Te(t.j,5)),Ee(r,5,t),Oe(r,4,"<eos>"),Oe(r,4,"<|endoftext|>"),xn(n,r.i()),Ie(t=new Cn,2,"DetokenizerCalculator"),Se(t,8,Bn,n),Oe(t,3,"IDS_AND_INPUT_OPTIONS:__stream_3"),Oe(t,5,"PROCESSOR_GETTER:__input_side_1"),Oe(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Oe(t,5,"MODEL_DATA:__side_packet_1"),Oe(t,4,"FINISH_AND_INPUT_OPTIONS:finish"),Oe(t,4,"WORDS:text_out"),Wn(e,t),Ie(t=new Cn,2,"TokenCostCalculator"),Oe(t,3,"PROMPT:token_cost_in"),Oe(t,5,"PROCESSOR_GETTER:__input_side_1"),Oe(t,5,"BYTES_TO_UNICODE_MAPPING:tokenizer_mapping"),Oe(t,4,"NUM_TOKENS:token_cost_out"),Wn(e,t),e}(t);t.i.attachStringVectorListener("text_out",((e,n)=>{e=function(t,e){return null==t||0===t.length?[]:t.map((t=>(t=(t=t.replaceAll("▁"," ")).replaceAll("<0x0A>","\n"),e&&(t=t.trimStart()),t.split("\\[eod\\]",1)[0])))}(e,0===t.F.length),e.forEach(((e,n)=>{n<Te(t.j,5)&&t.F[n].push(e)})),t.A&&0===t.B.length&&(t.G?(e.length>Te(t.j,5)&&e.pop(),t.A(e,!1)):t.A(e[0],!1)),lr(t,n)})),t.i.attachEmptyPacketListener("text_out",(e=>{lr(t,e)})),t.i.attachBoolListener("text_end",((e,n)=>{if(t.l=!1,lr(t,n),Vr(t),t.o&&(t.o.resolve(t.F.map((t=>t.join("")))),t.o=void 0),t.A)if(t.G){for(e=[],n=0;n<Te(t.j,5);n++)e.push("");t.A(e,!0)}else t.A("",!0);t.G=void 0})),t.i.attachEmptyPacketListener("text_end",(e=>{t.l=!1,t.G=void 0,lr(t,e),Vr(t),t.o&&(t.o.resolve(t.F.map((t=>t.join("")))),t.o=void 0)})),t.i.attachIntListener("token_cost_out",((e,n)=>{t.P=e,lr(t,n)})),t.K&&t.i.addStreamingReaderToInputSidePacket(t.K,"streaming_reader");const n=e.i();return t.v?.removeEventListener("uncapturederror",t.J),t.i.U().then((()=>{t.v?.addEventListener("uncapturederror",t.J),t.B.length=0,t.setGraph(new Uint8Array(n),!0),t.finishProcessing()}))}function Vr(t){if(t.B.length>0){const e=[...t.B];if(t.B.length=0,!t.o)throw e;t.o.reject(e),t.o=void 0}}function Cr(t,e,n,r){if(t.l)throw Error("Previous invocation or loading is still ongoing.");for(t.A="function"==typeof n?n:r,t.l=!0,t.F.length=0,r=0;r<Te(t.j,5);r++)t.F[r]=[];if(r=t.H+1,t.i.addStringToStream(e,"text_in",r),n instanceof Br){if(n.j!==t)throw t.l=!1,t.G=void 0,Error("The LoRA model was not loaded by this LLM Inference task.");t.i.addUintToStream(n.i,"lora_model_id_to_apply_in",r)}else t.i.addEmptyPacketToStream("lora_model_id_to_apply_in",r);return t.finishProcessing(),t.o=new jr,t.o.promise}var Gr=class extends cr{constructor(t,e){super(new xr(t,e)),this.F=[],this.l=!1,this.B=[],this.J=t=>{const e=(t=t.error).message.match(/exceeds the max buffer size limit \(([0-9]+)\)\./);e&&Number(e[1])>524550144?t=Error(`Failed to run this LLM model, but you could try a smaller LLM model. WebGPU throws: "${t.message}"`):t.message.match(/is larger than the maximum binding size/)&&(t=Error(`Failed to run LLM inference, the supported max binding size is smaller than the required size. WebGPU throws: "${t.message}"`)),this.B.push(t)},this.j=new dr,fr(this.j,new $n),this.u=new hr,be(this.j,3,this.u),le(this.j,2,Lt(512)),ge(this.u,1,2,0),Ee(this.u,2,40),ge(this.u,3,St(1),0),le(this.u,5,Pt(0)),ge(this.u,4,St(.8),0),le(this.j,5,Lt(1))}L(t){if(this.l)throw Error("Cannot set options while loading or processing.");if(this.l=!0,t.baseOptions?.gpuOptions?.device&&(this.v&&this.v.removeEventListener("uncapturederror",this.J),this.v=t.baseOptions.gpuOptions.device,this.i.X(this.v),this.v.addEventListener("uncapturederror",this.J)),"maxTokens"in t&&le(this.j,2,Lt(t.maxTokens??512)),"topK"in t&&Ee(this.u,2,t.topK??40),"temperature"in t&&ge(this.u,4,St(t.temperature??.8),0),"randomSeed"in t&&le(this.u,5,Pt(t.randomSeed??0)),"loraRanks"in t&&function(t,e){Pe(t,4,e)}(this.j,t.loraRanks??[]),"numResponses"in t){var e=t.numResponses??1;if(e<1)throw Error("'numResponses' must be at least 1.");le(this.j,5,Lt(e));var n=ve(this.j,hr,3);e>1&&n&&(Ae(Ot(se(n,2)))<=1||Ae(function(t){t=t.m;let e=q(t);const n=ue(t,e,4),r=At(n);return null!=r&&r!==n&&ce(t,e,4,r),r}(n))<=0)&&console.warn("To generate multiple responses, it is expected topK > 1 and temperature > 0; otherwise, all the generated responses may be the same.")}let r;if(e=new Promise((t=>{r=t})),t.baseOptions?.modelAssetPath||t.baseOptions?.modelAssetBuffer){if(t.baseOptions.modelAssetPath&&t.baseOptions.modelAssetBuffer)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");n=!1,t.baseOptions.modelAssetPath?this.K=function(t,e){const n=fetch(t.toString()).then((t=>t?.body?.getReader()));return new _r([],(async()=>{let e;try{e=await n}catch(e){throw Error(`Error loading model from "${t.toString()}": ${e}`)}const{value:r,done:i}=await e.read();return i?void 0:r}),e)}(t.baseOptions.modelAssetPath,r):t.baseOptions.modelAssetBuffer instanceof Uint8Array?(this.K=function(t,e){return new _r([new mr(t)],(()=>Promise.resolve(void 0)),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):t.baseOptions.modelAssetBuffer?(this.K=function(t,e){return new _r([],(async()=>{const{value:e,done:n}=await t.read();return n?void 0:e}),e)}(t.baseOptions.modelAssetBuffer,r),n=!0):r(),n&&(t.baseOptions.modelAssetBuffer=void 0)}return t=Dr(this).then((()=>{})),Promise.all([e,t]).then((()=>{this.l=!1,Vr(this)}))}get baseOptions(){return ve(this.j,$n,1)}set baseOptions(t){fr(this.j,t)}V(t,e,n){return Te(this.j,5)>1&&console.warn("'numResponses' is set larger than 1 and this function only returns the first response, so we recommend either using 'generateResponses()' to obtain multiple responses, or else setting 'numResponses' to 1 for better performance."),this.G=!1,Cr(this,t,e,n).then((t=>t[0]))}W(t,e,n){return this.G=!0,Cr(this,t,e,n)}ba(t){if(this.l)throw Error("Previous invocation or loading is still ongoing.");return this.l=!0,this.P=void 0,this.i.addStringToStream(t,"token_cost_in",this.H+1),this.finishProcessing(),this.l=!1,this.P}async Y(t){if(this.l)throw Error("Cannot load LoRA model while loading or processing.");if(this.l=!0,t instanceof Uint8Array){var e=new br(this.i.h,t.length);e.set(t),t=e}else t=await async function(t,e){var n=await fetch(e.toString());e=Number(n.headers.get("content-length")),t=new br(t,e);let r=0;for(n=n?.body?.getReader();;){const{value:e,done:i}=await n.read();if(i)break;t.set(e,r),r+=e.byteLength}if(e!==r)throw vr(t),Error(`File could not be fully loaded to memory, so was not retained. Loaded ${r}/${e} bytes before failure`);return t}(this.i.h,t);return e=new Br(this),this.i.T(t,this.H+1),this.i.addUintToStream(e.i,"lora_model_id_to_load_in",this.H+1),this.finishProcessing(),vr(t),this.l=!1,e}close(){this.v?.removeEventListener("uncapturederror",this.J),super.close()}};Gr.prototype.loadLoraModel=Gr.prototype.Y,Gr.prototype.sizeInTokens=Gr.prototype.ba,Gr.prototype.generateResponses=Gr.prototype.W,Gr.prototype.generateResponse=Gr.prototype.V,Gr.prototype.setOptions=Gr.prototype.L,Gr.createWebGpuDevice=Mr,Gr.createFromModelPath=async function(t,e){return ar(t,e={baseOptions:{gpuOptions:{device:await Mr()},modelAssetPath:e}})},Gr.createFromModelBuffer=async function(t,e){return ar(t,e={baseOptions:{gpuOptions:{device:await Mr()},modelAssetBuffer:e}})},Gr.createFromOptions=async function(t,e){if(!e.baseOptions?.gpuOptions?.device){const t=await Mr();e.baseOptions=e.baseOptions??{},e.baseOptions.gpuOptions=e?.baseOptions?.gpuOptions??{},e.baseOptions.gpuOptions.device=t}return ar(t,e)},exports.FilesetResolver=Xn,exports.LlmInference=Gr,exports.TaskRunner=cr;
2
2
  //# sourceMappingURL=genai_bundle_cjs.js.map