@mediapipe/tasks-decision 1.2.0-rc.20261028 → 1.2.0-rc.20261029

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/decision.d.ts CHANGED
@@ -453,6 +453,12 @@ export declare class DecisionMaker extends TaskRunner {
453
453
 
454
454
  /**
455
455
  * Options to configure the MediaPipe Semantic Decision Maker Task.
456
+ *
457
+ * Note: On Web, `baseOptions.delegate` defaults to `'GPU'` (WebGPU).
458
+ * `.litertlm` containers with external weights (such as EmbeddingGemma 2 and
459
+ * Gemma 4) require WebGPU on Web and do not support `delegate: 'CPU'`.
460
+ * Setting `baseOptions.delegate` to `'CPU'` on Web is only supported for
461
+ * `.task` or inline `.tflite` models (such as Laya).
456
462
  */
457
463
  export declare interface DecisionMakerOptions extends TaskRunnerOptions {
458
464
  /** Backend type (0=AUTO, 1=ENCODER, 2=DIRECT_LOGIT, 3=EMBEDDING). */
@@ -493,25 +499,11 @@ export declare interface DecisionMakerOptions extends TaskRunnerOptions {
493
499
  /**
494
500
  * Resolves the files required for the MediaPipe Task APIs.
495
501
  *
496
- * This class verifies whether SIMD is supported in the current environment and
497
- * loads the SIMD files only if support is detected. The returned filesets
498
- * require that the Wasm files are published without renaming. If this is not
499
- * possible, you can invoke the MediaPipe Tasks APIs using a manually created
500
- * `WasmFileset`.
502
+ * The returned filesets require that the Wasm files are published without
503
+ * renaming. If this is not possible, you can invoke the MediaPipe Tasks APIs
504
+ * using a manually created `WasmFileset`.
501
505
  */
502
506
  export declare class FilesetResolver {
503
- /**
504
- * Returns whether SIMD is supported in the current environment.
505
- *
506
- * If your environment requires custom locations for the MediaPipe Wasm files,
507
- * you can use `isSimdSupported()` to decide whether to load the SIMD-based
508
- * assets. Note that for ES6 Modules, SIMD is assumed to be always supported.
509
- *
510
- * @param useModule Whether to use ES6 Modules for the Wasm files.
511
- * @export
512
- * @return Whether SIMD support was detected in the current environment.
513
- */
514
- static isSimdSupported(useModule?: boolean): Promise<boolean>;
515
507
  /**
516
508
  * Creates a fileset for the MediaPipe Audio tasks.
517
509
  *
@@ -1,2 +1,2 @@
1
- "use strict";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}var r,n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0,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){let 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=e(610401301,!1),a=e(748402147,!0);function s(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var u,l=t.navigator;u=l&&l.userAgentData||null;var h={},c=null;function f(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;){let e=t.charAt(n++),r=c[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function d(){if(!c){c={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));h[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===c[e]&&(c[e]=t)}}}}var p="undefined"!=typeof Uint8Array,v=!(!(!!o&&(!!u&&u.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,g=/[-_.]/g,m={"-":"+",_:"/",".":"="};function y(t){return m[t]||""}function b(t){if(!v)return f(t);t=g.test(t)?t.replace(g,y):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var w,S={},_=class{constructor(t,e){if(A(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function A(t){if(t!==S)throw Error("illegal external caller")}function B(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var T=void 0;function I(t){return B(t=Error(t),"warning"),t}function x(e,r){if(null!=e){var n=T??={},i=n[e]||0;i>=r||(n[e]=i+1,B(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function E(){return"function"==typeof BigInt}var P="function"==typeof Symbol&&"symbol"==typeof Symbol();function U(t,e,r=!1){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?r&&Symbol.for&&t?Symbol.for(t):null!=t?Symbol(t):Symbol():e}var L,j=U("jas",void 0,!0),k=U(void 0,"1oa"),O=U(void 0,"0ubsb"),N=U(void 0,"0actk"),F=U("m_m","ra",!0),V={ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,M=P?j:"ga",C=[];function G(t,e){P||M in t||D(t,V),t[M]|=e}function $(t,e){P||M in t||D(t,V),t[M]=e}function W(t,e){return 2&e&&(t|=2),1|t}$(C,7),L=Object.freeze(C);var R={};function z(t,e){return void 0===e?t.i!==H&&!!(2&t.m[M]):!!(2&e)&&t.i!==H}var H={};function K(t,e){if(null!=t)if("string"==typeof t)t=t?new _(t,S):w||=new _(null,S);else if(!(t instanceof _))if(p&&null!=t&&t instanceof Uint8Array)t=t.length?new _(new Uint8Array(t),S):w||=new _(null,S);else{if(!e)throw Error();t=void 0}return t}function q(t){return t.qa=!0,t}var J=q(t=>"number"==typeof t),X=q(t=>"string"==typeof t),Y=q(t=>"boolean"==typeof t),Z="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Q(t){var e=t;if(X(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(J(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Z?BigInt(t):t=Y(t)?t?"1":"0":X(t)?t.trim()||"0":String(t)}var tt=q(t=>Z?t>=rt&&t<=it:"-"===t[0]?ot(t,et):ot(t,nt)),et=Number.MIN_SAFE_INTEGER.toString(),rt=Z?BigInt(Number.MIN_SAFE_INTEGER):void 0,nt=Number.MAX_SAFE_INTEGER.toString(),it=Z?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ot(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++){let n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var at,st=0,ut=0;function lt(t){var e=t>>>0;st=e,ut=(t-e)/4294967296>>>0}function ht(t){if(t<0){lt(-t);let[e,r]=gt(st,ut);st=e>>>0,ut=r>>>0}else lt(t)}function ct(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ft(t,e)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else E()?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(){var t=st,e=ut;if(2147483648&e)if(E())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=gt(t,e);t="-"+ft(r,n)}else t=ft(t,e);return t}function vt(t){if(t.length<16)ht(Number(t));else if(E())t=BigInt(t),st=Number(t&BigInt(4294967295))>>>0,ut=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ut=st=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));ut*=1e6,(st=1e6*st+e)>=4294967296&&(ut+=Math.trunc(st/4294967296),ut>>>=0,st>>>=0)}if(e){let[t,e]=gt(st,ut);st=t,ut=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof BigInt?BigInt.asIntN:void 0,yt="function"==typeof BigInt?BigInt.asUintN:void 0,bt=Number.isSafeInteger,wt=Number.isFinite,St=Math.trunc;function _t(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,Bt,Tt,It=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function xt(t){switch(typeof t){case"bigint":return!0;case"number":return wt(t);case"string":return It.test(t);default:return!1}}function Et(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?0|t:void 0}function Pt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(vt(t),pt())}function Ut(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(vt(t),ft(st,ut))}function Lt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(xt(t)){if("string"===e)return e=St(Number(t)),bt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Pt(t)),t;if("number"===e)return function(t){if(t=St(t),!bt(t)){ht(t);var e=st,r=ut;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ct(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function jt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(xt(t)){if("string"===e)return e=St(Number(t)),bt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ut(t)),t;if("number"===e)return function(t){return(t=St(t))>=0&&bt(t)||(ht(t),t=ct(st,ut)),t}(t)}}function kt(t){if(null==t||"string"==typeof t||t instanceof _)return t}function Ot(t){return null==t||"string"==typeof t?t:void 0}function Nt(t,e,r){if(null!=t&&t[F]===R)return t;if(Array.isArray(t)){var n=0|t[M];return(r=n|32&r|2&r)!==n&&$(t,r),new e(t)}}function Ft(t){return t}function Vt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),h=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(At??Ft)(s-h,h,t,c,void 0)+h)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-h;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+h)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Dt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return tt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[M];return 0===t.length&&1&e?void 0:Vt(t,e,Dt)}if(null!=t&&t[F]===R)return Mt(t);if(t instanceof _){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(v){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=h[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.i=e}return t}return}return t}function Mt(t){return Vt(t=t.m,0|t[M],Dt)}function Ct(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[M],a&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(a)throw Error("carr");x(N,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&$(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=64;var o=(r=t).length;if(o){var s=o-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<s&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&s)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return $(t,64|i|n),t}function Gt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[M];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Wt(t,r,!1,e&&!(16&r)):(G(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[F]===R?z(t,r=0|(e=t.m)[M])?t:Kt(t,e,r)?$t(t,e):Wt(e,r):t instanceof _?t:void 0}function $t(t,e,r){return t=new t.constructor(e),r&&(t.i=H),t.o=H,t}function Wt(t,e,r,n){return n??=!!(34&e),t=Vt(t,e,Gt,n),n=32,r&&(n|=2),$(t,e=16769217&e|n),t}function Rt(t){if(t.i!==H)return!1;var e=t.m;return G(e=Wt(e,0|e[M]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function zt(t){if(!Rt(t)&&z(t,0|t.m[M]))throw Error()}function Ht(t,e){void 0===e&&(e=0|t[M]),32&e&&!(4096&e)&&$(t,4096|e)}function Kt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&($(e,2|r),t.i=H,!0)}function qt(t,e,r){if(null!==(t=Jt(t.m,e,void 0,r)))return t}function Jt(t,e,r,n){if(-1===e)return null;var i=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(i>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(i!==o)return;r=a}}else r=t[i];if(n&&null!=r){if(null==(n=n(r)))return n;if(!Object.is(n,r))return s?a[e]=n:t[i]=n,n}return r}}function Xt(t,e,r){zt(t);var n=t.m;return Yt(n,0|n[M],e,r),t}function Yt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[M])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function Zt(t,e,r){return t=Jt(t,e,r),Array.isArray(t)?t:L}function Qt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function te(t){return K(t,!0)}function ee(t){if(P)return t[k]??(t[k]=new Map);if(k in t)return t[k];var e=new Map;return Object.defineProperty(t,k,{value:e}),e}function re(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Jt(e,o)&&(0!==i&&(r=Yt(e,r,i)),i=o)}return t.set(n,i),i}function ne(t,e,r){var n=t.m,i=0|n[M];if(e=function(t,e,r,n){var i=!1;if(null!=(n=Jt(t,n,void 0,t=>{var n=Nt(t,r,e);return i=n!==t&&null!=n,n})))return i&&!z(n)&&Ht(t,e),n}(n,i,e,r),null==e)return e;if(!z(t,i=0|n[M])){var o,a=e;let s=a.m,u=0|s[M];(o=z(a,u)?Kt(a,s,u)?$t(a,s,!0):new a.constructor(Wt(s,u,!1)):a)!==e&&(Rt(t)&&(i=0|(n=t.m)[M]),Ht(n,i=Yt(n,i,r,e=o)))}return e}function ie(t){return null==t&&(t=void 0),t}function oe(t,e,r){return Xt(t,e,r=ie(r)),r&&!z(r)&&Ht(t.m),t}function ae(t,e,r,n){t:{var i=n=ie(n);zt(t);let s=t.m;var o=0|s[M];if(null==i){var a=ee(s);if(re(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=ee(a=s),n=re(t,a,o,r);n!==e&&(n&&(o=Yt(a,o,n)),t.set(r,e))}Yt(s,o,e,i)}return n&&!z(n)&&Ht(t.m),t}function se(t,e){return-273&(2&e?2|t:-3&t)}function ue(t,e){var r=gn;zt(t);var n=t.m,i=n,o=0|n[M],a=(t?z(t,o):2&o)?1:2;2===a&&t&&Rt(t)&&(o=0|(i=t.m)[M]);var s=Zt(i,8),u=s===L?7:0|s[M],l=W(u,o);if(t=!(4&l)){var h=o;let t=!!(2&l);t&&(h|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){let o=Nt(s[i],r,h);if(o instanceof r){if(!t){let t=z(o);e&&=!t,n&&=t}s[a++]=o}}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&($(s,l),2&l&&Object.freeze(s)),l=u=l,(h=Qt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=se(u,o),o=Yt(i,o,8,s),h=!1),h||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&$(s,u),Object.freeze(s)):u!==l&&$(s,u)),2&u||!(4096&u||16&u)||Ht(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===L?7:0|a[M],(e=z(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||Ht(n)}function le(t,e,r){return Xt(t,e,null==r?r:function(t){if(!xt(t))throw I("int64");switch(typeof t){case"string":var e=St(Number(t));return bt(e)?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=E()?Q(mt(64,BigInt(t))):Q(Pt(t))),t;case"bigint":return Q(mt(64,t));default:return bt(t)||(t=St(t),bt(t)?t=String(t):(ht(t),t=pt())),Q(t)}}(r))}function he(t,e,r){return Xt(t,e,null==r?r:function(t){if(!xt(t))throw I("uint64");switch(typeof t){case"string":var e=St(Number(t));return bt(e)&&e>=0?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=E()?Q(yt(64,BigInt(t))):Q(Ut(t))),t;case"bigint":return Q(yt(64,t));default:return t>=0&&bt(t)||((t=St(t))>=0&&bt(t)?t=String(t):(ht(t),t=ft(st,ut))),Q(t)}}(r))}function ce(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Xt(t,e,r)}function fe(t,e,r){if(null!=r){if(!wt(r))throw I("enum");r|=0}return Xt(t,e,r)}var de=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function pe(t){if("string"==typeof t)return new de(b(t),!0);if(Array.isArray(t))return new de(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new de(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new de(t,!1);if(t.constructor===_){A(S);var e=t.i;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?b(e):null)?e:t.i=e)||new Uint8Array(0),new de(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new de(t,!1);throw Error()}function ve(t){return new ye(4294967295&t,Math.floor(t/4294967296))}function ge(t){return t?/^\d+$/.test(t)?(vt(t),new ye(st,ut)):null:me||=new ye(0,0)}var me,ye=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function be(t){return new Pe(4294967295&t,Math.floor(t/4294967296))}function we(t){return t?/^-?\d+$/.test(t)?(vt(t),new Pe(st,ut)):null:Se||=new Pe(0,0)}var Se,_e,Ae,Be,Te,Ie,xe,Ee,Pe=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Ue(t,e,r){return"undefined"!=typeof BigInt64Array?(xe||(xe=new BigInt64Array(1),Ee=new Uint32Array(xe.buffer),xe[0]=BigInt(1),Ie=1===Ee[0]),xe[0]=t,new e(Ee[t=Ie?0:1],Ee[1-t])):(Te||(_e=BigInt(Number.MIN_SAFE_INTEGER),Ae=BigInt(Number.MAX_SAFE_INTEGER),Be=BigInt(4294967295),Te=BigInt(32)),t>=_e&&t<=Ae?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Be),Number(t>>Te))))}function Le(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 je(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function ke(t,e){if(e>=0)je(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Oe(t,e){vt(e),function(t){var e=ut>>31;t(st<<1^e,(ut<<1|st>>>31)^e)}((e,r)=>{Le(t,e>>>0,r>>>0)})}function Ne(t,e){t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255)}var Fe=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function Ve(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function De(t,e,r){je(t.i,8*e+r)}function Me(t,e){return De(t,e,2),e=t.i.end(),Ve(t,e),e.push(t.j),e}function Ce(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 Ge(t,e,r){if(null!=r)switch(De(t,e,0),typeof r){case"number":t=t.i,ht(r),Le(t,st,ut);break;case"bigint":r=Ue(r,Pe,be),Le(t.i,r.j,r.i);break;default:r=we(r),Le(t.i,r.j,r.i)}}function $e(t,e,r){De(t,e,2),je(t.i,r.length),Ve(t,t.i.end()),Ve(t,r)}var We=class{constructor(){this.l=[],this.j=0,this.i=new Fe}};function Re(t){if("string"==typeof t)we(t)}function ze(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var He=ze(),Ke=ze(),qe=ze(),Je=ze(),Xe=ze(),Ye=ze(),Ze=ze(),Qe=ze(),tr=ze(),er=ze(),rr=ze(),nr=ze(),ir=class{constructor(t,e){this.m=Ct(t,e,void 0,2048)}toJSON(){return Mt(this)}};ir.prototype[F]=R,ir.prototype.toString=function(){return this.m.toString()};var or=class{constructor(t,e){this.i=t,t=He,this.j=!!t&&e===t||!1}};function ar(t,e,r,n,i){null!=(e=pr(e,n))&&(r=Me(t,r),i(e,t),Ce(t,r))}var sr,ur,lr=new or(ar,He),hr=new or(ar,He),cr=Symbol(),fr=Symbol();function dr(t){var e=vr,r=gr,n=t[cr];if(n)return n;(n={}).oa=t,n.aa=function(t){switch(typeof t){case"boolean":return Bt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Tt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.ea=i,"function"==typeof(i=t[++o])&&(n.ha=!0,sr??=i,ur??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let h;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof or?h=i:(h=lr,o--),h?.j){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,h,u,t):e(n,s,h,t)}}return t[cr]=n}function pr(t,e){return t instanceof ir?t.m:Array.isArray(t)?Ct(t,e[0],e[1]):void 0}function vr(t,e,r){t[e]=r.i}function gr(t,e,r,n){var i,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=dr(n).aa,i||=mr(n))}function mr(t){var e=t[fr];if(!e){let r=dr(t);e=(t,e)=>yr(t,e,r),t[fr]=e}return e}function yr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[M],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.ea)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof or?r:[hr,r]:[r,void 0])[0].i;if(r=r[1]){let e=mr(r),i=dr(r).aa;r=t.ha?ur(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||x(O,3)}})}function br(t,e,r){if(Array.isArray(e)){var n=0|e[M];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&$(e,t),r&&2&t&&Object.freeze(e),e}}var wr=(t,e)=>{var r=new We;yr(t.m,r,dr(e)),Ve(r,r.i.end()),t=new Uint8Array(r.j);var n=(e=r.l).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.l=[t],t};function Sr(t,e){return new or(t,e)}function _r(t,e){return new or(t,e)}function Ar(t,e,r){null!=(e=Lt(e))&&(Re(e),Ge(t,r,e))}function Br(t,e,r){null!=(e=Et(e))&&null!=e&&(De(t,r,0),ke(t.i,e))}function Tr(t,e,r){null!=(e=Ot(e))&&$e(t,r,i(e))}function Ir(t,e,r,n,i){null!=(e=pr(e,n))&&(r=Me(t,r),i(e,t),Ce(t,r))}function xr(t,e,r){null!=(e=kt(e))&&$e(t,r,pe(e).buffer)}function Er(t,e,r){null!=(e=Et(e))&&(e=parseInt(e,10),De(t,r,0),ke(t.i,e))}var Pr,Ur=Sr(function(t,e,r){null!=(e=_t(e))&&(De(t,r,1),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),st=r.getUint32(0,!0),ut=r.getUint32(4,!0),Ne(t,st),Ne(t,ut))},er),Lr=Sr(function(t,e,r){null!=(e=_t(e))&&(De(t,r,5),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ut=0,Ne(t,st=r.getUint32(0,!0)))},tr),jr=Sr(Ar,Ye),kr=Sr(Ar,Ye),Or=_r(function(t,e,r){if(null!=(e=br(Lt,e,!1)))for(let n=0;n<e.length;n++)Ge(t,r,e[n])},Ye),Nr=Sr(function(t,e,r){if(null!=(e=jt(e))){if("string"==typeof e)ge(e);if(null!=e)switch(De(t,r,0),typeof e){case"number":t=t.i,ht(e),Le(t,st,ut);break;case"bigint":r=Ue(e,ye,ve),Le(t.i,r.j,r.i);break;default:r=ge(e),Le(t.i,r.j,r.i)}}},Ze),Fr=Sr(Br,Je),Vr=_r(function(t,e,r){if(null!=(e=br(Et,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(De(n,i,0),ke(n.i,o))}},Je),Dr=_r(function(t,e,r){if(null!=(e=br(Et,e,!0))&&e.length){r=Me(t,r);for(let r=0;r<e.length;r++)ke(t.i,e[r]);Ce(t,r)}},Je),Mr=Sr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(De(t,r,0),t.i.i.push(e?1:0))},Ke),Cr=Sr(Tr,qe),Gr=_r(function(t,e,r){if(null!=(e=br(Ot,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&$e(n,o,i(a))}},qe),$r=function(t,e,r=He){return new or(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Ir(t,e[o],r,n,i);1&(t=0|e[M])||$(e,1|t)}}),Wr=new or(Ir,He),Rr=Sr(xr,rr),zr=_r(function(t,e,r){if(null!=(e=br(kt,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&$e(n,i,pe(o).buffer)}},rr),Hr=Sr(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(De(t,r,0),je(t.i,e))},Xe),Kr=Sr(Er,nr),qr=Sr(Er,nr),Jr=Sr(function(t,e,r){if(null!=(e=Lt(e))&&(Re(e),null!=e))switch(De(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,lt(r=2*Math.abs(r)),r=st;let n=ut;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),Le(t,st=r,ut=n);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),st=Number(BigInt.asUintN(32,e)),ut=Number(BigInt.asUintN(32,e>>BigInt(32))),Le(t,st,ut);break;default:Oe(t.i,e)}},Qe),Xr=[0,Rr,zr,Mr,Cr],Yr=[0,Sr(Tr,qe),[0,qr,[0,Sr(Ar,Ye),Sr(Br,Je)],qr,-1,[0,Kr],qr,-1],Sr(xr,rr)],Zr=[0,1,[0,12,Fr,10,Mr],[0,7,[0,Fr,-1]]],Qr=globalThis.trustedTypes;var tn=class{constructor(t){this.i=t}toString(){return this.i+""}};function en(t){var e;return void 0===Pr&&(Pr=function(){var t=null;if(!Qr)return t;try{let e=t=>t;t=Qr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Pr)?e.createScriptURL(t):t,new tn(t)}function rn(t,...e){if(0===e.length)return en(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return en(r)}var nn,on=class extends ir{constructor(t){super(t)}},an=class extends ir{constructor(t){super(t)}},sn=class extends ir{constructor(t){super(t)}},un=[1,2,3,4,5,6],ln=class extends ir{constructor(t){super(t)}j(){return null!=qt(this,1,te)}l(){return null!=Ot(qt(this,2))}},hn=class extends ir{constructor(t){super(t)}},cn=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 fn(t){if(t)return!0;if(void 0===nn)try{await WebAssembly.instantiate(cn),nn=!0}catch{nn=!1}return nn}async function dn(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await fn(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var pn=class{};function vn(t){return fe(new gn,1,t)}pn.forVisionTasks=function(t,e=!1){return dn("vision",t??rn``,e)},pn.forLiteRtLmTextTasks=function(t,e=!1){return dn("litertlm_text",t??rn``,e)},pn.forTextTasks=function(t,e=!1){return dn("text",t??rn``,e)},pn.forRetrievalTasks=function(t,e=!1){return dn("retrieval",t??rn``,e)},pn.forGenAiTasks=function(t,e=!1){return dn("genai",t??rn``,e)},pn.forDecisionTasks=function(t,e=!1){return dn("decision",t??rn``,e)},pn.forAudioTasks=function(t,e=!1){return dn("audio",t??rn``,e)},pn.isSimdSupported=function(t=!1){return fn(t)};var gn=class extends ir{constructor(t){super(t)}},mn=class extends ir{constructor(t){super(t)}},yn=[0,Kr,2,Nr,-2,kr,$r,[0,Kr,kr]],bn=class extends ir{constructor(t){super(t)}},wn=class extends ir{constructor(t){super(t)}};function Sn(t){var e=new An;return e=fe(e,1,30),fe(e,2,t)}var _n,An=class extends ir{constructor(t){super(t)}},Bn=[3,4,5,6,7],Tn=class extends ir{constructor(t){super(t)}},In=class extends ir{constructor(t){super(t)}};In.prototype.j=(_n=[0,[0,Kr,Cr,-3,Kr],[0,Bn,Kr,-1,Wr,[0,Kr,Cr,Nr],Wr,yn,Wr,[0,1,yn],Wr,[0,Kr],Wr,[0,Kr,Cr,Nr]]],function(){return wr(this,_n)});var xn=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var n=this.i?new AbortController:void 0,i=n&&t.V>0?setTimeout(()=>{n.abort()},t.V):void 0;try{let i=await fetch(t.url,{method:t.na,headers:{...t.ma},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.V&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},En=class extends ir{constructor(t){super(t,37)}},Pn=[-4,{},Zr,Kr,Yr],Un=[0,Cr,Kr,1,Cr,-1,Kr,1,Kr,1,kr],Ln=[0,Kr,Cr,-2],jn=[0,Cr,Kr],kn=[0,Cr,Kr],On=[0,Mr,-3],Nn=[0,Kr,Cr,-1,kr,Fr,-1,Cr,-5,$r,[0,Cr,-4],-1,Mr,[0,Mr,-3],Kr];var Fn=class extends ir{constructor(t){super(t,19)}},Vn=function(t){return e=>wr(e,t)}([-19,{},[0,Kr,1,[0,Cr,-6,kr,Fr,Cr,-1,kr],1,[0,Cr,1,Cr,-5],Cr,-1,[0,Kr,Cr,-8],[0,Cr,-3],[0,Cr,Kr,Cr,-2],[0,Cr,-1,Kr,Cr,-1,Kr,Cr,-1,[0,$r,[0,Cr,-1],Mr,Cr,-5],[0,Kr,Mr,Fr,-2]],kr,[0,Cr,-3,kr,Fr,Cr,-1],[0,Kr,Cr,-1],[0,Cr,-9],[0,Cr,-6,Kr,Cr,1,Cr,Mr,Kr,-1,Mr,Cr,-2,Kr,Cr,Kr,Cr,Fr,-1],1,[0,Kr],1,[0,Cr,-4],1,Un,[0,[1,2,3,4,5,6],Wr,Un,Wr,jn,Wr,kn,Wr,[0,Kr],Wr,Nn,Wr,Ln],jn,kn,Nn,[0,[0,Kr,Cr,-1,kr,Fr,-1,Cr,-4,$r,[0,Cr,-4],-1,1,On],[0,Kr,Cr,-1,kr,Fr,-1,Cr,-4,On]],Ln,[0,Cr,[0,Fr,-3,Kr],Kr,-2,[0,Fr,-1],Mr],4,[0,Cr,Kr,Cr,-1,kr,Kr,Cr,-1,Kr,Fr,-1]],Kr,$r,[-37,{},jr,Cr,$r,[0,Cr,-1],Rr,1,Rr,[0,Gr,-1,Vr,Or,-1],Cr,[0,Fr,Cr,-1],Mr,Fr,kr,Cr,-1,Jr,Xr,jr,Rr,Kr,Vr,kr,-1,[0,Kr,-1],Cr,Mr,Cr,Dr,Cr,-1,Ur,1,Ur,Pn,Mr,[0,Kr,[0,Lr,Fr,-2],[0,Lr]],[0,Kr,kr]],jr,zr,Cr,-1,jr,Kr,-1,[0,Mr,-1,Kr,Mr],[0,kr,-1,Cr],[0,jr,Mr,kr],kr,1,Hr,1,Pn]),Dn=class{constructor(t){this.j=[],this.o=new xn,this.l=t??"",this.i=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.i&&(clearInterval(this.i),this.i=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.j.length)t?.();else{var r=this.j;this.j=[],r=function(t){var e=new Fn;zt(e=fe(e,2,1786));var r=e.m,n=0|r[M];if(null==t)Yt(r,n,3);else{var i=t===L?7:0|t[M],o=i,a=Qt(i),s=a||Object.isFrozen(t),u=!0,l=!0;for(let e=0;e<t.length;e++){var h=t[e];a||(h=z(h),u&&=!h,l&&=h)}a||(i=u?13:5,i=l?-4097&i:4096|i),s&&i===o||(t=Array.prototype.slice.call(t),o=0,i=se(i,n)),i!==o&&$(t,i),n=Yt(r,n,3,t),2&i||!(4096&i||16&i)||Ht(r,n)}return e}(r),r=Vn(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",na:"POST",V:1e4,body:r,pa:2,ma:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.l},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.j=[],void 0!==this.i&&(clearInterval(this.i),this.i=void 0),e?.("net-send-failed",t)})}}};class Mn{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Cn(t,e){var r=new In;r=oe(r,1,t.L),r=oe(r,2,e),e=Xt(e=new En,6,K(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Gn(t,e){var r={F:e.F-t.l.F,H:e.H-t.l.H,G:e.G-t.l.G,B:e.B-t.l.B,I:e.I-t.l.I,D:e.D,M:e.M},n=Sn(1);r=$n(t,r),Cn(t,n=ae(n,4,Bn,r)),t.l=e}function $n(t,e){var r=new mn;return t=he(t=le(t=fe(r,1,t.J),7,e.B),5,e.D),t=he(t,6,e.M),e.G>0&&he(t,4,e.I/e.G),0!==e.F&&ue(t,r=le(r=vn(3),2,e.F)),0!==e.H&&ue(t,e=le(r=vn(4),2,e.H)),t}var Wn=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Mn,this.l=new Mn,this.C=new Dn(e),this.J=function(t){switch(t){case"IMAGE":return 11;case"VIDEO":return 12;case"LIVE_STREAM":return 13;case"AUDIO_CLIPS":return 14;case"AUDIO_STREAM":return 15;default:return 10}}(t),t=new Tn,"undefined"==typeof navigator?e=0:(e=navigator.userAgent,e=/Android/i.test(e)?1:/iPhone|iPad|iPod/i.test(e)?2:/Windows/i.test(e)?5:/Macintosh/i.test(e)?4:/Linux/i.test(e)?3:0),t=ce(t=fe(t,1,e),2,""),t=ce(t,3,""),t=ce(t,4,"1.2.0"),t=ce(t,5,""),this.L=fe(t,6,function(){var t=globalThis.__HOST_ENVIRONMENT__;if("string"==typeof t)switch(t){case"ANDROID":return 1;case"IOS":return 2;case"PYTHON":return 3;case"WEB":break;case"FLUTTER":return 5;case"FLUTTER_WEB":return 6;default:return 0}return 4}())}Z(){var t=new wn;t=he(t=fe(t,1,this.J),3,performance.now()-this.K),Cn(this,t=ae(Sn(0),3,Bn,t)),this.o=performance.now()}S(t){var e=this.j.get(t);if(void 0!==e&&(this.j.delete(t),t=performance.now()-e,++this.i.G,this.i.I+=t,this.i.D=Math.max(this.i.D,t),this.A=Math.max(this.A,t),performance.now()>this.o+3e4)){for(let[r,n]of this.j.entries())t=r,n<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Gn(this,e)}}ia(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Gn(this,t);var e=new bn;e=oe(e,2,t=$n(this,t)),Cn(this,e=ae(t=Sn(2),5,Bn,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Rn(){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 zn(t){if("function"!=typeof importScripts){let 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)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}function Hn(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 Kn(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var 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(let e of n)t.h._free(e);t.h._free(e)}function qn(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Jn(t,e,r){var n=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(r(n,i),n=[]):n.push(t)}}var Xn=function(t){return class extends t{get W(){return this.h}fa(){if("function"==typeof this.W._mediapipeLoggerGetEncodedApiKey){let t=this.W._mediapipeLoggerGetEncodedApiKey();return this.W._decodeBase64(t)}}}}(function(t){return class extends t{la(){this.h._registerModelResourcesGraphService()}}}(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:Rn()?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){var 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){var 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?'),Hn(this,n||"input_audio",n=>{Hn(this,i=i||"audio_header",i=>{this.h._configureAudio(n,i,t,e??0,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){var 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),Hn(this,n,t=>{this.h._addAudioToInputStream(this.i,e,r,t,i)})}addGpuBufferToStream(t,e,r){Hn(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var 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);var[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);var[a,s]=[i,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Hn(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Hn(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Hn(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Hn(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Hn(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Hn(this,e,e=>{Hn(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Hn(this,e,e=>{Kn(this,Object.keys(t),n=>{Kn(this,Object.values(t),i=>{this.h._addFlatHashMapToInputStream(n,i,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,n){Hn(this,r,r=>{Hn(this,e,e=>{var 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){Hn(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Hn(this,e,e=>{var n=this.h._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(n,e);this.h._addBoolVectorToInputStream(n,e,r)})}addDoubleVectorToStream(t,e,r){Hn(this,e,e=>{var n=this.h._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(n,e);this.h._addDoubleVectorToInputStream(n,e,r)})}addFloatVectorToStream(t,e,r){Hn(this,e,e=>{var n=this.h._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(n,e);this.h._addFloatVectorToInputStream(n,e,r)})}addIntVectorToStream(t,e,r){Hn(this,e,e=>{var n=this.h._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(n,e);this.h._addIntVectorToInputStream(n,e,r)})}addUintVectorToStream(t,e,r){Hn(this,e,e=>{var n=this.h._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(n,e);this.h._addUintVectorToInputStream(n,e,r)})}addStringVectorToStream(t,e,r){Hn(this,e,e=>{var n=this.h._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Hn(this,e,t=>{this.h._addStringVectorEntry(n,t)});this.h._addStringVectorToInputStream(n,e,r)})}addBoolToInputSidePacket(t,e){Hn(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Hn(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Hn(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Hn(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Hn(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Hn(this,e,e=>{Hn(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Hn(this,r,r=>{Hn(this,e,e=>{var 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){Hn(this,e,e=>{var r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)})}addDoubleVectorToInputSidePacket(t,e){Hn(this,e,e=>{var r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)})}addFloatVectorToInputSidePacket(t,e){Hn(this,e,e=>{var r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)})}addIntVectorToInputSidePacket(t,e){Hn(this,e,e=>{var r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)})}addUintVectorToInputSidePacket(t,e){Hn(this,e,e=>{var r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)})}addStringVectorToInputSidePacket(t,e){Hn(this,e,e=>{var r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Hn(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){qn(this,t,e),Hn(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Jn(this,t,e),Hn(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){qn(this,t,e),Hn(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Jn(this,t,e),Hn(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){qn(this,t,e),Hn(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Jn(this,t,e),Hn(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){qn(this,t,e),Hn(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Jn(this,t,e),Hn(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){qn(this,t,e),Hn(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Jn(this,t,e),Hn(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){qn(this,t,e),Hn(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Jn(this,t,e),Hn(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){qn(this,t,e),Hn(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Jn(this,t,e),Hn(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?'),qn(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Hn(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}})),Yn=class extends Xn{};async function Zn(t,e){var r=await(async(t,e,r)=>{var n=gi;if(t&&await zn(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await zn(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 Qn(r,e),await r.T(e),r}function Qn(t,e){e=e.sa??"";var r=t.j.fa();t.l=new Wn(e,r)}function ti(t,e){try{t.j.h.FS_unlink("/model.litertlm")}catch{}t.j.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!1),ce(e=ne(t.baseOptions,ln,1)||new ln,2,"/model.litertlm"),Xt(e,1),oe(t.baseOptions,1,e)}function ei(t,e,r=!0){if(r){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(ne(t.baseOptions,ln,1)?.j()||ne(t.baseOptions,ln,1)?.l()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){var r=ne(t.baseOptions,sn,3);if(!r){var n=r=new sn,i=new an;ae(n,4,un,i)}"delegate"in e&&("GPU"===e.delegate?(e=r,n=new on,ae(e,2,un,n)):(e=r,n=new an,ae(e,4,un,n))),oe(t.baseOptions,3,r)}(t,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${t.status})`)}).then(e=>{ti(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)ti(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(r.modelAssetBuffer).then(e=>{ti(t,e)})}return Promise.resolve()}function ri(t){try{let e=t.o.length;if(1===e)throw Error(t.o[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.o.map(t=>t.message).join(", "))}finally{t.o=[]}}var ni=class{constructor(t){this.j=t,this.o=[],this.j.setAutoRenderToScreen(!1)}setGraph(t,e){this.j.attachErrorListener((t,e)=>{this.o.push(Error(e))}),this.j.la(),this.j.setGraph(t,e),this.l?.Z(),ri(this)}finishProcessing(t){this.j.finishProcessing(),ri(this),this.l&&void 0!==t&&this.l.S(t)}close(){this.l?.ia(),this.l?.close(),this.j.closeGraph()}};function ii(t,e){var r="object"==typeof t&&null!==t,n=(r?t.imageBytes:void 0)??e?.imageBytes;return e=(r?t.audioSamples:void 0)??e?.audioSamples,{text:r?t.text??"":t,imageBytes:n,audioSamples:e,N:!!(n&&n.byteLength>0)||!!(e&&e.length>0)}}function oi(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function ai(t){var e={};if(t.criteria)for(let[r,n]of Object.entries(t.criteria))e[r]=n;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function si(t){if(t.options&&t.options.length>0){var e=t.options.map(t=>t.description?`${t.label}: ${t.description}`:t.label),r=(t=t.options.map(t=>t.label)).map(t=>Number(t)),n=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=n?r:t.map((t,e)=>e),{rubric:e,labels:t,R:r,P:n}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),n=e.map((t,e)=>e),{rubric:e,labels:t,R:n,P:!1}}function ui(t,e,r,n){var i=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<i.length;t++){let e=i[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:n&&i.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}ni.prototype.close=ni.prototype.close;var li=[];async function hi(t,e){var r=li.pop();if(r){Qn(t=new gi(r,null),e);try{return await t.T(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Zn(t,e)}(t,e)}function ci(t,e){var r=t.X.then(()=>{var r=t.ba++;return t.l&&(1===t.backendType||-1===t.backendType?function(t,e){++t.i.F,t.j.set(e,performance.now())}(t.l,r):function(t,e){++t.i.H,t.j.set(e,performance.now())}(t.l,r)),Promise.resolve().then(e).then(e=>(t.l?.S(r),e),e=>{throw t.l?.S(r),e})});return t.X=r.then(()=>{},()=>{}),r}function fi(t){if(!t)return 0;var e=t.context?oi(t.context):0;for(let r of t.questions??[]){e+=oi(r.prompt)+4;for(let t of r.options??[])e+=oi(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function di(t){if(t.byteLength>=30&&80===t[0]&&75===t[1]&&3===t[2]&&4===t[3]){let e=t[26]|t[27]<<8;if(e+(t=t[28]|t[29]<<8)<=4096)return 30+e+t}return 0}function pi(t,e,r=0){if(t=t.j.h,e<64){if(!(r=t._malloc(e)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:r,v:r}}if(!(t=t._malloc(e+64)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:(t+r+63&-64)-r>>>0,v:t}}async function vi(t,e,r,n){var i=t.j.h;if(r instanceof Uint8Array){var o=r.byteLength;if(0===o)return{u:0,v:0,size:0};let{u:e,v:n}=pi(t,o,di(r));return i.HEAPU8.set(r,e),{u:e,v:n,size:o}}if(n=n&&n>0?n:0,!r&&e){if(e=e.toString(),!(r=await fetch(e)).ok||!r.body)throw Error(`Failed to fetch asset: ${e} (${r.status})`);(e=Number(r.headers.get("content-length")||0))>0&&(n=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(n>0){e=[];for(var a=0;a<30;){let{value:t,done:n}=await r.read();if(n)break;t&&t.byteLength>0&&(e.push(t),a+=Number(t.byteLength))}if(0===a)return{u:0,v:0,size:0};let u=e[0];if(u.byteLength<30&&e.length>1)for(var s of(u=new Uint8Array(Math.min(a,30)),a=0,e)){let t=Math.min(s.byteLength,u.byteLength-a);if(u.set(s.subarray(0,t),a),(a+=t)>=u.byteLength)break}let{u:l,v:h}=pi(t,n,di(u));for(o of(t=0,e)){if(t+(s=Number(o.byteLength))>n)throw i._free(h),Error(`Stream exceeded expected content-length (${n} bytes).`);i.HEAPU8.set(o,l+t>>>0),t+=s}for(e.length=0;;){let{value:e,done:a}=await r.read();if(a)break;if(e&&e.byteLength>0){if(t+(o=Number(e.byteLength))>n)throw i._free(h),Error(`Stream exceeded expected content-length (${n} bytes).`);i.HEAPU8.set(e,l+t>>>0),t+=o}}return{u:l,v:h,size:t}}for(o=[],n=0;;){let{value:t,done:e}=await r.read();if(e)break;t&&t.byteLength>0&&(s=Number(t.byteLength),o.push(t),n+=s)}if(0===n)return{u:0,v:0,size:0};r=o[0];var{u:u,v:l}=pi(t,n,r?di(r):0);for(t=0,r=0;r<o.length;r++)(s=o[r])&&(i.HEAPU8.set(s,u+t>>>0),t+=s.byteLength,o[r]=void 0);return{u:u,v:l,size:n}}var gi=class extends ni{constructor(t,e){super(new Yn(t,e)),this.baseOptions=new hn,this.L=this.C=this.K=this.A=this.i=this.maxNumTokens=this.backendType=0,this.Y=!1,this.ba=this.J=0,this.X=Promise.resolve()}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}U(t){this.O=t,this.J=fi(t)}async ka(t){if(0!==this.i){var e=t.questions??[];if(0!==e.length){var r=this.j.h;"function"==typeof r.prewarmSchema?await ci(this,()=>r.prewarmSchema(this.i,t.context??"",e)):await ci(this,()=>r.evaluateSchema(this.i,"__PREWARM__",t.context??"",e))}}}async ja(t,e){return t=e?.context?`${e.context}\n${t}`:t,fi(this.O)+oi(t)}async T(t){if(0!==this.i)throw Error("Decision does not support updating options after initialization.");if("CPU"===t.baseOptions?.delegate?this.backendType=-1:void 0!==t.backendType&&(this.backendType=t.backendType),void 0!==t.maxNumTokens&&(this.maxNumTokens=t.maxNumTokens),t.schema?this.U(t.schema):(t.questions||t.context||t.expectedInputs)&&this.U({context:t.context,expectedInputs:t.expectedInputs,questions:t.questions}),-1===this.backendType){this.j.h.preinitializedWebGPUDevice=void 0;var e="undefined"!=typeof self?self:globalThis;"object"==typeof e.Module&&e.Module&&(e.Module.preinitializedWebGPUDevice=void 0)}else if("undefined"!=typeof navigator&&navigator.gpu)try{if(!(e=this.j.h).preinitializedWebGPUDevice){var r=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),n=r?.info,i=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${n?.vendor??""} ${n?.architecture??""} ${n?.description??""}`);if(r&&!i){for(var o of(i=[],["shader-f16","subgroups"]))r.features.has(o)&&i.push(o);o={};for(let t of["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize","maxTextureDimension2D"]){let e=r.limits[t];"number"==typeof e&&(o[t]=e)}let t=await r.requestDevice({requiredFeatures:i,requiredLimits:o});if(!t.adapterInfo&&n)try{Object.defineProperty(t,"adapterInfo",{value:n,writable:!0,configurable:!0})}catch{try{t.adapterInfo=n}catch{}}e.preinitializedWebGPUDevice=t}}e.preinitializedWebGPUDevice&&("object"==typeof(r=self).Module&&r.Module&&(r.Module.preinitializedWebGPUDevice=e.preinitializedWebGPUDevice))}catch(t){console.warn("WebGPU device initialization failed:",t)}if(r=e=this.j.h,(n=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await vi(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,n=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await vi(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,n=e.size}catch(t){console.warn("Optional companion per-layer embedder not loaded:",t)}this.i=await e.createDecisionFromBuffers(this.A,r.size,this.C,n,this.backendType,this.maxNumTokens)}else await ei(this,t,n),this.i=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.Z()}evaluateBoolean(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,n=e.context?`${e.context}\n${e.condition}`:e.condition,i=ii(t,e);return i.N?ci(this,()=>r.evaluateContextBoolean(this.i,i.text,n,e.threshold??.5,e.temperature??0,{imageBytes:i.imageBytes,audioSamples:i.audioSamples})):ci(this,()=>r.evaluateBoolean(this.i,i.text,n,e.threshold??.5,e.temperature??0))}evaluateChoice(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,n=ai(e),i=e.instructions??"",o=e.context?i?`${e.context}\n${i}`:e.context:i,a=ii(t,e);return t=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),a.N||t?ci(this,()=>r.evaluateContextChoice(this.i,a.text,n,e.options??[],e.temperature??0,o,{imageBytes:a.imageBytes,audioSamples:a.audioSamples})):ci(this,()=>r.evaluateChoice(this.i,a.text,n,e.temperature??0,o))}async evaluateScore(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,{rubric:n,labels:i,R:o,P:a}=si(e),s=e.instructions??"",u=e.context?s?`${e.context}\n${s}`:e.context:s,l=ii(t,e);return ui(t=l.N?await ci(this,()=>r.evaluateContextScore(this.i,l.text,n,e.temperature??0,u,{imageBytes:l.imageBytes,audioSamples:l.audioSamples})):await ci(this,()=>r.evaluateScore(this.i,l.text,n,e.temperature??0,u)),i,o,a)}async evaluate(t,e,r){if(0===this.i)throw Error("Decision is already closed.");if(r?.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");var n=ii(t,r),i=r?.context?n.text?`${r.context}\n${n.text}`:r.context:n.text,o=e.context;t=(n.imageBytes&&n.imageBytes.byteLength>0?70:0)+(n.audioSamples&&n.audioSamples.length>0?Math.ceil(n.audioSamples.length/640):0),this.J=fi(e)+oi(i)+t;var a=this.j.h,s=e.questions??[];return 0===s.length?{}:(e=s.some(t=>(t.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0)),n.N||e?ci(this,()=>a.evaluateContextSchema(this.i,i,o??"",s,{imageBytes:n.imageBytes,audioSamples:n.audioSamples})):ci(this,()=>a.evaluateSchema(this.i,i,o??"",s)))}async da(t,e,r){var n=[];for(let i of t)n.push(await this.evaluate(i,e,r));return n}async ca(t,e){if(!this.O)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.O,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var n=this.j.h,i=e.context?`${e.context}\n${e.condition}`:e.condition;if("function"==typeof n.evaluateBooleanBatch)return ci(this,()=>n.evaluateBooleanBatch(this.i,t,i,e.threshold??.5,e.temperature??0,r));var o=[];for(let n of t)o.push(await this.evaluateBoolean(r?`${r}\n${n}`:n,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var n=this.j.h,i=ai(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if("function"==typeof n.evaluateChoiceBatch)return ci(this,()=>n.evaluateChoiceBatch(this.i,t,i,e.temperature??0,a,r));o=[];for(let n of t)o.push(await this.evaluateChoice(r?`${r}\n${n}`:n,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var n=this.j.h,{rubric:i,labels:o,R:a,P:s}=si(e),u=e.instructions??"",l=e.context?u?`${e.context}\n${u}`:e.context:u;if("function"==typeof n.evaluateScoreBatch)return(await ci(this,()=>n.evaluateScoreBatch(this.i,t,i,e.temperature??0,l,r))).map(t=>ui(t,o,a,s));u=[];for(let n of t)u.push(await this.evaluateScore(r?`${r}\n${n}`:n,e));return u}close(){if(!this.Y){this.Y=!0;var t=this.j.h;if(0!==this.i){try{t.deleteDecision(this.i)}catch{}this.i=0}var e=this.K||this.A;if(0!==e){try{t._free(e)}catch{}this.K=this.A=0}if(0!==(e=this.L||this.C)){try{t._free(e)}catch{}this.L=this.C=0}super.close(),t&&!li.includes(t)&&li.push(t)}}};gi.prototype.close=gi.prototype.close,gi.prototype.evaluateScoreBatch=gi.prototype.evaluateScoreBatch,gi.prototype.evaluateChoiceBatch=gi.prototype.evaluateChoiceBatch,gi.prototype.evaluateBooleanBatch=gi.prototype.evaluateBooleanBatch,gi.prototype.classify=gi.prototype.ca,gi.prototype.evaluateBatch=gi.prototype.da,gi.prototype.evaluate=gi.prototype.evaluate,gi.prototype.evaluateScore=gi.prototype.evaluateScore,gi.prototype.evaluateChoice=gi.prototype.evaluateChoice,gi.prototype.evaluateBoolean=gi.prototype.evaluateBoolean,gi.prototype.setOptions=gi.prototype.T,gi.prototype.measureContextUsage=gi.prototype.ja,gi.prototype.prewarm=gi.prototype.ka,gi.prototype.setSchema=gi.prototype.U,gi.createFromModelBuffer=function(t,e,r=0,n=0){return hi(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:n})},gi.createFromModelPath=function(t,e,r=0,n=0){return hi(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:n})},gi.createFromOptions=hi,exports.DecisionMaker=gi,exports.FilesetResolver=pn,exports.TaskRunner=ni;
1
+ "use strict";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}var r,n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0,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){let 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=e(610401301,!1),a=e(748402147,!0);function s(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var u,l=t.navigator;u=l&&l.userAgentData||null;var h={},c=null;function f(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;){let e=t.charAt(n++),r=c[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function d(){if(!c){c={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));h[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===c[e]&&(c[e]=t)}}}}var p="undefined"!=typeof Uint8Array,v=!(!(!!o&&(!!u&&u.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,g=/[-_.]/g,m={"-":"+",_:"/",".":"="};function y(t){return m[t]||""}function b(t){if(!v)return f(t);t=g.test(t)?t.replace(g,y):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var w,S={},_=class{constructor(t,e){if(A(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function A(t){if(t!==S)throw Error("illegal external caller")}function B(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var T=void 0;function I(t){return B(t=Error(t),"warning"),t}function x(e,r){if(null!=e){var n=T??={},i=n[e]||0;i>=r||(n[e]=i+1,B(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function E(){return"function"==typeof BigInt}var P="function"==typeof Symbol&&"symbol"==typeof Symbol();function L(t,e,r=!1){return"function"==typeof Symbol&&"symbol"==typeof Symbol()?r&&Symbol.for&&t?Symbol.for(t):null!=t?Symbol(t):Symbol():e}var U,j=L("jas",void 0,!0),k=L(void 0,"1oa"),O=L(void 0,"0ubsb"),N=L(void 0,"0actk"),F=L("m_m","ra",!0),V={ga:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,M=P?j:"ga",C=[];function G(t,e){P||M in t||D(t,V),t[M]|=e}function $(t,e){P||M in t||D(t,V),t[M]=e}function W(t,e){return 2&e&&(t|=2),1|t}$(C,7),U=Object.freeze(C);var R={};function z(t,e){return void 0===e?t.i!==H&&!!(2&t.m[M]):!!(2&e)&&t.i!==H}var H={};function K(t,e){if(null!=t)if("string"==typeof t)t=t?new _(t,S):w||=new _(null,S);else if(!(t instanceof _))if(p&&null!=t&&t instanceof Uint8Array)t=t.length?new _(new Uint8Array(t),S):w||=new _(null,S);else{if(!e)throw Error();t=void 0}return t}function q(t){return t.qa=!0,t}var J=q(t=>"number"==typeof t),X=q(t=>"string"==typeof t),Y=q(t=>"boolean"==typeof t),Z="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Q(t){var e=t;if(X(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(J(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Z?BigInt(t):t=Y(t)?t?"1":"0":X(t)?t.trim()||"0":String(t)}var tt=q(t=>Z?t>=rt&&t<=it:"-"===t[0]?ot(t,et):ot(t,nt)),et=Number.MIN_SAFE_INTEGER.toString(),rt=Z?BigInt(Number.MIN_SAFE_INTEGER):void 0,nt=Number.MAX_SAFE_INTEGER.toString(),it=Z?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ot(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++){let n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var at,st=0,ut=0;function lt(t){var e=t>>>0;st=e,ut=(t-e)/4294967296>>>0}function ht(t){if(t<0){lt(-t);let[e,r]=gt(st,ut);st=e>>>0,ut=r>>>0}else lt(t)}function ct(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ft(t,e)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else E()?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(){var t=st,e=ut;if(2147483648&e)if(E())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=gt(t,e);t="-"+ft(r,n)}else t=ft(t,e);return t}function vt(t){if(t.length<16)ht(Number(t));else if(E())t=BigInt(t),st=Number(t&BigInt(4294967295))>>>0,ut=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ut=st=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));ut*=1e6,(st=1e6*st+e)>=4294967296&&(ut+=Math.trunc(st/4294967296),ut>>>=0,st>>>=0)}if(e){let[t,e]=gt(st,ut);st=t,ut=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof BigInt?BigInt.asIntN:void 0,yt="function"==typeof BigInt?BigInt.asUintN:void 0,bt=Number.isSafeInteger,wt=Number.isFinite,St=Math.trunc;function _t(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,Bt,Tt,It=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function xt(t){switch(typeof t){case"bigint":return!0;case"number":return wt(t);case"string":return It.test(t);default:return!1}}function Et(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?0|t:void 0}function Pt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(vt(t),pt())}function Lt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(vt(t),ft(st,ut))}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(xt(t)){if("string"===e)return e=St(Number(t)),bt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Pt(t)),t;if("number"===e)return function(t){if(t=St(t),!bt(t)){ht(t);var e=st,r=ut;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ct(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function jt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(xt(t)){if("string"===e)return e=St(Number(t)),bt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Lt(t)),t;if("number"===e)return function(t){return(t=St(t))>=0&&bt(t)||(ht(t),t=ct(st,ut)),t}(t)}}function kt(t){if(null==t||"string"==typeof t||t instanceof _)return t}function Ot(t){return null==t||"string"==typeof t?t:void 0}function Nt(t,e,r){if(null!=t&&t[F]===R)return t;if(Array.isArray(t)){var n=0|t[M];return(r=n|32&r|2&r)!==n&&$(t,r),new e(t)}}function Ft(t){return t}function Vt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),h=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(At??Ft)(s-h,h,t,c,void 0)+h)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-h;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+h)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Dt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return tt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[M];return 0===t.length&&1&e?void 0:Vt(t,e,Dt)}if(null!=t&&t[F]===R)return Mt(t);if(t instanceof _){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(v){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=h[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.i=e}return t}return}return t}function Mt(t){return Vt(t=t.m,0|t[M],Dt)}function Ct(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[M],a&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(a)throw Error("carr");x(N,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&$(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=64;var o=(r=t).length;if(o){var s=o-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<s&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&s)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return $(t,64|i|n),t}function Gt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[M];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Wt(t,r,!1,e&&!(16&r)):(G(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[F]===R?z(t,r=0|(e=t.m)[M])?t:Kt(t,e,r)?$t(t,e):Wt(e,r):t instanceof _?t:void 0}function $t(t,e,r){return t=new t.constructor(e),r&&(t.i=H),t.o=H,t}function Wt(t,e,r,n){return n??=!!(34&e),t=Vt(t,e,Gt,n),n=32,r&&(n|=2),$(t,e=16769217&e|n),t}function Rt(t){if(t.i!==H)return!1;var e=t.m;return G(e=Wt(e,0|e[M]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function zt(t){if(!Rt(t)&&z(t,0|t.m[M]))throw Error()}function Ht(t,e){void 0===e&&(e=0|t[M]),32&e&&!(4096&e)&&$(t,4096|e)}function Kt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&($(e,2|r),t.i=H,!0)}function qt(t,e,r){if(null!==(t=Jt(t.m,e,void 0,r)))return t}function Jt(t,e,r,n){if(-1===e)return null;var i=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(i>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(i!==o)return;r=a}}else r=t[i];if(n&&null!=r){if(null==(n=n(r)))return n;if(!Object.is(n,r))return s?a[e]=n:t[i]=n,n}return r}}function Xt(t,e,r){zt(t);var n=t.m;return Yt(n,0|n[M],e,r),t}function Yt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[M])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function Zt(t,e,r){return t=Jt(t,e,r),Array.isArray(t)?t:U}function Qt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function te(t){return K(t,!0)}function ee(t){if(P)return t[k]??(t[k]=new Map);if(k in t)return t[k];var e=new Map;return Object.defineProperty(t,k,{value:e}),e}function re(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Jt(e,o)&&(0!==i&&(r=Yt(e,r,i)),i=o)}return t.set(n,i),i}function ne(t,e,r){var n=t.m,i=0|n[M];if(e=function(t,e,r,n){var i=!1;if(null!=(n=Jt(t,n,void 0,t=>{var n=Nt(t,r,e);return i=n!==t&&null!=n,n})))return i&&!z(n)&&Ht(t,e),n}(n,i,e,r),null==e)return e;if(!z(t,i=0|n[M])){var o,a=e;let s=a.m,u=0|s[M];(o=z(a,u)?Kt(a,s,u)?$t(a,s,!0):new a.constructor(Wt(s,u,!1)):a)!==e&&(Rt(t)&&(i=0|(n=t.m)[M]),Ht(n,i=Yt(n,i,r,e=o)))}return e}function ie(t){return null==t&&(t=void 0),t}function oe(t,e,r){return Xt(t,e,r=ie(r)),r&&!z(r)&&Ht(t.m),t}function ae(t,e,r,n){t:{var i=n=ie(n);zt(t);let s=t.m;var o=0|s[M];if(null==i){var a=ee(s);if(re(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=ee(a=s),n=re(t,a,o,r);n!==e&&(n&&(o=Yt(a,o,n)),t.set(r,e))}Yt(s,o,e,i)}return n&&!z(n)&&Ht(t.m),t}function se(t,e){return-273&(2&e?2|t:-3&t)}function ue(t,e){var r=dn;zt(t);var n=t.m,i=n,o=0|n[M],a=(t?z(t,o):2&o)?1:2;2===a&&t&&Rt(t)&&(o=0|(i=t.m)[M]);var s=Zt(i,8),u=s===U?7:0|s[M],l=W(u,o);if(t=!(4&l)){var h=o;let t=!!(2&l);t&&(h|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){let o=Nt(s[i],r,h);if(o instanceof r){if(!t){let t=z(o);e&&=!t,n&&=t}s[a++]=o}}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&($(s,l),2&l&&Object.freeze(s)),l=u=l,(h=Qt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=se(u,o),o=Yt(i,o,8,s),h=!1),h||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&$(s,u),Object.freeze(s)):u!==l&&$(s,u)),2&u||!(4096&u||16&u)||Ht(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===U?7:0|a[M],(e=z(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||Ht(n)}function le(t,e,r){return Xt(t,e,null==r?r:function(t){if(!xt(t))throw I("int64");switch(typeof t){case"string":var e=St(Number(t));return bt(e)?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=E()?Q(mt(64,BigInt(t))):Q(Pt(t))),t;case"bigint":return Q(mt(64,t));default:return bt(t)||(t=St(t),bt(t)?t=String(t):(ht(t),t=pt())),Q(t)}}(r))}function he(t,e,r){return Xt(t,e,null==r?r:function(t){if(!xt(t))throw I("uint64");switch(typeof t){case"string":var e=St(Number(t));return bt(e)&&e>=0?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=E()?Q(yt(64,BigInt(t))):Q(Lt(t))),t;case"bigint":return Q(yt(64,t));default:return t>=0&&bt(t)||((t=St(t))>=0&&bt(t)?t=String(t):(ht(t),t=ft(st,ut))),Q(t)}}(r))}function ce(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Xt(t,e,r)}function fe(t,e,r){if(null!=r){if(!wt(r))throw I("enum");r|=0}return Xt(t,e,r)}var de=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function pe(t){if("string"==typeof t)return new de(b(t),!0);if(Array.isArray(t))return new de(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new de(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new de(t,!1);if(t.constructor===_){A(S);var e=t.i;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?b(e):null)?e:t.i=e)||new Uint8Array(0),new de(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new de(t,!1);throw Error()}function ve(t){return new ye(4294967295&t,Math.floor(t/4294967296))}function ge(t){return t?/^\d+$/.test(t)?(vt(t),new ye(st,ut)):null:me||=new ye(0,0)}var me,ye=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function be(t){return new Pe(4294967295&t,Math.floor(t/4294967296))}function we(t){return t?/^-?\d+$/.test(t)?(vt(t),new Pe(st,ut)):null:Se||=new Pe(0,0)}var Se,_e,Ae,Be,Te,Ie,xe,Ee,Pe=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Le(t,e,r){return"undefined"!=typeof BigInt64Array?(xe||(xe=new BigInt64Array(1),Ee=new Uint32Array(xe.buffer),xe[0]=BigInt(1),Ie=1===Ee[0]),xe[0]=t,new e(Ee[t=Ie?0:1],Ee[1-t])):(Te||(_e=BigInt(Number.MIN_SAFE_INTEGER),Ae=BigInt(Number.MAX_SAFE_INTEGER),Be=BigInt(4294967295),Te=BigInt(32)),t>=_e&&t<=Ae?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Be),Number(t>>Te))))}function Ue(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 je(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function ke(t,e){if(e>=0)je(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Oe(t,e){vt(e),function(t){var e=ut>>31;t(st<<1^e,(ut<<1|st>>>31)^e)}((e,r)=>{Ue(t,e>>>0,r>>>0)})}function Ne(t,e){t.i.push(e>>>0&255),t.i.push(e>>>8&255),t.i.push(e>>>16&255),t.i.push(e>>>24&255)}var Fe=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function Ve(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function De(t,e,r){je(t.i,8*e+r)}function Me(t,e){return De(t,e,2),e=t.i.end(),Ve(t,e),e.push(t.j),e}function Ce(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 Ge(t,e,r){if(null!=r)switch(De(t,e,0),typeof r){case"number":t=t.i,ht(r),Ue(t,st,ut);break;case"bigint":r=Le(r,Pe,be),Ue(t.i,r.j,r.i);break;default:r=we(r),Ue(t.i,r.j,r.i)}}function $e(t,e,r){De(t,e,2),je(t.i,r.length),Ve(t,t.i.end()),Ve(t,r)}var We=class{constructor(){this.l=[],this.j=0,this.i=new Fe}};function Re(t){if("string"==typeof t)we(t)}function ze(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var He=ze(),Ke=ze(),qe=ze(),Je=ze(),Xe=ze(),Ye=ze(),Ze=ze(),Qe=ze(),tr=ze(),er=ze(),rr=ze(),nr=ze(),ir=class{constructor(t,e){this.m=Ct(t,e,void 0,2048)}toJSON(){return Mt(this)}};ir.prototype[F]=R,ir.prototype.toString=function(){return this.m.toString()};var or=class{constructor(t,e){this.i=t,t=He,this.j=!!t&&e===t||!1}};function ar(t,e,r,n,i){null!=(e=pr(e,n))&&(r=Me(t,r),i(e,t),Ce(t,r))}var sr,ur,lr=new or(ar,He),hr=new or(ar,He),cr=Symbol(),fr=Symbol();function dr(t){var e=vr,r=gr,n=t[cr];if(n)return n;(n={}).oa=t,n.aa=function(t){switch(typeof t){case"boolean":return Bt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Tt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.ea=i,"function"==typeof(i=t[++o])&&(n.ha=!0,sr??=i,ur??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let h;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof or?h=i:(h=lr,o--),h?.j){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,h,u,t):e(n,s,h,t)}}return t[cr]=n}function pr(t,e){return t instanceof ir?t.m:Array.isArray(t)?Ct(t,e[0],e[1]):void 0}function vr(t,e,r){t[e]=r.i}function gr(t,e,r,n){var i,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=dr(n).aa,i||=mr(n))}function mr(t){var e=t[fr];if(!e){let r=dr(t);e=(t,e)=>yr(t,e,r),t[fr]=e}return e}function yr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[M],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.ea)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof or?r:[hr,r]:[r,void 0])[0].i;if(r=r[1]){let e=mr(r),i=dr(r).aa;r=t.ha?ur(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||x(O,3)}})}function br(t,e,r){if(Array.isArray(e)){var n=0|e[M];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&$(e,t),r&&2&t&&Object.freeze(e),e}}var wr=(t,e)=>{var r=new We;yr(t.m,r,dr(e)),Ve(r,r.i.end()),t=new Uint8Array(r.j);var n=(e=r.l).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.l=[t],t};function Sr(t,e){return new or(t,e)}function _r(t,e){return new or(t,e)}function Ar(t,e,r){null!=(e=Ut(e))&&(Re(e),Ge(t,r,e))}function Br(t,e,r){null!=(e=Et(e))&&null!=e&&(De(t,r,0),ke(t.i,e))}function Tr(t,e,r){null!=(e=Ot(e))&&$e(t,r,i(e))}function Ir(t,e,r,n,i){null!=(e=pr(e,n))&&(r=Me(t,r),i(e,t),Ce(t,r))}function xr(t,e,r){null!=(e=kt(e))&&$e(t,r,pe(e).buffer)}function Er(t,e,r){null!=(e=Et(e))&&(e=parseInt(e,10),De(t,r,0),ke(t.i,e))}var Pr,Lr=Sr(function(t,e,r){null!=(e=_t(e))&&(De(t,r,1),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),st=r.getUint32(0,!0),ut=r.getUint32(4,!0),Ne(t,st),Ne(t,ut))},er),Ur=Sr(function(t,e,r){null!=(e=_t(e))&&(De(t,r,5),t=t.i,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ut=0,Ne(t,st=r.getUint32(0,!0)))},tr),jr=Sr(Ar,Ye),kr=Sr(Ar,Ye),Or=_r(function(t,e,r){if(null!=(e=br(Ut,e,!1)))for(let n=0;n<e.length;n++)Ge(t,r,e[n])},Ye),Nr=Sr(function(t,e,r){if(null!=(e=jt(e))){if("string"==typeof e)ge(e);if(null!=e)switch(De(t,r,0),typeof e){case"number":t=t.i,ht(e),Ue(t,st,ut);break;case"bigint":r=Le(e,ye,ve),Ue(t.i,r.j,r.i);break;default:r=ge(e),Ue(t.i,r.j,r.i)}}},Ze),Fr=Sr(Br,Je),Vr=_r(function(t,e,r){if(null!=(e=br(Et,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(De(n,i,0),ke(n.i,o))}},Je),Dr=_r(function(t,e,r){if(null!=(e=br(Et,e,!0))&&e.length){r=Me(t,r);for(let r=0;r<e.length;r++)ke(t.i,e[r]);Ce(t,r)}},Je),Mr=Sr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(De(t,r,0),t.i.i.push(e?1:0))},Ke),Cr=Sr(Tr,qe),Gr=_r(function(t,e,r){if(null!=(e=br(Ot,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&$e(n,o,i(a))}},qe),$r=function(t,e,r=He){return new or(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Ir(t,e[o],r,n,i);1&(t=0|e[M])||$(e,1|t)}}),Wr=new or(Ir,He),Rr=Sr(xr,rr),zr=_r(function(t,e,r){if(null!=(e=br(kt,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&$e(n,i,pe(o).buffer)}},rr),Hr=Sr(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(De(t,r,0),je(t.i,e))},Xe),Kr=Sr(Er,nr),qr=Sr(Er,nr),Jr=Sr(function(t,e,r){if(null!=(e=Ut(e))&&(Re(e),null!=e))switch(De(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,lt(r=2*Math.abs(r)),r=st;let n=ut;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),Ue(t,st=r,ut=n);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),st=Number(BigInt.asUintN(32,e)),ut=Number(BigInt.asUintN(32,e>>BigInt(32))),Ue(t,st,ut);break;default:Oe(t.i,e)}},Qe),Xr=[0,Rr,zr,Mr,Cr],Yr=[0,Sr(Tr,qe),[0,qr,[0,Sr(Ar,Ye),Sr(Br,Je)],qr,-1,[0,Kr],qr,-1],Sr(xr,rr)],Zr=[0,1,[0,12,Fr,10,Mr],[0,7,[0,Fr,-1]]],Qr=globalThis.trustedTypes;var tn=class{constructor(t){this.i=t}toString(){return this.i+""}};function en(t){var e;return void 0===Pr&&(Pr=function(){var t=null;if(!Qr)return t;try{let e=t=>t;t=Qr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Pr)?e.createScriptURL(t):t,new tn(t)}function rn(t,...e){if(0===e.length)return en(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return en(r)}var nn=class extends ir{constructor(t){super(t)}},on=class extends ir{constructor(t){super(t)}},an=class extends ir{constructor(t){super(t)}},sn=[1,2,3,4,5,6],un=class extends ir{constructor(t){super(t)}j(){return null!=qt(this,1,te)}l(){return null!=Ot(qt(this,2))}},ln=class extends ir{constructor(t){super(t)}};function hn(t,e,r){return r=`wasm${r?"_module":""}_internal`,Promise.resolve({wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`})}var cn=class{};function fn(t){return fe(new dn,1,t)}cn.forVisionTasks=function(t,e=!1){return hn("vision",t??rn``,e)},cn.forLiteRtLmTextTasks=function(t,e=!1){return hn("litertlm_text",t??rn``,e)},cn.forTextTasks=function(t,e=!1){return hn("text",t??rn``,e)},cn.forRetrievalTasks=function(t,e=!1){return hn("retrieval",t??rn``,e)},cn.forGenAiTasks=function(t,e=!1){return hn("genai",t??rn``,e)},cn.forDecisionTasks=function(t,e=!1){return hn("decision",t??rn``,e)},cn.forAudioTasks=function(t,e=!1){return hn("audio",t??rn``,e)};var dn=class extends ir{constructor(t){super(t)}},pn=class extends ir{constructor(t){super(t)}},vn=[0,Kr,2,Nr,-2,kr,$r,[0,Kr,kr]],gn=class extends ir{constructor(t){super(t)}},mn=class extends ir{constructor(t){super(t)}};function yn(t){var e=new wn;return e=fe(e,1,30),fe(e,2,t)}var bn,wn=class extends ir{constructor(t){super(t)}},Sn=[3,4,5,6,7],_n=class extends ir{constructor(t){super(t)}},An=class extends ir{constructor(t){super(t)}};An.prototype.j=(bn=[0,[0,Kr,Cr,-3,Kr],[0,Sn,Kr,-1,Wr,[0,Kr,Cr,Nr],Wr,vn,Wr,[0,1,vn],Wr,[0,Kr],Wr,[0,Kr,Cr,Nr]]],function(){return wr(this,bn)});var Bn=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var n=this.i?new AbortController:void 0,i=n&&t.V>0?setTimeout(()=>{n.abort()},t.V):void 0;try{let i=await fetch(t.url,{method:t.na,headers:{...t.ma},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.V&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},Tn=class extends ir{constructor(t){super(t,37)}},In=[-4,{},Zr,Kr,Yr],xn=[0,Cr,Kr,1,Cr,-1,Kr,1,Kr,1,kr],En=[0,Kr,Cr,-2],Pn=[0,Cr,Kr],Ln=[0,Cr,Kr],Un=[0,Mr,-3],jn=[0,Kr,Cr,-1,kr,Fr,-1,Cr,-5,$r,[0,Cr,-4],-1,Mr,[0,Mr,-3],Kr];var kn=class extends ir{constructor(t){super(t,19)}},On=function(t){return e=>wr(e,t)}([-19,{},[0,Kr,1,[0,Cr,-6,kr,Fr,Cr,-1,kr],1,[0,Cr,1,Cr,-5],Cr,-1,[0,Kr,Cr,-8],[0,Cr,-3],[0,Cr,Kr,Cr,-2],[0,Cr,-1,Kr,Cr,-1,Kr,Cr,-1,[0,$r,[0,Cr,-1],Mr,Cr,-5],[0,Kr,Mr,Fr,-2]],kr,[0,Cr,-3,kr,Fr,Cr,-1],[0,Kr,Cr,-1],[0,Cr,-9],[0,Cr,-6,Kr,Cr,1,Cr,Mr,Kr,-1,Mr,Cr,-2,Kr,Cr,Kr,Cr,Fr,-1],1,[0,Kr],1,[0,Cr,-4],1,xn,[0,[1,2,3,4,5,6],Wr,xn,Wr,Pn,Wr,Ln,Wr,[0,Kr],Wr,jn,Wr,En],Pn,Ln,jn,[0,[0,Kr,Cr,-1,kr,Fr,-1,Cr,-4,$r,[0,Cr,-4],-1,1,Un],[0,Kr,Cr,-1,kr,Fr,-1,Cr,-4,Un]],En,[0,Cr,[0,Fr,-3,Kr],Kr,-2,[0,Fr,-1],Mr],4,[0,Cr,Kr,Cr,-1,kr,Kr,Cr,-1,Kr,Fr,-1]],Kr,$r,[-37,{},jr,Cr,$r,[0,Cr,-1],Rr,1,Rr,[0,Gr,-1,Vr,Or,-1],Cr,[0,Fr,Cr,-1],Mr,Fr,kr,Cr,-1,Jr,Xr,jr,Rr,Kr,Vr,kr,-1,[0,Kr,-1],Cr,Mr,Cr,Dr,Cr,-1,Lr,1,Lr,In,Mr,[0,Kr,[0,Ur,Fr,-2],[0,Ur]],[0,Kr,kr]],jr,zr,Cr,-1,jr,Kr,-1,[0,Mr,-1,Kr,Mr],[0,kr,-1,Cr],[0,jr,Mr,kr],kr,1,Hr,1,In]),Nn=class{constructor(t){this.j=[],this.o=new Bn,this.l=t??"",this.i=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.i&&(clearInterval(this.i),this.i=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.j.length)t?.();else{var r=this.j;this.j=[],r=function(t){var e=new kn;zt(e=fe(e,2,1786));var r=e.m,n=0|r[M];if(null==t)Yt(r,n,3);else{var i=t===U?7:0|t[M],o=i,a=Qt(i),s=a||Object.isFrozen(t),u=!0,l=!0;for(let e=0;e<t.length;e++){var h=t[e];a||(h=z(h),u&&=!h,l&&=h)}a||(i=u?13:5,i=l?-4097&i:4096|i),s&&i===o||(t=Array.prototype.slice.call(t),o=0,i=se(i,n)),i!==o&&$(t,i),n=Yt(r,n,3,t),2&i||!(4096&i||16&i)||Ht(r,n)}return e}(r),r=On(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",na:"POST",V:1e4,body:r,pa:2,ma:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.l},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.j=[],void 0!==this.i&&(clearInterval(this.i),this.i=void 0),e?.("net-send-failed",t)})}}};class Fn{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Vn(t,e){var r=new An;r=oe(r,1,t.L),r=oe(r,2,e),e=Xt(e=new Tn,6,K(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Dn(t,e){var r={F:e.F-t.l.F,H:e.H-t.l.H,G:e.G-t.l.G,B:e.B-t.l.B,I:e.I-t.l.I,D:e.D,M:e.M},n=yn(1);r=Mn(t,r),Vn(t,n=ae(n,4,Sn,r)),t.l=e}function Mn(t,e){var r=new pn;return t=he(t=le(t=fe(r,1,t.J),7,e.B),5,e.D),t=he(t,6,e.M),e.G>0&&he(t,4,e.I/e.G),0!==e.F&&ue(t,r=le(r=fn(3),2,e.F)),0!==e.H&&ue(t,e=le(r=fn(4),2,e.H)),t}var Cn=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Fn,this.l=new Fn,this.C=new Nn(e),this.J=function(t){switch(t){case"IMAGE":return 11;case"VIDEO":return 12;case"LIVE_STREAM":return 13;case"AUDIO_CLIPS":return 14;case"AUDIO_STREAM":return 15;default:return 10}}(t),t=new _n,"undefined"==typeof navigator?e=0:(e=navigator.userAgent,e=/Android/i.test(e)?1:/iPhone|iPad|iPod/i.test(e)?2:/Windows/i.test(e)?5:/Macintosh/i.test(e)?4:/Linux/i.test(e)?3:0),t=ce(t=fe(t,1,e),2,""),t=ce(t,3,""),t=ce(t,4,"1.2.0"),t=ce(t,5,""),this.L=fe(t,6,function(){var t=globalThis.__HOST_ENVIRONMENT__;if("string"==typeof t)switch(t){case"ANDROID":return 1;case"IOS":return 2;case"PYTHON":return 3;case"WEB":break;case"FLUTTER":return 5;case"FLUTTER_WEB":return 6;default:return 0}return 4}())}Z(){var t=new mn;t=he(t=fe(t,1,this.J),3,performance.now()-this.K),Vn(this,t=ae(yn(0),3,Sn,t)),this.o=performance.now()}S(t){var e=this.j.get(t);if(void 0!==e&&(this.j.delete(t),t=performance.now()-e,++this.i.G,this.i.I+=t,this.i.D=Math.max(this.i.D,t),this.A=Math.max(this.A,t),performance.now()>this.o+3e4)){for(let[r,n]of this.j.entries())t=r,n<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Dn(this,e)}}ia(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Dn(this,t);var e=new gn;e=oe(e,2,t=Mn(this,t)),Vn(this,e=ae(t=yn(2),5,Sn,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Gn(){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 $n(t){if("function"!=typeof importScripts){let 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)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}function Wn(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 Rn(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var 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(let e of n)t.h._free(e);t.h._free(e)}function zn(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Hn(t,e,r){var n=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,i)=>{e?(r(n,i),n=[]):n.push(t)}}var Kn=function(t){return class extends t{get W(){return this.h}fa(){if("function"==typeof this.W._mediapipeLoggerGetEncodedApiKey){let t=this.W._mediapipeLoggerGetEncodedApiKey();return this.W._decodeBase64(t)}}}}(function(t){return class extends t{la(){this.h._registerModelResourcesGraphService()}}}(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:Gn()?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){var 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){var 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?'),Wn(this,n||"input_audio",n=>{Wn(this,i=i||"audio_header",i=>{this.h._configureAudio(n,i,t,e??0,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){var 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),Wn(this,n,t=>{this.h._addAudioToInputStream(this.i,e,r,t,i)})}addGpuBufferToStream(t,e,r){Wn(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var 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);var[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);var[a,s]=[i,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Wn(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Wn(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Wn(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Wn(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Wn(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Wn(this,e,e=>{Wn(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Wn(this,e,e=>{Rn(this,Object.keys(t),n=>{Rn(this,Object.values(t),i=>{this.h._addFlatHashMapToInputStream(n,i,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,n){Wn(this,r,r=>{Wn(this,e,e=>{var 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){Wn(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Wn(this,e,e=>{var n=this.h._allocateBoolVector(t.length);if(!n)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(n,e);this.h._addBoolVectorToInputStream(n,e,r)})}addDoubleVectorToStream(t,e,r){Wn(this,e,e=>{var n=this.h._allocateDoubleVector(t.length);if(!n)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(n,e);this.h._addDoubleVectorToInputStream(n,e,r)})}addFloatVectorToStream(t,e,r){Wn(this,e,e=>{var n=this.h._allocateFloatVector(t.length);if(!n)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(n,e);this.h._addFloatVectorToInputStream(n,e,r)})}addIntVectorToStream(t,e,r){Wn(this,e,e=>{var n=this.h._allocateIntVector(t.length);if(!n)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(n,e);this.h._addIntVectorToInputStream(n,e,r)})}addUintVectorToStream(t,e,r){Wn(this,e,e=>{var n=this.h._allocateUintVector(t.length);if(!n)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(n,e);this.h._addUintVectorToInputStream(n,e,r)})}addStringVectorToStream(t,e,r){Wn(this,e,e=>{var n=this.h._allocateStringVector(t.length);if(!n)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Wn(this,e,t=>{this.h._addStringVectorEntry(n,t)});this.h._addStringVectorToInputStream(n,e,r)})}addBoolToInputSidePacket(t,e){Wn(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Wn(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Wn(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Wn(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Wn(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Wn(this,e,e=>{Wn(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Wn(this,r,r=>{Wn(this,e,e=>{var 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){Wn(this,e,e=>{var r=this.h._allocateBoolVector(t.length);if(!r)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(r,e);this.h._addBoolVectorToInputSidePacket(r,e)})}addDoubleVectorToInputSidePacket(t,e){Wn(this,e,e=>{var r=this.h._allocateDoubleVector(t.length);if(!r)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(r,e);this.h._addDoubleVectorToInputSidePacket(r,e)})}addFloatVectorToInputSidePacket(t,e){Wn(this,e,e=>{var r=this.h._allocateFloatVector(t.length);if(!r)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(r,e);this.h._addFloatVectorToInputSidePacket(r,e)})}addIntVectorToInputSidePacket(t,e){Wn(this,e,e=>{var r=this.h._allocateIntVector(t.length);if(!r)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(r,e);this.h._addIntVectorToInputSidePacket(r,e)})}addUintVectorToInputSidePacket(t,e){Wn(this,e,e=>{var r=this.h._allocateUintVector(t.length);if(!r)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(r,e);this.h._addUintVectorToInputSidePacket(r,e)})}addStringVectorToInputSidePacket(t,e){Wn(this,e,e=>{var r=this.h._allocateStringVector(t.length);if(!r)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Wn(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){zn(this,t,e),Wn(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Hn(this,t,e),Wn(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){zn(this,t,e),Wn(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Hn(this,t,e),Wn(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){zn(this,t,e),Wn(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Hn(this,t,e),Wn(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){zn(this,t,e),Wn(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Hn(this,t,e),Wn(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){zn(this,t,e),Wn(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Hn(this,t,e),Wn(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){zn(this,t,e),Wn(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Hn(this,t,e),Wn(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){zn(this,t,e),Wn(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Hn(this,t,e),Wn(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?'),zn(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Wn(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}})),qn=class extends Kn{};async function Jn(t,e){var r=await(async(t,e,r)=>{var n=di;if(t&&await $n(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await $n(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 Xn(r,e),await r.T(e),r}function Xn(t,e){e=e.sa??"";var r=t.j.fa();t.l=new Cn(e,r)}function Yn(t,e){try{t.j.h.FS_unlink("/model.litertlm")}catch{}t.j.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!1),ce(e=ne(t.baseOptions,un,1)||new un,2,"/model.litertlm"),Xt(e,1),oe(t.baseOptions,1,e)}function Zn(t,e,r=!0){if(r){let r=e.baseOptions||{};if(e.baseOptions?.modelAssetBuffer&&e.baseOptions?.modelAssetPath)throw Error("Cannot set both baseOptions.modelAssetPath and baseOptions.modelAssetBuffer");if(!(ne(t.baseOptions,un,1)?.j()||ne(t.baseOptions,un,1)?.l()||e.baseOptions?.modelAssetBuffer||e.baseOptions?.modelAssetPath))throw Error("Either baseOptions.modelAssetPath or baseOptions.modelAssetBuffer must be set");if(function(t,e){var r=ne(t.baseOptions,an,3);if(!r){var n=r=new an,i=new on;ae(n,4,sn,i)}"delegate"in e&&("GPU"===e.delegate?(e=r,n=new nn,ae(e,2,sn,n)):(e=r,n=new on,ae(e,4,sn,n))),oe(t.baseOptions,3,r)}(t,r),r.modelAssetPath)return fetch(r.modelAssetPath.toString()).then(t=>{if(t.ok)return t.arrayBuffer();throw Error(`Failed to fetch model: ${r.modelAssetPath} (${t.status})`)}).then(e=>{Yn(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)Yn(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(r.modelAssetBuffer).then(e=>{Yn(t,e)})}return Promise.resolve()}function Qn(t){try{let e=t.o.length;if(1===e)throw Error(t.o[0].message);if(e>1)throw Error("Encountered multiple errors: "+t.o.map(t=>t.message).join(", "))}finally{t.o=[]}}var ti=class{constructor(t){this.j=t,this.o=[],this.j.setAutoRenderToScreen(!1)}setGraph(t,e){this.j.attachErrorListener((t,e)=>{this.o.push(Error(e))}),this.j.la(),this.j.setGraph(t,e),this.l?.Z(),Qn(this)}finishProcessing(t){this.j.finishProcessing(),Qn(this),this.l&&void 0!==t&&this.l.S(t)}close(){this.l?.ia(),this.l?.close(),this.j.closeGraph()}};function ei(t,e){var r="object"==typeof t&&null!==t,n=(r?t.imageBytes:void 0)??e?.imageBytes;return e=(r?t.audioSamples:void 0)??e?.audioSamples,{text:r?t.text??"":t,imageBytes:n,audioSamples:e,N:!!(n&&n.byteLength>0)||!!(e&&e.length>0)}}function ri(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function ni(t){var e={};if(t.criteria)for(let[r,n]of Object.entries(t.criteria))e[r]=n;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function ii(t){if(t.options&&t.options.length>0){var e=t.options.map(t=>t.description?`${t.label}: ${t.description}`:t.label),r=(t=t.options.map(t=>t.label)).map(t=>Number(t)),n=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=n?r:t.map((t,e)=>e),{rubric:e,labels:t,R:r,P:n}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),n=e.map((t,e)=>e),{rubric:e,labels:t,R:n,P:!1}}function oi(t,e,r,n){var i=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<i.length;t++){let e=i[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:n&&i.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}ti.prototype.close=ti.prototype.close;var ai=[];async function si(t,e){var r=ai.pop();if(r){Xn(t=new di(r,null),e);try{return await t.T(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Jn(t,e)}(t,e)}function ui(t,e){var r=t.X.then(()=>{var r=t.ba++;return t.l&&(1===t.backendType||-1===t.backendType?function(t,e){++t.i.F,t.j.set(e,performance.now())}(t.l,r):function(t,e){++t.i.H,t.j.set(e,performance.now())}(t.l,r)),Promise.resolve().then(e).then(e=>(t.l?.S(r),e),e=>{throw t.l?.S(r),e})});return t.X=r.then(()=>{},()=>{}),r}function li(t){if(!t)return 0;var e=t.context?ri(t.context):0;for(let r of t.questions??[]){e+=ri(r.prompt)+4;for(let t of r.options??[])e+=ri(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function hi(t){if(t.byteLength>=30&&80===t[0]&&75===t[1]&&3===t[2]&&4===t[3]){let e=t[26]|t[27]<<8;if(e+(t=t[28]|t[29]<<8)<=4096)return 30+e+t}return 0}function ci(t,e,r=0){if(t=t.j.h,e<64){if(!(r=t._malloc(e)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:r,v:r}}if(!(t=t._malloc(e+64)>>>0))throw Error(`Failed to allocate ${e} bytes on Wasm heap.`);return{u:(t+r+63&-64)-r>>>0,v:t}}async function fi(t,e,r,n){var i=t.j.h;if(r instanceof Uint8Array){var o=r.byteLength;if(0===o)return{u:0,v:0,size:0};let{u:e,v:n}=ci(t,o,hi(r));return i.HEAPU8.set(r,e),{u:e,v:n,size:o}}if(n=n&&n>0?n:0,!r&&e){if(e=e.toString(),!(r=await fetch(e)).ok||!r.body)throw Error(`Failed to fetch asset: ${e} (${r.status})`);(e=Number(r.headers.get("content-length")||0))>0&&(n=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(n>0){e=[];for(var a=0;a<30;){let{value:t,done:n}=await r.read();if(n)break;t&&t.byteLength>0&&(e.push(t),a+=Number(t.byteLength))}if(0===a)return{u:0,v:0,size:0};let u=e[0];if(u.byteLength<30&&e.length>1)for(var s of(u=new Uint8Array(Math.min(a,30)),a=0,e)){let t=Math.min(s.byteLength,u.byteLength-a);if(u.set(s.subarray(0,t),a),(a+=t)>=u.byteLength)break}let{u:l,v:h}=ci(t,n,hi(u));for(o of(t=0,e)){if(t+(s=Number(o.byteLength))>n)throw i._free(h),Error(`Stream exceeded expected content-length (${n} bytes).`);i.HEAPU8.set(o,l+t>>>0),t+=s}for(e.length=0;;){let{value:e,done:a}=await r.read();if(a)break;if(e&&e.byteLength>0){if(t+(o=Number(e.byteLength))>n)throw i._free(h),Error(`Stream exceeded expected content-length (${n} bytes).`);i.HEAPU8.set(e,l+t>>>0),t+=o}}return{u:l,v:h,size:t}}for(o=[],n=0;;){let{value:t,done:e}=await r.read();if(e)break;t&&t.byteLength>0&&(s=Number(t.byteLength),o.push(t),n+=s)}if(0===n)return{u:0,v:0,size:0};r=o[0];var{u:u,v:l}=ci(t,n,r?hi(r):0);for(t=0,r=0;r<o.length;r++)(s=o[r])&&(i.HEAPU8.set(s,u+t>>>0),t+=s.byteLength,o[r]=void 0);return{u:u,v:l,size:n}}var di=class extends ti{constructor(t,e){super(new qn(t,e)),this.baseOptions=new ln,this.L=this.C=this.K=this.A=this.i=this.maxNumTokens=this.backendType=0,this.Y=!1,this.ba=this.J=0,this.X=Promise.resolve()}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}U(t){this.O=t,this.J=li(t)}async ka(t){if(0!==this.i){var e=t.questions??[];if(0!==e.length){var r=this.j.h;"function"==typeof r.prewarmSchema?await ui(this,()=>r.prewarmSchema(this.i,t.context??"",e)):await ui(this,()=>r.evaluateSchema(this.i,"__PREWARM__",t.context??"",e))}}}async ja(t,e){return t=e?.context?`${e.context}\n${t}`:t,li(this.O)+ri(t)}async T(t){if(0!==this.i)throw Error("Decision does not support updating options after initialization.");if("CPU"===t.baseOptions?.delegate?this.backendType=-1:void 0!==t.backendType&&(this.backendType=t.backendType),void 0!==t.maxNumTokens&&(this.maxNumTokens=t.maxNumTokens),t.schema?this.U(t.schema):(t.questions||t.context||t.expectedInputs)&&this.U({context:t.context,expectedInputs:t.expectedInputs,questions:t.questions}),-1===this.backendType){this.j.h.preinitializedWebGPUDevice=void 0;var e="undefined"!=typeof self?self:globalThis;"object"==typeof e.Module&&e.Module&&(e.Module.preinitializedWebGPUDevice=void 0)}else if("undefined"!=typeof navigator&&navigator.gpu)try{if(!(e=this.j.h).preinitializedWebGPUDevice){var r=await navigator.gpu.requestAdapter({powerPreference:"high-performance"}),n=r?.info,i=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${n?.vendor??""} ${n?.architecture??""} ${n?.description??""}`);if(r&&!i){for(var o of(i=[],["shader-f16","subgroups"]))r.features.has(o)&&i.push(o);o={};for(let t of["maxBufferSize","maxStorageBufferBindingSize","maxStorageBuffersPerShaderStage","maxComputeWorkgroupStorageSize","maxTextureDimension2D"]){let e=r.limits[t];"number"==typeof e&&(o[t]=e)}let t=await r.requestDevice({requiredFeatures:i,requiredLimits:o});if(!t.adapterInfo&&n)try{Object.defineProperty(t,"adapterInfo",{value:n,writable:!0,configurable:!0})}catch{try{t.adapterInfo=n}catch{}}e.preinitializedWebGPUDevice=t}}e.preinitializedWebGPUDevice&&("object"==typeof(r=self).Module&&r.Module&&(r.Module.preinitializedWebGPUDevice=e.preinitializedWebGPUDevice))}catch(t){console.warn("WebGPU device initialization failed:",t)}if(r=e=this.j.h,(n=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await fi(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,n=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await fi(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,n=e.size}catch(t){console.warn("Optional companion per-layer embedder not loaded:",t)}this.i=await e.createDecisionFromBuffers(this.A,r.size,this.C,n,this.backendType,this.maxNumTokens)}else await Zn(this,t,n),this.i=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.Z()}evaluateBoolean(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,n=e.context?`${e.context}\n${e.condition}`:e.condition,i=ei(t,e);return i.N?ui(this,()=>r.evaluateContextBoolean(this.i,i.text,n,e.threshold??.5,e.temperature??0,{imageBytes:i.imageBytes,audioSamples:i.audioSamples})):ui(this,()=>r.evaluateBoolean(this.i,i.text,n,e.threshold??.5,e.temperature??0))}evaluateChoice(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,n=ni(e),i=e.instructions??"",o=e.context?i?`${e.context}\n${i}`:e.context:i,a=ei(t,e);return t=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),a.N||t?ui(this,()=>r.evaluateContextChoice(this.i,a.text,n,e.options??[],e.temperature??0,o,{imageBytes:a.imageBytes,audioSamples:a.audioSamples})):ui(this,()=>r.evaluateChoice(this.i,a.text,n,e.temperature??0,o))}async evaluateScore(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,{rubric:n,labels:i,R:o,P:a}=ii(e),s=e.instructions??"",u=e.context?s?`${e.context}\n${s}`:e.context:s,l=ei(t,e);return oi(t=l.N?await ui(this,()=>r.evaluateContextScore(this.i,l.text,n,e.temperature??0,u,{imageBytes:l.imageBytes,audioSamples:l.audioSamples})):await ui(this,()=>r.evaluateScore(this.i,l.text,n,e.temperature??0,u)),i,o,a)}async evaluate(t,e,r){if(0===this.i)throw Error("Decision is already closed.");if(r?.signal?.aborted)throw new DOMException("The operation was aborted.","AbortError");var n=ei(t,r),i=r?.context?n.text?`${r.context}\n${n.text}`:r.context:n.text,o=e.context;t=(n.imageBytes&&n.imageBytes.byteLength>0?70:0)+(n.audioSamples&&n.audioSamples.length>0?Math.ceil(n.audioSamples.length/640):0),this.J=li(e)+ri(i)+t;var a=this.j.h,s=e.questions??[];return 0===s.length?{}:(e=s.some(t=>(t.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0)),n.N||e?ui(this,()=>a.evaluateContextSchema(this.i,i,o??"",s,{imageBytes:n.imageBytes,audioSamples:n.audioSamples})):ui(this,()=>a.evaluateSchema(this.i,i,o??"",s)))}async da(t,e,r){var n=[];for(let i of t)n.push(await this.evaluate(i,e,r));return n}async ca(t,e){if(!this.O)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.O,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var n=this.j.h,i=e.context?`${e.context}\n${e.condition}`:e.condition;if("function"==typeof n.evaluateBooleanBatch)return ui(this,()=>n.evaluateBooleanBatch(this.i,t,i,e.threshold??.5,e.temperature??0,r));var o=[];for(let n of t)o.push(await this.evaluateBoolean(r?`${r}\n${n}`:n,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var n=this.j.h,i=ni(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if("function"==typeof n.evaluateChoiceBatch)return ui(this,()=>n.evaluateChoiceBatch(this.i,t,i,e.temperature??0,a,r));o=[];for(let n of t)o.push(await this.evaluateChoice(r?`${r}\n${n}`:n,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var n=this.j.h,{rubric:i,labels:o,R:a,P:s}=ii(e),u=e.instructions??"",l=e.context?u?`${e.context}\n${u}`:e.context:u;if("function"==typeof n.evaluateScoreBatch)return(await ui(this,()=>n.evaluateScoreBatch(this.i,t,i,e.temperature??0,l,r))).map(t=>oi(t,o,a,s));u=[];for(let n of t)u.push(await this.evaluateScore(r?`${r}\n${n}`:n,e));return u}close(){if(!this.Y){this.Y=!0;var t=this.j.h;if(0!==this.i){try{t.deleteDecision(this.i)}catch{}this.i=0}var e=this.K||this.A;if(0!==e){try{t._free(e)}catch{}this.K=this.A=0}if(0!==(e=this.L||this.C)){try{t._free(e)}catch{}this.L=this.C=0}super.close(),t&&!ai.includes(t)&&ai.push(t)}}};di.prototype.close=di.prototype.close,di.prototype.evaluateScoreBatch=di.prototype.evaluateScoreBatch,di.prototype.evaluateChoiceBatch=di.prototype.evaluateChoiceBatch,di.prototype.evaluateBooleanBatch=di.prototype.evaluateBooleanBatch,di.prototype.classify=di.prototype.ca,di.prototype.evaluateBatch=di.prototype.da,di.prototype.evaluate=di.prototype.evaluate,di.prototype.evaluateScore=di.prototype.evaluateScore,di.prototype.evaluateChoice=di.prototype.evaluateChoice,di.prototype.evaluateBoolean=di.prototype.evaluateBoolean,di.prototype.setOptions=di.prototype.T,di.prototype.measureContextUsage=di.prototype.ja,di.prototype.prewarm=di.prototype.ka,di.prototype.setSchema=di.prototype.U,di.createFromModelBuffer=function(t,e,r=0,n=0){return si(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:n})},di.createFromModelPath=function(t,e,r=0,n=0){return si(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:n})},di.createFromOptions=si,exports.DecisionMaker=di,exports.FilesetResolver=cn,exports.TaskRunner=ti;
2
2
  //# sourceMappingURL=decision_bundle_cjs.js.map