-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworker.js
More file actions
2 lines (2 loc) · 21.3 KB
/
Copy pathworker.js
File metadata and controls
2 lines (2 loc) · 21.3 KB
1
2
(()=>{var q=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Q.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Q.unregister(this),e}free(){let e=this.__destroy_into_raw();r.__wbg_wasmencoder_free(e,0)}encode_file(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u,p=g(t,r.__wbindgen_export,r.__wbindgen_export2),y=u;r.wasmencoder_encode_file(i,this.__wbg_ptr,c,f,p,y);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return l(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}static new(e){try{let s=r.__wbindgen_add_to_stack_pointer(-16),i=A(e,r.__wbindgen_export),c=u;r.wasmencoder_new(s,i,c);var t=a().getInt32(s+4*0,!0),_=a().getInt32(s+4*1,!0),o=a().getInt32(s+4*2,!0);if(o)throw l(_);return n.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(q.prototype[Symbol.dispose]=q.prototype.free);var R=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,X.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,X.unregister(this),e}free(){let e=this.__destroy_into_raw();r.__wbg_wasmindexbuilder_free(e,0)}add_chunk(e,t,_,o){try{let c=r.__wbindgen_add_to_stack_pointer(-16),f=g(e,r.__wbindgen_export,r.__wbindgen_export2),p=u,y=ne(t,r.__wbindgen_export),x=u,O=g(_,r.__wbindgen_export,r.__wbindgen_export2),W=u;r.wasmindexbuilder_add_chunk(c,this.__wbg_ptr,f,p,y,x,O,W,o);var s=a().getInt32(c+4*0,!0),i=a().getInt32(c+4*1,!0);if(i)throw l(s)}finally{r.__wbindgen_add_to_stack_pointer(16)}}add_file(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u,p=g(t,r.__wbindgen_export,r.__wbindgen_export2),y=u;r.wasmindexbuilder_add_file(i,this.__wbg_ptr,c,f,p,y);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return _>>>0}finally{r.__wbindgen_add_to_stack_pointer(16)}}doc_count(){return r.wasmindexbuilder_doc_count(this.__wbg_ptr)>>>0}finish(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.wasmindexbuilder_finish(i,this.__wbg_ptr);var e=a().getInt32(i+4*0,!0),t=a().getInt32(i+4*1,!0),_=a().getInt32(i+4*2,!0),o=a().getInt32(i+4*3,!0);if(o)throw l(_);var s=$(e,t).slice();return r.__wbindgen_export4(e,t*1,1),s}finally{r.__wbindgen_add_to_stack_pointer(16)}}static new(e){try{let s=r.__wbindgen_add_to_stack_pointer(-16),i=A(e,r.__wbindgen_export),c=u;r.wasmindexbuilder_new(s,i,c);var t=a().getInt32(s+4*0,!0),_=a().getInt32(s+4*1,!0),o=a().getInt32(s+4*2,!0);if(o)throw l(_);return n.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(R.prototype[Symbol.dispose]=R.prototype.free);var C=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,V.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,V.unregister(this),e}free(){let e=this.__destroy_into_raw();r.__wbg_wasmmodel_free(e,0)}encode(e,t){try{let f=r.__wbindgen_add_to_stack_pointer(-16),p=re(e,r.__wbindgen_export),y=u;r.wasmmodel_encode(f,this.__wbg_ptr,p,y,t);var _=a().getInt32(f+4*0,!0),o=a().getInt32(f+4*1,!0),s=a().getInt32(f+4*2,!0),i=a().getInt32(f+4*3,!0);if(i)throw l(s);var c=ce(_,o).slice();return r.__wbindgen_export4(_,o*4,4),c}finally{r.__wbindgen_add_to_stack_pointer(16)}}static from_quantized(e){try{let s=r.__wbindgen_add_to_stack_pointer(-16),i=A(e,r.__wbindgen_export),c=u;r.wasmmodel_from_quantized(s,i,c);var t=a().getInt32(s+4*0,!0),_=a().getInt32(s+4*1,!0),o=a().getInt32(s+4*2,!0);if(o)throw l(_);return n.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}static from_type(e){let t=r.wasmmodel_from_type(e);return l(t)}constructor(e,t,_){try{let c=r.__wbindgen_add_to_stack_pointer(-16),f=A(e,r.__wbindgen_export),p=u,y=g(t,r.__wbindgen_export,r.__wbindgen_export2),x=u,O=g(_,r.__wbindgen_export,r.__wbindgen_export2),W=u;r.wasmmodel_new(c,f,p,y,x,O,W);var o=a().getInt32(c+4*0,!0),s=a().getInt32(c+4*1,!0),i=a().getInt32(c+4*2,!0);if(i)throw l(s);return this.__wbg_ptr=o>>>0,V.register(this,this.__wbg_ptr,this),this}finally{r.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(C.prototype[Symbol.dispose]=C.prototype.free);var Fe=Object.freeze({MiniLML6V2:0,0:"MiniLML6V2"}),S=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,Y.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Y.unregister(this),e}free(){let e=this.__destroy_into_raw();r.__wbg_wasmreranker_free(e,0)}static load(e){try{let s=r.__wbindgen_add_to_stack_pointer(-16),i=A(e,r.__wbindgen_export),c=u;r.wasmreranker_load(s,i,c);var t=a().getInt32(s+4*0,!0),_=a().getInt32(s+4*1,!0),o=a().getInt32(s+4*2,!0);if(o)throw l(_);return n.__wrap(t)}finally{r.__wbindgen_add_to_stack_pointer(16)}}rerank(e,t,_){try{let c=r.__wbindgen_add_to_stack_pointer(-16),f=g(e,r.__wbindgen_export,r.__wbindgen_export2),p=u,y=re(t,r.__wbindgen_export),x=u;r.wasmreranker_rerank(c,this.__wbg_ptr,f,p,y,x,_);var o=a().getInt32(c+4*0,!0),s=a().getInt32(c+4*1,!0),i=a().getInt32(c+4*2,!0);if(i)throw l(s);return l(o)}finally{r.__wbindgen_add_to_stack_pointer(16)}}score(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u,p=g(t,r.__wbindgen_export,r.__wbindgen_export2),y=u;r.wasmreranker_score(i,this.__wbg_ptr,c,f,p,y);var _=a().getFloat32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return _}finally{r.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(S.prototype[Symbol.dispose]=S.prototype.free);var v=class n{static __wrap(e){e=e>>>0;let t=Object.create(n.prototype);return t.__wbg_ptr=e,K.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,K.unregister(this),e}free(){let e=this.__destroy_into_raw();r.__wbg_wasmsearch_free(e,0)}add_chunk(e,t,_,o){try{let c=r.__wbindgen_add_to_stack_pointer(-16),f=g(e,r.__wbindgen_export,r.__wbindgen_export2),p=u,y=ne(t,r.__wbindgen_export),x=u,O=g(_,r.__wbindgen_export,r.__wbindgen_export2),W=u;r.wasmindexbuilder_add_chunk(c,this.__wbg_ptr,f,p,y,x,O,W,o);var s=a().getInt32(c+4*0,!0),i=a().getInt32(c+4*1,!0);if(i)throw l(s)}finally{r.__wbindgen_add_to_stack_pointer(16)}}doc_count(){return r.wasmindexbuilder_doc_count(this.__wbg_ptr)>>>0}static load(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=A(e,r.__wbindgen_export),f=u,p=A(t,r.__wbindgen_export),y=u;r.wasmsearch_load(i,c,f,p,y);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return n.__wrap(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}remove_file(e){let t=g(e,r.__wbindgen_export,r.__wbindgen_export2),_=u;return r.wasmsearch_remove_file(this.__wbg_ptr,t,_)>>>0}save_index(){try{let i=r.__wbindgen_add_to_stack_pointer(-16);r.wasmsearch_save_index(i,this.__wbg_ptr);var e=a().getInt32(i+4*0,!0),t=a().getInt32(i+4*1,!0),_=a().getInt32(i+4*2,!0),o=a().getInt32(i+4*3,!0);if(o)throw l(_);var s=$(e,t).slice();return r.__wbindgen_export4(e,t*1,1),s}finally{r.__wbindgen_add_to_stack_pointer(16)}}search(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u;r.wasmsearch_search(i,this.__wbg_ptr,c,f,t);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return l(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}search_keywords(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u;r.wasmsearch_search_keywords(i,this.__wbg_ptr,c,f,t);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return l(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}search_semantic(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u;r.wasmsearch_search_semantic(i,this.__wbg_ptr,c,f,t);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return l(_)}finally{r.__wbindgen_add_to_stack_pointer(16)}}update_file(e,t){try{let i=r.__wbindgen_add_to_stack_pointer(-16),c=g(e,r.__wbindgen_export,r.__wbindgen_export2),f=u,p=g(t,r.__wbindgen_export,r.__wbindgen_export2),y=u;r.wasmsearch_update_file(i,this.__wbg_ptr,c,f,p,y);var _=a().getInt32(i+4*0,!0),o=a().getInt32(i+4*1,!0),s=a().getInt32(i+4*2,!0);if(s)throw l(o);return _>>>0}finally{r.__wbindgen_add_to_stack_pointer(16)}}};Symbol.dispose&&(v.prototype[Symbol.dispose]=v.prototype.free);function ee(n){r.set_debug_logging(n)}function oe(){return{__proto__:null,"./kjarni_wasm_bg.js":{__proto__:null,__wbg_Error_8c4e43fe74559d73:function(e,t){let _=Error(k(e,t));return b(_)},__wbg_String_8f0eb39a4a4c2f66:function(e,t){let _=String(d(t)),o=g(_,r.__wbindgen_export,r.__wbindgen_export2),s=u;a().setInt32(e+4,s,!0),a().setInt32(e+0,o,!0)},__wbg___wbindgen_debug_string_0bc8482c6e3508ae:function(e,t){let _=P(d(t)),o=g(_,r.__wbindgen_export,r.__wbindgen_export2),s=u;a().setInt32(e+4,s,!0),a().setInt32(e+0,o,!0)},__wbg___wbindgen_is_function_0095a73b8b156f76:function(e){return typeof d(e)=="function"},__wbg___wbindgen_is_string_cd444516edc5b180:function(e){return typeof d(e)=="string"},__wbg___wbindgen_is_undefined_9e4d92534c42d778:function(e){return d(e)===void 0},__wbg___wbindgen_string_get_72fb696202c56729:function(e,t){let _=d(t),o=typeof _=="string"?_:void 0;var s=z(o)?0:g(o,r.__wbindgen_export,r.__wbindgen_export2),i=u;a().setInt32(e+4,i,!0),a().setInt32(e+0,s,!0)},__wbg___wbindgen_throw_be289d5034ed271b:function(e,t){throw new Error(k(e,t))},__wbg__wbg_cb_unref_d9b87ff7982e3b21:function(e){d(e)._wbg_cb_unref()},__wbg_arrayBuffer_bb54076166006c39:function(){return B(function(e){let t=d(e).arrayBuffer();return b(t)},arguments)},__wbg_call_389efe28435a9388:function(){return B(function(e,t){let _=d(e).call(d(t));return b(_)},arguments)},__wbg_call_4708e0c13bdc8e95:function(){return B(function(e,t,_){let o=d(e).call(d(t),d(_));return b(o)},arguments)},__wbg_error_7534b8e9a36f1ab4:function(e,t){let _,o;try{_=e,o=t,console.error(k(e,t))}finally{r.__wbindgen_export4(_,o,1)}},__wbg_fetch_4f06ca81d87798ba:function(e,t,_){let o=d(e).fetch(k(t,_));return b(o)},__wbg_fetch_d1488f40cef1e210:function(e,t,_){let o=d(e).fetch(k(t,_));return b(o)},__wbg_getRandomValues_1c61fac11405ffdc:function(){return B(function(e,t){globalThis.crypto.getRandomValues($(e,t))},arguments)},__wbg_instanceof_Response_ee1d54d79ae41977:function(e){let t;try{t=d(e)instanceof Response}catch(o){t=!1}return t},__wbg_instanceof_Window_ed49b2db8df90359:function(e){let t;try{t=d(e)instanceof Window}catch(o){t=!1}return t},__wbg_instanceof_WorkerGlobalScope_07b9d5514ff0156e:function(e){let t;try{t=d(e)instanceof WorkerGlobalScope}catch(o){t=!1}return t},__wbg_length_32ed9a279acd054c:function(e){return d(e).length},__wbg_log_6b5ca2e6124b2808:function(e){console.log(d(e))},__wbg_new_361308b2356cecd0:function(){let e=new Object;return b(e)},__wbg_new_3eb36ae241fe6f44:function(){let e=new Array;return b(e)},__wbg_new_8a6f238a6ece86ea:function(){let e=new Error;return b(e)},__wbg_new_b5d9e2fb389fef91:function(e,t){try{var _={a:e,b:t},o=(i,c)=>{let f=_.a;_.a=0;try{return se(f,_.b,i,c)}finally{_.a=f}};let s=new Promise(o);return b(s)}finally{_.a=_.b=0}},__wbg_new_dca287b076112a51:function(){return b(new Map)},__wbg_new_dd2b680c8bf6ae29:function(e){let t=new Uint8Array(d(e));return b(t)},__wbg_new_no_args_1c7c842f08d00ebb:function(e,t){let _=new Function(k(e,t));return b(_)},__wbg_now_a3af9a2f4bbaa4d1:function(){return Date.now()},__wbg_prototypesetcall_bdcdcc5842e4d77d:function(e,t,_){Uint8Array.prototype.set.call($(e,t),d(_))},__wbg_queueMicrotask_0aa0a927f78f5d98:function(e){let t=d(e).queueMicrotask;return b(t)},__wbg_queueMicrotask_5bb536982f78a56f:function(e){queueMicrotask(d(e))},__wbg_resolve_002c4b7d9d8f6b64:function(e){let t=Promise.resolve(d(e));return b(t)},__wbg_set_1eb0999cf5d27fc8:function(e,t,_){let o=d(e).set(d(t),d(_));return b(o)},__wbg_set_3f1d0b984ed272ed:function(e,t,_){d(e)[l(t)]=l(_)},__wbg_set_f43e577aea94465b:function(e,t,_){d(e)[t>>>0]=l(_)},__wbg_stack_0ed75d68575b0f3c:function(e,t){let _=d(t).stack,o=g(_,r.__wbindgen_export,r.__wbindgen_export2),s=u;a().setInt32(e+4,s,!0),a().setInt32(e+0,o,!0)},__wbg_static_accessor_GLOBAL_12837167ad935116:function(){let e=typeof global=="undefined"?null:global;return z(e)?0:b(e)},__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f:function(){let e=typeof globalThis=="undefined"?null:globalThis;return z(e)?0:b(e)},__wbg_static_accessor_SELF_a621d3dfbb60d0ce:function(){let e=typeof self=="undefined"?null:self;return z(e)?0:b(e)},__wbg_static_accessor_WINDOW_f8727f0cf888e0bd:function(){let e=typeof window=="undefined"?null:window;return z(e)?0:b(e)},__wbg_text_083b8727c990c8c0:function(){return B(function(e){let t=d(e).text();return b(t)},arguments)},__wbg_then_0d9fe2c7b1857d32:function(e,t,_){let o=d(e).then(d(t),d(_));return b(o)},__wbg_then_b9e7b3b5f1a9e1b5:function(e,t){let _=d(e).then(d(t));return b(_)},__wbg_wasmmodel_new:function(e){let t=C.__wrap(e);return b(t)},__wbindgen_cast_0000000000000001:function(e,t){let _=de(e,t,r.__wasm_bindgen_func_elem_1076,ie);return b(_)},__wbindgen_cast_0000000000000002:function(e){return b(e)},__wbindgen_cast_0000000000000003:function(e,t){let _=k(e,t);return b(_)},__wbindgen_cast_0000000000000004:function(e){let t=BigInt.asUintN(64,e);return b(t)},__wbindgen_object_clone_ref:function(e){let t=d(e);return b(t)},__wbindgen_object_drop_ref:function(e){l(e)}}}}function ie(n,e,t){r.__wasm_bindgen_func_elem_1077(n,e,b(t))}function se(n,e,t,_){r.__wasm_bindgen_func_elem_1124(n,e,b(t),b(_))}var Q=typeof FinalizationRegistry=="undefined"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>r.__wbg_wasmencoder_free(n>>>0,1)),X=typeof FinalizationRegistry=="undefined"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>r.__wbg_wasmindexbuilder_free(n>>>0,1)),V=typeof FinalizationRegistry=="undefined"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>r.__wbg_wasmmodel_free(n>>>0,1)),Y=typeof FinalizationRegistry=="undefined"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>r.__wbg_wasmreranker_free(n>>>0,1)),K=typeof FinalizationRegistry=="undefined"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>r.__wbg_wasmsearch_free(n>>>0,1));function b(n){U===m.length&&m.push(m.length+1);let e=U;return U=m[e],m[e]=n,e}var Z=typeof FinalizationRegistry=="undefined"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>n.dtor(n.a,n.b));function P(n){let e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){let o=n.description;return o==null?"Symbol":`Symbol(${o})`}if(e=="function"){let o=n.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(n)){let o=n.length,s="[";o>0&&(s+=P(n[0]));for(let i=1;i<o;i++)s+=", "+P(n[i]);return s+="]",s}let t=/\[object ([^\]]+)\]/.exec(toString.call(n)),_;if(t&&t.length>1)_=t[1];else return toString.call(n);if(_=="Object")try{return"Object("+JSON.stringify(n)+")"}catch(o){return"Object"}return n instanceof Error?`${n.name}: ${n.message}
${n.stack}`:_}function ae(n){n<132||(m[n]=U,U=n)}function ce(n,e){return n=n>>>0,te().subarray(n/4,n/4+e)}function $(n,e){return n=n>>>0,F().subarray(n/1,n/1+e)}var I=null;function a(){return(I===null||I.buffer.detached===!0||I.buffer.detached===void 0&&I.buffer!==r.memory.buffer)&&(I=new DataView(r.memory.buffer)),I}var T=null;function te(){return(T===null||T.byteLength===0)&&(T=new Float32Array(r.memory.buffer)),T}function k(n,e){return n=n>>>0,fe(n,e)}var E=null;function F(){return(E===null||E.byteLength===0)&&(E=new Uint8Array(r.memory.buffer)),E}function d(n){return m[n]}function B(n,e){try{return n.apply(this,e)}catch(t){r.__wbindgen_export3(b(t))}}var m=new Array(128).fill(void 0);m.push(void 0,null,!0,!1);var U=m.length;function z(n){return n==null}function de(n,e,t,_){let o={a:n,b:e,cnt:1,dtor:t},s=(...i)=>{o.cnt++;let c=o.a;o.a=0;try{return _(c,o.b,...i)}finally{o.a=c,s._wbg_cb_unref()}};return s._wbg_cb_unref=()=>{--o.cnt===0&&(o.dtor(o.a,o.b),o.a=0,Z.unregister(o))},Z.register(s,o,o),s}function A(n,e){let t=e(n.length*1,1)>>>0;return F().set(n,t/1),u=n.length,t}function ne(n,e){let t=e(n.length*4,4)>>>0;return te().set(n,t/4),u=n.length,t}function re(n,e){let t=e(n.length*4,4)>>>0,_=a();for(let o=0;o<n.length;o++)_.setUint32(t+4*o,b(n[o]),!0);return u=n.length,t}function g(n,e,t){if(t===void 0){let c=L.encode(n),f=e(c.length,1)>>>0;return F().subarray(f,f+c.length).set(c),u=c.length,f}let _=n.length,o=e(_,1)>>>0,s=F(),i=0;for(;i<_;i++){let c=n.charCodeAt(i);if(c>127)break;s[o+i]=c}if(i!==_){i!==0&&(n=n.slice(i)),o=t(o,_,_=i+n.length*3,1)>>>0;let c=F().subarray(o+i,o+_),f=L.encodeInto(n,c);i+=f.written,o=t(o,_,i,1)>>>0}return u=i,o}function l(n){let e=d(n);return ae(n),e}var N=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});N.decode();var ue=2146435072,G=0;function fe(n,e){return G+=e,G>=ue&&(N=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),N.decode(),G=e),N.decode(F().subarray(n,n+e))}var L=new TextEncoder;"encodeInto"in L||(L.encodeInto=function(n,e){let t=L.encode(n);return e.set(t),{read:n.length,written:t.length}});var u=0,be,r;function le(n,e){return r=n.exports,be=e,I=null,T=null,E=null,r.__wbindgen_start(),r}async function ge(n,e){if(typeof Response=="function"&&n instanceof Response){if(typeof WebAssembly.instantiateStreaming=="function")try{return await WebAssembly.instantiateStreaming(n,e)}catch(o){if(n.ok&&t(n.type)&&n.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let _=await n.arrayBuffer();return await WebAssembly.instantiate(_,e)}else{let _=await WebAssembly.instantiate(n,e);return _ instanceof WebAssembly.Instance?{instance:_,module:n}:_}function t(_){switch(_){case"basic":case"cors":case"default":return!0}return!1}}async function _e(n){if(r!==void 0)return r;n!==void 0&&(Object.getPrototypeOf(n)===Object.prototype?{module_or_path:n}=n:console.warn("using deprecated parameters for the initialization function; pass a single object instead")),n===void 0&&(n=new URL("kjarni_wasm_bg.wasm",""));let e=oe();(typeof n=="string"||typeof Request=="function"&&n instanceof Request||typeof URL=="function"&&n instanceof URL)&&(n=fetch(n));let{instance:t,module:_}=await ge(await n,e);return le(t,_)}var h=null,D=null,j=null,M=null;function w(n,e){e?self.postMessage(n,e):self.postMessage(n)}var H=!1,J=[];self.onmessage=n=>{J.push(n),we()};async function we(){if(!H){for(H=!0;J.length>0;){let e=J.shift().data;try{switch(e.type){case"init":await pe(e);break;case"build_start":ye(e);break;case"add_encoded_chunks":he(e);break;case"build_finish":me(e);break;case"search":xe(e);break;case"rerank":ke(e);break;case"update_file":Ie(e);break;case"remove_file":ve(e);break;case"save_index":Ae(e);break;case"set_logging":ee(e.enabled),w({type:"logging_set",id:e.id});break;default:w({type:"error",id:e.id,error:`Unknown: ${e.type}`})}}catch(t){w({type:"error",id:e.id,error:t.message||String(t)})}}H=!1}}async function pe(n){if(await _e(n.wasmBytes),M=new Uint8Array(n.encoderBytes),n.rerankerBytes)try{D=S.load(new Uint8Array(n.rerankerBytes))}catch(e){console.error("Worker: Failed to load reranker:",e)}if(n.indexBytes)try{h=v.load(M,new Uint8Array(n.indexBytes)),w({type:"init_done",id:n.id,hasIndex:!0,docCount:h.doc_count(),hasReranker:D!==null});return}catch(e){console.error("Worker: Failed to load index:",e)}w({type:"init_done",id:n.id,hasIndex:!1,docCount:0,hasReranker:D!==null})}function ye(n){if(!M){w({type:"error",id:n.id,error:"No encoder loaded"});return}j=R.new(M),w({type:"build_started",id:n.id})}function he(n){if(!j){w({type:"error",id:n.id,error:"No builder \u2014 call build_start first"});return}let e=n.chunks,t=0;for(let _ of e)try{j.add_chunk(_.text,new Float32Array(_.embedding),_.source,_.chunk_index),t++}catch(o){console.warn(`Worker: Failed to add chunk from ${_.source}: ${o}`)}w({type:"chunks_added",id:n.id,added:t})}function me(n){if(!j||!M){w({type:"error",id:n.id,error:"No builder or encoder"});return}let e=j.finish();h=v.load(M,new Uint8Array(e)),j=null;let t=e.buffer||e;w({type:"build_done",id:n.id,docCount:h.doc_count(),indexBytes:e},[t])}function xe(n){if(!h){w({type:"search_result",id:n.id,results:[]});return}let t=h.search(n.query,n.limit||20).map(_=>{let o=_.metadata instanceof Map?Object.fromEntries(_.metadata):_.metadata||{};return{score:_.score,text:_.text,source:o.source||"unknown",metadata:o}});w({type:"search_result",id:n.id,results:t})}function ke(n){if(!D){w({type:"rerank_result",id:n.id,results:[]});return}let t=D.rerank(n.query,n.docs,n.limit||5).map(_=>({index:_.index,score:_.score,text:_.text}));w({type:"rerank_result",id:n.id,results:t})}function Ie(n){if(!h){w({type:"error",id:n.id,error:"No search index loaded"});return}let e=0;try{e=h.update_file(n.text,n.path)}catch(t){w({type:"error",id:n.id,error:`Update failed: ${t}`});return}w({type:"file_updated",id:n.id,path:n.path,chunks:e,docCount:h.doc_count()})}function ve(n){if(!h){w({type:"error",id:n.id,error:"No search index loaded"});return}let e=h.remove_file(n.path);w({type:"file_removed",id:n.id,path:n.path,removed:e,docCount:h.doc_count()})}function Ae(n){if(!h){w({type:"error",id:n.id,error:"No search index to save"});return}let e=h.save_index(),t=e.buffer||e;w({type:"index_saved",id:n.id,docCount:h.doc_count(),indexBytes:e},[t])}})();