@mediapipe/tasks-retrieval 1.2.0-rc.20261026 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var Retrieval=function(t){"use strict";var e="undefined"!=typeof self?self:{};function r(t,r){t:{for(var n=["CLOSURE_FLAGS"],i=e,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(t=n&&n[t])?t:r}var n,i="undefined"!=typeof TextEncoder;function o(t){if(i)t=(n||=new TextEncoder).encode(t);else{let r=0,n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.subarray(0,r)}return t}var a=r(610401301,!1),s=r(748402147,!0);function u(){var t=e.navigator;return t&&(t=t.userAgent)?t:""}var l,f=e.navigator;l=f&&f.userAgentData||null;var c={},h=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 n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){let e=t.charAt(n++),r=h[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}p();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function p(){if(!h){h={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));c[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===h[e]&&(h[e]=t)}}}}var y="undefined"!=typeof Uint8Array,m=!(!(!!a&&(!!l&&l.brands.length>0))&&(-1!=u().indexOf("Trident")||-1!=u().indexOf("MSIE")))&&"function"==typeof btoa,g=/[-_.]/g,v={"-":"+",_:"/",".":"="};function b(t){return v[t]||""}function w(t){if(!m)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 A,I={},E=class{constructor(t,e){if(S(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function S(t){if(t!==I)throw Error("illegal external caller")}function N(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var B=void 0;function _(t){return N(t=Error(t),"warning"),t}function x(t,r){if(null!=t){var n=B??={},i=n[t]||0;i>=r||(n[t]=i+1,N(t=Error(),"incident"),function(t){e.setTimeout(()=>{throw t},0)}(t))}}function C(){return"function"==typeof BigInt}var T="function"==typeof Symbol&&"symbol"==typeof Symbol();function j(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 O,F=j("jas",void 0,!0),U=j(void 0,"1oa"),k=j(void 0,"0ubsb"),M=j(void 0,"0actk"),R=j("m_m","na",!0),P={ca:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,L=T?F:"ca",z=[];function G(t,e){T||L in t||D(t,P),t[L]|=e}function $(t,e){T||L in t||D(t,P),t[L]=e}function H(t,e){return 2&e&&(t|=2),1|t}$(z,7),O=Object.freeze(z);var W={};function J(t,e){return void 0===e?t.h!==V&&!!(2&t.l[L]):!!(2&e)&&t.h!==V}var V={};function q(t){return t.ma=!0,t}var K=q(t=>"number"==typeof t),X=q(t=>"string"==typeof t),Z=q(t=>"boolean"==typeof t),Y="function"==typeof e.BigInt&&"bigint"==typeof e.BigInt(0);function Q(t){var e=t;if(X(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(K(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Y?BigInt(t):t=Z(t)?t?"1":"0":X(t)?t.trim()||"0":String(t)}var tt=q(t=>Y?t>=rt&&t<=it:"-"===t[0]?ot(t,et):ot(t,nt)),et=Number.MIN_SAFE_INTEGER.toString(),rt=Y?BigInt(Number.MIN_SAFE_INTEGER):void 0,nt=Number.MAX_SAFE_INTEGER.toString(),it=Y?BigInt(Number.MAX_SAFE_INTEGER):void 0;function ot(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var at,st=0,ut=0;function lt(t){var e=t>>>0;st=e,ut=(t-e)/4294967296>>>0}function ft(t){if(t<0){lt(-t);let[e,r]=mt(st,ut);st=e>>>0,ut=r>>>0}else lt(t)}function ct(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ht(t,e)}function ht(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else C()?r=""+(BigInt(e)<<BigInt(32)|BigInt(t)):(t=(16777215&t)+6777216*(r=16777215&(t>>>24|e<<8))+6710656*(e=e>>16&65535),r+=8147497*e,e*=2,t>=1e7&&(r+=t/1e7>>>0,t%=1e7),r>=1e7&&(e+=r/1e7>>>0,r%=1e7),r=e+dt(r)+dt(t));return r}function dt(t){return t=String(t),"0000000".slice(t.length)+t}function pt(){var t=st,e=ut;if(2147483648&e)if(C())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=mt(t,e);t="-"+ht(r,n)}else t=ht(t,e);return t}function yt(t){if(t.length<16)ft(Number(t));else if(C())t=BigInt(t),st=Number(t&BigInt(4294967295))>>>0,ut=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);ut=st=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));ut*=1e6,(st=1e6*st+e)>=4294967296&&(ut+=Math.trunc(st/4294967296),ut>>>=0,st>>>=0)}if(e){let[t,e]=mt(st,ut);st=t,ut=e}}}function mt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var gt="function"==typeof BigInt?BigInt.asIntN:void 0,vt="function"==typeof BigInt?BigInt.asUintN:void 0,bt=Number.isSafeInteger,wt=Number.isFinite,At=Math.trunc;function It(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var Et,St,Nt,Bt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function _t(t){switch(typeof t){case"bigint":return!0;case"number":return wt(t);case"string":return Bt.test(t);default:return!1}}function xt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?0|t:void 0}function Ct(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(yt(t),pt())}function Tt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(yt(t),ht(st,ut))}function jt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(gt(64,t));if(_t(t)){if("string"===e)return e=At(Number(t)),bt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ct(t)),t;if("number"===e)return function(t){if(t=At(t),!bt(t)){ft(t);var e=st,r=ut;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=ct(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function Ot(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(vt(64,t));if(_t(t)){if("string"===e)return e=At(Number(t)),bt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Tt(t)),t;if("number"===e)return function(t){return(t=At(t))>=0&&bt(t)||(ft(t),t=ct(st,ut)),t}(t)}}function Ft(t){if(null==t||"string"==typeof t||t instanceof E)return t}function Ut(t){return null==t||"string"==typeof t?t:void 0}function kt(t){return t}function Mt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),f=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(Et??kt)(s-f,f,t,c,void 0)+f)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-f;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+f)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Rt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return tt(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[L];return 0===t.length&&1&e?void 0:Mt(t,e,Rt)}if(null!=t&&t[R]===W)return Pt(t);if(t instanceof E){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(m){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),p(),r=c[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.h=e}return t}return}return t}function Pt(t){return Mt(t=t.l,0|t[L],Rt)}function Dt(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[L],s&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(s)throw Error("carr");x(M,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&$(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=64;var o=(r=t).length;if(o){var a=o-1;let t=r[a];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((a-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<a&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&a)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return $(t,64|i|n),t}function Lt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[L];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=zt(t,r,!1,e&&!(16&r)):(G(t,34),4&r&&Object.freeze(t))),t}if(null!=t&&t[R]===W){let n=0|(r=t.l)[L];return J(t,n)||(2&n?e=!0:32&n&&!(4096&n)?($(r,2|n),t.h=V,e=!0):e=!1,e?(t=new t.constructor(r)).j=V:t=zt(r,n)),t}return t instanceof E?t:void 0}function zt(t,e,r,n){return n??=!!(34&e),t=Mt(t,e,Lt,n),n=32,r&&(n|=2),$(t,e=16769217&e|n),t}function Gt(t){if(t.h!==V)return!1;var e=t.l;return G(e=zt(e,0|e[L]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function $t(t){if(!Gt(t)&&J(t,0|t.l[L]))throw Error()}function Ht(t,e){void 0===e&&(e=0|t[L]),32&e&&!(4096&e)&&$(t,4096|e)}function Wt(t,e,r){if(-1===e)return null;var n=e+(r?0:-1),i=t.length-1;if(!(i<1+(r?0:-1))){if(n>=i)if(null!=(t=t[i])&&"object"==typeof t&&t.constructor===Object)e=t[e];else{if(n!==i)return;e=t}else e=t[n];return e}}function Jt(t,e,r){$t(t);var n=t.l;return Vt(n,0|n[L],e,r),t}function Vt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[L])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function qt(t,e,r){return t=Wt(t,e,r),Array.isArray(t)?t:O}function Kt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Xt(t){if(T)return t[U]??(t[U]=new Map);if(U in t)return t[U];var e=new Map;return Object.defineProperty(t,U,{value:e}),e}function Zt(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Wt(e,o)&&(0!==i&&(r=Vt(e,r,i)),i=o)}return t.set(n,i),i}function Yt(t){return null==t&&(t=void 0),t}function Qt(t,e,r){return Jt(t,e,r=Yt(r)),r&&!J(r)&&Ht(t.l),t}function te(t,e,r){var n=bn;t:{var i=r=Yt(r);$t(t);let s=t.l;var o=0|s[L];if(null==i){var a=Xt(s);if(Zt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Xt(a=s),r=Zt(t,a,o,n);r!==e&&(r&&(o=Vt(a,o,r)),t.set(n,e))}Vt(s,o,e,i)}return r&&!J(r)&&Ht(t.l),t}function ee(t,e){return-273&(2&e?2|t:-3&t)}function re(t,e){var r=fn;$t(t);var n=t.l,i=n,o=0|n[L],a=(t?J(t,o):2&o)?1:2;2===a&&t&&Gt(t)&&(o=0|(i=t.l)[L]);var s=qt(i,8),u=s===O?7:0|s[L],l=H(u,o);if(t=!(4&l)){var f=o;let t=!!(2&l);t&&(f|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){var c=s[i],h=r,d=f;if(null==c||c[R]!==W)if(Array.isArray(c)){let t,e=0|c[L];t=e|32&d,t|=2&d,t!==e&&$(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=J(c),e&&=!h,n&&=h),s[a++]=c)}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&($(s,l),2&l&&Object.freeze(s)),l=u=l,(f=Kt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=ee(u,o),o=Vt(i,o,8,s),f=!1),f||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&$(s,u),Object.freeze(s)):u!==l&&$(s,u)),2&u||!(4096&u||16&u)||Ht(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===O?7:0|a[L],(e=J(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||Ht(n)}function ne(t,e,r){return Jt(t,e,null==r?r:function(t){if(!_t(t))throw _("int64");switch(typeof t){case"string":var e=At(Number(t));return bt(e)?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Q(gt(64,BigInt(t))):Q(Ct(t))),t;case"bigint":return Q(gt(64,t));default:return bt(t)||(t=At(t),bt(t)?t=String(t):(ft(t),t=pt())),Q(t)}}(r))}function ie(t,e,r){return Jt(t,e,null==r?r:function(t){if(!_t(t))throw _("uint64");switch(typeof t){case"string":var e=At(Number(t));return bt(e)&&e>=0?t=Q(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Q(vt(64,BigInt(t))):Q(Tt(t))),t;case"bigint":return Q(vt(64,t));default:return t>=0&&bt(t)||((t=At(t))>=0&&bt(t)?t=String(t):(ft(t),t=ht(st,ut))),Q(t)}}(r))}function oe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Jt(t,e,r)}function ae(t,e,r){if(null!=r){if(!wt(r))throw _("enum");r|=0}return Jt(t,e,r)}var se=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ue(t){if("string"==typeof t)return new se(w(t),!0);if(Array.isArray(t))return new se(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new se(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new se(t,!1);if(t.constructor===E){S(I);var e=t.h;return e=(null==(e=null==e||y&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?w(e):null)?e:t.h=e)||new Uint8Array(0),new se(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new se(t,!1);throw Error()}function le(t){return new he(4294967295&t,Math.floor(t/4294967296))}function fe(t){return t?/^\d+$/.test(t)?(yt(t),new he(st,ut)):null:ce||=new he(0,0)}var ce,he=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function de(t){return new Ee(4294967295&t,Math.floor(t/4294967296))}function pe(t){return t?/^-?\d+$/.test(t)?(yt(t),new Ee(st,ut)):null:ye||=new Ee(0,0)}var ye,me,ge,ve,be,we,Ae,Ie,Ee=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Se(t,e,r){return"undefined"!=typeof BigInt64Array?(Ae||(Ae=new BigInt64Array(1),Ie=new Uint32Array(Ae.buffer),Ae[0]=BigInt(1),we=1===Ie[0]),Ae[0]=t,new e(Ie[t=we?0:1],Ie[1-t])):(be||(me=BigInt(Number.MIN_SAFE_INTEGER),ge=BigInt(Number.MAX_SAFE_INTEGER),ve=BigInt(4294967295),be=BigInt(32)),t>=me&&t<=ge?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ve),Number(t>>be))))}function Ne(t,e,r){for(;r>0||e>127;)t.h.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function Be(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function _e(t,e){if(e>=0)Be(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function xe(t,e){yt(e),function(t){var e=ut>>31;t(st<<1^e,(ut<<1|st>>>31)^e)}((e,r)=>{Ne(t,e>>>0,r>>>0)})}function Ce(t,e){t.h.push(e>>>0&255),t.h.push(e>>>8&255),t.h.push(e>>>16&255),t.h.push(e>>>24&255)}var Te=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function je(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function Oe(t,e,r){Be(t.h,8*e+r)}function Fe(t,e){return Oe(t,e,2),e=t.h.end(),je(t,e),e.push(t.i),e}function Ue(t,e){var r=e.pop();for(r=t.i+t.h.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.i++;e.push(r),t.i++}function ke(t,e,r){if(null!=r)switch(Oe(t,e,0),typeof r){case"number":t=t.h,ft(r),Ne(t,st,ut);break;case"bigint":r=Se(r,Ee,de),Ne(t.h,r.i,r.h);break;default:r=pe(r),Ne(t.h,r.i,r.h)}}function Me(t,e,r){Oe(t,e,2),Be(t.h,r.length),je(t,t.h.end()),je(t,r)}var Re=class{constructor(){this.j=[],this.i=0,this.h=new Te}};function Pe(t){if("string"==typeof t)pe(t)}function De(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Le=De(),ze=De(),Ge=De(),$e=De(),He=De(),We=De(),Je=De(),Ve=De(),qe=De(),Ke=De(),Xe=De(),Ze=De(),Ye=class{constructor(t,e){this.l=Dt(t,e,void 0,2048)}toJSON(){return Pt(this)}};Ye.prototype[R]=W,Ye.prototype.toString=function(){return this.l.toString()};var Qe=class{constructor(t,e){this.M=t,t=Le,this.h=!!t&&e===t||!1}};function tr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}var er,rr,nr=new Qe(tr,Le),ir=new Qe(tr,Le),or=Symbol(),ar=Symbol();function sr(t){var e=lr,r=fr,n=t[or];if(n)return n;(n={}).ka=t,n.P=function(t){switch(typeof t){case"boolean":return St||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Nt||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.X=i,"function"==typeof(i=t[++o])&&(n.da=!0,er??=i,rr??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let f;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof Qe?f=i:(f=nr,o--),f?.h){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,f,u,t):e(n,s,f,t)}}return t[or]=n}function ur(t,e){return t instanceof Ye?t.l:Array.isArray(t)?Dt(t,e[0],e[1]):void 0}function lr(t,e,r){t[e]=r.M}function fr(t,e,r,n){var i,o,a=r.M;t[e]=(t,e,r)=>a(t,e,r,o||=sr(n).P,i||=cr(n))}function cr(t){var e=t[ar];if(!e){let r=sr(t);e=(t,e)=>hr(t,e,r),t[ar]=e}return e}function hr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[L],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.X)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof Qe?r:[ir,r]:[r,void 0])[0].M;if(r=r[1]){let e=cr(r),i=sr(r).P;r=t.da?rr(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||x(k,3)}})}function dr(t,e,r){if(Array.isArray(e)){var n=0|e[L];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&$(e,t),r&&2&t&&Object.freeze(e),e}}var pr=(t,e)=>{var r=new Re;hr(t.l,r,sr(e)),je(r,r.h.end()),t=new Uint8Array(r.i);var n=(e=r.j).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.j=[t],t};function yr(t,e){return new Qe(t,e)}function mr(t,e){return new Qe(t,e)}function gr(t,e,r){null!=(e=jt(e))&&(Pe(e),ke(t,r,e))}function vr(t,e,r){null!=(e=xt(e))&&null!=e&&(Oe(t,r,0),_e(t.h,e))}function br(t,e,r){null!=(e=Ut(e))&&Me(t,r,o(e))}function wr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}function Ar(t,e,r){null!=(e=Ft(e))&&Me(t,r,ue(e).buffer)}function Ir(t,e,r){null!=(e=xt(e))&&(e=parseInt(e,10),Oe(t,r,0),_e(t.h,e))}var Er,Sr=yr(function(t,e,r){null!=(e=It(e))&&(Oe(t,r,1),t=t.h,(r=at||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),st=r.getUint32(0,!0),ut=r.getUint32(4,!0),Ce(t,st),Ce(t,ut))},Ke),Nr=yr(function(t,e,r){null!=(e=It(e))&&(Oe(t,r,5),t=t.h,(r=at||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),ut=0,Ce(t,st=r.getUint32(0,!0)))},qe),Br=yr(gr,We),_r=yr(gr,We),xr=mr(function(t,e,r){if(null!=(e=dr(jt,e,!1)))for(let n=0;n<e.length;n++)ke(t,r,e[n])},We),Cr=yr(function(t,e,r){if(null!=(e=Ot(e))){if("string"==typeof e)fe(e);if(null!=e)switch(Oe(t,r,0),typeof e){case"number":t=t.h,ft(e),Ne(t,st,ut);break;case"bigint":r=Se(e,he,le),Ne(t.h,r.i,r.h);break;default:r=fe(e),Ne(t.h,r.i,r.h)}}},Je),Tr=yr(vr,$e),jr=mr(function(t,e,r){if(null!=(e=dr(xt,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(Oe(n,i,0),_e(n.h,o))}},$e),Or=mr(function(t,e,r){if(null!=(e=dr(xt,e,!0))&&e.length){r=Fe(t,r);for(let r=0;r<e.length;r++)_e(t.h,e[r]);Ue(t,r)}},$e),Fr=yr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Oe(t,r,0),t.h.h.push(e?1:0))},ze),Ur=yr(br,Ge),kr=mr(function(t,e,r){if(null!=(e=dr(Ut,e,!0)))for(let s=0;s<e.length;s++){var n=t,i=r,a=e[s];null!=a&&Me(n,i,o(a))}},Ge),Mr=function(t,e,r=Le){return new Qe(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)wr(t,e[o],r,n,i);1&(t=0|e[L])||$(e,1|t)}}),Rr=new Qe(wr,Le),Pr=yr(Ar,Xe),Dr=mr(function(t,e,r){if(null!=(e=dr(Ft,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&Me(n,i,ue(o).buffer)}},Xe),Lr=yr(function(t,e,r){e=function(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return wt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Oe(t,r,0),Be(t.h,e))},He),zr=yr(Ir,Ze),Gr=yr(Ir,Ze),$r=yr(function(t,e,r){if(null!=(e=jt(e))&&(Pe(e),null!=e))switch(Oe(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,lt(r=2*Math.abs(r)),r=st;let n=ut;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),Ne(t,st=r,ut=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),st=Number(BigInt.asUintN(32,e)),ut=Number(BigInt.asUintN(32,e>>BigInt(32))),Ne(t,st,ut);break;default:xe(t.h,e)}},Ve),Hr=[0,Pr,Dr,Fr,Ur],Wr=[0,yr(br,Ge),[0,Gr,[0,yr(gr,We),yr(vr,$e)],Gr,-1,[0,zr],Gr,-1],yr(Ar,Xe)],Jr=[0,1,[0,12,Tr,10,Fr],[0,7,[0,Tr,-1]]],Vr=globalThis.trustedTypes;var qr=class{constructor(t){this.h=t}toString(){return this.h+""}};function Kr(t){var e;return void 0===Er&&(Er=function(){var t=null;if(!Vr)return t;try{let e=t=>t;t=Vr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Er)?e.createScriptURL(t):t,new qr(t)}function Xr(t,...e){if(0===e.length)return Kr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return Kr(r)}function Zr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Qr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Qr(Yr(t.quantizedEmbedding),Yr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Yr(t){return Array.from(t,t=>t>127?t-256:t)}function Qr(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);var r=0,n=0,i=0;for(let o=0;o<t.length;o++)r+=t[o]*e[o],n+=t[o]*t[o],i+=e[o]*e[o];if(n<=0||i<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*i)}function tn(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function en(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,tn(t)})}),tn(t)})}var rn,nn=class{constructor(){this.h=!1,this.i=[]}},on=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function an(t){if(t)return!0;if(void 0===rn)try{await WebAssembly.instantiate(on),rn=!0}catch{rn=!1}return rn}async function sn(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await an(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var un=class{};function ln(t){return ae(new fn,1,t)}un.forVisionTasks=function(t,e=!1){return sn("vision",t??Xr``,e)},un.forLiteRtLmTextTasks=function(t,e=!1){return sn("litertlm_text",t??Xr``,e)},un.forTextTasks=function(t,e=!1){return sn("text",t??Xr``,e)},un.forRetrievalTasks=function(t,e=!1){return sn("retrieval",t??Xr``,e)},un.forGenAiTasks=function(t,e=!1){return sn("genai",t??Xr``,e)},un.forDecisionTasks=function(t,e=!1){return sn("decision",t??Xr``,e)},un.forAudioTasks=function(t,e=!1){return sn("audio",t??Xr``,e)},un.isSimdSupported=function(t=!1){return an(t)};var fn=class extends Ye{constructor(t){super(t)}},cn=class extends Ye{constructor(t){super(t)}},hn=[0,zr,2,Cr,-2,_r,Mr,[0,zr,_r]],dn=class extends Ye{constructor(t){super(t)}},pn=class extends Ye{constructor(t){super(t)}};function yn(t,e){return ae(t,1,e)}function mn(t,e){return ae(t,2,e)}var gn,vn=class extends Ye{constructor(t){super(t)}},bn=[3,4,5,6,7],wn=class extends Ye{constructor(t){super(t)}},An=class extends Ye{constructor(t){super(t)}};An.prototype.i=(gn=[0,[0,zr,Ur,-3,zr],[0,bn,zr,-1,Rr,[0,zr,Ur,Cr],Rr,hn,Rr,[0,1,hn],Rr,[0,zr],Rr,[0,zr,Ur,Cr]]],function(){return pr(this,gn)});var In=class{constructor(){this.h="undefined"!=typeof AbortController}async send(t,e,r){var n=this.h?new AbortController:void 0,i=n&&t.O>0?setTimeout(()=>{n.abort()},t.O):void 0;try{let i=await fetch(t.url,{method:t.ga,headers:{...t.fa},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.O&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},En=class extends Ye{constructor(t){super(t,37)}},Sn=[-4,{},Jr,zr,Wr],Nn=[0,Ur,zr,1,Ur,-1,zr,1,zr,1,_r],Bn=[0,zr,Ur,-2],_n=[0,Ur,zr],xn=[0,Ur,zr],Cn=[0,Fr,-3],Tn=[0,zr,Ur,-1,_r,Tr,-1,Ur,-5,Mr,[0,Ur,-4],-1,Fr,[0,Fr,-3],zr];var jn=class extends Ye{constructor(t){super(t,19)}},On=function(t){return e=>pr(e,t)}([-19,{},[0,zr,1,[0,Ur,-6,_r,Tr,Ur,-1,_r],1,[0,Ur,1,Ur,-5],Ur,-1,[0,zr,Ur,-8],[0,Ur,-3],[0,Ur,zr,Ur,-2],[0,Ur,-1,zr,Ur,-1,zr,Ur,-1,[0,Mr,[0,Ur,-1],Fr,Ur,-5],[0,zr,Fr,Tr,-2]],_r,[0,Ur,-3,_r,Tr,Ur,-1],[0,zr,Ur,-1],[0,Ur,-9],[0,Ur,-6,zr,Ur,1,Ur,Fr,zr,-1,Fr,Ur,-2,zr,Ur,zr,Ur,Tr,-1],1,[0,zr],1,[0,Ur,-4],1,Nn,[0,[1,2,3,4,5,6],Rr,Nn,Rr,_n,Rr,xn,Rr,[0,zr],Rr,Tn,Rr,Bn],_n,xn,Tn,[0,[0,zr,Ur,-1,_r,Tr,-1,Ur,-4,Mr,[0,Ur,-4],-1,1,Cn],[0,zr,Ur,-1,_r,Tr,-1,Ur,-4,Cn]],Bn,[0,Ur,[0,Tr,-3,zr],zr,-2,[0,Tr,-1],Fr],4,[0,Ur,zr,Ur,-1,_r,zr,Ur,-1,zr,Tr,-1]],zr,Mr,[-37,{},Br,Ur,Mr,[0,Ur,-1],Pr,1,Pr,[0,kr,-1,jr,xr,-1],Ur,[0,Tr,Ur,-1],Fr,Tr,_r,Ur,-1,$r,Hr,Br,Pr,zr,jr,_r,-1,[0,zr,-1],Ur,Fr,Ur,Or,Ur,-1,Sr,1,Sr,Sn,Fr,[0,zr,[0,Nr,Tr,-2],[0,Nr]],[0,zr,_r]],Br,Dr,Ur,-1,Br,zr,-1,[0,Fr,-1,zr,Fr],[0,_r,-1,Ur],[0,Br,Fr,_r],_r,1,Lr,1,Sn]),Fn=class{constructor(t){this.i=[],this.m=new In,this.j=t??"",this.h=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.h&&(clearInterval(this.h),this.h=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.i.length)t?.();else{var r=this.i;this.i=[],r=function(t){var e=new jn;$t(e=ae(e,2,1786));var r=e.l,n=0|r[L];if(null==t)Vt(r,n,3);else{var i=t===O?7:0|t[L],o=i,a=Kt(i),s=a||Object.isFrozen(t),u=!0,l=!0;for(let e=0;e<t.length;e++){var f=t[e];a||(f=J(f),u&&=!f,l&&=f)}a||(i=u?13:5,i=l?-4097&i:4096|i),s&&i===o||(t=Array.prototype.slice.call(t),o=0,i=ee(i,n)),i!==o&&$(t,i),n=Vt(r,n,3,t),2&i||!(4096&i||16&i)||Ht(r,n)}return e}(r),r=On(r),this.m.send({url:"https://odml.pa.googleapis.com/v1/log",ga:"POST",O:1e4,body:r,la:2,fa:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.j},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.i=[],void 0!==this.h&&(clearInterval(this.h),this.h=void 0),e?.("net-send-failed",t)})}}};class Un{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function kn(t,e){var r=new An;if(r=Qt(r,1,t.S),r=Qt(r,2,e),e=new En,null!=(r=r.i()))if("string"==typeof r)r=r?new E(r,I):A||=new E(null,I);else if(!(r instanceof E)){if(!(y&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new E(new Uint8Array(r),I):A||=new E(null,I)}e=Jt(e,6,r),(t=t.H).error||t.i.push(e)}function Mn(t){var e=new pn;e=ie(e=ae(e,1,10),3,performance.now()-t.R),kn(t,e=te(mn(yn(new vn,t.v),0),3,e)),t.m=performance.now()}function Rn(t,e){++t.h.F,t.i.set(e,performance.now())}function Pn(t,e){var r={C:e.C-t.j.C,F:e.F-t.j.F,D:e.D-t.j.D,A:e.A-t.j.A,G:e.G-t.j.G,B:e.B,I:e.I},n=mn(yn(new vn,t.v),1);kn(t,n=te(n,4,r=Ln(r))),t.j=e}function Dn(t,e){var r=t.i.get(e);if(void 0!==r&&(t.i.delete(e),e=performance.now()-r,++t.h.D,t.h.G+=e,t.h.B=Math.max(t.h.B,e),t.u=Math.max(t.u,e),performance.now()>t.m+3e4)){for(let[n,i]of t.i.entries())e=n,i<r&&(t.h.A++,t.i.delete(e));r={...t.h,I:performance.now()-t.m},t.h.B=0,t.m=performance.now(),Pn(t,r)}}function Ln(t){var e=new cn;if(e=ie(e=ne(e=ae(e,1,10),7,t.A),5,t.B),e=ie(e,6,t.I),t.D>0&&ie(e,4,t.G/t.D),0!==t.C){var r=ln(3);re(e,r=ne(r,2,t.C))}return 0!==t.F&&re(e,t=ne(r=ln(4),2,t.F)),e}function zn(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.R};Pn(t,e);var r=new dn;r=Qt(r,2,e=Ln(e)),kn(t,r=te(e=mn(yn(new vn,t.v),2),5,r))}var Gn=class{constructor(t,e){this.R=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Un,this.j=new Un,this.H=new Fn(e),this.v=function(t){switch(t){case"AudioClassifier":return 4;case"AudioEmbedder":return 5;case"TextClassifier":return 6;case"TextEmbedder":return 7;case"GestureRecognizer":return 8;case"HandDetector":return 9;case"HandLandmarker":return 10;case"ImageClassifier":return 11;case"ImageEmbedder":return 12;case"ImageSegmenter":return 13;case"ObjectDetector":return 14;case"FaceDetector":return 15;case"FaceLandmarker":return 16;case"InteractiveSegmenter":case"InteractiveSegmenterLegacy":return 18;case"HolisticLandmarker":return 20;case"LlmInference":return 21;case"LanguageDetector":return 22;case"PoseLandmarker":return 23;case"UniversalEmbedder":return 28;case"SemanticRetriever":return 29;case"DecisionMaker":return 30;case"TextSummarizer":return 26;case"TextProofreader":return 27;case"AudioTranscriber":return 31;case"TextToSpeech":return 32;default:return 0}}(t),t=new wn,"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=oe(t=ae(t,1,e),2,""),t=oe(t,3,""),t=oe(t,4,"1.2.0"),t=oe(t,5,""),this.S=ae(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}())}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function $n(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new Gn(t,e)}async function Hn(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())}}}var Wn=async(t,e,r,n)=>{if(e&&await Hn(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await Hn(r),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((e=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new t(n,null)},Jn={CHARACTER:0,WORD:1};function Vn(t,e){if(t<=0)throw Error("Chunk size must be positive.");if(e<0||e>=t)throw Error("Chunk overlap must be non-negative and less than chunk size.")}function qn(t,e,r,n="CHARACTER"){Vn(e,r),t.j=e,t.i=r,t.mode=n}var Kn=class{constructor(t){this.j=512,this.i=100,this.mode="CHARACTER",this.h=t}chunk(t){if(!t||0===t.trim().length)return[];if(!this.h||"function"!=typeof this.h.defaultTextChunker_nativeChunkText)throw Error("DefaultTextChunker Wasm module is not initialized.");return(t=this.h.defaultTextChunker_nativeChunkText(t,this.j,this.i,Jn[this.mode]??0))?Array.from(t):[]}};function Xn(t){return{...t,content:t.content?t.content.map(t=>"imageBytes"in t?{...t,imageBytes:new Uint8Array(t.imageBytes)}:"audioData"in t?{...t,audioData:new Float32Array(t.audioData)}:{...t}):[],embeddings:t.embeddings?new Float32Array(t.embeddings):new Float32Array(0),metadata:t.metadata?{...t.metadata}:{},...t.childIds?{childIds:[...t.childIds]}:{}}}Kn.prototype.chunk=Kn.prototype.chunk,Kn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return Vn(e,r),qn(t=new Kn(t),e,r,n),t},Kn.create=async function(t,e=512,r=100,n="CHARACTER"){Vn(e,r);var i=await Wn(Kn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return qn(i,e,r,n),i};var Zn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Xn(e))}delete(t){var e=new Set(t);for(let r of t)if(t=this.h.get(r),t?.childIds)for(let r of t.childIds)e.add(r);for(let t of e)this.h.delete(t)}deleteByMetadata(t){var e=Object.keys(t);if(0!==e.length){var r=[];for(let n of this.h.values())n.parentId||n.metadata&&e.every(e=>n.metadata[e]===t[e])&&r.push(n.id);r.length>0&&this.delete(r)}}search(t,e,r){if(e<=0)throw Error(`'topK' must be greater than 0, got ${e}.`);var n=r?Object.keys(r):[];t=Array.from(t);var i=[];for(let e of this.h.values()){if(r&&n.length>0){if(!e.metadata)continue;if(!n.every(t=>e.metadata?.[t]===r[t]))continue}if(e.embeddings&&0!==e.embeddings.length)try{let r=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""});i.push({ea:e,score:r})}catch{}}return i.sort((t,e)=>e.score-t.score),i.slice(0,e).map(t=>Xn(t.ea))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Xn(t));return e}getAllRecordIds(){var t=[];for(let[e,r]of this.h.entries()){let n=e;r.parentId||t.push(n)}return t}deleteAll(){this.h.clear()}close(){this.h.clear()}};Zn.prototype.close=Zn.prototype.close,Zn.prototype.deleteAll=Zn.prototype.deleteAll,Zn.prototype.getAllRecordIds=Zn.prototype.getAllRecordIds,Zn.prototype.get=Zn.prototype.get,Zn.prototype.search=Zn.prototype.search,Zn.prototype.deleteByMetadata=Zn.prototype.deleteByMetadata,Zn.prototype.delete=Zn.prototype.delete,Zn.prototype.upsert=Zn.prototype.upsert;var Yn=class{constructor(){this.h=[]}T(t){return this.h.push(t),this}N(){return[...this.h]}ja(t){return this.j=t,this}o(){return this.j}ia(t){return this.i=t,this}L(){return this.i}};function Qn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Yn.prototype.textChunker=Yn.prototype.L,Yn.prototype.setTextChunker=Yn.prototype.ia,Yn.prototype.vectorStore=Yn.prototype.o,Yn.prototype.setVectorStore=Yn.prototype.ja,Yn.prototype.providers=Yn.prototype.N,Yn.prototype.addProvider=Yn.prototype.T;var ti=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=$n("SemanticRetriever"),Mn(this.h)}async embedContent(t){for(let e of this.m.N()){let r=await e.embedContent(t);if(null!=r)return r instanceof Float32Array?r:new Float32Array(r)}throw Error("No embedding provider found that can embed this content.")}async aa(t,e,r){return Qn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Qn(this),await this.o.delete([t]);var n=[],i=0;if(1===e.length&&"text"in e[0]&&"string"==typeof e[0].text){var o=await this.L.chunk(e[0].text);if(o.length>1){let r=[];for(let e of o)o=`${t}_chunk_${i++}`,r.push(o),n.push({id:o,J:[{text:e}],parentId:t});n.push({id:t,J:e,childIds:r})}else n.push({id:t,J:e})}else n.push({id:t,J:e});t=[];for(let e of n)n=void 0!==e.childIds&&e.childIds.length>0?new Float32Array(0):await this.embedContent(e.J),t.push({id:e.id,content:[...e.J],embeddings:n,metadata:r||{},parentId:e.parentId,childIds:e.childIds});await this.o.upsert(t)}async ba(t,e,r){return Qn(this),this.K(t,[{imageBytes:e}],r)}async Z(t,e,r){return Qn(this),this.K(t,[{audioData:e}],r)}async ha(t,e={}){Qn(this);var{limit:r=5,metadataFilter:n}=e;if(r<=0)throw Error(`'limit' must be greater than 0, got ${r}.`);e=this.j++;var i=this.h;++i.h.C,i.i.set(e,performance.now()),t=await this.embedContent("string"==typeof t?[{text:t}]:t),i=await this.o.search(t,3*r,n);var o=new Set;for(var a of i)a.parentId&&o.add(a.parentId);if(a=new Map,o.size>0)for(var s of o=await this.o.get(Array.from(o)))a.set(s.id,s);for(var u of(s=[],o=new Set,i))u.parentId?o.has(u.parentId)||(o.add(u.parentId),(i=a.get(u.parentId))&&s.push({id:i.id,content:i.content,embeddings:u.embeddings,metadata:i.metadata,parentId:i.parentId,childIds:i.childIds})):o.has(u.id)||(o.add(u.id),s.push(u));u=[],t=Array.from(t);for(let e of s){if(s=0,e.embeddings&&e.embeddings.length>0)try{s=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""})}catch{s=0}if(u.push({id:e.id,content:e.content?[...e.content]:[],metadata:e.metadata?{...e.metadata}:{},score:s}),u.length>=r)break}return Dn(this.h,e),u}async delete(t){Qn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Qn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Qn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,zn(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ei(t,e){var r=e.baseOptions.device;r||=await ri();var n=await Wn(oi,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return r&&(n.h.preinitializedWebGPUDevice=r),await async function(t,e,r){t.i=$n("UniversalEmbedder");var n=!1!==e.l2Normalize,i=e.baseOptions.modelAssetPath?e.baseOptions.modelAssetPath.toString():"";if((r=r||e.baseOptions.device||t.h.preinitializedWebGPUDevice)||(r=await ri()),t.h.preinitializedWebGPUDevice=r,e.baseOptions.modelAssetBuffer){i=e.baseOptions.modelAssetBuffer instanceof Uint8Array?e.baseOptions.modelAssetBuffer:await async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(e.baseOptions.modelAssetBuffer);var o=`/${r=`universal_embedder_model_${++ai}.litertlm`}`;try{t.h.FS_unlink?.(o)}catch{}t.h.FS_createDataFile("/",r,i,!0,!1,!1),t.v=o,i=t.v}if(!i)throw Error("No model asset path or buffer provided.");r=e.maxInputLength??0,o=e.visionTokensPerImage??0,e=function(t){if(void 0===t)return 0;switch(t){case"FLOAT32":return 1;case"FLOAT16":return 2;case"INT16":return 3;case"INT8":return 4;default:throw Error(`Unsupported activation data type: ${t}`)}}(e.activationDataType);try{t.j=await t.h.createUniversalEmbedder(i,n,r,o,e),Mn(t.i)}catch(e){throw ni(t),e}}(n,e,r),n}async function ri(){if("undefined"==typeof navigator||!navigator.gpu)throw Error("WebGPU is not supported on this platform.");var t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw Error("No appropriate WebGPU adapter found.");var e=[];if(t.features.has("subgroups")&&e.push("subgroups"),t.features.has("shader-f16")&&e.push("shader-f16"),!(e=await t.requestDevice({requiredFeatures:e})).adapterInfo&&t.info)try{Object.defineProperty(e,"adapterInfo",{value:t.info,writable:!0,configurable:!0})}catch{}return e}function ni(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ii(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}ti.prototype.close=ti.prototype.close,ti.prototype.deleteAll=ti.prototype.deleteAll,ti.prototype.getAllRecordIds=ti.prototype.getAllRecordIds,ti.prototype.delete=ti.prototype.delete,ti.prototype.retrieve=ti.prototype.ha,ti.prototype.insertAudio=ti.prototype.Z,ti.prototype.insertImage=ti.prototype.ba,ti.prototype.insertContent=ti.prototype.K,ti.prototype.insertDocument=ti.prototype.aa,ti.createFromComponents=async function(t){if(!t||0===t.N().length)throw Error("At least one EmbeddingProvider must be registered in SemanticRetrieverComponents.");var e=t.o();if(!e)throw Error("VectorStore must be provided in SemanticRetrieverComponents.");var r=t.L();if(!r)throw Error("TextChunker must be provided in SemanticRetrieverComponents.");return new ti(t,e,r)};var oi=class{constructor(t){this.H=!1,this.j=0,this.u=new nn,this.m=0,this.h=t}async W(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async V(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ii(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return en(this.u,async()=>{ii(this);var e=this.h.universalEmbedder_createContentBuilder();try{for(let r of t)if("text"in r&&"string"==typeof r.text)this.h.universalEmbedder_builderAddText(e,r.text);else if("imageBytes"in r&&(r.imageBytes instanceof Uint8Array||"string"==typeof r.imageBytes))this.h.universalEmbedder_builderAddImage(e,r.imageBytes);else{if(!("audioData"in r)||!(r.audioData instanceof Float32Array||Array.isArray(r.audioData)))throw Error(`Unsupported or invalid ContentPart: ${JSON.stringify(r)}`);this.h.universalEmbedder_builderAddAudio(e,r.audioData)}let r=this.m++;Rn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Dn(this.i,r),{embeddings:[{floatEmbedding:n?Array.from(n):[],headIndex:0,headName:"default"}]}}finally{this.h.universalEmbedder_freeContentBuilder(e)}})}Y(){return{embedContent:async t=>(await this.embedContent(t))?.embeddings?.[0]?.floatEmbedding??null}}close(){this.H||(this.H=!0,zn(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ni(this))}};oi.prototype.close=oi.prototype.close,oi.prototype.getProvider=oi.prototype.Y,oi.cosineSimilarity=function(t,e){return Zr(t,e)},oi.prototype.embedContent=oi.prototype.embedContent,oi.prototype.embedAudio=oi.prototype.U,oi.prototype.embedImage=oi.prototype.V,oi.prototype.embedText=oi.prototype.W,oi.createFromModelPath=function(t,e){return ei(t,{baseOptions:{modelAssetPath:e.toString()}})},oi.createFromModelBuffer=function(t,e){return ei(t,{baseOptions:{modelAssetBuffer:e}})},oi.createWebGpuDevice=ri,oi.createFromOptions=ei;var ai=0;return t.DefaultTextChunker=Kn,t.FilesetResolver=un,t.MemoryVectorStore=Zn,t.SemanticRetriever=ti,t.SemanticRetrieverComponents=Yn,t.UniversalEmbedder=oi,t}({});
1
+ var Retrieval=function(t){"use strict";var e="undefined"!=typeof self?self:{};function r(t,r){t:{for(var n=["CLOSURE_FLAGS"],i=e,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(t=n&&n[t])?t:r}var n,i="undefined"!=typeof TextEncoder;function o(t){if(i)t=(n||=new TextEncoder).encode(t);else{let r=0,n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.subarray(0,r)}return t}var a=r(610401301,!1),s=r(748402147,!0);function u(){var t=e.navigator;return t&&(t=t.userAgent)?t:""}var l,f=e.navigator;l=f&&f.userAgentData||null;var c={},h=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 n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){let e=t.charAt(n++),r=h[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}p();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function p(){if(!h){h={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));c[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===h[e]&&(h[e]=t)}}}}var y="undefined"!=typeof Uint8Array,m=!(!(!!a&&(!!l&&l.brands.length>0))&&(-1!=u().indexOf("Trident")||-1!=u().indexOf("MSIE")))&&"function"==typeof btoa,g=/[-_.]/g,v={"-":"+",_:"/",".":"="};function b(t){return v[t]||""}function w(t){if(!m)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 A,I={},E=class{constructor(t,e){if(S(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function S(t){if(t!==I)throw Error("illegal external caller")}function N(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var B=void 0;function _(t){return N(t=Error(t),"warning"),t}function x(t,r){if(null!=t){var n=B??={},i=n[t]||0;i>=r||(n[t]=i+1,N(t=Error(),"incident"),function(t){e.setTimeout(()=>{throw t},0)}(t))}}function C(){return"function"==typeof BigInt}var T="function"==typeof Symbol&&"symbol"==typeof Symbol();function j(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 O,F=j("jas",void 0,!0),U=j(void 0,"1oa"),k=j(void 0,"0ubsb"),M=j(void 0,"0actk"),R=j("m_m","ma",!0),P={ba:{value:0,configurable:!0,writable:!0,enumerable:!1}},D=Object.defineProperties,L=T?F:"ba",z=[];function G(t,e){T||L in t||D(t,P),t[L]|=e}function $(t,e){T||L in t||D(t,P),t[L]=e}$(z,7),O=Object.freeze(z);var H={};function W(t,e){return void 0===e?t.h!==J&&!!(2&t.l[L]):!!(2&e)&&t.h!==J}var J={};function V(t){return t.la=!0,t}var q=V(t=>"number"==typeof t),K=V(t=>"string"==typeof t),X=V(t=>"boolean"==typeof t),Z="function"==typeof e.BigInt&&"bigint"==typeof e.BigInt(0);function Y(t){var e=t;if(K(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(q(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Z?BigInt(t):t=X(t)?t?"1":"0":K(t)?t.trim()||"0":String(t)}var Q=V(t=>Z?t>=et&&t<=nt:"-"===t[0]?it(t,tt):it(t,rt)),tt=Number.MIN_SAFE_INTEGER.toString(),et=Z?BigInt(Number.MIN_SAFE_INTEGER):void 0,rt=Number.MAX_SAFE_INTEGER.toString(),nt=Z?BigInt(Number.MAX_SAFE_INTEGER):void 0;function it(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var ot,at=0,st=0;function ut(t){var e=t>>>0;at=e,st=(t-e)/4294967296>>>0}function lt(t){if(t<0){ut(-t);let[e,r]=yt(at,st);at=e>>>0,st=r>>>0}else ut(t)}function ft(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ct(t,e)}function ct(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else C()?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+ht(r)+ht(t));return r}function ht(t){return t=String(t),"0000000".slice(t.length)+t}function dt(){var t=at,e=st;if(2147483648&e)if(C())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=yt(t,e);t="-"+ct(r,n)}else t=ct(t,e);return t}function pt(t){if(t.length<16)lt(Number(t));else if(C())t=BigInt(t),at=Number(t&BigInt(4294967295))>>>0,st=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);st=at=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));st*=1e6,(at=1e6*at+e)>=4294967296&&(st+=Math.trunc(at/4294967296),st>>>=0,at>>>=0)}if(e){let[t,e]=yt(at,st);at=t,st=e}}}function yt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof BigInt?BigInt.asIntN:void 0,gt="function"==typeof BigInt?BigInt.asUintN:void 0,vt=Number.isSafeInteger,bt=Number.isFinite,wt=Math.trunc;function At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var It,Et,St,Nt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Bt(t){switch(typeof t){case"bigint":return!0;case"number":return bt(t);case"string":return Nt.test(t);default:return!1}}function _t(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return bt(t)?0|t:void 0}function xt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(pt(t),dt())}function Ct(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(pt(t),ct(at,st))}function Tt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),vt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=xt(t)),t;if("number"===e)return function(t){if(t=wt(t),!vt(t)){lt(t);var e=at,r=st;(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 jt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(gt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),vt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ct(t)),t;if("number"===e)return function(t){return(t=wt(t))>=0&&vt(t)||(lt(t),t=ft(at,st)),t}(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof E)return t}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Ut(t){return t}function kt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),f=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(It??Ut)(s-f,f,t,c,void 0)+f)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-f;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+f)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Mt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Q(t)?Number(t):""+t;case"boolean":return t?1:0;case"object":if(Array.isArray(t)){var e=0|t[L];return 0===t.length&&1&e?void 0:kt(t,e,Mt)}if(null!=t&&t[R]===H)return Rt(t);if(t instanceof E){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(m){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),p(),r=c[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.h=e}return t}return}return t}function Rt(t){return kt(t=t.l,0|t[L],Mt)}function Pt(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[L],s&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(s)throw Error("carr");x(M,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&$(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=64;var o=(r=t).length;if(o){var a=o-1;let t=r[a];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((a-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<a&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&a)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return $(t,64|i|n),t}function Dt(t,e){if("object"!=typeof t)return t;if(Array.isArray(t)){var r=0|t[L];return 0===t.length&&1&r?t=void 0:2&r||(!e||4096&r||16&r?t=Lt(t,r,!1,e&&!(16&r)):(G(t,34),4&r&&Object.freeze(t))),t}if(null!=t&&t[R]===H){let n=0|(r=t.l)[L];return W(t,n)||(2&n?e=!0:32&n&&!(4096&n)?($(r,2|n),t.h=J,e=!0):e=!1,e?(t=new t.constructor(r)).j=J:t=Lt(r,n)),t}return t instanceof E?t:void 0}function Lt(t,e,r,n){return n??=!!(34&e),t=kt(t,e,Dt,n),n=32,r&&(n|=2),$(t,e=16769217&e|n),t}function zt(t){if(t.h!==J)return!1;var e=t.l;return G(e=Lt(e,0|e[L]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function Gt(t){if(!zt(t)&&W(t,0|t.l[L]))throw Error()}function $t(t,e){void 0===e&&(e=0|t[L]),32&e&&!(4096&e)&&$(t,4096|e)}function Ht(t,e,r){if(-1===e)return null;var n=e+(r?0:-1),i=t.length-1;if(!(i<1+(r?0:-1))){if(n>=i)if(null!=(t=t[i])&&"object"==typeof t&&t.constructor===Object)e=t[e];else{if(n!==i)return;e=t}else e=t[n];return e}}function Wt(t,e,r){Gt(t);var n=t.l;return Jt(n,0|n[L],e,r),t}function Jt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[L])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function Vt(t,e,r){return t=Ht(t,e,r),Array.isArray(t)?t:O}function qt(t,e){return 2&e&&(t|=2),1|t}function Kt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Xt(t){if(T)return t[U]??(t[U]=new Map);if(U in t)return t[U];var e=new Map;return Object.defineProperty(t,U,{value:e}),e}function Zt(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Ht(e,o)&&(0!==i&&(r=Jt(e,r,i)),i=o)}return t.set(n,i),i}function Yt(t){return null==t&&(t=void 0),t}function Qt(t,e,r){return Wt(t,e,r=Yt(r)),r&&!W(r)&&$t(t.l),t}function te(t,e,r){var n=bn;t:{var i=r=Yt(r);Gt(t);let s=t.l;var o=0|s[L];if(null==i){var a=Xt(s);if(Zt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Xt(a=s),r=Zt(t,a,o,n);r!==e&&(r&&(o=Jt(a,o,r)),t.set(n,e))}Jt(s,o,e,i)}return r&&!W(r)&&$t(t.l),t}function ee(t,e){return-273&(2&e?2|t:-3&t)}function re(t,e){var r=fn;Gt(t);var n=t.l,i=n,o=0|n[L],a=W(t,o)?1:2;2===a&&zt(t)&&(o=0|(i=t.l)[L]);var s=Vt(i,8),u=s===O?7:0|s[L],l=qt(u,o);if(t=!(4&l)){var f=o;let t=!!(2&l);t&&(f|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){var c=s[i],h=r,d=f;if(null==c||c[R]!==H)if(Array.isArray(c)){let t,e=0|c[L];t=e|32&d,t|=2&d,t!==e&&$(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=W(c),e&&=!h,n&&=h),s[a++]=c)}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&($(s,l),2&l&&Object.freeze(s)),l=u=l,(f=Kt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=ee(u,o),o=Jt(i,o,8,s),f=!1),f||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&$(s,u),Object.freeze(s)):u!==l&&$(s,u)),2&u||!(4096&u||16&u)||$t(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===O?7:0|a[L],(e=W(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&$(a,r),e||$t(n)}function ne(t,e,r){return Wt(t,e,null==r?r:function(t){if(!Bt(t))throw _("int64");switch(typeof t){case"string":var e=wt(Number(t));return vt(e)?t=Y(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Y(mt(64,BigInt(t))):Y(xt(t))),t;case"bigint":return Y(mt(64,t));default:return vt(t)||(t=wt(t),vt(t)?t=String(t):(lt(t),t=dt())),Y(t)}}(r))}function ie(t,e,r){return Wt(t,e,null==r?r:function(t){if(!Bt(t))throw _("uint64");switch(typeof t){case"string":var e=wt(Number(t));return vt(e)&&e>=0?t=Y(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=C()?Y(gt(64,BigInt(t))):Y(Ct(t))),t;case"bigint":return Y(gt(64,t));default:return t>=0&&vt(t)||((t=wt(t))>=0&&vt(t)?t=String(t):(lt(t),t=ct(at,st))),Y(t)}}(r))}function oe(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Wt(t,e,r)}function ae(t,e,r){if(null!=r){if(!bt(r))throw _("enum");r|=0}return Wt(t,e,r)}var se=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function ue(t){if("string"==typeof t)return new se(w(t),!0);if(Array.isArray(t))return new se(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new se(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new se(t,!1);if(t.constructor===E){S(I);var e=t.h;return e=(null==(e=null==e||y&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?w(e):null)?e:t.h=e)||new Uint8Array(0),new se(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new se(t,!1);throw Error()}function le(t){return new he(4294967295&t,Math.floor(t/4294967296))}function fe(t){return t?/^\d+$/.test(t)?(pt(t),new he(at,st)):null:ce||=new he(0,0)}var ce,he=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function de(t){return new Ee(4294967295&t,Math.floor(t/4294967296))}function pe(t){return t?/^-?\d+$/.test(t)?(pt(t),new Ee(at,st)):null:ye||=new Ee(0,0)}var ye,me,ge,ve,be,we,Ae,Ie,Ee=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Se(t,e,r){return"undefined"!=typeof BigInt64Array?(Ae||(Ae=new BigInt64Array(1),Ie=new Uint32Array(Ae.buffer),Ae[0]=BigInt(1),we=1===Ie[0]),Ae[0]=t,new e(Ie[t=we?0:1],Ie[1-t])):(be||(me=BigInt(Number.MIN_SAFE_INTEGER),ge=BigInt(Number.MAX_SAFE_INTEGER),ve=BigInt(4294967295),be=BigInt(32)),t>=me&&t<=ge?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ve),Number(t>>be))))}function Ne(t,e,r){for(;r>0||e>127;)t.h.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function Be(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function _e(t,e){if(e>=0)Be(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function xe(t,e){pt(e),function(t){var e=st>>31;t(at<<1^e,(st<<1|at>>>31)^e)}((e,r)=>{Ne(t,e>>>0,r>>>0)})}function Ce(t,e){t.h.push(e>>>0&255),t.h.push(e>>>8&255),t.h.push(e>>>16&255),t.h.push(e>>>24&255)}var Te=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function je(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function Oe(t,e,r){Be(t.h,8*e+r)}function Fe(t,e){return Oe(t,e,2),e=t.h.end(),je(t,e),e.push(t.i),e}function Ue(t,e){var r=e.pop();for(r=t.i+t.h.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.i++;e.push(r),t.i++}function ke(t,e,r){if(null!=r)switch(Oe(t,e,0),typeof r){case"number":t=t.h,lt(r),Ne(t,at,st);break;case"bigint":r=Se(r,Ee,de),Ne(t.h,r.i,r.h);break;default:r=pe(r),Ne(t.h,r.i,r.h)}}function Me(t,e,r){Oe(t,e,2),Be(t.h,r.length),je(t,t.h.end()),je(t,r)}var Re=class{constructor(){this.j=[],this.i=0,this.h=new Te}};function Pe(t){if("string"==typeof t)pe(t)}function De(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var Le=De(),ze=De(),Ge=De(),$e=De(),He=De(),We=De(),Je=De(),Ve=De(),qe=De(),Ke=De(),Xe=De(),Ze=De(),Ye=class{constructor(t,e){this.l=Pt(t,e,void 0,2048)}toJSON(){return Rt(this)}};Ye.prototype[R]=H,Ye.prototype.toString=function(){return this.l.toString()};var Qe=class{constructor(t,e){this.h=t,t=Le,this.i=!!t&&e===t||!1}};function tr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}var er,rr,nr=new Qe(tr,Le),ir=new Qe(tr,Le),or=Symbol(),ar=Symbol();function sr(t){var e=lr,r=fr,n=t[or];if(n)return n;(n={}).ja=t,n.O=function(t){switch(typeof t){case"boolean":return Et||=[0,void 0,!0];case"number":return t>0?void 0:0===t?St||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.W=i,"function"==typeof(i=t[++o])&&(n.ca=!0,er??=i,rr??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let f;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof Qe?f=i:(f=nr,o--),f?.i){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,f,u,t):e(n,s,f,t)}}return t[or]=n}function ur(t,e){return t instanceof Ye?t.l:Array.isArray(t)?Pt(t,e[0],e[1]):void 0}function lr(t,e,r){t[e]=r.h}function fr(t,e,r,n){var i,o,a=r.h;t[e]=(t,e,r)=>a(t,e,r,o||=sr(n).O,i||=cr(n))}function cr(t){var e=t[ar];if(!e){let r=sr(t);e=(t,e)=>hr(t,e,r),t[ar]=e}return e}function hr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[L],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.W)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof Qe?r:[ir,r]:[r,void 0])[0].h;if(r=r[1]){let e=cr(r),i=sr(r).O;r=t.ca?rr(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||x(k,3)}})}function dr(t,e,r){if(Array.isArray(e)){var n=0|e[L];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&$(e,t),r&&2&t&&Object.freeze(e),e}}var pr=(t,e)=>{var r=new Re;hr(t.l,r,sr(e)),je(r,r.h.end()),t=new Uint8Array(r.i);var n=(e=r.j).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.j=[t],t};function yr(t,e){return new Qe(t,e)}function mr(t,e){return new Qe(t,e)}function gr(t,e,r){null!=(e=Tt(e))&&(Pe(e),ke(t,r,e))}function vr(t,e,r){null!=(e=_t(e))&&null!=e&&(Oe(t,r,0),_e(t.h,e))}function br(t,e,r){null!=(e=Ft(e))&&Me(t,r,o(e))}function wr(t,e,r,n,i){null!=(e=ur(e,n))&&(r=Fe(t,r),i(e,t),Ue(t,r))}function Ar(t,e,r){null!=(e=Ot(e))&&Me(t,r,ue(e).buffer)}function Ir(t,e,r){null!=(e=_t(e))&&(e=parseInt(e,10),Oe(t,r,0),_e(t.h,e))}var Er,Sr=yr(function(t,e,r){null!=(e=At(e))&&(Oe(t,r,1),t=t.h,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),at=r.getUint32(0,!0),st=r.getUint32(4,!0),Ce(t,at),Ce(t,st))},Ke),Nr=yr(function(t,e,r){null!=(e=At(e))&&(Oe(t,r,5),t=t.h,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),st=0,Ce(t,at=r.getUint32(0,!0)))},qe),Br=yr(gr,We),_r=yr(gr,We),xr=mr(function(t,e,r){if(null!=(e=dr(Tt,e,!1)))for(let n=0;n<e.length;n++)ke(t,r,e[n])},We),Cr=yr(function(t,e,r){if(null!=(e=jt(e))){if("string"==typeof e)fe(e);if(null!=e)switch(Oe(t,r,0),typeof e){case"number":t=t.h,lt(e),Ne(t,at,st);break;case"bigint":r=Se(e,he,le),Ne(t.h,r.i,r.h);break;default:r=fe(e),Ne(t.h,r.i,r.h)}}},Je),Tr=yr(vr,$e),jr=mr(function(t,e,r){if(null!=(e=dr(_t,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(Oe(n,i,0),_e(n.h,o))}},$e),Or=mr(function(t,e,r){if(null!=(e=dr(_t,e,!0))&&e.length){r=Fe(t,r);for(let r=0;r<e.length;r++)_e(t.h,e[r]);Ue(t,r)}},$e),Fr=yr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(Oe(t,r,0),t.h.h.push(e?1:0))},ze),Ur=yr(br,Ge),kr=mr(function(t,e,r){if(null!=(e=dr(Ft,e,!0)))for(let s=0;s<e.length;s++){var n=t,i=r,a=e[s];null!=a&&Me(n,i,o(a))}},Ge),Mr=function(t,e,r=Le){return new Qe(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)wr(t,e[o],r,n,i);1&(t=0|e[L])||$(e,1|t)}}),Rr=new Qe(wr,Le),Pr=yr(Ar,Xe),Dr=mr(function(t,e,r){if(null!=(e=dr(Ot,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&Me(n,i,ue(o).buffer)}},Xe),Lr=yr(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 bt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(Oe(t,r,0),Be(t.h,e))},He),zr=yr(Ir,Ze),Gr=yr(Ir,Ze),$r=yr(function(t,e,r){if(null!=(e=Tt(e))&&(Pe(e),null!=e))switch(Oe(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,ut(r=2*Math.abs(r)),r=at;let n=st;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),Ne(t,at=r,st=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),at=Number(BigInt.asUintN(32,e)),st=Number(BigInt.asUintN(32,e>>BigInt(32))),Ne(t,at,st);break;default:xe(t.h,e)}},Ve),Hr=[0,Pr,Dr,Fr,Ur],Wr=[0,yr(br,Ge),[0,Gr,[0,yr(gr,We),yr(vr,$e)],Gr,-1,[0,zr],Gr,-1],yr(Ar,Xe)],Jr=[0,1,[0,12,Tr,10,Fr],[0,7,[0,Tr,-1]]],Vr=globalThis.trustedTypes;var qr=class{constructor(t){this.h=t}toString(){return this.h+""}};function Kr(t){var e;return void 0===Er&&(Er=function(){var t=null;if(!Vr)return t;try{let e=t=>t;t=Vr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Er)?e.createScriptURL(t):t,new qr(t)}function Xr(t,...e){if(0===e.length)return Kr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return Kr(r)}function Zr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Qr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Qr(Yr(t.quantizedEmbedding),Yr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Yr(t){return Array.from(t,t=>t>127?t-256:t)}function Qr(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);var r=0,n=0,i=0;for(let o=0;o<t.length;o++)r+=t[o]*e[o],n+=t[o]*t[o],i+=e[o]*e[o];if(n<=0||i<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*i)}function tn(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function en(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,tn(t)})}),tn(t)})}var rn,nn=class{constructor(){this.h=!1,this.i=[]}},on=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function an(t){if(t)return!0;if(void 0===rn)try{await WebAssembly.instantiate(on),rn=!0}catch{rn=!1}return rn}async function sn(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await an(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var un=class{};function ln(t){return ae(new fn,1,t)}un.forVisionTasks=function(t,e=!1){return sn("vision",t??Xr``,e)},un.forLiteRtLmTextTasks=function(t,e=!1){return sn("litertlm_text",t??Xr``,e)},un.forTextTasks=function(t,e=!1){return sn("text",t??Xr``,e)},un.forRetrievalTasks=function(t,e=!1){return sn("retrieval",t??Xr``,e)},un.forGenAiTasks=function(t,e=!1){return sn("genai",t??Xr``,e)},un.forDecisionTasks=function(t,e=!1){return sn("decision",t??Xr``,e)},un.forAudioTasks=function(t,e=!1){return sn("audio",t??Xr``,e)},un.isSimdSupported=function(t=!1){return an(t)};var fn=class extends Ye{constructor(t){super(t)}},cn=class extends Ye{constructor(t){super(t)}},hn=[0,zr,2,Cr,-2,_r,Mr,[0,zr,_r]],dn=class extends Ye{constructor(t){super(t)}},pn=class extends Ye{constructor(t){super(t)}};function yn(t,e){return ae(t,1,e)}function mn(t,e){return ae(t,2,e)}var gn,vn=class extends Ye{constructor(t){super(t)}},bn=[3,4,5,6,7],wn=class extends Ye{constructor(t){super(t)}},An=class extends Ye{constructor(t){super(t)}};An.prototype.i=(gn=[0,[0,zr,Ur,-3,zr],[0,bn,zr,-1,Rr,[0,zr,Ur,Cr],Rr,hn,Rr,[0,1,hn],Rr,[0,zr],Rr,[0,zr,Ur,Cr]]],function(){return pr(this,gn)});var In=class{constructor(){this.h="undefined"!=typeof AbortController}async send(t,e,r){var n=this.h?new AbortController:void 0,i=n&&t.N>0?setTimeout(()=>{n.abort()},t.N):void 0;try{let i=await fetch(t.url,{method:t.fa,headers:{...t.ea},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.N&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},En=class extends Ye{constructor(t){super(t,37)}},Sn=[-4,{},Jr,zr,Wr],Nn=[0,Ur,zr,1,Ur,-1,zr,1,zr,1,_r],Bn=[0,zr,Ur,-2],_n=[0,Ur,zr],xn=[0,Ur,zr],Cn=[0,Fr,-3],Tn=[0,zr,Ur,-1,_r,Tr,-1,Ur,-5,Mr,[0,Ur,-4],-1,Fr,[0,Fr,-3],zr];var jn=class extends Ye{constructor(t){super(t,19)}},On=function(t){return e=>pr(e,t)}([-19,{},[0,zr,1,[0,Ur,-6,_r,Tr,Ur,-1,_r],1,[0,Ur,1,Ur,-5],Ur,-1,[0,zr,Ur,-8],[0,Ur,-3],[0,Ur,zr,Ur,-2],[0,Ur,-1,zr,Ur,-1,zr,Ur,-1,[0,Mr,[0,Ur,-1],Fr,Ur,-5],[0,zr,Fr,Tr,-2]],_r,[0,Ur,-3,_r,Tr,Ur,-1],[0,zr,Ur,-1],[0,Ur,-9],[0,Ur,-6,zr,Ur,1,Ur,Fr,zr,-1,Fr,Ur,-2,zr,Ur,zr,Ur,Tr,-1],1,[0,zr],1,[0,Ur,-4],1,Nn,[0,[1,2,3,4,5,6],Rr,Nn,Rr,_n,Rr,xn,Rr,[0,zr],Rr,Tn,Rr,Bn],_n,xn,Tn,[0,[0,zr,Ur,-1,_r,Tr,-1,Ur,-4,Mr,[0,Ur,-4],-1,1,Cn],[0,zr,Ur,-1,_r,Tr,-1,Ur,-4,Cn]],Bn,[0,Ur,[0,Tr,-3,zr],zr,-2,[0,Tr,-1],Fr],4,[0,Ur,zr,Ur,-1,_r,zr,Ur,-1,zr,Tr,-1]],zr,Mr,[-37,{},Br,Ur,Mr,[0,Ur,-1],Pr,1,Pr,[0,kr,-1,jr,xr,-1],Ur,[0,Tr,Ur,-1],Fr,Tr,_r,Ur,-1,$r,Hr,Br,Pr,zr,jr,_r,-1,[0,zr,-1],Ur,Fr,Ur,Or,Ur,-1,Sr,1,Sr,Sn,Fr,[0,zr,[0,Nr,Tr,-2],[0,Nr]],[0,zr,_r]],Br,Dr,Ur,-1,Br,zr,-1,[0,Fr,-1,zr,Fr],[0,_r,-1,Ur],[0,Br,Fr,_r],_r,1,Lr,1,Sn]),Fn=class{constructor(t){this.i=[],this.m=new In,this.j=t??"",this.h=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.h&&(clearInterval(this.h),this.h=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.i.length)t?.();else{var r=this.i;this.i=[],r=function(t){var e=new jn;{Gt(e=ae(e,2,1786));let l=e.l,f=0|l[L];if(null==t)Jt(l,f,3);else{var r=t===O?7:0|t[L],n=r,i=Kt(r),o=i||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var u=t[e];i||(u=W(u),a&&=!u,s&&=u)}i||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===n||(t=Array.prototype.slice.call(t),n=0,r=ee(r,f)),r!==n&&$(t,r),f=Jt(l,f,3,t),2&r||!(4096&r||16&r)||$t(l,f)}}return e}(r),r=On(r),this.m.send({url:"https://odml.pa.googleapis.com/v1/log",fa:"POST",N:1e4,body:r,ka:2,ea:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.j},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.i=[],void 0!==this.h&&(clearInterval(this.h),this.h=void 0),e?.("net-send-failed",t)})}}};class Un{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function kn(t,e){var r=new An;if(r=Qt(r,1,t.R),r=Qt(r,2,e),e=new En,null!=(r=r.i()))if("string"==typeof r)r=r?new E(r,I):A||=new E(null,I);else if(r.constructor!==E){if(!(y&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new E(new Uint8Array(r),I):A||=new E(null,I)}e=Wt(e,6,r),(t=t.H).error||t.i.push(e)}function Mn(t){var e=new pn;e=ie(e=ae(e,1,10),3,performance.now()-t.P),kn(t,e=te(mn(yn(new vn,t.v),0),3,e)),t.m=performance.now()}function Rn(t,e){++t.h.F,t.i.set(e,performance.now())}function Pn(t,e){var r={C:e.C-t.j.C,F:e.F-t.j.F,D:e.D-t.j.D,A:e.A-t.j.A,G:e.G-t.j.G,B:e.B,I:e.I},n=mn(yn(new vn,t.v),1);kn(t,n=te(n,4,r=Ln(r))),t.j=e}function Dn(t,e){var r=t.i.get(e);if(void 0!==r&&(t.i.delete(e),e=performance.now()-r,++t.h.D,t.h.G+=e,t.h.B=Math.max(t.h.B,e),t.u=Math.max(t.u,e),performance.now()>t.m+3e4)){for(let[n,i]of t.i.entries())e=n,i<r&&(t.h.A++,t.i.delete(e));r={...t.h,I:performance.now()-t.m},t.h.B=0,t.m=performance.now(),Pn(t,r)}}function Ln(t){var e=new cn;if(e=ie(e=ne(e=ae(e,1,10),7,t.A),5,t.B),e=ie(e,6,t.I),t.D>0&&ie(e,4,t.G/t.D),0!==t.C){var r=ln(3);re(e,r=ne(r,2,t.C))}return 0!==t.F&&re(e,t=ne(r=ln(4),2,t.F)),e}function zn(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.P};Pn(t,e);var r=new dn;r=Qt(r,2,e=Ln(e)),kn(t,r=te(e=mn(yn(new vn,t.v),2),5,r))}var Gn=class{constructor(t,e){this.P=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Un,this.j=new Un,this.H=new Fn(e),this.v=function(t){switch(t){case"AudioClassifier":return 4;case"AudioEmbedder":return 5;case"TextClassifier":return 6;case"TextEmbedder":return 7;case"GestureRecognizer":return 8;case"HandDetector":return 9;case"HandLandmarker":return 10;case"ImageClassifier":return 11;case"ImageEmbedder":return 12;case"ImageSegmenter":return 13;case"ObjectDetector":return 14;case"FaceDetector":return 15;case"FaceLandmarker":return 16;case"InteractiveSegmenter":case"InteractiveSegmenterLegacy":return 18;case"HolisticLandmarker":return 20;case"LlmInference":return 21;case"LanguageDetector":return 22;case"PoseLandmarker":return 23;case"UniversalEmbedder":return 28;case"SemanticRetriever":return 29;case"DecisionMaker":return 30;case"TextSummarizer":return 26;case"TextProofreader":return 27;case"AudioTranscriber":return 31;case"TextToSpeech":return 32;default:return 0}}(t),t=new wn,"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=oe(t=ae(t,1,e),2,""),t=oe(t,3,""),t=oe(t,4,"1.2.0"),t=oe(t,5,""),this.R=ae(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}())}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function $n(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new Gn(t,e)}async function Hn(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())}}}var Wn=async(t,e,r,n)=>{if(e&&await Hn(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await Hn(r),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((e=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new t(n,null)},Jn={CHARACTER:0,WORD:1};function Vn(t,e){if(t<=0)throw Error("Chunk size must be positive.");if(e<0||e>=t)throw Error("Chunk overlap must be non-negative and less than chunk size.")}function qn(t,e,r,n="CHARACTER"){Vn(e,r),t.j=e,t.i=r,t.mode=n}var Kn=class{constructor(t){this.j=512,this.i=100,this.mode="CHARACTER",this.h=t}chunk(t){if(!t||0===t.trim().length)return[];if(!this.h||"function"!=typeof this.h.defaultTextChunker_nativeChunkText)throw Error("DefaultTextChunker Wasm module is not initialized.");return(t=this.h.defaultTextChunker_nativeChunkText(t,this.j,this.i,Jn[this.mode]??0))?Array.from(t):[]}};function Xn(t){return{...t,content:t.content?t.content.map(t=>"imageBytes"in t?{...t,imageBytes:new Uint8Array(t.imageBytes)}:"audioData"in t?{...t,audioData:new Float32Array(t.audioData)}:{...t}):[],embeddings:t.embeddings?new Float32Array(t.embeddings):new Float32Array(0),metadata:t.metadata?{...t.metadata}:{},...t.childIds?{childIds:[...t.childIds]}:{}}}Kn.prototype.chunk=Kn.prototype.chunk,Kn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return Vn(e,r),qn(t=new Kn(t),e,r,n),t},Kn.create=async function(t,e=512,r=100,n="CHARACTER"){Vn(e,r);var i=await Wn(Kn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return qn(i,e,r,n),i};var Zn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Xn(e))}delete(t){var e=new Set(t);for(let r of t)if(t=this.h.get(r),t?.childIds)for(let r of t.childIds)e.add(r);for(let t of e)this.h.delete(t)}deleteByMetadata(t){var e=Object.keys(t);if(0!==e.length){var r=[];for(let n of this.h.values())n.parentId||n.metadata&&e.every(e=>n.metadata[e]===t[e])&&r.push(n.id);r.length>0&&this.delete(r)}}search(t,e,r){if(e<=0)throw Error(`'topK' must be greater than 0, got ${e}.`);var n=r?Object.keys(r):[];t=Array.from(t);var i=[];for(let e of this.h.values()){if(r&&n.length>0){if(!e.metadata)continue;if(!n.every(t=>e.metadata?.[t]===r[t]))continue}if(e.embeddings&&0!==e.embeddings.length)try{let r=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""});i.push({da:e,score:r})}catch{}}return i.sort((t,e)=>e.score-t.score),i.slice(0,e).map(t=>Xn(t.da))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Xn(t));return e}getAllRecordIds(){var t=[];for(let[e,r]of this.h.entries()){let n=e;r.parentId||t.push(n)}return t}deleteAll(){this.h.clear()}close(){this.h.clear()}};Zn.prototype.close=Zn.prototype.close,Zn.prototype.deleteAll=Zn.prototype.deleteAll,Zn.prototype.getAllRecordIds=Zn.prototype.getAllRecordIds,Zn.prototype.get=Zn.prototype.get,Zn.prototype.search=Zn.prototype.search,Zn.prototype.deleteByMetadata=Zn.prototype.deleteByMetadata,Zn.prototype.delete=Zn.prototype.delete,Zn.prototype.upsert=Zn.prototype.upsert;var Yn=class{constructor(){this.h=[]}S(t){return this.h.push(t),this}M(){return[...this.h]}ia(t){return this.j=t,this}o(){return this.j}ha(t){return this.i=t,this}L(){return this.i}};function Qn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Yn.prototype.textChunker=Yn.prototype.L,Yn.prototype.setTextChunker=Yn.prototype.ha,Yn.prototype.vectorStore=Yn.prototype.o,Yn.prototype.setVectorStore=Yn.prototype.ia,Yn.prototype.providers=Yn.prototype.M,Yn.prototype.addProvider=Yn.prototype.S;var ti=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=$n("SemanticRetriever"),Mn(this.h)}async embedContent(t){for(let e of this.m.M()){let r=await e.embedContent(t);if(null!=r)return r instanceof Float32Array?r:new Float32Array(r)}throw Error("No embedding provider found that can embed this content.")}async Z(t,e,r){return Qn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Qn(this),await this.o.delete([t]);var n=[],i=0;if(1===e.length&&"text"in e[0]&&"string"==typeof e[0].text){var o=await this.L.chunk(e[0].text);if(o.length>1){let r=[];for(let e of o)o=`${t}_chunk_${i++}`,r.push(o),n.push({id:o,J:[{text:e}],parentId:t});n.push({id:t,J:e,childIds:r})}else n.push({id:t,J:e})}else n.push({id:t,J:e});t=[];for(let e of n)n=void 0!==e.childIds&&e.childIds.length>0?new Float32Array(0):await this.embedContent(e.J),t.push({id:e.id,content:[...e.J],embeddings:n,metadata:r||{},parentId:e.parentId,childIds:e.childIds});await this.o.upsert(t)}async aa(t,e,r){return Qn(this),this.K(t,[{imageBytes:e}],r)}async Y(t,e,r){return Qn(this),this.K(t,[{audioData:e}],r)}async ga(t,e={}){Qn(this);var{limit:r=5,metadataFilter:n}=e;if(r<=0)throw Error(`'limit' must be greater than 0, got ${r}.`);e=this.j++;var i=this.h;++i.h.C,i.i.set(e,performance.now()),t=await this.embedContent("string"==typeof t?[{text:t}]:t),i=await this.o.search(t,3*r,n);var o=new Set;for(var a of i)a.parentId&&o.add(a.parentId);if(a=new Map,o.size>0)for(var s of o=await this.o.get(Array.from(o)))a.set(s.id,s);for(var u of(s=[],o=new Set,i))u.parentId?o.has(u.parentId)||(o.add(u.parentId),(i=a.get(u.parentId))&&s.push({id:i.id,content:i.content,embeddings:u.embeddings,metadata:i.metadata,parentId:i.parentId,childIds:i.childIds})):o.has(u.id)||(o.add(u.id),s.push(u));u=[],t=Array.from(t);for(let e of s){if(s=0,e.embeddings&&e.embeddings.length>0)try{s=Zr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""})}catch{s=0}if(u.push({id:e.id,content:e.content?[...e.content]:[],metadata:e.metadata?{...e.metadata}:{},score:s}),u.length>=r)break}return Dn(this.h,e),u}async delete(t){Qn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Qn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Qn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,zn(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ei(t,e){var r=e.baseOptions.device;r||=await ri();var n=await Wn(oi,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return r&&(n.h.preinitializedWebGPUDevice=r),await async function(t,e,r){t.i=$n("UniversalEmbedder");var n=!1!==e.l2Normalize,i=e.baseOptions.modelAssetPath?e.baseOptions.modelAssetPath.toString():"";if((r=r||e.baseOptions.device||t.h.preinitializedWebGPUDevice)||(r=await ri()),t.h.preinitializedWebGPUDevice=r,e.baseOptions.modelAssetBuffer){i=e.baseOptions.modelAssetBuffer instanceof Uint8Array?e.baseOptions.modelAssetBuffer:await async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(e.baseOptions.modelAssetBuffer);var o=`/${r=`universal_embedder_model_${++ai}.litertlm`}`;try{t.h.FS_unlink?.(o)}catch{}t.h.FS_createDataFile("/",r,i,!0,!1,!1),t.v=o,i=t.v}if(!i)throw Error("No model asset path or buffer provided.");r=e.maxInputLength??0,o=e.visionTokensPerImage??0,e=function(t){if(void 0===t)return 0;switch(t){case"FLOAT32":return 1;case"FLOAT16":return 2;case"INT16":return 3;case"INT8":return 4;default:throw Error(`Unsupported activation data type: ${t}`)}}(e.activationDataType);try{t.j=await t.h.createUniversalEmbedder(i,n,r,o,e),Mn(t.i)}catch(e){throw ni(t),e}}(n,e,r),n}async function ri(){if("undefined"==typeof navigator||!navigator.gpu)throw Error("WebGPU is not supported on this platform.");var t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw Error("No appropriate WebGPU adapter found.");var e=[];if(t.features.has("subgroups")&&e.push("subgroups"),t.features.has("shader-f16")&&e.push("shader-f16"),!(e=await t.requestDevice({requiredFeatures:e})).adapterInfo&&t.info)try{Object.defineProperty(e,"adapterInfo",{value:t.info,writable:!0,configurable:!0})}catch{}return e}function ni(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ii(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}ti.prototype.close=ti.prototype.close,ti.prototype.deleteAll=ti.prototype.deleteAll,ti.prototype.getAllRecordIds=ti.prototype.getAllRecordIds,ti.prototype.delete=ti.prototype.delete,ti.prototype.retrieve=ti.prototype.ga,ti.prototype.insertAudio=ti.prototype.Y,ti.prototype.insertImage=ti.prototype.aa,ti.prototype.insertContent=ti.prototype.K,ti.prototype.insertDocument=ti.prototype.Z,ti.createFromComponents=async function(t){if(!t||0===t.M().length)throw Error("At least one EmbeddingProvider must be registered in SemanticRetrieverComponents.");var e=t.o();if(!e)throw Error("VectorStore must be provided in SemanticRetrieverComponents.");var r=t.L();if(!r)throw Error("TextChunker must be provided in SemanticRetrieverComponents.");return new ti(t,e,r)};var oi=class{constructor(t){this.H=!1,this.j=0,this.u=new nn,this.m=0,this.h=t}async V(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async T(t){return en(this.u,async()=>{ii(this);var e=this.m++;Rn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Dn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ii(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return en(this.u,async()=>{ii(this);var e=this.h.universalEmbedder_createContentBuilder();try{for(let r of t)if("text"in r&&"string"==typeof r.text)this.h.universalEmbedder_builderAddText(e,r.text);else if("imageBytes"in r&&(r.imageBytes instanceof Uint8Array||"string"==typeof r.imageBytes))this.h.universalEmbedder_builderAddImage(e,r.imageBytes);else{if(!("audioData"in r)||!(r.audioData instanceof Float32Array||Array.isArray(r.audioData)))throw Error(`Unsupported or invalid ContentPart: ${JSON.stringify(r)}`);this.h.universalEmbedder_builderAddAudio(e,r.audioData)}let r=this.m++;Rn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Dn(this.i,r),{embeddings:[{floatEmbedding:n?Array.from(n):[],headIndex:0,headName:"default"}]}}finally{this.h.universalEmbedder_freeContentBuilder(e)}})}X(){return{embedContent:async t=>(await this.embedContent(t))?.embeddings?.[0]?.floatEmbedding??null}}close(){this.H||(this.H=!0,zn(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ni(this))}};oi.prototype.close=oi.prototype.close,oi.prototype.getProvider=oi.prototype.X,oi.cosineSimilarity=function(t,e){return Zr(t,e)},oi.prototype.embedContent=oi.prototype.embedContent,oi.prototype.embedAudio=oi.prototype.T,oi.prototype.embedImage=oi.prototype.U,oi.prototype.embedText=oi.prototype.V,oi.createFromModelPath=function(t,e){return ei(t,{baseOptions:{modelAssetPath:e.toString()}})},oi.createFromModelBuffer=function(t,e){return ei(t,{baseOptions:{modelAssetBuffer:e}})},oi.createWebGpuDevice=ri,oi.createFromOptions=ei;var ai=0;return t.DefaultTextChunker=Kn,t.FilesetResolver=un,t.MemoryVectorStore=Zn,t.SemanticRetriever=ti,t.SemanticRetrieverComponents=Yn,t.UniversalEmbedder=oi,t}({});
2
2
  //# sourceMappingURL=retrieval_bundle_iife.js.map
@@ -1,2 +1,2 @@
1
- var t="undefined"!=typeof self?self:{};function e(e,r){t:{for(var n=["CLOSURE_FLAGS"],i=t,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(e=n&&n[e])?e:r}var r,n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0,n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.subarray(0,r)}return t}var o=e(610401301,!1),a=e(748402147,!0);function s(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var u,l=t.navigator;u=l&&l.userAgentData||null;var f={},c=null;function h(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){let e=t.charAt(n++),r=c[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function d(){if(!c){c={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));f[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===c[e]&&(c[e]=t)}}}}var p="undefined"!=typeof Uint8Array,y=!(!(!!o&&(!!u&&u.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,m=/[-_.]/g,g={"-":"+",_:"/",".":"="};function v(t){return g[t]||""}function b(t){if(!y)return h(t);t=m.test(t)?t.replace(m,v):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var w,A={},I=class{constructor(t,e){if(E(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function E(t){if(t!==A)throw Error("illegal external caller")}function S(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var N=void 0;function B(t){return S(t=Error(t),"warning"),t}function _(e,r){if(null!=e){var n=N??={},i=n[e]||0;i>=r||(n[e]=i+1,S(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function x(){return"function"==typeof BigInt}var C="function"==typeof Symbol&&"symbol"==typeof Symbol();function T(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 j,O=T("jas",void 0,!0),F=T(void 0,"1oa"),U=T(void 0,"0ubsb"),k=T(void 0,"0actk"),M=T("m_m","na",!0),R={ca:{value:0,configurable:!0,writable:!0,enumerable:!1}},P=Object.defineProperties,D=C?O:"ca",L=[];function z(t,e){C||D in t||P(t,R),t[D]|=e}function G(t,e){C||D in t||P(t,R),t[D]=e}function $(t,e){return 2&e&&(t|=2),1|t}G(L,7),j=Object.freeze(L);var H={};function W(t,e){return void 0===e?t.h!==J&&!!(2&t.l[D]):!!(2&e)&&t.h!==J}var J={};function V(t){return t.ma=!0,t}var q=V(t=>"number"==typeof t),K=V(t=>"string"==typeof t),X=V(t=>"boolean"==typeof t),Z="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Y(t){var e=t;if(K(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(q(e)&&!Number.isSafeInteger(e))throw Error(String(e));return Z?BigInt(t):t=X(t)?t?"1":"0":K(t)?t.trim()||"0":String(t)}var Q=V(t=>Z?t>=et&&t<=nt:"-"===t[0]?it(t,tt):it(t,rt)),tt=Number.MIN_SAFE_INTEGER.toString(),et=Z?BigInt(Number.MIN_SAFE_INTEGER):void 0,rt=Number.MAX_SAFE_INTEGER.toString(),nt=Z?BigInt(Number.MAX_SAFE_INTEGER):void 0;function it(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var ot,at=0,st=0;function ut(t){var e=t>>>0;at=e,st=(t-e)/4294967296>>>0}function lt(t){if(t<0){ut(-t);let[e,r]=yt(at,st);at=e>>>0,st=r>>>0}else ut(t)}function ft(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ct(t,e)}function ct(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else x()?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+ht(r)+ht(t));return r}function ht(t){return t=String(t),"0000000".slice(t.length)+t}function dt(){var t=at,e=st;if(2147483648&e)if(x())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=yt(t,e);t="-"+ct(r,n)}else t=ct(t,e);return t}function pt(t){if(t.length<16)lt(Number(t));else if(x())t=BigInt(t),at=Number(t&BigInt(4294967295))>>>0,st=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);st=at=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));st*=1e6,(at=1e6*at+e)>=4294967296&&(st+=Math.trunc(at/4294967296),st>>>=0,at>>>=0)}if(e){let[t,e]=yt(at,st);at=t,st=e}}}function yt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var mt="function"==typeof BigInt?BigInt.asIntN:void 0,gt="function"==typeof BigInt?BigInt.asUintN:void 0,vt=Number.isSafeInteger,bt=Number.isFinite,wt=Math.trunc;function At(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var It,Et,St,Nt=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Bt(t){switch(typeof t){case"bigint":return!0;case"number":return bt(t);case"string":return Nt.test(t);default:return!1}}function _t(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return bt(t)?0|t:void 0}function xt(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(pt(t),dt())}function Ct(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(pt(t),ct(at,st))}function Tt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),vt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=xt(t)),t;if("number"===e)return function(t){if(t=wt(t),!vt(t)){lt(t);var e=at,r=st;(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 jt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(gt(64,t));if(Bt(t)){if("string"===e)return e=wt(Number(t)),vt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=Ct(t)),t;if("number"===e)return function(t){return(t=wt(t))>=0&&vt(t)||(lt(t),t=ft(at,st)),t}(t)}}function Ot(t){if(null==t||"string"==typeof t||t instanceof I)return t}function Ft(t){return null==t||"string"==typeof t?t:void 0}function Ut(t){return t}function kt(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),f=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(It??Ut)(s-f,f,t,c,void 0)+f)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-f;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+f)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function Mt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Q(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:kt(t,e,Mt)}if(null!=t&&t[M]===H)return Rt(t);if(t instanceof I){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(y){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=f[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.h=e}return t}return}return t}function Rt(t){return kt(t=t.l,0|t[D],Mt)}function Pt(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[D],a&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(a)throw Error("carr");_(k,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&G(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=64;var o=(r=t).length;if(o){var s=o-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<s&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&s)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return G(t,64|i|n),t}function Dt(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=Lt(t,r,!1,e&&!(16&r)):(z(t,34),4&r&&Object.freeze(t))),t}if(null!=t&&t[M]===H){let n=0|(r=t.l)[D];return W(t,n)||(2&n?e=!0:32&n&&!(4096&n)?(G(r,2|n),t.h=J,e=!0):e=!1,e?(t=new t.constructor(r)).j=J:t=Lt(r,n)),t}return t instanceof I?t:void 0}function Lt(t,e,r,n){return n??=!!(34&e),t=kt(t,e,Dt,n),n=32,r&&(n|=2),G(t,e=16769217&e|n),t}function zt(t){if(t.h!==J)return!1;var e=t.l;return z(e=Lt(e,0|e[D]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function Gt(t){if(!zt(t)&&W(t,0|t.l[D]))throw Error()}function $t(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&G(t,4096|e)}function Ht(t,e,r){if(-1===e)return null;var n=e+(r?0:-1),i=t.length-1;if(!(i<1+(r?0:-1))){if(n>=i)if(null!=(t=t[i])&&"object"==typeof t&&t.constructor===Object)e=t[e];else{if(n!==i)return;e=t}else e=t[n];return e}}function Wt(t,e,r){Gt(t);var n=t.l;return Jt(n,0|n[D],e,r),t}function Jt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[D])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function Vt(t,e,r){return t=Ht(t,e,r),Array.isArray(t)?t:j}function qt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Kt(t){if(C)return t[F]??(t[F]=new Map);if(F in t)return t[F];var e=new Map;return Object.defineProperty(t,F,{value:e}),e}function Xt(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=Ht(e,o)&&(0!==i&&(r=Jt(e,r,i)),i=o)}return t.set(n,i),i}function Zt(t){return null==t&&(t=void 0),t}function Yt(t,e,r){return Wt(t,e,r=Zt(r)),r&&!W(r)&&$t(t.l),t}function Qt(t,e,r){var n=vn;t:{var i=r=Zt(r);Gt(t);let s=t.l;var o=0|s[D];if(null==i){var a=Kt(s);if(Xt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Kt(a=s),r=Xt(t,a,o,n);r!==e&&(r&&(o=Jt(a,o,r)),t.set(n,e))}Jt(s,o,e,i)}return r&&!W(r)&&$t(t.l),t}function te(t,e){return-273&(2&e?2|t:-3&t)}function ee(t,e){var r=ln;Gt(t);var n=t.l,i=n,o=0|n[D],a=(t?W(t,o):2&o)?1:2;2===a&&t&&zt(t)&&(o=0|(i=t.l)[D]);var s=Vt(i,8),u=s===j?7:0|s[D],l=$(u,o);if(t=!(4&l)){var f=o;let t=!!(2&l);t&&(f|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){var c=s[i],h=r,d=f;if(null==c||c[M]!==H)if(Array.isArray(c)){let t,e=0|c[D];t=e|32&d,t|=2&d,t!==e&&G(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=W(c),e&&=!h,n&&=h),s[a++]=c)}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&(G(s,l),2&l&&Object.freeze(s)),l=u=l,(f=qt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=te(u,o),o=Jt(i,o,8,s),f=!1),f||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&G(s,u),Object.freeze(s)):u!==l&&G(s,u)),2&u||!(4096&u||16&u)||$t(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===j?7:0|a[D],(e=W(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&G(a,r),e||$t(n)}function re(t,e,r){return Wt(t,e,null==r?r:function(t){if(!Bt(t))throw B("int64");switch(typeof t){case"string":var e=wt(Number(t));return vt(e)?t=Y(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Y(mt(64,BigInt(t))):Y(xt(t))),t;case"bigint":return Y(mt(64,t));default:return vt(t)||(t=wt(t),vt(t)?t=String(t):(lt(t),t=dt())),Y(t)}}(r))}function ne(t,e,r){return Wt(t,e,null==r?r:function(t){if(!Bt(t))throw B("uint64");switch(typeof t){case"string":var e=wt(Number(t));return vt(e)&&e>=0?t=Y(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Y(gt(64,BigInt(t))):Y(Ct(t))),t;case"bigint":return Y(gt(64,t));default:return t>=0&&vt(t)||((t=wt(t))>=0&&vt(t)?t=String(t):(lt(t),t=ct(at,st))),Y(t)}}(r))}function ie(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Wt(t,e,r)}function oe(t,e,r){if(null!=r){if(!bt(r))throw B("enum");r|=0}return Wt(t,e,r)}var ae=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function se(t){if("string"==typeof t)return new ae(b(t),!0);if(Array.isArray(t))return new ae(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ae(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ae(t,!1);if(t.constructor===I){E(A);var e=t.h;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?b(e):null)?e:t.h=e)||new Uint8Array(0),new ae(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ae(t,!1);throw Error()}function ue(t){return new ce(4294967295&t,Math.floor(t/4294967296))}function le(t){return t?/^\d+$/.test(t)?(pt(t),new ce(at,st)):null:fe||=new ce(0,0)}var fe,ce=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function he(t){return new Ie(4294967295&t,Math.floor(t/4294967296))}function de(t){return t?/^-?\d+$/.test(t)?(pt(t),new Ie(at,st)):null:pe||=new Ie(0,0)}var pe,ye,me,ge,ve,be,we,Ae,Ie=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Ee(t,e,r){return"undefined"!=typeof BigInt64Array?(we||(we=new BigInt64Array(1),Ae=new Uint32Array(we.buffer),we[0]=BigInt(1),be=1===Ae[0]),we[0]=t,new e(Ae[t=be?0:1],Ae[1-t])):(ve||(ye=BigInt(Number.MIN_SAFE_INTEGER),me=BigInt(Number.MAX_SAFE_INTEGER),ge=BigInt(4294967295),ve=BigInt(32)),t>=ye&&t<=me?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ge),Number(t>>ve))))}function Se(t,e,r){for(;r>0||e>127;)t.h.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function Ne(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function Be(t,e){if(e>=0)Ne(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function _e(t,e){pt(e),function(t){var e=st>>31;t(at<<1^e,(st<<1|at>>>31)^e)}((e,r)=>{Se(t,e>>>0,r>>>0)})}function xe(t,e){t.h.push(e>>>0&255),t.h.push(e>>>8&255),t.h.push(e>>>16&255),t.h.push(e>>>24&255)}var Ce=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function Te(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function je(t,e,r){Ne(t.h,8*e+r)}function Oe(t,e){return je(t,e,2),e=t.h.end(),Te(t,e),e.push(t.i),e}function Fe(t,e){var r=e.pop();for(r=t.i+t.h.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.i++;e.push(r),t.i++}function Ue(t,e,r){if(null!=r)switch(je(t,e,0),typeof r){case"number":t=t.h,lt(r),Se(t,at,st);break;case"bigint":r=Ee(r,Ie,he),Se(t.h,r.i,r.h);break;default:r=de(r),Se(t.h,r.i,r.h)}}function ke(t,e,r){je(t,e,2),Ne(t.h,r.length),Te(t,t.h.end()),Te(t,r)}var Me=class{constructor(){this.j=[],this.i=0,this.h=new Ce}};function Re(t){if("string"==typeof t)de(t)}function Pe(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var De=Pe(),Le=Pe(),ze=Pe(),Ge=Pe(),$e=Pe(),He=Pe(),We=Pe(),Je=Pe(),Ve=Pe(),qe=Pe(),Ke=Pe(),Xe=Pe(),Ze=class{constructor(t,e){this.l=Pt(t,e,void 0,2048)}toJSON(){return Rt(this)}};Ze.prototype[M]=H,Ze.prototype.toString=function(){return this.l.toString()};var Ye=class{constructor(t,e){this.M=t,t=De,this.h=!!t&&e===t||!1}};function Qe(t,e,r,n,i){null!=(e=sr(e,n))&&(r=Oe(t,r),i(e,t),Fe(t,r))}var tr,er,rr=new Ye(Qe,De),nr=new Ye(Qe,De),ir=Symbol(),or=Symbol();function ar(t){var e=ur,r=lr,n=t[ir];if(n)return n;(n={}).ka=t,n.P=function(t){switch(typeof t){case"boolean":return Et||=[0,void 0,!0];case"number":return t>0?void 0:0===t?St||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.X=i,"function"==typeof(i=t[++o])&&(n.da=!0,tr??=i,er??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let f;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof Ye?f=i:(f=rr,o--),f?.h){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,f,u,t):e(n,s,f,t)}}return t[ir]=n}function sr(t,e){return t instanceof Ze?t.l:Array.isArray(t)?Pt(t,e[0],e[1]):void 0}function ur(t,e,r){t[e]=r.M}function lr(t,e,r,n){var i,o,a=r.M;t[e]=(t,e,r)=>a(t,e,r,o||=ar(n).P,i||=fr(n))}function fr(t){var e=t[or];if(!e){let r=ar(t);e=(t,e)=>cr(t,e,r),t[or]=e}return e}function cr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[D],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.X)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof Ye?r:[nr,r]:[r,void 0])[0].M;if(r=r[1]){let e=fr(r),i=ar(r).P;r=t.da?er(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||_(U,3)}})}function hr(t,e,r){if(Array.isArray(e)){var n=0|e[D];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&G(e,t),r&&2&t&&Object.freeze(e),e}}var dr=(t,e)=>{var r=new Me;cr(t.l,r,ar(e)),Te(r,r.h.end()),t=new Uint8Array(r.i);var n=(e=r.j).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.j=[t],t};function pr(t,e){return new Ye(t,e)}function yr(t,e){return new Ye(t,e)}function mr(t,e,r){null!=(e=Tt(e))&&(Re(e),Ue(t,r,e))}function gr(t,e,r){null!=(e=_t(e))&&null!=e&&(je(t,r,0),Be(t.h,e))}function vr(t,e,r){null!=(e=Ft(e))&&ke(t,r,i(e))}function br(t,e,r,n,i){null!=(e=sr(e,n))&&(r=Oe(t,r),i(e,t),Fe(t,r))}function wr(t,e,r){null!=(e=Ot(e))&&ke(t,r,se(e).buffer)}function Ar(t,e,r){null!=(e=_t(e))&&(e=parseInt(e,10),je(t,r,0),Be(t.h,e))}var Ir,Er=pr(function(t,e,r){null!=(e=At(e))&&(je(t,r,1),t=t.h,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),at=r.getUint32(0,!0),st=r.getUint32(4,!0),xe(t,at),xe(t,st))},qe),Sr=pr(function(t,e,r){null!=(e=At(e))&&(je(t,r,5),t=t.h,(r=ot||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),st=0,xe(t,at=r.getUint32(0,!0)))},Ve),Nr=pr(mr,He),Br=pr(mr,He),_r=yr(function(t,e,r){if(null!=(e=hr(Tt,e,!1)))for(let n=0;n<e.length;n++)Ue(t,r,e[n])},He),xr=pr(function(t,e,r){if(null!=(e=jt(e))){if("string"==typeof e)le(e);if(null!=e)switch(je(t,r,0),typeof e){case"number":t=t.h,lt(e),Se(t,at,st);break;case"bigint":r=Ee(e,ce,ue),Se(t.h,r.i,r.h);break;default:r=le(e),Se(t.h,r.i,r.h)}}},We),Cr=pr(gr,Ge),Tr=yr(function(t,e,r){if(null!=(e=hr(_t,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(je(n,i,0),Be(n.h,o))}},Ge),jr=yr(function(t,e,r){if(null!=(e=hr(_t,e,!0))&&e.length){r=Oe(t,r);for(let r=0;r<e.length;r++)Be(t.h,e[r]);Fe(t,r)}},Ge),Or=pr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(je(t,r,0),t.h.h.push(e?1:0))},Le),Fr=pr(vr,ze),Ur=yr(function(t,e,r){if(null!=(e=hr(Ft,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&ke(n,o,i(a))}},ze),kr=function(t,e,r=De){return new Ye(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)br(t,e[o],r,n,i);1&(t=0|e[D])||G(e,1|t)}}),Mr=new Ye(br,De),Rr=pr(wr,Ke),Pr=yr(function(t,e,r){if(null!=(e=hr(Ot,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&ke(n,i,se(o).buffer)}},Ke),Dr=pr(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 bt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(je(t,r,0),Ne(t.h,e))},$e),Lr=pr(Ar,Xe),zr=pr(Ar,Xe),Gr=pr(function(t,e,r){if(null!=(e=Tt(e))&&(Re(e),null!=e))switch(je(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,ut(r=2*Math.abs(r)),r=at;let n=st;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),Se(t,at=r,st=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),at=Number(BigInt.asUintN(32,e)),st=Number(BigInt.asUintN(32,e>>BigInt(32))),Se(t,at,st);break;default:_e(t.h,e)}},Je),$r=[0,Rr,Pr,Or,Fr],Hr=[0,pr(vr,ze),[0,zr,[0,pr(mr,He),pr(gr,Ge)],zr,-1,[0,Lr],zr,-1],pr(wr,Ke)],Wr=[0,1,[0,12,Cr,10,Or],[0,7,[0,Cr,-1]]],Jr=globalThis.trustedTypes;var Vr=class{constructor(t){this.h=t}toString(){return this.h+""}};function qr(t){var e;return void 0===Ir&&(Ir=function(){var t=null;if(!Jr)return t;try{let e=t=>t;t=Jr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Ir)?e.createScriptURL(t):t,new Vr(t)}function Kr(t,...e){if(0===e.length)return qr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return qr(r)}function Xr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Yr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Yr(Zr(t.quantizedEmbedding),Zr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Zr(t){return Array.from(t,t=>t>127?t-256:t)}function Yr(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);var r=0,n=0,i=0;for(let o=0;o<t.length;o++)r+=t[o]*e[o],n+=t[o]*t[o],i+=e[o]*e[o];if(n<=0||i<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*i)}function Qr(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function tn(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,Qr(t)})}),Qr(t)})}var en,rn=class{constructor(){this.h=!1,this.i=[]}},nn=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function on(t){if(t)return!0;if(void 0===en)try{await WebAssembly.instantiate(nn),en=!0}catch{en=!1}return en}async function an(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await on(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var sn=class{};function un(t){return oe(new ln,1,t)}sn.forVisionTasks=function(t,e=!1){return an("vision",t??Kr``,e)},sn.forLiteRtLmTextTasks=function(t,e=!1){return an("litertlm_text",t??Kr``,e)},sn.forTextTasks=function(t,e=!1){return an("text",t??Kr``,e)},sn.forRetrievalTasks=function(t,e=!1){return an("retrieval",t??Kr``,e)},sn.forGenAiTasks=function(t,e=!1){return an("genai",t??Kr``,e)},sn.forDecisionTasks=function(t,e=!1){return an("decision",t??Kr``,e)},sn.forAudioTasks=function(t,e=!1){return an("audio",t??Kr``,e)},sn.isSimdSupported=function(t=!1){return on(t)};var ln=class extends Ze{constructor(t){super(t)}},fn=class extends Ze{constructor(t){super(t)}},cn=[0,Lr,2,xr,-2,Br,kr,[0,Lr,Br]],hn=class extends Ze{constructor(t){super(t)}},dn=class extends Ze{constructor(t){super(t)}};function pn(t,e){return oe(t,1,e)}function yn(t,e){return oe(t,2,e)}var mn,gn=class extends Ze{constructor(t){super(t)}},vn=[3,4,5,6,7],bn=class extends Ze{constructor(t){super(t)}},wn=class extends Ze{constructor(t){super(t)}};wn.prototype.i=(mn=[0,[0,Lr,Fr,-3,Lr],[0,vn,Lr,-1,Mr,[0,Lr,Fr,xr],Mr,cn,Mr,[0,1,cn],Mr,[0,Lr],Mr,[0,Lr,Fr,xr]]],function(){return dr(this,mn)});var An=class{constructor(){this.h="undefined"!=typeof AbortController}async send(t,e,r){var n=this.h?new AbortController:void 0,i=n&&t.O>0?setTimeout(()=>{n.abort()},t.O):void 0;try{let i=await fetch(t.url,{method:t.ga,headers:{...t.fa},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.O&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},In=class extends Ze{constructor(t){super(t,37)}},En=[-4,{},Wr,Lr,Hr],Sn=[0,Fr,Lr,1,Fr,-1,Lr,1,Lr,1,Br],Nn=[0,Lr,Fr,-2],Bn=[0,Fr,Lr],_n=[0,Fr,Lr],xn=[0,Or,-3],Cn=[0,Lr,Fr,-1,Br,Cr,-1,Fr,-5,kr,[0,Fr,-4],-1,Or,[0,Or,-3],Lr];var Tn=class extends Ze{constructor(t){super(t,19)}},jn=function(t){return e=>dr(e,t)}([-19,{},[0,Lr,1,[0,Fr,-6,Br,Cr,Fr,-1,Br],1,[0,Fr,1,Fr,-5],Fr,-1,[0,Lr,Fr,-8],[0,Fr,-3],[0,Fr,Lr,Fr,-2],[0,Fr,-1,Lr,Fr,-1,Lr,Fr,-1,[0,kr,[0,Fr,-1],Or,Fr,-5],[0,Lr,Or,Cr,-2]],Br,[0,Fr,-3,Br,Cr,Fr,-1],[0,Lr,Fr,-1],[0,Fr,-9],[0,Fr,-6,Lr,Fr,1,Fr,Or,Lr,-1,Or,Fr,-2,Lr,Fr,Lr,Fr,Cr,-1],1,[0,Lr],1,[0,Fr,-4],1,Sn,[0,[1,2,3,4,5,6],Mr,Sn,Mr,Bn,Mr,_n,Mr,[0,Lr],Mr,Cn,Mr,Nn],Bn,_n,Cn,[0,[0,Lr,Fr,-1,Br,Cr,-1,Fr,-4,kr,[0,Fr,-4],-1,1,xn],[0,Lr,Fr,-1,Br,Cr,-1,Fr,-4,xn]],Nn,[0,Fr,[0,Cr,-3,Lr],Lr,-2,[0,Cr,-1],Or],4,[0,Fr,Lr,Fr,-1,Br,Lr,Fr,-1,Lr,Cr,-1]],Lr,kr,[-37,{},Nr,Fr,kr,[0,Fr,-1],Rr,1,Rr,[0,Ur,-1,Tr,_r,-1],Fr,[0,Cr,Fr,-1],Or,Cr,Br,Fr,-1,Gr,$r,Nr,Rr,Lr,Tr,Br,-1,[0,Lr,-1],Fr,Or,Fr,jr,Fr,-1,Er,1,Er,En,Or,[0,Lr,[0,Sr,Cr,-2],[0,Sr]],[0,Lr,Br]],Nr,Pr,Fr,-1,Nr,Lr,-1,[0,Or,-1,Lr,Or],[0,Br,-1,Fr],[0,Nr,Or,Br],Br,1,Dr,1,En]),On=class{constructor(t){this.i=[],this.m=new An,this.j=t??"",this.h=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.h&&(clearInterval(this.h),this.h=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.i.length)t?.();else{var r=this.i;this.i=[],r=function(t){var e=new Tn;Gt(e=oe(e,2,1786));var r=e.l,n=0|r[D];if(null==t)Jt(r,n,3);else{var i=t===j?7:0|t[D],o=i,a=qt(i),s=a||Object.isFrozen(t),u=!0,l=!0;for(let e=0;e<t.length;e++){var f=t[e];a||(f=W(f),u&&=!f,l&&=f)}a||(i=u?13:5,i=l?-4097&i:4096|i),s&&i===o||(t=Array.prototype.slice.call(t),o=0,i=te(i,n)),i!==o&&G(t,i),n=Jt(r,n,3,t),2&i||!(4096&i||16&i)||$t(r,n)}return e}(r),r=jn(r),this.m.send({url:"https://odml.pa.googleapis.com/v1/log",ga:"POST",O:1e4,body:r,la:2,fa:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.j},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.i=[],void 0!==this.h&&(clearInterval(this.h),this.h=void 0),e?.("net-send-failed",t)})}}};class Fn{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function Un(t,e){var r=new wn;if(r=Yt(r,1,t.S),r=Yt(r,2,e),e=new In,null!=(r=r.i()))if("string"==typeof r)r=r?new I(r,A):w||=new I(null,A);else if(!(r instanceof I)){if(!(p&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new I(new Uint8Array(r),A):w||=new I(null,A)}e=Wt(e,6,r),(t=t.H).error||t.i.push(e)}function kn(t){var e=new dn;e=ne(e=oe(e,1,10),3,performance.now()-t.R),Un(t,e=Qt(yn(pn(new gn,t.v),0),3,e)),t.m=performance.now()}function Mn(t,e){++t.h.F,t.i.set(e,performance.now())}function Rn(t,e){var r={C:e.C-t.j.C,F:e.F-t.j.F,D:e.D-t.j.D,A:e.A-t.j.A,G:e.G-t.j.G,B:e.B,I:e.I},n=yn(pn(new gn,t.v),1);Un(t,n=Qt(n,4,r=Dn(r))),t.j=e}function Pn(t,e){var r=t.i.get(e);if(void 0!==r&&(t.i.delete(e),e=performance.now()-r,++t.h.D,t.h.G+=e,t.h.B=Math.max(t.h.B,e),t.u=Math.max(t.u,e),performance.now()>t.m+3e4)){for(let[n,i]of t.i.entries())e=n,i<r&&(t.h.A++,t.i.delete(e));r={...t.h,I:performance.now()-t.m},t.h.B=0,t.m=performance.now(),Rn(t,r)}}function Dn(t){var e=new fn;if(e=ne(e=re(e=oe(e,1,10),7,t.A),5,t.B),e=ne(e,6,t.I),t.D>0&&ne(e,4,t.G/t.D),0!==t.C){var r=un(3);ee(e,r=re(r,2,t.C))}return 0!==t.F&&ee(e,t=re(r=un(4),2,t.F)),e}function Ln(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.R};Rn(t,e);var r=new hn;r=Yt(r,2,e=Dn(e)),Un(t,r=Qt(e=yn(pn(new gn,t.v),2),5,r))}var zn=class{constructor(t,e){this.R=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Fn,this.j=new Fn,this.H=new On(e),this.v=function(t){switch(t){case"AudioClassifier":return 4;case"AudioEmbedder":return 5;case"TextClassifier":return 6;case"TextEmbedder":return 7;case"GestureRecognizer":return 8;case"HandDetector":return 9;case"HandLandmarker":return 10;case"ImageClassifier":return 11;case"ImageEmbedder":return 12;case"ImageSegmenter":return 13;case"ObjectDetector":return 14;case"FaceDetector":return 15;case"FaceLandmarker":return 16;case"InteractiveSegmenter":case"InteractiveSegmenterLegacy":return 18;case"HolisticLandmarker":return 20;case"LlmInference":return 21;case"LanguageDetector":return 22;case"PoseLandmarker":return 23;case"UniversalEmbedder":return 28;case"SemanticRetriever":return 29;case"DecisionMaker":return 30;case"TextSummarizer":return 26;case"TextProofreader":return 27;case"AudioTranscriber":return 31;case"TextToSpeech":return 32;default:return 0}}(t),t=new bn,"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=ie(t=oe(t,1,e),2,""),t=ie(t,3,""),t=ie(t,4,"1.2.0"),t=ie(t,5,""),this.S=oe(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}())}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function Gn(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new zn(t,e)}async function $n(t){if("function"!=typeof importScripts){let e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((t,r)=>{e.addEventListener("load",()=>{t()},!1),e.addEventListener("error",t=>{r(t)},!1),document.body.appendChild(e)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}var Hn=async(t,e,r,n)=>{if(e&&await $n(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await $n(r),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((e=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new t(n,null)},Wn={CHARACTER:0,WORD:1};function Jn(t,e){if(t<=0)throw Error("Chunk size must be positive.");if(e<0||e>=t)throw Error("Chunk overlap must be non-negative and less than chunk size.")}function Vn(t,e,r,n="CHARACTER"){Jn(e,r),t.j=e,t.i=r,t.mode=n}var qn=class{constructor(t){this.j=512,this.i=100,this.mode="CHARACTER",this.h=t}chunk(t){if(!t||0===t.trim().length)return[];if(!this.h||"function"!=typeof this.h.defaultTextChunker_nativeChunkText)throw Error("DefaultTextChunker Wasm module is not initialized.");return(t=this.h.defaultTextChunker_nativeChunkText(t,this.j,this.i,Wn[this.mode]??0))?Array.from(t):[]}};function Kn(t){return{...t,content:t.content?t.content.map(t=>"imageBytes"in t?{...t,imageBytes:new Uint8Array(t.imageBytes)}:"audioData"in t?{...t,audioData:new Float32Array(t.audioData)}:{...t}):[],embeddings:t.embeddings?new Float32Array(t.embeddings):new Float32Array(0),metadata:t.metadata?{...t.metadata}:{},...t.childIds?{childIds:[...t.childIds]}:{}}}qn.prototype.chunk=qn.prototype.chunk,qn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return Jn(e,r),Vn(t=new qn(t),e,r,n),t},qn.create=async function(t,e=512,r=100,n="CHARACTER"){Jn(e,r);var i=await Hn(qn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return Vn(i,e,r,n),i};var Xn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Kn(e))}delete(t){var e=new Set(t);for(let r of t)if(t=this.h.get(r),t?.childIds)for(let r of t.childIds)e.add(r);for(let t of e)this.h.delete(t)}deleteByMetadata(t){var e=Object.keys(t);if(0!==e.length){var r=[];for(let n of this.h.values())n.parentId||n.metadata&&e.every(e=>n.metadata[e]===t[e])&&r.push(n.id);r.length>0&&this.delete(r)}}search(t,e,r){if(e<=0)throw Error(`'topK' must be greater than 0, got ${e}.`);var n=r?Object.keys(r):[];t=Array.from(t);var i=[];for(let e of this.h.values()){if(r&&n.length>0){if(!e.metadata)continue;if(!n.every(t=>e.metadata?.[t]===r[t]))continue}if(e.embeddings&&0!==e.embeddings.length)try{let r=Xr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""});i.push({ea:e,score:r})}catch{}}return i.sort((t,e)=>e.score-t.score),i.slice(0,e).map(t=>Kn(t.ea))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Kn(t));return e}getAllRecordIds(){var t=[];for(let[e,r]of this.h.entries()){let n=e;r.parentId||t.push(n)}return t}deleteAll(){this.h.clear()}close(){this.h.clear()}};Xn.prototype.close=Xn.prototype.close,Xn.prototype.deleteAll=Xn.prototype.deleteAll,Xn.prototype.getAllRecordIds=Xn.prototype.getAllRecordIds,Xn.prototype.get=Xn.prototype.get,Xn.prototype.search=Xn.prototype.search,Xn.prototype.deleteByMetadata=Xn.prototype.deleteByMetadata,Xn.prototype.delete=Xn.prototype.delete,Xn.prototype.upsert=Xn.prototype.upsert;var Zn=class{constructor(){this.h=[]}T(t){return this.h.push(t),this}N(){return[...this.h]}ja(t){return this.j=t,this}o(){return this.j}ia(t){return this.i=t,this}L(){return this.i}};function Yn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Zn.prototype.textChunker=Zn.prototype.L,Zn.prototype.setTextChunker=Zn.prototype.ia,Zn.prototype.vectorStore=Zn.prototype.o,Zn.prototype.setVectorStore=Zn.prototype.ja,Zn.prototype.providers=Zn.prototype.N,Zn.prototype.addProvider=Zn.prototype.T;var Qn=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=Gn("SemanticRetriever"),kn(this.h)}async embedContent(t){for(let e of this.m.N()){let r=await e.embedContent(t);if(null!=r)return r instanceof Float32Array?r:new Float32Array(r)}throw Error("No embedding provider found that can embed this content.")}async aa(t,e,r){return Yn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Yn(this),await this.o.delete([t]);var n=[],i=0;if(1===e.length&&"text"in e[0]&&"string"==typeof e[0].text){var o=await this.L.chunk(e[0].text);if(o.length>1){let r=[];for(let e of o)o=`${t}_chunk_${i++}`,r.push(o),n.push({id:o,J:[{text:e}],parentId:t});n.push({id:t,J:e,childIds:r})}else n.push({id:t,J:e})}else n.push({id:t,J:e});t=[];for(let e of n)n=void 0!==e.childIds&&e.childIds.length>0?new Float32Array(0):await this.embedContent(e.J),t.push({id:e.id,content:[...e.J],embeddings:n,metadata:r||{},parentId:e.parentId,childIds:e.childIds});await this.o.upsert(t)}async ba(t,e,r){return Yn(this),this.K(t,[{imageBytes:e}],r)}async Z(t,e,r){return Yn(this),this.K(t,[{audioData:e}],r)}async ha(t,e={}){Yn(this);var{limit:r=5,metadataFilter:n}=e;if(r<=0)throw Error(`'limit' must be greater than 0, got ${r}.`);e=this.j++;var i=this.h;++i.h.C,i.i.set(e,performance.now()),t=await this.embedContent("string"==typeof t?[{text:t}]:t),i=await this.o.search(t,3*r,n);var o=new Set;for(var a of i)a.parentId&&o.add(a.parentId);if(a=new Map,o.size>0)for(var s of o=await this.o.get(Array.from(o)))a.set(s.id,s);for(var u of(s=[],o=new Set,i))u.parentId?o.has(u.parentId)||(o.add(u.parentId),(i=a.get(u.parentId))&&s.push({id:i.id,content:i.content,embeddings:u.embeddings,metadata:i.metadata,parentId:i.parentId,childIds:i.childIds})):o.has(u.id)||(o.add(u.id),s.push(u));u=[],t=Array.from(t);for(let e of s){if(s=0,e.embeddings&&e.embeddings.length>0)try{s=Xr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""})}catch{s=0}if(u.push({id:e.id,content:e.content?[...e.content]:[],metadata:e.metadata?{...e.metadata}:{},score:s}),u.length>=r)break}return Pn(this.h,e),u}async delete(t){Yn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Yn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Yn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,Ln(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ti(t,e){var r=e.baseOptions.device;r||=await ei();var n=await Hn(ii,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return r&&(n.h.preinitializedWebGPUDevice=r),await async function(t,e,r){t.i=Gn("UniversalEmbedder");var n=!1!==e.l2Normalize,i=e.baseOptions.modelAssetPath?e.baseOptions.modelAssetPath.toString():"";if((r=r||e.baseOptions.device||t.h.preinitializedWebGPUDevice)||(r=await ei()),t.h.preinitializedWebGPUDevice=r,e.baseOptions.modelAssetBuffer){i=e.baseOptions.modelAssetBuffer instanceof Uint8Array?e.baseOptions.modelAssetBuffer:await async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(e.baseOptions.modelAssetBuffer);var o=`/${r=`universal_embedder_model_${++oi}.litertlm`}`;try{t.h.FS_unlink?.(o)}catch{}t.h.FS_createDataFile("/",r,i,!0,!1,!1),t.v=o,i=t.v}if(!i)throw Error("No model asset path or buffer provided.");r=e.maxInputLength??0,o=e.visionTokensPerImage??0,e=function(t){if(void 0===t)return 0;switch(t){case"FLOAT32":return 1;case"FLOAT16":return 2;case"INT16":return 3;case"INT8":return 4;default:throw Error(`Unsupported activation data type: ${t}`)}}(e.activationDataType);try{t.j=await t.h.createUniversalEmbedder(i,n,r,o,e),kn(t.i)}catch(e){throw ri(t),e}}(n,e,r),n}async function ei(){if("undefined"==typeof navigator||!navigator.gpu)throw Error("WebGPU is not supported on this platform.");var t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw Error("No appropriate WebGPU adapter found.");var e=[];if(t.features.has("subgroups")&&e.push("subgroups"),t.features.has("shader-f16")&&e.push("shader-f16"),!(e=await t.requestDevice({requiredFeatures:e})).adapterInfo&&t.info)try{Object.defineProperty(e,"adapterInfo",{value:t.info,writable:!0,configurable:!0})}catch{}return e}function ri(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ni(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}Qn.prototype.close=Qn.prototype.close,Qn.prototype.deleteAll=Qn.prototype.deleteAll,Qn.prototype.getAllRecordIds=Qn.prototype.getAllRecordIds,Qn.prototype.delete=Qn.prototype.delete,Qn.prototype.retrieve=Qn.prototype.ha,Qn.prototype.insertAudio=Qn.prototype.Z,Qn.prototype.insertImage=Qn.prototype.ba,Qn.prototype.insertContent=Qn.prototype.K,Qn.prototype.insertDocument=Qn.prototype.aa,Qn.createFromComponents=async function(t){if(!t||0===t.N().length)throw Error("At least one EmbeddingProvider must be registered in SemanticRetrieverComponents.");var e=t.o();if(!e)throw Error("VectorStore must be provided in SemanticRetrieverComponents.");var r=t.L();if(!r)throw Error("TextChunker must be provided in SemanticRetrieverComponents.");return new Qn(t,e,r)};var ii=class{constructor(t){this.H=!1,this.j=0,this.u=new rn,this.m=0,this.h=t}async W(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async V(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ni(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return tn(this.u,async()=>{ni(this);var e=this.h.universalEmbedder_createContentBuilder();try{for(let r of t)if("text"in r&&"string"==typeof r.text)this.h.universalEmbedder_builderAddText(e,r.text);else if("imageBytes"in r&&(r.imageBytes instanceof Uint8Array||"string"==typeof r.imageBytes))this.h.universalEmbedder_builderAddImage(e,r.imageBytes);else{if(!("audioData"in r)||!(r.audioData instanceof Float32Array||Array.isArray(r.audioData)))throw Error(`Unsupported or invalid ContentPart: ${JSON.stringify(r)}`);this.h.universalEmbedder_builderAddAudio(e,r.audioData)}let r=this.m++;Mn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Pn(this.i,r),{embeddings:[{floatEmbedding:n?Array.from(n):[],headIndex:0,headName:"default"}]}}finally{this.h.universalEmbedder_freeContentBuilder(e)}})}Y(){return{embedContent:async t=>(await this.embedContent(t))?.embeddings?.[0]?.floatEmbedding??null}}close(){this.H||(this.H=!0,Ln(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ri(this))}};ii.prototype.close=ii.prototype.close,ii.prototype.getProvider=ii.prototype.Y,ii.cosineSimilarity=function(t,e){return Xr(t,e)},ii.prototype.embedContent=ii.prototype.embedContent,ii.prototype.embedAudio=ii.prototype.U,ii.prototype.embedImage=ii.prototype.V,ii.prototype.embedText=ii.prototype.W,ii.createFromModelPath=function(t,e){return ti(t,{baseOptions:{modelAssetPath:e.toString()}})},ii.createFromModelBuffer=function(t,e){return ti(t,{baseOptions:{modelAssetBuffer:e}})},ii.createWebGpuDevice=ei,ii.createFromOptions=ti;var oi=0;export{qn as DefaultTextChunker,sn as FilesetResolver,Xn as MemoryVectorStore,Qn as SemanticRetriever,Zn as SemanticRetrieverComponents,ii as UniversalEmbedder};
1
+ var t="undefined"!=typeof self?self:{};function e(e,r){t:{for(var n=["CLOSURE_FLAGS"],i=t,o=0;o<n.length;o++)if(null==(i=i[n[o]])){n=null;break t}n=i}return null!=(e=n&&n[e])?e:r}var r,n="undefined"!=typeof TextEncoder;function i(t){if(n)t=(r||=new TextEncoder).encode(t);else{let r=0,n=new Uint8Array(3*t.length);for(let i=0;i<t.length;i++){var e=t.charCodeAt(i);if(e<128)n[r++]=e;else{if(e<2048)n[r++]=e>>6|192;else{if(e>=55296&&e<=57343){if(e<=56319&&i<t.length){let o=t.charCodeAt(++i);if(o>=56320&&o<=57343){e=1024*(e-55296)+o-56320+65536,n[r++]=e>>18|240,n[r++]=e>>12&63|128,n[r++]=e>>6&63|128,n[r++]=63&e|128;continue}i--}e=65533}n[r++]=e>>12|224,n[r++]=e>>6&63|128}n[r++]=63&e|128}}t=r===n.length?n:n.subarray(0,r)}return t}var o=e(610401301,!1),a=e(748402147,!0);function s(){var e=t.navigator;return e&&(e=e.userAgent)?e:""}var u,l=t.navigator;u=l&&l.userAgentData||null;var f={},c=null;function h(t){var e=t.length,r=3*e/4;r%3?r=Math.floor(r):-1!="=.".indexOf(t[e-1])&&(r=-1!="=.".indexOf(t[e-2])?r-2:r-1);var n=new Uint8Array(r),i=0;return function(t,e){function r(e){for(;n<t.length;){let e=t.charAt(n++),r=c[e];if(null!=r)return r;if(!/^[\s\xa0]*$/.test(e))throw Error("Unknown base64 encoding at char: "+e)}return e}d();for(var n=0;;){let t=r(-1),n=r(0),i=r(64),o=r(64);if(64===o&&-1===t)break;e(t<<2|n>>4),64!=i&&(e(n<<4&240|i>>2),64!=o&&e(i<<6&192|o))}}(t,function(t){n[i++]=t}),i!==r?n.subarray(0,i):n}function d(){if(!c){c={};var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""),e=["+/=","+/","-_=","-_.","-_"];for(let r=0;r<5;r++){let n=t.concat(e[r].split(""));f[r]=n;for(let t=0;t<n.length;t++){let e=n[t];void 0===c[e]&&(c[e]=t)}}}}var p="undefined"!=typeof Uint8Array,y=!(!(!!o&&(!!u&&u.brands.length>0))&&(-1!=s().indexOf("Trident")||-1!=s().indexOf("MSIE")))&&"function"==typeof btoa,m=/[-_.]/g,g={"-":"+",_:"/",".":"="};function v(t){return g[t]||""}function b(t){if(!y)return h(t);t=m.test(t)?t.replace(m,v):t,t=atob(t);var e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var w,A={},I=class{constructor(t,e){if(E(e),this.h=t,null!=t&&0===t.length)throw Error("ByteString should be constructed with non-empty values")}};function E(t){if(t!==A)throw Error("illegal external caller")}function S(t,e){t.__closure__error__context__984382||(t.__closure__error__context__984382={}),t.__closure__error__context__984382.severity=e}var N=void 0;function B(t){return S(t=Error(t),"warning"),t}function _(e,r){if(null!=e){var n=N??={},i=n[e]||0;i>=r||(n[e]=i+1,S(e=Error(),"incident"),function(e){t.setTimeout(()=>{throw e},0)}(e))}}function x(){return"function"==typeof BigInt}var C="function"==typeof Symbol&&"symbol"==typeof Symbol();function T(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 j,O=T("jas",void 0,!0),F=T(void 0,"1oa"),U=T(void 0,"0ubsb"),k=T(void 0,"0actk"),M=T("m_m","ma",!0),R={ba:{value:0,configurable:!0,writable:!0,enumerable:!1}},P=Object.defineProperties,D=C?O:"ba",L=[];function z(t,e){C||D in t||P(t,R),t[D]|=e}function G(t,e){C||D in t||P(t,R),t[D]=e}G(L,7),j=Object.freeze(L);var $={};function H(t,e){return void 0===e?t.h!==W&&!!(2&t.l[D]):!!(2&e)&&t.h!==W}var W={};function J(t){return t.la=!0,t}var V=J(t=>"number"==typeof t),q=J(t=>"string"==typeof t),K=J(t=>"boolean"==typeof t),X="function"==typeof t.BigInt&&"bigint"==typeof t.BigInt(0);function Z(t){var e=t;if(q(e)){if(!/^\s*(?:-?[1-9]\d*|0)?\s*$/.test(e))throw Error(String(e))}else if(V(e)&&!Number.isSafeInteger(e))throw Error(String(e));return X?BigInt(t):t=K(t)?t?"1":"0":q(t)?t.trim()||"0":String(t)}var Y=J(t=>X?t>=tt&&t<=rt:"-"===t[0]?nt(t,Q):nt(t,et)),Q=Number.MIN_SAFE_INTEGER.toString(),tt=X?BigInt(Number.MIN_SAFE_INTEGER):void 0,et=Number.MAX_SAFE_INTEGER.toString(),rt=X?BigInt(Number.MAX_SAFE_INTEGER):void 0;function nt(t,e){if(t.length>e.length)return!1;if(t.length<e.length||t===e)return!0;for(let r=0;r<t.length;r++){let n=t[r],i=e[r];if(n>i)return!1;if(n<i)return!0}}var it,ot=0,at=0;function st(t){var e=t>>>0;ot=e,at=(t-e)/4294967296>>>0}function ut(t){if(t<0){st(-t);let[e,r]=pt(ot,at);ot=e>>>0,at=r>>>0}else st(t)}function lt(t,e){var r=4294967296*e+(t>>>0);return Number.isSafeInteger(r)?r:ft(t,e)}function ft(t,e){if(t>>>=0,(e>>>=0)<=2097151)var r=""+(4294967296*e+t);else x()?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+ct(r)+ct(t));return r}function ct(t){return t=String(t),"0000000".slice(t.length)+t}function ht(){var t=ot,e=at;if(2147483648&e)if(x())t=""+(BigInt(0|e)<<BigInt(32)|BigInt(t>>>0));else{let[r,n]=pt(t,e);t="-"+ft(r,n)}else t=ft(t,e);return t}function dt(t){if(t.length<16)ut(Number(t));else if(x())t=BigInt(t),ot=Number(t&BigInt(4294967295))>>>0,at=Number(t>>BigInt(32)&BigInt(4294967295));else{let e=+("-"===t[0]);at=ot=0;let r=t.length;for(let n=e,i=(r-e)%6+e;i<=r;n=i,i+=6){let e=Number(t.slice(n,i));at*=1e6,(ot=1e6*ot+e)>=4294967296&&(at+=Math.trunc(ot/4294967296),at>>>=0,ot>>>=0)}if(e){let[t,e]=pt(ot,at);ot=t,at=e}}}function pt(t,e){return e=~e,t?t=1+~t:e+=1,[t,e]}var yt="function"==typeof BigInt?BigInt.asIntN:void 0,mt="function"==typeof BigInt?BigInt.asUintN:void 0,gt=Number.isSafeInteger,vt=Number.isFinite,bt=Math.trunc;function wt(t){return null==t||"number"==typeof t?t:"NaN"===t||"Infinity"===t||"-Infinity"===t?Number(t):void 0}var At,It,Et,St=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;function Nt(t){switch(typeof t){case"bigint":return!0;case"number":return vt(t);case"string":return St.test(t);default:return!1}}function Bt(t){if(null==t)return t;if("string"==typeof t&&t)t=+t;else if("number"!=typeof t)return;return vt(t)?0|t:void 0}function _t(t){var e=t.length;return("-"===t[0]?e<20||20===e&&t<="-9223372036854775808":e<19||19===e&&t<="9223372036854775807")?t:(dt(t),ht())}function xt(t){if("-"===t[0])var e=!1;else e=(e=t.length)<20||20===e&&t<="18446744073709551615";return e?t:(dt(t),ft(ot,at))}function Ct(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(yt(64,t));if(Nt(t)){if("string"===e)return e=bt(Number(t)),gt(e)?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=_t(t)),t;if("number"===e)return function(t){if(t=bt(t),!gt(t)){ut(t);var e=ot,r=at;(t=2147483648&r)&&(r=~r>>>0,0==(e=1+~e>>>0)&&(r=r+1>>>0)),t="number"==typeof(e=lt(e,r))?t?-e:e:t?"-"+e:e}return t}(t)}}function Tt(t){if(null==t)return t;var e=typeof t;if("bigint"===e)return String(mt(64,t));if(Nt(t)){if("string"===e)return e=bt(Number(t)),gt(e)&&e>=0?t=String(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=xt(t)),t;if("number"===e)return function(t){return(t=bt(t))>=0&&gt(t)||(ut(t),t=lt(ot,at)),t}(t)}}function jt(t){if(null==t||"string"==typeof t||t instanceof I)return t}function Ot(t){return null==t||"string"==typeof t?t:void 0}function Ft(t){return t}function Ut(t,e,r,n){var i=void 0!==n;n=!!n;var o=[],a=t.length,s=4294967295,u=!1,l=!!(64&e),f=l?128&e?0:-1:void 0;if(!(1&e)){var c=a&&t[a-1];null!=c&&"object"==typeof c&&c.constructor===Object?s=--a:c=void 0,!l||128&e||i||(u=!0,s=(At??Ft)(s-f,f,t,c,void 0)+f)}for(e=void 0,i=0;i<a;i++){let a=t[i];if(null!=a&&null!=(a=r(a,n)))if(l&&i>=s){let t=i-f;(e??={})[t]=a}else o[i]=a}if(c)for(let i in c){if(null==(t=c[i])||null==(t=r(t,n)))continue;let u;a=+i,l&&!Number.isNaN(a)&&(u=a+f)<s?o[u]=t:(e??={})[i]=t}return e&&(u?o.push(e):o[s]=e),o}function kt(t){switch(typeof t){case"number":return Number.isFinite(t)?t:""+t;case"bigint":return Y(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:Ut(t,e,kt)}if(null!=t&&t[M]===$)return Mt(t);if(t instanceof I){if(null==(e=t.h))t="";else if("string"==typeof e)t=e;else{if(y){for(var r="",n=0,i=e.length-10240;n<i;)r+=String.fromCharCode.apply(null,e.subarray(n,n+=10240));r+=String.fromCharCode.apply(null,n?e.subarray(n):e),e=btoa(r)}else{void 0===r&&(r=0),d(),r=f[r],n=Array(Math.floor(e.length/3)),i=r[64]||"";let t=0,l=0;for(;t<e.length-2;t+=3){var o=e[t],a=e[t+1],s=e[t+2],u=r[o>>2];o=r[(3&o)<<4|a>>4],a=r[(15&a)<<2|s>>6],s=r[63&s],n[l++]=u+o+a+s}switch(u=0,s=i,e.length-t){case 2:s=r[(15&(u=e[t+1]))<<2]||i;case 1:e=e[t],n[l]=r[e>>2]+r[(3&e)<<4|u>>4]+s+i}e=n.join("")}t=t.h=e}return t}return}return t}function Mt(t){return Ut(t=t.l,0|t[D],kt)}function Rt(t,e,r,n=0){if(null==t){var i=32;r?(t=[r],i|=128):t=[],e&&(i=-16760833&i|(1023&e)<<14)}else{if(!Array.isArray(t))throw Error("narr");if(i=0|t[D],a&&1&i)throw Error("rfarr");if(2048&i&&!(2&i)&&function(){if(a)throw Error("carr");_(k,5)}(),256&i)throw Error("farr");if(64&i)return(i|n)!==i&&G(t,i|n),t;if(r&&(i|=128,r!==t[0]))throw Error("mid");t:{i|=64;var o=(r=t).length;if(o){var s=o-1;let t=r[s];if(null!=t&&"object"==typeof t&&t.constructor===Object){if((s-=e=128&i?0:-1)>=1024)throw Error("pvtlmt");for(var u in t)(o=+u)<s&&(r[o+e]=t[u],delete t[u]);i=-16760833&i|(1023&s)<<14;break t}}if(e){if((u=Math.max(e,o-(128&i?0:-1)))>1024)throw Error("spvt");i=-16760833&i|(1023&u)<<14}}}return G(t,64|i|n),t}function Pt(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=Dt(t,r,!1,e&&!(16&r)):(z(t,34),4&r&&Object.freeze(t))),t}if(null!=t&&t[M]===$){let n=0|(r=t.l)[D];return H(t,n)||(2&n?e=!0:32&n&&!(4096&n)?(G(r,2|n),t.h=W,e=!0):e=!1,e?(t=new t.constructor(r)).j=W:t=Dt(r,n)),t}return t instanceof I?t:void 0}function Dt(t,e,r,n){return n??=!!(34&e),t=Ut(t,e,Pt,n),n=32,r&&(n|=2),G(t,e=16769217&e|n),t}function Lt(t){if(t.h!==W)return!1;var e=t.l;return z(e=Dt(e,0|e[D]),2048),t.l=e,t.h=void 0,t.j=void 0,!0}function zt(t){if(!Lt(t)&&H(t,0|t.l[D]))throw Error()}function Gt(t,e){void 0===e&&(e=0|t[D]),32&e&&!(4096&e)&&G(t,4096|e)}function $t(t,e,r){if(-1===e)return null;var n=e+(r?0:-1),i=t.length-1;if(!(i<1+(r?0:-1))){if(n>=i)if(null!=(t=t[i])&&"object"==typeof t&&t.constructor===Object)e=t[e];else{if(n!==i)return;e=t}else e=t[n];return e}}function Ht(t,e,r){zt(t);var n=t.l;return Wt(n,0|n[D],e,r),t}function Wt(t,e,r,n,i){var o=r+(i?0:-1),a=t.length-1;if(a>=1+(i?0:-1)&&o>=a){let i=t[a];if(null!=i&&"object"==typeof i&&i.constructor===Object)return i[r]=n,e}return o<=a?(t[o]=n,e):(void 0!==n&&(r>=(a=(e??=0|t[D])>>14&1023||536870912)?null!=n&&(t[a+(i?0:-1)]={[r]:n}):t[o]=n),e)}function Jt(t,e,r){return t=$t(t,e,r),Array.isArray(t)?t:j}function Vt(t,e){return 2&e&&(t|=2),1|t}function qt(t){return!!(2&t)&&!!(4&t)||!!(256&t)}function Kt(t){if(C)return t[F]??(t[F]=new Map);if(F in t)return t[F];var e=new Map;return Object.defineProperty(t,F,{value:e}),e}function Xt(t,e,r,n){var i=t.get(n);if(null!=i)return i;i=0;for(let t=0;t<n.length;t++){let o=n[t];null!=$t(e,o)&&(0!==i&&(r=Wt(e,r,i)),i=o)}return t.set(n,i),i}function Zt(t){return null==t&&(t=void 0),t}function Yt(t,e,r){return Ht(t,e,r=Zt(r)),r&&!H(r)&&Gt(t.l),t}function Qt(t,e,r){var n=vn;t:{var i=r=Zt(r);zt(t);let s=t.l;var o=0|s[D];if(null==i){var a=Kt(s);if(Xt(a,s,o,n)!==e)break t;a.set(n,0)}else{let t=Kt(a=s),r=Xt(t,a,o,n);r!==e&&(r&&(o=Wt(a,o,r)),t.set(n,e))}Wt(s,o,e,i)}return r&&!H(r)&&Gt(t.l),t}function te(t,e){return-273&(2&e?2|t:-3&t)}function ee(t,e){var r=ln;zt(t);var n=t.l,i=n,o=0|n[D],a=H(t,o)?1:2;2===a&&Lt(t)&&(o=0|(i=t.l)[D]);var s=Jt(i,8),u=s===j?7:0|s[D],l=Vt(u,o);if(t=!(4&l)){var f=o;let t=!!(2&l);t&&(f|=2);let e=!t,n=!0,i=0,a=0;for(;i<s.length;i++){var c=s[i],h=r,d=f;if(null==c||c[M]!==$)if(Array.isArray(c)){let t,e=0|c[D];t=e|32&d,t|=2&d,t!==e&&G(c,t),c=new h(c)}else c=void 0;c instanceof r&&(t||(h=H(c),e&&=!h,n&&=h),s[a++]=c)}a<i&&(s.length=a),l|=4,l=n?-4097&l:4096|l,l=e?8|l:-9&l}l!==u&&(G(s,l),2&l&&Object.freeze(s)),l=u=l,(f=qt(u))&&2===a&&(s=Array.prototype.slice.call(s),l=0,u=te(u,o),o=Wt(i,o,8,s),f=!1),f||(1===a||4===a&&(2&u||!(16&u)&&32&o)?((u|=!s.length||t&&!(4096&u)||32&o&&!(4096&u||16&u)?2:256)!==l&&G(s,u),Object.freeze(s)):u!==l&&G(s,u)),2&u||!(4096&u||16&u)||Gt(i,o),a=s,e=null!=e?e:new r,a.push(e),t=r=a===j?7:0|a[D],(e=H(e))?(r&=-9,1===a.length&&(r&=-4097)):r|=4096,r!==t&&G(a,r),e||Gt(n)}function re(t,e,r){return Ht(t,e,null==r?r:function(t){if(!Nt(t))throw B("int64");switch(typeof t){case"string":var e=bt(Number(t));return gt(e)?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Z(yt(64,BigInt(t))):Z(_t(t))),t;case"bigint":return Z(yt(64,t));default:return gt(t)||(t=bt(t),gt(t)?t=String(t):(ut(t),t=ht())),Z(t)}}(r))}function ne(t,e,r){return Ht(t,e,null==r?r:function(t){if(!Nt(t))throw B("uint64");switch(typeof t){case"string":var e=bt(Number(t));return gt(e)&&e>=0?t=Z(e):(-1!==(e=t.indexOf("."))&&(t=t.substring(0,e)),t=x()?Z(mt(64,BigInt(t))):Z(xt(t))),t;case"bigint":return Z(mt(64,t));default:return t>=0&&gt(t)||((t=bt(t))>=0&&gt(t)?t=String(t):(ut(t),t=ft(ot,at))),Z(t)}}(r))}function ie(t,e,r){if(null!=r&&"string"!=typeof r)throw Error();return Ht(t,e,r)}function oe(t,e,r){if(null!=r){if(!vt(r))throw B("enum");r|=0}return Ht(t,e,r)}var ae=class{constructor(t,e,r){if(this.buffer=t,r&&!e)throw Error()}};function se(t){if("string"==typeof t)return new ae(b(t),!0);if(Array.isArray(t))return new ae(new Uint8Array(t),!0);if(t.constructor===Uint8Array)return new ae(t,!1);if(t.constructor===ArrayBuffer)return t=new Uint8Array(t),new ae(t,!1);if(t.constructor===I){E(A);var e=t.h;return e=(null==(e=null==e||p&&null!=e&&e instanceof Uint8Array?e:"string"==typeof e?b(e):null)?e:t.h=e)||new Uint8Array(0),new ae(e,!0,t)}if(t instanceof Uint8Array)return t=t.constructor===Uint8Array?t:new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new ae(t,!1);throw Error()}function ue(t){return new ce(4294967295&t,Math.floor(t/4294967296))}function le(t){return t?/^\d+$/.test(t)?(dt(t),new ce(ot,at)):null:fe||=new ce(0,0)}var fe,ce=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function he(t){return new Ie(4294967295&t,Math.floor(t/4294967296))}function de(t){return t?/^-?\d+$/.test(t)?(dt(t),new Ie(ot,at)):null:pe||=new Ie(0,0)}var pe,ye,me,ge,ve,be,we,Ae,Ie=class{constructor(t,e){this.i=t>>>0,this.h=e>>>0}};function Ee(t,e,r){return"undefined"!=typeof BigInt64Array?(we||(we=new BigInt64Array(1),Ae=new Uint32Array(we.buffer),we[0]=BigInt(1),be=1===Ae[0]),we[0]=t,new e(Ae[t=be?0:1],Ae[1-t])):(ve||(ye=BigInt(Number.MIN_SAFE_INTEGER),me=BigInt(Number.MAX_SAFE_INTEGER),ge=BigInt(4294967295),ve=BigInt(32)),t>=ye&&t<=me?r(Number(t)):(t=BigInt.asUintN(64,t),new e(Number(t&ge),Number(t>>ve))))}function Se(t,e,r){for(;r>0||e>127;)t.h.push(127&e|128),e=(e>>>7|r<<25)>>>0,r>>>=7;t.h.push(e)}function Ne(t,e){for(;e>127;)t.h.push(127&e|128),e>>>=7;t.h.push(e)}function Be(t,e){if(e>=0)Ne(t,e);else{for(let r=0;r<9;r++)t.h.push(127&e|128),e>>=7;t.h.push(1)}}function _e(t,e){dt(e),function(t){var e=at>>31;t(ot<<1^e,(at<<1|ot>>>31)^e)}((e,r)=>{Se(t,e>>>0,r>>>0)})}function xe(t,e){t.h.push(e>>>0&255),t.h.push(e>>>8&255),t.h.push(e>>>16&255),t.h.push(e>>>24&255)}var Ce=class{constructor(){this.h=[]}length(){return this.h.length}end(){var t=this.h;return this.h=[],t}};function Te(t,e){0!==e.length&&(t.j.push(e),t.i+=e.length)}function je(t,e,r){Ne(t.h,8*e+r)}function Oe(t,e){return je(t,e,2),e=t.h.end(),Te(t,e),e.push(t.i),e}function Fe(t,e){var r=e.pop();for(r=t.i+t.h.length()-r;r>127;)e.push(127&r|128),r>>>=7,t.i++;e.push(r),t.i++}function Ue(t,e,r){if(null!=r)switch(je(t,e,0),typeof r){case"number":t=t.h,ut(r),Se(t,ot,at);break;case"bigint":r=Ee(r,Ie,he),Se(t.h,r.i,r.h);break;default:r=de(r),Se(t.h,r.i,r.h)}}function ke(t,e,r){je(t,e,2),Ne(t.h,r.length),Te(t,t.h.end()),Te(t,r)}var Me=class{constructor(){this.j=[],this.i=0,this.h=new Ce}};function Re(t){if("string"==typeof t)de(t)}function Pe(){var t=class{constructor(){throw Error()}};return Object.setPrototypeOf(t,t.prototype),t}var De=Pe(),Le=Pe(),ze=Pe(),Ge=Pe(),$e=Pe(),He=Pe(),We=Pe(),Je=Pe(),Ve=Pe(),qe=Pe(),Ke=Pe(),Xe=Pe(),Ze=class{constructor(t,e){this.l=Rt(t,e,void 0,2048)}toJSON(){return Mt(this)}};Ze.prototype[M]=$,Ze.prototype.toString=function(){return this.l.toString()};var Ye=class{constructor(t,e){this.h=t,t=De,this.i=!!t&&e===t||!1}};function Qe(t,e,r,n,i){null!=(e=sr(e,n))&&(r=Oe(t,r),i(e,t),Fe(t,r))}var tr,er,rr=new Ye(Qe,De),nr=new Ye(Qe,De),ir=Symbol(),or=Symbol();function ar(t){var e=ur,r=lr,n=t[ir];if(n)return n;(n={}).ja=t,n.O=function(t){switch(typeof t){case"boolean":return It||=[0,void 0,!0];case"number":return t>0?void 0:0===t?Et||=[0,void 0]:[-t,void 0];case"string":return[0,t];case"object":return t}}(t[0]);var i=t[1],o=1;i&&i.constructor===Object&&(n.W=i,"function"==typeof(i=t[++o])&&(n.ca=!0,tr??=i,er??=t[o+1],i=t[o+=2]));for(var a={};i&&Array.isArray(i)&&i.length&&"number"==typeof i[0]&&i[0]>0;){for(var s=0;s<i.length;s++)a[i[s]]=i;i=t[++o]}for(s=1;void 0!==i;){let f;"number"==typeof i&&(s+=i,i=t[++o]);var u=void 0;if(i instanceof Ye?f=i:(f=rr,o--),f?.i){i=t[++o],u=t;var l=o;"function"==typeof i&&(i=i(),u[l]=i),u=i}for(l=s+1,"number"==typeof(i=t[++o])&&i<0&&(l-=i,i=t[++o]);s<l;s++){let t=a[s];u?r(n,s,f,u,t):e(n,s,f,t)}}return t[ir]=n}function sr(t,e){return t instanceof Ze?t.l:Array.isArray(t)?Rt(t,e[0],e[1]):void 0}function ur(t,e,r){t[e]=r.h}function lr(t,e,r,n){var i,o,a=r.h;t[e]=(t,e,r)=>a(t,e,r,o||=ar(n).O,i||=fr(n))}function fr(t){var e=t[or];if(!e){let r=ar(t);e=(t,e)=>cr(t,e,r),t[or]=e}return e}function cr(t,e,r){!function(t,e,r){var n,i=128&e?0:-1,o=t.length;(n=!!o)&&(n=null!=(n=t[o-1])&&"object"==typeof n&&n.constructor===Object);var a=o+(n?-1:0);for(e=128&e?1:0;e<a;e++)r(e-i,t[e]);if(n){t=t[o-1];for(let e in t)!isNaN(e)&&r(+e,t[e])}}(t,0|t[D],(t,n)=>{if(null!=n){var i=function(t,e){var r=t[e];if(r)return r;if((r=t.W)&&(r=r[e])){var n=(r=Array.isArray(r)?r[0]instanceof Ye?r:[nr,r]:[r,void 0])[0].h;if(r=r[1]){let e=fr(r),i=ar(r).O;r=t.ca?er(i,e):(t,r,o)=>n(t,r,o,i,e)}else r=n;return t[e]=r}}(r,t);i?i(e,n,t):t<500||_(U,3)}})}function hr(t,e,r){if(Array.isArray(e)){var n=0|e[D];if(4&n)return e;for(var i=0,o=0;i<e.length;i++){let r=t(e[i]);null!=r&&(e[o++]=r)}return o<i&&(e.length=o),t=1|n,r&&(t=-1537&t|4),t!==n&&G(e,t),r&&2&t&&Object.freeze(e),e}}var dr=(t,e)=>{var r=new Me;cr(t.l,r,ar(e)),Te(r,r.h.end()),t=new Uint8Array(r.i);var n=(e=r.j).length,i=0;for(let r=0;r<n;r++){let n=e[r];t.set(n,i),i+=n.length}return r.j=[t],t};function pr(t,e){return new Ye(t,e)}function yr(t,e){return new Ye(t,e)}function mr(t,e,r){null!=(e=Ct(e))&&(Re(e),Ue(t,r,e))}function gr(t,e,r){null!=(e=Bt(e))&&null!=e&&(je(t,r,0),Be(t.h,e))}function vr(t,e,r){null!=(e=Ot(e))&&ke(t,r,i(e))}function br(t,e,r,n,i){null!=(e=sr(e,n))&&(r=Oe(t,r),i(e,t),Fe(t,r))}function wr(t,e,r){null!=(e=jt(e))&&ke(t,r,se(e).buffer)}function Ar(t,e,r){null!=(e=Bt(e))&&(e=parseInt(e,10),je(t,r,0),Be(t.h,e))}var Ir,Er=pr(function(t,e,r){null!=(e=wt(e))&&(je(t,r,1),t=t.h,(r=it||=new DataView(new ArrayBuffer(8))).setFloat64(0,+e,!0),ot=r.getUint32(0,!0),at=r.getUint32(4,!0),xe(t,ot),xe(t,at))},qe),Sr=pr(function(t,e,r){null!=(e=wt(e))&&(je(t,r,5),t=t.h,(r=it||=new DataView(new ArrayBuffer(8))).setFloat32(0,+e,!0),at=0,xe(t,ot=r.getUint32(0,!0)))},Ve),Nr=pr(mr,He),Br=pr(mr,He),_r=yr(function(t,e,r){if(null!=(e=hr(Ct,e,!1)))for(let n=0;n<e.length;n++)Ue(t,r,e[n])},He),xr=pr(function(t,e,r){if(null!=(e=Tt(e))){if("string"==typeof e)le(e);if(null!=e)switch(je(t,r,0),typeof e){case"number":t=t.h,ut(e),Se(t,ot,at);break;case"bigint":r=Ee(e,ce,ue),Se(t.h,r.i,r.h);break;default:r=le(e),Se(t.h,r.i,r.h)}}},We),Cr=pr(gr,Ge),Tr=yr(function(t,e,r){if(null!=(e=hr(Bt,e,!0)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&(je(n,i,0),Be(n.h,o))}},Ge),jr=yr(function(t,e,r){if(null!=(e=hr(Bt,e,!0))&&e.length){r=Oe(t,r);for(let r=0;r<e.length;r++)Be(t.h,e[r]);Fe(t,r)}},Ge),Or=pr(function(t,e,r){null!=(e=null==e||"boolean"==typeof e?e:"number"==typeof e?!!e:void 0)&&(je(t,r,0),t.h.h.push(e?1:0))},Le),Fr=pr(vr,ze),Ur=yr(function(t,e,r){if(null!=(e=hr(Ot,e,!0)))for(let s=0;s<e.length;s++){var n=t,o=r,a=e[s];null!=a&&ke(n,o,i(a))}},ze),kr=function(t,e,r=De){return new Ye(e,r)}(0,function(t,e,r,n,i){if(Array.isArray(e)){for(let o=0;o<e.length;o++)br(t,e[o],r,n,i);1&(t=0|e[D])||G(e,1|t)}}),Mr=new Ye(br,De),Rr=pr(wr,Ke),Pr=yr(function(t,e,r){if(null!=(e=hr(jt,e,!1)))for(let a=0;a<e.length;a++){var n=t,i=r,o=e[a];null!=o&&ke(n,i,se(o).buffer)}},Ke),Dr=pr(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 vt(t)?t>>>0:void 0}(e),null!=e&&null!=e&&(je(t,r,0),Ne(t.h,e))},$e),Lr=pr(Ar,Xe),zr=pr(Ar,Xe),Gr=pr(function(t,e,r){if(null!=(e=Ct(e))&&(Re(e),null!=e))switch(je(t,r,0),typeof e){case"number":t=t.h,e=(r=e)<0,st(r=2*Math.abs(r)),r=ot;let n=at;e&&(0==r?0==n?n=r=4294967295:(n--,r=4294967295):r--),Se(t,ot=r,at=n);break;case"bigint":t=t.h,e=e<<BigInt(1)^e>>BigInt(63),ot=Number(BigInt.asUintN(32,e)),at=Number(BigInt.asUintN(32,e>>BigInt(32))),Se(t,ot,at);break;default:_e(t.h,e)}},Je),$r=[0,Rr,Pr,Or,Fr],Hr=[0,pr(vr,ze),[0,zr,[0,pr(mr,He),pr(gr,Ge)],zr,-1,[0,Lr],zr,-1],pr(wr,Ke)],Wr=[0,1,[0,12,Cr,10,Or],[0,7,[0,Cr,-1]]],Jr=globalThis.trustedTypes;var Vr=class{constructor(t){this.h=t}toString(){return this.h+""}};function qr(t){var e;return void 0===Ir&&(Ir=function(){var t=null;if(!Jr)return t;try{let e=t=>t;t=Jr.createPolicy("goog#html",{createHTML:e,createScript:e,createScriptURL:e})}catch(t){}return t}()),t=(e=Ir)?e.createScriptURL(t):t,new Vr(t)}function Kr(t,...e){if(0===e.length)return qr(t[0]);var r=t[0];for(let n=0;n<e.length;n++)r+=encodeURIComponent(e[n])+t[n+1];return qr(r)}function Xr(t,e){if(t.floatEmbedding&&e.floatEmbedding)return Yr(t.floatEmbedding,e.floatEmbedding);if(t.quantizedEmbedding&&e.quantizedEmbedding)return Yr(Zr(t.quantizedEmbedding),Zr(e.quantizedEmbedding));throw Error("Cannot compute cosine similarity between quantized and float embeddings.")}function Zr(t){return Array.from(t,t=>t>127?t-256:t)}function Yr(t,e){if(t.length!==e.length)throw Error(`Cannot compute cosine similarity between embeddings of different sizes (${t.length} vs. ${e.length}).`);var r=0,n=0,i=0;for(let o=0;o<t.length;o++)r+=t[o]*e[o],n+=t[o]*t[o],i+=e[o]*e[o];if(n<=0||i<=0)throw Error("Cannot compute cosine similarity on embedding with 0 norm.");return r/Math.sqrt(n*i)}function Qr(t){!t.h&&t.i.length>0&&(t.h=!0,t.i.shift()())}async function tn(t,e){return new Promise((r,n)=>{t.i.push(()=>{e().then(r,n).finally(()=>{t.h=!1,Qr(t)})}),Qr(t)})}var en,rn=class{constructor(){this.h=!1,this.i=[]}},nn=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]);async function on(t){if(t)return!0;if(void 0===en)try{await WebAssembly.instantiate(nn),en=!0}catch{en=!1}return en}async function an(t,e,r){return{wasmLoaderPath:`${e}/${t}_${r=`wasm${r?"_module":""}${await on(r)?"":"_nosimd"}_internal`}.js`,wasmBinaryPath:`${e}/${t}_${r}.wasm`}}var sn=class{};function un(t){return oe(new ln,1,t)}sn.forVisionTasks=function(t,e=!1){return an("vision",t??Kr``,e)},sn.forLiteRtLmTextTasks=function(t,e=!1){return an("litertlm_text",t??Kr``,e)},sn.forTextTasks=function(t,e=!1){return an("text",t??Kr``,e)},sn.forRetrievalTasks=function(t,e=!1){return an("retrieval",t??Kr``,e)},sn.forGenAiTasks=function(t,e=!1){return an("genai",t??Kr``,e)},sn.forDecisionTasks=function(t,e=!1){return an("decision",t??Kr``,e)},sn.forAudioTasks=function(t,e=!1){return an("audio",t??Kr``,e)},sn.isSimdSupported=function(t=!1){return on(t)};var ln=class extends Ze{constructor(t){super(t)}},fn=class extends Ze{constructor(t){super(t)}},cn=[0,Lr,2,xr,-2,Br,kr,[0,Lr,Br]],hn=class extends Ze{constructor(t){super(t)}},dn=class extends Ze{constructor(t){super(t)}};function pn(t,e){return oe(t,1,e)}function yn(t,e){return oe(t,2,e)}var mn,gn=class extends Ze{constructor(t){super(t)}},vn=[3,4,5,6,7],bn=class extends Ze{constructor(t){super(t)}},wn=class extends Ze{constructor(t){super(t)}};wn.prototype.i=(mn=[0,[0,Lr,Fr,-3,Lr],[0,vn,Lr,-1,Mr,[0,Lr,Fr,xr],Mr,cn,Mr,[0,1,cn],Mr,[0,Lr],Mr,[0,Lr,Fr,xr]]],function(){return dr(this,mn)});var An=class{constructor(){this.h="undefined"!=typeof AbortController}async send(t,e,r){var n=this.h?new AbortController:void 0,i=n&&t.N>0?setTimeout(()=>{n.abort()},t.N):void 0;try{let i=await fetch(t.url,{method:t.fa,headers:{...t.ea},...t.body&&{body:t.body},...t.withCredentials&&{credentials:"include"},signal:t.N&&n?n.signal:null});200===i.status?e?.(await i.text()):r?.(i.status)}catch(t){if("AbortError"===t?.name)r?.(408);else r?.(400)}finally{clearTimeout(i)}}},In=class extends Ze{constructor(t){super(t,37)}},En=[-4,{},Wr,Lr,Hr],Sn=[0,Fr,Lr,1,Fr,-1,Lr,1,Lr,1,Br],Nn=[0,Lr,Fr,-2],Bn=[0,Fr,Lr],_n=[0,Fr,Lr],xn=[0,Or,-3],Cn=[0,Lr,Fr,-1,Br,Cr,-1,Fr,-5,kr,[0,Fr,-4],-1,Or,[0,Or,-3],Lr];var Tn=class extends Ze{constructor(t){super(t,19)}},jn=function(t){return e=>dr(e,t)}([-19,{},[0,Lr,1,[0,Fr,-6,Br,Cr,Fr,-1,Br],1,[0,Fr,1,Fr,-5],Fr,-1,[0,Lr,Fr,-8],[0,Fr,-3],[0,Fr,Lr,Fr,-2],[0,Fr,-1,Lr,Fr,-1,Lr,Fr,-1,[0,kr,[0,Fr,-1],Or,Fr,-5],[0,Lr,Or,Cr,-2]],Br,[0,Fr,-3,Br,Cr,Fr,-1],[0,Lr,Fr,-1],[0,Fr,-9],[0,Fr,-6,Lr,Fr,1,Fr,Or,Lr,-1,Or,Fr,-2,Lr,Fr,Lr,Fr,Cr,-1],1,[0,Lr],1,[0,Fr,-4],1,Sn,[0,[1,2,3,4,5,6],Mr,Sn,Mr,Bn,Mr,_n,Mr,[0,Lr],Mr,Cn,Mr,Nn],Bn,_n,Cn,[0,[0,Lr,Fr,-1,Br,Cr,-1,Fr,-4,kr,[0,Fr,-4],-1,1,xn],[0,Lr,Fr,-1,Br,Cr,-1,Fr,-4,xn]],Nn,[0,Fr,[0,Cr,-3,Lr],Lr,-2,[0,Cr,-1],Or],4,[0,Fr,Lr,Fr,-1,Br,Lr,Fr,-1,Lr,Cr,-1]],Lr,kr,[-37,{},Nr,Fr,kr,[0,Fr,-1],Rr,1,Rr,[0,Ur,-1,Tr,_r,-1],Fr,[0,Cr,Fr,-1],Or,Cr,Br,Fr,-1,Gr,$r,Nr,Rr,Lr,Tr,Br,-1,[0,Lr,-1],Fr,Or,Fr,jr,Fr,-1,Er,1,Er,En,Or,[0,Lr,[0,Sr,Cr,-2],[0,Sr]],[0,Lr,Br]],Nr,Pr,Fr,-1,Nr,Lr,-1,[0,Or,-1,Lr,Or],[0,Br,-1,Fr],[0,Nr,Or,Br],Br,1,Dr,1,En]),On=class{constructor(t){this.i=[],this.m=new An,this.j=t??"",this.h=setInterval(()=>{this.flush()},6e4)}close(){void 0!==this.h&&(clearInterval(this.h),this.h=void 0),this.flush()}flush(t,e){if(this.error)e?.("net-send-failed");else if(0===this.i.length)t?.();else{var r=this.i;this.i=[],r=function(t){var e=new Tn;{zt(e=oe(e,2,1786));let l=e.l,f=0|l[D];if(null==t)Wt(l,f,3);else{var r=t===j?7:0|t[D],n=r,i=qt(r),o=i||Object.isFrozen(t),a=!0,s=!0;for(let e=0;e<t.length;e++){var u=t[e];i||(u=H(u),a&&=!u,s&&=u)}i||(r=a?13:5,r=s?-4097&r:4096|r),o&&r===n||(t=Array.prototype.slice.call(t),n=0,r=te(r,f)),r!==n&&G(t,r),f=Wt(l,f,3,t),2&r||!(4096&r||16&r)||Gt(l,f)}}return e}(r),r=jn(r),this.m.send({url:"https://odml.pa.googleapis.com/v1/log",fa:"POST",N:1e4,body:r,ka:2,ea:{"Content-Type":"application/x-protobuf","x-goog-api-key":this.j},withCredentials:!1},()=>{t?.()},t=>{this.error=Error(`Logging failed with HTTP error: ${t}`),this.i=[],void 0!==this.h&&(clearInterval(this.h),this.h=void 0),e?.("net-send-failed",t)})}}};class Fn{constructor(){this.I=this.B=this.G=this.A=this.D=this.F=this.C=0}}function Un(t,e){var r=new wn;if(r=Yt(r,1,t.R),r=Yt(r,2,e),e=new In,null!=(r=r.i()))if("string"==typeof r)r=r?new I(r,A):w||=new I(null,A);else if(r.constructor!==I){if(!(p&&null!=r&&r instanceof Uint8Array))throw Error();r=r.length?new I(new Uint8Array(r),A):w||=new I(null,A)}e=Ht(e,6,r),(t=t.H).error||t.i.push(e)}function kn(t){var e=new dn;e=ne(e=oe(e,1,10),3,performance.now()-t.P),Un(t,e=Qt(yn(pn(new gn,t.v),0),3,e)),t.m=performance.now()}function Mn(t,e){++t.h.F,t.i.set(e,performance.now())}function Rn(t,e){var r={C:e.C-t.j.C,F:e.F-t.j.F,D:e.D-t.j.D,A:e.A-t.j.A,G:e.G-t.j.G,B:e.B,I:e.I},n=yn(pn(new gn,t.v),1);Un(t,n=Qt(n,4,r=Dn(r))),t.j=e}function Pn(t,e){var r=t.i.get(e);if(void 0!==r&&(t.i.delete(e),e=performance.now()-r,++t.h.D,t.h.G+=e,t.h.B=Math.max(t.h.B,e),t.u=Math.max(t.u,e),performance.now()>t.m+3e4)){for(let[n,i]of t.i.entries())e=n,i<r&&(t.h.A++,t.i.delete(e));r={...t.h,I:performance.now()-t.m},t.h.B=0,t.m=performance.now(),Rn(t,r)}}function Dn(t){var e=new fn;if(e=ne(e=re(e=oe(e,1,10),7,t.A),5,t.B),e=ne(e,6,t.I),t.D>0&&ne(e,4,t.G/t.D),0!==t.C){var r=un(3);ee(e,r=re(r,2,t.C))}return 0!==t.F&&ee(e,t=re(r=un(4),2,t.F)),e}function Ln(t){var e={...t.h,A:t.h.A+t.i.size,B:t.u,I:performance.now()-t.P};Rn(t,e);var r=new hn;r=Yt(r,2,e=Dn(e)),Un(t,r=Qt(e=yn(pn(new gn,t.v),2),5,r))}var zn=class{constructor(t,e){this.P=performance.now(),this.m=performance.now(),this.i=new Map,this.u=0,this.h=new Fn,this.j=new Fn,this.H=new On(e),this.v=function(t){switch(t){case"AudioClassifier":return 4;case"AudioEmbedder":return 5;case"TextClassifier":return 6;case"TextEmbedder":return 7;case"GestureRecognizer":return 8;case"HandDetector":return 9;case"HandLandmarker":return 10;case"ImageClassifier":return 11;case"ImageEmbedder":return 12;case"ImageSegmenter":return 13;case"ObjectDetector":return 14;case"FaceDetector":return 15;case"FaceLandmarker":return 16;case"InteractiveSegmenter":case"InteractiveSegmenterLegacy":return 18;case"HolisticLandmarker":return 20;case"LlmInference":return 21;case"LanguageDetector":return 22;case"PoseLandmarker":return 23;case"UniversalEmbedder":return 28;case"SemanticRetriever":return 29;case"DecisionMaker":return 30;case"TextSummarizer":return 26;case"TextProofreader":return 27;case"AudioTranscriber":return 31;case"TextToSpeech":return 32;default:return 0}}(t),t=new bn,"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=ie(t=oe(t,1,e),2,""),t=ie(t,3,""),t=ie(t,4,"1.2.0"),t=ie(t,5,""),this.R=oe(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}())}close(){var t=this.H;"function"==typeof t.close?t.close():t.flush()}};function Gn(t){var e=atob("QUl6YVN5QS1XbGdRNjczMWpZSThjWGhKNEFxZjhuX3J1UmNLMzJZ");return new zn(t,e)}async function $n(t){if("function"!=typeof importScripts){let e=document.createElement("script");return e.src=t.toString(),e.crossOrigin="anonymous",new Promise((t,r)=>{e.addEventListener("load",()=>{t()},!1),e.addEventListener("error",t=>{r(t)},!1),document.body.appendChild(e)})}try{importScripts(t.toString())}catch(e){if(!(e instanceof TypeError))throw e;{let e=self.import;e?await e(t.toString()):await import(t.toString())}}}var Hn=async(t,e,r,n)=>{if(e&&await $n(e),!self.ModuleFactory)throw Error("ModuleFactory not set.");if(r&&(await $n(r),!self.ModuleFactory))throw Error("ModuleFactory not set.");return self.Module&&n&&((e=self.Module).locateFile=n.locateFile,n.mainScriptUrlOrBlob&&(e.mainScriptUrlOrBlob=n.mainScriptUrlOrBlob)),n=await self.ModuleFactory(self.Module||n),self.ModuleFactory=self.Module=void 0,new t(n,null)},Wn={CHARACTER:0,WORD:1};function Jn(t,e){if(t<=0)throw Error("Chunk size must be positive.");if(e<0||e>=t)throw Error("Chunk overlap must be non-negative and less than chunk size.")}function Vn(t,e,r,n="CHARACTER"){Jn(e,r),t.j=e,t.i=r,t.mode=n}var qn=class{constructor(t){this.j=512,this.i=100,this.mode="CHARACTER",this.h=t}chunk(t){if(!t||0===t.trim().length)return[];if(!this.h||"function"!=typeof this.h.defaultTextChunker_nativeChunkText)throw Error("DefaultTextChunker Wasm module is not initialized.");return(t=this.h.defaultTextChunker_nativeChunkText(t,this.j,this.i,Wn[this.mode]??0))?Array.from(t):[]}};function Kn(t){return{...t,content:t.content?t.content.map(t=>"imageBytes"in t?{...t,imageBytes:new Uint8Array(t.imageBytes)}:"audioData"in t?{...t,audioData:new Float32Array(t.audioData)}:{...t}):[],embeddings:t.embeddings?new Float32Array(t.embeddings):new Float32Array(0),metadata:t.metadata?{...t.metadata}:{},...t.childIds?{childIds:[...t.childIds]}:{}}}qn.prototype.chunk=qn.prototype.chunk,qn.createFromModule=function(t,e=512,r=100,n="CHARACTER"){return Jn(e,r),Vn(t=new qn(t),e,r,n),t},qn.create=async function(t,e=512,r=100,n="CHARACTER"){Jn(e,r);var i=await Hn(qn,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return Vn(i,e,r,n),i};var Xn=class{constructor(){this.h=new Map}upsert(t){for(let e of t)this.h.set(e.id,Kn(e))}delete(t){var e=new Set(t);for(let r of t)if(t=this.h.get(r),t?.childIds)for(let r of t.childIds)e.add(r);for(let t of e)this.h.delete(t)}deleteByMetadata(t){var e=Object.keys(t);if(0!==e.length){var r=[];for(let n of this.h.values())n.parentId||n.metadata&&e.every(e=>n.metadata[e]===t[e])&&r.push(n.id);r.length>0&&this.delete(r)}}search(t,e,r){if(e<=0)throw Error(`'topK' must be greater than 0, got ${e}.`);var n=r?Object.keys(r):[];t=Array.from(t);var i=[];for(let e of this.h.values()){if(r&&n.length>0){if(!e.metadata)continue;if(!n.every(t=>e.metadata?.[t]===r[t]))continue}if(e.embeddings&&0!==e.embeddings.length)try{let r=Xr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""});i.push({da:e,score:r})}catch{}}return i.sort((t,e)=>e.score-t.score),i.slice(0,e).map(t=>Kn(t.da))}get(t){var e=[];for(let r of t)(t=this.h.get(r))&&e.push(Kn(t));return e}getAllRecordIds(){var t=[];for(let[e,r]of this.h.entries()){let n=e;r.parentId||t.push(n)}return t}deleteAll(){this.h.clear()}close(){this.h.clear()}};Xn.prototype.close=Xn.prototype.close,Xn.prototype.deleteAll=Xn.prototype.deleteAll,Xn.prototype.getAllRecordIds=Xn.prototype.getAllRecordIds,Xn.prototype.get=Xn.prototype.get,Xn.prototype.search=Xn.prototype.search,Xn.prototype.deleteByMetadata=Xn.prototype.deleteByMetadata,Xn.prototype.delete=Xn.prototype.delete,Xn.prototype.upsert=Xn.prototype.upsert;var Zn=class{constructor(){this.h=[]}S(t){return this.h.push(t),this}M(){return[...this.h]}ia(t){return this.j=t,this}o(){return this.j}ha(t){return this.i=t,this}L(){return this.i}};function Yn(t){if(t.i)throw Error("SemanticRetriever has already been closed.")}Zn.prototype.textChunker=Zn.prototype.L,Zn.prototype.setTextChunker=Zn.prototype.ha,Zn.prototype.vectorStore=Zn.prototype.o,Zn.prototype.setVectorStore=Zn.prototype.ia,Zn.prototype.providers=Zn.prototype.M,Zn.prototype.addProvider=Zn.prototype.S;var Qn=class{constructor(t,e,r){this.m=t,this.o=e,this.L=r,this.i=!1,this.j=0,this.h=Gn("SemanticRetriever"),kn(this.h)}async embedContent(t){for(let e of this.m.M()){let r=await e.embedContent(t);if(null!=r)return r instanceof Float32Array?r:new Float32Array(r)}throw Error("No embedding provider found that can embed this content.")}async Z(t,e,r){return Yn(this),this.K(t,[{text:e}],r)}async K(t,e,r){Yn(this),await this.o.delete([t]);var n=[],i=0;if(1===e.length&&"text"in e[0]&&"string"==typeof e[0].text){var o=await this.L.chunk(e[0].text);if(o.length>1){let r=[];for(let e of o)o=`${t}_chunk_${i++}`,r.push(o),n.push({id:o,J:[{text:e}],parentId:t});n.push({id:t,J:e,childIds:r})}else n.push({id:t,J:e})}else n.push({id:t,J:e});t=[];for(let e of n)n=void 0!==e.childIds&&e.childIds.length>0?new Float32Array(0):await this.embedContent(e.J),t.push({id:e.id,content:[...e.J],embeddings:n,metadata:r||{},parentId:e.parentId,childIds:e.childIds});await this.o.upsert(t)}async aa(t,e,r){return Yn(this),this.K(t,[{imageBytes:e}],r)}async Y(t,e,r){return Yn(this),this.K(t,[{audioData:e}],r)}async ga(t,e={}){Yn(this);var{limit:r=5,metadataFilter:n}=e;if(r<=0)throw Error(`'limit' must be greater than 0, got ${r}.`);e=this.j++;var i=this.h;++i.h.C,i.i.set(e,performance.now()),t=await this.embedContent("string"==typeof t?[{text:t}]:t),i=await this.o.search(t,3*r,n);var o=new Set;for(var a of i)a.parentId&&o.add(a.parentId);if(a=new Map,o.size>0)for(var s of o=await this.o.get(Array.from(o)))a.set(s.id,s);for(var u of(s=[],o=new Set,i))u.parentId?o.has(u.parentId)||(o.add(u.parentId),(i=a.get(u.parentId))&&s.push({id:i.id,content:i.content,embeddings:u.embeddings,metadata:i.metadata,parentId:i.parentId,childIds:i.childIds})):o.has(u.id)||(o.add(u.id),s.push(u));u=[],t=Array.from(t);for(let e of s){if(s=0,e.embeddings&&e.embeddings.length>0)try{s=Xr({floatEmbedding:t,headIndex:0,headName:""},{floatEmbedding:Array.from(e.embeddings),headIndex:0,headName:""})}catch{s=0}if(u.push({id:e.id,content:e.content?[...e.content]:[],metadata:e.metadata?{...e.metadata}:{},score:s}),u.length>=r)break}return Pn(this.h,e),u}async delete(t){Yn(this),"string"==typeof t?await this.o.delete([t]):Array.isArray(t)?await this.o.delete(t):await this.o.deleteByMetadata(t)}async getAllRecordIds(){Yn(this);var t=await this.o.getAllRecordIds();return Array.from(new Set(t))}async deleteAll(){Yn(this),await this.o.deleteAll()}close(){if(!this.i){this.i=!0,Ln(this.h),this.h.close();try{this.o.close()}catch{}}}};async function ti(t,e){var r=e.baseOptions.device;r||=await ei();var n=await Hn(ii,t.wasmLoaderPath,t.assetLoaderPath,{locateFile:e=>e.endsWith(".wasm")?t.wasmBinaryPath.toString():e});return r&&(n.h.preinitializedWebGPUDevice=r),await async function(t,e,r){t.i=Gn("UniversalEmbedder");var n=!1!==e.l2Normalize,i=e.baseOptions.modelAssetPath?e.baseOptions.modelAssetPath.toString():"";if((r=r||e.baseOptions.device||t.h.preinitializedWebGPUDevice)||(r=await ei()),t.h.preinitializedWebGPUDevice=r,e.baseOptions.modelAssetBuffer){i=e.baseOptions.modelAssetBuffer instanceof Uint8Array?e.baseOptions.modelAssetBuffer:await async function(t){for(var e=[],r=0;;){let{done:n,value:i}=await t.read();if(n)break;e.push(i),r+=i.length}if(0===e.length)return new Uint8Array(0);if(1===e.length)return e[0];t=new Uint8Array(r),r=0;for(let n of e)t.set(n,r),r+=n.length;return t}(e.baseOptions.modelAssetBuffer);var o=`/${r=`universal_embedder_model_${++oi}.litertlm`}`;try{t.h.FS_unlink?.(o)}catch{}t.h.FS_createDataFile("/",r,i,!0,!1,!1),t.v=o,i=t.v}if(!i)throw Error("No model asset path or buffer provided.");r=e.maxInputLength??0,o=e.visionTokensPerImage??0,e=function(t){if(void 0===t)return 0;switch(t){case"FLOAT32":return 1;case"FLOAT16":return 2;case"INT16":return 3;case"INT8":return 4;default:throw Error(`Unsupported activation data type: ${t}`)}}(e.activationDataType);try{t.j=await t.h.createUniversalEmbedder(i,n,r,o,e),kn(t.i)}catch(e){throw ri(t),e}}(n,e,r),n}async function ei(){if("undefined"==typeof navigator||!navigator.gpu)throw Error("WebGPU is not supported on this platform.");var t=await navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw Error("No appropriate WebGPU adapter found.");var e=[];if(t.features.has("subgroups")&&e.push("subgroups"),t.features.has("shader-f16")&&e.push("shader-f16"),!(e=await t.requestDevice({requiredFeatures:e})).adapterInfo&&t.info)try{Object.defineProperty(e,"adapterInfo",{value:t.info,writable:!0,configurable:!0})}catch{}return e}function ri(t){if(t.v){try{t.h.FS_unlink?.(t.v)}catch{}t.v=void 0}}function ni(t){if(t.H||0===t.j)throw Error("UniversalEmbedder has already been closed.")}Qn.prototype.close=Qn.prototype.close,Qn.prototype.deleteAll=Qn.prototype.deleteAll,Qn.prototype.getAllRecordIds=Qn.prototype.getAllRecordIds,Qn.prototype.delete=Qn.prototype.delete,Qn.prototype.retrieve=Qn.prototype.ga,Qn.prototype.insertAudio=Qn.prototype.Y,Qn.prototype.insertImage=Qn.prototype.aa,Qn.prototype.insertContent=Qn.prototype.K,Qn.prototype.insertDocument=Qn.prototype.Z,Qn.createFromComponents=async function(t){if(!t||0===t.M().length)throw Error("At least one EmbeddingProvider must be registered in SemanticRetrieverComponents.");var e=t.o();if(!e)throw Error("VectorStore must be provided in SemanticRetrieverComponents.");var r=t.L();if(!r)throw Error("TextChunker must be provided in SemanticRetrieverComponents.");return new Qn(t,e,r)};var ii=class{constructor(t){this.H=!1,this.j=0,this.u=new rn,this.m=0,this.h=t}async V(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedText(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async U(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedImage(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async T(t){return tn(this.u,async()=>{ni(this);var e=this.m++;Mn(this.i,e);var r=await this.h.universalEmbedder_embedAudio(this.j,t);return Pn(this.i,e),{embeddings:[{floatEmbedding:r?Array.from(r):[],headIndex:0,headName:"default"}]}})}async embedContent(t){if(ni(this),!Array.isArray(t))throw Error("Content must be an array of ContentParts.");return tn(this.u,async()=>{ni(this);var e=this.h.universalEmbedder_createContentBuilder();try{for(let r of t)if("text"in r&&"string"==typeof r.text)this.h.universalEmbedder_builderAddText(e,r.text);else if("imageBytes"in r&&(r.imageBytes instanceof Uint8Array||"string"==typeof r.imageBytes))this.h.universalEmbedder_builderAddImage(e,r.imageBytes);else{if(!("audioData"in r)||!(r.audioData instanceof Float32Array||Array.isArray(r.audioData)))throw Error(`Unsupported or invalid ContentPart: ${JSON.stringify(r)}`);this.h.universalEmbedder_builderAddAudio(e,r.audioData)}let r=this.m++;Mn(this.i,r);let n=await this.h.universalEmbedder_executeEmbedContent(this.j,e);return Pn(this.i,r),{embeddings:[{floatEmbedding:n?Array.from(n):[],headIndex:0,headName:"default"}]}}finally{this.h.universalEmbedder_freeContentBuilder(e)}})}X(){return{embedContent:async t=>(await this.embedContent(t))?.embeddings?.[0]?.floatEmbedding??null}}close(){this.H||(this.H=!0,Ln(this.i),this.i.close(),0!==this.j&&(this.h.universalEmbedder_close(this.j),this.j=0),ri(this))}};ii.prototype.close=ii.prototype.close,ii.prototype.getProvider=ii.prototype.X,ii.cosineSimilarity=function(t,e){return Xr(t,e)},ii.prototype.embedContent=ii.prototype.embedContent,ii.prototype.embedAudio=ii.prototype.T,ii.prototype.embedImage=ii.prototype.U,ii.prototype.embedText=ii.prototype.V,ii.createFromModelPath=function(t,e){return ti(t,{baseOptions:{modelAssetPath:e.toString()}})},ii.createFromModelBuffer=function(t,e){return ti(t,{baseOptions:{modelAssetBuffer:e}})},ii.createWebGpuDevice=ei,ii.createFromOptions=ti;var oi=0;export{qn as DefaultTextChunker,sn as FilesetResolver,Xn as MemoryVectorStore,Qn as SemanticRetriever,Zn as SemanticRetrieverComponents,ii as UniversalEmbedder};
2
2
  //# sourceMappingURL=retrieval_bundle_mjs.js.map