(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const u of i)if(u.type==="childList")for(const h of u.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function o(i){const u={};return i.integrity&&(u.integrity=i.integrity),i.referrerPolicy&&(u.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?u.credentials="include":i.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(i){if(i.ep)return;i.ep=!0;const u=o(i);fetch(i.href,u)}})();const _e=new Worker(new URL("/assets/db-worker-AHwpujSZ.js",import.meta.url),{type:"module"});let ar=0,Ye=null;const De=new Map;function kn(){return Ye||(Ye=new Promise((r,n)=>{_e.onmessage=s=>{const i=s.data;if(i.type==="ready")return;const u=De.get(i.id);u&&(De.delete(i.id),i.type=="success"?u.resolve(i.data):u.reject(new Error(i.error??i.message??"Неизвестная ошибка Worker")))},_e.onerror=s=>{console.error("[SQLite Worker] Ошибка:",s),n(new Error("Ошибка Worker"))};const o=++ar;De.set(o,{resolve:r,reject:n}),_e.postMessage({type:"start",id:o})}),Ye)}function $n(r,n){return new Promise((o,s)=>{if(!_e){s(new Error("Worker не создан"));return}const i=++ar;De.set(i,{resolve:o,reject:s}),_e.postMessage({type:r,id:i,...n})})}async function Ae(r,n){return await $n("query",{sql:r,params:n??[]})}function Qn(r){if(r==null)return[];const n=String(r).trim();return n?n.split(/[,\s;]+/).map(o=>o.trim()).filter(o=>o.length>0):[]}function Tn(r){const n=new Map;if(r==null)return n;const o=String(r);if(!o)return n;const s=o.split("");for(let i=0;i+10?`WHERE ${n.join(" AND ")}`:"",params:o}}async function Nn(r={}){const{clause:n,params:o}=or(r),i=(await Ae(`SELECT COUNT(*) as cnt FROM words ${n}`,o))[0]?.cnt;return typeof i=="number"?i:Number(i??0)}async function jt(r={}){const{clause:n,params:o}=or(r),s=Math.max(1,Math.min(r.limit??50,500)),i=Math.max(0,r.offset??0);return(await Ae(`SELECT id, key, value, tags, more, group_id FROM words ${n} ORDER BY id LIMIT ? OFFSET ?`,[...o,s,i])).map(Fn)}async function Hn(){return(await Ae("SELECT id, name FROM word_groups ORDER BY id")).map(n=>({id:Number(n.id),name:String(n.name??"")}))}async function Pn(){return(await Ae("SELECT id, name, identifier FROM custom_fields ORDER BY id")).map(n=>({id:Number(n.id),name:String(n.name??""),identifier:String(n.identifier??"")}))}const Ut="japanese_app.db";async function Ct(){return navigator.storage.getDirectory()}async function _n(r){r[18]=1,r[19]=1;const o=await(await Ct()).getFileHandle(Ut,{create:!0}),s=o.createSyncAccessHandle;if(typeof s=="function")try{const u=await s.call(o);try{u.truncate(0),u.write(r,{at:0}),u.flush()}finally{u.close()}return}catch{}const i=await o.createWritable();try{await i.truncate(0);const u=new Uint8Array(r.length);u.set(r),await i.write(u)}finally{await i.close()}}async function qn(){const r=await Ct();let n;try{n=await r.getFileHandle(Ut)}catch{throw new Error("Локальная база не найдена — сначала скачай сохранение")}const o=await n.getFile();if(o.size===0)throw new Error("Локальная база пуста");return new Uint8Array(await o.arrayBuffer())}async function Ge(){try{return(await(await(await Ct()).getFileHandle(Ut)).getFile()).size>0}catch{return!1}}var Ln=ArrayBuffer,z=Uint8Array,je=Uint16Array,Rn=Int16Array,et=Int32Array,ft=function(r,n,o){if(z.prototype.slice)return z.prototype.slice.call(r,n,o);(n==null||n<0)&&(n=0),(o==null||o>r.length)&&(o=r.length);var s=new z(o-n);return s.set(r.subarray(n,o)),s},qe=function(r,n,o,s){if(z.prototype.fill)return z.prototype.fill.call(r,n,o,s);for((o==null||o<0)&&(o=0),(s==null||s>r.length)&&(s=r.length);or.length)&&(s=r.length);o2046MB)","invalid block type","FSE accuracy too high","match distance too far back","unexpected EOF"],B=function(r,n,o){var s=new Error(n||Jn[r]);if(s.code=r,Error.captureStackTrace&&Error.captureStackTrace(s,B),!o)throw s;return s},Wt=function(r,n,o){for(var s=0,i=0;s>>0},Kn=function(r,n){var o=r[0]|r[1]<<8|r[2]<<16;if(o==3126568&&r[3]==253){var s=r[4],i=s>>5&1,u=s>>2&1,h=s&3,w=s>>6;s&8&&B(0);var U=6-i,M=h==3?4:h,b=Wt(r,U,M);U+=M;var F=w?1<>3);y=Q+(Q>>3)*(r[5]&7)}y>2145386496&&B(1);var m=new z((n==1?N||y:n?0:y)+12);return m[0]=1,m[4]=4,m[8]=8,{b:U+F,y:0,l:0,d:b,w:n&&n!=1?n:m.subarray(12),e:y,o:new et(m.buffer,0,3),u:N,c:u,m:Math.min(131072,y)}}else if((o>>4|r[3]<<20)==25481893)return Sn(r,4)+8;B(0)},Ce=function(r){for(var n=0;1<o&&B(3);for(var u=1<0;){var X=Ce(h+1),R=s>>3,Y=(1<>(s&7)&Y,E=(1<E&&(K-=O)),N[++w]=--K,K==-1?(h+=K,x[--b]=w):h-=K,!K)do{var ee=s>>3;U=(r[ee]|r[ee+1]<<8)>>(s&7)&3,s+=2,w+=U}while(U==3)}(w>255||h)&&B(0);for(var G=0,re=(u>>1)+(u>>3)+3,V=u-1,j=0;j<=w;++j){var H=N[j];if(H<1){y[j]=-H;continue}for(M=0;M=b)}}for(G&&B(0),M=0;M>3,{b:i,s:x,n:I,t:Q}]},Xn=function(r,n){var o=0,s=-1,i=new z(292),u=r[n],h=i.subarray(0,256),w=i.subarray(256,268),U=new je(i.buffer,268);if(u<128){var M=Le(r,n+1,6),b=M[0],F=M[1];n+=u;var N=b<<3,y=r[n];y||B(0);for(var Q=0,m=0,x=F.b,I=x,X=(++n<<3)-8+Ce(y);X-=x,!(X>3;if(Q+=(r[R]|r[R+1]<<8)>>(X&7)&(1<>3,m+=(r[R]|r[R+1]<<8)>>(X&7)&(1<255&&B(0)}else{for(s=u-127;o>4,h[o+1]=Y&15}++n}var K=0;for(o=0;o11&&B(0),K+=E&&1<0;--o){var j=U[o];qe(V,o,j,U[o-1]=j+w[o]*(1<w&&F>3,y=(r[N]|r[N+1]<<8|r[N+2]<<16)>>(b&7);U=(U<>2,h=u<<1,w=u+h;Pe(r.subarray(s,s+=r[0]|r[1]<<8),n.subarray(0,u),o),Pe(r.subarray(s,s+=r[2]|r[3]<<8),n.subarray(u,h),o),Pe(r.subarray(s,s+=r[4]|r[5]<<8),n.subarray(h,w),o),Pe(r.subarray(s),n.subarray(w),o)},Dn=function(r,n,o){var s,i=n.b,u=r[i],h=u>>1&3;n.l=u&1;var w=u>>3|r[i+1]<<5|r[i+2]<<13,U=(i+=3)+w;if(h==1)return i>=r.length?void 0:(n.b=i+1,o?(qe(o,r[i],n.y,n.y+=w),o):qe(new z(w),r[i]));if(!(U>r.length)){if(h==0)return n.b=U,o?(o.set(r.subarray(i,U),n.y),n.y+=w,o):ft(r,i,U);if(h==2){var M=r[i],b=M&3,F=M>>2&3,N=M>>4,y=0,Q=0;b<2?F&1?N|=r[++i]<<4|(F&2&&r[++i]<<12):N=M>>3:(Q=F,F<2?(N|=(r[++i]&63)<<4,y=r[i]>>6|r[++i]<<2):F==2?(N|=r[++i]<<4|(r[++i]&3)<<12,y=r[i]>>2|r[++i]<<6):(N|=r[++i]<<4|(r[++i]&63)<<12,y=r[i]>>6|r[++i]<<2|r[++i]<<10)),++i;var m=o?o.subarray(n.y,n.y+n.m):new z(n.m),x=m.length-N;if(b==0)m.set(r.subarray(i,i+=N),x);else if(b==1)qe(m,r[i++],x);else{var I=n.h;if(b==2){var X=Xn(r,i);y+=i-(i=X[0]),n.h=I=X[1]}else I||B(0);(Q?Yn:Pe)(r.subarray(i,i+=y),m.subarray(x),I)}var R=r[i++];if(R){R==255?R=(r[i++]|r[i++]<<8)+32512:R>127&&(R=R-128<<8|r[i++]);var Y=r[i++];Y&3&&B(0);for(var K=[zn,Vn,On],E=2;E>-1;--E){var O=Y>>(E<<1)+2&3;if(O==1){var D=new z([0,0,r[i++]]);K[E]={s:D.subarray(2,3),n:D.subarray(0,1),t:new je(D.buffer,0,1),b:0}}else O==2?(s=Le(r,i,9-(E&1)),i=s[0],K[E]=s[1]):O==3&&(n.t||B(0),K[E]=n.t[E])}var ee=n.t=K,G=ee[0],re=ee[1],V=ee[2],j=r[U-1];j||B(0);var H=(U<<3)-8+Ce(j)-V.b,g=H>>3,C=0,k=(r[g]|r[g+1]<<8)>>(H&7)&(1<>3;var P=(r[g]|r[g+1]<<8)>>(H&7)&(1<>3;var _=(r[g]|r[g+1]<<8)>>(H&7)&(1<>3;var we=1<>>(H&7)&we-1);g=(H-=vt[Me])>>3;var ie=Bn[Me]+((r[g]|r[g+1]<<8|r[g+2]<<16)>>(H&7)&(1<>3;var he=Zn[fe]+((r[g]|r[g+1]<<8|r[g+2]<<16)>>(H&7)&(1<>3,k=V.t[k]+((r[g]|r[g+1]<<8)>>(H&7)&(1<>3,_=G.t[_]+((r[g]|r[g+1]<<8)>>(H&7)&(1<>3,P=re.t[P]+((r[g]|r[g+1]<<8)>>(H&7)&(1<3)n.o[2]=n.o[1],n.o[1]=n.o[0],n.o[0]=ne-=3;else{var Ee=ne-(he!=0);Ee?(ne=Ee==3?n.o[0]-1:n.o[Ee],Ee>1&&(n.o[2]=n.o[1]),n.o[1]=n.o[0],n.o[0]=ne):ne=n.o[0]}for(var E=0;Eie&&(ae=ie);for(var E=0;E{throw e},s,i=console.log.bind(console),u=console.error.bind(console),h,w=!1,U,M=t=>t.startsWith("file://"),b=!1;function F(){return Ze.buffer}function N(){if(!D?.buffer?.resizable){var t=F();D=new Int8Array(t),Se=new Int16Array(t),n.HEAPU8=k=new Uint8Array(t),$e=new Uint16Array(t),Ke=new Int32Array(t),_=new Uint32Array(t),qt=new Float32Array(t),Lt=new Float64Array(t),Mt=new BigInt64Array(t),xt=new BigUint64Array(t)}}function y(){b=!0,Fe.A()}function Q(t){t=`Aborted(${t})`,u(t),w=!0,t+=". Build with -sASSERTIONS for more info.",b&&Xt();var e=new WebAssembly.RuntimeError(t);throw e}var m;let x=()=>"";function I(t){if(t==m&&h)return new Uint8Array(h);throw"both async and sync fetching of the wasm failed"}async function X(t){if(!h)try{var e=await s(t);return new Uint8Array(e)}catch{}return I(t)}async function R(t,e){try{var a=await X(t),l=await WebAssembly.instantiate(a,e);return l}catch(c){u(`failed to asynchronously prepare wasm: ${c}`),Q(c)}}async function Y(t,e,a){if(!t&&!M(e))try{var l=fetch(e,{credentials:"same-origin"}),c=await WebAssembly.instantiateStreaming(l,a);return c}catch(d){u(`wasm streaming compile failed: ${d}`),u("falling back to ArrayBuffer instantiation")}return R(e,a)}function K(){var t={a:Mn};return t}async function E(){function t(d){return Fe=d.exports,En(Fe),N(),Fe}function e(d){return t(d.instance)}var a=K();m??=x();var l=await Y(h,m,a),c=e(l);return c}class O{name="ExitStatus";constructor(e){this.message=`Program terminated with exit(${e})`,this.status=e}}var D,ee=()=>Yt,G=t=>{var e=t.getArg(ee(),0);return Zt(e)},re=()=>Vt(),V=t=>Ot(t),j=t=>zt(t),H=globalThis.TextDecoder&&new TextDecoder,g=(t,e,a,l)=>{var c=e+a;if(l)return c;for(;t[e]&&!(e>=c);)++e;return e},C=(t,e=0,a,l)=>{var c=g(t,e,a,l);if(c-e>16&&t.buffer&&H)return H.decode(t.subarray(e,c));for(var d="";e>10,56320|$&1023)}}return d},k,P=(t,e,a)=>t?C(k,t,e,a):"",_,fe=t=>{var e=re(),a=j(4),l=j(4);Bt(t,a,l);var c=_[a>>2],d=_[l>>2],p=P(c);pe(c);var f;return d&&(f=P(d),pe(d)),V(e),[p,f]},ue=t=>{var e=G(t);return fe(e)},Me=t=>{var e=new WebAssembly.Exception(ee(),[t],{traceStack:!0});throw e.message=ue(e),e},Je=()=>Q(""),ve={},xe=t=>{for(;t.length;){var e=t.pop(),a=t.pop();a(e)}};function we(t){return this.fromWireType(_[t>>2])}var ne={},ie={},he={};class Ee extends Error{constructor(e){super(e),this.name="InternalError"}}var ce=t=>{throw new Ee(t)},ae=(t,e,a)=>{t.forEach(f=>he[f]=e);function l(f){var v=a(f);v.length!==t.length&&ce("Mismatched type converter count");for(var $=0;${c[f]=ie[v],++p,p===d.length&&l(c)}));d.length===0&&l(c)},tt=t=>{var e=ve[t];delete ve[t];var a=e.rawConstructor,l=e.rawDestructor,c=e.fields,d=c.map(p=>p.getterReturnType).concat(c.map(p=>p.setterArgumentType));ae([t],d,p=>{var f={};for(var[v,$]of c.entries()){let T=p[v],J=$.getter,L=$.getterContext,S=p[v+c.length],W=$.setter,oe=$.setterContext;f[$.fieldName]={read:A=>T.fromWireType(J(L,A)),write:(A,Z)=>{var me=[];W(oe,A,S.toWireType(me,Z)),xe(me)},optional:T.optional}}return[{name:e.name,fromWireType:T=>{var J={};for(var L in f)J[L]=f[L].read(T);return l(T),J},toWireType:(T,J)=>{for(var L in f)if(!(L in J)&&!f[L].optional)throw new TypeError(`Missing field: "${L}"`);var S=a();for(L in f)f[L].write(S,J[L]);return T!==null&&T.push(l,S),S},readValueFromPointer:we,destructorFunction:l}]})},te=t=>{for(var e="";;){var a=k[t++];if(!a)return e;e+=String.fromCharCode(a)}};class ke extends Error{constructor(e){super(e),this.name="BindingError"}}var q=t=>{throw new ke(t)};function hr(t,e,a={}){var l=e.name;if(t||q(`type "${l}" must have a positive integer typeid pointer`),ie.hasOwnProperty(t)){if(a.ignoreDuplicateRegistrations)return;q(`Cannot register type '${l}' twice`)}if(ie[t]=e,delete he[t],ne.hasOwnProperty(t)){var c=ne[t];delete ne[t],c.forEach(d=>d())}}function de(t,e,a={}){return hr(t,e,a)}var Se,$e,Ke,Mt,xt,kt=(t,e,a)=>{switch(e){case 1:return a?l=>D[l]:l=>k[l];case 2:return a?l=>Se[l>>1]:l=>$e[l>>1];case 4:return a?l=>Ke[l>>2]:l=>_[l>>2];case 8:return a?l=>Mt[l>>3]:l=>xt[l>>3];default:throw new TypeError(`invalid integer width (${e}): ${t}`)}},gr=(t,e,a,l,c)=>{e=te(e);let d=l===0n,p=f=>f;if(d){let f=a*8;p=v=>BigInt.asUintN(f,v),c=p(c)}de(t,{name:e,fromWireType:p,toWireType:(f,v)=>(typeof v=="number"&&(v=BigInt(v)),v),readValueFromPointer:kt(e,a,!d),destructorFunction:null})},wr=(t,e,a,l)=>{e=te(e),de(t,{name:e,fromWireType:function(c){return!!c},toWireType:function(c,d){return d?a:l},readValueFromPointer:function(c){return this.fromWireType(k[c])},destructorFunction:null})},mr=t=>({count:t.count,deleteScheduled:t.deleteScheduled,preservePointerOnDelete:t.preservePointerOnDelete,ptr:t.ptr,ptrType:t.ptrType,smartPtr:t.smartPtr,smartPtrType:t.smartPtrType}),rt=t=>{function e(a){return a.$$.ptrType.registeredClass.name}q(e(t)+" instance already deleted")},nt=!1,$t=t=>{},vr=t=>{t.smartPtr?t.smartPtrType.rawDestructor(t.smartPtr):t.ptrType.registeredClass.rawDestructor(t.ptr)},Qt=t=>{t.count.value-=1;var e=t.count.value===0;e&&vr(t)},Qe=t=>globalThis.FinalizationRegistry?(nt=new FinalizationRegistry(e=>{Qt(e.$$)}),Qe=e=>{var a=e.$$,l=!!a.smartPtr;if(l){var c={$$:a};nt.register(e,c,e)}return e},$t=e=>nt.unregister(e),Qe(t)):(Qe=e=>e,t),yr=()=>{let t=Xe.prototype;Object.assign(t,{isAliasOf(a){if(!(this instanceof Xe)||!(a instanceof Xe))return!1;var l=this.$$.ptrType.registeredClass,c=this.$$.ptr;a.$$=a.$$;for(var d=a.$$.ptrType.registeredClass,p=a.$$.ptr;l.baseClass;)c=l.upcast(c),l=l.baseClass;for(;d.baseClass;)p=d.upcast(p),d=d.baseClass;return l===d&&c===p},clone(){if(this.$$.ptr||rt(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var a=Qe(Object.create(Object.getPrototypeOf(this),{$$:{value:mr(this.$$)}}));return a.$$.count.value+=1,a.$$.deleteScheduled=!1,a},delete(){this.$$.ptr||rt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),$t(this),Qt(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)},isDeleted(){return!this.$$.ptr},deleteLater(){return this.$$.ptr||rt(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&q("Object already scheduled for deletion"),this.$$.deleteScheduled=!0,this}});let e=Symbol.dispose;e&&(t[e]=t.delete)};function Xe(){}var Tt=(t,e)=>Object.defineProperty(e,"name",{value:t}),Ft={},at=(t,e,a)=>{if(t[e].overloadTable===void 0){var l=t[e];t[e]=function(...c){return t[e].overloadTable.hasOwnProperty(c.length)||q(`Function '${a}' called with an invalid number of arguments (${c.length}) - expects one of (${t[e].overloadTable})!`),t[e].overloadTable[c.length].apply(this,c)},t[e].overloadTable=[],t[e].overloadTable[l.argCount]=l}},br=(t,e,a)=>{n.hasOwnProperty(t)?(q(`Cannot register public name '${t}' twice`),at(n,t,t),n[t].overloadTable.hasOwnProperty(a)&&q(`Cannot register multiple overloads of a function with the same number of arguments (${a})!`),n[t].overloadTable[a]=e):(n[t]=e,n[t].argCount=a)},Ur=48,Cr=57,Er=t=>{t=t.replace(/[^a-zA-Z0-9_]/g,"$");var e=t.charCodeAt(0);return e>=Ur&&e<=Cr?`_${t}`:t};function Mr(t,e,a,l,c,d,p,f){this.name=t,this.constructor=e,this.instancePrototype=a,this.rawDestructor=l,this.baseClass=c,this.getActualType=d,this.upcast=p,this.downcast=f,this.pureVirtualFunctions=[]}var ot=(t,e,a)=>{for(;e!==a;)e.upcast||q(`Expected null or instance of ${a.name}, got an instance of ${e.name}`),t=e.upcast(t),e=e.baseClass;return t},it=t=>{if(t===null)return"null";var e=typeof t;return e==="object"||e==="array"||e==="function"?t.toString():""+t};function xr(t,e){if(e===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;e.$$||q(`Cannot pass "${it(e)}" as a ${this.name}`),e.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`);var a=e.$$.ptrType.registeredClass,l=ot(e.$$.ptr,a,this.registeredClass);return l}function kr(t,e){var a;if(e===null)return this.isReference&&q(`null is not a valid ${this.name}`),this.isSmartPointer?(a=this.rawConstructor(),t!==null&&t.push(this.rawDestructor,a),a):0;(!e||!e.$$)&&q(`Cannot pass "${it(e)}" as a ${this.name}`),e.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.isConst&&e.$$.ptrType.isConst&&q(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);var l=e.$$.ptrType.registeredClass;if(a=ot(e.$$.ptr,l,this.registeredClass),this.isSmartPointer)switch(e.$$.smartPtr===void 0&&q("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:e.$$.smartPtrType===this?a=e.$$.smartPtr:q(`Cannot convert argument of type ${e.$$.smartPtrType?e.$$.smartPtrType.name:e.$$.ptrType.name} to parameter type ${this.name}`);break;case 1:a=e.$$.smartPtr;break;case 2:if(e.$$.smartPtrType===this)a=e.$$.smartPtr;else{var c=e.clone();a=this.rawShare(a,ut.toHandle(()=>c.delete())),t!==null&&t.push(this.rawDestructor,a)}break;default:q("Unsupported sharing policy")}return a}function $r(t,e){if(e===null)return this.isReference&&q(`null is not a valid ${this.name}`),0;e.$$||q(`Cannot pass "${it(e)}" as a ${this.name}`),e.$$.ptr||q(`Cannot pass deleted object as a pointer of type ${this.name}`),e.$$.ptrType.isConst&&q(`Cannot convert argument of type ${e.$$.ptrType.name} to parameter type ${this.name}`);var a=e.$$.ptrType.registeredClass,l=ot(e.$$.ptr,a,this.registeredClass);return l}var Nt=(t,e,a)=>{if(e===a)return t;if(a.baseClass===void 0)return null;var l=Nt(t,e,a.baseClass);return l===null?null:a.downcast(l)},Qr={},Tr=(t,e)=>{for(e===void 0&&q("ptr should not be undefined");t.baseClass;)e=t.upcast(e),t=t.baseClass;return e},Fr=(t,e)=>(e=Tr(t,e),Qr[e]),Oe=(t,e)=>{(!e.ptrType||!e.ptr)&&ce("makeClassHandle requires ptr and ptrType");var a=!!e.smartPtrType,l=!!e.smartPtr;return a!==l&&ce("Both smartPtrType and smartPtr must be specified"),e.count={value:1},Qe(Object.create(t,{$$:{value:e,writable:!0}}))};function Nr(t){var e=this.getPointee(t);if(!e)return this.destructor(t),null;var a=Fr(this.registeredClass,e);if(a!==void 0){if(a.$$.count.value===0)return a.$$.ptr=e,a.$$.smartPtr=t,a.clone();var l=a.clone();return this.destructor(t),l}function c(){return this.isSmartPointer?Oe(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:e,smartPtrType:this,smartPtr:t}):Oe(this.registeredClass.instancePrototype,{ptrType:this,ptr:t})}var d=this.registeredClass.getActualType(e),p=Ft[d];if(!p)return c.call(this);var f;this.isConst?f=p.constPointerType:f=p.pointerType;var v=Nt(e,this.registeredClass,f.registeredClass);return v===null?c.call(this):this.isSmartPointer?Oe(f.registeredClass.instancePrototype,{ptrType:f,ptr:v,smartPtrType:this,smartPtr:t}):Oe(f.registeredClass.instancePrototype,{ptrType:f,ptr:v})}var Hr=()=>{Object.assign(ze.prototype,{getPointee(t){return this.rawGetPointee&&(t=this.rawGetPointee(t)),t},destructor(t){this.rawDestructor?.(t)},readValueFromPointer:we,fromWireType:Nr})};function ze(t,e,a,l,c,d,p,f,v,$,T){this.name=t,this.registeredClass=e,this.isReference=a,this.isConst=l,this.isSmartPointer=c,this.pointeeType=d,this.sharingPolicy=p,this.rawGetPointee=f,this.rawConstructor=v,this.rawShare=$,this.rawDestructor=T,!c&&e.baseClass===void 0?l?(this.toWireType=xr,this.destructorFunction=null):(this.toWireType=$r,this.destructorFunction=null):this.toWireType=kr}var Pr=(t,e,a)=>{n.hasOwnProperty(t)||ce("Replacing nonexistent public symbol"),n[t].overloadTable!==void 0&&a!==void 0?n[t].overloadTable[a]=e:(n[t]=e,n[t].argCount=a)},_r=t=>Dt.get(t),le=(t,e,a=!1)=>{t=te(t);function l(){var d=_r(e);return d}var c=l();return typeof c!="function"&&q(`unknown function pointer with signature ${t}: ${e}`),c};class qr extends Error{}var Lr=t=>{var e=St(t),a=te(e);return pe(e),a},Ve=(t,e)=>{var a=[],l={};function c(d){if(!l[d]&&!ie[d]){if(he[d]){he[d].forEach(c);return}a.push(d),l[d]=!0}}throw e.forEach(c),new qr(`${t}: `+a.map(Lr).join([", "]))},Rr=(t,e,a,l,c,d,p,f,v,$,T,J,L)=>{T=te(T),d=le(c,d),f&&=le(p,f),$&&=le(v,$),L=le(J,L);var S=Er(T);br(S,function(){Ve(`Cannot construct ${T} due to unbound types`,[l])}),ae([t,e,a],l?[l]:[],W=>{W=W[0];var oe,A;l?(oe=W.registeredClass,A=oe.instancePrototype):A=Xe.prototype;var Z=Tt(T,function(...pt){if(Object.getPrototypeOf(this)!==me)throw new ke(`Use 'new' to construct ${T}`);if(se.constructor_body===void 0)throw new ke(`${T} has no accessible constructor`);var Gt=se.constructor_body[pt.length];if(Gt===void 0)throw new ke(`Tried to invoke ctor of ${T} with invalid number of parameters (${pt.length}) - expected (${Object.keys(se.constructor_body).toString()}) parameters instead!`);return Gt.apply(this,pt)}),me=Object.create(A,{constructor:{value:Z}});Z.prototype=me;var se=new Mr(T,Z,me,L,oe,d,f,$);se.baseClass&&(se.baseClass.__derivedClasses??=[],se.baseClass.__derivedClasses.push(se));var dt=new ze(T,se,!0,!1,!1),ge=new ze(T+"*",se,!1,!1,!1),Be=new ze(T+" const*",se,!1,!0,!1);return Ft[t]={pointerType:ge,constPointerType:Be},Pr(S,Z),[dt,ge,Be]})};function Ir(t){for(var e=1;e{for(var a=[],l=0;l>2]);return a},Ht=t=>{t=t.trim();let e=t.indexOf("(");return e===-1?t:t.slice(0,e)},Jr=(t,e,a,l,c,d,p,f,v)=>{var $=lt(a,l);e=te(e),e=Ht(e),d=le(c,d,f),ae([],[t],T=>{T=T[0];var J=`${T.name}.${e}`;function L(){Ve(`Cannot call ${J} due to unbound types`,$)}e.startsWith("@@")&&(e=Symbol[e.substring(2)]);var S=T.registeredClass.constructor;return S[e]===void 0?(L.argCount=a-1,S[e]=L):(at(S,e,J),S[e].overloadTable[a-1]=L),ae([],$,W=>{var oe=[W[0],null].concat(W.slice(1)),A=st(J,oe,null,d,p);if(S[e].overloadTable===void 0?(A.argCount=a-1,S[e]=A):S[e].overloadTable[a-1]=A,T.registeredClass.__derivedClasses)for(let Z of T.registeredClass.__derivedClasses)Z.constructor.hasOwnProperty(e)||(Z.constructor[e]=A);return[]}),[]})},Sr=(t,e,a,l,c,d)=>{var p=lt(e,a);c=le(l,c),ae([],[t],f=>{f=f[0];var v=`constructor ${f.name}`;if(f.registeredClass.constructor_body===void 0&&(f.registeredClass.constructor_body=[]),f.registeredClass.constructor_body[e-1]!==void 0)throw new ke(`Cannot register multiple constructors with identical number of parameters (${e-1}) for class '${f.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return f.registeredClass.constructor_body[e-1]=()=>{Ve(`Cannot construct ${f.name} due to unbound types`,p)},ae([],p,$=>($.splice(1,0,null),f.registeredClass.constructor_body[e-1]=st(v,$,null,c,d),[])),[]})},Kr=(t,e,a,l,c,d,p,f,v,$)=>{var T=lt(a,l);e=te(e),e=Ht(e),d=le(c,d,v),ae([],[t],J=>{J=J[0];var L=`${J.name}.${e}`;e.startsWith("@@")&&(e=Symbol[e.substring(2)]),f&&J.registeredClass.pureVirtualFunctions.push(e);function S(){Ve(`Cannot call ${L} due to unbound types`,T)}var W=J.registeredClass.instancePrototype,oe=W[e];return oe===void 0||oe.overloadTable===void 0&&oe.className!==J.name&&oe.argCount===a-2?(S.argCount=a-2,S.className=J.name,W[e]=S):(at(W,e,L),W[e].overloadTable[a-2]=S),ae([],T,A=>{var Z=st(L,A,J,d,p);return W[e].overloadTable===void 0?(Z.argCount=a-2,W[e]=Z):W[e].overloadTable[a-2]=Z,[]}),[]})},Pt=[],ye=[0,1,,1,null,1,!0,1,!1,1],_t=[],Xr=t=>{if(t>9&&--ye[t+1]===0){var e=ye[t];ye[t]=void 0;var a=_t[t];a&&(_t[t]=void 0,a(e)),Pt.push(t)}},ut={toValue:t=>(t||q(`Cannot use deleted val. handle = ${t}`),ye[t]),toHandle:t=>{switch(t){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:{let e=Pt.pop()||ye.length;return ye[e]=t,ye[e+1]=1,e}}}},Or={name:"emscripten::val",fromWireType:t=>{var e=ut.toValue(t);return Xr(t),e},toWireType:(t,e)=>ut.toHandle(e),readValueFromPointer:we,destructorFunction:null},zr=t=>de(t,Or),qt,Lt,Vr=(t,e)=>{switch(e){case 4:return function(a){return this.fromWireType(qt[a>>2])};case 8:return function(a){return this.fromWireType(Lt[a>>3])};default:throw new TypeError(`invalid float width (${e}): ${t}`)}},Zr=(t,e,a)=>{e=te(e),de(t,{name:e,fromWireType:l=>l,toWireType:(l,c)=>c,readValueFromPointer:Vr(e,a),destructorFunction:null})},Br=(t,e,a,l,c)=>{e=te(e);let d=l===0,p=v=>v;if(d){var f=32-8*a;p=v=>v<>>f,c=p(c)}de(t,{name:e,fromWireType:p,toWireType:(v,$)=>$,readValueFromPointer:kt(e,a,l!==0),destructorFunction:null})},Yr=(t,e,a)=>{var l=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,BigInt64Array,BigUint64Array],c=l[e];function d(p){var f=_[p>>2],v=_[p+4>>2];return new c(D.buffer,v,f)}a=te(a),de(t,{name:a,fromWireType:d,readValueFromPointer:d},{ignoreDuplicateRegistrations:!0})},Dr=(t,e,a,l)=>{if(!(l>0))return 0;for(var c=a,d=a+l-1,p=0;p=d)break;e[a++]=f}else if(f<=2047){if(a+1>=d)break;e[a++]=192|f>>6,e[a++]=128|f&63}else if(f<=65535){if(a+2>=d)break;e[a++]=224|f>>12,e[a++]=128|f>>6&63,e[a++]=128|f&63}else{if(a+3>=d)break;e[a++]=240|f>>18,e[a++]=128|f>>12&63,e[a++]=128|f>>6&63,e[a++]=128|f&63,p++}}return e[a]=0,a-c},Rt=(t,e,a)=>Dr(t,k,e,a),It=t=>{for(var e=0,a=0;a=55296&&l<=57343?(e+=4,++a):e+=3}return e},Gr=(t,e)=>{e=te(e),de(t,{name:e,fromWireType(a){var l=_[a>>2],c=a+4,d;return d=P(c,l,!0),pe(a),d},toWireType(a,l){l instanceof ArrayBuffer&&(l=new Uint8Array(l));var c,d=typeof l=="string";d||ArrayBuffer.isView(l)&&l.BYTES_PER_ELEMENT==1||q("Cannot pass non-string to std::string"),d?c=It(l):c=l.length;var p=ct(4+c+1),f=p+4;return _[p>>2]=c,d?Rt(l,f,c+1):k.set(l,f),a!==null&&a.push(pe,p),p},readValueFromPointer:we,destructorFunction(a){pe(a)}})},Jt=globalThis.TextDecoder?new TextDecoder("utf-16le"):void 0,jr=(t,e,a)=>{var l=t>>1,c=g($e,l,e/2,a);if(c-l>16&&Jt)return Jt.decode($e.subarray(l,c));for(var d="",p=l;p{if(a<2)return 0;a-=2;for(var l=e,c=a>1]=p,e+=2}return Se[e>>1]=0,e-l},Ar=t=>t.length*2,en=(t,e,a)=>{for(var l="",c=t>>2,d=0;!(d>=e/4);d++){var p=_[c+d];if(!p&&!a)break;l+=String.fromCodePoint(p)}return l},tn=(t,e,a=2147483647)=>{if(a<4)return 0;for(var l=e,c=l+a-4,d=0;d65535&&d++,Ke[e>>2]=p,e+=4,e+4>c)break}return Ke[e>>2]=0,e-l},rn=t=>{for(var e=0,a=0;a65535&&a++,e+=4}return e},nn=(t,e,a)=>{a=te(a);var l,c,d;e===2?(l=jr,c=Wr,d=Ar):(l=en,c=tn,d=rn),de(t,{name:a,fromWireType:p=>{var f=_[p>>2],v=l(p+4,f*e,!0);return pe(p),v},toWireType:(p,f)=>{typeof f!="string"&&q(`Cannot pass non-string to C++ string type ${a}`);var v=d(f),$=ct(4+v+e);return _[$>>2]=v/e,c(f,$+4,v+e),p!==null&&p.push(pe,$),$},readValueFromPointer:we,destructorFunction(p){pe(p)}})},an=(t,e,a,l,c,d)=>{ve[t]={name:te(e),rawConstructor:le(a,l),rawDestructor:le(c,d),fields:[]}},on=(t,e,a,l,c,d,p,f,v,$)=>{ve[t].fields.push({fieldName:te(e),getterReturnType:a,getter:le(l,c),getterContext:d,setterArgumentType:p,setter:le(f,v),setterContext:$})},sn=(t,e)=>{e=te(e),de(t,{isVoid:!0,name:e,fromWireType:()=>{},toWireType:(a,l)=>{}})},ln=()=>{},Te={},un=t=>{if(t instanceof O||t=="unwind")return U;o(1,t)},cn=t=>{U=t,o(t,new O(t))},dn=t=>{if(!w)try{return t()}catch(e){un(e)}},pn=()=>performance.now(),fn=(t,e)=>{if(Te[t]&&(clearTimeout(Te[t].id),delete Te[t]),!e)return 0;var a=setTimeout(()=>{delete Te[t],dn(()=>Kt(t,pn()))},e);return Te[t]={id:a,timeout_ms:e},0},hn=()=>2147483648,gn=(t,e)=>Math.ceil(t/e)*e,wn=t=>{var e=Ze.buffer.byteLength,a=(t-e+65535)/65536|0;try{return Ze.grow(a),N(),1}catch{}},mn=t=>{var e=k.length;t>>>=0;var a=hn();if(t>a)return!1;for(var l=1;l<=4;l*=2){var c=e*(1+.2/l);c=Math.min(c,t+100663296);var d=Math.min(a,gn(Math.max(t,c),65536)),p=wn(d);if(p)return!0}return!1},vn=t=>52;function yn(t,e,a,l){return 70}var bn=[null,[],[]],Un=(t,e)=>{var a=bn[t];!e||e===10?((t===1?i:u)(C(a)),a.length=0):a.push(e)},Cn=(t,e,a,l)=>{for(var c=0,d=0;d>2],f=_[e+4>>2];e+=8;for(var v=0;v>2]=c,0};yr(),Hr(),n.wasmBinary&&(h=n.wasmBinary),n.UTF8ToString=P,n.stringToUTF8=Rt,n.lengthBytesUTF8=It;var St,ct,pe,Kt,Xt,Ot,zt,Vt,Zt,Bt,Yt,Ze,Dt;function En(t){St=t.B,ct=n._malloc=t.C,pe=n._free=t.D,Kt=t.F,Xt=t.G,Ot=t.H,zt=t.I,Vt=t.J,Zt=t.K,Bt=t.L,Ze=t.z,Dt=t.E,Yt=t.M}var Mn={t:Me,x:Je,f:tt,i:gr,l:wr,o:Rr,b:Jr,n:Sr,d:Kr,y:zr,h:Zr,c:Br,a:Yr,k:Gr,g:nn,j:an,e:on,m:sn,w:ln,p:fn,u:mn,s:vn,q:yn,r:Cn,v:cn};async function xn(){!w&&y()}var Fe;return Fe=await E(),await xn(),n}var An=Wn,ea=new Int8Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,90,63,64,65,66,-1,67,68,69,70,71,-1,72,73,52,53,54,55,56,57,58,59,60,61,74,75,76,77,78,79,80,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,81,-1,82,83,84,85,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,86,87,88,89,-1]);function ta(r){let n=new Uint8Array(170930),o=0,s=0,i=0,u=-1;for(let h=0,w=r.length;h127)continue;let M=ea[U];if(!(M<0))if(u<0)u=M;else{u+=M*91,s|=u<88?13:14;do n[o++]=s,s>>>=8,i-=8;while(i>7);u=-1}}return u>=0&&(n[o++]=(s|u<""})}function aa(){yt=void 0}var oa=class{_module;constructor(r){this._module=r}malloc(r){let n=this._module._malloc(r);return{ptr:n,size:r,dispose:()=>this.free({ptr:n,size:r,dispose:()=>{}})}}free(r){this._module._free(r.ptr)}dataToHeap(r){let n=this.malloc(r.byteLength);return this._module.HEAPU8.set(r,n.ptr),n}heapView(r){return this._module.HEAPU8.subarray(r.ptr,r.ptr+r.size)}heapToUint8Array(r){return new Uint8Array([...this.heapView(r)])}lengthBytes(r){return this._module.lengthBytesUTF8(r)}stringToHeap(r){let n=this.lengthBytes(r)+1,o=this._module._malloc(n);return this._module.stringToUTF8(r,o,n),{ptr:o,size:n,dispose:()=>this.free({ptr:o,size:n,dispose:()=>{}})}}heapToString(r){return this._module.UTF8ToString(r.ptr,r.size)}hasFilesystem(){let r=this._module;return r.FS_createPath!==void 0&&r.FS_createDataFile!==void 0&&r.FS_preloadFile!==void 0&&r.FS_unlink!==void 0}createPath(r,n=!0,o=!0){return this._module.FS_createPath("/",r,n,o)}createDataFile(r,n,o=!0,s=!0,i=!0){return this._module.FS_createDataFile("/",r,n,o,s,i)}preloadFile(r,n,o=!0,s=!0,i=!1,u=!0,h=!1){return this._module.FS_preloadFile("/",r,n,o,s,i,u,h)}unlink(r){return this._module.FS_unlink(r)}},Ne,ia=4294967295;function He(r,n){if(!Number.isInteger(r)||r<0||r>ia)throw new Error(`${n} length ${r} is outside the WASM32-safe range`)}function ht(r){if(r.length===0)return new Uint8Array(0);if(r.length===1)return r[0];let n=0;for(let i of r)n+=i.length;let o=new Uint8Array(n),s=0;for(let i of r)o.set(i,s),s+=i.length;return o}var sa=class sr{_mainModule;_zstdClass;_zstd;_compressionLevel;_decompressFrameCompleted=!1;_decompressRemaining=0;_decompressSawInput=!1;constructor(n){this._mainModule=new oa(n),this._zstdClass=n.zstd,this._zstd=new this._zstdClass,this._compressionLevel=this._zstdClass.defaultCLevel()}static load(){return Ne||(Ne=na().then(n=>new sr(n))),Ne}static unload(){aa(),Ne?.then(n=>{n?._zstd?.delete()}),Ne=void 0}copyHeap(n){return this._mainModule.heapView(n).slice()}mallocChecked(n,o){He(n,o);let s=this._mainModule.malloc(n);if(!s.ptr)throw this._mainModule.free(s),new Error(`Failed to allocate ${n} bytes for ${o}`);return s}throwStreamError(n,o){throw new Error(`${n} failed: ${o.errorName||"unknown error"}`)}ensureStreamOk(n,o){o.error&&this.throwStreamError(n,o)}version(){return this._zstdClass.version()}reset(){let n=this._zstd.reset();this.ensureStreamOk("reset",n),this._decompressFrameCompleted=!1,this._decompressRemaining=0,this._decompressSawInput=!1}resetCompression(n){n!==void 0&&(this._compressionLevel=n);let o=this._zstd.resetCompression(this._compressionLevel);this.ensureStreamOk("resetCompression",o)}resetDecompression(){let n=this._zstd.resetDecompression();this.ensureStreamOk("resetDecompression",n),this._decompressFrameCompleted=!1,this._decompressRemaining=0,this._decompressSawInput=!1}setCompressionLevel(n){let o=this._zstd.setCompressionLevel(n);this.ensureStreamOk("setCompressionLevel",o),this._compressionLevel=n}compress(n,o=this.defaultCLevel()){He(n.length,"compress input");let s=this._mainModule.dataToHeap(n);try{if(!s.ptr&&n.length>0)throw new Error("Failed to allocate compress input buffer");let i=this._zstdClass.compressBound(n.length),u=this.mallocChecked(i,"compress output");try{if(u.size=this._zstdClass.compress(u.ptr,i,s.ptr,s.size,o),this._zstdClass.isError(u.size))throw new Error(`compress failed: ${this._zstdClass.getErrorName(u.size)}`);return this.copyHeap(u)}finally{this._mainModule.free(u)}}finally{this._mainModule.free(s)}}compressChunk(n){if(He(n.length,"compressChunk input"),n.length===0)return new Uint8Array(0);let o=this._mainModule.dataToHeap(n);try{if(!o.ptr)throw new Error("Failed to allocate compressChunk input buffer");let s=this._zstdClass.CStreamOutSize(),i=[],u=0;for(;u0&&(h.size=w.produced,i.push(this.copyHeap(h)))}finally{this._mainModule.free(h)}}return ht(i)}finally{this._mainModule.free(o)}}compressEnd(){let n=this._zstdClass.CStreamOutSize(),o=[],s=1;for(;s!==0;){let i=this.mallocChecked(n,"compressEnd output");try{let u=this._zstd.compressEnd(i.ptr,n);if(this.ensureStreamOk("compressEnd",u),u.produced===0&&u.remaining!==0)throw new Error("compressEnd failed: no progress while finishing stream");s=u.remaining,u.produced>0&&(i.size=u.produced,o.push(this.copyHeap(i)))}finally{this._mainModule.free(i)}}return ht(o)}frameContentSize(n){return this._zstdClass.getFrameContentSize(n.ptr,n.size)}decompress(n){He(n.length,"decompress input");let o=this._mainModule.dataToHeap(n);try{if(!o.ptr&&n.length>0)throw new Error("Failed to allocate decompress input buffer");let s=this.frameContentSize(o);if(s.error)throw new Error(`Failed to get frame content size: ${s.errorName}`);let i=s.known;if(i){let u=this._zstdClass.findFrameCompressedSize(o.ptr,o.size);if(this._zstdClass.isError(u))throw new Error(`Failed to find frame compressed size: ${this._zstdClass.getErrorName(u)}`);u0?o.ptr+u:0,b=this._zstd.decompressChunk(w.ptr,s,M,U);if(this.ensureStreamOk("decompressChunk",b),b.consumed===0&&b.produced===0){if(U===0){b.remaining>0&&(this._decompressRemaining=b.remaining);break}throw new Error("decompressChunk failed: no progress while consuming input")}u+=b.consumed,h=b.produced===s&&b.remaining!==0,b.produced>0&&(w.size=b.produced,i.push(this.copyHeap(w))),b.remaining===0?(this._decompressFrameCompleted=!0,this._decompressRemaining=0):this._decompressRemaining=b.remaining}finally{this._mainModule.free(w)}}return ht(i)}finally{this._mainModule.free(o)}}decompressEnd(){if(!this._decompressSawInput)throw new Error("decompressEnd failed: empty compressed input is not a completed frame");if(!this._decompressFrameCompleted||this._decompressRemaining!==0)throw new Error("decompressEnd failed: truncated Zstandard input")}defaultCLevel(){return this._zstdClass.defaultCLevel()}minCLevel(){return this._zstdClass.minCLevel()}maxCLevel(){return this._zstdClass.maxCLevel()}};let gt=null;function la(){return gt||(gt=sa.load()),gt}function ua(r){return r.length>=4&&r[0]===40&&r[1]===181&&r[2]===47&&r[3]===253}function bt(r){const n="SQLite format 3\0";if(r.length/g,">").replace(/"/g,""").replace(/'/g,"'")}function er(r,n,o){const s=r.tagsList[0]??"",i=r.tagsList.length>1?` +${r.tagsList.length-1}`:"",u=Ue(r.tagsList.join(", ")),h=s?`${Ue(s)}${i}`:"",w=r.more.size>0?'':"";return`
`+(o?lr(r,n):"")+"
"}function lr(r,n){const o=[...r.more.entries()].map(([s,i])=>{const u=n.get(s);return`
${u?Ue(u.name):`Поле #${s}`}
${Ue(i)}
`}).join("");return o?`
${o}
`:""}function da(r,n){r.innerHTML=`

📚 Слова

База ещё не проверена.
`;const o=r.querySelector("#home-db-banner"),s=r.querySelector("#home-db-text"),i=r.querySelector("#home-db-go"),u=r.querySelector("#words-search"),h=r.querySelector("#words-group"),w=r.querySelector("#words-count"),U=r.querySelector("#words-status"),M=r.querySelector("#words-list"),b=r.querySelector("#words-more");function F(g,C){o.hidden=!1,s.textContent=g,i.hidden=!1}function N(){o.hidden=!0}i.addEventListener("click",()=>{document.querySelector('.drawer-btn[data-page="sync"]')?.click()});let y=!1,Q=new Map,m=0,x=[],I=null,X=0,R=!1,Y=0,K=0;function E(){const g=h.value;if(g==="")return{search:u.value.trim(),groupId:null};const C=Number(g);return{search:u.value.trim(),groupId:Number.isFinite(C)?C:null}}function O(){b.hidden=!(y&&x.lengther(g,Q,g.id===I)).join(""),w.textContent=m>0?`Показано ${x.length} из ${m}`:"",O()}function ee(g){if(I===g){g!=null&&G(g),I=null;return}I!=null&&G(I),I=g,g!=null&&re(g)}function G(g){const C=M.querySelector(`.word-row-wrap[data-word-id="${g}"]`);if(!C)return;const k=C.querySelector(".word-row"),P=C.querySelector(".word-extra");k&&(k.classList.remove("open"),k.setAttribute("aria-expanded","false")),P&&(P.hidden=!0,P.innerHTML="")}function re(g){const C=x.find(fe=>fe.id===g),k=M.querySelector(`.word-row-wrap[data-word-id="${g}"]`);if(!C||!k)return;const P=k.querySelector(".word-row"),_=k.querySelector(".word-extra");P&&(P.classList.add("open"),P.setAttribute("aria-expanded","true")),_&&(_.hidden=!1,_.innerHTML=lr(C,Q))}function V(g){U.textContent=g,U.hidden=g===""}async function j(){if(!y||R)return;R=!0;const g=++Y,C=E();b.disabled=!0,x.length===0&&V("Загрузка слов…");try{const[k,P]=await Promise.all([Nn({search:C.search,groupId:C.groupId??void 0}),jt({search:C.search,groupId:C.groupId??void 0,limit:At,offset:0})]);if(g!==Y)return;m=k,x=P,X=P.length,I!=null&&!x.some(_=>_.id===I)&&(I=null),D(),V(P.length===0?"По этому запросу слов нет.":""),P.length===0&&m===0&&(w.textContent="Слов в базе пока нет.")}catch(k){if(g!==Y)return;V(`Не удалось загрузить слова: ${k instanceof Error?k.message:String(k)}`)}finally{g===Y&&(R=!1,b.disabled=!1,O())}}async function H(){if(!y||R||x.length>=m)return;R=!0;const g=++Y,C=E();b.disabled=!0,b.textContent="Загрузка…";try{const k=await jt({search:C.search,groupId:C.groupId??void 0,limit:At,offset:X});if(g!==Y)return;x=x.concat(k),X+=k.length,M.insertAdjacentHTML("beforeend",k.map(P=>er(P,Q,P.id===I)).join("")),w.textContent=`Показано ${x.length} из ${m}`,O()}catch(k){if(g!==Y)return;V(`Не удалось догрузить: ${k instanceof Error?k.message:String(k)}`)}finally{g===Y&&(R=!1,b.disabled=!1,O())}}u.addEventListener("input",()=>{window.clearTimeout(K),K=window.setTimeout(()=>{j()},300)}),u.addEventListener("keydown",g=>{g.key==="Enter"&&(window.clearTimeout(K),j())}),h.addEventListener("change",()=>{j()}),b.addEventListener("click",()=>{H()}),M.addEventListener("click",g=>{const C=g.target.closest(".word-row");if(!C||C.disabled)return;const k=Number(C.dataset.wordId);Number.isFinite(k)&&ee(I===k?null:k)}),(async()=>{if(!await Ge()){F("Локальной базы нет — скачай сохранение."),V("Нет локальной базы — скачай сохранение на странице «Синхронизация»."),w.textContent="";return}try{const C=await qn();if(!bt(C)){F("Файл в OPFS не похож на SQLite — перекачай сохранение.",!0),V("Файл в OPFS не похож на SQLite — перекачай сохранение.");return}N();try{const[P,_]=await Promise.all([Hn(),Pn()]),fe=P;Q=new Map(_.map(ue=>[ue.id,ue])),h.innerHTML=''+fe.map(ue=>``).join(""),y=!0,await j(),h.options[0].textContent=`Все группы (${m})`}catch(P){V(`БД есть, но слова не прочитались: ${P instanceof Error?P.message:String(P)}`)}}catch(C){F(`Не удалось прочитать базу: ${C instanceof Error?C.message:String(C)}`)}})()}const tr=24,pa=/^[A-Za-z0-9]{24}$/,ur="japlearn_sync_token";function rr(r){return r.trim().replace(/\s+/g,"")}function be(r){return pa.test(r)}function fa(){try{return localStorage.getItem(ur)??""}catch{return""}}function wt(r){try{localStorage.setItem(ur,r)}catch{}}const cr="https://learning.micialware.ru";function ha(r,n=cr){return`${n.replace(/\/+$/,"")}/download/${encodeURIComponent(r)}`}async function ga(r,n,o=cr){const s=ha(r,o);let i;try{i=await fetch(s,{method:"GET",...n})}catch(h){throw new Error(`Нет связи с сервером: ${h instanceof Error?h.message:String(h)}`)}if(!i.ok)throw i.status===404?new Error("Сохранение не найдено (404). Проверь токен."):new Error(`Сервер ответил ${i.status} ${i.statusText}`);const u=await i.arrayBuffer();if(u.byteLength===0)throw new Error("Сервер вернул пустой файл");return new Uint8Array(u)}function wa(r){r.innerHTML=`

📡 Синхронизация

Токен сохранения — 24 символа: латинские буквы и цифры.

0 / 24

Введите токен из 24 символов

`;const n=r.querySelector("#token-input"),o=r.querySelector("#token-error"),s=r.querySelector("#token-counter"),i=r.querySelector("#btn-download"),u=r.querySelector("#btn-upload"),h=r.querySelector("#status");function w(y){h.textContent=y,console.log(`[JapLearn] ${y}`)}function U(){return rr(n.value)}function M(y){i.disabled=y||!be(U()),u.disabled=!0,n.disabled=y,y||Ge().then(Q=>{!n.disabled&&be(U())&&(u.disabled=!Q)})}function b(){const y=U(),Q=y.length;s.textContent=`${Q} / ${tr}`;const m=be(y),x=Q===0;n.classList.toggle("invalid",!x&&!m),n.setAttribute("aria-invalid",String(!x&&!m)),x?o.textContent="":Q!==tr?o.textContent=`Нужно 24 символа, сейчас ${Q}`:o.textContent=m?"":"Только латинские буквы и цифры",i.disabled=!m,m?Ge().then(I=>{n.disabled||(u.disabled=!I)}):u.disabled=!0}async function F(){const y=U();if(be(y)){wt(y),M(!0),w("Скачивание сохранения...");try{const Q=await ga(y);w(`Скачано ${(Q.length/1024).toFixed(1)} КБ, распаковка...`);const m=await ca(Q);w(`Распаковано ${(m.length/1024).toFixed(1)} КБ, сохранение в OPFS...`),await _n(m),w(`Готово: база ${(m.length/1024).toFixed(1)} КБ сохранена локально (OPFS).`)}catch(Q){w(`Ошибка скачивания: ${Q instanceof Error?Q.message:String(Q)}`)}finally{M(!1),b()}}}n.addEventListener("input",()=>{b()}),n.addEventListener("change",()=>{const y=U();n.value=y,be(y)&&(wt(y),w("Токен сохранён локально. Можно скачивать или выгружать.")),b()}),i.addEventListener("click",()=>{F()}),u.addEventListener("click",()=>{const y=U();be(y)&&(wt(y),w("Выгрузка — следующий шаг (POST /upload/stream/{id})."))});const N=fa();N&&(n.value=N),b(),be(rr(N))&&Ge().then(y=>{w(y?"Токен восстановлен, локальная база на месте.":"Токен восстановлен. Нажми «Скачать», чтобы получить базу."),b()})}const ma={home:"Главная",sync:"Синхронизация"};function Re(r){const n=document.getElementById(r);if(!n)throw new Error(`[JapLearn] Не найден элемент #${r}`);return n}const dr=Re("burger-btn"),We=Re("drawer"),pr=Re("drawer-overlay"),va=Re("page-title"),nr=Re("page");let Et=!1;function Ie(r){Et=r,We.classList.toggle("open",r),pr.hidden=!r,dr.setAttribute("aria-expanded",String(r)),We.setAttribute("aria-hidden",String(!r)),document.body.classList.toggle("drawer-open",r)}function ya(r){We.querySelectorAll(".drawer-btn").forEach(n=>{n.classList.toggle("active",n.dataset.page===r)})}function fr(r){va.textContent=ma[r],ya(r),r==="home"?da(nr):wa(nr)}dr.addEventListener("click",()=>{Ie(!Et)});pr.addEventListener("click",()=>{Ie(!1)});document.addEventListener("keydown",r=>{r.key==="Escape"&&Et&&Ie(!1)});We.querySelectorAll(".drawer-btn").forEach(r=>{r.addEventListener("click",()=>{const n=r.dataset.page;(n==="home"||n==="sync")&&fr(n),Ie(!1)})});await kn();Ie(!1);fr("home");console.log("[JapLearn] crossOriginIsolated =",window.crossOriginIsolated);