1import{n as e}from"./chunk-CilyBKbf.js";import{n as t,t as n}from"./index.esm-o_fNatQd.js";var r=r===void 0?{}:r,i={},a;for(a in r)r.hasOwnProperty(a)&&(i[a]=r[a]);var o=r.printErr||console.warn.bind(console);for(a in i)i.hasOwnProperty(a)&&(r[a]=i[a]);var s=(e,t)=>{throw t};i=null,r.arguments&&r.arguments,r.thisProgram&&(thisProgram=r.thisProgram),r.quit&&(s=r.quit),typeof WebAssembly!=`object`&&_(`no native wasm support detected`);var c,l=!1,u,d;function f(){var e=c.buffer;r.HEAP8=new Int8Array(e),r.HEAPU8=d=new Uint8Array(e)}var p=[],m=[],ee=[];function te(){if(r.preRun)for(typeof r.preRun==`function`&&(r.preRun=[r.preRun]);r.preRun.length;)ie(r.preRun.shift());v(p)}function ne(){v(m)}function re(){if(r.postRun)for(typeof r.postRun==`function`&&(r.postRun=[r.postRun]);r.postRun.length;)oe(r.postRun.shift());v(ee)}function ie(e){p.unshift(e)}function ae(e){m.unshift(e)}function oe(e){ee.unshift(e)}var h=0,g=null;function se(e){var t;h++,(t=r.monitorRunDependencies)==null||t.call(r,h)}function ce(e){var t;if(h--,(t=r.monitorRunDependencies)==null||t.call(r,h),h==0&&g){var n=g;g=null,n()}}function _(e){var t;throw(t=r.onAbort)==null||t.call(r,e),e=`Aborted(`+e+`)`,o(e),l=!0,e+=`. Build with -sASSERTIONS for more info.`,new WebAssembly.RuntimeError(e)}function le(){return{a:Te}}function ue(e){return fetch(e,{credentials:`same-origin`}).then(function(t){if(!t.ok)throw`failed to load wasm binary file at '`+e+`'`;return t.arrayBuffer()})}function de(e){var t=le();function n(e,t){return C=e.exports,c=C.f,f(),ae(C.g),ce(`wasm-instantiate`),C}se(`wasm-instantiate`);function i(e){n(e.instance)}function a(n){return ue(e).then(function(e){return WebAssembly.instantiate(e,t)}).then(n,function(e){o(`failed to asynchronously prepare wasm: `+e),_(e)})}function s(){return e&&e.byteLength>0?WebAssembly.instantiate(e,t).then(i,function(e){o(`wasm compile failed: `+e)}):typeof WebAssembly.instantiateStreaming==`function`&&typeof e==`string`&&typeof fetch==`function`?fetch(e,{credentials:`same-origin`}).then(function(e){return WebAssembly.instantiateStreaming(e,t).then(i,function(e){return o(`wasm streaming compile failed: `+e),o(`falling back to ArrayBuffer instantiation`),a(i)})}):a(i)}if(r.instantiateWasm)try{return r.instantiateWasm(t,n)}catch(e){return o(`Module.instantiateWasm callback failed with error: `+e),!1}return s(),{}}var fe=class{constructor(e){this.name=`ExitStatus`,this.message=`Program terminated with exit(${e})`,this.status=e}},v=e=>{for(;e.length>0;)e.shift()(r)},y=r.noExitRuntime||!0,pe=()=>_(``),b=0,me=()=>{y=!1,b=0},x={},he=e=>{if(e instanceof fe||e==`unwind`)return u;s(1,e)},S=()=>y||b>0,ge=e=>{var t;u=e,S()||((t=r.onExit)==null||t.call(r,e),l=!0),s(e,new fe(e))},_e=(e,t)=>{u=e,ge(e)},ve=()=>{if(!S())try{_e(u)}catch(e){he(e)}},ye=e=>{if(!l)try{e(),ve()}catch(e){he(e)}},be=()=>performance.now(),xe=(e,t)=>(x[e]&&(clearTimeout(x[e].id),delete x[e]),t&&(x[e]={id:setTimeout(()=>{delete x[e],ye(()=>ze(e,be()))},t),timeout_ms:t}),0),Se=()=>2147483648,Ce=(e,t)=>Math.ceil(e/t)*t,we=e=>{var t=(e-c.buffer.byteLength+65535)/65536|0;try{return c.grow(t),f(),1}catch{}},Te={c:pe,b:me,d:xe,e:e=>{var t=d.length;e>>>=0;var n=Se();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),we(Math.min(n,Ce(Math.max(e,i),65536))))return!0}return!1},a:ge},C,Ee=r._ZSTD_isError=e=>(Ee=r._ZSTD_isError=C.h)(e),De=r._ZSTD_compressBound=e=>(De=r._ZSTD_compressBound=C.i)(e),Oe=r._ZSTD_createCCtx=()=>(Oe=r._ZSTD_createCCtx=C.j)(),ke=r._ZSTD_freeCCtx=e=>(ke=r._ZSTD_freeCCtx=C.k)(e),Ae=r._ZSTD_compress_usingDict=(e,t,n,i,a,o,s,c)=>(Ae=r._ZSTD_compress_usingDict=C.l)(e,t,n,i,a,o,s,c),je=r._ZSTD_compress=(e,t,n,i,a)=>(je=r._ZSTD_compress=C.m)(e,t,n,i,a),Me=r._ZSTD_createDCtx=()=>(Me=r._ZSTD_createDCtx=C.n)(),Ne=r._ZSTD_freeDCtx=e=>(Ne=r._ZSTD_freeDCtx=C.o)(e),Pe=r._ZSTD_getFrameContentSize=(e,t)=>(Pe=r._ZSTD_getFrameContentSize=C.p)(e,t),Fe=r._ZSTD_decompress_usingDict=(e,t,n,i,a,o,s)=>(Fe=r._ZSTD_decompress_usingDict=C.q)(e,t,n,i,a,o,s),Ie=r._ZSTD_decompress=(e,t,n,i)=>(Ie=r._ZSTD_decompress=C.r)(e,t,n,i),Le=r._malloc=e=>(Le=r._malloc=C.s)(e),Re=r._free=e=>(Re=r._free=C.t)(e),ze=(e,t)=>(ze=C.v)(e,t),w;g=function e(){w||T(),w||(g=e)};function T(){if(h>0||(te(),h>0))return;function e(){var e;w||(w=!0,r.calledRun=!0,!l&&(ne(),(e=r.onRuntimeInitialized)==null||e.call(r),re()))}r.setStatus?(r.setStatus(`Running...`),setTimeout(()=>{setTimeout(()=>r.setStatus(``),1),e()},1)):e()}if(r.run=T,r.preInit)for(typeof r.preInit==`function`&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.pop()();r.init=de;var Be=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Ve=new Promise(e=>{r.onRuntimeInitialized=e}),He=()=>Be(void 0,void 0,void 0,function*(){yield Ve}),E=e=>{let t=r._ZSTD_isError;return t(e)},Ue=(e,t)=>{let n=r._ZSTD_getFrameContentSize;return n(e,t)},We=(e,t={defaultHeapSize:1024*1024})=>{let n=r._malloc,i=n(e.byteLength);r.HEAP8.set(e,i);let a=Ue(i,e.byteLength),o=a===-1?t.defaultHeapSize:a,s=r._free,c=n(o);try{let t=r._ZSTD_decompress,n=t(c,o,i,e.byteLength);if(E(n))throw Error(`Failed to compress with code ${n}`);let a=new Uint8Array(r.HEAPU8.buffer,c,n).slice();return s(c,o),s(i,e.byteLength),a}catch(t){throw s(c,o),s(i,e.byteLength),t}},Ge=e=>{let t=r._ZSTD_compressBound;return t(e)},Ke=(e,t)=>{let n=Ge(e.byteLength),i=r._malloc,a=i(n),o=i(e.byteLength);r.HEAP8.set(e,o);let s=r._free;try{let i=r._ZSTD_compress,c=i(a,n,o,e.byteLength,t??3);if(E(c))throw Error(`Failed to compress with code ${c}`);let l=new Uint8Array(r.HEAPU8.buffer,a,c).slice();return s(a,n),s(o,e.byteLength),l}catch(t){throw s(a,n),s(o,e.byteLength),t}},qe=function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},Je=e=>qe(void 0,void 0,void 0,function*(){let t=new URL(`/assets/zstd-CV7N7xSg.wasm`,``+import.meta.url).href;r.init(e??t),yield He()}),D=null;function O(){return D||=Je().catch(e=>{throw D=null,e}),D}async function Ye(e,t=19){return await O(),Ke(e,t)}async function Xe(e){return await O(),We(e)}var Ze=e({CHECKSUM_LEN:()=>4,HEADER_LEN:()=>8,MAGIC:()=>k,NONCE_LEN:()=>12,SALT_LEN:()=>16,TAG_LEN:()=>16,VERSION:()=>1,buildPayload:()=>q,bytesToUuid:()=>ft,parsePayload:()=>J,uuidToBytes:()=>dt}),k=1346586707,Qe=65536,$e=3,et=4,A=1,j=2,M=3,N=4,P=5,F=1,I=2,L=3,R=4,z=1,B=2,V=4,H=8,U=16,W=32,G=64,tt=128,K=[`visa`,`mastercard`,`amex`,`discover`,`unknown`];async function q(e){let t=[];t.push(await Y(A,it(e.entries))),t.push(await Y(j,X(e.settings))),e.license&&t.push(await Y(M,X(e.license))),e.manualSummonDomains&&Object.keys(e.manualSummonDomains).length>0&&t.push(await Y(N,X(e.manualSummonDomains))),e.declinedCardFingerprints&&e.declinedCardFingerprints.length>0&&t.push(await Y(P,X(e.declinedCardFingerprints)));let n=new Uint8Array(8);new DataView(n.buffer).setUint32(0,k,!1),n[4]=1,n[5]=t.length;let r=$([n,...t]),i=$([r,await vt(r)]),a=crypto.getRandomValues(new Uint8Array(16)),o=crypto.getRandomValues(new Uint8Array(12)),s=await ht(e.passphrase,a);try{let{ciphertext:e,tag:t}=await gt(s,o,i);return $([a,o,e,t])}finally{s.fill(0)}}async function J(e,t){if(e.length<56)throw Error(`PAYLOAD_TOO_SHORT`);let n=e.subarray(0,16),r=e.subarray(16,28),i=e.subarray(e.length-16),a=e.subarray(28,e.length-16),o=await ht(t,n),s;try{s=await _t(o,r,a,i)}catch{throw Error(`INVALID_PASSPHRASE`)}finally{o.fill(0)}if(s.length<12)throw Error(`PAYLOAD_TOO_SHORT`);let c=s.subarray(0,s.length-4);if(!yt(s.subarray(s.length-4),await vt(c)))throw Error(`CHECKSUM_FAILED`);let l=new DataView(c.buffer,c.byteOffset,c.byteLength);if(l.getUint32(0,!1)!==1346586707)throw Error(`BAD_MAGIC`);let u=c[4];if(u!==1)throw Error(`UNSUPPORTED_VERSION:${u}`);let d=c[5],f=8,p={entries:[],settings:{}};for(let e=0;e<d;e++){if(f+9>c.length)throw Error(`PAYLOAD_TOO_SHORT`);let e=c[f],t=l.getUint32(f+1,!0),n=l.getUint32(f+5,!0),r=f+9,i=r+n;if(i>c.length)throw Error(`PAYLOAD_TOO_SHORT`);let a=await Xe(c.subarray(r,i));if(a.length!==t)throw Error(`SECTION_LENGTH_MISMATCH`);switch(e){case A:p.entries=at(a);break;case j:p.settings=Z(a);break;case M:p.license=Z(a);break;case N:p.manualSummonDomains=Z(a);break;case P:p.declinedCardFingerprints=Z(a);break;default:break}f=i}return p}async function Y(e,t){let n=await Ye(t,19),r=new Uint8Array(9+n.length),i=new DataView(r.buffer);return r[0]=e,i.setUint32(1,t.length,!0),i.setUint32(5,n.length,!0),r.set(n,9),r}function X(e){return new TextEncoder().encode(JSON.stringify(e))}function Z(e){return JSON.parse(new TextDecoder().decode(e))}var nt=class{map=new Map;list=[];intern(e){if(!e)return 0;let t=this.map.get(e);if(t!==void 0)return t;let n=this.list.length+1;if(n>65535)throw Error(`STRING_TABLE_OVERFLOW`);return this.map.set(e,n),this.list.push(e),n}serialize(){let e=new TextEncoder,t=this.list.map(t=>e.encode(t)),n=2;for(let e of t)n+=2+e.length;let r=new Uint8Array(n),i=new DataView(r.buffer),a=0;i.setUint16(a,t.length,!0),a+=2;for(let e of t){if(e.length>65535)throw Error(`STRING_TOO_LONG`);i.setUint16(a,e.length,!0),a+=2,r.set(e,a),a+=e.length}return r}};function rt(e,t){let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint16(t,!0);t+=2;let i=[],a=new TextDecoder;for(let o=0;o<r;o++){let r=n.getUint16(t,!0);t+=2,i.push(a.decode(e.subarray(t,t+r))),t+=r}return{strings:i,cursor:t}}function Q(e,t){if(t!==0)return e[t-1]}function it(e){let t=new nt,n=[];for(let n of e)t.intern(n.title);for(let r of e)n.push(ot(r,t));let r=t.serialize(),i=0;for(let e of n)i+=e.length;let a=new Uint8Array(4+r.length+i);new DataView(a.buffer).setUint32(0,e.length,!0),a.set(r,4);let o=4+r.length;for(let e of n)a.set(e,o),o+=e.length;return a}function at(e){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!0),{strings:n,cursor:r}=rt(e,4),i=[],a=r;for(let r=0;r<t;r++){let{entry:t,cursor:r}=st(e,a,n);i.push(t),a=r}return i}function ot(e,t){let n=new pt,r=ct(e);n.u8(r),n.bytes(dt(e.id));let i=Math.floor((e.createdAt??Date.now())/1e3),a=Math.floor((e.modifiedAt??e.createdAt??Date.now())/1e3),o=Math.max(0,a-i),s=e.deletedAt?Math.floor(e.deletedAt/1e3):0,c=n.length;n.u8(0),n.u32(i),n.u32(o),n.u32(s),n.u16(t.intern(e.title));let l=0;if(e.deletedAt&&(l|=tt),r===F){if(n.u16(t.intern(e.url)),n.u16(t.intern(e.username)),n.lpString(e.password??``,1),e.totp&&(l|=z,n.lpString(e.totp,1)),e.tags&&e.tags.length>0){l|=B,n.u8(Math.min(e.tags.length,255));for(let r=0;r<Math.min(e.tags.length,255);r++)n.u16(t.intern(e.tags[r]))}if(e.notes&&(l|=V,n.u16(t.intern(e.notes))),e.canary&&(l|=H,n.u16(t.intern(e.canary.webhookUrl)),n.u16(t.intern(e.canary.label))),e.passwordChangedAt){l|=U;let t=Math.floor(e.passwordChangedAt/1e3);n.u32(Math.max(0,t-i))}if(typeof e.breach==`number`&&e.breach>0&&(l|=W,n.u32(e.breach)),e.additionalUrls&&e.additionalUrls.length>0){l|=G,n.u8(Math.min(e.additionalUrls.length,255));for(let r=0;r<Math.min(e.additionalUrls.length,255);r++)n.u16(t.intern(e.additionalUrls[r]))}}else if(r===I){if(e.notes&&(l|=V,n.u16(t.intern(e.notes))),e.tags&&e.tags.length>0){l|=B,n.u8(Math.min(e.tags.length,255));for(let r=0;r<Math.min(e.tags.length,255);r++)n.u16(t.intern(e.tags[r]))}}else if(r===L){if(n.u16(t.intern(e.cardholderName)),n.lpString(e.cardNumber??``,1),n.lpString(e.expMonth??``,1),n.lpString(e.expYear??``,1),n.lpString(e.cvc??``,1),n.u16(t.intern(e.cardNickname)),n.u8(lt(e.network)),n.u16(t.intern(e.last4)),e.tags&&e.tags.length>0){l|=B,n.u8(Math.min(e.tags.length,255));for(let r=0;r<Math.min(e.tags.length,255);r++)n.u16(t.intern(e.tags[r]))}e.notes&&(l|=V,n.u16(t.intern(e.notes)))}else if(r===R){let t=X({rpId:e.rpId,rpName:e.rpName,credentialId:e.credentialId,publicKeyCose:e.publicKeyCose,privateKeyJwk:e.privateKeyJwk,userHandle:e.userHandle,userName:e.userName,userDisplayName:e.userDisplayName,algorithm:e.algorithm,signCount:e.signCount,aaguid:e.aaguid,backupEligible:e.backupEligible,backupState:e.backupState,lastUsedAt:e.lastUsedAt});n.u32(t.length),n.bytes(t)}return n.setU8(c,l),n.toBytes()}function st(e,t,n){let r=new mt(e,t),i=r.u8(),a=ft(r.read(16)),o=r.u8(),s=r.u32(),c=r.u32(),l=r.u32(),u=r.u16(),d=s*1e3,f=(s+c)*1e3,p=l>0?l*1e3:void 0,m={id:a,title:Q(n,u)??``,createdAt:d,modifiedAt:f,...p===void 0?{}:{deletedAt:p}};if(i===F){let e=r.u16(),t=r.u16(),i=r.lpString(1),a={};if(o&z&&(a.totp=r.lpString(1)),o&B){let e=r.u8(),t=[];for(let i=0;i<e;i++){let e=Q(n,r.u16());e!==void 0&&t.push(e)}a.tags=t}if(o&V&&(a.notes=Q(n,r.u16())),o&H){let e=Q(n,r.u16())??``,t=Q(n,r.u16()),i={webhookUrl:e};t!==void 0&&(i.label=t),a.canary=i}if(o&U&&(a.passwordChangedAt=(s+r.u32())*1e3),o&W&&(a.breach=r.u32()),o&G){let e=r.u8(),t=[];for(let i=0;i<e;i++){let e=Q(n,r.u16());e!==void 0&&t.push(e)}a.additionalUrls=t}return{entry:{...m,type:`login`,url:Q(n,e),username:Q(n,t),password:i,...a},cursor:r.cursor}}if(i===I){let e={};if(o&V&&(e.notes=Q(n,r.u16())),o&B){let t=r.u8(),i=[];for(let e=0;e<t;e++){let e=Q(n,r.u16());e!==void 0&&i.push(e)}e.tags=i}return{entry:{...m,type:`note`,...e},cursor:r.cursor}}if(i===L){let e=r.u16(),t=r.lpString(1),i=r.lpString(1),a=r.lpString(1),s=r.lpString(1),c=r.u16(),l=ut(r.u8()),u=r.u16(),d={};if(o&B){let e=r.u8(),t=[];for(let i=0;i<e;i++){let e=Q(n,r.u16());e!==void 0&&t.push(e)}d.tags=t}return o&V&&(d.notes=Q(n,r.u16())),{entry:{...m,type:`card`,cardholderName:Q(n,e),cardNumber:t,expMonth:i,expYear:a,cvc:s,cardNickname:Q(n,c),network:l,last4:Q(n,u),...d},cursor:r.cursor}}if(i===R){let e=r.u32(),t=Z(r.read(e));return{entry:{...m,type:`passkey`,...t},cursor:r.cursor}}throw Error(`UNKNOWN_ENTRY_TYPE:${i}`)}function ct(e){switch(e.type){case`note`:return I;case`card`:return L;case`passkey`:return R;default:return F}}function lt(e){if(!e)return 255;let t=K.indexOf(e);return t>=0?t:K.indexOf(`unknown`)}function ut(e){if(e!==255)return K[e]??`unknown`}function dt(e){let t=e.replace(/-/g,``);if(t.length!==32)throw Error(`UUID_FORMAT`);let n=new Uint8Array(16);for(let e=0;e<16;e++)n[e]=parseInt(t.slice(e*2,e*2+2),16);return n}function ft(e){if(e.length!==16)throw Error(`UUID_LENGTH`);let t=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var pt=class{chunks=[];len=0;get length(){return this.len}u8(e){let t=new Uint8Array(1);t[0]=e&255,this.push(t)}setU8(e,t){let n=0;for(let r of this.chunks){if(e<n+r.length){r[e-n]=t&255;return}n+=r.length}throw Error(`setU8 out of range`)}u16(e){let t=new Uint8Array(2);new DataView(t.buffer).setUint16(0,e&65535,!0),this.push(t)}u32(e){let t=new Uint8Array(4);new DataView(t.buffer).setUint32(0,e>>>0,!0),this.push(t)}bytes(e){this.push(e)}lpString(e,t){let n=new TextEncoder().encode(e);if(t===1){if(n.length>255)throw Error(`STRING_TOO_LONG_U8`);this.u8(n.length)}else{if(n.length>65535)throw Error(`STRING_TOO_LONG_U16`);this.u16(n.length)}this.push(n)}toBytes(){let e=new Uint8Array(this.len),t=0;for(let n of this.chunks)e.set(n,t),t+=n.length;return e}push(e){this.chunks.push(e),this.len+=e.length}},mt=class{cursor;view;constructor(e,t){this.data=e,this.cursor=t,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}u8(){return this.data[this.cursor++]}u16(){let e=this.view.getUint16(this.cursor,!0);return this.cursor+=2,e}u32(){let e=this.view.getUint32(this.cursor,!0);return this.cursor+=4,e}read(e){let t=this.data.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}lpString(e){let t=e===1?this.u8():this.u16();return new TextDecoder().decode(this.read(t))}};async function ht(e,t){return n({password:e,salt:t,parallelism:et,iterations:$e,memorySize:Qe,hashLength:32,outputType:`binary`})}async function gt(e,t,n){let r=await crypto.subtle.importKey(`raw`,e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),{name:`AES-GCM`},!1,[`encrypt`]),i=await crypto.subtle.encrypt({name:`AES-GCM`,iv:t.buffer,tagLength:128},r,n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)),a=new Uint8Array(i);return{ciphertext:a.slice(0,a.length-16),tag:a.slice(a.length-16)}}async function _t(e,t,n,r){let i=await crypto.subtle.importKey(`raw`,e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),{name:`AES-GCM`},!1,[`decrypt`]),a=$([n,r]),o=await crypto.subtle.decrypt({name:`AES-GCM`,iv:t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),tagLength:128},i,a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength));return new Uint8Array(o)}async function vt(e){let n=await t(e),r=new Uint8Array(4);for(let e=0;e<4;e++)r[e]=parseInt(n.slice(e*2,e*2+2),16);return r}function yt(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}function $(e){let t=0;for(let n of e)t+=n.length;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;return n}export{J as n,Ze as r,q as t};