@mediapipe/tasks-decision 1.2.2-rc.20261111 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var Decision=function(t){"use strict";var e="undefined"!=typeof self?self:{};var r,i,n,o="undefined"!=typeof TextEncoder;function a(t){if(o)t=(r||=new TextEncoder).encode(t);else{let r=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)i[r++]=e;else{if(e<2048)i[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,i[r++]=e>>18|240,i[r++]=e>>12&63|128,i[r++]=e>>6&63|128,i[r++]=63&e|128;continue}n--}e=65533}i[r++]=e>>12|224,i[r++]=e>>6&63|128}i[r++]=63&e|128}}t=r===i.length?i:i.subarray(0,r)}return t}t:{for(var s=["CLOSURE_FLAGS"],l=e,u=0;u<s.length;u++)if(null==(l=l[s[u]])){n=null;break t}n=l}var h=n&&n[748402147];function c(){var t=e.navigator;return t&&(t=t.userAgent)?t:""}i=null==h||h;var f={},d=null;function p(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 i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=d[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}m();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function m(){if(!d){d={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));f[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===d[e]&&(d[e]=t)}}}}var v="undefined"!=typeof Uint8Array,g=!(-1!=c().indexOf("Trident")||-1!=c().indexOf("MSIE"))&&"function"==typeof btoa,y=/[-_.]/g,b={"-":"+",_:"/",".":"="};function w(t){return b[t]||""}function S(t){if(!g)return p(t);t=y.test(t)?t.replace(y,w):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 _,A={},B=class{constructor(t,e){if(T(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function T(t){if(t!==A)throw Error("illegal external caller")}function x(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var I=void 0;function E(t){return x(t=Error(t),"warning"),t}function P(t,r){if(null!=t){var i=I??={},n=i[t]||0;n>=r||(i[t]=n+1,x(t=Error(),"incident"),function(t){e.setTimeout(()=>{throw t},0)}(t))}}function j(){return"function"==typeof BigInt}var k="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,O=L("jas",void 0,!0),N=L(void 0,"1oa"),F=L(void 0,"0ubsb"),V=L(void 0,"0actk"),M=L("m_m","ta",!0),C={ha:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,$=k?O:"ha",G=[];function z(t,e){k||$ in t||D(t,C),t[$]|=e}function W(t,e){k||$ in t||D(t,C),t[$]=e}function R(t,e){return 2&e&&(t|=2),1|t}W(G,7),U=Object.freeze(G);var H={};function q(t,e){return void 0===e?t.i!==K&&!!(2&t.m[$]):!!(2&e)&&t.i!==K}var K={};function J(t,e){if(null!=t)if("string"==typeof t)t=t?new B(t,A):_||=new B(null,A);else if(!(t instanceof B))if(v&&null!=t&&t instanceof Uint8Array)t=t.length?new B(new Uint8Array(t),A):_||=new B(null,A);else{if(!e)throw Error();t=void 0}return t}function X(t){return t.sa=!0,t}var Y=X(t=>"number"==typeof t),Z=X(t=>"string"==typeof t),Q=X(t=>"boolean"==typeof t),tt="function"==typeof e.BigInt&&"bigint"==typeof e.BigInt(0);function et(t){var e=t;if(Z(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(Y(e)&&!Number.isSafeInteger(e))throw Error(String(e));return tt?BigInt(t):t=Q(t)?t?"1":"0":Z(t)?t.trim()||"0":String(t)}var rt=X(t=>tt?t>=nt&&t<=at:"-"===t[0]?st(t,it):st(t,ot)),it=Number.MIN_SAFE_INTEGER.toString(),nt=tt?BigInt(Number.MIN_SAFE_INTEGER):void 0,ot=Number.MAX_SAFE_INTEGER.toString(),at=tt?BigInt(Number.MAX_SAFE_INTEGER):void 0;function st(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 i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var lt,ut=0,ht=0;function ct(t){var e=t>>>0;ut=e,ht=(t-e)/4294967296>>>0}function ft(t){if(t<0){ct(-t);let[e,r]=yt(ut,ht);ut=e>>>0,ht=r>>>0}else ct(t)}function dt(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:pt(t,e)}function pt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else j()?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+mt(r)+mt(t));return r}function mt(t){return t=String(t),"0000000".slice(t.length)+t}function vt(){var t=ut,e=ht;if(2147483648&e)if(j())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=yt(t,e);t="-"+pt(r,i)}else t=pt(t,e);return t}function gt(t){if(t.length<16)ft(Number(t));else if(j())t=BigInt(t),ut=Number(t&BigInt(4294967295))>>>0,ht=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ht=ut=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));ht*=1e6,(ut=1e6*ut+e)>=4294967296&&(ht+=Math.trunc(ut/4294967296),ht>>>=0,ut>>>=0)}if(e){let[t,e]=yt(ut,ht);ut=t,ht=e}}}function yt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var bt="function"==typeof BigInt?BigInt.asIntN:void 0,wt="function"==typeof BigInt?BigInt.asUintN:void 0,St=Number.isSafeInteger,_t=Number.isFinite,At=Math.trunc;function Bt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var Tt,xt,It,Et=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Pt(t){switch(typeof t){case"bigint":return!0;case"number":return _t(t);case"string":return Et.test(t);default:return!1}}function jt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return _t(t)?0|t:void 0}function kt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(gt(t),vt())}function Lt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(gt(t),pt(ut,ht))}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(bt(64,t));if(Pt(t)){if("string"===e)return e=At(Number(t)),St(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=kt(t)),t;if("number"===e)return function(t){if(t=At(t),!St(t)){ft(t);var e=ut,r=ht;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=dt(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function Ot(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(wt(64,t));if(Pt(t)){if("string"===e)return e=At(Number(t)),St(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=At(t))>=0&&St(t)||(ft(t),t=dt(ut,ht)),t}(t)}}function Nt(t){if(null==t||"string"==typeof t||t instanceof B)return t}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Vt(t,e,r){if(null!=t&&t[M]===H)return t;if(Array.isArray(t)){var i=0|t[$];return(r=i|32&r|2&r)!==i&&W(t,r),new e(t)}}function Mt(t){return t}function Ct(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),h=u?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,!u||128&e||n||(l=!0,s=(Tt??Mt)(s-h,h,t,c,void 0)+h)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-h;(e??={})[t]=a}else o[n]=a}if(c)for(let n in c){if(null==(t=c[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+h)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Dt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return rt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[$];return 0===t.length&&1&e?void 0:Ct(t,e,Dt)}if(null!=t&&t[M]===H)return $t(t);if(t instanceof B){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(g){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),m(),r=f[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function $t(t){return Ct(t=t.m,0|t[$],Dt)}function Gt(t,e,r,n=0){if(null==t){var o=32;r?(t=[r],o|=128):t=[],e&&(o=-16760833&o|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(o=0|t[$],i&&1&o)throw Error("rfarr");if(2048&o&&!(2&o)&&function(){if(i)throw Error("carr");P(V,5)}(),256&o)throw Error("farr");if(64&o)return(o|n)!==o&&W(t,o|n),t;if(r&&(o|=128,r!==t[0]))throw Error("mid");t:{o|=64;var a=(r=t).length;if(a){var s=a-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&o?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(a=+l)<s&&(r[a+e]=t[l],delete t[l]);o=-16760833&o|(1023&s)<<14;break t}}if(e){if((l=Math.max(e,a-(128&o?0:-1)))>1024)throw Error("spvt");o=-16760833&o|(1023&l)<<14}}}return W(t,64|o|n),t}function zt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[$];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Rt(t,r,!1,e&&!(16&r)):(z(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[M]===H?q(t,r=0|(e=t.m)[$])?t:Jt(t,e,r)?Wt(t,e):Rt(e,r):t instanceof B?t:void 0}function Wt(t,e,r){return t=new t.constructor(e),r&&(t.i=K),t.o=K,t}function Rt(t,e,r,i){return i??=!!(34&e),t=Ct(t,e,zt,i),i=32,r&&(i|=2),W(t,e=16769217&e|i),t}function Ht(t){if(t.i!==K)return!1;var e=t.m;return z(e=Rt(e,0|e[$]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function qt(t){if(!Ht(t)&&q(t,0|t.m[$]))throw Error()}function Kt(t,e){void 0===e&&(e=0|t[$]),32&e&&!(4096&e)&&W(t,4096|e)}function Jt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&(W(e,2|r),t.i=K,!0)}function Xt(t,e,r){if(null!==(t=Yt(t.m,e,void 0,r)))return t}function Yt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Zt(t,e,r){qt(t);var i=t.m;return Qt(i,0|i[$],e,r),t}function Qt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[$])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function te(t,e,r){return t=Yt(t,e,r),Array.isArray(t)?t:U}function ee(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function re(t){return J(t,!0)}function ie(t){if(k)return t[N]??(t[N]=new Map);if(N in t)return t[N];var e=new Map;return Object.defineProperty(t,N,{value:e}),e}function ne(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Yt(e,o)&&(0!==n&&(r=Qt(e,r,n)),n=o)}return t.set(i,n),n}function oe(t,e,r,i){var n=!1;if(i=function(t,e,r){return Yt(t,e,void 0,r)}(t,i,t=>{var i=Vt(t,r,e);return n=i!==t&&null!=i,i}),null!=i)return n&&!q(i)&&Kt(t,e),i}function ae(t,e,r){var i=t.m,n=0|i[$];if(null==(e=oe(i,n,e,r)))return e;if(!q(t,n=0|i[$])){var o,a=e;let s=a.m,l=0|s[$];(o=q(a,l)?Jt(a,s,l)?Wt(a,s,!0):new a.constructor(Rt(s,l,!1)):a)!==e&&(Ht(t)&&(n=0|(i=t.m)[$]),Kt(i,n=Qt(i,n,r,e=o)))}return e}function se(t){return null==t&&(t=void 0),t}function le(t,e,r){return Zt(t,e,r=se(r)),r&&!q(r)&&Kt(t.m),t}function ue(t,e,r,i){t:{var n=i=se(i);qt(t);let s=t.m;var o=0|s[$];if(null==n){var a=ie(s);if(ne(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=ie(a=s),i=ne(t,a,o,r);i!==e&&(i&&(o=Qt(a,o,i)),t.set(r,e))}Qt(s,o,e,n)}return i&&!q(i)&&Kt(t.m),t}function he(t,e){return-273&(2&e?2|t:-3&t)}function ce(t,e){var r=mi;qt(t);var i=t.m,n=i,o=0|i[$],a=(t?q(t,o):2&o)?1:2;2===a&&t&&Ht(t)&&(o=0|(n=t.m)[$]);var s=te(n,8),l=s===U?7:0|s[$],u=R(l,o);if(t=!(4&u)){var h=o;let t=!!(2&u);t&&(h|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Vt(s[n],r,h);if(o instanceof r){if(!t){let t=q(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&(W(s,u),2&u&&Object.freeze(s)),u=l=u,(h=ee(l))&&2===a&&(s=Array.prototype.slice.call(s),u=0,l=he(l,o),o=Qt(n,o,8,s),h=!1),h||(1===a||4===a&&(2&l||!(16&l)&&32&o)?((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&W(s,l),Object.freeze(s)):l!==u&&W(s,l)),2&l||!(4096&l||16&l)||Kt(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===U?7:0|a[$],(e=q(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&W(a,r),e||Kt(i)}function fe(t,e,r){return Zt(t,e,null==r?r:function(t){if(!Pt(t))throw E("int64");switch(typeof t){case"string":var e=At(Number(t));return St(e)?t=et(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=j()?et(bt(64,BigInt(t))):et(kt(t))),t;case"bigint":return et(bt(64,t));default:return St(t)||(t=At(t),St(t)?t=String(t):(ft(t),t=vt())),et(t)}}(r))}function de(t,e,r){return Zt(t,e,null==r?r:function(t){if(!Pt(t))throw E("uint64");switch(typeof t){case"string":var e=At(Number(t));return St(e)&&e>=0?t=et(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=j()?et(wt(64,BigInt(t))):et(Lt(t))),t;case"bigint":return et(wt(64,t));default:return t>=0&&St(t)||((t=At(t))>=0&&St(t)?t=String(t):(ft(t),t=pt(ut,ht))),et(t)}}(r))}function pe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Zt(t,e,r)}function me(t,e,r){if(null!=r){if(!_t(r))throw E("enum");r|=0}return Zt(t,e,r)}var ve=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ge(t){if("string"==typeof t)return new ve(S(t),!0);if(Array.isArray(t))return new ve(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ve(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ve(t,!1);if(t.constructor===B){T(A);var e=t.i;return e=(null==(e=null==e||v&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?S(e):null)?e:t.i=e)||new Uint8Array(0),new ve(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ve(t,!1);throw Error()}function ye(t){return new Se(4294967295&t,Math.floor(t/4294967296))}function be(t){return t?/^\d+$/.test(t)?(gt(t),new Se(ut,ht)):null:we||=new Se(0,0)}var we,Se=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function _e(t){return new Le(4294967295&t,Math.floor(t/4294967296))}function Ae(t){return t?/^-?\d+$/.test(t)?(gt(t),new Le(ut,ht)):null:Be||=new Le(0,0)}var Be,Te,xe,Ie,Ee,Pe,je,ke,Le=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Ue(t,e,r){return"undefined"!=typeof BigInt64Array?(je||(je=new BigInt64Array(1),ke=new Uint32Array(je.buffer),je[0]=BigInt(1),Pe=1===ke[0]),je[0]=t,new e(ke[t=Pe?0:1],ke[1-t])):(Ee||(Te=BigInt(Number.MIN_SAFE_INTEGER),xe=BigInt(Number.MAX_SAFE_INTEGER),Ie=BigInt(4294967295),Ee=BigInt(32)),t>=Te&&t<=xe?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Ie),Number(t>>Ee))))}function Oe(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 Ne(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Fe(t,e){if(e>=0)Ne(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ve(t,e){gt(e),function(t){var e=ht>>31;t(ut<<1^e,(ht<<1|ut>>>31)^e)}((e,r)=>{Oe(t,e>>>0,r>>>0)})}function Me(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 Ce=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function De(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function $e(t,e,r){Ne(t.i,8*e+r)}function Ge(t,e){return $e(t,e,2),e=t.i.end(),De(t,e),e.push(t.j),e}function ze(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 We(t,e,r){if(null!=r)switch($e(t,e,0),typeof r){case"number":t=t.i,ft(r),Oe(t,ut,ht);break;case"bigint":r=Ue(r,Le,_e),Oe(t.i,r.j,r.i);break;default:r=Ae(r),Oe(t.i,r.j,r.i)}}function Re(t,e,r){$e(t,e,2),Ne(t.i,r.length),De(t,t.i.end()),De(t,r)}var He=class{constructor(){this.l=[],this.j=0,this.i=new Ce}};function qe(t){if("string"==typeof t)Ae(t)}function Ke(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Je=Ke(),Xe=Ke(),Ye=Ke(),Ze=Ke(),Qe=Ke(),tr=Ke(),er=Ke(),rr=Ke(),ir=Ke(),nr=Ke(),or=Ke(),ar=Ke(),sr=class{constructor(t,e){this.m=Gt(t,e,void 0,2048)}toJSON(){return $t(this)}};sr.prototype[M]=H,sr.prototype.toString=function(){return this.m.toString()};var lr=class{constructor(t,e){this.i=t,t=Je,this.j=!!t&&e===t||!1}};function ur(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),ze(t,r))}var hr,cr,fr=new lr(ur,Je),dr=new lr(ur,Je),pr=Symbol(),mr=Symbol();function vr(t){var e=yr,r=br,i=t[pr];if(i)return i;(i={}).qa=t,i.ba=function(t){switch(typeof t){case"boolean":return xt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?It||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.fa=n,"function"==typeof(n=t[++o])&&n.length>0&&(i.ia=!0,hr??=n,cr??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let h;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof lr?h=n:(h=fr,o--),h?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,h,l,t):e(i,s,h,t)}}return t[pr]=i}function gr(t,e){return t instanceof sr?t.m:Array.isArray(t)?Gt(t,e[0],e[1]):void 0}function yr(t,e,r){t[e]=r.i}function br(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=vr(i).ba,n||=wr(i))}function wr(t){var e=t[mr];if(!e){let r=vr(t);e=(t,e)=>Sr(t,e,r),t[mr]=e}return e}function Sr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[$],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.fa)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof lr?r:[dr,r]:[r,void 0])[0].i;if(r=r[1]){let e=wr(r),n=vr(r).ba;r=t.ia?cr(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||P(F,3)}})}function _r(t,e,r){if(Array.isArray(e)){var i=0|e[$];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&W(e,t),r&&2&t&&Object.freeze(e),e}}var Ar=(t,e)=>{var r=new He;Sr(t.m,r,vr(e)),De(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function Br(t,e){return new lr(t,e)}function Tr(t,e){return new lr(t,e)}function xr(t,e,r){null!=(e=Ut(e))&&(qe(e),We(t,r,e))}function Ir(t,e,r){null!=(e=jt(e))&&null!=e&&($e(t,r,0),Fe(t.i,e))}function Er(t,e,r){null!=(e=Ft(e))&&Re(t,r,a(e))}function Pr(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),ze(t,r))}function jr(t,e,r){null!=(e=Nt(e))&&Re(t,r,ge(e).buffer)}function kr(t,e,r){null!=(e=jt(e))&&(e=parseInt(e,10),$e(t,r,0),Fe(t.i,e))}var Lr,Ur=Br(function(t,e,r){null!=(e=Bt(e))&&($e(t,r,1),t=t.i,(r=lt||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),ut=r.getUint32(0,!0),ht=r.getUint32(4,!0),Me(t,ut),Me(t,ht))},nr),Or=Br(function(t,e,r){null!=(e=Bt(e))&&($e(t,r,5),t=t.i,(r=lt||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ht=0,Me(t,ut=r.getUint32(0,!0)))},ir),Nr=Br(xr,tr),Fr=Br(xr,tr),Vr=Tr(function(t,e,r){if(null!=(e=_r(Ut,e,!1)))for(let i=0;i<e.length;i++)We(t,r,e[i])},tr),Mr=Br(function(t,e,r){if(null!=(e=Ot(e))){if("string"==typeof e)be(e);if(null!=e)switch($e(t,r,0),typeof e){case"number":t=t.i,ft(e),Oe(t,ut,ht);break;case"bigint":r=Ue(e,Se,ye),Oe(t.i,r.j,r.i);break;default:r=be(e),Oe(t.i,r.j,r.i)}}},er),Cr=Br(Ir,Ze),Dr=Tr(function(t,e,r){if(null!=(e=_r(jt,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&($e(i,n,0),Fe(i.i,o))}},Ze),$r=Tr(function(t,e,r){if(null!=(e=_r(jt,e,!0))&&e.length){r=Ge(t,r);for(let r=0;r<e.length;r++)Fe(t.i,e[r]);ze(t,r)}},Ze),Gr=Br(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&($e(t,r,0),t.i.i.push(e?1:0))},Xe),zr=Br(Er,Ye),Wr=Tr(function(t,e,r){if(null!=(e=_r(Ft,e,!0)))for(let s=0;s<e.length;s++){var i=t,n=r,o=e[s];null!=o&&Re(i,n,a(o))}},Ye),Rr=function(t,e,r=Je){return new lr(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Pr(t,e[o],r,i,n);1&(t=0|e[$])||W(e,1|t)}}),Hr=new lr(Pr,Je),qr=Br(jr,or),Kr=Tr(function(t,e,r){if(null!=(e=_r(Nt,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&Re(i,n,ge(o).buffer)}},or),Jr=Br(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 _t(t)?t>>>0:void 0}(e),null!=e&&null!=e&&($e(t,r,0),Ne(t.i,e))},Qe),Xr=Br(kr,ar),Yr=Br(kr,ar),Zr=Br(function(t,e,r){if(null!=(e=Ut(e))&&(qe(e),null!=e))switch($e(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,ct(r=2*Math.abs(r)),r=ut;let i=ht;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),Oe(t,ut=r,ht=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),ut=Number(BigInt.asUintN(32,e)),ht=Number(BigInt.asUintN(32,e>>BigInt(32))),Oe(t,ut,ht);break;default:Ve(t.i,e)}},rr),Qr=[0,qr,Kr,Gr,zr],ti=[0,Br(Er,Ye),[0,Yr,[0,Br(xr,tr),Br(Ir,Ze)],Yr,-1,[0,Xr],Yr,-1],Br(jr,or)],ei=[0,1,[0,12,Cr,10,Gr],[0,7,[0,Cr,-1]]],ri=globalThis.trustedTypes;var ii=class{constructor(t){this.i=t}toString(){return this.i+""}};function ni(t){var e;return void 0===Lr&&(Lr=function(){var t=null;if(!ri)return t;try{let e=t=>t;t=ri.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Lr)?e.createScriptURL(t):t,new ii(t)}function oi(t,...e){if(0===e.length)return ni(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ni(r)}var ai=class extends sr{constructor(t){super(t)}},si=class extends sr{constructor(t){super(t)}},li=class extends sr{constructor(t){super(t)}},ui=[1,2,3,4,5,6],hi=class extends sr{constructor(t){super(t)}j(){return null!=Xt(this,1,re)}l(){return null!=Ft(Xt(this,2))}},ci=class extends sr{constructor(t){super(t)}};function fi(t,e,r){return r=`wasm${r?"_module":""}_internal`,Promise.resolve({wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`})}var di=class{};function pi(t){return me(new mi,1,t)}di.forVisionTasks=function(t,e=!1){return fi("vision",t??oi``,e)},di.forLiteRtLmTextTasks=function(t,e=!1){return fi("litertlm_text",t??oi``,e)},di.forTextTasks=function(t,e=!1){return fi("text",t??oi``,e)},di.forRetrievalTasks=function(t,e=!1){return fi("retrieval",t??oi``,e)},di.forGenAiTasks=function(t,e=!1){return fi("genai",t??oi``,e)},di.forDecisionTasks=function(t,e=!1){return fi("decision",t??oi``,e)},di.forAudioTasks=function(t,e=!1){return fi("audio",t??oi``,e)};var mi=class extends sr{constructor(t){super(t)}},vi=class extends sr{constructor(t){super(t)}},gi=[0,Xr,2,Mr,-2,Fr,Rr,[0,Xr,Fr]],yi=class extends sr{constructor(t){super(t)}},bi=class extends sr{constructor(t){super(t)}};function wi(t){var e=new _i;return e=me(e,1,30),me(e,2,t)}var Si,_i=class extends sr{constructor(t){super(t)}},Ai=[3,4,5,6,7],Bi=class extends sr{constructor(t){super(t)}},Ti=class extends sr{constructor(t){super(t)}};Ti.prototype.j=(Si=[0,[0,Xr,zr,-3,Xr],[0,Ai,Xr,-1,Hr,[0,Xr,zr,Mr],Hr,gi,Hr,[0,1,gi],Hr,[0,Xr],Hr,[0,Xr,zr,Mr]]],function(){return Ar(this,Si)});var xi=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.W>0?setTimeout(()=>{i.abort()},t.W):void 0;try{let n=await fetch(t.url,{method:t.pa,headers:{...t.oa},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.W&&i?i.signal:null});n.ok?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(0)}finally{clearTimeout(n)}}},Ii=class extends sr{constructor(t){super(t,37)}},Ei=[-4,{},ei,Xr,ti],Pi=[0,zr,Xr,1,zr,-1,Xr,1,Xr,1,Fr],ji=[0,Xr,zr,-2],ki=[0,zr,Xr],Li=[0,zr,Xr],Ui=[0,Gr,-3],Oi=[0,Xr,zr,-1,Fr,Cr,-1,zr,-5,Rr,[0,zr,-4],-1,Gr,[0,Gr,-3],Xr];var Ni=class extends sr{constructor(t){super(t,19)}},Fi=function(t){return e=>Ar(e,t)}([-19,{},[0,Xr,1,[0,zr,-6,Fr,Cr,zr,-1,Fr],1,[0,zr,1,zr,-5],zr,-1,[0,Xr,zr,-8],[0,zr,-3],[0,zr,Xr,zr,-2],[0,zr,-1,Xr,zr,-1,Xr,zr,-1,[0,Rr,[0,zr,-1],Gr,zr,-5],[0,Xr,Gr,Cr,-2]],Fr,[0,zr,-3,Fr,Cr,zr,-1],[0,Xr,zr,-1],[0,zr,-9],[0,zr,-6,Xr,zr,1,zr,Gr,Xr,-1,Gr,zr,-2,Xr,zr,Xr,zr,Cr,-1],1,[0,Xr],1,[0,zr,-4],1,Pi,[0,[1,2,3,4,5,6],Hr,Pi,Hr,ki,Hr,Li,Hr,[0,Xr],Hr,Oi,Hr,ji],ki,Li,Oi,[0,[0,Xr,zr,-1,Fr,Cr,-1,zr,-4,Rr,[0,zr,-4],-1,1,Ui],[0,Xr,zr,-1,Fr,Cr,-1,zr,-4,Ui]],ji,[0,zr,[0,Cr,-3,Xr],Xr,-2,[0,Cr,-1],Gr],4,[0,zr,Xr,zr,-1,Fr,Xr,zr,-1,Xr,Cr,-1]],Xr,Rr,[-37,{},Nr,zr,Rr,[0,zr,-1],qr,1,qr,[0,Wr,-1,Dr,Vr,-1],zr,[0,Cr,zr,-1],Gr,Cr,Fr,zr,-1,Zr,Qr,Nr,qr,Xr,Dr,Fr,-1,[0,Xr,-1],zr,Gr,zr,$r,zr,-1,Ur,1,Ur,Ei,Gr,[0,Xr,[0,Or,Cr,-2],[0,Or]],[0,Xr,Fr]],Nr,Kr,zr,-1,Nr,Xr,-1,[0,Gr,-1,Xr,Gr],[0,Fr,-1,zr],[0,Nr,Gr,Fr],Fr,1,Jr,1,Ei]),Vi=class{constructor(t){this.j=[],this.o=new xi,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 Ni;qt(e=me(e,2,1786));var r=e.m,i=0|r[$];if(null==t)Qt(r,i,3);else{var n=t===U?7:0|t[$],o=n,a=ee(n),s=a||Object.isFrozen(t),l=!0,u=!0;for(let e=0;e<t.length;e++){var h=t[e];a||(h=q(h),l&&=!h,u&&=h)}a||(n=l?13:5,n=u?-4097&n:4096|n),s&&n===o||(t=Array.prototype.slice.call(t),o=0,n=he(n,i)),n!==o&&W(t,n),i=Qt(r,i,3,t),2&n||!(4096&n||16&n)||Kt(r,i)}return e}(r),r=Fi(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",pa:"POST",W:1e4,body:r,ra:2,oa:{"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 Mi{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Ci(t,e){var r=new Ti;r=le(r,1,t.L),r=le(r,2,e),e=Zt(e=new Ii,6,J(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Di(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},i=wi(1);r=$i(t,r),Ci(t,i=ue(i,4,Ai,r)),t.l=e}function $i(t,e){var r=new vi;return t=de(t=fe(t=me(r,1,t.J),7,e.B),5,e.D),t=de(t,6,e.M),e.G>0&&de(t,4,e.I/e.G),0!==e.F&&ce(t,r=fe(r=pi(3),2,e.F)),0!==e.H&&ce(t,e=fe(r=pi(4),2,e.H)),t}var Gi=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Mi,this.l=new Mi,this.C=new Vi(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 Bi,"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=pe(t=me(t,1,e),2,""),t=pe(t,3,""),t=pe(t,4,"1.2.2"),t=pe(t,5,""),this.L=me(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}())}aa(){var t=new bi;t=de(t=me(t,1,this.J),3,performance.now()-this.K),Ci(this,t=ue(wi(0),3,Ai,t)),this.o=performance.now()}T(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,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Di(this,e)}}ja(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Di(this,t);var e=new yi;e=le(e,2,t=$i(this,t)),Ci(this,e=ue(t=wi(2),5,Ai,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function zi(){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 Wi(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 Ri(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 Hi(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function qi(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Ki(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Ji=function(t){return class extends t{get X(){return this.h}ga(){if("function"==typeof this.X._mediapipeLoggerGetEncodedApiKey){let t=this.X._mediapipeLoggerGetEncodedApiKey();return this.X._decodeBase64(t)}}}}(function(t){return class extends t{na(){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:zi()?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,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Ri(this,i||"input_audio",i=>{Ri(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,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,i,n){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),Ri(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Ri(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Ri(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Ri(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Ri(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Ri(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Ri(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Ri(this,e,e=>{Ri(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Ri(this,e,e=>{Hi(this,Object.keys(t),i=>{Hi(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Ri(this,r,r=>{Ri(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Ri(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Ri(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Ri(this,e,e=>{Ri(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Ri(this,r,r=>{Ri(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Ri(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){Ri(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){Ri(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){Ri(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){Ri(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){Ri(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)Ri(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){qi(this,t,e),Ri(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Ki(this,t,e),Ri(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?'),qi(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Ri(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}})),Xi=class extends Ji{};async function Yi(t,e){var r=await(async(t,e,r)=>{var i=bn;if(t&&await Wi(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Wi(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 i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return Zi(r,e),await r.U(e),r}function Zi(t,e){e=e.ua??"";var r=t.j.ga();t.l=new Gi(e,r)}function Qi(t,e){try{t.j.h.FS_unlink("/model.litertlm")}catch{}t.j.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!0),pe(e=ae(t.baseOptions,hi,1)||new hi,2,"/model.litertlm"),Zt(e,1),le(t.baseOptions,1,e)}function tn(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(!(ae(t.baseOptions,hi,1)?.j()||ae(t.baseOptions,hi,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=ae(t.baseOptions,li,3);if(!r){var i=r=new li,n=new si;ue(i,4,ui,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new ai,ue(e,2,ui,i)):(e=r,i=new si,ue(e,4,ui,i))),le(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=>{Qi(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)Qi(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{Qi(t,e)})}return Promise.resolve()}function en(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 rn=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.na(),this.j.setGraph(t,e),this.l?.aa(),en(this)}finishProcessing(t){this.j.finishProcessing(),en(this),this.l&&void 0!==t&&this.l.T(t)}close(){this.l?.ja(),this.l?.close(),this.j.closeGraph()}};function nn(t){return!!(t?.imageBytes&&t.imageBytes.byteLength>0)||!!(t?.audioSamples&&t.audioSamples.length>0)}function on(t,e){var r="object"==typeof t&&null!==t,i=(r?t.imageBytes:void 0)??e?.imageBytes;return e=(r?t.audioSamples:void 0)??e?.audioSamples,{text:r?t.text??"":t,imageBytes:i,audioSamples:e,N:!!(i&&i.byteLength>0)||!!(e&&e.length>0)}}function an(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function sn(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function ln(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)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,S:r,R:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,S:i,R:!1}}function un(t){if(0===t.length)return[];t=[...t].sort((t,e)=>t.probability!==e.probability?e.probability-t.probability:t.key<e.key?-1:t.key>e.key?1:0);var e=[],r=0;for(let i of t)if(e.push(i.key),(r+=i.probability)>=.9)break;return e}function hn(t){if(void 0!==t.predictionSet)return{...t,predictionSet:t.predictionSet};var e=Object.entries(t.probabilities??{}).map(([t,e])=>({key:t,probability:e}));return{...t,predictionSet:un(e)}}function cn(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}rn.prototype.close=rn.prototype.close;var fn=[];async function dn(t,e){var r=fn.pop();if(r){Zi(t=new bn(r,null),e);try{return await t.U(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Yi(t,e)}(t,e)}function pn(t,e){var r=t.Y.then(()=>{var r=t.ca++;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?.T(r),e),e=>{throw t.l?.T(r),e})});return t.Y=r.then(()=>{},()=>{}),r}function mn(t){if(!t)return 0;var e=t.context?an(t.context):0;for(let r of t.questions??[]){e+=an(r.prompt)+4;for(let t of r.options??[])e+=an(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function vn(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 gn(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 yn(t,e,r,i){var n=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:i}=gn(t,o,vn(r));return n.HEAPU8.set(r,e),{u:e,v:i,size:o}}if(i=i&&i>0?i: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&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){e=[];for(var a=0;a<30;){let{value:t,done:i}=await r.read();if(i)break;t&&t.byteLength>0&&(e.push(t),a+=Number(t.byteLength))}if(0===a)return{u:0,v:0,size:0};let l=e[0];if(l.byteLength<30&&e.length>1)for(var s of(l=new Uint8Array(Math.min(a,30)),a=0,e)){let t=Math.min(s.byteLength,l.byteLength-a);if(l.set(s.subarray(0,t),a),(a+=t)>=l.byteLength)break}let{u:u,v:h}=gn(t,i,vn(l));for(o of(t=0,e)){if(t+(s=Number(o.byteLength))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(o,u+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))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(e,u+t>>>0),t+=o}}return{u:u,v:h,size:t}}for(o=[],i=0;;){let{value:t,done:e}=await r.read();if(e)break;t&&t.byteLength>0&&(s=Number(t.byteLength),o.push(t),i+=s)}if(0===i)return{u:0,v:0,size:0};r=o[0];var{u:l,v:u}=gn(t,i,r?vn(r):0);for(t=0,r=0;r<o.length;r++)(s=o[r])&&(n.HEAPU8.set(s,l+t>>>0),t+=s.byteLength,o[r]=void 0);return{u:l,v:u,size:i}}var bn=class extends rn{constructor(t,e){super(new Xi(t,e)),this.baseOptions=new ci,this.L=this.C=this.K=this.A=this.i=this.maxNumTokens=this.backendType=0,this.Z=!1,this.ca=this.J=0,this.Y=Promise.resolve()}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}V(t){this.P=t,this.J=mn(t)}async O(t){if(0!==this.i){var e=t.questions??[];if(0!==e.length){var r=this.j.h;"function"==typeof r.prewarmSchema?await pn(this,()=>r.prewarmSchema(this.i,t.context??"",e)):await pn(this,()=>r.evaluateSchema(this.i,"__PREWARM__",t.context??"",e))}}}async prewarmChoice(t){if(0!==this.i){var e=sn(t);if(0!==Object.keys(e).length){var r=t.instructions??"",i=t.context?r?`${t.context}\n${r}`:t.context:r,n=this.j.h;if("function"==typeof n.prewarmChoice)await pn(this,()=>n.prewarmChoice(this.i,e,t.options??[],t.temperature??0,i,t.normalizePrior??!1));else{var o=new Map;for(var a of t.options??[])o.set(a.label,a);a=Object.entries(e).map(([t,e])=>{var r=o.get(t);return r?{...r,label:t,description:e}:{label:t,description:e}}),await this.O({context:t.context,questions:[{id:"__choice__",type:"choice",prompt:r,options:a,temperature:t.temperature,normalizePrior:t.normalizePrior}]})}}}}async la(t){0!==this.i&&(t.options&&t.options.length>=2?await this.prewarmChoice({options:t.options,instructions:t.condition,context:t.context,temperature:t.temperature,normalizePrior:t.normalizePrior}):await this.O({context:t.context,questions:[{id:"__boolean__",type:"boolean",prompt:t.condition,threshold:t.threshold,temperature:t.temperature,normalizePrior:t.normalizePrior}]}))}async ma(t){if(0!==this.i){var{rubric:e}=ln(t);0!==e.length&&await this.O({context:t.context,questions:[{id:"__score__",type:"score",prompt:t.instructions??"",options:e.map(t=>({label:"",description:t})),temperature:t.temperature}]})}}async ka(t,e){return t=e?.context?`${e.context}\n${t}`:t,mn(this.P)+an(t)}async U(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.V(t.schema):(t.questions||t.context||t.expectedInputs)&&this.V({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"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups"]))r.features.has(o)&&n.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:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}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,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await yn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await yn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=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,i,this.backendType,this.maxNumTokens)}else await tn(this,t,i),this.i=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.aa()}evaluateBoolean(t,e){if(0===this.i)throw Error("Decision is already closed.");if(e.options&&e.options.length>=2){let r=void 0!==e.threshold&&e.threshold>0?e.threshold:.5;return this.evaluateChoice(t,{options:e.options,instructions:e.condition,context:e.context,temperature:e.temperature,normalizePrior:e.normalizePrior,imageBytes:e.imageBytes,audioSamples:e.audioSamples}).then(t=>{var i=e.options,n=/^(true|yes|1|allow|allowed|entailment|supported)$/i,o=/^(false|no|0|deny|denied|reject|rejected|contradiction|contradicted|refuted)$/i,a=i.find(t=>n.test(t.label.trim()));return a||=o.test(i[1].label.trim())&&!o.test(i[0].label.trim())?i[0]:i[1],{value:o=(i=t.probabilities[a.label]??0)>=r,probabilityTrue:i,confidence:r>0&&r<1?Math.min(1,Math.max(0,o?(i-r)/(1-r):(r-i)/r)):t.confidence}})}var r=this.j.h,i=e.context?`${e.context}\n${e.condition}`:e.condition,n=e.normalizePrior??!1,o=on(t,e);return o.N?pn(this,()=>r.evaluateContextBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,{imageBytes:o.imageBytes,audioSamples:o.audioSamples},n)):pn(this,()=>r.evaluateBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,n))}evaluateChoice(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,i=sn(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n,a=e.normalizePrior??!1,s=on(t,e);return t=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),(s.N||t?pn(this,()=>r.evaluateContextChoice(this.i,s.text,i,e.options??[],e.temperature??0,o,{imageBytes:s.imageBytes,audioSamples:s.audioSamples},a)):pn(this,()=>r.evaluateChoice(this.i,s.text,i,e.temperature??0,o,a))).then(hn)}async evaluateScore(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,{rubric:i,labels:n,S:o,R:a}=ln(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s,u=on(t,e);return cn(t=u.N?await pn(this,()=>r.evaluateContextScore(this.i,u.text,i,e.temperature??0,l,{imageBytes:u.imageBytes,audioSamples:u.audioSamples})):await pn(this,()=>r.evaluateScore(this.i,u.text,i,e.temperature??0,l)),n,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 i=on(t,r),n=r?.context?i.text?`${r.context}\n${i.text}`:r.context:i.text,o=e.context;t=(i.imageBytes&&i.imageBytes.byteLength>0?70:0)+(i.audioSamples&&i.audioSamples.length>0?Math.ceil(i.audioSamples.length/640):0),this.J=mn(e)+an(n)+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)),function(t,e){t={...t};for(let r of e)"categorical"!==r.type&&"choice"!==r.type||(e=t[r.id])&&void 0===e.predictionSet&&(t[r.id]={...e,predictionSet:un((e.probabilities??[]).map(t=>({key:t.label,probability:t.probability})))});return t}(e=i.N||e?await pn(this,()=>a.evaluateContextSchema(this.i,n,o??"",s,{imageBytes:i.imageBytes,audioSamples:i.audioSamples})):await pn(this,()=>a.evaluateSchema(this.i,n,o??"",s)),s))}async ea(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async da(t,e){if(!this.P)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.P,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if(!(nn(e)||e.options&&e.options.length>=2)&&"function"==typeof i.evaluateBooleanBatch)return pn(this,()=>i.evaluateBooleanBatch(this.i,t,n,e.threshold??.5,e.temperature??0,r,e.normalizePrior??!1));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=sn(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if(o=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),!nn(e)&&!o&&"function"==typeof i.evaluateChoiceBatch)return(await pn(this,()=>i.evaluateChoiceBatch(this.i,t,n,e.temperature??0,a,r,e.normalizePrior??!1))).map(hn);o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,{rubric:n,labels:o,S:a,R:s}=ln(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if(!nn(e)&&"function"==typeof i.evaluateScoreBatch)return(await pn(this,()=>i.evaluateScoreBatch(this.i,t,n,e.temperature??0,u,r))).map(t=>cn(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.Z){this.Z=!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&&!fn.includes(t)&&fn.push(t)}}};return bn.prototype.close=bn.prototype.close,bn.prototype.evaluateScoreBatch=bn.prototype.evaluateScoreBatch,bn.prototype.evaluateChoiceBatch=bn.prototype.evaluateChoiceBatch,bn.prototype.evaluateBooleanBatch=bn.prototype.evaluateBooleanBatch,bn.prototype.classify=bn.prototype.da,bn.prototype.evaluateBatch=bn.prototype.ea,bn.prototype.evaluate=bn.prototype.evaluate,bn.prototype.evaluateScore=bn.prototype.evaluateScore,bn.prototype.evaluateChoice=bn.prototype.evaluateChoice,bn.prototype.evaluateBoolean=bn.prototype.evaluateBoolean,bn.prototype.setOptions=bn.prototype.U,bn.prototype.measureContextUsage=bn.prototype.ka,bn.prototype.prewarmScore=bn.prototype.ma,bn.prototype.prewarmBoolean=bn.prototype.la,bn.prototype.prewarmChoice=bn.prototype.prewarmChoice,bn.prototype.prewarm=bn.prototype.O,bn.prototype.setSchema=bn.prototype.V,bn.createFromModelBuffer=function(t,e,r=0,i=0){return dn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},bn.createFromModelPath=function(t,e,r=0,i=0){return dn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},bn.createFromOptions=dn,t.DecisionMaker=bn,t.FilesetResolver=di,t.TaskRunner=rn,t}({});
1
+ var Decision=function(t){"use strict";var e="undefined"!=typeof self?self:{};var r,i,n,o="undefined"!=typeof TextEncoder;function a(t){if(o)t=(r||=new TextEncoder).encode(t);else{let r=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var e=t.charCodeAt(n);if(e<128)i[r++]=e;else{if(e<2048)i[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,i[r++]=e>>18|240,i[r++]=e>>12&63|128,i[r++]=e>>6&63|128,i[r++]=63&e|128;continue}n--}e=65533}i[r++]=e>>12|224,i[r++]=e>>6&63|128}i[r++]=63&e|128}}t=r===i.length?i:i.subarray(0,r)}return t}t:{for(var s=["CLOSURE_FLAGS"],l=e,u=0;u<s.length;u++)if(null==(l=l[s[u]])){n=null;break t}n=l}var h=n&&n[748402147];function c(){var t=e.navigator;return t&&(t=t.userAgent)?t:""}i=null==h||h;var f={},d=null;function p(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 i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=d[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}m();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function m(){if(!d){d={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));f[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===d[e]&&(d[e]=t)}}}}var v="undefined"!=typeof Uint8Array,g=!(-1!=c().indexOf("Trident")||-1!=c().indexOf("MSIE"))&&"function"==typeof btoa,y=/[-_.]/g,b={"-":"+",_:"/",".":"="};function w(t){return b[t]||""}function S(t){if(!g)return p(t);t=y.test(t)?t.replace(y,w):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 _,A={},B=class{constructor(t,e){if(T(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function T(t){if(t!==A)throw Error("illegal external caller")}function x(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var I=void 0;function E(t){return x(t=Error(t),"warning"),t}function P(t,r){if(null!=t){var i=I??={},n=i[t]||0;n>=r||(i[t]=n+1,x(t=Error(),"incident"),function(t){e.setTimeout(()=>{throw t},0)}(t))}}function j(){return"function"==typeof BigInt}var k="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,O=L("jas",void 0,!0),N=L(void 0,"1oa"),F=L(void 0,"0ubsb"),V=L(void 0,"0actk"),M=L("m_m","ta",!0),C={ha:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,$=k?O:"ha",G=[];function z(t,e){k||$ in t||D(t,C),t[$]|=e}function W(t,e){k||$ in t||D(t,C),t[$]=e}function R(t,e){return 2&e&&(t|=2),1|t}W(G,7),U=Object.freeze(G);var H={};function q(t,e){return void 0===e?t.i!==K&&!!(2&t.m[$]):!!(2&e)&&t.i!==K}var K={};function J(t,e){if(null!=t)if("string"==typeof t)t=t?new B(t,A):_||=new B(null,A);else if(!(t instanceof B))if(v&&null!=t&&t instanceof Uint8Array)t=t.length?new B(new Uint8Array(t),A):_||=new B(null,A);else{if(!e)throw Error();t=void 0}return t}function X(t){return t.sa=!0,t}var Y=X(t=>"number"==typeof t),Z=X(t=>"string"==typeof t),Q=X(t=>"boolean"==typeof t),tt="function"==typeof e.BigInt&&"bigint"==typeof e.BigInt(0);function et(t){var e=t;if(Z(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(Y(e)&&!Number.isSafeInteger(e))throw Error(String(e));return tt?BigInt(t):t=Q(t)?t?"1":"0":Z(t)?t.trim()||"0":String(t)}var rt=X(t=>tt?t>=nt&&t<=at:"-"===t[0]?st(t,it):st(t,ot)),it=Number.MIN_SAFE_INTEGER.toString(),nt=tt?BigInt(Number.MIN_SAFE_INTEGER):void 0,ot=Number.MAX_SAFE_INTEGER.toString(),at=tt?BigInt(Number.MAX_SAFE_INTEGER):void 0;function st(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 i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var lt,ut=0,ht=0;function ct(t){var e=t>>>0;ut=e,ht=(t-e)/4294967296>>>0}function ft(t){if(t<0){ct(-t);let[e,r]=yt(ut,ht);ut=e>>>0,ht=r>>>0}else ct(t)}function dt(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:pt(t,e)}function pt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else j()?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+mt(r)+mt(t));return r}function mt(t){return t=String(t),"0000000".slice(t.length)+t}function vt(){var t=ut,e=ht;if(2147483648&e)if(j())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=yt(t,e);t="-"+pt(r,i)}else t=pt(t,e);return t}function gt(t){if(t.length<16)ft(Number(t));else if(j())t=BigInt(t),ut=Number(t&BigInt(4294967295))>>>0,ht=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ht=ut=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));ht*=1e6,(ut=1e6*ut+e)>=4294967296&&(ht+=Math.trunc(ut/4294967296),ht>>>=0,ut>>>=0)}if(e){let[t,e]=yt(ut,ht);ut=t,ht=e}}}function yt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var bt="function"==typeof BigInt?BigInt.asIntN:void 0,wt="function"==typeof BigInt?BigInt.asUintN:void 0,St=Number.isSafeInteger,_t=Number.isFinite,At=Math.trunc;function Bt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var Tt,xt,It,Et=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Pt(t){switch(typeof t){case"bigint":return!0;case"number":return _t(t);case"string":return Et.test(t);default:return!1}}function jt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return _t(t)?0|t:void 0}function kt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(gt(t),vt())}function Lt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(gt(t),pt(ut,ht))}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(bt(64,t));if(Pt(t)){if("string"===e)return e=At(Number(t)),St(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=kt(t)),t;if("number"===e)return function(t){if(t=At(t),!St(t)){ft(t);var e=ut,r=ht;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=dt(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function Ot(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(wt(64,t));if(Pt(t)){if("string"===e)return e=At(Number(t)),St(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=At(t))>=0&&St(t)||(ft(t),t=dt(ut,ht)),t}(t)}}function Nt(t){if(null==t||"string"==typeof t||t instanceof B)return t}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Vt(t,e,r){if(null!=t&&t[M]===H)return t;if(Array.isArray(t)){var i=0|t[$];return(r=i|32&r|2&r)!==i&&W(t,r),new e(t)}}function Mt(t){return t}function Ct(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),h=u?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,!u||128&e||n||(l=!0,s=(Tt??Mt)(s-h,h,t,c,void 0)+h)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-h;(e??={})[t]=a}else o[n]=a}if(c)for(let n in c){if(null==(t=c[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+h)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Dt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return rt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[$];return 0===t.length&&1&e?void 0:Ct(t,e,Dt)}if(null!=t&&t[M]===H)return $t(t);if(t instanceof B){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(g){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),m(),r=f[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function $t(t){return Ct(t=t.m,0|t[$],Dt)}function Gt(t,e,r,n=0){if(null==t){var o=32;r?(t=[r],o|=128):t=[],e&&(o=-16760833&o|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(o=0|t[$],i&&1&o)throw Error("rfarr");if(2048&o&&!(2&o)&&function(){if(i)throw Error("carr");P(V,5)}(),256&o)throw Error("farr");if(64&o)return(o|n)!==o&&W(t,o|n),t;if(r&&(o|=128,r!==t[0]))throw Error("mid");t:{o|=64;var a=(r=t).length;if(a){var s=a-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&o?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(a=+l)<s&&(r[a+e]=t[l],delete t[l]);o=-16760833&o|(1023&s)<<14;break t}}if(e){if((l=Math.max(e,a-(128&o?0:-1)))>1024)throw Error("spvt");o=-16760833&o|(1023&l)<<14}}}return W(t,64|o|n),t}function zt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[$];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Rt(t,r,!1,e&&!(16&r)):(z(t,34),4&r&&Object.freeze(t))),t}return null!=t&&t[M]===H?q(t,r=0|(e=t.m)[$])?t:Jt(t,e,r)?Wt(t,e):Rt(e,r):t instanceof B?t:void 0}function Wt(t,e,r){return t=new t.constructor(e),r&&(t.i=K),t.o=K,t}function Rt(t,e,r,i){return i??=!!(34&e),t=Ct(t,e,zt,i),i=32,r&&(i|=2),W(t,e=16769217&e|i),t}function Ht(t){if(t.i!==K)return!1;var e=t.m;return z(e=Rt(e,0|e[$]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function qt(t){if(!Ht(t)&&q(t,0|t.m[$]))throw Error()}function Kt(t,e){void 0===e&&(e=0|t[$]),32&e&&!(4096&e)&&W(t,4096|e)}function Jt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&(W(e,2|r),t.i=K,!0)}function Xt(t,e,r){if(null!==(t=Yt(t.m,e,void 0,r)))return t}function Yt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Zt(t,e,r){qt(t);var i=t.m;return Qt(i,0|i[$],e,r),t}function Qt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[$])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function te(t,e,r){return t=Yt(t,e,r),Array.isArray(t)?t:U}function ee(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function re(t){return J(t,!0)}function ie(t){if(k)return t[N]??(t[N]=new Map);if(N in t)return t[N];var e=new Map;return Object.defineProperty(t,N,{value:e}),e}function ne(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Yt(e,o)&&(0!==n&&(r=Qt(e,r,n)),n=o)}return t.set(i,n),n}function oe(t,e,r,i){var n=!1;if(i=function(t,e,r){return Yt(t,e,void 0,r)}(t,i,t=>{var i=Vt(t,r,e);return n=i!==t&&null!=i,i}),null!=i)return n&&!q(i)&&Kt(t,e),i}function ae(t,e,r){var i=t.m,n=0|i[$];if(null==(e=oe(i,n,e,r)))return e;if(!q(t,n=0|i[$])){var o,a=e;let s=a.m,l=0|s[$];(o=q(a,l)?Jt(a,s,l)?Wt(a,s,!0):new a.constructor(Rt(s,l,!1)):a)!==e&&(Ht(t)&&(n=0|(i=t.m)[$]),Kt(i,n=Qt(i,n,r,e=o)))}return e}function se(t){return null==t&&(t=void 0),t}function le(t,e,r){return Zt(t,e,r=se(r)),r&&!q(r)&&Kt(t.m),t}function ue(t,e,r,i){t:{var n=i=se(i);qt(t);let s=t.m;var o=0|s[$];if(null==n){var a=ie(s);if(ne(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=ie(a=s),i=ne(t,a,o,r);i!==e&&(i&&(o=Qt(a,o,i)),t.set(r,e))}Qt(s,o,e,n)}return i&&!q(i)&&Kt(t.m),t}function he(t,e){return-273&(2&e?2|t:-3&t)}function ce(t,e){var r=mi;qt(t);var i=t.m,n=i,o=0|i[$],a=(t?q(t,o):2&o)?1:2;2===a&&t&&Ht(t)&&(o=0|(n=t.m)[$]);var s=te(n,8),l=s===U?7:0|s[$],u=R(l,o);if(t=!(4&u)){var h=o;let t=!!(2&u);t&&(h|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Vt(s[n],r,h);if(o instanceof r){if(!t){let t=q(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&(W(s,u),2&u&&Object.freeze(s)),u=l=u,(h=ee(l))&&2===a&&(s=Array.prototype.slice.call(s),u=0,l=he(l,o),o=Qt(n,o,8,s),h=!1),h||(1===a||4===a&&(2&l||!(16&l)&&32&o)?((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&W(s,l),Object.freeze(s)):l!==u&&W(s,l)),2&l||!(4096&l||16&l)||Kt(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===U?7:0|a[$],(e=q(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&W(a,r),e||Kt(i)}function fe(t,e,r){return Zt(t,e,null==r?r:function(t){if(!Pt(t))throw E("int64");switch(typeof t){case"string":var e=At(Number(t));return St(e)?t=et(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=j()?et(bt(64,BigInt(t))):et(kt(t))),t;case"bigint":return et(bt(64,t));default:return St(t)||(t=At(t),St(t)?t=String(t):(ft(t),t=vt())),et(t)}}(r))}function de(t,e,r){return Zt(t,e,null==r?r:function(t){if(!Pt(t))throw E("uint64");switch(typeof t){case"string":var e=At(Number(t));return St(e)&&e>=0?t=et(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=j()?et(wt(64,BigInt(t))):et(Lt(t))),t;case"bigint":return et(wt(64,t));default:return t>=0&&St(t)||((t=At(t))>=0&&St(t)?t=String(t):(ft(t),t=pt(ut,ht))),et(t)}}(r))}function pe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Zt(t,e,r)}function me(t,e,r){if(null!=r){if(!_t(r))throw E("enum");r|=0}return Zt(t,e,r)}var ve=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ge(t){if("string"==typeof t)return new ve(S(t),!0);if(Array.isArray(t))return new ve(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ve(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ve(t,!1);if(t.constructor===B){T(A);var e=t.i;return e=(null==(e=null==e||v&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?S(e):null)?e:t.i=e)||new Uint8Array(0),new ve(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ve(t,!1);throw Error()}function ye(t){return new Se(4294967295&t,Math.floor(t/4294967296))}function be(t){return t?/^\d+$/.test(t)?(gt(t),new Se(ut,ht)):null:we||=new Se(0,0)}var we,Se=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function _e(t){return new Le(4294967295&t,Math.floor(t/4294967296))}function Ae(t){return t?/^-?\d+$/.test(t)?(gt(t),new Le(ut,ht)):null:Be||=new Le(0,0)}var Be,Te,xe,Ie,Ee,Pe,je,ke,Le=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Ue(t,e,r){return"undefined"!=typeof BigInt64Array?(je||(je=new BigInt64Array(1),ke=new Uint32Array(je.buffer),je[0]=BigInt(1),Pe=1===ke[0]),je[0]=t,new e(ke[t=Pe?0:1],ke[1-t])):(Ee||(Te=BigInt(Number.MIN_SAFE_INTEGER),xe=BigInt(Number.MAX_SAFE_INTEGER),Ie=BigInt(4294967295),Ee=BigInt(32)),t>=Te&&t<=xe?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&Ie),Number(t>>Ee))))}function Oe(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 Ne(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Fe(t,e){if(e>=0)Ne(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Ve(t,e){gt(e),function(t){var e=ht>>31;t(ut<<1^e,(ht<<1|ut>>>31)^e)}((e,r)=>{Oe(t,e>>>0,r>>>0)})}function Me(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 Ce=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function De(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function $e(t,e,r){Ne(t.i,8*e+r)}function Ge(t,e){return $e(t,e,2),e=t.i.end(),De(t,e),e.push(t.j),e}function ze(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 We(t,e,r){if(null!=r)switch($e(t,e,0),typeof r){case"number":t=t.i,ft(r),Oe(t,ut,ht);break;case"bigint":r=Ue(r,Le,_e),Oe(t.i,r.j,r.i);break;default:r=Ae(r),Oe(t.i,r.j,r.i)}}function Re(t,e,r){$e(t,e,2),Ne(t.i,r.length),De(t,t.i.end()),De(t,r)}var He=class{constructor(){this.l=[],this.j=0,this.i=new Ce}};function qe(t){if("string"==typeof t)Ae(t)}function Ke(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Je=Ke(),Xe=Ke(),Ye=Ke(),Ze=Ke(),Qe=Ke(),tr=Ke(),er=Ke(),rr=Ke(),ir=Ke(),nr=Ke(),or=Ke(),ar=Ke(),sr=class{constructor(t,e){this.m=Gt(t,e,void 0,2048)}toJSON(){return $t(this)}};sr.prototype[M]=H,sr.prototype.toString=function(){return this.m.toString()};var lr=class{constructor(t,e){this.i=t,t=Je,this.j=!!t&&e===t||!1}};function ur(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),ze(t,r))}var hr,cr,fr=new lr(ur,Je),dr=new lr(ur,Je),pr=Symbol(),mr=Symbol();function vr(t){var e=yr,r=br,i=t[pr];if(i)return i;(i={}).qa=t,i.ba=function(t){switch(typeof t){case"boolean":return xt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?It||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.fa=n,"function"==typeof(n=t[++o])&&n.length>0&&(i.ia=!0,hr??=n,cr??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let h;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof lr?h=n:(h=fr,o--),h?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,h,l,t):e(i,s,h,t)}}return t[pr]=i}function gr(t,e){return t instanceof sr?t.m:Array.isArray(t)?Gt(t,e[0],e[1]):void 0}function yr(t,e,r){t[e]=r.i}function br(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=vr(i).ba,n||=wr(i))}function wr(t){var e=t[mr];if(!e){let r=vr(t);e=(t,e)=>Sr(t,e,r),t[mr]=e}return e}function Sr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[$],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.fa)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof lr?r:[dr,r]:[r,void 0])[0].i;if(r=r[1]){let e=wr(r),n=vr(r).ba;r=t.ia?cr(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||P(F,3)}})}function _r(t,e,r){if(Array.isArray(e)){var i=0|e[$];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&W(e,t),r&&2&t&&Object.freeze(e),e}}var Ar=(t,e)=>{var r=new He;Sr(t.m,r,vr(e)),De(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function Br(t,e){return new lr(t,e)}function Tr(t,e){return new lr(t,e)}function xr(t,e,r){null!=(e=Ut(e))&&(qe(e),We(t,r,e))}function Ir(t,e,r){null!=(e=jt(e))&&null!=e&&($e(t,r,0),Fe(t.i,e))}function Er(t,e,r){null!=(e=Ft(e))&&Re(t,r,a(e))}function Pr(t,e,r,i,n){null!=(e=gr(e,i))&&(r=Ge(t,r),n(e,t),ze(t,r))}function jr(t,e,r){null!=(e=Nt(e))&&Re(t,r,ge(e).buffer)}function kr(t,e,r){null!=(e=jt(e))&&(e=parseInt(e,10),$e(t,r,0),Fe(t.i,e))}var Lr,Ur=Br(function(t,e,r){null!=(e=Bt(e))&&($e(t,r,1),t=t.i,(r=lt||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),ut=r.getUint32(0,!0),ht=r.getUint32(4,!0),Me(t,ut),Me(t,ht))},nr),Or=Br(function(t,e,r){null!=(e=Bt(e))&&($e(t,r,5),t=t.i,(r=lt||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ht=0,Me(t,ut=r.getUint32(0,!0)))},ir),Nr=Br(xr,tr),Fr=Br(xr,tr),Vr=Tr(function(t,e,r){if(null!=(e=_r(Ut,e,!1)))for(let i=0;i<e.length;i++)We(t,r,e[i])},tr),Mr=Br(function(t,e,r){if(null!=(e=Ot(e))){if("string"==typeof e)be(e);if(null!=e)switch($e(t,r,0),typeof e){case"number":t=t.i,ft(e),Oe(t,ut,ht);break;case"bigint":r=Ue(e,Se,ye),Oe(t.i,r.j,r.i);break;default:r=be(e),Oe(t.i,r.j,r.i)}}},er),Cr=Br(Ir,Ze),Dr=Tr(function(t,e,r){if(null!=(e=_r(jt,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&($e(i,n,0),Fe(i.i,o))}},Ze),$r=Tr(function(t,e,r){if(null!=(e=_r(jt,e,!0))&&e.length){r=Ge(t,r);for(let r=0;r<e.length;r++)Fe(t.i,e[r]);ze(t,r)}},Ze),Gr=Br(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&($e(t,r,0),t.i.i.push(e?1:0))},Xe),zr=Br(Er,Ye),Wr=Tr(function(t,e,r){if(null!=(e=_r(Ft,e,!0)))for(let s=0;s<e.length;s++){var i=t,n=r,o=e[s];null!=o&&Re(i,n,a(o))}},Ye),Rr=function(t,e,r=Je){return new lr(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Pr(t,e[o],r,i,n);1&(t=0|e[$])||W(e,1|t)}}),Hr=new lr(Pr,Je),qr=Br(jr,or),Kr=Tr(function(t,e,r){if(null!=(e=_r(Nt,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&Re(i,n,ge(o).buffer)}},or),Jr=Br(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 _t(t)?t>>>0:void 0}(e),null!=e&&null!=e&&($e(t,r,0),Ne(t.i,e))},Qe),Xr=Br(kr,ar),Yr=Br(kr,ar),Zr=Br(function(t,e,r){if(null!=(e=Ut(e))&&(qe(e),null!=e))switch($e(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,ct(r=2*Math.abs(r)),r=ut;let i=ht;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),Oe(t,ut=r,ht=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),ut=Number(BigInt.asUintN(32,e)),ht=Number(BigInt.asUintN(32,e>>BigInt(32))),Oe(t,ut,ht);break;default:Ve(t.i,e)}},rr),Qr=[0,qr,Kr,Gr,zr],ti=[0,Br(Er,Ye),[0,Yr,[0,Br(xr,tr),Br(Ir,Ze)],Yr,-1,[0,Xr],Yr,-1],Br(jr,or)],ei=[0,1,[0,12,Cr,10,Gr],[0,7,[0,Cr,-1]]],ri=globalThis.trustedTypes;var ii=class{constructor(t){this.i=t}toString(){return this.i+""}};function ni(t){var e;return void 0===Lr&&(Lr=function(){var t=null;if(!ri)return t;try{let e=t=>t;t=ri.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Lr)?e.createScriptURL(t):t,new ii(t)}function oi(t,...e){if(0===e.length)return ni(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ni(r)}var ai=class extends sr{constructor(t){super(t)}},si=class extends sr{constructor(t){super(t)}},li=class extends sr{constructor(t){super(t)}},ui=[1,2,3,4,5,6],hi=class extends sr{constructor(t){super(t)}j(){return null!=Xt(this,1,re)}l(){return null!=Ft(Xt(this,2))}},ci=class extends sr{constructor(t){super(t)}};function fi(t,e,r){return r=`wasm${r?"_module":""}_internal`,Promise.resolve({wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`})}var di=class{};function pi(t){return me(new mi,1,t)}di.forVisionTasks=function(t,e=!1){return fi("vision",t??oi``,e)},di.forLiteRtLmTextTasks=function(t,e=!1){return fi("litertlm_text",t??oi``,e)},di.forTextTasks=function(t,e=!1){return fi("text",t??oi``,e)},di.forRetrievalTasks=function(t,e=!1){return fi("retrieval",t??oi``,e)},di.forGenAiTasks=function(t,e=!1){return fi("genai",t??oi``,e)},di.forDecisionTasks=function(t,e=!1){return fi("decision",t??oi``,e)},di.forAudioTasks=function(t,e=!1){return fi("audio",t??oi``,e)};var mi=class extends sr{constructor(t){super(t)}},vi=class extends sr{constructor(t){super(t)}},gi=[0,Xr,2,Mr,-2,Fr,Rr,[0,Xr,Fr]],yi=class extends sr{constructor(t){super(t)}},bi=class extends sr{constructor(t){super(t)}};function wi(t){var e=new _i;return e=me(e,1,30),me(e,2,t)}var Si,_i=class extends sr{constructor(t){super(t)}},Ai=[3,4,5,6,7],Bi=class extends sr{constructor(t){super(t)}},Ti=class extends sr{constructor(t){super(t)}};Ti.prototype.j=(Si=[0,[0,Xr,zr,-3,Xr],[0,Ai,Xr,-1,Hr,[0,Xr,zr,Mr],Hr,gi,Hr,[0,1,gi],Hr,[0,Xr],Hr,[0,Xr,zr,Mr]]],function(){return Ar(this,Si)});var xi=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.W>0?setTimeout(()=>{i.abort()},t.W):void 0;try{let n=await fetch(t.url,{method:t.pa,headers:{...t.oa},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.W&&i?i.signal:null});n.ok?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(0)}finally{clearTimeout(n)}}},Ii=class extends sr{constructor(t){super(t,37)}},Ei=[-4,{},ei,Xr,ti],Pi=[0,zr,Xr,1,zr,-1,Xr,1,Xr,1,Fr],ji=[0,Xr,zr,-2],ki=[0,zr,Xr],Li=[0,zr,Xr],Ui=[0,Gr,-3],Oi=[0,Xr,zr,-1,Fr,Cr,-1,zr,-5,Rr,[0,zr,-4],-1,Gr,[0,Gr,-3],Xr];var Ni=class extends sr{constructor(t){super(t,19)}},Fi=function(t){return e=>Ar(e,t)}([-19,{},[0,Xr,1,[0,zr,-6,Fr,Cr,zr,-1,Fr],1,[0,zr,1,zr,-5],zr,-1,[0,Xr,zr,-8],[0,zr,-3],[0,zr,Xr,zr,-2],[0,zr,-1,Xr,zr,-1,Xr,zr,-1,[0,Rr,[0,zr,-1],Gr,zr,-5],[0,Xr,Gr,Cr,-2]],Fr,[0,zr,-3,Fr,Cr,zr,-1],[0,Xr,zr,-1],[0,zr,-9],[0,zr,-6,Xr,zr,1,zr,Gr,Xr,-1,Gr,zr,-2,Xr,zr,Xr,zr,Cr,-1],1,[0,Xr],1,[0,zr,-4],1,Pi,[0,[1,2,3,4,5,6],Hr,Pi,Hr,ki,Hr,Li,Hr,[0,Xr],Hr,Oi,Hr,ji],ki,Li,Oi,[0,[0,Xr,zr,-1,Fr,Cr,-1,zr,-4,Rr,[0,zr,-4],-1,1,Ui],[0,Xr,zr,-1,Fr,Cr,-1,zr,-4,Ui]],ji,[0,zr,[0,Cr,-3,Xr],Xr,-2,[0,Cr,-1],Gr],4,[0,zr,Xr,zr,-1,Fr,Xr,zr,-1,Xr,Cr,-1]],Xr,Rr,[-37,{},Nr,zr,Rr,[0,zr,-1],qr,1,qr,[0,Wr,-1,Dr,Vr,-1],zr,[0,Cr,zr,-1],Gr,Cr,Fr,zr,-1,Zr,Qr,Nr,qr,Xr,Dr,Fr,-1,[0,Xr,-1],zr,Gr,zr,$r,zr,-1,Ur,1,Ur,Ei,Gr,[0,Xr,[0,Or,Cr,-2],[0,Or]],[0,Xr,Fr]],Nr,Kr,zr,-1,Nr,Xr,-1,[0,Gr,-1,Xr,Gr],[0,Fr,-1,zr],[0,Nr,Gr,Fr],Fr,1,Jr,1,Ei]),Vi=class{constructor(t){this.j=[],this.o=new xi,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 Ni;qt(e=me(e,2,1786));var r=e.m,i=0|r[$];if(null==t)Qt(r,i,3);else{var n=t===U?7:0|t[$],o=n,a=ee(n),s=a||Object.isFrozen(t),l=!0,u=!0;for(let e=0;e<t.length;e++){var h=t[e];a||(h=q(h),l&&=!h,u&&=h)}a||(n=l?13:5,n=u?-4097&n:4096|n),s&&n===o||(t=Array.prototype.slice.call(t),o=0,n=he(n,i)),n!==o&&W(t,n),i=Qt(r,i,3,t),2&n||!(4096&n||16&n)||Kt(r,i)}return e}(r),r=Fi(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",pa:"POST",W:1e4,body:r,ra:2,oa:{"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 Mi{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Ci(t,e){var r=new Ti;r=le(r,1,t.L),r=le(r,2,e),e=Zt(e=new Ii,6,J(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Di(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},i=wi(1);r=$i(t,r),Ci(t,i=ue(i,4,Ai,r)),t.l=e}function $i(t,e){var r=new vi;return t=de(t=fe(t=me(r,1,t.J),7,e.B),5,e.D),t=de(t,6,e.M),e.G>0&&de(t,4,e.I/e.G),0!==e.F&&ce(t,r=fe(r=pi(3),2,e.F)),0!==e.H&&ce(t,e=fe(r=pi(4),2,e.H)),t}var Gi=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Mi,this.l=new Mi,this.C=new Vi(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 Bi,"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=pe(t=me(t,1,e),2,""),t=pe(t,3,""),t=pe(t,4,"1.2.3"),t=pe(t,5,""),this.L=me(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}())}aa(){var t=new bi;t=de(t=me(t,1,this.J),3,performance.now()-this.K),Ci(this,t=ue(wi(0),3,Ai,t)),this.o=performance.now()}T(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,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Di(this,e)}}ja(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Di(this,t);var e=new yi;e=le(e,2,t=$i(this,t)),Ci(this,e=ue(t=wi(2),5,Ai,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function zi(){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 Wi(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 Ri(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 Hi(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function qi(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function Ki(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Ji=function(t){return class extends t{get X(){return this.h}ga(){if("function"==typeof this.X._mediapipeLoggerGetEncodedApiKey){let t=this.X._mediapipeLoggerGetEncodedApiKey();return this.X._decodeBase64(t)}}}}(function(t){return class extends t{na(){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:zi()?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,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Ri(this,i||"input_audio",i=>{Ri(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,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,i,n){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),Ri(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Ri(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Ri(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Ri(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Ri(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Ri(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Ri(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Ri(this,e,e=>{Ri(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Ri(this,e,e=>{Hi(this,Object.keys(t),i=>{Hi(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Ri(this,r,r=>{Ri(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Ri(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Ri(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Ri(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Ri(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Ri(this,e,e=>{Ri(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Ri(this,r,r=>{Ri(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Ri(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){Ri(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){Ri(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){Ri(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){Ri(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){Ri(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)Ri(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){qi(this,t,e),Ri(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){Ki(this,t,e),Ri(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){qi(this,t,e),Ri(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){Ki(this,t,e),Ri(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?'),qi(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Ri(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}})),Xi=class extends Ji{};async function Yi(t,e){var r=await(async(t,e,r)=>{var i=bn;if(t&&await Wi(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await Wi(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 i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return Zi(r,e),await r.U(e),r}function Zi(t,e){e=e.ua??"";var r=t.j.ga();t.l=new Gi(e,r)}function Qi(t,e){try{t.j.h.FS_unlink("/model.litertlm")}catch{}t.j.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!0),pe(e=ae(t.baseOptions,hi,1)||new hi,2,"/model.litertlm"),Zt(e,1),le(t.baseOptions,1,e)}function tn(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(!(ae(t.baseOptions,hi,1)?.j()||ae(t.baseOptions,hi,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=ae(t.baseOptions,li,3);if(!r){var i=r=new li,n=new si;ue(i,4,ui,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new ai,ue(e,2,ui,i)):(e=r,i=new si,ue(e,4,ui,i))),le(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=>{Qi(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)Qi(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{Qi(t,e)})}return Promise.resolve()}function en(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 rn=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.na(),this.j.setGraph(t,e),this.l?.aa(),en(this)}finishProcessing(t){this.j.finishProcessing(),en(this),this.l&&void 0!==t&&this.l.T(t)}close(){this.l?.ja(),this.l?.close(),this.j.closeGraph()}};function nn(t){return!!(t?.imageBytes&&t.imageBytes.byteLength>0)||!!(t?.audioSamples&&t.audioSamples.length>0)}function on(t,e){var r="object"==typeof t&&null!==t,i=(r?t.imageBytes:void 0)??e?.imageBytes;return e=(r?t.audioSamples:void 0)??e?.audioSamples,{text:r?t.text??"":t,imageBytes:i,audioSamples:e,N:!!(i&&i.byteLength>0)||!!(e&&e.length>0)}}function an(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function sn(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function ln(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)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,S:r,R:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,S:i,R:!1}}function un(t){if(0===t.length)return[];t=[...t].sort((t,e)=>t.probability!==e.probability?e.probability-t.probability:t.key<e.key?-1:t.key>e.key?1:0);var e=[],r=0;for(let i of t)if(e.push(i.key),(r+=i.probability)>=.9)break;return e}function hn(t){if(void 0!==t.predictionSet)return{...t,predictionSet:t.predictionSet};var e=Object.entries(t.probabilities??{}).map(([t,e])=>({key:t,probability:e}));return{...t,predictionSet:un(e)}}function cn(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}rn.prototype.close=rn.prototype.close;var fn=[];async function dn(t,e){var r=fn.pop();if(r){Zi(t=new bn(r,null),e);try{return await t.U(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Yi(t,e)}(t,e)}function pn(t,e){var r=t.Y.then(()=>{var r=t.ca++;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?.T(r),e),e=>{throw t.l?.T(r),e})});return t.Y=r.then(()=>{},()=>{}),r}function mn(t){if(!t)return 0;var e=t.context?an(t.context):0;for(let r of t.questions??[]){e+=an(r.prompt)+4;for(let t of r.options??[])e+=an(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function vn(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 gn(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 yn(t,e,r,i){var n=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:i}=gn(t,o,vn(r));return n.HEAPU8.set(r,e),{u:e,v:i,size:o}}if(i=i&&i>0?i: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&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){e=[];for(var a=0;a<30;){let{value:t,done:i}=await r.read();if(i)break;t&&t.byteLength>0&&(e.push(t),a+=Number(t.byteLength))}if(0===a)return{u:0,v:0,size:0};let l=e[0];if(l.byteLength<30&&e.length>1)for(var s of(l=new Uint8Array(Math.min(a,30)),a=0,e)){let t=Math.min(s.byteLength,l.byteLength-a);if(l.set(s.subarray(0,t),a),(a+=t)>=l.byteLength)break}let{u:u,v:h}=gn(t,i,vn(l));for(o of(t=0,e)){if(t+(s=Number(o.byteLength))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(o,u+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))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(e,u+t>>>0),t+=o}}return{u:u,v:h,size:t}}for(o=[],i=0;;){let{value:t,done:e}=await r.read();if(e)break;t&&t.byteLength>0&&(s=Number(t.byteLength),o.push(t),i+=s)}if(0===i)return{u:0,v:0,size:0};r=o[0];var{u:l,v:u}=gn(t,i,r?vn(r):0);for(t=0,r=0;r<o.length;r++)(s=o[r])&&(n.HEAPU8.set(s,l+t>>>0),t+=s.byteLength,o[r]=void 0);return{u:l,v:u,size:i}}var bn=class extends rn{constructor(t,e){super(new Xi(t,e)),this.baseOptions=new ci,this.L=this.C=this.K=this.A=this.i=this.maxNumTokens=this.backendType=0,this.Z=!1,this.ca=this.J=0,this.Y=Promise.resolve()}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}V(t){this.P=t,this.J=mn(t)}async O(t){if(0!==this.i){var e=t.questions??[];if(0!==e.length){var r=this.j.h;"function"==typeof r.prewarmSchema?await pn(this,()=>r.prewarmSchema(this.i,t.context??"",e)):await pn(this,()=>r.evaluateSchema(this.i,"__PREWARM__",t.context??"",e))}}}async prewarmChoice(t){if(0!==this.i){var e=sn(t);if(0!==Object.keys(e).length){var r=t.instructions??"",i=t.context?r?`${t.context}\n${r}`:t.context:r,n=this.j.h;if("function"==typeof n.prewarmChoice)await pn(this,()=>n.prewarmChoice(this.i,e,t.options??[],t.temperature??0,i,t.normalizePrior??!1));else{var o=new Map;for(var a of t.options??[])o.set(a.label,a);a=Object.entries(e).map(([t,e])=>{var r=o.get(t);return r?{...r,label:t,description:e}:{label:t,description:e}}),await this.O({context:t.context,questions:[{id:"__choice__",type:"choice",prompt:r,options:a,temperature:t.temperature,normalizePrior:t.normalizePrior}]})}}}}async la(t){0!==this.i&&(t.options&&t.options.length>=2?await this.prewarmChoice({options:t.options,instructions:t.condition,context:t.context,temperature:t.temperature,normalizePrior:t.normalizePrior}):await this.O({context:t.context,questions:[{id:"__boolean__",type:"boolean",prompt:t.condition,threshold:t.threshold,temperature:t.temperature,normalizePrior:t.normalizePrior}]}))}async ma(t){if(0!==this.i){var{rubric:e}=ln(t);0!==e.length&&await this.O({context:t.context,questions:[{id:"__score__",type:"score",prompt:t.instructions??"",options:e.map(t=>({label:"",description:t})),temperature:t.temperature}]})}}async ka(t,e){return t=e?.context?`${e.context}\n${t}`:t,mn(this.P)+an(t)}async U(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.V(t.schema):(t.questions||t.context||t.expectedInputs)&&this.V({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"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups"]))r.features.has(o)&&n.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:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}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,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await yn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await yn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=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,i,this.backendType,this.maxNumTokens)}else await tn(this,t,i),this.i=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.aa()}evaluateBoolean(t,e){if(0===this.i)throw Error("Decision is already closed.");if(e.options&&e.options.length>=2){let r=void 0!==e.threshold&&e.threshold>0?e.threshold:.5;return this.evaluateChoice(t,{options:e.options,instructions:e.condition,context:e.context,temperature:e.temperature,normalizePrior:e.normalizePrior,imageBytes:e.imageBytes,audioSamples:e.audioSamples}).then(t=>{var i=e.options,n=/^(true|yes|1|allow|allowed|entailment|supported)$/i,o=/^(false|no|0|deny|denied|reject|rejected|contradiction|contradicted|refuted)$/i,a=i.find(t=>n.test(t.label.trim()));return a||=o.test(i[1].label.trim())&&!o.test(i[0].label.trim())?i[0]:i[1],{value:o=(i=t.probabilities[a.label]??0)>=r,probabilityTrue:i,confidence:r>0&&r<1?Math.min(1,Math.max(0,o?(i-r)/(1-r):(r-i)/r)):t.confidence}})}var r=this.j.h,i=e.context?`${e.context}\n${e.condition}`:e.condition,n=e.normalizePrior??!1,o=on(t,e);return o.N?pn(this,()=>r.evaluateContextBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,{imageBytes:o.imageBytes,audioSamples:o.audioSamples},n)):pn(this,()=>r.evaluateBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,n))}evaluateChoice(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,i=sn(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n,a=e.normalizePrior??!1,s=on(t,e);return t=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),(s.N||t?pn(this,()=>r.evaluateContextChoice(this.i,s.text,i,e.options??[],e.temperature??0,o,{imageBytes:s.imageBytes,audioSamples:s.audioSamples},a)):pn(this,()=>r.evaluateChoice(this.i,s.text,i,e.temperature??0,o,a))).then(hn)}async evaluateScore(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,{rubric:i,labels:n,S:o,R:a}=ln(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s,u=on(t,e);return cn(t=u.N?await pn(this,()=>r.evaluateContextScore(this.i,u.text,i,e.temperature??0,l,{imageBytes:u.imageBytes,audioSamples:u.audioSamples})):await pn(this,()=>r.evaluateScore(this.i,u.text,i,e.temperature??0,l)),n,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 i=on(t,r),n=r?.context?i.text?`${r.context}\n${i.text}`:r.context:i.text,o=e.context;t=(i.imageBytes&&i.imageBytes.byteLength>0?70:0)+(i.audioSamples&&i.audioSamples.length>0?Math.ceil(i.audioSamples.length/640):0),this.J=mn(e)+an(n)+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)),function(t,e){t={...t};for(let r of e)"categorical"!==r.type&&"choice"!==r.type||(e=t[r.id])&&void 0===e.predictionSet&&(t[r.id]={...e,predictionSet:un((e.probabilities??[]).map(t=>({key:t.label,probability:t.probability})))});return t}(e=i.N||e?await pn(this,()=>a.evaluateContextSchema(this.i,n,o??"",s,{imageBytes:i.imageBytes,audioSamples:i.audioSamples})):await pn(this,()=>a.evaluateSchema(this.i,n,o??"",s)),s))}async ea(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async da(t,e){if(!this.P)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.P,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if(!(nn(e)||e.options&&e.options.length>=2)&&"function"==typeof i.evaluateBooleanBatch)return pn(this,()=>i.evaluateBooleanBatch(this.i,t,n,e.threshold??.5,e.temperature??0,r,e.normalizePrior??!1));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=sn(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if(o=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),!nn(e)&&!o&&"function"==typeof i.evaluateChoiceBatch)return(await pn(this,()=>i.evaluateChoiceBatch(this.i,t,n,e.temperature??0,a,r,e.normalizePrior??!1))).map(hn);o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,{rubric:n,labels:o,S:a,R:s}=ln(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if(!nn(e)&&"function"==typeof i.evaluateScoreBatch)return(await pn(this,()=>i.evaluateScoreBatch(this.i,t,n,e.temperature??0,u,r))).map(t=>cn(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.Z){this.Z=!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&&!fn.includes(t)&&fn.push(t)}}};return bn.prototype.close=bn.prototype.close,bn.prototype.evaluateScoreBatch=bn.prototype.evaluateScoreBatch,bn.prototype.evaluateChoiceBatch=bn.prototype.evaluateChoiceBatch,bn.prototype.evaluateBooleanBatch=bn.prototype.evaluateBooleanBatch,bn.prototype.classify=bn.prototype.da,bn.prototype.evaluateBatch=bn.prototype.ea,bn.prototype.evaluate=bn.prototype.evaluate,bn.prototype.evaluateScore=bn.prototype.evaluateScore,bn.prototype.evaluateChoice=bn.prototype.evaluateChoice,bn.prototype.evaluateBoolean=bn.prototype.evaluateBoolean,bn.prototype.setOptions=bn.prototype.U,bn.prototype.measureContextUsage=bn.prototype.ka,bn.prototype.prewarmScore=bn.prototype.ma,bn.prototype.prewarmBoolean=bn.prototype.la,bn.prototype.prewarmChoice=bn.prototype.prewarmChoice,bn.prototype.prewarm=bn.prototype.O,bn.prototype.setSchema=bn.prototype.V,bn.createFromModelBuffer=function(t,e,r=0,i=0){return dn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},bn.createFromModelPath=function(t,e,r=0,i=0){return dn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},bn.createFromOptions=dn,t.DecisionMaker=bn,t.FilesetResolver=di,t.TaskRunner=rn,t}({});
2
2
  //# sourceMappingURL=decision_bundle_iife.js.map
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof self?self:{};var e,r,i,n="undefined"!=typeof TextEncoder;function o(t){if(n)t=(e||=new TextEncoder).encode(t);else{let e=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<128)i[e++]=r;else{if(r<2048)i[e++]=r>>6|192;else{if(r>=55296&&r<=57343){if(r<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){r=1024*(r-55296)+o-56320+65536,i[e++]=r>>18|240,i[e++]=r>>12&63|128,i[e++]=r>>6&63|128,i[e++]=63&r|128;continue}n--}r=65533}i[e++]=r>>12|224,i[e++]=r>>6&63|128}i[e++]=63&r|128}}t=e===i.length?i:i.subarray(0,e)}return t}t:{for(var a=["CLOSURE_FLAGS"],s=t,l=0;l<a.length;l++)if(null==(s=s[a[l]])){i=null;break t}i=s}var u=i&&i[748402147];function h(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}r=null==u||u;var c={},f=null;function d(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 i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=f[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}p();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function p(){if(!f){f={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));c[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===f[e]&&(f[e]=t)}}}}var m="undefined"!=typeof Uint8Array,v=!(-1!=h().indexOf("Trident")||-1!=h().indexOf("MSIE"))&&"function"==typeof btoa,g=/[-_.]/g,y={"-":"+",_:"/",".":"="};function b(t){return y[t]||""}function w(t){if(!v)return d(t);t=g.test(t)?t.replace(g,b):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 S,_={},A=class{constructor(t,e){if(B(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function B(t){if(t!==_)throw Error("illegal external caller")}function T(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var x=void 0;function I(t){return T(t=Error(t),"warning"),t}function E(e,r){if(null!=e){var i=x??={},n=i[e]||0;n>=r||(i[e]=n+1,T(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function P(){return"function"==typeof BigInt}var j="function"==typeof Symbol&&"symbol"==typeof Symbol();function k(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,U=k("jas",void 0,!0),O=k(void 0,"1oa"),N=k(void 0,"0ubsb"),F=k(void 0,"0actk"),V=k("m_m","ta",!0),M={ha:{value:0,configurable:!0,writable:!0,enumerable:!1}},C=Object.defineProperties,D=j?U:"ha",$=[];function G(t,e){j||D in t||C(t,M),t[D]|=e}function z(t,e){j||D in t||C(t,M),t[D]=e}function W(t,e){return 2&e&&(t|=2),1|t}z($,7),L=Object.freeze($);var R={};function H(t,e){return void 0===e?t.i!==q&&!!(2&t.m[D]):!!(2&e)&&t.i!==q}var q={};function K(t,e){if(null!=t)if("string"==typeof t)t=t?new A(t,_):S||=new A(null,_);else if(!(t instanceof A))if(m&&null!=t&&t instanceof Uint8Array)t=t.length?new A(new Uint8Array(t),_):S||=new A(null,_);else{if(!e)throw Error();t=void 0}return t}function J(t){return t.sa=!0,t}var X=J(t=>"number"==typeof t),Y=J(t=>"string"==typeof t),Z=J(t=>"boolean"==typeof t),Q="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function tt(t){var e=t;if(Y(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(X(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Q?BigInt(t):t=Z(t)?t?"1":"0":Y(t)?t.trim()||"0":String(t)}var et=J(t=>Q?t>=it&&t<=ot:"-"===t[0]?at(t,rt):at(t,nt)),rt=Number.MIN_SAFE_INTEGER.toString(),it=Q?BigInt(Number.MIN_SAFE_INTEGER):void 0,nt=Number.MAX_SAFE_INTEGER.toString(),ot=Q?BigInt(Number.MAX_SAFE_INTEGER):void 0;function at(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 i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var st,lt=0,ut=0;function ht(t){var e=t>>>0;lt=e,ut=(t-e)/4294967296>>>0}function ct(t){if(t<0){ht(-t);let[e,r]=gt(lt,ut);lt=e>>>0,ut=r>>>0}else ht(t)}function ft(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:dt(t,e)}function dt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else P()?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+pt(r)+pt(t));return r}function pt(t){return t=String(t),"0000000".slice(t.length)+t}function mt(){var t=lt,e=ut;if(2147483648&e)if(P())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=gt(t,e);t="-"+dt(r,i)}else t=dt(t,e);return t}function vt(t){if(t.length<16)ct(Number(t));else if(P())t=BigInt(t),lt=Number(t&BigInt(4294967295))>>>0,ut=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ut=lt=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));ut*=1e6,(lt=1e6*lt+e)>=4294967296&&(ut+=Math.trunc(lt/4294967296),ut>>>=0,lt>>>=0)}if(e){let[t,e]=gt(lt,ut);lt=t,ut=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var yt="function"==typeof BigInt?BigInt.asIntN:void 0,bt="function"==typeof BigInt?BigInt.asUintN:void 0,wt=Number.isSafeInteger,St=Number.isFinite,_t=Math.trunc;function At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var Bt,Tt,xt,It=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){switch(typeof t){case"bigint":return!0;case"number":return St(t);case"string":return It.test(t);default:return!1}}function Pt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return St(t)?0|t:void 0}function jt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(vt(t),mt())}function kt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(vt(t),dt(lt,ut))}function Lt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(Et(t)){if("string"===e)return e=_t(Number(t)),wt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=jt(t)),t;if("number"===e)return function(t){if(t=_t(t),!wt(t)){ct(t);var e=lt,r=ut;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ft(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(bt(64,t));if(Et(t)){if("string"===e)return e=_t(Number(t)),wt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=kt(t)),t;if("number"===e)return function(t){return(t=_t(t))>=0&&wt(t)||(ct(t),t=ft(lt,ut)),t}(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof A)return t}function Nt(t){return null==t||"string"==typeof t?t:void 0}function Ft(t,e,r){if(null!=t&&t[V]===R)return t;if(Array.isArray(t)){var i=0|t[D];return(r=i|32&r|2&r)!==i&&z(t,r),new e(t)}}function Vt(t){return t}function Mt(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),h=u?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,!u||128&e||n||(l=!0,s=(Bt??Vt)(s-h,h,t,c,void 0)+h)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-h;(e??={})[t]=a}else o[n]=a}if(c)for(let n in c){if(null==(t=c[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+h)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Ct(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return et(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[D];return 0===t.length&&1&e?void 0:Mt(t,e,Ct)}if(null!=t&&t[V]===R)return Dt(t);if(t instanceof A){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(v){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),p(),r=c[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function Dt(t){return Mt(t=t.m,0|t[D],Ct)}function $t(t,e,i,n=0){if(null==t){var o=32;i?(t=[i],o|=128):t=[],e&&(o=-16760833&o|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(o=0|t[D],r&&1&o)throw Error("rfarr");if(2048&o&&!(2&o)&&function(){if(r)throw Error("carr");E(F,5)}(),256&o)throw Error("farr");if(64&o)return(o|n)!==o&&z(t,o|n),t;if(i&&(o|=128,i!==t[0]))throw Error("mid");t:{o|=64;var a=(i=t).length;if(a){var s=a-1;let t=i[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&o?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(a=+l)<s&&(i[a+e]=t[l],delete t[l]);o=-16760833&o|(1023&s)<<14;break t}}if(e){if((l=Math.max(e,a-(128&o?0:-1)))>1024)throw Error("spvt");o=-16760833&o|(1023&l)<<14}}}return z(t,64|o|n),t}function Gt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[D];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[V]===R?H(t,r=0|(e=t.m)[D])?t:Kt(t,e,r)?zt(t,e):Wt(e,r):t instanceof A?t:void 0}function zt(t,e,r){return t=new t.constructor(e),r&&(t.i=q),t.o=q,t}function Wt(t,e,r,i){return i??=!!(34&e),t=Mt(t,e,Gt,i),i=32,r&&(i|=2),z(t,e=16769217&e|i),t}function Rt(t){if(t.i!==q)return!1;var e=t.m;return G(e=Wt(e,0|e[D]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function Ht(t){if(!Rt(t)&&H(t,0|t.m[D]))throw Error()}function qt(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&z(t,4096|e)}function Kt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&(z(e,2|r),t.i=q,!0)}function Jt(t,e,r){if(null!==(t=Xt(t.m,e,void 0,r)))return t}function Xt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Yt(t,e,r){Ht(t);var i=t.m;return Zt(i,0|i[D],e,r),t}function Zt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[D])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function Qt(t,e,r){return t=Xt(t,e,r),Array.isArray(t)?t:L}function te(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function ee(t){return K(t,!0)}function re(t){if(j)return t[O]??(t[O]=new Map);if(O in t)return t[O];var e=new Map;return Object.defineProperty(t,O,{value:e}),e}function ie(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Xt(e,o)&&(0!==n&&(r=Zt(e,r,n)),n=o)}return t.set(i,n),n}function ne(t,e,r,i){var n=!1;if(i=function(t,e,r){return Xt(t,e,void 0,r)}(t,i,t=>{var i=Ft(t,r,e);return n=i!==t&&null!=i,i}),null!=i)return n&&!H(i)&&qt(t,e),i}function oe(t,e,r){var i=t.m,n=0|i[D];if(null==(e=ne(i,n,e,r)))return e;if(!H(t,n=0|i[D])){var o,a=e;let s=a.m,l=0|s[D];(o=H(a,l)?Kt(a,s,l)?zt(a,s,!0):new a.constructor(Wt(s,l,!1)):a)!==e&&(Rt(t)&&(n=0|(i=t.m)[D]),qt(i,n=Zt(i,n,r,e=o)))}return e}function ae(t){return null==t&&(t=void 0),t}function se(t,e,r){return Yt(t,e,r=ae(r)),r&&!H(r)&&qt(t.m),t}function le(t,e,r,i){t:{var n=i=ae(i);Ht(t);let s=t.m;var o=0|s[D];if(null==n){var a=re(s);if(ie(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=re(a=s),i=ie(t,a,o,r);i!==e&&(i&&(o=Zt(a,o,i)),t.set(r,e))}Zt(s,o,e,n)}return i&&!H(i)&&qt(t.m),t}function ue(t,e){return-273&(2&e?2|t:-3&t)}function he(t,e){var r=pi;Ht(t);var i=t.m,n=i,o=0|i[D],a=(t?H(t,o):2&o)?1:2;2===a&&t&&Rt(t)&&(o=0|(n=t.m)[D]);var s=Qt(n,8),l=s===L?7:0|s[D],u=W(l,o);if(t=!(4&u)){var h=o;let t=!!(2&u);t&&(h|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Ft(s[n],r,h);if(o instanceof r){if(!t){let t=H(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&(z(s,u),2&u&&Object.freeze(s)),u=l=u,(h=te(l))&&2===a&&(s=Array.prototype.slice.call(s),u=0,l=ue(l,o),o=Zt(n,o,8,s),h=!1),h||(1===a||4===a&&(2&l||!(16&l)&&32&o)?((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&z(s,l),Object.freeze(s)):l!==u&&z(s,l)),2&l||!(4096&l||16&l)||qt(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===L?7:0|a[D],(e=H(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&z(a,r),e||qt(i)}function ce(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw I("int64");switch(typeof t){case"string":var e=_t(Number(t));return wt(e)?t=tt(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?tt(yt(64,BigInt(t))):tt(jt(t))),t;case"bigint":return tt(yt(64,t));default:return wt(t)||(t=_t(t),wt(t)?t=String(t):(ct(t),t=mt())),tt(t)}}(r))}function fe(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw I("uint64");switch(typeof t){case"string":var e=_t(Number(t));return wt(e)&&e>=0?t=tt(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?tt(bt(64,BigInt(t))):tt(kt(t))),t;case"bigint":return tt(bt(64,t));default:return t>=0&&wt(t)||((t=_t(t))>=0&&wt(t)?t=String(t):(ct(t),t=dt(lt,ut))),tt(t)}}(r))}function de(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Yt(t,e,r)}function pe(t,e,r){if(null!=r){if(!St(r))throw I("enum");r|=0}return Yt(t,e,r)}var me=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ve(t){if("string"==typeof t)return new me(w(t),!0);if(Array.isArray(t))return new me(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new me(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new me(t,!1);if(t.constructor===A){B(_);var e=t.i;return e=(null==(e=null==e||m&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?w(e):null)?e:t.i=e)||new Uint8Array(0),new me(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new me(t,!1);throw Error()}function ge(t){return new we(4294967295&t,Math.floor(t/4294967296))}function ye(t){return t?/^\d+$/.test(t)?(vt(t),new we(lt,ut)):null:be||=new we(0,0)}var be,we=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Se(t){return new ke(4294967295&t,Math.floor(t/4294967296))}function _e(t){return t?/^-?\d+$/.test(t)?(vt(t),new ke(lt,ut)):null:Ae||=new ke(0,0)}var Ae,Be,Te,xe,Ie,Ee,Pe,je,ke=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Le(t,e,r){return"undefined"!=typeof BigInt64Array?(Pe||(Pe=new BigInt64Array(1),je=new Uint32Array(Pe.buffer),Pe[0]=BigInt(1),Ee=1===je[0]),Pe[0]=t,new e(je[t=Ee?0:1],je[1-t])):(Ie||(Be=BigInt(Number.MIN_SAFE_INTEGER),Te=BigInt(Number.MAX_SAFE_INTEGER),xe=BigInt(4294967295),Ie=BigInt(32)),t>=Be&&t<=Te?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&xe),Number(t>>Ie))))}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 Oe(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Ne(t,e){if(e>=0)Oe(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Fe(t,e){vt(e),function(t){var e=ut>>31;t(lt<<1^e,(ut<<1|lt>>>31)^e)}((e,r)=>{Ue(t,e>>>0,r>>>0)})}function Ve(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 Me=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function Ce(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function De(t,e,r){Oe(t.i,8*e+r)}function $e(t,e){return De(t,e,2),e=t.i.end(),Ce(t,e),e.push(t.j),e}function Ge(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 ze(t,e,r){if(null!=r)switch(De(t,e,0),typeof r){case"number":t=t.i,ct(r),Ue(t,lt,ut);break;case"bigint":r=Le(r,ke,Se),Ue(t.i,r.j,r.i);break;default:r=_e(r),Ue(t.i,r.j,r.i)}}function We(t,e,r){De(t,e,2),Oe(t.i,r.length),Ce(t,t.i.end()),Ce(t,r)}var Re=class{constructor(){this.l=[],this.j=0,this.i=new Me}};function He(t){if("string"==typeof t)_e(t)}function qe(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Ke=qe(),Je=qe(),Xe=qe(),Ye=qe(),Ze=qe(),Qe=qe(),tr=qe(),er=qe(),rr=qe(),ir=qe(),nr=qe(),or=qe(),ar=class{constructor(t,e){this.m=$t(t,e,void 0,2048)}toJSON(){return Dt(this)}};ar.prototype[V]=R,ar.prototype.toString=function(){return this.m.toString()};var sr=class{constructor(t,e){this.i=t,t=Ke,this.j=!!t&&e===t||!1}};function lr(t,e,r,i,n){null!=(e=vr(e,i))&&(r=$e(t,r),n(e,t),Ge(t,r))}var ur,hr,cr=new sr(lr,Ke),fr=new sr(lr,Ke),dr=Symbol(),pr=Symbol();function mr(t){var e=gr,r=yr,i=t[dr];if(i)return i;(i={}).qa=t,i.ba=function(t){switch(typeof t){case"boolean":return Tt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?xt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.fa=n,"function"==typeof(n=t[++o])&&n.length>0&&(i.ia=!0,ur??=n,hr??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let h;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof sr?h=n:(h=cr,o--),h?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,h,l,t):e(i,s,h,t)}}return t[dr]=i}function vr(t,e){return t instanceof ar?t.m:Array.isArray(t)?$t(t,e[0],e[1]):void 0}function gr(t,e,r){t[e]=r.i}function yr(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=mr(i).ba,n||=br(i))}function br(t){var e=t[pr];if(!e){let r=mr(t);e=(t,e)=>wr(t,e,r),t[pr]=e}return e}function wr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[D],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.fa)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof sr?r:[fr,r]:[r,void 0])[0].i;if(r=r[1]){let e=br(r),n=mr(r).ba;r=t.ia?hr(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||E(N,3)}})}function Sr(t,e,r){if(Array.isArray(e)){var i=0|e[D];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&z(e,t),r&&2&t&&Object.freeze(e),e}}var _r=(t,e)=>{var r=new Re;wr(t.m,r,mr(e)),Ce(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function Ar(t,e){return new sr(t,e)}function Br(t,e){return new sr(t,e)}function Tr(t,e,r){null!=(e=Lt(e))&&(He(e),ze(t,r,e))}function xr(t,e,r){null!=(e=Pt(e))&&null!=e&&(De(t,r,0),Ne(t.i,e))}function Ir(t,e,r){null!=(e=Nt(e))&&We(t,r,o(e))}function Er(t,e,r,i,n){null!=(e=vr(e,i))&&(r=$e(t,r),n(e,t),Ge(t,r))}function Pr(t,e,r){null!=(e=Ot(e))&&We(t,r,ve(e).buffer)}function jr(t,e,r){null!=(e=Pt(e))&&(e=parseInt(e,10),De(t,r,0),Ne(t.i,e))}var kr,Lr=Ar(function(t,e,r){null!=(e=At(e))&&(De(t,r,1),t=t.i,(r=st||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),lt=r.getUint32(0,!0),ut=r.getUint32(4,!0),Ve(t,lt),Ve(t,ut))},ir),Ur=Ar(function(t,e,r){null!=(e=At(e))&&(De(t,r,5),t=t.i,(r=st||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ut=0,Ve(t,lt=r.getUint32(0,!0)))},rr),Or=Ar(Tr,Qe),Nr=Ar(Tr,Qe),Fr=Br(function(t,e,r){if(null!=(e=Sr(Lt,e,!1)))for(let i=0;i<e.length;i++)ze(t,r,e[i])},Qe),Vr=Ar(function(t,e,r){if(null!=(e=Ut(e))){if("string"==typeof e)ye(e);if(null!=e)switch(De(t,r,0),typeof e){case"number":t=t.i,ct(e),Ue(t,lt,ut);break;case"bigint":r=Le(e,we,ge),Ue(t.i,r.j,r.i);break;default:r=ye(e),Ue(t.i,r.j,r.i)}}},tr),Mr=Ar(xr,Ye),Cr=Br(function(t,e,r){if(null!=(e=Sr(Pt,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&(De(i,n,0),Ne(i.i,o))}},Ye),Dr=Br(function(t,e,r){if(null!=(e=Sr(Pt,e,!0))&&e.length){r=$e(t,r);for(let r=0;r<e.length;r++)Ne(t.i,e[r]);Ge(t,r)}},Ye),$r=Ar(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))},Je),Gr=Ar(Ir,Xe),zr=Br(function(t,e,r){if(null!=(e=Sr(Nt,e,!0)))for(let s=0;s<e.length;s++){var i=t,n=r,a=e[s];null!=a&&We(i,n,o(a))}},Xe),Wr=function(t,e,r=Ke){return new sr(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Er(t,e[o],r,i,n);1&(t=0|e[D])||z(e,1|t)}}),Rr=new sr(Er,Ke),Hr=Ar(Pr,nr),qr=Br(function(t,e,r){if(null!=(e=Sr(Ot,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&We(i,n,ve(o).buffer)}},nr),Kr=Ar(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 St(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(De(t,r,0),Oe(t.i,e))},Ze),Jr=Ar(jr,or),Xr=Ar(jr,or),Yr=Ar(function(t,e,r){if(null!=(e=Lt(e))&&(He(e),null!=e))switch(De(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,ht(r=2*Math.abs(r)),r=lt;let i=ut;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),Ue(t,lt=r,ut=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),lt=Number(BigInt.asUintN(32,e)),ut=Number(BigInt.asUintN(32,e>>BigInt(32))),Ue(t,lt,ut);break;default:Fe(t.i,e)}},er),Zr=[0,Hr,qr,$r,Gr],Qr=[0,Ar(Ir,Xe),[0,Xr,[0,Ar(Tr,Qe),Ar(xr,Ye)],Xr,-1,[0,Jr],Xr,-1],Ar(Pr,nr)],ti=[0,1,[0,12,Mr,10,$r],[0,7,[0,Mr,-1]]],ei=globalThis.trustedTypes;var ri=class{constructor(t){this.i=t}toString(){return this.i+""}};function ii(t){var e;return void 0===kr&&(kr=function(){var t=null;if(!ei)return t;try{let e=t=>t;t=ei.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=kr)?e.createScriptURL(t):t,new ri(t)}function ni(t,...e){if(0===e.length)return ii(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ii(r)}var oi=class extends ar{constructor(t){super(t)}},ai=class extends ar{constructor(t){super(t)}},si=class extends ar{constructor(t){super(t)}},li=[1,2,3,4,5,6],ui=class extends ar{constructor(t){super(t)}j(){return null!=Jt(this,1,ee)}l(){return null!=Nt(Jt(this,2))}},hi=class extends ar{constructor(t){super(t)}};function ci(t,e,r){return r=`wasm${r?"_module":""}_internal`,Promise.resolve({wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`})}var fi=class{};function di(t){return pe(new pi,1,t)}fi.forVisionTasks=function(t,e=!1){return ci("vision",t??ni``,e)},fi.forLiteRtLmTextTasks=function(t,e=!1){return ci("litertlm_text",t??ni``,e)},fi.forTextTasks=function(t,e=!1){return ci("text",t??ni``,e)},fi.forRetrievalTasks=function(t,e=!1){return ci("retrieval",t??ni``,e)},fi.forGenAiTasks=function(t,e=!1){return ci("genai",t??ni``,e)},fi.forDecisionTasks=function(t,e=!1){return ci("decision",t??ni``,e)},fi.forAudioTasks=function(t,e=!1){return ci("audio",t??ni``,e)};var pi=class extends ar{constructor(t){super(t)}},mi=class extends ar{constructor(t){super(t)}},vi=[0,Jr,2,Vr,-2,Nr,Wr,[0,Jr,Nr]],gi=class extends ar{constructor(t){super(t)}},yi=class extends ar{constructor(t){super(t)}};function bi(t){var e=new Si;return e=pe(e,1,30),pe(e,2,t)}var wi,Si=class extends ar{constructor(t){super(t)}},_i=[3,4,5,6,7],Ai=class extends ar{constructor(t){super(t)}},Bi=class extends ar{constructor(t){super(t)}};Bi.prototype.j=(wi=[0,[0,Jr,Gr,-3,Jr],[0,_i,Jr,-1,Rr,[0,Jr,Gr,Vr],Rr,vi,Rr,[0,1,vi],Rr,[0,Jr],Rr,[0,Jr,Gr,Vr]]],function(){return _r(this,wi)});var Ti=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.W>0?setTimeout(()=>{i.abort()},t.W):void 0;try{let n=await fetch(t.url,{method:t.pa,headers:{...t.oa},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.W&&i?i.signal:null});n.ok?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(0)}finally{clearTimeout(n)}}},xi=class extends ar{constructor(t){super(t,37)}},Ii=[-4,{},ti,Jr,Qr],Ei=[0,Gr,Jr,1,Gr,-1,Jr,1,Jr,1,Nr],Pi=[0,Jr,Gr,-2],ji=[0,Gr,Jr],ki=[0,Gr,Jr],Li=[0,$r,-3],Ui=[0,Jr,Gr,-1,Nr,Mr,-1,Gr,-5,Wr,[0,Gr,-4],-1,$r,[0,$r,-3],Jr];var Oi=class extends ar{constructor(t){super(t,19)}},Ni=function(t){return e=>_r(e,t)}([-19,{},[0,Jr,1,[0,Gr,-6,Nr,Mr,Gr,-1,Nr],1,[0,Gr,1,Gr,-5],Gr,-1,[0,Jr,Gr,-8],[0,Gr,-3],[0,Gr,Jr,Gr,-2],[0,Gr,-1,Jr,Gr,-1,Jr,Gr,-1,[0,Wr,[0,Gr,-1],$r,Gr,-5],[0,Jr,$r,Mr,-2]],Nr,[0,Gr,-3,Nr,Mr,Gr,-1],[0,Jr,Gr,-1],[0,Gr,-9],[0,Gr,-6,Jr,Gr,1,Gr,$r,Jr,-1,$r,Gr,-2,Jr,Gr,Jr,Gr,Mr,-1],1,[0,Jr],1,[0,Gr,-4],1,Ei,[0,[1,2,3,4,5,6],Rr,Ei,Rr,ji,Rr,ki,Rr,[0,Jr],Rr,Ui,Rr,Pi],ji,ki,Ui,[0,[0,Jr,Gr,-1,Nr,Mr,-1,Gr,-4,Wr,[0,Gr,-4],-1,1,Li],[0,Jr,Gr,-1,Nr,Mr,-1,Gr,-4,Li]],Pi,[0,Gr,[0,Mr,-3,Jr],Jr,-2,[0,Mr,-1],$r],4,[0,Gr,Jr,Gr,-1,Nr,Jr,Gr,-1,Jr,Mr,-1]],Jr,Wr,[-37,{},Or,Gr,Wr,[0,Gr,-1],Hr,1,Hr,[0,zr,-1,Cr,Fr,-1],Gr,[0,Mr,Gr,-1],$r,Mr,Nr,Gr,-1,Yr,Zr,Or,Hr,Jr,Cr,Nr,-1,[0,Jr,-1],Gr,$r,Gr,Dr,Gr,-1,Lr,1,Lr,Ii,$r,[0,Jr,[0,Ur,Mr,-2],[0,Ur]],[0,Jr,Nr]],Or,qr,Gr,-1,Or,Jr,-1,[0,$r,-1,Jr,$r],[0,Nr,-1,Gr],[0,Or,$r,Nr],Nr,1,Kr,1,Ii]),Fi=class{constructor(t){this.j=[],this.o=new Ti,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 Oi;Ht(e=pe(e,2,1786));var r=e.m,i=0|r[D];if(null==t)Zt(r,i,3);else{var n=t===L?7:0|t[D],o=n,a=te(n),s=a||Object.isFrozen(t),l=!0,u=!0;for(let e=0;e<t.length;e++){var h=t[e];a||(h=H(h),l&&=!h,u&&=h)}a||(n=l?13:5,n=u?-4097&n:4096|n),s&&n===o||(t=Array.prototype.slice.call(t),o=0,n=ue(n,i)),n!==o&&z(t,n),i=Zt(r,i,3,t),2&n||!(4096&n||16&n)||qt(r,i)}return e}(r),r=Ni(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",pa:"POST",W:1e4,body:r,ra:2,oa:{"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 Vi{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Mi(t,e){var r=new Bi;r=se(r,1,t.L),r=se(r,2,e),e=Yt(e=new xi,6,K(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Ci(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},i=bi(1);r=Di(t,r),Mi(t,i=le(i,4,_i,r)),t.l=e}function Di(t,e){var r=new mi;return t=fe(t=ce(t=pe(r,1,t.J),7,e.B),5,e.D),t=fe(t,6,e.M),e.G>0&&fe(t,4,e.I/e.G),0!==e.F&&he(t,r=ce(r=di(3),2,e.F)),0!==e.H&&he(t,e=ce(r=di(4),2,e.H)),t}var $i=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Vi,this.l=new Vi,this.C=new Fi(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 Ai,"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=de(t=pe(t,1,e),2,""),t=de(t,3,""),t=de(t,4,"1.2.2"),t=de(t,5,""),this.L=pe(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}())}aa(){var t=new yi;t=fe(t=pe(t,1,this.J),3,performance.now()-this.K),Mi(this,t=le(bi(0),3,_i,t)),this.o=performance.now()}T(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,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Ci(this,e)}}ja(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Ci(this,t);var e=new gi;e=se(e,2,t=Di(this,t)),Mi(this,e=le(t=bi(2),5,_i,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Gi(){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 zi(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 Wi(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 Ri(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function Hi(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function qi(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Ki=function(t){return class extends t{get X(){return this.h}ga(){if("function"==typeof this.X._mediapipeLoggerGetEncodedApiKey){let t=this.X._mediapipeLoggerGetEncodedApiKey();return this.X._decodeBase64(t)}}}}(function(t){return class extends t{na(){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:Gi()?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,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Wi(this,i||"input_audio",i=>{Wi(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,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,i,n){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),Wi(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Wi(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Wi(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Wi(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Wi(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Wi(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Wi(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Wi(this,e,e=>{Wi(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Wi(this,e,e=>{Ri(this,Object.keys(t),i=>{Ri(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Wi(this,r,r=>{Wi(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Wi(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Wi(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Wi(this,e,e=>{Wi(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Wi(this,r,r=>{Wi(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Wi(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){Wi(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){Wi(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){Wi(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){Wi(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){Wi(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)Wi(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){Hi(this,t,e),Wi(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){qi(this,t,e),Wi(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?'),Hi(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Wi(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}})),Ji=class extends Ki{};async function Xi(t,e){var r=await(async(t,e,r)=>{var i=yn;if(t&&await zi(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await zi(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 i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return Yi(r,e),await r.U(e),r}function Yi(t,e){e=e.ua??"";var r=t.j.ga();t.l=new $i(e,r)}function Zi(t,e){try{t.j.h.FS_unlink("/model.litertlm")}catch{}t.j.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!0),de(e=oe(t.baseOptions,ui,1)||new ui,2,"/model.litertlm"),Yt(e,1),se(t.baseOptions,1,e)}function Qi(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(!(oe(t.baseOptions,ui,1)?.j()||oe(t.baseOptions,ui,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=oe(t.baseOptions,si,3);if(!r){var i=r=new si,n=new ai;le(i,4,li,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new oi,le(e,2,li,i)):(e=r,i=new ai,le(e,4,li,i))),se(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=>{Zi(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)Zi(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{Zi(t,e)})}return Promise.resolve()}function tn(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 en=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.na(),this.j.setGraph(t,e),this.l?.aa(),tn(this)}finishProcessing(t){this.j.finishProcessing(),tn(this),this.l&&void 0!==t&&this.l.T(t)}close(){this.l?.ja(),this.l?.close(),this.j.closeGraph()}};function rn(t){return!!(t?.imageBytes&&t.imageBytes.byteLength>0)||!!(t?.audioSamples&&t.audioSamples.length>0)}function nn(t,e){var r="object"==typeof t&&null!==t,i=(r?t.imageBytes:void 0)??e?.imageBytes;return e=(r?t.audioSamples:void 0)??e?.audioSamples,{text:r?t.text??"":t,imageBytes:i,audioSamples:e,N:!!(i&&i.byteLength>0)||!!(e&&e.length>0)}}function on(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function an(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function sn(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)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,S:r,R:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,S:i,R:!1}}function ln(t){if(0===t.length)return[];t=[...t].sort((t,e)=>t.probability!==e.probability?e.probability-t.probability:t.key<e.key?-1:t.key>e.key?1:0);var e=[],r=0;for(let i of t)if(e.push(i.key),(r+=i.probability)>=.9)break;return e}function un(t){if(void 0!==t.predictionSet)return{...t,predictionSet:t.predictionSet};var e=Object.entries(t.probabilities??{}).map(([t,e])=>({key:t,probability:e}));return{...t,predictionSet:ln(e)}}function hn(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}en.prototype.close=en.prototype.close;var cn=[];async function fn(t,e){var r=cn.pop();if(r){Yi(t=new yn(r,null),e);try{return await t.U(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Xi(t,e)}(t,e)}function dn(t,e){var r=t.Y.then(()=>{var r=t.ca++;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?.T(r),e),e=>{throw t.l?.T(r),e})});return t.Y=r.then(()=>{},()=>{}),r}function pn(t){if(!t)return 0;var e=t.context?on(t.context):0;for(let r of t.questions??[]){e+=on(r.prompt)+4;for(let t of r.options??[])e+=on(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function mn(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 vn(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 gn(t,e,r,i){var n=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:i}=vn(t,o,mn(r));return n.HEAPU8.set(r,e),{u:e,v:i,size:o}}if(i=i&&i>0?i: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&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){e=[];for(var a=0;a<30;){let{value:t,done:i}=await r.read();if(i)break;t&&t.byteLength>0&&(e.push(t),a+=Number(t.byteLength))}if(0===a)return{u:0,v:0,size:0};let l=e[0];if(l.byteLength<30&&e.length>1)for(var s of(l=new Uint8Array(Math.min(a,30)),a=0,e)){let t=Math.min(s.byteLength,l.byteLength-a);if(l.set(s.subarray(0,t),a),(a+=t)>=l.byteLength)break}let{u:u,v:h}=vn(t,i,mn(l));for(o of(t=0,e)){if(t+(s=Number(o.byteLength))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(o,u+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))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(e,u+t>>>0),t+=o}}return{u:u,v:h,size:t}}for(o=[],i=0;;){let{value:t,done:e}=await r.read();if(e)break;t&&t.byteLength>0&&(s=Number(t.byteLength),o.push(t),i+=s)}if(0===i)return{u:0,v:0,size:0};r=o[0];var{u:l,v:u}=vn(t,i,r?mn(r):0);for(t=0,r=0;r<o.length;r++)(s=o[r])&&(n.HEAPU8.set(s,l+t>>>0),t+=s.byteLength,o[r]=void 0);return{u:l,v:u,size:i}}var yn=class extends en{constructor(t,e){super(new Ji(t,e)),this.baseOptions=new hi,this.L=this.C=this.K=this.A=this.i=this.maxNumTokens=this.backendType=0,this.Z=!1,this.ca=this.J=0,this.Y=Promise.resolve()}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}V(t){this.P=t,this.J=pn(t)}async O(t){if(0!==this.i){var e=t.questions??[];if(0!==e.length){var r=this.j.h;"function"==typeof r.prewarmSchema?await dn(this,()=>r.prewarmSchema(this.i,t.context??"",e)):await dn(this,()=>r.evaluateSchema(this.i,"__PREWARM__",t.context??"",e))}}}async prewarmChoice(t){if(0!==this.i){var e=an(t);if(0!==Object.keys(e).length){var r=t.instructions??"",i=t.context?r?`${t.context}\n${r}`:t.context:r,n=this.j.h;if("function"==typeof n.prewarmChoice)await dn(this,()=>n.prewarmChoice(this.i,e,t.options??[],t.temperature??0,i,t.normalizePrior??!1));else{var o=new Map;for(var a of t.options??[])o.set(a.label,a);a=Object.entries(e).map(([t,e])=>{var r=o.get(t);return r?{...r,label:t,description:e}:{label:t,description:e}}),await this.O({context:t.context,questions:[{id:"__choice__",type:"choice",prompt:r,options:a,temperature:t.temperature,normalizePrior:t.normalizePrior}]})}}}}async la(t){0!==this.i&&(t.options&&t.options.length>=2?await this.prewarmChoice({options:t.options,instructions:t.condition,context:t.context,temperature:t.temperature,normalizePrior:t.normalizePrior}):await this.O({context:t.context,questions:[{id:"__boolean__",type:"boolean",prompt:t.condition,threshold:t.threshold,temperature:t.temperature,normalizePrior:t.normalizePrior}]}))}async ma(t){if(0!==this.i){var{rubric:e}=sn(t);0!==e.length&&await this.O({context:t.context,questions:[{id:"__score__",type:"score",prompt:t.instructions??"",options:e.map(t=>({label:"",description:t})),temperature:t.temperature}]})}}async ka(t,e){return t=e?.context?`${e.context}\n${t}`:t,pn(this.P)+on(t)}async U(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.V(t.schema):(t.questions||t.context||t.expectedInputs)&&this.V({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"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups"]))r.features.has(o)&&n.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:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}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,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await gn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await gn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=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,i,this.backendType,this.maxNumTokens)}else await Qi(this,t,i),this.i=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.aa()}evaluateBoolean(t,e){if(0===this.i)throw Error("Decision is already closed.");if(e.options&&e.options.length>=2){let r=void 0!==e.threshold&&e.threshold>0?e.threshold:.5;return this.evaluateChoice(t,{options:e.options,instructions:e.condition,context:e.context,temperature:e.temperature,normalizePrior:e.normalizePrior,imageBytes:e.imageBytes,audioSamples:e.audioSamples}).then(t=>{var i=e.options,n=/^(true|yes|1|allow|allowed|entailment|supported)$/i,o=/^(false|no|0|deny|denied|reject|rejected|contradiction|contradicted|refuted)$/i,a=i.find(t=>n.test(t.label.trim()));return a||=o.test(i[1].label.trim())&&!o.test(i[0].label.trim())?i[0]:i[1],{value:o=(i=t.probabilities[a.label]??0)>=r,probabilityTrue:i,confidence:r>0&&r<1?Math.min(1,Math.max(0,o?(i-r)/(1-r):(r-i)/r)):t.confidence}})}var r=this.j.h,i=e.context?`${e.context}\n${e.condition}`:e.condition,n=e.normalizePrior??!1,o=nn(t,e);return o.N?dn(this,()=>r.evaluateContextBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,{imageBytes:o.imageBytes,audioSamples:o.audioSamples},n)):dn(this,()=>r.evaluateBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,n))}evaluateChoice(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,i=an(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n,a=e.normalizePrior??!1,s=nn(t,e);return t=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),(s.N||t?dn(this,()=>r.evaluateContextChoice(this.i,s.text,i,e.options??[],e.temperature??0,o,{imageBytes:s.imageBytes,audioSamples:s.audioSamples},a)):dn(this,()=>r.evaluateChoice(this.i,s.text,i,e.temperature??0,o,a))).then(un)}async evaluateScore(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,{rubric:i,labels:n,S:o,R:a}=sn(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s,u=nn(t,e);return hn(t=u.N?await dn(this,()=>r.evaluateContextScore(this.i,u.text,i,e.temperature??0,l,{imageBytes:u.imageBytes,audioSamples:u.audioSamples})):await dn(this,()=>r.evaluateScore(this.i,u.text,i,e.temperature??0,l)),n,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 i=nn(t,r),n=r?.context?i.text?`${r.context}\n${i.text}`:r.context:i.text,o=e.context;t=(i.imageBytes&&i.imageBytes.byteLength>0?70:0)+(i.audioSamples&&i.audioSamples.length>0?Math.ceil(i.audioSamples.length/640):0),this.J=pn(e)+on(n)+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)),function(t,e){t={...t};for(let r of e)"categorical"!==r.type&&"choice"!==r.type||(e=t[r.id])&&void 0===e.predictionSet&&(t[r.id]={...e,predictionSet:ln((e.probabilities??[]).map(t=>({key:t.label,probability:t.probability})))});return t}(e=i.N||e?await dn(this,()=>a.evaluateContextSchema(this.i,n,o??"",s,{imageBytes:i.imageBytes,audioSamples:i.audioSamples})):await dn(this,()=>a.evaluateSchema(this.i,n,o??"",s)),s))}async ea(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async da(t,e){if(!this.P)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.P,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if(!(rn(e)||e.options&&e.options.length>=2)&&"function"==typeof i.evaluateBooleanBatch)return dn(this,()=>i.evaluateBooleanBatch(this.i,t,n,e.threshold??.5,e.temperature??0,r,e.normalizePrior??!1));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=an(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if(o=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),!rn(e)&&!o&&"function"==typeof i.evaluateChoiceBatch)return(await dn(this,()=>i.evaluateChoiceBatch(this.i,t,n,e.temperature??0,a,r,e.normalizePrior??!1))).map(un);o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,{rubric:n,labels:o,S:a,R:s}=sn(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if(!rn(e)&&"function"==typeof i.evaluateScoreBatch)return(await dn(this,()=>i.evaluateScoreBatch(this.i,t,n,e.temperature??0,u,r))).map(t=>hn(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.Z){this.Z=!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&&!cn.includes(t)&&cn.push(t)}}};yn.prototype.close=yn.prototype.close,yn.prototype.evaluateScoreBatch=yn.prototype.evaluateScoreBatch,yn.prototype.evaluateChoiceBatch=yn.prototype.evaluateChoiceBatch,yn.prototype.evaluateBooleanBatch=yn.prototype.evaluateBooleanBatch,yn.prototype.classify=yn.prototype.da,yn.prototype.evaluateBatch=yn.prototype.ea,yn.prototype.evaluate=yn.prototype.evaluate,yn.prototype.evaluateScore=yn.prototype.evaluateScore,yn.prototype.evaluateChoice=yn.prototype.evaluateChoice,yn.prototype.evaluateBoolean=yn.prototype.evaluateBoolean,yn.prototype.setOptions=yn.prototype.U,yn.prototype.measureContextUsage=yn.prototype.ka,yn.prototype.prewarmScore=yn.prototype.ma,yn.prototype.prewarmBoolean=yn.prototype.la,yn.prototype.prewarmChoice=yn.prototype.prewarmChoice,yn.prototype.prewarm=yn.prototype.O,yn.prototype.setSchema=yn.prototype.V,yn.createFromModelBuffer=function(t,e,r=0,i=0){return fn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},yn.createFromModelPath=function(t,e,r=0,i=0){return fn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},yn.createFromOptions=fn;export{yn as DecisionMaker,fi as FilesetResolver,en as TaskRunner};
1
+ var t="undefined"!=typeof self?self:{};var e,r,i,n="undefined"!=typeof TextEncoder;function o(t){if(n)t=(e||=new TextEncoder).encode(t);else{let e=0,i=new Uint8Array(3*t.length);for(let n=0;n<t.length;n++){var r=t.charCodeAt(n);if(r<128)i[e++]=r;else{if(r<2048)i[e++]=r>>6|192;else{if(r>=55296&&r<=57343){if(r<=56319&&n<t.length){let o=t.charCodeAt(++n);if(o>=56320&&o<=57343){r=1024*(r-55296)+o-56320+65536,i[e++]=r>>18|240,i[e++]=r>>12&63|128,i[e++]=r>>6&63|128,i[e++]=63&r|128;continue}n--}r=65533}i[e++]=r>>12|224,i[e++]=r>>6&63|128}i[e++]=63&r|128}}t=e===i.length?i:i.subarray(0,e)}return t}t:{for(var a=["CLOSURE_FLAGS"],s=t,l=0;l<a.length;l++)if(null==(s=s[a[l]])){i=null;break t}i=s}var u=i&&i[748402147];function h(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}r=null==u||u;var c={},f=null;function d(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 i=new Uint8Array(r),n=0;return function(t,e){function r(e){for(;i<t.length;){let e=t.charAt(i++),r=f[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}p();for(var i=0;;){let t=r(-1),i=r(0),n=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|i>>4),64!=n&&(e(i<<4&240|n>>2),64!=o&&e(n<<6&192|o))}}(t,function(t){i[n++]=t}),n!==r?i.subarray(0,n):i}function p(){if(!f){f={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let i=t.concat(e[r].split(""));c[r]=i;for(let t=0;t<i.length;t++){let e=i[t];void 0===f[e]&&(f[e]=t)}}}}var m="undefined"!=typeof Uint8Array,v=!(-1!=h().indexOf("Trident")||-1!=h().indexOf("MSIE"))&&"function"==typeof btoa,g=/[-_.]/g,y={"-":"+",_:"/",".":"="};function b(t){return y[t]||""}function w(t){if(!v)return d(t);t=g.test(t)?t.replace(g,b):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 S,_={},A=class{constructor(t,e){if(B(e),this.i=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function B(t){if(t!==_)throw Error("illegal external caller")}function T(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var x=void 0;function I(t){return T(t=Error(t),"warning"),t}function E(e,r){if(null!=e){var i=x??={},n=i[e]||0;n>=r||(i[e]=n+1,T(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function P(){return"function"==typeof BigInt}var j="function"==typeof Symbol&&"symbol"==typeof Symbol();function k(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,U=k("jas",void 0,!0),O=k(void 0,"1oa"),N=k(void 0,"0ubsb"),F=k(void 0,"0actk"),V=k("m_m","ta",!0),M={ha:{value:0,configurable:!0,writable:!0,enumerable:!1}},C=Object.defineProperties,D=j?U:"ha",$=[];function G(t,e){j||D in t||C(t,M),t[D]|=e}function z(t,e){j||D in t||C(t,M),t[D]=e}function W(t,e){return 2&e&&(t|=2),1|t}z($,7),L=Object.freeze($);var R={};function H(t,e){return void 0===e?t.i!==q&&!!(2&t.m[D]):!!(2&e)&&t.i!==q}var q={};function K(t,e){if(null!=t)if("string"==typeof t)t=t?new A(t,_):S||=new A(null,_);else if(!(t instanceof A))if(m&&null!=t&&t instanceof Uint8Array)t=t.length?new A(new Uint8Array(t),_):S||=new A(null,_);else{if(!e)throw Error();t=void 0}return t}function J(t){return t.sa=!0,t}var X=J(t=>"number"==typeof t),Y=J(t=>"string"==typeof t),Z=J(t=>"boolean"==typeof t),Q="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function tt(t){var e=t;if(Y(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(X(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Q?BigInt(t):t=Z(t)?t?"1":"0":Y(t)?t.trim()||"0":String(t)}var et=J(t=>Q?t>=it&&t<=ot:"-"===t[0]?at(t,rt):at(t,nt)),rt=Number.MIN_SAFE_INTEGER.toString(),it=Q?BigInt(Number.MIN_SAFE_INTEGER):void 0,nt=Number.MAX_SAFE_INTEGER.toString(),ot=Q?BigInt(Number.MAX_SAFE_INTEGER):void 0;function at(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 i=t[r],n=e[r];if(i>n)return!1;if(i<n)return!0}}var st,lt=0,ut=0;function ht(t){var e=t>>>0;lt=e,ut=(t-e)/4294967296>>>0}function ct(t){if(t<0){ht(-t);let[e,r]=gt(lt,ut);lt=e>>>0,ut=r>>>0}else ht(t)}function ft(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:dt(t,e)}function dt(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else P()?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+pt(r)+pt(t));return r}function pt(t){return t=String(t),"0000000".slice(t.length)+t}function mt(){var t=lt,e=ut;if(2147483648&e)if(P())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,i]=gt(t,e);t="-"+dt(r,i)}else t=dt(t,e);return t}function vt(t){if(t.length<16)ct(Number(t));else if(P())t=BigInt(t),lt=Number(t&BigInt(4294967295))>>>0,ut=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ut=lt=0;let r=t.length;for(let i=e,n=(r-e)%6+e;n<=r;i=n,n+=6){let e=Number(t.slice(i,n));ut*=1e6,(lt=1e6*lt+e)>=4294967296&&(ut+=Math.trunc(lt/4294967296),ut>>>=0,lt>>>=0)}if(e){let[t,e]=gt(lt,ut);lt=t,ut=e}}}function gt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var yt="function"==typeof BigInt?BigInt.asIntN:void 0,bt="function"==typeof BigInt?BigInt.asUintN:void 0,wt=Number.isSafeInteger,St=Number.isFinite,_t=Math.trunc;function At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var Bt,Tt,xt,It=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Et(t){switch(typeof t){case"bigint":return!0;case"number":return St(t);case"string":return It.test(t);default:return!1}}function Pt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return St(t)?0|t:void 0}function jt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(vt(t),mt())}function kt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(vt(t),dt(lt,ut))}function Lt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(Et(t)){if("string"===e)return e=_t(Number(t)),wt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=jt(t)),t;if("number"===e)return function(t){if(t=_t(t),!wt(t)){ct(t);var e=lt,r=ut;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ft(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function Ut(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(bt(64,t));if(Et(t)){if("string"===e)return e=_t(Number(t)),wt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=kt(t)),t;if("number"===e)return function(t){return(t=_t(t))>=0&&wt(t)||(ct(t),t=ft(lt,ut)),t}(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof A)return t}function Nt(t){return null==t||"string"==typeof t?t:void 0}function Ft(t,e,r){if(null!=t&&t[V]===R)return t;if(Array.isArray(t)){var i=0|t[D];return(r=i|32&r|2&r)!==i&&z(t,r),new e(t)}}function Vt(t){return t}function Mt(t,e,r,i){var n=void 0!==i;i=!!i;var o=[],a=t.length,s=4294967295,l=!1,u=!!(64&e),h=u?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,!u||128&e||n||(l=!0,s=(Bt??Vt)(s-h,h,t,c,void 0)+h)}for(e=void 0,n=0;n<a;n++){let a=t[n];if(null!=a&&null!=(a=r(a,i)))if(u&&n>=s){let t=n-h;(e??={})[t]=a}else o[n]=a}if(c)for(let n in c){if(null==(t=c[n])||null==(t=r(t,i)))continue;let l;a=+n,u&&!Number.isNaN(a)&&(l=a+h)<s?o[l]=t:(e??={})[n]=t}return e&&(l?o.push(e):o[s]=e),o}function Ct(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return et(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[D];return 0===t.length&&1&e?void 0:Mt(t,e,Ct)}if(null!=t&&t[V]===R)return Dt(t);if(t instanceof A){if(null==(e=t.i))t="";else if("string"==typeof e)t=e;else{if(v){for(var r="",i=0,n=e.length-10240;i<n;)r+=String.fromCharCode.apply(null,e.subarray(i,i+=10240));r+=String.fromCharCode.apply(null,i?e.subarray(i):e),e=btoa(r)}else{void 0===r&&(r=0),p(),r=c[r],i=Array(Math.floor(e.length/3)),n=r[64]||"";let t=0,u=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],l=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],i[u++]=l+o+a+s}switch(l=0,s=n,e.length-t){case 2:s=r[(15&(l=e[t+1]))<<2]||n;case 1:e=e[t],i[u]=r[e>>2]+r[(3&e)<<4|l>>4]+s+n}e=i.join("")}t=t.i=e}return t}return}return t}function Dt(t){return Mt(t=t.m,0|t[D],Ct)}function $t(t,e,i,n=0){if(null==t){var o=32;i?(t=[i],o|=128):t=[],e&&(o=-16760833&o|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(o=0|t[D],r&&1&o)throw Error("rfarr");if(2048&o&&!(2&o)&&function(){if(r)throw Error("carr");E(F,5)}(),256&o)throw Error("farr");if(64&o)return(o|n)!==o&&z(t,o|n),t;if(i&&(o|=128,i!==t[0]))throw Error("mid");t:{o|=64;var a=(i=t).length;if(a){var s=a-1;let t=i[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&o?0:-1)>=1024)throw Error("pvtlmt");for(var l in t)(a=+l)<s&&(i[a+e]=t[l],delete t[l]);o=-16760833&o|(1023&s)<<14;break t}}if(e){if((l=Math.max(e,a-(128&o?0:-1)))>1024)throw Error("spvt");o=-16760833&o|(1023&l)<<14}}}return z(t,64|o|n),t}function Gt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[D];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[V]===R?H(t,r=0|(e=t.m)[D])?t:Kt(t,e,r)?zt(t,e):Wt(e,r):t instanceof A?t:void 0}function zt(t,e,r){return t=new t.constructor(e),r&&(t.i=q),t.o=q,t}function Wt(t,e,r,i){return i??=!!(34&e),t=Mt(t,e,Gt,i),i=32,r&&(i|=2),z(t,e=16769217&e|i),t}function Rt(t){if(t.i!==q)return!1;var e=t.m;return G(e=Wt(e,0|e[D]),2048),t.m=e,t.i=void 0,t.o=void 0,!0}function Ht(t){if(!Rt(t)&&H(t,0|t.m[D]))throw Error()}function qt(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&z(t,4096|e)}function Kt(t,e,r){return!!(2&r)||!(!(32&r)||4096&r)&&(z(e,2|r),t.i=q,!0)}function Jt(t,e,r){if(null!==(t=Xt(t.m,e,void 0,r)))return t}function Xt(t,e,r,i){if(-1===e)return null;var n=e+(r?0:-1),o=t.length-1;if(!(o<1+(r?0:-1))){if(n>=o){var a=t[o];if(null!=a&&"object"==typeof a&&a.constructor===Object){r=a[e];var s=!0}else{if(n!==o)return;r=a}}else r=t[n];if(i&&null!=r){if(null==(i=i(r)))return i;if(!Object.is(i,r))return s?a[e]=i:t[n]=i,i}return r}}function Yt(t,e,r){Ht(t);var i=t.m;return Zt(i,0|i[D],e,r),t}function Zt(t,e,r,i,n){var o=r+(n?0:-1),a=t.length-1;if(a>=1+(n?0:-1)&&o>=a){let n=t[a];if(null!=n&&"object"==typeof n&&n.constructor===Object)return n[r]=i,e}return o<=a?(t[o]=i,e):(void 0!==i&&(r>=(a=(e??=0|t[D])>>14&1023||536870912)?null!=i&&(t[a+(n?0:-1)]={[r]:i}):t[o]=i),e)}function Qt(t,e,r){return t=Xt(t,e,r),Array.isArray(t)?t:L}function te(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function ee(t){return K(t,!0)}function re(t){if(j)return t[O]??(t[O]=new Map);if(O in t)return t[O];var e=new Map;return Object.defineProperty(t,O,{value:e}),e}function ie(t,e,r,i){var n=t.get(i);if(null!=n)return n;n=0;for(let t=0;t<i.length;t++){let o=i[t];null!=Xt(e,o)&&(0!==n&&(r=Zt(e,r,n)),n=o)}return t.set(i,n),n}function ne(t,e,r,i){var n=!1;if(i=function(t,e,r){return Xt(t,e,void 0,r)}(t,i,t=>{var i=Ft(t,r,e);return n=i!==t&&null!=i,i}),null!=i)return n&&!H(i)&&qt(t,e),i}function oe(t,e,r){var i=t.m,n=0|i[D];if(null==(e=ne(i,n,e,r)))return e;if(!H(t,n=0|i[D])){var o,a=e;let s=a.m,l=0|s[D];(o=H(a,l)?Kt(a,s,l)?zt(a,s,!0):new a.constructor(Wt(s,l,!1)):a)!==e&&(Rt(t)&&(n=0|(i=t.m)[D]),qt(i,n=Zt(i,n,r,e=o)))}return e}function ae(t){return null==t&&(t=void 0),t}function se(t,e,r){return Yt(t,e,r=ae(r)),r&&!H(r)&&qt(t.m),t}function le(t,e,r,i){t:{var n=i=ae(i);Ht(t);let s=t.m;var o=0|s[D];if(null==n){var a=re(s);if(ie(a,s,o,r)!==e)break t;a.set(r,0)}else{let t=re(a=s),i=ie(t,a,o,r);i!==e&&(i&&(o=Zt(a,o,i)),t.set(r,e))}Zt(s,o,e,n)}return i&&!H(i)&&qt(t.m),t}function ue(t,e){return-273&(2&e?2|t:-3&t)}function he(t,e){var r=pi;Ht(t);var i=t.m,n=i,o=0|i[D],a=(t?H(t,o):2&o)?1:2;2===a&&t&&Rt(t)&&(o=0|(n=t.m)[D]);var s=Qt(n,8),l=s===L?7:0|s[D],u=W(l,o);if(t=!(4&u)){var h=o;let t=!!(2&u);t&&(h|=2);let e=!t,i=!0,n=0,a=0;for(;n<s.length;n++){let o=Ft(s[n],r,h);if(o instanceof r){if(!t){let t=H(o);e&&=!t,i&&=t}s[a++]=o}}a<n&&(s.length=a),u|=4,u=i?-4097&u:4096|u,u=e?8|u:-9&u}u!==l&&(z(s,u),2&u&&Object.freeze(s)),u=l=u,(h=te(l))&&2===a&&(s=Array.prototype.slice.call(s),u=0,l=ue(l,o),o=Zt(n,o,8,s),h=!1),h||(1===a||4===a&&(2&l||!(16&l)&&32&o)?((l|=!s.length||t&&!(4096&l)||32&o&&!(4096&l||16&l)?2:256)!==u&&z(s,l),Object.freeze(s)):l!==u&&z(s,l)),2&l||!(4096&l||16&l)||qt(n,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===L?7:0|a[D],(e=H(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&z(a,r),e||qt(i)}function ce(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw I("int64");switch(typeof t){case"string":var e=_t(Number(t));return wt(e)?t=tt(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?tt(yt(64,BigInt(t))):tt(jt(t))),t;case"bigint":return tt(yt(64,t));default:return wt(t)||(t=_t(t),wt(t)?t=String(t):(ct(t),t=mt())),tt(t)}}(r))}function fe(t,e,r){return Yt(t,e,null==r?r:function(t){if(!Et(t))throw I("uint64");switch(typeof t){case"string":var e=_t(Number(t));return wt(e)&&e>=0?t=tt(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=P()?tt(bt(64,BigInt(t))):tt(kt(t))),t;case"bigint":return tt(bt(64,t));default:return t>=0&&wt(t)||((t=_t(t))>=0&&wt(t)?t=String(t):(ct(t),t=dt(lt,ut))),tt(t)}}(r))}function de(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Yt(t,e,r)}function pe(t,e,r){if(null!=r){if(!St(r))throw I("enum");r|=0}return Yt(t,e,r)}var me=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ve(t){if("string"==typeof t)return new me(w(t),!0);if(Array.isArray(t))return new me(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new me(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new me(t,!1);if(t.constructor===A){B(_);var e=t.i;return e=(null==(e=null==e||m&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?w(e):null)?e:t.i=e)||new Uint8Array(0),new me(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new me(t,!1);throw Error()}function ge(t){return new we(4294967295&t,Math.floor(t/4294967296))}function ye(t){return t?/^\d+$/.test(t)?(vt(t),new we(lt,ut)):null:be||=new we(0,0)}var be,we=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Se(t){return new ke(4294967295&t,Math.floor(t/4294967296))}function _e(t){return t?/^-?\d+$/.test(t)?(vt(t),new ke(lt,ut)):null:Ae||=new ke(0,0)}var Ae,Be,Te,xe,Ie,Ee,Pe,je,ke=class{constructor(t,e){this.j=t>>>0,this.i=e>>>0}};function Le(t,e,r){return"undefined"!=typeof BigInt64Array?(Pe||(Pe=new BigInt64Array(1),je=new Uint32Array(Pe.buffer),Pe[0]=BigInt(1),Ee=1===je[0]),Pe[0]=t,new e(je[t=Ee?0:1],je[1-t])):(Ie||(Be=BigInt(Number.MIN_SAFE_INTEGER),Te=BigInt(Number.MAX_SAFE_INTEGER),xe=BigInt(4294967295),Ie=BigInt(32)),t>=Be&&t<=Te?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&xe),Number(t>>Ie))))}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 Oe(t,e){for(;e>127;)t.i.push(127&e|128),e>>>=7;t.i.push(e)}function Ne(t,e){if(e>=0)Oe(t,e);else{for(let r=0;r<9;r++)t.i.push(127&e|128),e>>=7;t.i.push(1)}}function Fe(t,e){vt(e),function(t){var e=ut>>31;t(lt<<1^e,(ut<<1|lt>>>31)^e)}((e,r)=>{Ue(t,e>>>0,r>>>0)})}function Ve(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 Me=class{constructor(){this.i=[]}length(){return this.i.length}end(){var t=this.i;return this.i=[],t}};function Ce(t,e){0!==e.length&&(t.l.push(e),t.j+=e.length)}function De(t,e,r){Oe(t.i,8*e+r)}function $e(t,e){return De(t,e,2),e=t.i.end(),Ce(t,e),e.push(t.j),e}function Ge(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 ze(t,e,r){if(null!=r)switch(De(t,e,0),typeof r){case"number":t=t.i,ct(r),Ue(t,lt,ut);break;case"bigint":r=Le(r,ke,Se),Ue(t.i,r.j,r.i);break;default:r=_e(r),Ue(t.i,r.j,r.i)}}function We(t,e,r){De(t,e,2),Oe(t.i,r.length),Ce(t,t.i.end()),Ce(t,r)}var Re=class{constructor(){this.l=[],this.j=0,this.i=new Me}};function He(t){if("string"==typeof t)_e(t)}function qe(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Ke=qe(),Je=qe(),Xe=qe(),Ye=qe(),Ze=qe(),Qe=qe(),tr=qe(),er=qe(),rr=qe(),ir=qe(),nr=qe(),or=qe(),ar=class{constructor(t,e){this.m=$t(t,e,void 0,2048)}toJSON(){return Dt(this)}};ar.prototype[V]=R,ar.prototype.toString=function(){return this.m.toString()};var sr=class{constructor(t,e){this.i=t,t=Ke,this.j=!!t&&e===t||!1}};function lr(t,e,r,i,n){null!=(e=vr(e,i))&&(r=$e(t,r),n(e,t),Ge(t,r))}var ur,hr,cr=new sr(lr,Ke),fr=new sr(lr,Ke),dr=Symbol(),pr=Symbol();function mr(t){var e=gr,r=yr,i=t[dr];if(i)return i;(i={}).qa=t,i.ba=function(t){switch(typeof t){case"boolean":return Tt||=[0,void 0,!0];case"number":return t>0?void 0:0===t?xt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var n=t[1],o=1;n&&n.constructor===Object&&(i.fa=n,"function"==typeof(n=t[++o])&&n.length>0&&(i.ia=!0,ur??=n,hr??=t[o+1],n=t[o+=2]));for(var a={};n&&Array.isArray(n)&&n.length&&"number"==typeof n[0]&&n[0]>0;){for(var s=0;s<n.length;s++)a[n[s]]=n;n=t[++o]}for(s=1;void 0!==n;){let h;"number"==typeof n&&(s+=n,n=t[++o]);var l=void 0;if(n instanceof sr?h=n:(h=cr,o--),h?.j){n=t[++o],l=t;var u=o;"function"==typeof n&&(n=n(),l[u]=n),l=n}for(u=s+1,"number"==typeof(n=t[++o])&&n<0&&(u-=n,n=t[++o]);s<u;s++){let t=a[s];l?r(i,s,h,l,t):e(i,s,h,t)}}return t[dr]=i}function vr(t,e){return t instanceof ar?t.m:Array.isArray(t)?$t(t,e[0],e[1]):void 0}function gr(t,e,r){t[e]=r.i}function yr(t,e,r,i){var n,o,a=r.i;t[e]=(t,e,r)=>a(t,e,r,o||=mr(i).ba,n||=br(i))}function br(t){var e=t[pr];if(!e){let r=mr(t);e=(t,e)=>wr(t,e,r),t[pr]=e}return e}function wr(t,e,r){!function(t,e,r){var i,n=128&e?0:-1,o=t.length;(i=!!o)&&(i=null!=(i=t[o-1])&&"object"==typeof i&&i.constructor===Object);var a=o+(i?-1:0);for(e=128&e?1:0;e<a;e++)r(e-n,t[e]);if(i){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[D],(t,i)=>{if(null!=i){var n=function(t,e){var r=t[e];if(r)return r;if((r=t.fa)&&(r=r[e])){var i=(r=Array.isArray(r)?r[0]instanceof sr?r:[fr,r]:[r,void 0])[0].i;if(r=r[1]){let e=br(r),n=mr(r).ba;r=t.ia?hr(n,e):(t,r,o)=>i(t,r,o,n,e)}else r=i;return t[e]=r}}(r,t);n?n(e,i,t):t<500||E(N,3)}})}function Sr(t,e,r){if(Array.isArray(e)){var i=0|e[D];if(4&i)return e;for(var n=0,o=0;n<e.length;n++){let r=t(e[n]);null!=r&&(e[o++]=r)}return o<n&&(e.length=o),t=1|i,r&&(t=-1537&t|4),t!==i&&z(e,t),r&&2&t&&Object.freeze(e),e}}var _r=(t,e)=>{var r=new Re;wr(t.m,r,mr(e)),Ce(r,r.i.end()),t=new Uint8Array(r.j);var i=(e=r.l).length,n=0;for(let r=0;r<i;r++){let i=e[r];t.set(i,n),n+=i.length}return r.l=[t],t};function Ar(t,e){return new sr(t,e)}function Br(t,e){return new sr(t,e)}function Tr(t,e,r){null!=(e=Lt(e))&&(He(e),ze(t,r,e))}function xr(t,e,r){null!=(e=Pt(e))&&null!=e&&(De(t,r,0),Ne(t.i,e))}function Ir(t,e,r){null!=(e=Nt(e))&&We(t,r,o(e))}function Er(t,e,r,i,n){null!=(e=vr(e,i))&&(r=$e(t,r),n(e,t),Ge(t,r))}function Pr(t,e,r){null!=(e=Ot(e))&&We(t,r,ve(e).buffer)}function jr(t,e,r){null!=(e=Pt(e))&&(e=parseInt(e,10),De(t,r,0),Ne(t.i,e))}var kr,Lr=Ar(function(t,e,r){null!=(e=At(e))&&(De(t,r,1),t=t.i,(r=st||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),lt=r.getUint32(0,!0),ut=r.getUint32(4,!0),Ve(t,lt),Ve(t,ut))},ir),Ur=Ar(function(t,e,r){null!=(e=At(e))&&(De(t,r,5),t=t.i,(r=st||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ut=0,Ve(t,lt=r.getUint32(0,!0)))},rr),Or=Ar(Tr,Qe),Nr=Ar(Tr,Qe),Fr=Br(function(t,e,r){if(null!=(e=Sr(Lt,e,!1)))for(let i=0;i<e.length;i++)ze(t,r,e[i])},Qe),Vr=Ar(function(t,e,r){if(null!=(e=Ut(e))){if("string"==typeof e)ye(e);if(null!=e)switch(De(t,r,0),typeof e){case"number":t=t.i,ct(e),Ue(t,lt,ut);break;case"bigint":r=Le(e,we,ge),Ue(t.i,r.j,r.i);break;default:r=ye(e),Ue(t.i,r.j,r.i)}}},tr),Mr=Ar(xr,Ye),Cr=Br(function(t,e,r){if(null!=(e=Sr(Pt,e,!0)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&(De(i,n,0),Ne(i.i,o))}},Ye),Dr=Br(function(t,e,r){if(null!=(e=Sr(Pt,e,!0))&&e.length){r=$e(t,r);for(let r=0;r<e.length;r++)Ne(t.i,e[r]);Ge(t,r)}},Ye),$r=Ar(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))},Je),Gr=Ar(Ir,Xe),zr=Br(function(t,e,r){if(null!=(e=Sr(Nt,e,!0)))for(let s=0;s<e.length;s++){var i=t,n=r,a=e[s];null!=a&&We(i,n,o(a))}},Xe),Wr=function(t,e,r=Ke){return new sr(e,r)}(0,function(t,e,r,i,n){if(Array.isArray(e)){for(let o=0;o<e.length;o++)Er(t,e[o],r,i,n);1&(t=0|e[D])||z(e,1|t)}}),Rr=new sr(Er,Ke),Hr=Ar(Pr,nr),qr=Br(function(t,e,r){if(null!=(e=Sr(Ot,e,!1)))for(let a=0;a<e.length;a++){var i=t,n=r,o=e[a];null!=o&&We(i,n,ve(o).buffer)}},nr),Kr=Ar(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 St(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(De(t,r,0),Oe(t.i,e))},Ze),Jr=Ar(jr,or),Xr=Ar(jr,or),Yr=Ar(function(t,e,r){if(null!=(e=Lt(e))&&(He(e),null!=e))switch(De(t,r,0),typeof e){case"number":t=t.i,e=(r=e)<0,ht(r=2*Math.abs(r)),r=lt;let i=ut;e&&(0==r?0==i?i=r=4294967295:(i--,r=4294967295):r--),Ue(t,lt=r,ut=i);break;case"bigint":t=t.i,e=e<<BigInt(1)^e>>BigInt(63),lt=Number(BigInt.asUintN(32,e)),ut=Number(BigInt.asUintN(32,e>>BigInt(32))),Ue(t,lt,ut);break;default:Fe(t.i,e)}},er),Zr=[0,Hr,qr,$r,Gr],Qr=[0,Ar(Ir,Xe),[0,Xr,[0,Ar(Tr,Qe),Ar(xr,Ye)],Xr,-1,[0,Jr],Xr,-1],Ar(Pr,nr)],ti=[0,1,[0,12,Mr,10,$r],[0,7,[0,Mr,-1]]],ei=globalThis.trustedTypes;var ri=class{constructor(t){this.i=t}toString(){return this.i+""}};function ii(t){var e;return void 0===kr&&(kr=function(){var t=null;if(!ei)return t;try{let e=t=>t;t=ei.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=kr)?e.createScriptURL(t):t,new ri(t)}function ni(t,...e){if(0===e.length)return ii(t[0]);var r=t[0];for(let i=0;i<e.length;i++)r+=encodeURIComponent(e[i])+t[i+1];return ii(r)}var oi=class extends ar{constructor(t){super(t)}},ai=class extends ar{constructor(t){super(t)}},si=class extends ar{constructor(t){super(t)}},li=[1,2,3,4,5,6],ui=class extends ar{constructor(t){super(t)}j(){return null!=Jt(this,1,ee)}l(){return null!=Nt(Jt(this,2))}},hi=class extends ar{constructor(t){super(t)}};function ci(t,e,r){return r=`wasm${r?"_module":""}_internal`,Promise.resolve({wasmLoaderPath:`${e}/${t}_${r}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`})}var fi=class{};function di(t){return pe(new pi,1,t)}fi.forVisionTasks=function(t,e=!1){return ci("vision",t??ni``,e)},fi.forLiteRtLmTextTasks=function(t,e=!1){return ci("litertlm_text",t??ni``,e)},fi.forTextTasks=function(t,e=!1){return ci("text",t??ni``,e)},fi.forRetrievalTasks=function(t,e=!1){return ci("retrieval",t??ni``,e)},fi.forGenAiTasks=function(t,e=!1){return ci("genai",t??ni``,e)},fi.forDecisionTasks=function(t,e=!1){return ci("decision",t??ni``,e)},fi.forAudioTasks=function(t,e=!1){return ci("audio",t??ni``,e)};var pi=class extends ar{constructor(t){super(t)}},mi=class extends ar{constructor(t){super(t)}},vi=[0,Jr,2,Vr,-2,Nr,Wr,[0,Jr,Nr]],gi=class extends ar{constructor(t){super(t)}},yi=class extends ar{constructor(t){super(t)}};function bi(t){var e=new Si;return e=pe(e,1,30),pe(e,2,t)}var wi,Si=class extends ar{constructor(t){super(t)}},_i=[3,4,5,6,7],Ai=class extends ar{constructor(t){super(t)}},Bi=class extends ar{constructor(t){super(t)}};Bi.prototype.j=(wi=[0,[0,Jr,Gr,-3,Jr],[0,_i,Jr,-1,Rr,[0,Jr,Gr,Vr],Rr,vi,Rr,[0,1,vi],Rr,[0,Jr],Rr,[0,Jr,Gr,Vr]]],function(){return _r(this,wi)});var Ti=class{constructor(){this.i="undefined"!=typeof AbortController}async send(t,e,r){var i=this.i?new AbortController:void 0,n=i&&t.W>0?setTimeout(()=>{i.abort()},t.W):void 0;try{let n=await fetch(t.url,{method:t.pa,headers:{...t.oa},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.W&&i?i.signal:null});n.ok?e?.(await n.text()):r?.(n.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(0)}finally{clearTimeout(n)}}},xi=class extends ar{constructor(t){super(t,37)}},Ii=[-4,{},ti,Jr,Qr],Ei=[0,Gr,Jr,1,Gr,-1,Jr,1,Jr,1,Nr],Pi=[0,Jr,Gr,-2],ji=[0,Gr,Jr],ki=[0,Gr,Jr],Li=[0,$r,-3],Ui=[0,Jr,Gr,-1,Nr,Mr,-1,Gr,-5,Wr,[0,Gr,-4],-1,$r,[0,$r,-3],Jr];var Oi=class extends ar{constructor(t){super(t,19)}},Ni=function(t){return e=>_r(e,t)}([-19,{},[0,Jr,1,[0,Gr,-6,Nr,Mr,Gr,-1,Nr],1,[0,Gr,1,Gr,-5],Gr,-1,[0,Jr,Gr,-8],[0,Gr,-3],[0,Gr,Jr,Gr,-2],[0,Gr,-1,Jr,Gr,-1,Jr,Gr,-1,[0,Wr,[0,Gr,-1],$r,Gr,-5],[0,Jr,$r,Mr,-2]],Nr,[0,Gr,-3,Nr,Mr,Gr,-1],[0,Jr,Gr,-1],[0,Gr,-9],[0,Gr,-6,Jr,Gr,1,Gr,$r,Jr,-1,$r,Gr,-2,Jr,Gr,Jr,Gr,Mr,-1],1,[0,Jr],1,[0,Gr,-4],1,Ei,[0,[1,2,3,4,5,6],Rr,Ei,Rr,ji,Rr,ki,Rr,[0,Jr],Rr,Ui,Rr,Pi],ji,ki,Ui,[0,[0,Jr,Gr,-1,Nr,Mr,-1,Gr,-4,Wr,[0,Gr,-4],-1,1,Li],[0,Jr,Gr,-1,Nr,Mr,-1,Gr,-4,Li]],Pi,[0,Gr,[0,Mr,-3,Jr],Jr,-2,[0,Mr,-1],$r],4,[0,Gr,Jr,Gr,-1,Nr,Jr,Gr,-1,Jr,Mr,-1]],Jr,Wr,[-37,{},Or,Gr,Wr,[0,Gr,-1],Hr,1,Hr,[0,zr,-1,Cr,Fr,-1],Gr,[0,Mr,Gr,-1],$r,Mr,Nr,Gr,-1,Yr,Zr,Or,Hr,Jr,Cr,Nr,-1,[0,Jr,-1],Gr,$r,Gr,Dr,Gr,-1,Lr,1,Lr,Ii,$r,[0,Jr,[0,Ur,Mr,-2],[0,Ur]],[0,Jr,Nr]],Or,qr,Gr,-1,Or,Jr,-1,[0,$r,-1,Jr,$r],[0,Nr,-1,Gr],[0,Or,$r,Nr],Nr,1,Kr,1,Ii]),Fi=class{constructor(t){this.j=[],this.o=new Ti,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 Oi;Ht(e=pe(e,2,1786));var r=e.m,i=0|r[D];if(null==t)Zt(r,i,3);else{var n=t===L?7:0|t[D],o=n,a=te(n),s=a||Object.isFrozen(t),l=!0,u=!0;for(let e=0;e<t.length;e++){var h=t[e];a||(h=H(h),l&&=!h,u&&=h)}a||(n=l?13:5,n=u?-4097&n:4096|n),s&&n===o||(t=Array.prototype.slice.call(t),o=0,n=ue(n,i)),n!==o&&z(t,n),i=Zt(r,i,3,t),2&n||!(4096&n||16&n)||qt(r,i)}return e}(r),r=Ni(r),this.o.send({url:"https://odml.pa.googleapis.com/v1/log",pa:"POST",W:1e4,body:r,ra:2,oa:{"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 Vi{constructor(){this.M=this.D=this.I=this.B=this.G=this.H=this.F=0}}function Mi(t,e){var r=new Bi;r=se(r,1,t.L),r=se(r,2,e),e=Yt(e=new xi,6,K(r=r.j(),!1)),(t=t.C).error||t.j.push(e)}function Ci(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},i=bi(1);r=Di(t,r),Mi(t,i=le(i,4,_i,r)),t.l=e}function Di(t,e){var r=new mi;return t=fe(t=ce(t=pe(r,1,t.J),7,e.B),5,e.D),t=fe(t,6,e.M),e.G>0&&fe(t,4,e.I/e.G),0!==e.F&&he(t,r=ce(r=di(3),2,e.F)),0!==e.H&&he(t,e=ce(r=di(4),2,e.H)),t}var $i=class{constructor(t,e){this.K=performance.now(),this.o=performance.now(),this.j=new Map,this.A=0,this.i=new Vi,this.l=new Vi,this.C=new Fi(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 Ai,"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=de(t=pe(t,1,e),2,""),t=de(t,3,""),t=de(t,4,"1.2.3"),t=de(t,5,""),this.L=pe(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}())}aa(){var t=new yi;t=fe(t=pe(t,1,this.J),3,performance.now()-this.K),Mi(this,t=le(bi(0),3,_i,t)),this.o=performance.now()}T(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,i]of this.j.entries())t=r,i<e&&(this.i.B++,this.j.delete(t));e={...this.i,M:performance.now()-this.o},this.i.D=0,this.o=performance.now(),Ci(this,e)}}ja(){var t={...this.i,B:this.i.B+this.j.size,D:this.A,M:performance.now()-this.K};Ci(this,t);var e=new gi;e=se(e,2,t=Di(this,t)),Mi(this,e=le(t=bi(2),5,_i,e))}close(){var t=this.C;"function"==typeof t.close?t.close():t.flush()}};function Gi(){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 zi(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 Wi(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 Ri(t,e,r){t.o||console.error("No wasm multistream support detected: ensure dependency inclusion of :gl_graph_runner_internal_multi_input target");var i=new Uint32Array(e.length);for(let r=0;r<e.length;r++)i[r]=t.h.stringToNewUTF8(e[r]);e=t.h._malloc(4*i.length),t.h.HEAPU32.set(i,e>>2),r(e);for(let e of i)t.h._free(e);t.h._free(e)}function Hi(t,e,r){t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=r}function qi(t,e,r){var i=[];t.h.simpleListeners=t.h.simpleListeners||{},t.h.simpleListeners[e]=(t,e,n)=>{e?(r(i,n),i=[]):i.push(t)}}var Ki=function(t){return class extends t{get X(){return this.h}ga(){if("function"==typeof this.X._mediapipeLoggerGetEncodedApiKey){let t=this.X._mediapipeLoggerGetEncodedApiKey();return this.X._decodeBase64(t)}}}}(function(t){return class extends t{na(){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:Gi()?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,i=this.h._malloc(r);this.h.HEAPU8.set(t,i),e?this.h._changeBinaryGraph(r,i):this.h._changeTextGraph(r,i),this.h._free(i)}configureAudio(t,e,r,i,n){this.h._configureAudio||console.warn('Attempting to use configureAudio without support for input audio. Is build dep ":gl_graph_runner_audio" missing?'),Wi(this,i||"input_audio",i=>{Wi(this,n=n||"audio_header",n=>{this.h._configureAudio(i,n,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,i,n){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),Wi(this,i,t=>{this.h._addAudioToInputStream(this.i,e,r,t,n)})}addGpuBufferToStream(t,e,r){Wi(this,e,e=>{if(!this.h.canvas)throw Error("No OpenGL canvas configured.");e?this.h._bindTextureToStream(e):this.h._bindTextureToCanvas();var i=this.h.canvas.getContext("webgl2")||this.h.canvas.getContext("webgl");if(!i)throw Error("Failed to obtain WebGL context from the provided canvas. `getContext()` should only be invoked with `webgl` or `webgl2`.");this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!0),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),this.h.gpuOriginForWebTexturesIsBottomLeft&&i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1);var[n,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||n===this.h.canvas.width&&o===this.h.canvas.height||(this.h.canvas.width=n,this.h.canvas.height=o);var[a,s]=[n,o];this.h._addBoundTextureToStream(e,a,s,r)})}addBoolToStream(t,e,r){Wi(this,e,e=>{this.h._addBoolToInputStream(t,e,r)})}addDoubleToStream(t,e,r){Wi(this,e,e=>{this.h._addDoubleToInputStream(t,e,r)})}addFloatToStream(t,e,r){Wi(this,e,e=>{this.h._addFloatToInputStream(t,e,r)})}addIntToStream(t,e,r){Wi(this,e,e=>{this.h._addIntToInputStream(t,e,r)})}addUintToStream(t,e,r){Wi(this,e,e=>{this.h._addUintToInputStream(t,e,r)})}addStringToStream(t,e,r){Wi(this,e,e=>{Wi(this,t,t=>{this.h._addStringToInputStream(t,e,r)})})}addStringRecordToStream(t,e,r){Wi(this,e,e=>{Ri(this,Object.keys(t),i=>{Ri(this,Object.values(t),n=>{this.h._addFlatHashMapToInputStream(i,n,Object.keys(t).length,e,r)})})})}addProtoToStream(t,e,r,i){Wi(this,r,r=>{Wi(this,e,e=>{var n=this.h._malloc(t.length);this.h.HEAPU8.set(t,n),this.h._addProtoToInputStream(n,t.length,e,r,i),this.h._free(n)})})}addEmptyPacketToStream(t,e){Wi(this,t,t=>{this.h._addEmptyPacketToInputStream(t,e)})}addBoolVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateBoolVector(t.length);if(!i)throw Error("Unable to allocate new bool vector on heap.");for(let e of t)this.h._addBoolVectorEntry(i,e);this.h._addBoolVectorToInputStream(i,e,r)})}addDoubleVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateDoubleVector(t.length);if(!i)throw Error("Unable to allocate new double vector on heap.");for(let e of t)this.h._addDoubleVectorEntry(i,e);this.h._addDoubleVectorToInputStream(i,e,r)})}addFloatVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateFloatVector(t.length);if(!i)throw Error("Unable to allocate new float vector on heap.");for(let e of t)this.h._addFloatVectorEntry(i,e);this.h._addFloatVectorToInputStream(i,e,r)})}addIntVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateIntVector(t.length);if(!i)throw Error("Unable to allocate new int vector on heap.");for(let e of t)this.h._addIntVectorEntry(i,e);this.h._addIntVectorToInputStream(i,e,r)})}addUintVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateUintVector(t.length);if(!i)throw Error("Unable to allocate new unsigned int vector on heap.");for(let e of t)this.h._addUintVectorEntry(i,e);this.h._addUintVectorToInputStream(i,e,r)})}addStringVectorToStream(t,e,r){Wi(this,e,e=>{var i=this.h._allocateStringVector(t.length);if(!i)throw Error("Unable to allocate new string vector on heap.");for(let e of t)Wi(this,e,t=>{this.h._addStringVectorEntry(i,t)});this.h._addStringVectorToInputStream(i,e,r)})}addBoolToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addBoolToInputSidePacket(t,e)})}addDoubleToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addDoubleToInputSidePacket(t,e)})}addFloatToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addFloatToInputSidePacket(t,e)})}addIntToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addIntToInputSidePacket(t,e)})}addUintToInputSidePacket(t,e){Wi(this,e,e=>{this.h._addUintToInputSidePacket(t,e)})}addStringToInputSidePacket(t,e){Wi(this,e,e=>{Wi(this,t,t=>{this.h._addStringToInputSidePacket(t,e)})})}addProtoToInputSidePacket(t,e,r){Wi(this,r,r=>{Wi(this,e,e=>{var i=this.h._malloc(t.length);this.h.HEAPU8.set(t,i),this.h._addProtoToInputSidePacket(i,t.length,e,r),this.h._free(i)})})}addBoolVectorToInputSidePacket(t,e){Wi(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){Wi(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){Wi(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){Wi(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){Wi(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){Wi(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)Wi(this,e,t=>{this.h._addStringVectorEntry(r,t)});this.h._addStringVectorToInputSidePacket(r,e)})}attachBoolListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachBoolListener(t)})}attachBoolVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachBoolVectorListener(t)})}attachIntListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachIntListener(t)})}attachIntVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachIntVectorListener(t)})}attachUintListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachUintListener(t)})}attachUintVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachUintVectorListener(t)})}attachDoubleListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachDoubleListener(t)})}attachDoubleVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachDoubleVectorListener(t)})}attachFloatListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachFloatListener(t)})}attachFloatVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachFloatVectorListener(t)})}attachStringListener(t,e){Hi(this,t,e),Wi(this,t,t=>{this.h._attachStringListener(t)})}attachStringVectorListener(t,e){qi(this,t,e),Wi(this,t,t=>{this.h._attachStringVectorListener(t)})}attachProtoListener(t,e,r){Hi(this,t,e),Wi(this,t,t=>{this.h._attachProtoListener(t,r||!1)})}attachProtoVectorListener(t,e,r){qi(this,t,e),Wi(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?'),Hi(this,t,(t,r)=>{t=new Float32Array(t.buffer,t.byteOffset,t.length/4),e(t,r)}),Wi(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}})),Ji=class extends Ki{};async function Xi(t,e){var r=await(async(t,e,r)=>{var i=yn;if(t&&await zi(t),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(e&&(await zi(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 i(r,null)})(t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():t.assetBinaryPath&&e.endsWith(".data")?t.assetBinaryPath.toString():e});return Yi(r,e),await r.U(e),r}function Yi(t,e){e=e.ua??"";var r=t.j.ga();t.l=new $i(e,r)}function Zi(t,e){try{t.j.h.FS_unlink("/model.litertlm")}catch{}t.j.h.FS_createDataFile("/","model.litertlm",e,!0,!1,!0),de(e=oe(t.baseOptions,ui,1)||new ui,2,"/model.litertlm"),Yt(e,1),se(t.baseOptions,1,e)}function Qi(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(!(oe(t.baseOptions,ui,1)?.j()||oe(t.baseOptions,ui,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=oe(t.baseOptions,si,3);if(!r){var i=r=new si,n=new ai;le(i,4,li,n)}"delegate"in e&&("GPU"===e.delegate?(e=r,i=new oi,le(e,2,li,i)):(e=r,i=new ai,le(e,4,li,i))),se(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=>{Zi(t,new Uint8Array(e))});if(r.modelAssetBuffer instanceof Uint8Array)Zi(t,r.modelAssetBuffer);else if(r.modelAssetBuffer)return async function(t){for(var e=[],r=0;;){let{done:i,value:n}=await t.read();if(i)break;e.push(n),r+=n.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let i of e)t.set(i,r),r+=i.length;return t}(r.modelAssetBuffer).then(e=>{Zi(t,e)})}return Promise.resolve()}function tn(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 en=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.na(),this.j.setGraph(t,e),this.l?.aa(),tn(this)}finishProcessing(t){this.j.finishProcessing(),tn(this),this.l&&void 0!==t&&this.l.T(t)}close(){this.l?.ja(),this.l?.close(),this.j.closeGraph()}};function rn(t){return!!(t?.imageBytes&&t.imageBytes.byteLength>0)||!!(t?.audioSamples&&t.audioSamples.length>0)}function nn(t,e){var r="object"==typeof t&&null!==t,i=(r?t.imageBytes:void 0)??e?.imageBytes;return e=(r?t.audioSamples:void 0)??e?.audioSamples,{text:r?t.text??"":t,imageBytes:i,audioSamples:e,N:!!(i&&i.byteLength>0)||!!(e&&e.length>0)}}function on(t){return(t=t.trim())?Math.max(1,Math.ceil(t.length/4)):0}function an(t){var e={};if(t.criteria)for(let[r,i]of Object.entries(t.criteria))e[r]=i;if(t.options)for(let r of t.options)e[r.label]=r.description??"";return e}function sn(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)),i=r.every(t=>Number.isFinite(t))&&t.every(t=>""!==t.trim());return r=i?r:t.map((t,e)=>e),{rubric:e,labels:t,S:r,R:i}}return t=(e=t.rubric??[]).map((t,e)=>String(e)),i=e.map((t,e)=>e),{rubric:e,labels:t,S:i,R:!1}}function ln(t){if(0===t.length)return[];t=[...t].sort((t,e)=>t.probability!==e.probability?e.probability-t.probability:t.key<e.key?-1:t.key>e.key?1:0);var e=[],r=0;for(let i of t)if(e.push(i.key),(r+=i.probability)>=.9)break;return e}function un(t){if(void 0!==t.predictionSet)return{...t,predictionSet:t.predictionSet};var e=Object.entries(t.probabilities??{}).map(([t,e])=>({key:t,probability:e}));return{...t,predictionSet:ln(e)}}function hn(t,e,r,i){var n=t.probabilities??[],o=0,a=-1,s=0;for(let t=0;t<n.length;t++){let e=n[t];e>a&&(a=e,o=t),s+=(t<r.length?r[t]:t)*e}return{...t,expectedScore:i&&n.length>0?s:t.expectedScore,selectedKey:o<e.length?e[o]:t.selectedKey??String(o)}}en.prototype.close=en.prototype.close;var cn=[];async function fn(t,e){var r=cn.pop();if(r){Yi(t=new yn(r,null),e);try{return await t.U(e),t}catch(e){throw t.close(),e}}return async function(t,e){return Xi(t,e)}(t,e)}function dn(t,e){var r=t.Y.then(()=>{var r=t.ca++;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?.T(r),e),e=>{throw t.l?.T(r),e})});return t.Y=r.then(()=>{},()=>{}),r}function pn(t){if(!t)return 0;var e=t.context?on(t.context):0;for(let r of t.questions??[]){e+=on(r.prompt)+4;for(let t of r.options??[])e+=on(t.description?`${t.label}: ${t.description}`:t.label)+2}return e}function mn(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 vn(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 gn(t,e,r,i){var n=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:i}=vn(t,o,mn(r));return n.HEAPU8.set(r,e),{u:e,v:i,size:o}}if(i=i&&i>0?i: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&&(i=e),r=r.body.getReader()}if(!r)return{u:0,v:0,size:0};if(i>0){e=[];for(var a=0;a<30;){let{value:t,done:i}=await r.read();if(i)break;t&&t.byteLength>0&&(e.push(t),a+=Number(t.byteLength))}if(0===a)return{u:0,v:0,size:0};let l=e[0];if(l.byteLength<30&&e.length>1)for(var s of(l=new Uint8Array(Math.min(a,30)),a=0,e)){let t=Math.min(s.byteLength,l.byteLength-a);if(l.set(s.subarray(0,t),a),(a+=t)>=l.byteLength)break}let{u:u,v:h}=vn(t,i,mn(l));for(o of(t=0,e)){if(t+(s=Number(o.byteLength))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(o,u+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))>i)throw n._free(h),Error(`Stream exceeded expected content-length (${i} bytes).`);n.HEAPU8.set(e,u+t>>>0),t+=o}}return{u:u,v:h,size:t}}for(o=[],i=0;;){let{value:t,done:e}=await r.read();if(e)break;t&&t.byteLength>0&&(s=Number(t.byteLength),o.push(t),i+=s)}if(0===i)return{u:0,v:0,size:0};r=o[0];var{u:l,v:u}=vn(t,i,r?mn(r):0);for(t=0,r=0;r<o.length;r++)(s=o[r])&&(n.HEAPU8.set(s,l+t>>>0),t+=s.byteLength,o[r]=void 0);return{u:l,v:u,size:i}}var yn=class extends en{constructor(t,e){super(new Ji(t,e)),this.baseOptions=new hi,this.L=this.C=this.K=this.A=this.i=this.maxNumTokens=this.backendType=0,this.Z=!1,this.ca=this.J=0,this.Y=Promise.resolve()}get contextWindow(){return this.maxNumTokens}get contextUsage(){return this.J}V(t){this.P=t,this.J=pn(t)}async O(t){if(0!==this.i){var e=t.questions??[];if(0!==e.length){var r=this.j.h;"function"==typeof r.prewarmSchema?await dn(this,()=>r.prewarmSchema(this.i,t.context??"",e)):await dn(this,()=>r.evaluateSchema(this.i,"__PREWARM__",t.context??"",e))}}}async prewarmChoice(t){if(0!==this.i){var e=an(t);if(0!==Object.keys(e).length){var r=t.instructions??"",i=t.context?r?`${t.context}\n${r}`:t.context:r,n=this.j.h;if("function"==typeof n.prewarmChoice)await dn(this,()=>n.prewarmChoice(this.i,e,t.options??[],t.temperature??0,i,t.normalizePrior??!1));else{var o=new Map;for(var a of t.options??[])o.set(a.label,a);a=Object.entries(e).map(([t,e])=>{var r=o.get(t);return r?{...r,label:t,description:e}:{label:t,description:e}}),await this.O({context:t.context,questions:[{id:"__choice__",type:"choice",prompt:r,options:a,temperature:t.temperature,normalizePrior:t.normalizePrior}]})}}}}async la(t){0!==this.i&&(t.options&&t.options.length>=2?await this.prewarmChoice({options:t.options,instructions:t.condition,context:t.context,temperature:t.temperature,normalizePrior:t.normalizePrior}):await this.O({context:t.context,questions:[{id:"__boolean__",type:"boolean",prompt:t.condition,threshold:t.threshold,temperature:t.temperature,normalizePrior:t.normalizePrior}]}))}async ma(t){if(0!==this.i){var{rubric:e}=sn(t);0!==e.length&&await this.O({context:t.context,questions:[{id:"__score__",type:"score",prompt:t.instructions??"",options:e.map(t=>({label:"",description:t})),temperature:t.temperature}]})}}async ka(t,e){return t=e?.context?`${e.context}\n${t}`:t,pn(this.P)+on(t)}async U(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.V(t.schema):(t.questions||t.context||t.expectedInputs)&&this.V({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"}),i=r?.info,n=!!r?.isFallbackAdapter||/swiftshader|llvmpipe|software|lavapipe/i.test(`${i?.vendor??""} ${i?.architecture??""} ${i?.description??""}`);if(r&&!n){for(var o of(n=[],["shader-f16","subgroups"]))r.features.has(o)&&n.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:n,requiredLimits:o});if(!t.adapterInfo&&i)try{Object.defineProperty(t,"adapterInfo",{value:i,writable:!0,configurable:!0})}catch{try{t.adapterInfo=i}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,(i=!(!t.baseOptions||!t.baseOptions.modelAssetPath&&!t.baseOptions.modelAssetBuffer))&&"function"==typeof e.createDecisionFromBuffers&&"function"==typeof r._malloc){if(r=await gn(this,t.baseOptions?.modelAssetPath,t.baseOptions?.modelAssetBuffer,t.modelAssetSize),this.A=r.u,this.K=r.v,i=0,t.companionPleAssetPath||t.companionPleAssetBuffer)try{let e=await gn(this,t.companionPleAssetPath,t.companionPleAssetBuffer,t.companionPleAssetSize);this.C=e.u,this.L=e.v,i=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,i,this.backendType,this.maxNumTokens)}else await Qi(this,t,i),this.i=await e.createDecision("/model.litertlm",this.backendType,this.maxNumTokens);this.l?.aa()}evaluateBoolean(t,e){if(0===this.i)throw Error("Decision is already closed.");if(e.options&&e.options.length>=2){let r=void 0!==e.threshold&&e.threshold>0?e.threshold:.5;return this.evaluateChoice(t,{options:e.options,instructions:e.condition,context:e.context,temperature:e.temperature,normalizePrior:e.normalizePrior,imageBytes:e.imageBytes,audioSamples:e.audioSamples}).then(t=>{var i=e.options,n=/^(true|yes|1|allow|allowed|entailment|supported)$/i,o=/^(false|no|0|deny|denied|reject|rejected|contradiction|contradicted|refuted)$/i,a=i.find(t=>n.test(t.label.trim()));return a||=o.test(i[1].label.trim())&&!o.test(i[0].label.trim())?i[0]:i[1],{value:o=(i=t.probabilities[a.label]??0)>=r,probabilityTrue:i,confidence:r>0&&r<1?Math.min(1,Math.max(0,o?(i-r)/(1-r):(r-i)/r)):t.confidence}})}var r=this.j.h,i=e.context?`${e.context}\n${e.condition}`:e.condition,n=e.normalizePrior??!1,o=nn(t,e);return o.N?dn(this,()=>r.evaluateContextBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,{imageBytes:o.imageBytes,audioSamples:o.audioSamples},n)):dn(this,()=>r.evaluateBoolean(this.i,o.text,i,e.threshold??.5,e.temperature??0,n))}evaluateChoice(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,i=an(e),n=e.instructions??"",o=e.context?n?`${e.context}\n${n}`:e.context:n,a=e.normalizePrior??!1,s=nn(t,e);return t=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),(s.N||t?dn(this,()=>r.evaluateContextChoice(this.i,s.text,i,e.options??[],e.temperature??0,o,{imageBytes:s.imageBytes,audioSamples:s.audioSamples},a)):dn(this,()=>r.evaluateChoice(this.i,s.text,i,e.temperature??0,o,a))).then(un)}async evaluateScore(t,e){if(0===this.i)throw Error("Decision is already closed.");var r=this.j.h,{rubric:i,labels:n,S:o,R:a}=sn(e),s=e.instructions??"",l=e.context?s?`${e.context}\n${s}`:e.context:s,u=nn(t,e);return hn(t=u.N?await dn(this,()=>r.evaluateContextScore(this.i,u.text,i,e.temperature??0,l,{imageBytes:u.imageBytes,audioSamples:u.audioSamples})):await dn(this,()=>r.evaluateScore(this.i,u.text,i,e.temperature??0,l)),n,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 i=nn(t,r),n=r?.context?i.text?`${r.context}\n${i.text}`:r.context:i.text,o=e.context;t=(i.imageBytes&&i.imageBytes.byteLength>0?70:0)+(i.audioSamples&&i.audioSamples.length>0?Math.ceil(i.audioSamples.length/640):0),this.J=pn(e)+on(n)+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)),function(t,e){t={...t};for(let r of e)"categorical"!==r.type&&"choice"!==r.type||(e=t[r.id])&&void 0===e.predictionSet&&(t[r.id]={...e,predictionSet:ln((e.probabilities??[]).map(t=>({key:t.label,probability:t.probability})))});return t}(e=i.N||e?await dn(this,()=>a.evaluateContextSchema(this.i,n,o??"",s,{imageBytes:i.imageBytes,audioSamples:i.audioSamples})):await dn(this,()=>a.evaluateSchema(this.i,n,o??"",s)),s))}async ea(t,e,r){var i=[];for(let n of t)i.push(await this.evaluate(n,e,r));return i}async da(t,e){if(!this.P)throw Error("No session schema configured. Pass `schema` or `questions` in DecisionMakerOptions or call setSchema() before classify().");return this.evaluate(t,this.P,e)}async evaluateBooleanBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=e.context?`${e.context}\n${e.condition}`:e.condition;if(!(rn(e)||e.options&&e.options.length>=2)&&"function"==typeof i.evaluateBooleanBatch)return dn(this,()=>i.evaluateBooleanBatch(this.i,t,n,e.threshold??.5,e.temperature??0,r,e.normalizePrior??!1));var o=[];for(let i of t)o.push(await this.evaluateBoolean(r?`${r}\n${i}`:i,e));return o}async evaluateChoiceBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,n=an(e),o=e.instructions??"",a=e.context?o?`${e.context}\n${o}`:e.context:o;if(o=(e.options??[]).some(t=>t.imageBytes&&t.imageBytes.byteLength>0||t.audioSamples&&t.audioSamples.length>0),!rn(e)&&!o&&"function"==typeof i.evaluateChoiceBatch)return(await dn(this,()=>i.evaluateChoiceBatch(this.i,t,n,e.temperature??0,a,r,e.normalizePrior??!1))).map(un);o=[];for(let i of t)o.push(await this.evaluateChoice(r?`${r}\n${i}`:i,e));return o}async evaluateScoreBatch(t,e,r=""){if(0===this.i)throw Error("Decision is already closed.");if(0===t.length)return[];var i=this.j.h,{rubric:n,labels:o,S:a,R:s}=sn(e),l=e.instructions??"",u=e.context?l?`${e.context}\n${l}`:e.context:l;if(!rn(e)&&"function"==typeof i.evaluateScoreBatch)return(await dn(this,()=>i.evaluateScoreBatch(this.i,t,n,e.temperature??0,u,r))).map(t=>hn(t,o,a,s));l=[];for(let i of t)l.push(await this.evaluateScore(r?`${r}\n${i}`:i,e));return l}close(){if(!this.Z){this.Z=!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&&!cn.includes(t)&&cn.push(t)}}};yn.prototype.close=yn.prototype.close,yn.prototype.evaluateScoreBatch=yn.prototype.evaluateScoreBatch,yn.prototype.evaluateChoiceBatch=yn.prototype.evaluateChoiceBatch,yn.prototype.evaluateBooleanBatch=yn.prototype.evaluateBooleanBatch,yn.prototype.classify=yn.prototype.da,yn.prototype.evaluateBatch=yn.prototype.ea,yn.prototype.evaluate=yn.prototype.evaluate,yn.prototype.evaluateScore=yn.prototype.evaluateScore,yn.prototype.evaluateChoice=yn.prototype.evaluateChoice,yn.prototype.evaluateBoolean=yn.prototype.evaluateBoolean,yn.prototype.setOptions=yn.prototype.U,yn.prototype.measureContextUsage=yn.prototype.ka,yn.prototype.prewarmScore=yn.prototype.ma,yn.prototype.prewarmBoolean=yn.prototype.la,yn.prototype.prewarmChoice=yn.prototype.prewarmChoice,yn.prototype.prewarm=yn.prototype.O,yn.prototype.setSchema=yn.prototype.V,yn.createFromModelBuffer=function(t,e,r=0,i=0){return fn(t,{baseOptions:{modelAssetBuffer:e},backendType:r,maxNumTokens:i})},yn.createFromModelPath=function(t,e,r=0,i=0){return fn(t,{baseOptions:{modelAssetPath:e},backendType:r,maxNumTokens:i})},yn.createFromOptions=fn;export{yn as DecisionMaker,fi as FilesetResolver,en as TaskRunner};
2
2
  //# sourceMappingURL=decision_bundle_mjs.js.map