element-web-synapse01pim.gr.jp

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

rust-crypto-Bko3GkMP.js (232423B)


      1 try{let e=typeof window<`u`?window:t===void 0?typeof globalThis<`u`?globalThis:typeof self<`u`?self:{}:t,n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=`01f5c592-8477-495b-8c45-555d8c110fe8`,e._sentryDebugIdIdentifier=`sentry-dbid-01f5c592-8477-495b-8c45-555d8c110fe8`)}catch{}import{a as e,o as t,r as n,t as r}from"./_sentry-release-injection-file-CVmuPGUe.js";import{$ as i,A as a,B as o,C as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,L as ee,M as h,N as te,O as g,P as ne,Q as _,R as v,S as y,T as b,U as re,V as x,W as ie,X as ae,Y as oe,Z as S,_ as C,b as se,c as ce,d as w,et as T,f as le,g as ue,h as de,j as fe,k as pe,l as me,m as he,p as ge,q as _e,s as ve,tt as E,u as ye,v as be,w as xe,x as Se,y as Ce,z as we}from"./index-BGDyK1x3.js";var Te=n({Attachment:()=>Ee,BackupDecryptionKey:()=>D,BackupKeys:()=>De,BackupSecretsBundle:()=>Oe,Base64EncodedPkMessage:()=>ke,BaseMigrationData:()=>Ae,CancelInfo:()=>je,CheckCode:()=>Me,CollectStrategy:()=>O,CrossSigningBootstrapRequests:()=>Ne,CrossSigningKeyExport:()=>Pe,CrossSigningStatus:()=>Fe,Curve25519PublicKey:()=>k,Curve25519SecretKey:()=>Ie,DecryptedRoomEvent:()=>Le,DecryptedToDeviceEvent:()=>Re,DecryptionErrorCode:()=>A,DecryptionSettings:()=>ze,DehydratedDevice:()=>Be,DehydratedDeviceKey:()=>j,DehydratedDevices:()=>Ve,Device:()=>He,DeviceId:()=>M,DeviceKey:()=>Ue,DeviceKeyAlgorithm:()=>We,DeviceKeyAlgorithmName:()=>Ge,DeviceKeyId:()=>Ke,DeviceKeyName:()=>qe,DeviceLists:()=>Je,Ecies:()=>Ye,Ed25519PublicKey:()=>Xe,Ed25519Signature:()=>Ze,Emoji:()=>Qe,EncryptedAttachment:()=>$e,EncryptionAlgorithm:()=>et,EncryptionInfo:()=>tt,EncryptionSettings:()=>nt,EstablishedEcies:()=>rt,EventId:()=>it,HistoryVisibility:()=>at,IdentityKeys:()=>ot,InboundCreationResult:()=>st,InboundGroupSession:()=>ct,InvalidToDeviceEvent:()=>lt,KeysBackupRequest:()=>ut,KeysClaimRequest:()=>dt,KeysQueryRequest:()=>ft,KeysUploadRequest:()=>pt,LocalTrust:()=>mt,LoggerLevel:()=>ht,MaybeSignature:()=>gt,MegolmDecryptionError:()=>_t,MegolmV1BackupKey:()=>vt,Migration:()=>yt,Msc4108IntentData:()=>bt,Msc4388IntentData:()=>xt,OlmMachine:()=>St,OtherUserIdentity:()=>Ct,OutboundCreationResult:()=>wt,OwnUserIdentity:()=>Tt,PickledInboundGroupSession:()=>Et,PickledSession:()=>Dt,PkDecryption:()=>Ot,PkEncryption:()=>kt,PkMessage:()=>N,PlainTextToDeviceEvent:()=>At,ProcessedToDeviceEventType:()=>jt,PutDehydratedDeviceRequest:()=>Mt,Qr:()=>Nt,QrCode:()=>Pt,QrCodeData:()=>Ft,QrCodeIntent:()=>It,QrCodeIntentData:()=>Lt,QrCodeScan:()=>Rt,QrState:()=>P,RehydratedDevice:()=>zt,RequestType:()=>Bt,RoomId:()=>F,RoomKeyCounts:()=>Vt,RoomKeyImportResult:()=>Ht,RoomKeyInfo:()=>Ut,RoomKeyWithheldInfo:()=>Wt,RoomMessageRequest:()=>Gt,RoomPendingKeyBundleDetails:()=>Kt,RoomSettings:()=>qt,Sas:()=>Jt,SecretsBundle:()=>Yt,ServerName:()=>Xt,ShieldColor:()=>Zt,ShieldState:()=>Qt,ShieldStateCode:()=>$t,Signature:()=>en,SignatureState:()=>tn,SignatureUploadRequest:()=>nn,SignatureVerification:()=>rn,Signatures:()=>an,StoreHandle:()=>I,StoredRoomKeyBundleData:()=>on,ToDeviceEncryptionInfo:()=>sn,ToDeviceRequest:()=>cn,ToDeviceUnableToDecryptInfo:()=>ln,ToDeviceUnableToDecryptReason:()=>un,Tracing:()=>dn,TrustRequirement:()=>fn,UTDToDeviceEvent:()=>pn,UploadSigningKeysRequest:()=>mn,UserDevices:()=>hn,UserId:()=>L,VerificationMethod:()=>gn,VerificationRequest:()=>_n,VerificationRequestPhase:()=>R,Versions:()=>vn,__wbg_Error_bce6d499ff0a4aff:()=>xn,__wbg_Number_b7972a139bfbfdf0:()=>Sn,__wbg_String_8564e559799eccda:()=>Cn,__wbg_Window_241244be8c9776c1:()=>wn,__wbg_WorkerGlobalScope_8623a7c9030fbce2:()=>Tn,__wbg___wbindgen_bigint_get_as_i64_410e28c7b761ad83:()=>En,__wbg___wbindgen_boolean_get_2304fb8c853028c8:()=>Dn,__wbg___wbindgen_debug_string_edece8177ad01481:()=>On,__wbg___wbindgen_in_07056af4f902c445:()=>kn,__wbg___wbindgen_is_bigint_aeae3893f30ed54e:()=>An,__wbg___wbindgen_is_function_5cd60d5cf78b4eef:()=>jn,__wbg___wbindgen_is_null_2042690d351e14f0:()=>Mn,__wbg___wbindgen_is_object_b4593df85baada48:()=>Nn,__wbg___wbindgen_is_string_dde0fd9020db4434:()=>Pn,__wbg___wbindgen_is_undefined_35bb9f4c7fd651d5:()=>Fn,__wbg___wbindgen_jsval_eq_c0ed08b3e0f393b9:()=>In,__wbg___wbindgen_jsval_loose_eq_0ad77b7717db155c:()=>Ln,__wbg___wbindgen_number_get_f73a1244370fcc2c:()=>Rn,__wbg___wbindgen_string_get_d109740c0d18f4d7:()=>zn,__wbg___wbindgen_throw_9c31b086c2b26051:()=>Bn,__wbg__wbg_cb_unref_3fa391f3fcdb55f8:()=>Vn,__wbg_abort_70a701fced9ad53a:()=>Hn,__wbg_add_07a7ab95134233b9:()=>Un,__wbg_add_2d9a55f3b0313ab0:()=>Wn,__wbg_at_3bffe427b0245c4e:()=>Gn,__wbg_backupkeys_new:()=>Kn,__wbg_bound_8d5dfa042d13a74b:()=>qn,__wbg_call_084ee3e860ee9f92:()=>Jn,__wbg_call_13665d9f14390edc:()=>Yn,__wbg_call_dfde26266607c996:()=>Xn,__wbg_call_faa0a261f288f846:()=>Zn,__wbg_clearTimeout_113b1cde814ec762:()=>Qn,__wbg_clear_bb1b3ff877b62598:()=>$n,__wbg_close_b66c780bfc7dd92c:()=>er,__wbg_code_b725fad05a5aceb3:()=>tr,__wbg_commit_ebd6d9676954e0d2:()=>nr,__wbg_continue_6f5a7d3d3bc4a125:()=>rr,__wbg_count_048ba344d77978d6:()=>ir,__wbg_count_0e78b9f66eb6a1d6:()=>ar,__wbg_createIndex_4dedb55a60318332:()=>or,__wbg_createIndex_82392a1ffeb84021:()=>sr,__wbg_createObjectStore_ce6be0d6715f0760:()=>cr,__wbg_crosssigningbootstraprequests_new:()=>lr,__wbg_crosssigningkeyexport_new:()=>ur,__wbg_crosssigningstatus_new:()=>dr,__wbg_crypto_38df2bab126b63dc:()=>fr,__wbg_debug_1ac2ea5532f70f4c:()=>pr,__wbg_debug_83758bc0b77ada71:()=>mr,__wbg_decryptedroomevent_new:()=>hr,__wbg_decryptedtodeviceevent_new:()=>gr,__wbg_dehydrateddevice_new:()=>_r,__wbg_dehydrateddevicekey_new:()=>vr,__wbg_deleteObjectStore_91d035f22c860ba0:()=>yr,__wbg_delete_9c4e8b22a8b0ff3c:()=>br,__wbg_delete_bc03f88e7f14db56:()=>xr,__wbg_device_new:()=>Sr,__wbg_deviceid_new:()=>Cr,__wbg_devicekey_new:()=>wr,__wbg_devicekeyid_new:()=>Tr,__wbg_done_54b8da57023b7ed2:()=>Er,__wbg_emoji_new:()=>Dr,__wbg_encryptedattachment_new:()=>Or,__wbg_encryptioninfo_new:()=>kr,__wbg_entries_564a7e8b1e54ede5:()=>Ar,__wbg_entries_c5ae2149eef72ab2:()=>jr,__wbg_error_a6fa202b58aa1cd3:()=>Mr,__wbg_error_dbd3752906405f8d:()=>Nr,__wbg_error_ef9cbaece146d1d5:()=>Pr,__wbg_error_f085d7e62279b703:()=>Fr,__wbg_from_fa561fa561dc8031:()=>Ir,__wbg_getAllKeys_07d656e168400060:()=>Lr,__wbg_getAll_31747a1df22443f5:()=>Rr,__wbg_getAll_a0a54eef6ac20915:()=>zr,__wbg_getAll_bc4f4ec6a1504163:()=>Br,__wbg_getAll_f658d6ff0380c8c0:()=>Vr,__wbg_getRandomValues_76dfc69825c9c552:()=>Hr,__wbg_getRandomValues_c44a50d8cfdaebeb:()=>Ur,__wbg_getRandomValues_ef12552bf5acd2fe:()=>Wr,__wbg_getTime_09f1dd40a44edb30:()=>Gr,__wbg_get_335f027bf0ad3391:()=>Kr,__wbg_get_3e9a707ab7d352eb:()=>qr,__wbg_get_98fdf51d029a75eb:()=>Jr,__wbg_get_b6f278d067d9edad:()=>Yr,__wbg_get_dcf82ab8aad1a593:()=>Xr,__wbg_get_unchecked_1dfe6d05ad91d9b7:()=>Zr,__wbg_get_with_ref_key_6412cf3094599694:()=>Qr,__wbg_global_94a489d2e6a0c5fd:()=>$r,__wbg_inboundgroupsession_new:()=>ei,__wbg_index_1eb6fae6472ecb14:()=>ti,__wbg_indexedDB_2e82cb845ce6b3ad:()=>ni,__wbg_indexedDB_47c354eb27472a00:()=>ri,__wbg_indexedDB_cbfeacc981615a77:()=>ii,__wbg_info_929f1b00bd4820a9:()=>ai,__wbg_info_d2226ca1698bd09c:()=>oi,__wbg_instanceof_ArrayBuffer_53db37b06f6b9afe:()=>si,__wbg_instanceof_CursorSys_383984afc1fa1bbc:()=>ci,__wbg_instanceof_DomException_bc16ce893e8c7439:()=>li,__wbg_instanceof_Error_b3f7e146d654031a:()=>ui,__wbg_instanceof_IdbCursor_9dd6ddde8160efcf:()=>di,__wbg_instanceof_IdbDatabase_102b0fe5255eee9c:()=>fi,__wbg_instanceof_IdbOpenDbRequest_2cce7fd687448f0f:()=>pi,__wbg_instanceof_IdbRequest_eef501cff5d0b7c1:()=>mi,__wbg_instanceof_Map_16f217b9a2a08d8c:()=>hi,__wbg_instanceof_Promise_09012cfa9708520a:()=>gi,__wbg_instanceof_Uint8Array_abd07d4bd221d50b:()=>_i,__wbg_invalidtodeviceevent_new:()=>vi,__wbg_isArray_74b636a53056fecb:()=>yi,__wbg_isArray_94898ed3aad6947b:()=>bi,__wbg_isSafeInteger_01e964d144ad3a55:()=>xi,__wbg_item_c9a2ae22eb138d82:()=>Si,__wbg_iterator_1441b47f341dc34f:()=>Ci,__wbg_key_387cdde352276f3a:()=>wi,__wbg_keysbackuprequest_new:()=>Ti,__wbg_keysclaimrequest_new:()=>Ei,__wbg_keysqueryrequest_new:()=>Di,__wbg_keysuploadrequest_new:()=>Oi,__wbg_length_2591a0f4f659a55c:()=>ki,__wbg_length_56fcd3e2b7e0299d:()=>Ai,__wbg_length_949f85b73ce6595d:()=>ji,__wbg_lowerBound_a64226f683db77bb:()=>Mi,__wbg_maybesignature_new:()=>Ni,__wbg_megolmdecryptionerror_new:()=>Pi,__wbg_message_324ac511aeaf710e:()=>Fi,__wbg_message_e88a8d3ba2b91c2a:()=>Ii,__wbg_msCrypto_bd5a034af96bcba6:()=>Li,__wbg_name_fe88cfc178ec40b8:()=>Ri,__wbg_new_02d162bc6cf02f60:()=>zi,__wbg_new_070df68d66325372:()=>Bi,__wbg_new_1f236d63ba0c4784:()=>Vi,__wbg_new_227d7c05414eb861:()=>Hi,__wbg_new_310879b66b6e95e1:()=>Ui,__wbg_new_6c6169c583e23af8:()=>Wi,__wbg_new_7ddec6de44ff8f5d:()=>Gi,__wbg_new_859b9002e2668e82:()=>Ki,__wbg_new_d8dfd33fa007511d:()=>qi,__wbg_new_typed_c072c4ce9a2a0cdf:()=>Ji,__wbg_new_with_length_99887c91eae4abab:()=>Yi,__wbg_new_with_length_f193d8561d89261d:()=>Xi,__wbg_next_2a4e19f4f5083b0f:()=>Zi,__wbg_next_6429a146bf756f93:()=>Qi,__wbg_node_84ea875411254db1:()=>$i,__wbg_now_81363d44c96dd239:()=>ea,__wbg_now_e7c6795a7f81e10f:()=>ta,__wbg_objectStoreNames_7eb10221ec542d29:()=>na,__wbg_objectStore_b28adb984a77902e:()=>ra,__wbg_oldVersion_afd7254bce31480c:()=>ia,__wbg_olmmachine_new:()=>aa,__wbg_openCursor_3f4e3e61d07887e9:()=>oa,__wbg_openCursor_61c49273b7c65183:()=>sa,__wbg_openCursor_7423d75422835a48:()=>ca,__wbg_open_40ab11cdd8f5ac5a:()=>la,__wbg_open_a9584db064190886:()=>ua,__wbg_otheruseridentity_new:()=>da,__wbg_ownuseridentity_new:()=>fa,__wbg_parse_2c1cad6215e84999:()=>pa,__wbg_performance_3fcf6e32a7e1ed0a:()=>ma,__wbg_pickledinboundgroupsession_unwrap:()=>ha,__wbg_pickledsession_unwrap:()=>ga,__wbg_plaintexttodeviceevent_new:()=>_a,__wbg_process_44c7a14e11e9f69e:()=>va,__wbg_prototypesetcall_337df880a7679568:()=>ya,__wbg_prototypesetcall_5f9bdc8d75e07276:()=>ba,__wbg_push_b77c476b01548d0a:()=>xa,__wbg_put_ad17713e2c2f12fa:()=>Sa,__wbg_putdehydrateddevicerequest_new:()=>Ca,__wbg_qr_new:()=>wa,__wbg_queueMicrotask_78d584b53af520f5:()=>Ta,__wbg_queueMicrotask_b39ea83c7f01971a:()=>Ea,__wbg_randomFillSync_6c25eac9869eb53c:()=>Da,__wbg_readyState_b7c530197b76b93b:()=>Oa,__wbg_rehydrateddevice_new:()=>ka,__wbg_request_64abeba15a72c084:()=>Aa,__wbg_request_72a78988f2edecad:()=>ja,__wbg_require_b4edbdcf3e2a1ef0:()=>Ma,__wbg_resolve_d17db9352f5a220e:()=>Na,__wbg_result_c4cb33cd39c97cac:()=>Pa,__wbg_roomid_unwrap:()=>Fa,__wbg_roomkeycounts_new:()=>Ia,__wbg_roomkeyimportresult_new:()=>La,__wbg_roomkeyinfo_new:()=>Ra,__wbg_roomkeywithheldinfo_new:()=>za,__wbg_roommessagerequest_new:()=>Ba,__wbg_roompendingkeybundledetails_new:()=>Va,__wbg_roomsettings_new:()=>Ha,__wbg_sas_new:()=>Ua,__wbg_secretsbundle_new:()=>Wa,__wbg_setTimeout_ef24d2fc3ad97385:()=>Ga,__wbg_set_6be42768c690e380:()=>Ka,__wbg_set_78ea6a19f4818587:()=>qa,__wbg_set_bf22f3de29cb1fce:()=>Ja,__wbg_set_facb7a5914e0fa39:()=>Ya,__wbg_set_onabort_ed56d2172d920901:()=>Xa,__wbg_set_oncomplete_3f428ec13b20d7cc:()=>Za,__wbg_set_onerror_38740b892815eedc:()=>Qa,__wbg_set_onerror_457b093a5063c7ec:()=>$a,__wbg_set_onsuccess_b556141053d02ea7:()=>eo,__wbg_set_onupgradeneeded_f885fa17614acd2b:()=>to,__wbg_set_unique_c307b08264e831b2:()=>no,__wbg_set_wasm:()=>il,__wbg_signatures_new:()=>ro,__wbg_signatureuploadrequest_new:()=>io,__wbg_signatureverification_new:()=>ao,__wbg_stack_3b0d974bbf31e44f:()=>oo,__wbg_static_accessor_GLOBAL_THIS_02344c9b09eb08a9:()=>so,__wbg_static_accessor_GLOBAL_ac6d4ac874d5cd54:()=>co,__wbg_static_accessor_SELF_9b2406c23aeb2023:()=>lo,__wbg_static_accessor_WINDOW_b34d2126934e16ba:()=>uo,__wbg_storedroomkeybundledata_new:()=>fo,__wbg_storehandle_new:()=>po,__wbg_stringify_ef0c105b1ccc3849:()=>mo,__wbg_subarray_7c6a0da8f3b4a1ba:()=>ho,__wbg_target_84e05e84ffc12989:()=>go,__wbg_then_837494e384b37459:()=>_o,__wbg_then_bd927500e8905df2:()=>vo,__wbg_toString_1dda136fd8f30a5f:()=>yo,__wbg_todevicerequest_new:()=>bo,__wbg_transaction_213e4f585d3d1b40:()=>xo,__wbg_transaction_38cea079a9d82352:()=>So,__wbg_transaction_623d0b0d88e248ee:()=>Co,__wbg_transaction_b7261fed68fa4264:()=>wo,__wbg_update_5c0f974a3c0850fc:()=>To,__wbg_upperBound_f7daa7529e579cfc:()=>Eo,__wbg_userdevices_new:()=>Do,__wbg_userid_new:()=>Oo,__wbg_userid_unwrap:()=>ko,__wbg_utdtodeviceevent_new:()=>Ao,__wbg_value_308a5bab6b4eb311:()=>jo,__wbg_value_9cc0518af87a489c:()=>Mo,__wbg_values_2e4d34d52f9540dc:()=>No,__wbg_verificationrequest_new:()=>Po,__wbg_version_0fcb42f756365cc1:()=>Fo,__wbg_versions_276b2795b1c6a219:()=>Io,__wbg_warn_b62de6508e8608cc:()=>Lo,__wbg_warn_c4e0780980765a86:()=>Ro,__wbindgen_cast_0000000000000001:()=>zo,__wbindgen_cast_0000000000000002:()=>Bo,__wbindgen_cast_0000000000000003:()=>Vo,__wbindgen_cast_0000000000000004:()=>Ho,__wbindgen_cast_0000000000000005:()=>Uo,__wbindgen_cast_0000000000000006:()=>Wo,__wbindgen_cast_0000000000000007:()=>Go,__wbindgen_cast_0000000000000008:()=>Ko,__wbindgen_cast_0000000000000009:()=>qo,__wbindgen_cast_000000000000000a:()=>Jo,__wbindgen_init_externref_table:()=>Yo,getVersions:()=>yn,start:()=>bn}),Ee=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,rs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_attachment_free(e,0)}static decrypt(e){B(e,$e);let t=Z.attachment_decrypt(e.__wbg_ptr);if(t[3])throw Y(t[2]);var n=V(t[0],t[1]).slice();return Z.__wbindgen_free(t[0],t[1]*1,1),n}static encrypt(e){let t=K(e,Z.__wbindgen_malloc),n=X,r=Z.attachment_encrypt(t,n);if(r[2])throw Y(r[1]);return $e.__wrap(r[0])}};Symbol.dispose&&(Ee.prototype[Symbol.dispose]=Ee.prototype.free);var D=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,is.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,is.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_backupdecryptionkey_free(e,0)}static createRandomKey(){let t=Z.backupdecryptionkey_createRandomKey();return e.__wrap(t)}decryptV1(e,t,n){let r,i;try{let s=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),c=X,l=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),u=X,d=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),f=X,p=Z.backupdecryptionkey_decryptV1(this.__wbg_ptr,s,c,l,u,d,f);var a=p[0],o=p[1];if(p[3])throw a=0,o=0,Y(p[2]);return r=a,i=o,U(a,o)}finally{Z.__wbindgen_free(r,i,1)}}static fromBase64(t){let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.backupdecryptionkey_fromBase64(n,r);if(i[2])throw Y(i[1]);return e.__wrap(i[0])}get megolmV1PublicKey(){let e=Z.backupdecryptionkey_megolmV1PublicKey(this.__wbg_ptr);return vt.__wrap(e)}toBase64(){return Z.backupdecryptionkey_toBase64(this.__wbg_ptr)}};Symbol.dispose&&(D.prototype[Symbol.dispose]=D.prototype.free);var De=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,as.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,as.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_backupkeys_free(e,0)}get decryptionKeyBase64(){return Z.backupkeys_decryptionKeyBase64(this.__wbg_ptr)}get backupVersion(){let e=Z.__wbg_get_backupkeys_backupVersion(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get decryptionKey(){let e=Z.__wbg_get_backupkeys_decryptionKey(this.__wbg_ptr);return e===0?void 0:D.__wrap(e)}set backupVersion(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_backupkeys_backupVersion(this.__wbg_ptr,t,n)}set decryptionKey(e){let t=0;G(e)||(B(e,D),t=e.__destroy_into_raw()),Z.__wbg_set_backupkeys_decryptionKey(this.__wbg_ptr,t)}};Symbol.dispose&&(De.prototype[Symbol.dispose]=De.prototype.free);var Oe=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,os.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,os.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_backupsecretsbundle_free(e,0)}get backup_version(){let e,t;try{let n=Z.__wbg_get_backupsecretsbundle_backup_version(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get key(){let e,t;try{let n=Z.__wbg_get_backupsecretsbundle_key(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}set backup_version(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_backupsecretsbundle_backup_version(this.__wbg_ptr,t,n)}set key(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_backupsecretsbundle_key(this.__wbg_ptr,t,n)}};Symbol.dispose&&(Oe.prototype[Symbol.dispose]=Oe.prototype.free);var ke=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ss.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ss.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_base64encodedpkmessage_free(e,0)}constructor(e,t,n){let r=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X,s=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),c=X,l=Z.base64encodedpkmessage_new(r,i,a,o,s,c);return this.__wbg_ptr=l,ss.register(this,this.__wbg_ptr,this),this}get ciphertext(){let e,t;try{let n=Z.__wbg_get_base64encodedpkmessage_ciphertext(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get ephemeralKey(){let e,t;try{let n=Z.__wbg_get_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get mac(){let e,t;try{let n=Z.__wbg_get_base64encodedpkmessage_mac(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}set ciphertext(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_base64encodedpkmessage_ciphertext(this.__wbg_ptr,t,n)}set ephemeralKey(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_base64encodedpkmessage_ephemeralKey(this.__wbg_ptr,t,n)}set mac(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_base64encodedpkmessage_mac(this.__wbg_ptr,t,n)}};Symbol.dispose&&(ke.prototype[Symbol.dispose]=ke.prototype.free);var Ae=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,cs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_basemigrationdata_free(e,0)}constructor(){let e=Z.basemigrationdata_new();return this.__wbg_ptr=e,cs.register(this,this.__wbg_ptr,this),this}get backupRecoveryKey(){let e=Z.__wbg_get_basemigrationdata_backupRecoveryKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get backupVersion(){let e=Z.__wbg_get_basemigrationdata_backupVersion(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get deviceId(){let e=Z.__wbg_get_basemigrationdata_deviceId(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}get pickledAccount(){let e,t;try{let n=Z.__wbg_get_basemigrationdata_pickledAccount(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get privateCrossSigningMasterKey(){let e=Z.__wbg_get_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get privateCrossSigningSelfSigningKey(){let e=Z.__wbg_get_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get privateCrossSigningUserSigningKey(){let e=Z.__wbg_get_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get userId(){let e=Z.__wbg_get_basemigrationdata_userId(this.__wbg_ptr);return e===0?void 0:L.__wrap(e)}set backupRecoveryKey(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_basemigrationdata_backupRecoveryKey(this.__wbg_ptr,t,n)}set backupVersion(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_basemigrationdata_backupVersion(this.__wbg_ptr,t,n)}set deviceId(e){let t=0;G(e)||(B(e,M),t=e.__destroy_into_raw()),Z.__wbg_set_basemigrationdata_deviceId(this.__wbg_ptr,t)}set pickledAccount(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_basemigrationdata_pickledAccount(this.__wbg_ptr,t,n)}set privateCrossSigningMasterKey(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_basemigrationdata_privateCrossSigningMasterKey(this.__wbg_ptr,t,n)}set privateCrossSigningSelfSigningKey(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_basemigrationdata_privateCrossSigningSelfSigningKey(this.__wbg_ptr,t,n)}set privateCrossSigningUserSigningKey(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_basemigrationdata_privateCrossSigningUserSigningKey(this.__wbg_ptr,t,n)}set userId(e){let t=0;G(e)||(B(e,L),t=e.__destroy_into_raw()),Z.__wbg_set_basemigrationdata_userId(this.__wbg_ptr,t)}};Symbol.dispose&&(Ae.prototype[Symbol.dispose]=Ae.prototype.free);var je=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ls.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ls.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_cancelinfo_free(e,0)}cancelCode(){let e,t;try{let n=Z.cancelinfo_cancelCode(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}cancelledbyUs(){return Z.cancelinfo_cancelledbyUs(this.__wbg_ptr)!==0}reason(){return Z.cancelinfo_reason(this.__wbg_ptr)}};Symbol.dispose&&(je.prototype[Symbol.dispose]=je.prototype.free);var Me=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,us.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,us.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_checkcode_free(e,0)}as_bytes(){let e=Z.checkcode_as_bytes(this.__wbg_ptr);var t=V(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*1,1),t}to_digit(){return Z.checkcode_to_digit(this.__wbg_ptr)}};Symbol.dispose&&(Me.prototype[Symbol.dispose]=Me.prototype.free);var O=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ds.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ds.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_collectstrategy_free(e,0)}static allDevices(){let t=Z.collectstrategy_allDevices();return e.__wrap(t)}static deviceBasedStrategy(t,n){let r=Z.collectstrategy_deviceBasedStrategy(t,n);return e.__wrap(r)}eq(t){return B(t,e),Z.collectstrategy_eq(this.__wbg_ptr,t.__wbg_ptr)!==0}static errorOnUnverifiedUserProblem(){let t=Z.collectstrategy_errorOnUnverifiedUserProblem();return e.__wrap(t)}static identityBasedStrategy(){let t=Z.collectstrategy_identityBasedStrategy();return e.__wrap(t)}static onlyTrustedDevices(){let t=Z.collectstrategy_onlyTrustedDevices();return e.__wrap(t)}};Symbol.dispose&&(O.prototype[Symbol.dispose]=O.prototype.free);var Ne=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,fs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,fs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_crosssigningbootstraprequests_free(e,0)}get uploadKeysRequest(){return Z.__wbg_get_crosssigningbootstraprequests_uploadKeysRequest(this.__wbg_ptr)}get uploadSignaturesRequest(){let e=Z.__wbg_get_crosssigningbootstraprequests_uploadSignaturesRequest(this.__wbg_ptr);return nn.__wrap(e)}get uploadSigningKeysRequest(){let e=Z.__wbg_get_crosssigningbootstraprequests_uploadSigningKeysRequest(this.__wbg_ptr);return mn.__wrap(e)}};Symbol.dispose&&(Ne.prototype[Symbol.dispose]=Ne.prototype.free);var Pe=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ps.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ps.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_crosssigningkeyexport_free(e,0)}get masterKey(){let e=Z.crosssigningkeyexport_masterKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get self_signing_key(){let e=Z.crosssigningkeyexport_self_signing_key(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get userSigningKey(){let e=Z.crosssigningkeyexport_userSigningKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}};Symbol.dispose&&(Pe.prototype[Symbol.dispose]=Pe.prototype.free);var Fe=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ms.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ms.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_crosssigningstatus_free(e,0)}get hasMaster(){return Z.crosssigningstatus_hasMaster(this.__wbg_ptr)!==0}get hasSelfSigning(){return Z.crosssigningstatus_hasSelfSigning(this.__wbg_ptr)!==0}get hasUserSigning(){return Z.crosssigningstatus_hasUserSigning(this.__wbg_ptr)!==0}};Symbol.dispose&&(Fe.prototype[Symbol.dispose]=Fe.prototype.free);var k=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,hs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,hs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_curve25519publickey_free(e,0)}get length(){return Z.curve25519publickey_length(this.__wbg_ptr)>>>0}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.curve25519publickey_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],hs.register(this,this.__wbg_ptr,this),this}toBase64(){let e,t;try{let n=Z.curve25519publickey_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(k.prototype[Symbol.dispose]=k.prototype.free);var Ie=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,gs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,gs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_curve25519secretkey_free(e,0)}static fromBase64(t){let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.curve25519secretkey_fromBase64(n,r);if(i[2])throw Y(i[1]);return e.__wrap(i[0])}static fromUint8Array(t){let n=K(t,Z.__wbindgen_malloc),r=X,i=Z.curve25519secretkey_fromUint8Array(n,r);if(i[2])throw Y(i[1]);return e.__wrap(i[0])}static new(){let t=Z.curve25519secretkey_new();return e.__wrap(t)}toBase64(){let e,t;try{let n=Z.curve25519secretkey_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}toUint8Array(){let e=Z.curve25519secretkey_toUint8Array(this.__wbg_ptr);var t=V(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*1,1),t}};Symbol.dispose&&(Ie.prototype[Symbol.dispose]=Ie.prototype.free);var Le=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,_s.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,_s.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_decryptedroomevent_free(e,0)}get forwarder(){let e=Z.decryptedroomevent_forwarder(this.__wbg_ptr);return e===0?void 0:L.__wrap(e)}get forwarderDevice(){let e=Z.decryptedroomevent_forwarderDevice(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}get forwardingCurve25519KeyChain(){return Z.decryptedroomevent_forwardingCurve25519KeyChain(this.__wbg_ptr)}get sender(){let e=Z.decryptedroomevent_sender(this.__wbg_ptr);return L.__wrap(e)}get senderClaimedEd25519Key(){return Z.decryptedroomevent_senderClaimedEd25519Key(this.__wbg_ptr)}get senderCurve25519Key(){let e,t;try{let n=Z.decryptedroomevent_senderCurve25519Key(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get senderDevice(){let e=Z.decryptedroomevent_senderDevice(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}shieldState(e){let t=Z.decryptedroomevent_shieldState(this.__wbg_ptr,e);return Qt.__wrap(t)}get event(){return Z.__wbg_get_decryptedroomevent_event(this.__wbg_ptr)}};Symbol.dispose&&(Le.prototype[Symbol.dispose]=Le.prototype.free);var Re=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,vs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,vs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_decryptedtodeviceevent_free(e,0)}get type(){return Z.decryptedtodeviceevent_type(this.__wbg_ptr)}get encryptionInfo(){let e=Z.__wbg_get_decryptedtodeviceevent_encryptionInfo(this.__wbg_ptr);return sn.__wrap(e)}get rawEvent(){return Z.__wbg_get_decryptedtodeviceevent_rawEvent(this.__wbg_ptr)}};Symbol.dispose&&(Re.prototype[Symbol.dispose]=Re.prototype.free);var A=Object.freeze({MissingRoomKey:0,0:`MissingRoomKey`,UnknownMessageIndex:1,1:`UnknownMessageIndex`,MismatchedIdentityKeys:2,2:`MismatchedIdentityKeys`,UnknownSenderDevice:3,3:`UnknownSenderDevice`,UnsignedSenderDevice:4,4:`UnsignedSenderDevice`,SenderIdentityVerificationViolation:5,5:`SenderIdentityVerificationViolation`,UnableToDecrypt:6,6:`UnableToDecrypt`,MismatchedSender:7,7:`MismatchedSender`}),ze=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ys.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_decryptionsettings_free(e,0)}constructor(e){let t=Z.decryptionsettings_new(e);return this.__wbg_ptr=t,ys.register(this,this.__wbg_ptr,this),this}get sender_device_trust_requirement(){return Z.__wbg_get_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr)}set sender_device_trust_requirement(e){Z.__wbg_set_decryptionsettings_sender_device_trust_requirement(this.__wbg_ptr,e)}};Symbol.dispose&&(ze.prototype[Symbol.dispose]=ze.prototype.free);var Be=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,bs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,bs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_dehydrateddevice_free(e,0)}keysForUpload(e,t){return B(t,j),Z.dehydrateddevice_keysForUpload(this.__wbg_ptr,e,t.__wbg_ptr)}};Symbol.dispose&&(Be.prototype[Symbol.dispose]=Be.prototype.free);var j=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,xs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,xs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_dehydrateddevicekey_free(e,0)}static createKeyFromArray(t){let n=Z.dehydrateddevicekey_createKeyFromArray(t);if(n[2])throw Y(n[1]);return e.__wrap(n[0])}static createRandomKey(){let t=Z.dehydrateddevicekey_createRandomKey();return e.__wrap(t)}toBase64(){return Z.dehydrateddevicekey_toBase64(this.__wbg_ptr)}};Symbol.dispose&&(j.prototype[Symbol.dispose]=j.prototype.free);var Ve=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ss.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ss.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_dehydrateddevices_free(e,0)}create(){return Z.dehydrateddevices_create(this.__wbg_ptr)}deleteDehydratedDeviceKey(){return Z.dehydrateddevices_deleteDehydratedDeviceKey(this.__wbg_ptr)}getDehydratedDeviceKey(){return Z.dehydrateddevices_getDehydratedDeviceKey(this.__wbg_ptr)}rehydrate(e,t,n){B(e,j),B(t,M);let r=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X;return Z.dehydrateddevices_rehydrate(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i)}saveDehydratedDeviceKey(e){return B(e,j),Z.dehydrateddevices_saveDehydratedDeviceKey(this.__wbg_ptr,e.__wbg_ptr)}};Symbol.dispose&&(Ve.prototype[Symbol.dispose]=Ve.prototype.free);var He=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Cs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Cs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_device_free(e,0)}get algorithms(){return Z.device_algorithms(this.__wbg_ptr)}get curve25519Key(){let e=Z.device_curve25519Key(this.__wbg_ptr);return e===0?void 0:k.__wrap(e)}get deviceId(){let e=Z.device_deviceId(this.__wbg_ptr);return M.__wrap(e)}get displayName(){let e=Z.device_displayName(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get ed25519Key(){let e=Z.device_ed25519Key(this.__wbg_ptr);return e===0?void 0:Xe.__wrap(e)}encryptToDeviceEvent(e,t,n){let r=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=0;return G(n)||(B(n,O),a=n.__destroy_into_raw()),Z.device_encryptToDeviceEvent(this.__wbg_ptr,r,i,t,a)}firstTimeSeen(){let e=Z.device_firstTimeSeen(this.__wbg_ptr);return BigInt.asUintN(64,e)}getKey(e){let t=Z.device_getKey(this.__wbg_ptr,e);if(t[2])throw Y(t[1]);return t[0]===0?void 0:Ue.__wrap(t[0])}isBlacklisted(){return Z.device_isBlacklisted(this.__wbg_ptr)!==0}isCrossSignedByOwner(){return Z.device_isCrossSignedByOwner(this.__wbg_ptr)!==0}isCrossSigningTrusted(){return Z.device_isCrossSigningTrusted(this.__wbg_ptr)!==0}get isDehydrated(){return Z.device_isDehydrated(this.__wbg_ptr)!==0}isDeleted(){return Z.device_isDeleted(this.__wbg_ptr)!==0}isLocallyTrusted(){return Z.device_isLocallyTrusted(this.__wbg_ptr)!==0}isVerified(){return Z.device_isVerified(this.__wbg_ptr)!==0}get keys(){return Z.device_keys(this.__wbg_ptr)}get localTrustState(){return Z.device_localTrustState(this.__wbg_ptr)}requestVerification(e){var t=G(e)?0:q(e,Z.__wbindgen_malloc),n=X;let r=Z.device_requestVerification(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return Y(r[0])}setLocalTrust(e){return Z.device_setLocalTrust(this.__wbg_ptr,e)}get signatures(){let e=Z.device_signatures(this.__wbg_ptr);return an.__wrap(e)}get userId(){let e=Z.device_userId(this.__wbg_ptr);return L.__wrap(e)}verify(){return Z.device_verify(this.__wbg_ptr)}};Symbol.dispose&&(He.prototype[Symbol.dispose]=He.prototype.free);var M=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ws.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ws.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_deviceid_free(e,0)}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.deviceid_new(t,n);return this.__wbg_ptr=r,ws.register(this,this.__wbg_ptr,this),this}toString(){let e,t;try{let n=Z.deviceid_toString(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(M.prototype[Symbol.dispose]=M.prototype.free);var Ue=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ts.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ts.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_devicekey_free(e,0)}get curve25519(){let e=Z.devicekey_curve25519(this.__wbg_ptr);return e===0?void 0:k.__wrap(e)}get ed25519(){let e=Z.devicekey_ed25519(this.__wbg_ptr);return e===0?void 0:Xe.__wrap(e)}get name(){return Z.devicekey_name(this.__wbg_ptr)}toBase64(){let e,t;try{let n=Z.devicekey_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get unknown(){let e=Z.devicekey_unknown(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}};Symbol.dispose&&(Ue.prototype[Symbol.dispose]=Ue.prototype.free);var We=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Es.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Es.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_devicekeyalgorithm_free(e,0)}get name(){return Z.devicekeyalgorithm_name(this.__wbg_ptr)}toString(){let e,t;try{let n=Z.devicekeyalgorithm_toString(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(We.prototype[Symbol.dispose]=We.prototype.free);var Ge=Object.freeze({Ed25519:0,0:`Ed25519`,Curve25519:1,1:`Curve25519`,Unknown:3,3:`Unknown`}),Ke=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ds.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ds.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_devicekeyid_free(e,0)}get algorithm(){let e=Z.devicekeyid_algorithm(this.__wbg_ptr);return We.__wrap(e)}get deviceId(){let e=Z.devicekeyid_deviceId(this.__wbg_ptr);return M.__wrap(e)}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.devicekeyid_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],Ds.register(this,this.__wbg_ptr,this),this}toString(){let e,t;try{let n=Z.devicekeyid_toString(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(Ke.prototype[Symbol.dispose]=Ke.prototype.free);var qe=Object.freeze({Curve25519:0,0:`Curve25519`,Ed25519:1,1:`Ed25519`,Unknown:2,2:`Unknown`}),Je=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Os.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_devicelists_free(e,0)}get changed(){let e=Z.devicelists_changed(this.__wbg_ptr);var t=Gc(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*4,4),t}isEmpty(){return Z.devicelists_isEmpty(this.__wbg_ptr)!==0}get left(){let e=Z.devicelists_left(this.__wbg_ptr);var t=Gc(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*4,4),t}constructor(e,t){var n=G(e)?0:q(e,Z.__wbindgen_malloc),r=X,i=G(t)?0:q(t,Z.__wbindgen_malloc),a=X;let o=Z.devicelists_new(n,r,i,a);if(o[2])throw Y(o[1]);return this.__wbg_ptr=o[0],Os.register(this,this.__wbg_ptr,this),this}};Symbol.dispose&&(Je.prototype[Symbol.dispose]=Je.prototype.free);var Ye=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ks.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_ecies_free(e,0)}establish_inbound_channel(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.ecies_establish_inbound_channel(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return st.__wrap(r[0])}establish_outbound_channel(e,t){B(e,k);let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.ecies_establish_outbound_channel(this.__wbg_ptr,e.__wbg_ptr,n,r);if(i[2])throw Y(i[1]);return wt.__wrap(i[0])}constructor(){let e=Z.ecies_new();return this.__wbg_ptr=e,ks.register(this,this.__wbg_ptr,this),this}public_key(){let e=Z.ecies_public_key(this.__wbg_ptr);return k.__wrap(e)}};Symbol.dispose&&(Ye.prototype[Symbol.dispose]=Ye.prototype.free);var Xe=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,As.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,As.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_ed25519publickey_free(e,0)}get length(){return Z.ed25519publickey_length(this.__wbg_ptr)>>>0}toBase64(){let e,t;try{let n=Z.ed25519publickey_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(Xe.prototype[Symbol.dispose]=Xe.prototype.free);var Ze=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,js.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,js.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_ed25519signature_free(e,0)}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.ed25519signature_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],js.register(this,this.__wbg_ptr,this),this}toBase64(){let e,t;try{let n=Z.ed25519signature_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(Ze.prototype[Symbol.dispose]=Ze.prototype.free);var Qe=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ms.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ms.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_emoji_free(e,0)}get description(){return Z.emoji_description(this.__wbg_ptr)}get symbol(){return Z.emoji_symbol(this.__wbg_ptr)}};Symbol.dispose&&(Qe.prototype[Symbol.dispose]=Qe.prototype.free);var $e=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ns.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ns.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_encryptedattachment_free(e,0)}get encryptedData(){let e=Z.encryptedattachment_encryptedData(this.__wbg_ptr);var t=V(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*1,1),t}get hasMediaEncryptionInfoBeenConsumed(){return Z.encryptedattachment_hasMediaEncryptionInfoBeenConsumed(this.__wbg_ptr)!==0}get mediaEncryptionInfo(){let e=Z.encryptedattachment_mediaEncryptionInfo(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}constructor(e,t){let n=K(e,Z.__wbindgen_malloc),r=X,i=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),a=X,o=Z.encryptedattachment_new(n,r,i,a);if(o[2])throw Y(o[1]);return this.__wbg_ptr=o[0],Ns.register(this,this.__wbg_ptr,this),this}};Symbol.dispose&&($e.prototype[Symbol.dispose]=$e.prototype.free);var et=Object.freeze({OlmV1Curve25519AesSha2:0,0:`OlmV1Curve25519AesSha2`,MegolmV1AesSha2:1,1:`MegolmV1AesSha2`,Unknown:2,2:`Unknown`}),tt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ps.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ps.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_encryptioninfo_free(e,0)}shieldState(e){let t=Z.encryptioninfo_shieldState(this.__wbg_ptr,e);return Qt.__wrap(t)}get forwarderDevice(){let e=Z.__wbg_get_encryptioninfo_forwarderDevice(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}get forwarder(){let e=Z.__wbg_get_encryptioninfo_forwarder(this.__wbg_ptr);return e===0?void 0:L.__wrap(e)}get senderClaimedEd25519Key(){let e=Z.__wbg_get_encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get senderCurve25519Key(){let e,t;try{let n=Z.__wbg_get_encryptioninfo_senderCurve25519Key(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get senderDevice(){let e=Z.__wbg_get_encryptioninfo_senderDevice(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}get sender(){let e=Z.__wbg_get_encryptioninfo_sender(this.__wbg_ptr);return L.__wrap(e)}set forwarderDevice(e){let t=0;G(e)||(B(e,M),t=e.__destroy_into_raw()),Z.__wbg_set_encryptioninfo_forwarderDevice(this.__wbg_ptr,t)}set forwarder(e){let t=0;G(e)||(B(e,L),t=e.__destroy_into_raw()),Z.__wbg_set_encryptioninfo_forwarder(this.__wbg_ptr,t)}set senderClaimedEd25519Key(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_encryptioninfo_senderClaimedEd25519Key(this.__wbg_ptr,t,n)}set senderCurve25519Key(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_encryptioninfo_senderCurve25519Key(this.__wbg_ptr,t,n)}set senderDevice(e){let t=0;G(e)||(B(e,M),t=e.__destroy_into_raw()),Z.__wbg_set_encryptioninfo_senderDevice(this.__wbg_ptr,t)}set sender(e){B(e,L);var t=e.__destroy_into_raw();Z.__wbg_set_encryptioninfo_sender(this.__wbg_ptr,t)}};Symbol.dispose&&(tt.prototype[Symbol.dispose]=tt.prototype.free);var nt=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Fs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_encryptionsettings_free(e,0)}constructor(){let e=Z.encryptionsettings_new();return this.__wbg_ptr=e,Fs.register(this,this.__wbg_ptr,this),this}get algorithm(){return Z.__wbg_get_encryptionsettings_algorithm(this.__wbg_ptr)}get encryptStateEvents(){return Z.__wbg_get_encryptionsettings_encryptStateEvents(this.__wbg_ptr)!==0}get historyVisibility(){return Z.__wbg_get_encryptionsettings_historyVisibility(this.__wbg_ptr)}get rotationPeriodMessages(){let e=Z.__wbg_get_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr);return BigInt.asUintN(64,e)}get rotationPeriod(){let e=Z.__wbg_get_encryptionsettings_rotationPeriod(this.__wbg_ptr);return BigInt.asUintN(64,e)}get sharingStrategy(){let e=Z.__wbg_get_encryptionsettings_sharingStrategy(this.__wbg_ptr);return O.__wrap(e)}set algorithm(e){Z.__wbg_set_encryptionsettings_algorithm(this.__wbg_ptr,e)}set encryptStateEvents(e){Z.__wbg_set_encryptionsettings_encryptStateEvents(this.__wbg_ptr,e)}set historyVisibility(e){Z.__wbg_set_encryptionsettings_historyVisibility(this.__wbg_ptr,e)}set rotationPeriodMessages(e){Z.__wbg_set_encryptionsettings_rotationPeriodMessages(this.__wbg_ptr,e)}set rotationPeriod(e){Z.__wbg_set_encryptionsettings_rotationPeriod(this.__wbg_ptr,e)}set sharingStrategy(e){B(e,O);var t=e.__destroy_into_raw();Z.__wbg_set_encryptionsettings_sharingStrategy(this.__wbg_ptr,t)}};Symbol.dispose&&(nt.prototype[Symbol.dispose]=nt.prototype.free);var rt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Is.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Is.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_establishedecies_free(e,0)}check_code(){let e=Z.establishedecies_check_code(this.__wbg_ptr);return Me.__wrap(e)}decrypt(e){let t,n;try{let a=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X,s=Z.establishedecies_decrypt(this.__wbg_ptr,a,o);var r=s[0],i=s[1];if(s[3])throw r=0,i=0,Y(s[2]);return t=r,n=i,U(r,i)}finally{Z.__wbindgen_free(t,n,1)}}encrypt(e){let t,n;try{let r=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=Z.establishedecies_encrypt(this.__wbg_ptr,r,i);return t=a[0],n=a[1],U(a[0],a[1])}finally{Z.__wbindgen_free(t,n,1)}}public_key(){let e=Z.establishedecies_public_key(this.__wbg_ptr);return k.__wrap(e)}};Symbol.dispose&&(rt.prototype[Symbol.dispose]=rt.prototype.free);var it=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ls.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_eventid_free(e,0)}get localpart(){let e,t;try{let n=Z.eventid_localpart(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.eventid_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],Ls.register(this,this.__wbg_ptr,this),this}get serverName(){let e=Z.eventid_serverName(this.__wbg_ptr);return e===0?void 0:Xt.__wrap(e)}toString(){let e,t;try{let n=Z.eventid_toString(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(it.prototype[Symbol.dispose]=it.prototype.free);var at=Object.freeze({Invited:0,0:`Invited`,Joined:1,1:`Joined`,Shared:2,2:`Shared`,WorldReadable:3,3:`WorldReadable`}),ot=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Rs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Rs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_identitykeys_free(e,0)}get curve25519(){let e=Z.__wbg_get_identitykeys_curve25519(this.__wbg_ptr);return k.__wrap(e)}get ed25519(){let e=Z.__wbg_get_identitykeys_ed25519(this.__wbg_ptr);return Xe.__wrap(e)}set curve25519(e){B(e,k);var t=e.__destroy_into_raw();Z.__wbg_set_identitykeys_curve25519(this.__wbg_ptr,t)}set ed25519(e){B(e,Xe);var t=e.__destroy_into_raw();Z.__wbg_set_identitykeys_ed25519(this.__wbg_ptr,t)}};Symbol.dispose&&(ot.prototype[Symbol.dispose]=ot.prototype.free);var st=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,zs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,zs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_inboundcreationresult_free(e,0)}get channel(){let e=Z.__wbg_get_inboundcreationresult_channel(this.__wbg_ptr);return rt.__wrap(e)}get message(){let e,t;try{let n=Z.__wbg_get_inboundcreationresult_message(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}set channel(e){B(e,rt);var t=e.__destroy_into_raw();Z.__wbg_set_inboundcreationresult_channel(this.__wbg_ptr,t)}set message(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_inboundcreationresult_message(this.__wbg_ptr,t,n)}};Symbol.dispose&&(st.prototype[Symbol.dispose]=st.prototype.free);var ct=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Bs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Bs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_inboundgroupsession_free(e,0)}hasBeenImported(){return Z.inboundgroupsession_hasBeenImported(this.__wbg_ptr)!==0}get roomId(){let e=Z.inboundgroupsession_roomId(this.__wbg_ptr);return F.__wrap(e)}get senderKey(){let e=Z.inboundgroupsession_senderKey(this.__wbg_ptr);return k.__wrap(e)}get sessionId(){let e,t;try{let n=Z.inboundgroupsession_sessionId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(ct.prototype[Symbol.dispose]=ct.prototype.free);var lt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Vs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Vs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_invalidtodeviceevent_free(e,0)}get rawEvent(){return Z.__wbg_get_invalidtodeviceevent_rawEvent(this.__wbg_ptr)}get type(){return Z.invalidtodeviceevent_type(this.__wbg_ptr)}};Symbol.dispose&&(lt.prototype[Symbol.dispose]=lt.prototype.free);var ut=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Hs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Hs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_keysbackuprequest_free(e,0)}get body(){return Z.__wbg_get_keysbackuprequest_body(this.__wbg_ptr)}get id(){return Z.__wbg_get_keysbackuprequest_id(this.__wbg_ptr)}get version(){return Z.__wbg_get_keysbackuprequest_version(this.__wbg_ptr)}constructor(e,t,n){let r=Z.keysbackuprequest_new(e,t,n);return this.__wbg_ptr=r,Hs.register(this,this.__wbg_ptr,this),this}get type(){return Z.keysbackuprequest_type(this.__wbg_ptr)}};Symbol.dispose&&(ut.prototype[Symbol.dispose]=ut.prototype.free);var dt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Us.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Us.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_keysclaimrequest_free(e,0)}get body(){return Z.__wbg_get_keysclaimrequest_body(this.__wbg_ptr)}get id(){return Z.__wbg_get_keysclaimrequest_id(this.__wbg_ptr)}constructor(e,t){let n=Z.keysclaimrequest_new(e,t);return this.__wbg_ptr=n,Us.register(this,this.__wbg_ptr,this),this}get type(){return Z.keysclaimrequest_type(this.__wbg_ptr)}};Symbol.dispose&&(dt.prototype[Symbol.dispose]=dt.prototype.free);var ft=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ws.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ws.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_keysqueryrequest_free(e,0)}get body(){return Z.__wbg_get_keysqueryrequest_body(this.__wbg_ptr)}get id(){return Z.__wbg_get_keysqueryrequest_id(this.__wbg_ptr)}constructor(e,t){let n=Z.keysqueryrequest_new(e,t);return this.__wbg_ptr=n,Ws.register(this,this.__wbg_ptr,this),this}get type(){return Z.keysqueryrequest_type(this.__wbg_ptr)}};Symbol.dispose&&(ft.prototype[Symbol.dispose]=ft.prototype.free);var pt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Gs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Gs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_keysuploadrequest_free(e,0)}get body(){return Z.__wbg_get_keysuploadrequest_body(this.__wbg_ptr)}get id(){return Z.__wbg_get_keysuploadrequest_id(this.__wbg_ptr)}constructor(e,t){let n=Z.keysuploadrequest_new(e,t);return this.__wbg_ptr=n,Gs.register(this,this.__wbg_ptr,this),this}get type(){return Z.keysuploadrequest_type(this.__wbg_ptr)}};Symbol.dispose&&(pt.prototype[Symbol.dispose]=pt.prototype.free);var mt=Object.freeze({Verified:0,0:`Verified`,BlackListed:1,1:`BlackListed`,Ignored:2,2:`Ignored`,Unset:3,3:`Unset`}),ht=Object.freeze({Trace:0,0:`Trace`,Debug:1,1:`Debug`,Info:2,2:`Info`,Warn:3,3:`Warn`,Error:4,4:`Error`}),gt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ks.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ks.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_maybesignature_free(e,0)}get invalidSignatureSource(){let e=Z.maybesignature_invalidSignatureSource(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}isInvalid(){return Z.maybesignature_isInvalid(this.__wbg_ptr)!==0}isValid(){return Z.maybesignature_isValid(this.__wbg_ptr)!==0}get signature(){let e=Z.maybesignature_signature(this.__wbg_ptr);return e===0?void 0:en.__wrap(e)}};Symbol.dispose&&(gt.prototype[Symbol.dispose]=gt.prototype.free);var _t=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,qs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,qs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_megolmdecryptionerror_free(e,0)}get code(){return Z.__wbg_get_megolmdecryptionerror_code(this.__wbg_ptr)}get description(){return Z.__wbg_get_megolmdecryptionerror_description(this.__wbg_ptr)}get maybe_withheld(){let e=Z.megolmdecryptionerror_maybe_withheld(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}static unable_to_decrypt(t){let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.megolmdecryptionerror_unable_to_decrypt(n,r);return e.__wrap(i)}get withheldCode(){let e=Z.megolmdecryptionerror_withheldCode(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}};Symbol.dispose&&(_t.prototype[Symbol.dispose]=_t.prototype.free);var vt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Js.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Js.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_megolmv1backupkey_free(e,0)}get algorithm(){return Z.megolmv1backupkey_algorithm(this.__wbg_ptr)}get publicKeyBase64(){return Z.megolmv1backupkey_publicKeyBase64(this.__wbg_ptr)}};Symbol.dispose&&(vt.prototype[Symbol.dispose]=vt.prototype.free);var yt=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ys.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_migration_free(e,0)}static migrateBaseData(e,t,n,r){return B(e,Ae),B(n,I),Z.migration_migrateBaseData(e.__wbg_ptr,t,n.__wbg_ptr,G(r)?0:z(r))}static migrateMegolmSessions(e,t,n,r){let i=q(e,Z.__wbindgen_malloc),a=X;B(n,I);let o=Z.migration_migrateMegolmSessions(i,a,t,n.__wbg_ptr,G(r)?0:z(r));if(o[2])throw Y(o[1]);return Y(o[0])}static migrateOlmSessions(e,t,n,r){let i=q(e,Z.__wbindgen_malloc),a=X;B(n,I);let o=Z.migration_migrateOlmSessions(i,a,t,n.__wbg_ptr,G(r)?0:z(r));if(o[2])throw Y(o[1]);return Y(o[0])}};Symbol.dispose&&(yt.prototype[Symbol.dispose]=yt.prototype.free);var bt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Xs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Xs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_msc4108intentdata_free(e,0)}get rendezvousUrl(){let e,t;try{let n=Z.__wbg_get_msc4108intentdata_rendezvousUrl(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get serverName(){let e=Z.__wbg_get_msc4108intentdata_serverName(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}set rendezvousUrl(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_msc4108intentdata_rendezvousUrl(this.__wbg_ptr,t,n)}set serverName(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_msc4108intentdata_serverName(this.__wbg_ptr,t,n)}};Symbol.dispose&&(bt.prototype[Symbol.dispose]=bt.prototype.free);var xt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Zs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Zs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_msc4388intentdata_free(e,0)}get baseUrl(){let e,t;try{let n=Z.__wbg_get_msc4388intentdata_baseUrl(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get rendezvousId(){let e,t;try{let n=Z.__wbg_get_msc4388intentdata_rendezvousId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}set baseUrl(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_msc4388intentdata_baseUrl(this.__wbg_ptr,t,n)}set rendezvousId(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_msc4388intentdata_rendezvousId(this.__wbg_ptr,t,n)}};Symbol.dispose&&(xt.prototype[Symbol.dispose]=xt.prototype.free);var St=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Qs.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Qs.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_olmmachine_free(e,0)}backupRoomKeys(){return Z.olmmachine_backupRoomKeys(this.__wbg_ptr)}bootstrapCrossSigning(e){return Z.olmmachine_bootstrapCrossSigning(this.__wbg_ptr,e)}buildRoomKeyBundle(e){return B(e,F),Z.olmmachine_buildRoomKeyBundle(this.__wbg_ptr,e.__wbg_ptr)}clearRoomPendingKeyBundle(e){return B(e,F),Z.olmmachine_clearRoomPendingKeyBundle(this.__wbg_ptr,e.__wbg_ptr)}close(){let e=this.__destroy_into_raw();Z.olmmachine_close(e)}crossSigningStatus(){return Z.olmmachine_crossSigningStatus(this.__wbg_ptr)}static decryptExportedRoomKeys(e,t){let n,r;try{let o=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),s=X,c=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),l=X,u=Z.olmmachine_decryptExportedRoomKeys(o,s,c,l);var i=u[0],a=u[1];if(u[3])throw i=0,a=0,Y(u[2]);return n=i,r=a,U(i,a)}finally{Z.__wbindgen_free(n,r,1)}}decryptRoomEvent(e,t,n){let r=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X;B(t,F),B(n,ze);let a=Z.olmmachine_decryptRoomEvent(this.__wbg_ptr,r,i,t.__wbg_ptr,n.__wbg_ptr);if(a[2])throw Y(a[1]);return Y(a[0])}dehydratedDevices(){let e=Z.olmmachine_dehydratedDevices(this.__wbg_ptr);return Ve.__wrap(e)}deleteSecretsFromInbox(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;return Z.olmmachine_deleteSecretsFromInbox(this.__wbg_ptr,t,n)}get deviceCreationTimeMs(){return Z.olmmachine_deviceCreationTimeMs(this.__wbg_ptr)}get deviceId(){let e=Z.olmmachine_deviceId(this.__wbg_ptr);return M.__wrap(e)}disableBackup(){return Z.olmmachine_disableBackup(this.__wbg_ptr)}get displayName(){return Z.olmmachine_displayName(this.__wbg_ptr)}enableBackupV1(e,t){let n=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),a=X,o=Z.olmmachine_enableBackupV1(this.__wbg_ptr,n,r,i,a);if(o[2])throw Y(o[1]);return Y(o[0])}static encryptExportedRoomKeys(e,t,n){let r,i;try{let s=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),c=X,l=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),u=X,d=Z.olmmachine_encryptExportedRoomKeys(s,c,l,u,n);var a=d[0],o=d[1];if(d[3])throw a=0,o=0,Y(d[2]);return r=a,i=o,U(a,o)}finally{Z.__wbindgen_free(r,i,1)}}encryptRoomEvent(e,t,n){B(e,F);let r=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X,s=Z.olmmachine_encryptRoomEvent(this.__wbg_ptr,e.__wbg_ptr,r,i,a,o);if(s[2])throw Y(s[1]);return Y(s[0])}encryptStateEvent(e,t,n,r){B(e,F);let i=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),a=X,o=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),s=X,c=J(r,Z.__wbindgen_malloc,Z.__wbindgen_realloc),l=X,u=Z.olmmachine_encryptStateEvent(this.__wbg_ptr,e.__wbg_ptr,i,a,o,s,c,l);if(u[2])throw Y(u[1]);return Y(u[0])}exportCrossSigningKeys(){return Z.olmmachine_exportCrossSigningKeys(this.__wbg_ptr)}exportRoomKeys(e){return Z.olmmachine_exportRoomKeys(this.__wbg_ptr,e)}exportSecretsBundle(){return Z.olmmachine_exportSecretsBundle(this.__wbg_ptr)}getAllRoomsPendingKeyBundles(){return Z.olmmachine_getAllRoomsPendingKeyBundles(this.__wbg_ptr)}getBackupKeys(){return Z.olmmachine_getBackupKeys(this.__wbg_ptr)}getDevice(e,t,n){return B(e,L),B(t,M),Z.olmmachine_getDevice(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,!G(n),G(n)?0:n)}getIdentity(e){return B(e,L),Z.olmmachine_getIdentity(this.__wbg_ptr,e.__wbg_ptr)}getMissingSessions(e){let t=q(e,Z.__wbindgen_malloc),n=X;return Z.olmmachine_getMissingSessions(this.__wbg_ptr,t,n)}getPendingKeyBundleDetailsForRoom(e){return B(e,F),Z.olmmachine_getPendingKeyBundleDetailsForRoom(this.__wbg_ptr,e.__wbg_ptr)}getReceivedRoomKeyBundleData(e,t){return B(e,F),B(t,L),Z.olmmachine_getReceivedRoomKeyBundleData(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr)}getRoomEventEncryptionInfo(e,t){let n=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X;B(t,F);let i=Z.olmmachine_getRoomEventEncryptionInfo(this.__wbg_ptr,n,r,t.__wbg_ptr);if(i[2])throw Y(i[1]);return Y(i[0])}getRoomSettings(e){return B(e,F),Z.olmmachine_getRoomSettings(this.__wbg_ptr,e.__wbg_ptr)}getSecretsFromInbox(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;return Z.olmmachine_getSecretsFromInbox(this.__wbg_ptr,t,n)}getUserDevices(e,t){return B(e,L),Z.olmmachine_getUserDevices(this.__wbg_ptr,e.__wbg_ptr,!G(t),G(t)?0:t)}getVerification(e,t){B(e,L);let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.olmmachine_getVerification(this.__wbg_ptr,e.__wbg_ptr,n,r);if(i[2])throw Y(i[1]);return Y(i[0])}getVerificationRequest(e,t){B(e,L);let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.olmmachine_getVerificationRequest(this.__wbg_ptr,e.__wbg_ptr,n,r);return i===0?void 0:_n.__wrap(i)}getVerificationRequests(e){return B(e,L),Z.olmmachine_getVerificationRequests(this.__wbg_ptr,e.__wbg_ptr)}hasDownloadedAllRoomKeys(e){return B(e,F),Z.olmmachine_hasDownloadedAllRoomKeys(this.__wbg_ptr,e.__wbg_ptr)}get identityKeys(){let e=Z.olmmachine_identityKeys(this.__wbg_ptr);return ot.__wrap(e)}importBackedUpRoomKeys(e,t,n){let r=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=Z.olmmachine_importBackedUpRoomKeys(this.__wbg_ptr,e,G(t)?0:z(t),r,i);if(a[2])throw Y(a[1]);return Y(a[0])}importCrossSigningKeys(e,t,n){var r=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=G(t)?0:J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X,s=G(n)?0:J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),c=X;return Z.olmmachine_importCrossSigningKeys(this.__wbg_ptr,r,i,a,o,s,c)}importExportedRoomKeys(e,t){let n=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.olmmachine_importExportedRoomKeys(this.__wbg_ptr,n,r,t);if(i[2])throw Y(i[1]);return Y(i[0])}importRoomKeys(e,t){let n=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.olmmachine_importRoomKeys(this.__wbg_ptr,n,r,t);if(i[2])throw Y(i[1]);return Y(i[0])}importSecretsBundle(e){B(e,Yt);var t=e.__destroy_into_raw();return Z.olmmachine_importSecretsBundle(this.__wbg_ptr,t)}static initFromStore(e,t,n,r){return B(e,L),B(t,M),B(n,I),Z.olmmachine_initFromStore(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,G(r)?0:z(r))}static initialize(e,t,n,r,i){B(e,L),B(t,M);var a=G(n)?0:J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X,s=G(r)?0:J(r,Z.__wbindgen_malloc,Z.__wbindgen_realloc),c=X;return Z.olmmachine_initialize(e.__wbg_ptr,t.__wbg_ptr,a,o,s,c,G(i)?0:z(i))}invalidateGroupSession(e){return B(e,F),Z.olmmachine_invalidateGroupSession(this.__wbg_ptr,e.__wbg_ptr)}isBackupEnabled(){return Z.olmmachine_isBackupEnabled(this.__wbg_ptr)}markAllTrackedUsersAsDirty(){return Z.olmmachine_markAllTrackedUsersAsDirty(this.__wbg_ptr)}markRequestAsSent(e,t,n){let r=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X,s=Z.olmmachine_markRequestAsSent(this.__wbg_ptr,r,i,t,a,o);if(s[2])throw Y(s[1]);return Y(s[0])}constructor(){let e=Z.olmmachine_new();if(e[2])throw Y(e[1]);return this.__wbg_ptr=e[0],Qs.register(this,this.__wbg_ptr,this),this}outgoingRequests(){return Z.olmmachine_outgoingRequests(this.__wbg_ptr)}pushSecretToVerifiedDevices(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;return Z.olmmachine_pushSecretToVerifiedDevices(this.__wbg_ptr,t,n)}queryKeysForUsers(e){let t=q(e,Z.__wbindgen_malloc),n=X,r=Z.olmmachine_queryKeysForUsers(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return ft.__wrap(r[0])}receiveRoomKeyBundle(e,t){B(e,on);var n=e.__destroy_into_raw();let r=K(t,Z.__wbindgen_malloc),i=X,a=Z.olmmachine_receiveRoomKeyBundle(this.__wbg_ptr,n,r,i);if(a[2])throw Y(a[1]);return Y(a[0])}receiveSyncChanges(e,t,n,r,i){let a=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X;B(t,Je);let s=0;G(i)||(B(i,ze),s=i.__destroy_into_raw());let c=Z.olmmachine_receiveSyncChanges(this.__wbg_ptr,a,o,t.__wbg_ptr,n,G(r)?0:z(r),s);if(c[2])throw Y(c[1]);return Y(c[0])}receiveVerificationEvent(e,t){let n=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X;B(t,F);let i=Z.olmmachine_receiveVerificationEvent(this.__wbg_ptr,n,r,t.__wbg_ptr);if(i[2])throw Y(i[1]);return Y(i[0])}registerDevicesUpdatedCallback(e){Z.olmmachine_registerDevicesUpdatedCallback(this.__wbg_ptr,e)}registerReceiveSecretCallback(e){Z.olmmachine_registerReceiveSecretCallback(this.__wbg_ptr,e)}registerRoomKeyUpdatedCallback(e){Z.olmmachine_registerRoomKeyUpdatedCallback(this.__wbg_ptr,e)}registerRoomKeysWithheldCallback(e){Z.olmmachine_registerRoomKeysWithheldCallback(this.__wbg_ptr,e)}registerUserIdentityUpdatedCallback(e){Z.olmmachine_registerUserIdentityUpdatedCallback(this.__wbg_ptr,e)}requestMissingSecretsIfNeeded(){return Z.olmmachine_requestMissingSecretsIfNeeded(this.__wbg_ptr)}roomKeyCounts(){return Z.olmmachine_roomKeyCounts(this.__wbg_ptr)}get roomKeyForwardingEnabled(){return Z.olmmachine_roomKeyForwardingEnabled(this.__wbg_ptr)!==0}get roomKeyRequestsEnabled(){return Z.olmmachine_roomKeyRequestsEnabled(this.__wbg_ptr)!==0}saveBackupDecryptionKey(e,t){B(e,D);let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X;return Z.olmmachine_saveBackupDecryptionKey(this.__wbg_ptr,e.__wbg_ptr,n,r)}setHasDownloadedAllRoomKeys(e){return B(e,F),Z.olmmachine_setHasDownloadedAllRoomKeys(this.__wbg_ptr,e.__wbg_ptr)}setRoomSettings(e,t){return B(e,F),B(t,qt),Z.olmmachine_setRoomSettings(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr)}set roomKeyForwardingEnabled(e){Z.olmmachine_set_roomKeyForwardingEnabled(this.__wbg_ptr,e)}set roomKeyRequestsEnabled(e){Z.olmmachine_set_roomKeyRequestsEnabled(this.__wbg_ptr,e)}shareRoomKey(e,t,n){B(e,F);let r=q(t,Z.__wbindgen_malloc),i=X;return B(n,nt),Z.olmmachine_shareRoomKey(this.__wbg_ptr,e.__wbg_ptr,r,i,n.__wbg_ptr)}shareRoomKeyBundleData(e,t,n,r,i){B(e,L),B(t,F);let a=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X;var s=G(r)?0:J(r,Z.__wbindgen_malloc,Z.__wbindgen_realloc),c=X;B(i,O);var l=i.__destroy_into_raw();let u=Z.olmmachine_shareRoomKeyBundleData(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,a,o,s,c,l);if(u[2])throw Y(u[1]);return Y(u[0])}sign(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;return Z.olmmachine_sign(this.__wbg_ptr,t,n)}storeRoomPendingKeyBundle(e,t){return B(e,F),B(t,L),Z.olmmachine_storeRoomPendingKeyBundle(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr)}trackedUsers(){let e=Z.olmmachine_trackedUsers(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}updateTrackedUsers(e){let t=q(e,Z.__wbindgen_malloc),n=X;return Z.olmmachine_updateTrackedUsers(this.__wbg_ptr,t,n)}get userId(){let e=Z.olmmachine_userId(this.__wbg_ptr);return L.__wrap(e)}verifyBackup(e){let t=Z.olmmachine_verifyBackup(this.__wbg_ptr,e);if(t[2])throw Y(t[1]);return Y(t[0])}};Symbol.dispose&&(St.prototype[Symbol.dispose]=St.prototype.free);var Ct=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,$s.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,$s.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_otheruseridentity_free(e,0)}hasVerificationViolation(){return Z.otheruseridentity_hasVerificationViolation(this.__wbg_ptr)!==0}identityNeedsUserApproval(){return Z.otheruseridentity_identityNeedsUserApproval(this.__wbg_ptr)!==0}isVerified(){return Z.otheruseridentity_isVerified(this.__wbg_ptr)!==0}get masterKey(){let e,t;try{let i=Z.otheruseridentity_masterKey(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,Y(i[2]);return e=n,t=r,U(n,r)}finally{Z.__wbindgen_free(e,t,1)}}pinCurrentMasterKey(){return Z.otheruseridentity_pinCurrentMasterKey(this.__wbg_ptr)}requestVerification(e,t,n){B(e,F),B(t,it);var r=G(n)?0:q(n,Z.__wbindgen_malloc),i=X;let a=Z.otheruseridentity_requestVerification(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,r,i);if(a[2])throw Y(a[1]);return _n.__wrap(a[0])}get selfSigningKey(){let e,t;try{let i=Z.otheruseridentity_selfSigningKey(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,Y(i[2]);return e=n,t=r,U(n,r)}finally{Z.__wbindgen_free(e,t,1)}}verificationRequestContent(e){let t,n;try{var r=G(e)?0:q(e,Z.__wbindgen_malloc),i=X;let s=Z.otheruseridentity_verificationRequestContent(this.__wbg_ptr,r,i);var a=s[0],o=s[1];if(s[3])throw a=0,o=0,Y(s[2]);return t=a,n=o,U(a,o)}finally{Z.__wbindgen_free(t,n,1)}}verify(){return Z.otheruseridentity_verify(this.__wbg_ptr)}wasPreviouslyVerified(){return Z.otheruseridentity_wasPreviouslyVerified(this.__wbg_ptr)!==0}withdrawVerification(){return Z.otheruseridentity_withdrawVerification(this.__wbg_ptr)}};Symbol.dispose&&(Ct.prototype[Symbol.dispose]=Ct.prototype.free);var wt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ec.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ec.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_outboundcreationresult_free(e,0)}get channel(){let e=Z.__wbg_get_outboundcreationresult_channel(this.__wbg_ptr);return rt.__wrap(e)}get initial_message(){let e,t;try{let n=Z.__wbg_get_outboundcreationresult_initial_message(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}set channel(e){B(e,rt);var t=e.__destroy_into_raw();Z.__wbg_set_outboundcreationresult_channel(this.__wbg_ptr,t)}set initial_message(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_outboundcreationresult_initial_message(this.__wbg_ptr,t,n)}};Symbol.dispose&&(wt.prototype[Symbol.dispose]=wt.prototype.free);var Tt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,tc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,tc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_ownuseridentity_free(e,0)}hasVerificationViolation(){return Z.ownuseridentity_hasVerificationViolation(this.__wbg_ptr)!==0}isVerified(){return Z.ownuseridentity_isVerified(this.__wbg_ptr)!==0}get masterKey(){let e,t;try{let i=Z.ownuseridentity_masterKey(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,Y(i[2]);return e=n,t=r,U(n,r)}finally{Z.__wbindgen_free(e,t,1)}}requestVerification(e){var t=G(e)?0:q(e,Z.__wbindgen_malloc),n=X;let r=Z.ownuseridentity_requestVerification(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return Y(r[0])}get selfSigningKey(){let e,t;try{let i=Z.ownuseridentity_selfSigningKey(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,Y(i[2]);return e=n,t=r,U(n,r)}finally{Z.__wbindgen_free(e,t,1)}}trustsOurOwnDevice(){return Z.ownuseridentity_trustsOurOwnDevice(this.__wbg_ptr)}get userSigningKey(){let e,t;try{let i=Z.ownuseridentity_userSigningKey(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,Y(i[2]);return e=n,t=r,U(n,r)}finally{Z.__wbindgen_free(e,t,1)}}verify(){return Z.ownuseridentity_verify(this.__wbg_ptr)}wasPreviouslyVerified(){return Z.ownuseridentity_wasPreviouslyVerified(this.__wbg_ptr)!==0}withdrawVerification(){return Z.ownuseridentity_withdrawVerification(this.__wbg_ptr)}};Symbol.dispose&&(Tt.prototype[Symbol.dispose]=Tt.prototype.free);var Et=class e{static __unwrap(t){return t instanceof e?t.__destroy_into_raw():0}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,nc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_pickledinboundgroupsession_free(e,0)}get backedUp(){return Z.__wbg_get_pickledinboundgroupsession_backedUp(this.__wbg_ptr)!==0}get imported(){return Z.__wbg_get_pickledinboundgroupsession_imported(this.__wbg_ptr)!==0}get pickle(){let e,t;try{let n=Z.__wbg_get_pickledinboundgroupsession_pickle(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get roomId(){let e=Z.__wbg_get_pickledinboundgroupsession_roomId(this.__wbg_ptr);return e===0?void 0:F.__wrap(e)}get senderKey(){let e,t;try{let n=Z.__wbg_get_pickledinboundgroupsession_senderKey(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get senderSigningKey(){let e=Z.__wbg_get_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}constructor(){let e=Z.pickledinboundgroupsession_new();return this.__wbg_ptr=e,nc.register(this,this.__wbg_ptr,this),this}set backedUp(e){Z.__wbg_set_pickledinboundgroupsession_backedUp(this.__wbg_ptr,e)}set imported(e){Z.__wbg_set_pickledinboundgroupsession_imported(this.__wbg_ptr,e)}set pickle(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_pickledinboundgroupsession_pickle(this.__wbg_ptr,t,n)}set roomId(e){let t=0;G(e)||(B(e,F),t=e.__destroy_into_raw()),Z.__wbg_set_pickledinboundgroupsession_roomId(this.__wbg_ptr,t)}set senderKey(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_pickledinboundgroupsession_senderKey(this.__wbg_ptr,t,n)}set senderSigningKey(e){var t=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_pickledinboundgroupsession_senderSigningKey(this.__wbg_ptr,t,n)}};Symbol.dispose&&(Et.prototype[Symbol.dispose]=Et.prototype.free);var Dt=class e{static __unwrap(t){return t instanceof e?t.__destroy_into_raw():0}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,rc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_pickledsession_free(e,0)}get createdUsingFallbackKey(){return Z.__wbg_get_pickledsession_createdUsingFallbackKey(this.__wbg_ptr)!==0}get creationTime(){return Z.__wbg_get_pickledsession_creationTime(this.__wbg_ptr)}get lastUseTime(){return Z.__wbg_get_pickledsession_lastUseTime(this.__wbg_ptr)}get pickle(){let e,t;try{let n=Z.__wbg_get_pickledsession_pickle(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get senderKey(){let e,t;try{let n=Z.__wbg_get_pickledsession_senderKey(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}constructor(){let e=Z.pickledsession_new();return this.__wbg_ptr=e,rc.register(this,this.__wbg_ptr,this),this}set createdUsingFallbackKey(e){Z.__wbg_set_pickledsession_createdUsingFallbackKey(this.__wbg_ptr,e)}set creationTime(e){Z.__wbg_set_pickledsession_creationTime(this.__wbg_ptr,e)}set lastUseTime(e){Z.__wbg_set_pickledsession_lastUseTime(this.__wbg_ptr,e)}set pickle(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_pickledsession_pickle(this.__wbg_ptr,t,n)}set senderKey(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_pickledsession_senderKey(this.__wbg_ptr,t,n)}};Symbol.dispose&&(Dt.prototype[Symbol.dispose]=Dt.prototype.free);var Ot=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ic.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ic.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_pkdecryption_free(e,0)}decrypt(e){B(e,N);let t=Z.pkdecryption_decrypt(this.__wbg_ptr,e.__wbg_ptr);if(t[3])throw Y(t[2]);var n=V(t[0],t[1]).slice();return Z.__wbindgen_free(t[0],t[1]*1,1),n}decryptString(e){let t,n;try{B(e,N);let a=Z.pkdecryption_decryptString(this.__wbg_ptr,e.__wbg_ptr);var r=a[0],i=a[1];if(a[3])throw r=0,i=0,Y(a[2]);return t=r,n=i,U(r,i)}finally{Z.__wbindgen_free(t,n,1)}}static fromKey(t){B(t,Ie);let n=Z.pkdecryption_fromKey(t.__wbg_ptr);return e.__wrap(n)}constructor(){let e=Z.pkdecryption_new();return this.__wbg_ptr=e,ic.register(this,this.__wbg_ptr,this),this}publicKey(){let e=Z.pkdecryption_publicKey(this.__wbg_ptr);return k.__wrap(e)}secretKey(){let e=Z.pkdecryption_secretKey(this.__wbg_ptr);return Ie.__wrap(e)}};Symbol.dispose&&(Ot.prototype[Symbol.dispose]=Ot.prototype.free);var kt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,ac.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,ac.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_pkencryption_free(e,0)}encrypt(e){let t=K(e,Z.__wbindgen_malloc),n=X,r=Z.pkencryption_encrypt(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return N.__wrap(r[0])}encryptString(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.pkencryption_encryptString(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return N.__wrap(r[0])}static fromKey(t){B(t,k);let n=Z.pkencryption_fromKey(t.__wbg_ptr);return e.__wrap(n)}};Symbol.dispose&&(kt.prototype[Symbol.dispose]=kt.prototype.free);var N=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,oc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,oc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_pkmessage_free(e,0)}ciphertext(){let e=Z.pkmessage_ciphertext(this.__wbg_ptr);var t=V(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*1,1),t}ephemeralKey(){let e=Z.pkmessage_ephemeralKey(this.__wbg_ptr);return k.__wrap(e)}static fromBase64(t){B(t,ke);let n=Z.pkmessage_fromBase64(t.__wbg_ptr);if(n[2])throw Y(n[1]);return e.__wrap(n[0])}static fromParts(t,n,r){let i=K(t,Z.__wbindgen_malloc),a=X,o=K(n,Z.__wbindgen_malloc),s=X;B(r,k);let c=Z.pkmessage_fromParts(i,a,o,s,r.__wbg_ptr);return e.__wrap(c)}mac(){let e=Z.pkmessage_mac(this.__wbg_ptr);var t=V(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*1,1),t}toBase64(){let e=Z.pkmessage_toBase64(this.__wbg_ptr);return ke.__wrap(e)}};Symbol.dispose&&(N.prototype[Symbol.dispose]=N.prototype.free);var At=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,sc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,sc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_plaintexttodeviceevent_free(e,0)}get rawEvent(){return Z.__wbg_get_plaintexttodeviceevent_rawEvent(this.__wbg_ptr)}get type(){return Z.plaintexttodeviceevent_type(this.__wbg_ptr)}};Symbol.dispose&&(At.prototype[Symbol.dispose]=At.prototype.free);var jt=Object.freeze({Decrypted:0,0:`Decrypted`,UnableToDecrypt:1,1:`UnableToDecrypt`,PlainText:2,2:`PlainText`,Invalid:3,3:`Invalid`}),Mt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,cc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,cc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_putdehydrateddevicerequest_free(e,0)}get body(){return Z.__wbg_get_putdehydrateddevicerequest_body(this.__wbg_ptr)}constructor(e){let t=Z.putdehydrateddevicerequest_new(e);return this.__wbg_ptr=t,cc.register(this,this.__wbg_ptr,this),this}};Symbol.dispose&&(Mt.prototype[Symbol.dispose]=Mt.prototype.free);var Nt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,lc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,lc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_qr_free(e,0)}cancel(){let e=Z.qr_cancel(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}cancelInfo(){let e=Z.qr_cancelInfo(this.__wbg_ptr);return e===0?void 0:je.__wrap(e)}cancelWithCode(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.qr_cancelWithCode(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return Y(r[0])}confirmScanning(){let e=Z.qr_confirmScanning(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}get flowId(){let e,t;try{let n=Z.qr_flowId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}hasBeenConfirmed(){return Z.qr_hasBeenConfirmed(this.__wbg_ptr)!==0}hasBeenScanned(){return Z.qr_hasBeenScanned(this.__wbg_ptr)!==0}isCancelled(){return Z.qr_isCancelled(this.__wbg_ptr)!==0}isDone(){return Z.qr_isDone(this.__wbg_ptr)!==0}isSelfVerification(){return Z.qr_isSelfVerification(this.__wbg_ptr)!==0}get otherDeviceId(){let e=Z.qr_otherDeviceId(this.__wbg_ptr);return M.__wrap(e)}get otherUserId(){let e=Z.qr_otherUserId(this.__wbg_ptr);return L.__wrap(e)}reciprocate(){let e=Z.qr_reciprocate(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}reciprocated(){return Z.qr_reciprocated(this.__wbg_ptr)!==0}registerChangesCallback(e){Z.qr_registerChangesCallback(this.__wbg_ptr,e)}get roomId(){let e=Z.qr_roomId(this.__wbg_ptr);return e===0?void 0:F.__wrap(e)}state(){return Z.qr_state(this.__wbg_ptr)}toBytes(){let e=Z.qr_toBytes(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}toQrCode(){let e=Z.qr_toQrCode(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Pt.__wrap(e[0])}get userId(){let e=Z.qr_userId(this.__wbg_ptr);return L.__wrap(e)}weStarted(){return Z.qr_weStarted(this.__wbg_ptr)!==0}};Symbol.dispose&&(Nt.prototype[Symbol.dispose]=Nt.prototype.free);var Pt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,uc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,uc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_qrcode_free(e,0)}renderIntoBuffer(){let e=Z.qrcode_renderIntoBuffer(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}};Symbol.dispose&&(Pt.prototype[Symbol.dispose]=Pt.prototype.free);var Ft=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,dc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,dc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_qrcodedata_free(e,0)}static fromBase64(t){let n=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=Z.qrcodedata_fromBase64(n,r);if(i[2])throw Y(i[1]);return e.__wrap(i[0])}static fromBytes(t){let n=K(t,Z.__wbindgen_malloc),r=X,i=Z.qrcodedata_fromBytes(n,r);if(i[2])throw Y(i[1]);return e.__wrap(i[0])}get intentData(){let e=Z.qrcodedata_intentData(this.__wbg_ptr);return Lt.__wrap(e)}get mode(){return Z.qrcodedata_mode(this.__wbg_ptr)}constructor(e,t,n){B(e,k);var r=e.__destroy_into_raw();let i=J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),a=X;var o=G(n)?0:J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),s=X;let c=Z.qrcodedata_new(r,i,a,o,s);if(c[2])throw Y(c[1]);return this.__wbg_ptr=c[0],dc.register(this,this.__wbg_ptr,this),this}static newMsc4388(t,n,r,i){B(t,k);var a=t.__destroy_into_raw();let o=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),s=X,c=J(r,Z.__wbindgen_malloc,Z.__wbindgen_realloc),l=X,u=Z.qrcodedata_newMsc4388(a,o,s,c,l,i);if(u[2])throw Y(u[1]);return e.__wrap(u[0])}get publicKey(){let e=Z.qrcodedata_publicKey(this.__wbg_ptr);return k.__wrap(e)}get rendezvousUrl(){let e=Z.qrcodedata_rendezvousUrl(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get serverName(){let e=Z.qrcodedata_serverName(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}toBase64(){let e,t;try{let n=Z.qrcodedata_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}toBytes(){let e=Z.qrcodedata_toBytes(this.__wbg_ptr);var t=V(e[0],e[1]).slice();return Z.__wbindgen_free(e[0],e[1]*1,1),t}};Symbol.dispose&&(Ft.prototype[Symbol.dispose]=Ft.prototype.free);var It=Object.freeze({Login:0,0:`Login`,Reciprocate:1,1:`Reciprocate`}),Lt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,fc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,fc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_qrcodeintentdata_free(e,0)}get msc4108(){let e=Z.__wbg_get_qrcodeintentdata_msc4108(this.__wbg_ptr);return e===0?void 0:bt.__wrap(e)}get msc4388(){let e=Z.__wbg_get_qrcodeintentdata_msc4388(this.__wbg_ptr);return e===0?void 0:xt.__wrap(e)}set msc4108(e){let t=0;G(e)||(B(e,bt),t=e.__destroy_into_raw()),Z.__wbg_set_qrcodeintentdata_msc4108(this.__wbg_ptr,t)}set msc4388(e){let t=0;G(e)||(B(e,xt),t=e.__destroy_into_raw()),Z.__wbg_set_qrcodeintentdata_msc4388(this.__wbg_ptr,t)}};Symbol.dispose&&(Lt.prototype[Symbol.dispose]=Lt.prototype.free);var Rt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,pc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,pc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_qrcodescan_free(e,0)}static fromBytes(t){let n=Z.qrcodescan_fromBytes(t);if(n[2])throw Y(n[1]);return e.__wrap(n[0])}};Symbol.dispose&&(Rt.prototype[Symbol.dispose]=Rt.prototype.free);var P=Object.freeze({Created:0,0:`Created`,Scanned:1,1:`Scanned`,Confirmed:2,2:`Confirmed`,Reciprocated:3,3:`Reciprocated`,Done:4,4:`Done`,Cancelled:5,5:`Cancelled`}),zt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,mc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,mc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_rehydrateddevice_free(e,0)}receiveEvents(e,t){let n=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X,i=0;return G(t)||(B(t,ze),i=t.__destroy_into_raw()),Z.rehydrateddevice_receiveEvents(this.__wbg_ptr,n,r,i)}};Symbol.dispose&&(zt.prototype[Symbol.dispose]=zt.prototype.free);var Bt=Object.freeze({KeysUpload:0,0:`KeysUpload`,KeysQuery:1,1:`KeysQuery`,KeysClaim:2,2:`KeysClaim`,ToDevice:3,3:`ToDevice`,SignatureUpload:4,4:`SignatureUpload`,RoomMessage:5,5:`RoomMessage`,KeysBackup:6,6:`KeysBackup`}),F=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,hc.register(n,n.__wbg_ptr,n),n}static __unwrap(t){return t instanceof e?t.__destroy_into_raw():0}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,hc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roomid_free(e,0)}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.roomid_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],hc.register(this,this.__wbg_ptr,this),this}toString(){let e,t;try{let n=Z.roomid_toString(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(F.prototype[Symbol.dispose]=F.prototype.free);var Vt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,gc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,gc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roomkeycounts_free(e,0)}get backedUp(){return Z.__wbg_get_roomkeycounts_backedUp(this.__wbg_ptr)}get total(){return Z.__wbg_get_roomkeycounts_total(this.__wbg_ptr)}set backedUp(e){Z.__wbg_set_roomkeycounts_backedUp(this.__wbg_ptr,e)}set total(e){Z.__wbg_set_roomkeycounts_total(this.__wbg_ptr,e)}};Symbol.dispose&&(Vt.prototype[Symbol.dispose]=Vt.prototype.free);var Ht=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,_c.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,_c.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roomkeyimportresult_free(e,0)}get importedCount(){return Z.__wbg_get_roomkeyimportresult_importedCount(this.__wbg_ptr)>>>0}get totalCount(){return Z.__wbg_get_roomkeyimportresult_totalCount(this.__wbg_ptr)>>>0}keys(){return Z.roomkeyimportresult_keys(this.__wbg_ptr)}};Symbol.dispose&&(Ht.prototype[Symbol.dispose]=Ht.prototype.free);var Ut=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,vc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,vc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roomkeyinfo_free(e,0)}get algorithm(){return Z.roomkeyinfo_algorithm(this.__wbg_ptr)}get roomId(){let e=Z.roomkeyinfo_roomId(this.__wbg_ptr);return F.__wrap(e)}get senderKey(){let e=Z.roomkeyinfo_senderKey(this.__wbg_ptr);return k.__wrap(e)}get sessionId(){let e,t;try{let n=Z.roomkeyinfo_sessionId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(Ut.prototype[Symbol.dispose]=Ut.prototype.free);var Wt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,yc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,yc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roomkeywithheldinfo_free(e,0)}get algorithm(){return Z.roomkeywithheldinfo_algorithm(this.__wbg_ptr)}get roomId(){let e=Z.roomkeywithheldinfo_roomId(this.__wbg_ptr);return F.__wrap(e)}get sender(){let e=Z.roomkeywithheldinfo_sender(this.__wbg_ptr);return L.__wrap(e)}get sessionId(){let e,t;try{let n=Z.roomkeywithheldinfo_sessionId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get withheldCode(){let e,t;try{let n=Z.roomkeywithheldinfo_withheldCode(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(Wt.prototype[Symbol.dispose]=Wt.prototype.free);var Gt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,bc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,bc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roommessagerequest_free(e,0)}get body(){return Z.__wbg_get_roommessagerequest_body(this.__wbg_ptr)}get event_type(){return Z.__wbg_get_roommessagerequest_event_type(this.__wbg_ptr)}get id(){return Z.__wbg_get_roommessagerequest_id(this.__wbg_ptr)}get room_id(){return Z.__wbg_get_roommessagerequest_room_id(this.__wbg_ptr)}get txn_id(){return Z.__wbg_get_roommessagerequest_txn_id(this.__wbg_ptr)}constructor(e,t,n,r,i){let a=Z.roommessagerequest_new(e,t,n,r,i);return this.__wbg_ptr=a,bc.register(this,this.__wbg_ptr,this),this}get type(){return Z.roommessagerequest_type(this.__wbg_ptr)}};Symbol.dispose&&(Gt.prototype[Symbol.dispose]=Gt.prototype.free);var Kt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,xc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,xc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roompendingkeybundledetails_free(e,0)}get inviteAcceptedAtMillis(){return Z.roompendingkeybundledetails_inviteAcceptedAtMillis(this.__wbg_ptr)}get inviterId(){let e=Z.roompendingkeybundledetails_inviterId(this.__wbg_ptr);return L.__wrap(e)}get roomId(){let e=Z.roompendingkeybundledetails_roomId(this.__wbg_ptr);return F.__wrap(e)}};Symbol.dispose&&(Kt.prototype[Symbol.dispose]=Kt.prototype.free);var qt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Sc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Sc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_roomsettings_free(e,0)}get algorithm(){return Z.__wbg_get_roomsettings_algorithm(this.__wbg_ptr)}get encryptStateEvents(){return Z.__wbg_get_roomsettings_encryptStateEvents(this.__wbg_ptr)!==0}get onlyAllowTrustedDevices(){return Z.__wbg_get_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr)!==0}get sessionRotationPeriodMessages(){let e=Z.__wbg_get_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr);return e[0]===0?void 0:e[1]}get sessionRotationPeriodMs(){let e=Z.__wbg_get_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr);return e[0]===0?void 0:e[1]}constructor(){let e=Z.roomsettings_new();return this.__wbg_ptr=e,Sc.register(this,this.__wbg_ptr,this),this}set algorithm(e){Z.__wbg_set_roomsettings_algorithm(this.__wbg_ptr,e)}set encryptStateEvents(e){Z.__wbg_set_roomsettings_encryptStateEvents(this.__wbg_ptr,e)}set onlyAllowTrustedDevices(e){Z.__wbg_set_roomsettings_onlyAllowTrustedDevices(this.__wbg_ptr,e)}set sessionRotationPeriodMessages(e){Z.__wbg_set_roomsettings_sessionRotationPeriodMessages(this.__wbg_ptr,!G(e),G(e)?0:e)}set sessionRotationPeriodMs(e){Z.__wbg_set_roomsettings_sessionRotationPeriodMs(this.__wbg_ptr,!G(e),G(e)?0:e)}};Symbol.dispose&&(qt.prototype[Symbol.dispose]=qt.prototype.free);var Jt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Cc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Cc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_sas_free(e,0)}accept(){let e=Z.sas_accept(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}canBePresented(){return Z.sas_canBePresented(this.__wbg_ptr)!==0}cancel(){let e=Z.sas_cancel(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}cancelInfo(){let e=Z.sas_cancelInfo(this.__wbg_ptr);return e===0?void 0:je.__wrap(e)}cancelWithCode(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.sas_cancelWithCode(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return Y(r[0])}confirm(){return Z.sas_confirm(this.__wbg_ptr)}decimals(){let e=Z.sas_decimals(this.__wbg_ptr),t;return e[0]!==0&&(t=Kc(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*2,2)),t}get deviceId(){let e=Z.sas_deviceId(this.__wbg_ptr);return M.__wrap(e)}emoji(){let e=Z.sas_emoji(this.__wbg_ptr),t;return e[0]!==0&&(t=Gc(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*4,4)),t}emojiIndex(){let e=Z.sas_emojiIndex(this.__wbg_ptr),t;return e[0]!==0&&(t=V(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}get flowId(){let e,t;try{let n=Z.sas_flowId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}hasBeenAccepted(){return Z.sas_hasBeenAccepted(this.__wbg_ptr)!==0}haveWeConfirmed(){return Z.sas_haveWeConfirmed(this.__wbg_ptr)!==0}isCancelled(){return Z.sas_isCancelled(this.__wbg_ptr)!==0}isDone(){return Z.sas_isDone(this.__wbg_ptr)!==0}isSelfVerification(){return Z.sas_isSelfVerification(this.__wbg_ptr)!==0}get otherDeviceId(){let e=Z.sas_otherDeviceId(this.__wbg_ptr);return M.__wrap(e)}get otherUserId(){let e=Z.sas_otherUserId(this.__wbg_ptr);return L.__wrap(e)}registerChangesCallback(e){Z.sas_registerChangesCallback(this.__wbg_ptr,e)}get roomId(){let e=Z.sas_roomId(this.__wbg_ptr);return e===0?void 0:F.__wrap(e)}startedFromRequest(){return Z.sas_startedFromRequest(this.__wbg_ptr)!==0}supportsEmoji(){return Z.sas_supportsEmoji(this.__wbg_ptr)!==0}timedOut(){return Z.sas_timedOut(this.__wbg_ptr)!==0}get userId(){let e=Z.sas_userId(this.__wbg_ptr);return L.__wrap(e)}weStarted(){return Z.sas_weStarted(this.__wbg_ptr)!==0}};Symbol.dispose&&(Jt.prototype[Symbol.dispose]=Jt.prototype.free);var Yt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,wc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,wc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_secretsbundle_free(e,0)}get backupBundle(){let e=Z.secretsbundle_backupBundle(this.__wbg_ptr);return e===0?void 0:Oe.__wrap(e)}static from_json(t){let n=Z.secretsbundle_from_json(t);if(n[2])throw Y(n[1]);return e.__wrap(n[0])}get masterKey(){let e,t;try{let n=Z.secretsbundle_masterKey(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get selfSigningKey(){let e,t;try{let n=Z.secretsbundle_selfSigningKey(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}to_json(){let e=Z.secretsbundle_to_json(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}get userSigningKey(){let e,t;try{let n=Z.secretsbundle_userSigningKey(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(Yt.prototype[Symbol.dispose]=Yt.prototype.free);var Xt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Tc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Tc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_servername_free(e,0)}get host(){let e,t;try{let n=Z.servername_host(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}isIpLiteral(){return Z.servername_isIpLiteral(this.__wbg_ptr)!==0}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.servername_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],Tc.register(this,this.__wbg_ptr,this),this}get port(){let e=Z.servername_port(this.__wbg_ptr);return e===16777215?void 0:e}};Symbol.dispose&&(Xt.prototype[Symbol.dispose]=Xt.prototype.free);var Zt=Object.freeze({Red:0,0:`Red`,Grey:1,1:`Grey`,None:2,2:`None`}),Qt=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ec.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ec.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_shieldstate_free(e,0)}get code(){let e=Z.__wbg_get_shieldstate_code(this.__wbg_ptr);return e===6?void 0:e}get color(){return Z.__wbg_get_shieldstate_color(this.__wbg_ptr)}set code(e){Z.__wbg_set_shieldstate_code(this.__wbg_ptr,G(e)?6:e)}set color(e){Z.__wbg_set_shieldstate_color(this.__wbg_ptr,e)}get message(){let e=Z.shieldstate_message(this.__wbg_ptr),t;return e[0]!==0&&(t=U(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*1,1)),t}};Symbol.dispose&&(Qt.prototype[Symbol.dispose]=Qt.prototype.free);var $t=Object.freeze({AuthenticityNotGuaranteed:0,0:`AuthenticityNotGuaranteed`,UnknownDevice:1,1:`UnknownDevice`,UnsignedDevice:2,2:`UnsignedDevice`,UnverifiedIdentity:3,3:`UnverifiedIdentity`,VerificationViolation:4,4:`VerificationViolation`,MismatchedSender:5,5:`MismatchedSender`}),en=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Dc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Dc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_signature_free(e,0)}get ed25519(){let e=Z.signature_ed25519(this.__wbg_ptr);return e===0?void 0:Ze.__wrap(e)}toBase64(){let e,t;try{let n=Z.signature_toBase64(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(en.prototype[Symbol.dispose]=en.prototype.free);var tn=Object.freeze({Missing:0,0:`Missing`,Invalid:1,1:`Invalid`,ValidButNotTrusted:2,2:`ValidButNotTrusted`,ValidAndTrusted:3,3:`ValidAndTrusted`}),nn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Oc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Oc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_signatureuploadrequest_free(e,0)}get body(){return Z.__wbg_get_signatureuploadrequest_body(this.__wbg_ptr)}get id(){return Z.__wbg_get_signatureuploadrequest_id(this.__wbg_ptr)}constructor(e,t){let n=Z.signatureuploadrequest_new(e,t);return this.__wbg_ptr=n,Oc.register(this,this.__wbg_ptr,this),this}get type(){return Z.signatureuploadrequest_type(this.__wbg_ptr)}};Symbol.dispose&&(nn.prototype[Symbol.dispose]=nn.prototype.free);var rn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,kc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,kc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_signatureverification_free(e,0)}get deviceState(){return Z.signatureverification_deviceState(this.__wbg_ptr)}trusted(){return Z.signatureverification_trusted(this.__wbg_ptr)!==0}get userState(){return Z.signatureverification_userState(this.__wbg_ptr)}};Symbol.dispose&&(rn.prototype[Symbol.dispose]=rn.prototype.free);var an=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Ac.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ac.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_signatures_free(e,0)}addSignature(e,t,n){B(e,L),B(t,Ke),B(n,Ze);let r=Z.signatures_addSignature(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr);return r===0?void 0:gt.__wrap(r)}asJSON(){let e=Z.signatures_asJSON(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}clear(){Z.signatures_clear(this.__wbg_ptr)}get count(){return Z.signatures_count(this.__wbg_ptr)>>>0}get(e){return B(e,L),Z.signatures_get(this.__wbg_ptr,e.__wbg_ptr)}getSignature(e,t){B(e,L),B(t,Ke);let n=Z.signatures_getSignature(this.__wbg_ptr,e.__wbg_ptr,t.__wbg_ptr);return n===0?void 0:Ze.__wrap(n)}isEmpty(){return Z.signatures_isEmpty(this.__wbg_ptr)!==0}constructor(){let e=Z.signatures_new();return this.__wbg_ptr=e,Ac.register(this,this.__wbg_ptr,this),this}};Symbol.dispose&&(an.prototype[Symbol.dispose]=an.prototype.free);var I=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,jc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,jc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_storehandle_free(e,0)}static open(e,t,n){var r=G(e)?0:J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=G(t)?0:J(t,Z.__wbindgen_malloc,Z.__wbindgen_realloc),o=X;return Z.storehandle_open(r,i,a,o,G(n)?0:z(n))}static openWithKey(e,t,n){let r=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X,a=K(t,Z.__wbindgen_malloc),o=X;return Z.storehandle_openWithKey(r,i,a,o,G(n)?0:z(n))}};Symbol.dispose&&(I.prototype[Symbol.dispose]=I.prototype.free);var on=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Mc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Mc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_storedroomkeybundledata_free(e,0)}get encryptionInfo(){let e,t;try{let n=Z.storedroomkeybundledata_encryptionInfo(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get roomId(){let e=Z.storedroomkeybundledata_roomId(this.__wbg_ptr);return F.__wrap(e)}get senderUser(){let e=Z.storedroomkeybundledata_senderUser(this.__wbg_ptr);return L.__wrap(e)}get url(){let e,t;try{let n=Z.storedroomkeybundledata_url(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(on.prototype[Symbol.dispose]=on.prototype.free);var sn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Nc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Nc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_todeviceencryptioninfo_free(e,0)}get senderCurve25519Key(){let e,t;try{let n=Z.__wbg_get_todeviceencryptioninfo_senderCurve25519Key(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}get senderDevice(){let e=Z.__wbg_get_todeviceencryptioninfo_senderDevice(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}get sender(){let e=Z.__wbg_get_todeviceencryptioninfo_sender(this.__wbg_ptr);return L.__wrap(e)}set senderCurve25519Key(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X;Z.__wbg_set_todeviceencryptioninfo_senderCurve25519Key(this.__wbg_ptr,t,n)}set senderDevice(e){let t=0;G(e)||(B(e,M),t=e.__destroy_into_raw()),Z.__wbg_set_todeviceencryptioninfo_senderDevice(this.__wbg_ptr,t)}set sender(e){B(e,L);var t=e.__destroy_into_raw();Z.__wbg_set_todeviceencryptioninfo_sender(this.__wbg_ptr,t)}isSenderVerified(){return Z.todeviceencryptioninfo_isSenderVerified(this.__wbg_ptr)!==0}};Symbol.dispose&&(sn.prototype[Symbol.dispose]=sn.prototype.free);var cn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Pc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Pc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_todevicerequest_free(e,0)}get body(){return Z.__wbg_get_todevicerequest_body(this.__wbg_ptr)}get event_type(){return Z.__wbg_get_todevicerequest_event_type(this.__wbg_ptr)}get id(){return Z.__wbg_get_todevicerequest_id(this.__wbg_ptr)}get txn_id(){return Z.__wbg_get_todevicerequest_txn_id(this.__wbg_ptr)}constructor(e,t,n,r){let i=Z.todevicerequest_new(e,t,n,r);return this.__wbg_ptr=i,Pc.register(this,this.__wbg_ptr,this),this}get type(){return Z.todevicerequest_type(this.__wbg_ptr)}};Symbol.dispose&&(cn.prototype[Symbol.dispose]=cn.prototype.free);var ln=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Fc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Fc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_todeviceunabletodecryptinfo_free(e,0)}get reason(){return Z.__wbg_get_todeviceunabletodecryptinfo_reason(this.__wbg_ptr)}set reason(e){Z.__wbg_set_todeviceunabletodecryptinfo_reason(this.__wbg_ptr,e)}};Symbol.dispose&&(ln.prototype[Symbol.dispose]=ln.prototype.free);var un=Object.freeze({DecryptionFailure:0,0:`DecryptionFailure`,UnverifiedSenderDevice:1,1:`UnverifiedSenderDevice`,NoOlmMachine:2,2:`NoOlmMachine`,EncryptionIsDisabled:3,3:`EncryptionIsDisabled`}),dn=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ic.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_tracing_free(e,0)}static isAvailable(){return Z.tracing_isAvailable()!==0}constructor(e){let t=Z.tracing_new(e);if(t[2])throw Y(t[1]);return this.__wbg_ptr=t[0],Ic.register(this,this.__wbg_ptr,this),this}set minLevel(e){let t=Z.tracing_set_minLevel(this.__wbg_ptr,e);if(t[1])throw Y(t[0])}turnOff(){let e=Z.tracing_turnOff(this.__wbg_ptr);if(e[1])throw Y(e[0])}turnOn(){let e=Z.tracing_turnOn(this.__wbg_ptr);if(e[1])throw Y(e[0])}};Symbol.dispose&&(dn.prototype[Symbol.dispose]=dn.prototype.free);var fn=Object.freeze({Untrusted:0,0:`Untrusted`,CrossSignedOrLegacy:1,1:`CrossSignedOrLegacy`,CrossSigned:2,2:`CrossSigned`}),pn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Lc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Lc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_utdtodeviceevent_free(e,0)}get rawEvent(){return Z.__wbg_get_utdtodeviceevent_rawEvent(this.__wbg_ptr)}get utdInfo(){let e=Z.__wbg_get_utdtodeviceevent_utdInfo(this.__wbg_ptr);return ln.__wrap(e)}get type(){return Z.utdtodeviceevent_type(this.__wbg_ptr)}};Symbol.dispose&&(pn.prototype[Symbol.dispose]=pn.prototype.free);var mn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Rc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Rc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_uploadsigningkeysrequest_free(e,0)}get body(){return Z.__wbg_get_uploadsigningkeysrequest_body(this.__wbg_ptr)}constructor(e){let t=Z.uploadsigningkeysrequest_new(e);return this.__wbg_ptr=t,Rc.register(this,this.__wbg_ptr,this),this}};Symbol.dispose&&(mn.prototype[Symbol.dispose]=mn.prototype.free);var hn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,zc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,zc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_userdevices_free(e,0)}devices(){return Z.userdevices_devices(this.__wbg_ptr)}get(e){B(e,M);let t=Z.userdevices_get(this.__wbg_ptr,e.__wbg_ptr);return t===0?void 0:He.__wrap(t)}isAnyVerified(){return Z.userdevices_isAnyVerified(this.__wbg_ptr)!==0}keys(){return Z.userdevices_keys(this.__wbg_ptr)}};Symbol.dispose&&(hn.prototype[Symbol.dispose]=hn.prototype.free);var L=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Bc.register(n,n.__wbg_ptr,n),n}static __unwrap(t){return t instanceof e?t.__destroy_into_raw():0}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Bc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_userid_free(e,0)}clone(){let t=Z.userid_clone(this.__wbg_ptr);return e.__wrap(t)}isHistorical(){return Z.userid_isHistorical(this.__wbg_ptr)!==0}get localpart(){let e,t;try{let n=Z.userid_localpart(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}constructor(e){let t=J(e,Z.__wbindgen_malloc,Z.__wbindgen_realloc),n=X,r=Z.userid_new(t,n);if(r[2])throw Y(r[1]);return this.__wbg_ptr=r[0],Bc.register(this,this.__wbg_ptr,this),this}get serverName(){let e=Z.userid_serverName(this.__wbg_ptr);return Xt.__wrap(e)}toString(){let e,t;try{let n=Z.userid_toString(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(L.prototype[Symbol.dispose]=L.prototype.free);var gn=Object.freeze({SasV1:0,0:`SasV1`,QrCodeScanV1:1,1:`QrCodeScanV1`,QrCodeShowV1:2,2:`QrCodeShowV1`,ReciprocateV1:3,3:`ReciprocateV1`}),_n=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Vc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Vc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_verificationrequest_free(e,0)}accept(){let e=Z.verificationrequest_accept(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}acceptWithMethods(e){let t=q(e,Z.__wbindgen_malloc),n=X,r=Z.verificationrequest_acceptWithMethods(this.__wbg_ptr,t,n);if(r[2])throw Y(r[1]);return Y(r[0])}cancel(){let e=Z.verificationrequest_cancel(this.__wbg_ptr);if(e[2])throw Y(e[1]);return Y(e[0])}get cancelInfo(){let e=Z.verificationrequest_cancelInfo(this.__wbg_ptr);return e===0?void 0:je.__wrap(e)}get flowId(){let e,t;try{let n=Z.verificationrequest_flowId(this.__wbg_ptr);return e=n[0],t=n[1],U(n[0],n[1])}finally{Z.__wbindgen_free(e,t,1)}}generateQrCode(){return Z.verificationrequest_generateQrCode(this.__wbg_ptr)}getVerification(){return Z.verificationrequest_getVerification(this.__wbg_ptr)}isCancelled(){return Z.verificationrequest_isCancelled(this.__wbg_ptr)!==0}isDone(){return Z.verificationrequest_isDone(this.__wbg_ptr)!==0}isPassive(){return Z.verificationrequest_isPassive(this.__wbg_ptr)!==0}isReady(){return Z.verificationrequest_isReady(this.__wbg_ptr)!==0}isSelfVerification(){return Z.verificationrequest_isSelfVerification(this.__wbg_ptr)!==0}get otherDeviceId(){let e=Z.verificationrequest_otherDeviceId(this.__wbg_ptr);return e===0?void 0:M.__wrap(e)}get otherUserId(){let e=Z.verificationrequest_otherUserId(this.__wbg_ptr);return L.__wrap(e)}get ourSupportedMethods(){let e=Z.verificationrequest_ourSupportedMethods(this.__wbg_ptr);if(e[3])throw Y(e[2]);let t;return e[0]!==0&&(t=Gc(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*4,4)),t}get ownUserId(){let e=Z.verificationrequest_ownUserId(this.__wbg_ptr);return L.__wrap(e)}phase(){return Z.verificationrequest_phase(this.__wbg_ptr)}registerChangesCallback(e){Z.verificationrequest_registerChangesCallback(this.__wbg_ptr,e)}static request(e,t,n,r){let i,a;try{B(e,L),B(t,M),B(n,L);var o=G(r)?0:q(r,Z.__wbindgen_malloc),s=X;let u=Z.verificationrequest_request(e.__wbg_ptr,t.__wbg_ptr,n.__wbg_ptr,o,s);var c=u[0],l=u[1];if(u[3])throw c=0,l=0,Y(u[2]);return i=c,a=l,U(c,l)}finally{Z.__wbindgen_free(i,a,1)}}get roomId(){let e=Z.verificationrequest_roomId(this.__wbg_ptr);return e===0?void 0:F.__wrap(e)}scanQrCode(e){return B(e,Rt),Z.verificationrequest_scanQrCode(this.__wbg_ptr,e.__wbg_ptr)}startSas(){return Z.verificationrequest_startSas(this.__wbg_ptr)}get theirSupportedMethods(){let e=Z.verificationrequest_theirSupportedMethods(this.__wbg_ptr);if(e[3])throw Y(e[2]);let t;return e[0]!==0&&(t=Gc(e[0],e[1]).slice(),Z.__wbindgen_free(e[0],e[1]*4,4)),t}timeRemainingMillis(){return Z.verificationrequest_timeRemainingMillis(this.__wbg_ptr)}timedOut(){return Z.verificationrequest_timedOut(this.__wbg_ptr)!==0}weStarted(){return Z.verificationrequest_weStarted(this.__wbg_ptr)!==0}};Symbol.dispose&&(_n.prototype[Symbol.dispose]=_n.prototype.free);var R=Object.freeze({Created:0,0:`Created`,Requested:1,1:`Requested`,Ready:2,2:`Ready`,Transitioned:3,3:`Transitioned`,Done:4,4:`Done`,Cancelled:5,5:`Cancelled`}),vn=class e{static __wrap(t){let n=Object.create(e.prototype);return n.__wbg_ptr=t,Hc.register(n,n.__wbg_ptr,n),n}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Hc.unregister(this),e}free(){let e=this.__destroy_into_raw();Z.__wbg_versions_free(e,0)}get git_description(){return Z.__wbg_get_versions_git_description(this.__wbg_ptr)}get git_sha(){return Z.__wbg_get_versions_git_sha(this.__wbg_ptr)}get matrix_sdk_crypto(){return Z.__wbg_get_versions_matrix_sdk_crypto(this.__wbg_ptr)}get vodozemac(){return Z.__wbg_get_versions_vodozemac(this.__wbg_ptr)}};Symbol.dispose&&(vn.prototype[Symbol.dispose]=vn.prototype.free);function yn(){let e=Z.getVersions();return vn.__wrap(e)}function bn(){Z.start()}function xn(e,t){return Error(U(e,t))}function Sn(e){return Number(e)}function Cn(e,t){let n=J(String(t),Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X;H().setInt32(e+4,r,!0),H().setInt32(e+0,n,!0)}function wn(e){return e.Window}function Tn(e){return e.WorkerGlobalScope}function En(e,t){let n=t,r=typeof n==`bigint`?n:void 0;H().setBigInt64(e+8,G(r)?BigInt(0):r,!0),H().setInt32(e+0,!G(r),!0)}function Dn(e){let t=e,n=typeof t==`boolean`?t:void 0;return G(n)?16777215:+!!n}function On(e,t){let n=J(Wc(t),Z.__wbindgen_malloc,Z.__wbindgen_realloc),r=X;H().setInt32(e+4,r,!0),H().setInt32(e+0,n,!0)}function kn(e,t){return e in t}function An(e){return typeof e==`bigint`}function jn(e){return typeof e==`function`}function Mn(e){return e===null}function Nn(e){let t=e;return typeof t==`object`&&!!t}function Pn(e){return typeof e==`string`}function Fn(e){return e===void 0}function In(e,t){return e===t}function Ln(e,t){return e==t}function Rn(e,t){let n=t,r=typeof n==`number`?n:void 0;H().setFloat64(e+8,G(r)?0:r,!0),H().setInt32(e+0,!G(r),!0)}function zn(e,t){let n=t,r=typeof n==`string`?n:void 0;var i=G(r)?0:J(r,Z.__wbindgen_malloc,Z.__wbindgen_realloc),a=X;H().setInt32(e+4,a,!0),H().setInt32(e+0,i,!0)}function Bn(e,t){throw Error(U(e,t))}function Vn(e){e._wbg_cb_unref()}function Hn(){return W(function(e){e.abort()},arguments)}function Un(e,t){return e.add(t)}function Wn(){return W(function(e,t,n){return e.add(t,n)},arguments)}function Gn(e,t){return e.at(t)}function Kn(e){return De.__wrap(e)}function qn(){return W(function(e,t,n,r){return IDBKeyRange.bound(e,t,n!==0,r!==0)},arguments)}function Jn(){return W(function(e,t,n,r,i){return e.call(t,n,r,i)},arguments)}function Yn(){return W(function(e,t){return e.call(t)},arguments)}function Xn(){return W(function(e,t,n){return e.call(t,n)},arguments)}function Zn(){return W(function(e,t,n,r){return e.call(t,n,r)},arguments)}function Qn(e){return clearTimeout(e)}function $n(){return W(function(e){return e.clear()},arguments)}function er(e){e.close()}function tr(e){return e.code}function nr(){return W(function(e){e.commit()},arguments)}function rr(){return W(function(e){e.continue()},arguments)}function ir(){return W(function(e){return e.count()},arguments)}function ar(){return W(function(e){return e.count()},arguments)}function or(){return W(function(e,t,n,r,i){return e.createIndex(U(t,n),r,i)},arguments)}function sr(){return W(function(e,t,n,r){return e.createIndex(U(t,n),r)},arguments)}function cr(){return W(function(e,t,n){return e.createObjectStore(U(t,n))},arguments)}function lr(e){return Ne.__wrap(e)}function ur(e){return Pe.__wrap(e)}function dr(e){return Fe.__wrap(e)}function fr(e){return e.crypto}function pr(e,t){e.debug(t)}function mr(e){console.debug(e)}function hr(e){return Le.__wrap(e)}function gr(e){return Re.__wrap(e)}function _r(e){return Be.__wrap(e)}function vr(e){return j.__wrap(e)}function yr(){return W(function(e,t,n){e.deleteObjectStore(U(t,n))},arguments)}function br(){return W(function(e){return e.delete()},arguments)}function xr(){return W(function(e,t){return e.delete(t)},arguments)}function Sr(e){return He.__wrap(e)}function Cr(e){return M.__wrap(e)}function wr(e){return Ue.__wrap(e)}function Tr(e){return Ke.__wrap(e)}function Er(e){return e.done}function Dr(e){return Qe.__wrap(e)}function Or(e){return $e.__wrap(e)}function kr(e){return tt.__wrap(e)}function Ar(e){return Object.entries(e)}function jr(e){return e.entries()}function Mr(e,t){let n,r;try{n=e,r=t,console.error(U(e,t))}finally{Z.__wbindgen_free(n,r,1)}}function Nr(e,t){e.error(t)}function Pr(){return W(function(e){let t=e.error;return G(t)?0:z(t)},arguments)}function Fr(e){console.error(e)}function Ir(e){return Array.from(e)}function Lr(){return W(function(e){return e.getAllKeys()},arguments)}function Rr(){return W(function(e){return e.getAll()},arguments)}function zr(){return W(function(e,t){return e.getAll(t)},arguments)}function Br(){return W(function(e){return e.getAll()},arguments)}function Vr(){return W(function(e,t,n){return e.getAll(t,n>>>0)},arguments)}function Hr(){return W(function(e,t){globalThis.crypto.getRandomValues(V(e,t))},arguments)}function Ur(){return W(function(e,t){e.getRandomValues(t)},arguments)}function Wr(){return W(function(e,t){globalThis.crypto.getRandomValues(V(e,t))},arguments)}function Gr(e){return e.getTime()}function Kr(){return W(function(e,t){return e.get(t)},arguments)}function qr(){return W(function(e,t){return Reflect.get(e,t)},arguments)}function Jr(e,t){return e[t>>>0]}function Yr(){return W(function(e,t){return e.get(t)},arguments)}function Xr(){return W(function(e,t){return Reflect.get(e,t)},arguments)}function Zr(e,t){return e[t>>>0]}function Qr(e,t){return e[t]}function $r(e){return e.global}function ei(e){return ct.__wrap(e)}function ti(){return W(function(e,t,n){return e.index(U(t,n))},arguments)}function ni(){return W(function(e){let t=e.indexedDB;return G(t)?0:z(t)},arguments)}function ri(){return W(function(e){let t=e.indexedDB;return G(t)?0:z(t)},arguments)}function ii(){return W(function(e){let t=e.indexedDB;return G(t)?0:z(t)},arguments)}function ai(e,t){e.info(t)}function oi(e){console.info(e)}function si(e){let t;try{t=e instanceof ArrayBuffer}catch{t=!1}return t}function ci(e){let t;try{t=e instanceof IDBCursorWithValue}catch{t=!1}return t}function li(e){let t;try{t=e instanceof DOMException}catch{t=!1}return t}function ui(e){let t;try{t=e instanceof Error}catch{t=!1}return t}function di(e){let t;try{t=e instanceof IDBCursor}catch{t=!1}return t}function fi(e){let t;try{t=e instanceof IDBDatabase}catch{t=!1}return t}function pi(e){let t;try{t=e instanceof IDBOpenDBRequest}catch{t=!1}return t}function mi(e){let t;try{t=e instanceof IDBRequest}catch{t=!1}return t}function hi(e){let t;try{t=e instanceof Map}catch{t=!1}return t}function gi(e){let t;try{t=e instanceof Promise}catch{t=!1}return t}function _i(e){let t;try{t=e instanceof Uint8Array}catch{t=!1}return t}function vi(e){return lt.__wrap(e)}function yi(e){return Array.isArray(e)}function bi(e){return Array.isArray(e)}function xi(e){return Number.isSafeInteger(e)}function Si(e,t,n){let r=t.item(n>>>0);var i=G(r)?0:J(r,Z.__wbindgen_malloc,Z.__wbindgen_realloc),a=X;H().setInt32(e+4,a,!0),H().setInt32(e+0,i,!0)}function Ci(){return Symbol.iterator}function wi(){return W(function(e){return e.key},arguments)}function Ti(e){return ut.__wrap(e)}function Ei(e){return dt.__wrap(e)}function Di(e){return ft.__wrap(e)}function Oi(e){return pt.__wrap(e)}function ki(e){return e.length}function Ai(e){return e.length}function ji(e){return e.length}function Mi(){return W(function(e,t){return IDBKeyRange.lowerBound(e,t!==0)},arguments)}function Ni(e){return gt.__wrap(e)}function Pi(e){return _t.__wrap(e)}function Fi(e){return e.message}function Ii(e,t){let n=t.message,r=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X;H().setInt32(e+4,i,!0),H().setInt32(e+0,r,!0)}function Li(e){return e.msCrypto}function Ri(e,t){let n=t.name,r=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X;H().setInt32(e+4,i,!0),H().setInt32(e+0,r,!0)}function zi(){return{}}function Bi(){return new Map}function Vi(e,t){return Error(U(e,t))}function Hi(){return Error()}function Ui(){return[]}function Wi(e){return new Set(e)}function Gi(e){return new Uint8Array(e)}function Ki(e){return new Date(e)}function qi(e,t){try{var n={a:e,b:t};return new Promise((e,t)=>{let r=n.a;n.a=0;try{return es(r,n.b,e,t)}finally{n.a=r}})}finally{n.a=0}}function Ji(e,t){try{var n={a:e,b:t};return new Promise((e,t)=>{let r=n.a;n.a=0;try{return es(r,n.b,e,t)}finally{n.a=r}})}finally{n.a=0}}function Yi(e){return new Uint8Array(e>>>0)}function Xi(e){return new Uint8ClampedArray(e>>>0)}function Zi(e){return e.next}function Qi(){return W(function(e){return e.next()},arguments)}function $i(e){return e.node}function ea(){return Date.now()}function ta(e){return e.now()}function na(e){return e.objectStoreNames}function ra(){return W(function(e,t,n){return e.objectStore(U(t,n))},arguments)}function ia(e){return e.oldVersion}function aa(e){return St.__wrap(e)}function oa(){return W(function(e){return e.openCursor()},arguments)}function sa(){return W(function(e,t){return e.openCursor(t)},arguments)}function ca(){return W(function(e){return e.openCursor()},arguments)}function la(){return W(function(e,t,n,r){return e.open(U(t,n),r>>>0)},arguments)}function ua(){return W(function(e,t,n){return e.open(U(t,n))},arguments)}function da(e){return Ct.__wrap(e)}function fa(e){return Tt.__wrap(e)}function pa(){return W(function(e,t){return JSON.parse(U(e,t))},arguments)}function ma(e){return e.performance}function ha(e){return Et.__unwrap(e)}function ga(e){return Dt.__unwrap(e)}function _a(e){return At.__wrap(e)}function va(e){return e.process}function ya(e,t,n){Uint8ClampedArray.prototype.set.call(V(e,t),n)}function ba(e,t,n){Uint8Array.prototype.set.call(V(e,t),n)}function xa(e,t){return e.push(t)}function Sa(){return W(function(e,t,n){return e.put(t,n)},arguments)}function Ca(e){return Mt.__wrap(e)}function wa(e){return Nt.__wrap(e)}function Ta(e){return e.queueMicrotask}function Ea(e){queueMicrotask(e)}function Da(){return W(function(e,t){e.randomFillSync(t)},arguments)}function Oa(e){let t=e.readyState;return(ts.indexOf(t)+1||3)-1}function ka(e){return zt.__wrap(e)}function Aa(e){return e.request}function ja(e){return e.request}function Ma(){return W(function(){return module.require},arguments)}function Na(e){return Promise.resolve(e)}function Pa(){return W(function(e){return e.result},arguments)}function Fa(e){return F.__unwrap(e)}function Ia(e){return Vt.__wrap(e)}function La(e){return Ht.__wrap(e)}function Ra(e){return Ut.__wrap(e)}function za(e){return Wt.__wrap(e)}function Ba(e){return Gt.__wrap(e)}function Va(e){return Kt.__wrap(e)}function Ha(e){return qt.__wrap(e)}function Ua(e){return Jt.__wrap(e)}function Wa(e){return Yt.__wrap(e)}function Ga(){return W(function(e,t){return setTimeout(e,t)},arguments)}function Ka(e,t,n){e[t]=n}function qa(e,t,n){e[t>>>0]=n}function Ja(e,t,n){e.set(V(t,n))}function Ya(e,t,n){return e.set(t,n)}function Xa(e,t){e.onabort=t}function Za(e,t){e.oncomplete=t}function Qa(e,t){e.onerror=t}function $a(e,t){e.onerror=t}function eo(e,t){e.onsuccess=t}function to(e,t){e.onupgradeneeded=t}function no(e,t){e.unique=t!==0}function ro(e){return an.__wrap(e)}function io(e){return nn.__wrap(e)}function ao(e){return rn.__wrap(e)}function oo(e,t){let n=t.stack,r=J(n,Z.__wbindgen_malloc,Z.__wbindgen_realloc),i=X;H().setInt32(e+4,i,!0),H().setInt32(e+0,r,!0)}function so(){let e=typeof globalThis>`u`?null:globalThis;return G(e)?0:z(e)}function co(){let e=t===void 0?null:t;return G(e)?0:z(e)}function lo(){let e=typeof self>`u`?null:self;return G(e)?0:z(e)}function uo(){let e=typeof window>`u`?null:window;return G(e)?0:z(e)}function fo(e){return on.__wrap(e)}function po(e){return I.__wrap(e)}function mo(){return W(function(e){return JSON.stringify(e)},arguments)}function ho(e,t,n){return e.subarray(t>>>0,n>>>0)}function go(e){let t=e.target;return G(t)?0:z(t)}function _o(e,t){return e.then(t)}function vo(e,t,n){return e.then(t,n)}function yo(e){return e.toString()}function bo(e){return cn.__wrap(e)}function xo(e){return e.transaction}function So(){return W(function(e,t,n){return e.transaction(t,ns[n])},arguments)}function Co(e){let t=e.transaction;return G(t)?0:z(t)}function wo(){return W(function(e,t,n,r){return e.transaction(U(t,n),ns[r])},arguments)}function To(){return W(function(e,t){return e.update(t)},arguments)}function Eo(){return W(function(e,t){return IDBKeyRange.upperBound(e,t!==0)},arguments)}function Do(e){return hn.__wrap(e)}function Oo(e){return L.__wrap(e)}function ko(e){return L.__unwrap(e)}function Ao(e){return pn.__wrap(e)}function jo(){return W(function(e){return e.value},arguments)}function Mo(e){return e.value}function No(e){return e.values()}function Po(e){return _n.__wrap(e)}function Fo(e){return e.version}function Io(e){return e.versions}function Lo(e,t){e.warn(t)}function Ro(e){console.warn(e)}function zo(e,t){return Qc(e,t,Qo)}function Bo(e,t){return Qc(e,t,Zo)}function Vo(e,t){return Qc(e,t,$o)}function Ho(e,t){return Qc(e,t,Xo)}function Uo(e){return e}function Wo(e){return e}function Go(e,t){return V(e,t)}function Ko(e,t){return U(e,t)}function qo(e){return BigInt.asUintN(64,e)}function Jo(e,t){var n=Gc(e,t).slice();return Z.__wbindgen_free(e,t*4,4),n}function Yo(){let e=Z.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}function Xo(e,t){Z.wasm_bindgen__convert__closures_____invoke__h3fc5f4d47ac7b23e(e,t)}function Zo(e,t,n){Z.wasm_bindgen__convert__closures_____invoke__hc98e844383b6010d(e,t,n)}function Qo(e,t,n){let r=Z.wasm_bindgen__convert__closures_____invoke__h6cc6e60feaea7523(e,t,n);if(r[1])throw Y(r[0])}function $o(e,t,n){let r=Z.wasm_bindgen__convert__closures_____invoke__h6cc6e60feaea7523_2(e,t,n);if(r[1])throw Y(r[0])}function es(e,t,n,r){Z.wasm_bindgen__convert__closures_____invoke__h33afbfdbaf3c68e2(e,t,n,r)}var ts=[`pending`,`done`],ns=[`readonly`,`readwrite`,`versionchange`,`readwriteflush`,`cleanup`],rs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_attachment_free(e,1)),is=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_backupdecryptionkey_free(e,1)),as=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_backupkeys_free(e,1)),os=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_backupsecretsbundle_free(e,1)),ss=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_base64encodedpkmessage_free(e,1)),cs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_basemigrationdata_free(e,1)),ls=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_cancelinfo_free(e,1)),us=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_checkcode_free(e,1)),ds=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_collectstrategy_free(e,1)),fs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_crosssigningbootstraprequests_free(e,1)),ps=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_crosssigningkeyexport_free(e,1)),ms=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_crosssigningstatus_free(e,1)),hs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_curve25519publickey_free(e,1)),gs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_curve25519secretkey_free(e,1)),_s=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_decryptedroomevent_free(e,1)),vs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_decryptedtodeviceevent_free(e,1)),ys=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_decryptionsettings_free(e,1)),bs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_dehydrateddevice_free(e,1)),xs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_dehydrateddevicekey_free(e,1)),Ss=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_dehydrateddevices_free(e,1)),Cs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_device_free(e,1)),ws=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_deviceid_free(e,1)),Ts=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_devicekey_free(e,1)),Es=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_devicekeyalgorithm_free(e,1)),Ds=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_devicekeyid_free(e,1)),Os=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_devicelists_free(e,1)),ks=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_ecies_free(e,1)),As=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_ed25519publickey_free(e,1)),js=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_ed25519signature_free(e,1)),Ms=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_emoji_free(e,1)),Ns=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_encryptedattachment_free(e,1)),Ps=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_encryptioninfo_free(e,1)),Fs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_encryptionsettings_free(e,1)),Is=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_establishedecies_free(e,1)),Ls=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_eventid_free(e,1)),Rs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_identitykeys_free(e,1)),zs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_inboundcreationresult_free(e,1)),Bs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_inboundgroupsession_free(e,1)),Vs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_invalidtodeviceevent_free(e,1)),Hs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_keysbackuprequest_free(e,1)),Us=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_keysclaimrequest_free(e,1)),Ws=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_keysqueryrequest_free(e,1)),Gs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_keysuploadrequest_free(e,1)),Ks=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_maybesignature_free(e,1)),qs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_megolmdecryptionerror_free(e,1)),Js=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_megolmv1backupkey_free(e,1)),Ys=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_migration_free(e,1)),Xs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_msc4108intentdata_free(e,1)),Zs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_msc4388intentdata_free(e,1)),Qs=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_olmmachine_free(e,1)),$s=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_otheruseridentity_free(e,1)),ec=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_outboundcreationresult_free(e,1)),tc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_ownuseridentity_free(e,1)),nc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_pickledinboundgroupsession_free(e,1)),rc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_pickledsession_free(e,1)),ic=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_pkdecryption_free(e,1)),ac=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_pkencryption_free(e,1)),oc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_pkmessage_free(e,1)),sc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_plaintexttodeviceevent_free(e,1)),cc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_putdehydrateddevicerequest_free(e,1)),lc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_qr_free(e,1)),uc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_qrcode_free(e,1)),dc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_qrcodedata_free(e,1)),fc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_qrcodeintentdata_free(e,1)),pc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_qrcodescan_free(e,1)),mc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_rehydrateddevice_free(e,1)),hc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roomid_free(e,1)),gc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roomkeycounts_free(e,1)),_c=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roomkeyimportresult_free(e,1)),vc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roomkeyinfo_free(e,1)),yc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roomkeywithheldinfo_free(e,1)),bc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roommessagerequest_free(e,1)),xc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roompendingkeybundledetails_free(e,1)),Sc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_roomsettings_free(e,1)),Cc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_sas_free(e,1)),wc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_secretsbundle_free(e,1)),Tc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_servername_free(e,1)),Ec=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_shieldstate_free(e,1)),Dc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_signature_free(e,1)),Oc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_signatureuploadrequest_free(e,1)),kc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_signatureverification_free(e,1)),Ac=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_signatures_free(e,1)),jc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_storehandle_free(e,1)),Mc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_storedroomkeybundledata_free(e,1)),Nc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_todeviceencryptioninfo_free(e,1)),Pc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_todevicerequest_free(e,1)),Fc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_todeviceunabletodecryptinfo_free(e,1)),Ic=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_tracing_free(e,1)),Lc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_utdtodeviceevent_free(e,1)),Rc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_uploadsigningkeysrequest_free(e,1)),zc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_userdevices_free(e,1)),Bc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_userid_free(e,1)),Vc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_verificationrequest_free(e,1)),Hc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbg_versions_free(e,1));function z(e){let t=Z.__externref_table_alloc();return Z.__wbindgen_externrefs.set(t,e),t}function B(e,t){if(!(e instanceof t))throw Error(`expected instance of ${t.name}`)}var Uc=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>Z.__wbindgen_destroy_closure(e.a,e.b));function Wc(e){let t=typeof e;if(t==`number`||t==`boolean`||e==null)return`${e}`;if(t==`string`)return`"${e}"`;if(t==`symbol`){let t=e.description;return t==null?`Symbol`:`Symbol(${t})`}if(t==`function`){let t=e.name;return typeof t==`string`&&t.length>0?`Function(${t})`:`Function`}if(Array.isArray(e)){let t=e.length,n=`[`;t>0&&(n+=Wc(e[0]));for(let r=1;r<t;r++)n+=`, `+Wc(e[r]);return n+=`]`,n}let n=/\[object ([^\]]+)\]/.exec(toString.call(e)),r;if(n&&n.length>1)r=n[1];else return toString.call(e);if(r==`Object`)try{return`Object(`+JSON.stringify(e)+`)`}catch{return`Object`}return e instanceof Error?`${e.name}: ${e.message}\n${e.stack}`:r}function Gc(e,t){e>>>=0;let n=H(),r=[];for(let i=e;i<e+4*t;i+=4)r.push(Z.__wbindgen_externrefs.get(n.getUint32(i,!0)));return Z.__externref_drop_slice(e,t),r}function Kc(e,t){return e>>>=0,Yc().subarray(e/2,e/2+t)}function V(e,t){return e>>>=0,Zc().subarray(e/1,e/1+t)}var qc=null;function H(){return(qc===null||qc.buffer.detached===!0||qc.buffer.detached===void 0&&qc.buffer!==Z.memory.buffer)&&(qc=new DataView(Z.memory.buffer)),qc}function U(e,t){return nl(e>>>0,t)}var Jc=null;function Yc(){return(Jc===null||Jc.byteLength===0)&&(Jc=new Uint16Array(Z.memory.buffer)),Jc}var Xc=null;function Zc(){return(Xc===null||Xc.byteLength===0)&&(Xc=new Uint8Array(Z.memory.buffer)),Xc}function W(e,t){try{return e.apply(this,t)}catch(e){let t=z(e);Z.__wbindgen_exn_store(t)}}function G(e){return e==null}function Qc(e,t,n){let r={a:e,b:t,cnt:1},i=(...e)=>{r.cnt++;let t=r.a;r.a=0;try{return n(t,r.b,...e)}finally{r.a=t,i._wbg_cb_unref()}};return i._wbg_cb_unref=()=>{--r.cnt===0&&(Z.__wbindgen_destroy_closure(r.a,r.b),r.a=0,Uc.unregister(r))},Uc.register(i,r,r),i}function K(e,t){let n=t(e.length*1,1)>>>0;return Zc().set(e,n/1),X=e.length,n}function q(e,t){let n=t(e.length*4,4)>>>0;for(let t=0;t<e.length;t++){let r=z(e[t]);H().setUint32(n+4*t,r,!0)}return X=e.length,n}function J(e,t,n){if(n===void 0){let n=rl.encode(e),r=t(n.length,1)>>>0;return Zc().subarray(r,r+n.length).set(n),X=n.length,r}let r=e.length,i=t(r,1)>>>0,a=Zc(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=Zc().subarray(i+o,i+r),a=rl.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return X=o,i}function Y(e){let t=Z.__wbindgen_externrefs.get(e);return Z.__externref_table_dealloc(e),t}var $c=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});$c.decode();var el=2146435072,tl=0;function nl(e,t){return tl+=t,tl>=el&&($c=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),$c.decode(),tl=t),$c.decode(Zc().subarray(e,e+t))}var rl=new TextEncoder;`encodeInto`in rl||(rl.encodeInto=function(e,t){let n=rl.encode(e);return t.set(n),{read:e.length,written:n.length}});var X=0,Z;function il(e){Z=e}var al=new URL(``+new URL(`matrix_sdk_crypto_wasm_bg-DwIieW7K.wasm`,import.meta.url).href,``+import.meta.url);il(new Proxy({},{get(){throw Error("@matrix-org/matrix-sdk-crypto-wasm was used before it was initialized. Call `initAsync` first.")}}));var ol=null;async function sl(e){let{instance:t}=await WebAssembly.instantiateStreaming(fetch(e),{"./matrix_sdk_crypto_wasm_bg.js":Te});il(t.exports),t.exports.__wbindgen_start()}async function cl(e=al){ol||=sl(e),await ol}var ll=e(r(((e,t)=>{for(var n=/[\\\"\x00-\x1F]/g,r={},i=0;i<32;++i)r[String.fromCharCode(i)]=`\\U`+(`0000`+i.toString(16)).slice(-4).toUpperCase();r[`\b`]=`\\b`,r[`	`]=`\\t`,r[`
      2 `]=`\\n`,r[`\f`]=`\\f`,r[`\r`]=`\\r`,r[`"`]=`\\"`,r[`\\`]=`\\\\`;function a(e){return n.lastIndex=0,e.replace(n,function(e){return r[e]})}function o(e){switch(typeof e){case`string`:return`"`+a(e)+`"`;case`number`:return isFinite(e)?e:`null`;case`boolean`:return e;case`object`:return e===null?`null`:Array.isArray(e)?s(e):c(e);default:throw Error(`Cannot stringify: `+typeof e)}}function s(e){for(var t=`[`,n=``,r=0;r<e.length;++r)n+=t,t=`,`,n+=o(e[r]);return t==`,`?n+`]`:`[]`}function c(e){var t=`{`,n=``,r=Object.keys(e);r.sort();for(var i=0;i<r.length;++i){var s=r[i];n+=t+`"`+a(s)+`":`,t=`,`,n+=o(e[s])}return t==`,`?n+`}`:`{}`}t.exports={stringify:o}}))(),1),ul=class{constructor(e,t,n,r,a,o){this.prefixedLogger=e,this.olmMachine=t,this.keyClaimManager=n,this.outgoingRequestManager=r,this.room=a,this.encryptionSettings=o,i(this,`lazyLoadedMembersResolved`,!1),i(this,`currentEncryptionPromise`,Promise.resolve());var s=a.getJoinedMembers();this.olmMachine.updateTrackedUsers(s.map(e=>new L(e.userId))).catch(e=>this.prefixedLogger.error(`Error initializing tracked users`,e))}onCryptoEvent(e){if(JSON.stringify(this.encryptionSettings)!=JSON.stringify(e))throw Error(`Cannot reconfigure an active RoomEncryptor`)}onRoomMembership(e){(e.membership==o.Join||e.membership==o.Invite&&this.room.shouldEncryptForInvitedMembers())&&this.olmMachine.updateTrackedUsers([new L(e.userId)]).catch(e=>{this.prefixedLogger.error(`Unable to update tracked users`,e)})}prepareForEncryption(e,t){var n=this;return T(function*(){yield n.encryptEvent(null,e,t)})()}encryptEvent(e,t,n){var r=this,i=new d(this.prefixedLogger,e?e.getTxnId()??``:`prepareForEncryption`),a=this.currentEncryptionPromise.catch(()=>{}).then(T(function*(){yield S(i,`ensureEncryptionSession`,T(function*(){yield r.ensureEncryptionSession(i,t,n)})),e&&(yield S(i,`encryptEventInner`,T(function*(){yield r.encryptEventInner(i,e)})))}));return this.currentEncryptionPromise=a,a}ensureEncryptionSession(e,t,n){var r=this;return T(function*(){if(r.encryptionSettings.algorithm!==`m.megolm.v1.aes-sha2`)throw Error(`Cannot encrypt in ${r.room.roomId} for unsupported algorithm '${r.encryptionSettings.algorithm}'`);e.debug(`Starting encryption`);var i=yield r.room.getEncryptionTargetMembers();r.lazyLoadedMembersResolved?(e.debug(`Processing outgoing requests in background`),r.outgoingRequestManager.doProcessOutgoingRequests()):(yield S(e,`loadMembersIfNeeded: updateTrackedUsers`,T(function*(){yield r.olmMachine.updateTrackedUsers(i.map(e=>new L(e.userId)))})),e.debug(`Updated tracked users`),r.lazyLoadedMembersResolved=!0,e.debug(`Processing outgoing requests`),yield S(e,`doProcessOutgoingRequests`,T(function*(){yield r.outgoingRequestManager.doProcessOutgoingRequests()}))),e.debug(`Encrypting for users (shouldEncryptForInvitedMembers: ${r.room.shouldEncryptForInvitedMembers()}):`,i.map(e=>`${e.userId} (${e.membership})`));var a=i.map(e=>new L(e.userId));yield S(e,`ensureSessionsForUsers`,T(function*(){yield r.keyClaimManager.ensureSessionsForUsers(e,a)}));var o=new nt;switch(o.historyVisibility=dl(r.room.getHistoryVisibility()),o.algorithm=et.MegolmV1AesSha2,typeof r.encryptionSettings.rotation_period_ms==`number`&&(o.rotationPeriod=BigInt(r.encryptionSettings.rotation_period_ms*1e3)),typeof r.encryptionSettings.rotation_period_msgs==`number`&&(o.rotationPeriodMessages=BigInt(r.encryptionSettings.rotation_period_msgs)),n.kind){case Ce.AllDevicesIsolationMode:var s=r.room.getBlacklistUnverifiedDevices()??t;o.sharingStrategy=O.deviceBasedStrategy(s,n.errorOnVerifiedUserProblems);break;case Ce.OnlySignedDevicesIsolationMode:o.sharingStrategy=O.identityBasedStrategy();break}yield S(e,`shareRoomKey`,T(function*(){var e=yield r.olmMachine.shareRoomKey(new F(r.room.roomId),a,o);if(e)for(var t of e)yield r.outgoingRequestManager.outgoingRequestProcessor.makeOutgoingRequest(t)}))})()}forceDiscardSession(){var e=this;return T(function*(){(yield e.olmMachine.invalidateGroupSession(new F(e.room.roomId)))&&e.prefixedLogger.info(`Discarded existing group session`)})()}encryptEventInner(e,t){var n=this;return T(function*(){e.debug(`Encrypting actual message content`);var r=new F(n.room.roomId),i=t.getType(),a=JSON.stringify(t.getContent()),o=t.isState()?yield n.olmMachine.encryptStateEvent(r,i,t.getStateKey(),a):yield n.olmMachine.encryptRoomEvent(r,i,a);t.makeEncrypted(x.RoomMessageEncrypted,JSON.parse(o),n.olmMachine.identityKeys.curve25519.toBase64(),n.olmMachine.identityKeys.ed25519.toBase64()),e.debug(`Encrypted event successfully`)})()}};function dl(e){switch(e){case fe.Invited:return at.Invited;case fe.Joined:return at.Joined;case fe.Shared:return at.Shared;case fe.WorldReadable:return at.WorldReadable}}var fl=`/_matrix/client/unstable/org.matrix.msc3814.v1`,pl=`org.matrix.msc3814`,ml=10080*60*1e3,hl=class extends ie{constructor(e,t,n,r,a){super(),this.logger=e,this.olmMachine=t,this.http=n,this.outgoingRequestProcessor=r,this.secretStorage=a,i(this,`intervalId`,void 0)}cacheKey(e){var t=this;return T(function*(){yield t.olmMachine.dehydratedDevices().saveDehydratedDeviceKey(e),t.emit(b.DehydrationKeyCached)})()}isSupported(){var e=this;return T(function*(){try{yield e.http.authedRequest(v.Get,`/dehydrated_device`,void 0,void 0,{prefix:fl})}catch(e){var t=e;if(t.errcode===`M_UNRECOGNIZED`)return!1;if(t.errcode===`M_NOT_FOUND`)return!0;throw e}return!0})()}start(){var e=arguments,t=this;return T(function*(){var n=e.length>0&&e[0]!==void 0?e[0]:{};if(typeof n==`boolean`&&(n={createNewKey:n}),!(n.onlyIfKeyCached&&!(yield t.olmMachine.dehydratedDevices().getDehydratedDeviceKey()))){if(t.stop(),n.rehydrate!==!1)try{yield t.rehydrateDeviceIfAvailable()}catch(e){t.logger.info(`dehydration: Error rehydrating device:`,e),t.emit(b.RehydrationError,e.message)}n.createNewKey&&(yield t.resetKey()),yield t.scheduleDeviceDehydration()}})()}isKeyStored(){var e=this;return T(function*(){return!!(yield e.secretStorage.isStored(pl))})()}resetKey(){var e=this;return T(function*(){var t=j.createRandomKey();return yield e.secretStorage.store(pl,t.toBase64()),yield e.cacheKey(t),t})()}getKey(e){var t=this;return T(function*(){var n=yield t.olmMachine.dehydratedDevices().getDehydratedDeviceKey();if(n)return n;var r=yield t.secretStorage.get(pl);if(r===void 0)return e?yield t.resetKey():null;var i=te(r);try{var a=j.createKeyFromArray(i);return yield t.cacheKey(a),a}finally{i.fill(0)}})()}rehydrateDeviceIfAvailable(){var e=this;return T(function*(){var t=yield e.getKey(!1);if(!t)return!1;var n;try{n=yield e.http.authedRequest(v.Get,`/dehydrated_device`,void 0,void 0,{prefix:fl})}catch(t){var r=t;if(r.errcode===`M_NOT_FOUND`||r.errcode===`M_UNRECOGNIZED`)return e.logger.info(`dehydration: No dehydrated device`),!1;throw r}e.logger.info(`dehydration: dehydrated device found`),e.emit(b.RehydrationStarted);var i=yield e.olmMachine.dehydratedDevices().rehydrate(t,new M(n.device_id),JSON.stringify(n.device_data));e.logger.info(`dehydration: device rehydrated`);for(var a=void 0,o=0,s=0,c=ae(`/dehydrated_device/$device_id/events`,{$device_id:n.device_id});;){var l=yield e.http.authedRequest(v.Post,c,void 0,a?{next_batch:a}:{},{prefix:fl});if(l.events.length===0)break;o+=l.events.length,a=l.next_batch;var u=yield i.receiveEvents(JSON.stringify(l.events));s+=u.length,e.emit(b.RehydrationProgress,s,o)}return e.logger.info(`dehydration: received ${s} room keys from ${o} to-device events`),e.emit(b.RehydrationCompleted),!0})()}createAndUploadDehydratedDevice(){var e=this;return T(function*(){var t=yield e.getKey(!0),n=yield e.olmMachine.dehydratedDevices().create();e.emit(b.DehydratedDeviceCreated);var r=yield n.keysForUpload(`Dehydrated device`,t);yield e.outgoingRequestProcessor.makeOutgoingRequest(r),e.emit(b.DehydratedDeviceUploaded),e.logger.info(`dehydration: uploaded device`)})()}scheduleDeviceDehydration(){var e=this;return T(function*(){e.stop(),yield e.createAndUploadDehydratedDevice(),e.intervalId=setInterval(()=>{e.createAndUploadDehydratedDevice().catch(t=>{e.emit(b.DehydratedDeviceRotationError,t.message),e.logger.error(`Error creating dehydrated device:`,t)})},ml)})()}stop(){this.intervalId&&=(clearInterval(this.intervalId),void 0)}delete(){var e=this;return T(function*(){e.stop();try{yield e.http.authedRequest(v.Delete,`/dehydrated_device`,void 0,{},{prefix:fl})}catch(e){var t=e;if(t.errcode===`M_UNRECOGNIZED`||t.errcode===`M_NOT_FOUND`)return;throw e}})()}};function gl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _l(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?gl(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gl(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var vl=class{constructor(e,t,n){this.logger=e,this.olmMachine=t,this.http=n}makeOutgoingRequest(e,t){var n=this;return T(function*(){var r;if(e instanceof pt)r=yield n.requestWithRetry(v.Post,`/_matrix/client/v3/keys/upload`,{},e.body);else if(e instanceof ft)r=yield n.requestWithRetry(v.Post,`/_matrix/client/v3/keys/query`,{},e.body);else if(e instanceof dt)r=yield n.requestWithRetry(v.Post,`/_matrix/client/v3/keys/claim`,{},e.body);else if(e instanceof nn)r=yield n.requestWithRetry(v.Post,`/_matrix/client/v3/keys/signatures/upload`,{},e.body);else if(e instanceof ut)r=yield n.requestWithRetry(v.Put,`/_matrix/client/v3/room_keys/keys`,{version:e.version},e.body);else if(e instanceof cn)r=yield n.sendToDeviceRequest(e);else if(e instanceof Gt){var i=`/_matrix/client/v3/rooms/${encodeURIComponent(e.room_id)}/send/${encodeURIComponent(e.event_type)}/${encodeURIComponent(e.txn_id)}`;r=yield n.requestWithRetry(v.Put,i,{},e.body)}else if(e instanceof mn){yield n.makeRequestWithUIA(v.Post,`/_matrix/client/v3/keys/device_signing/upload`,{},e.body,t);return}else if(e instanceof Mt){var a=fl+`/dehydrated_device`;yield n.rawJsonRequest(v.Put,a,{},e.body);return}else n.logger.warn(`Unsupported outgoing message`,Object.getPrototypeOf(e)),r=``;if(e.id)try{yield S(n.logger,`Mark Request as sent ${e.type}`,T(function*(){yield n.olmMachine.markRequestAsSent(e.id,e.type,r)}))}catch(e){if(e instanceof Error&&(e.message===`Attempt to use a moved value`||e.message===`null pointer passed to rust`))n.logger.debug(`Ignoring error '${e.message}': client is likely shutting down`);else throw e}else n.logger.trace(`Outgoing request type:${e.type} does not have an ID`)})()}sendToDeviceRequest(e){var t=this;return T(function*(){var n=JSON.parse(e.body),r=[];for(var i of Object.entries(n.messages)){var a=E(i,2),o=a[0],s=a[1];for(var c of Object.entries(s)){var l=E(c,2),u=l[0],d=l[1];r.push(`${o}/${u} (msgid ${d[re]})`)}}t.logger.info(`Sending batch of to-device messages. type=${e.event_type} txnid=${e.txn_id}`,r);var f=`/_matrix/client/v3/sendToDevice/${encodeURIComponent(e.event_type)}/`+encodeURIComponent(e.txn_id);return yield t.requestWithRetry(v.Put,f,{},e.body)})()}makeRequestWithUIA(e,t,n,r,i){var a=this;return T(function*(){if(!i)return yield a.requestWithRetry(e,t,n,r);var o=JSON.parse(r),s=yield i(function(){var r=T(function*(r){var i=_l({},o);r!==null&&(i.auth=r);var s=yield a.requestWithRetry(e,t,n,JSON.stringify(i));return JSON.parse(s)});return function(e){return r.apply(this,arguments)}}());return JSON.stringify(s)})()}requestWithRetry(e,t,n,r){var i=this;return T(function*(){for(var a=0;;)try{return yield i.rawJsonRequest(e,t,n,r)}catch(e){a++;var o=p(e,a,!0);if(o<0)throw e;yield _(o)}})()}rawJsonRequest(e,t,n,r){var i=this;return T(function*(){return yield i.http.authedRequest(e,t,n,r,{json:!1,headers:{"Content-Type":`application/json`,Accept:`application/json`},prefix:``,localTimeoutMs:6e4})})()}},yl=class{constructor(e,t){this.olmMachine=e,this.outgoingRequestProcessor=t,i(this,`currentClaimPromise`,void 0),i(this,`stopped`,!1),this.currentClaimPromise=Promise.resolve()}stop(){this.stopped=!0}ensureSessionsForUsers(e,t){var n=this.currentClaimPromise.catch(()=>{}).then(()=>this.ensureSessionsForUsersInner(e,t));return this.currentClaimPromise=n,n}ensureSessionsForUsersInner(e,t){var n=this;return T(function*(){if(n.stopped)throw Error(`Cannot ensure Olm sessions: shutting down`);e.info(`Checking for missing Olm sessions`);var r=yield n.olmMachine.getMissingSessions(t.map(e=>e.clone()));r&&(e.info(`Making /keys/claim request`),yield n.outgoingRequestProcessor.makeOutgoingRequest(r)),e.info(`Olm sessions prepared`)})()}};function bl(e,t){var n=new Map;for(var r of e.keys.entries()){var i=E(r,2),a=i[0],o=i[1];n.set(a.toString(),o.toBase64())}var s=me.Unverified;e.isBlacklisted()?s=me.Blocked:e.isVerified()&&(s=me.Verified);var c=new Map,l=e.signatures.get(t);if(l){var u=new Map;for(var d of l.entries()){var f=E(d,2),p=f[0],m=f[1];m.isValid()&&m.signature&&u.set(p,m.signature.toBase64())}c.set(t.toString(),u)}var ee=e.algorithms,h=new Set;return ee.forEach(e=>{switch(e){case et.MegolmV1AesSha2:h.add(`m.megolm.v1.aes-sha2`);break;case et.OlmV1Curve25519AesSha2:default:h.add(`m.olm.v1.curve25519-aes-sha2`);break}}),new ce({deviceId:e.deviceId.toString(),userId:t.toString(),keys:n,algorithms:Array.from(h),verified:s,signatures:c,displayName:e.displayName,dehydrated:e.isDehydrated})}function xl(e){return new Map(Object.entries(e).map(e=>{var t=E(e,2),n=t[0],r=t[1];return[n,Sl(r)]}))}function Sl(e){var t=new Map(Object.entries(e.keys)),n=e.unsigned?.device_display_name,r=new Map;if(e.signatures)for(var i in e.signatures)r.set(i,new Map(Object.entries(e.signatures[i])));return new ce({deviceId:e.device_id,userId:e.user_id,keys:t,algorithms:e.algorithms,verified:me.Unverified,signatures:r,displayName:n})}var Cl=class{constructor(e,t,n,r){this.logger=e,this.olmMachine=t,this.outgoingRequestProcessor=n,this.secretStorage=r}bootstrapCrossSigning(e){var t=this;return T(function*(){if(e.setupNewCrossSigning){yield t.resetCrossSigning(e.authUploadDeviceSigningKeys);return}var n=yield t.olmMachine.crossSigningStatus(),r=yield t.secretStorage.get(`m.cross_signing.master`),i=yield t.secretStorage.get(`m.cross_signing.self_signing`),a=yield t.secretStorage.get(`m.cross_signing.user_signing`),o=!!(r&&i&&a),s=n.hasMaster&&n.hasUserSigning&&n.hasSelfSigning;if(t.logger.debug(`bootstrapCrossSigning: starting`,{setupNewCrossSigning:e.setupNewCrossSigning,olmDeviceHasMaster:n.hasMaster,olmDeviceHasUserSigning:n.hasUserSigning,olmDeviceHasSelfSigning:n.hasSelfSigning,privateKeysInSecretStorage:o}),s)(yield t.secretStorage.hasKey())?o?t.logger.debug(`bootstrapCrossSigning: Olm device has private keys and they are saved in secret storage; doing nothing`):(t.logger.debug(`bootstrapCrossSigning: Olm device has private keys: exporting to secret storage`),yield t.exportCrossSigningKeysToStorage()):t.logger.warn(`bootstrapCrossSigning: Olm device has private keys, but secret storage is not yet set up; doing nothing for now.`);else if(o){t.logger.debug(`bootstrapCrossSigning: Cross-signing private keys not found locally, but they are available in secret storage, reading storage and caching locally`);var c=yield t.olmMachine.importCrossSigningKeys(r,i,a);if(!c.hasMaster||!c.hasSelfSigning||!c.hasUserSigning)throw Error(`importCrossSigningKeys failed to import the keys`);var l=yield t.olmMachine.getDevice(t.olmMachine.userId,t.olmMachine.deviceId);try{var u=yield l.verify();yield t.outgoingRequestProcessor.makeOutgoingRequest(u)}finally{l.free()}}else t.logger.debug(`bootstrapCrossSigning: Cross-signing private keys not found locally or in secret storage, creating new keys`),yield t.resetCrossSigning(e.authUploadDeviceSigningKeys);t.logger.debug(`bootstrapCrossSigning: complete`)})()}resetCrossSigning(e){var t=this;return T(function*(){var n=yield t.olmMachine.bootstrapCrossSigning(!0);(yield t.secretStorage.hasKey())?(t.logger.debug(`resetCrossSigning: exporting private keys to secret storage`),yield t.exportCrossSigningKeysToStorage()):t.logger.warn(`resetCrossSigning: Secret storage is not yet set up; not exporting keys to secret storage yet.`),t.logger.debug(`resetCrossSigning: publishing public keys to server`);for(var r of[n.uploadKeysRequest,n.uploadSigningKeysRequest,n.uploadSignaturesRequest])r&&(yield t.outgoingRequestProcessor.makeOutgoingRequest(r,e))})()}exportCrossSigningKeysToStorage(){var e=this;return T(function*(){var t=yield e.olmMachine.exportCrossSigningKeys();t!=null&&t.masterKey?yield e.secretStorage.store(`m.cross_signing.master`,t.masterKey):e.logger.error(`Cannot export MSK to secret storage, private key unknown`),t!=null&&t.self_signing_key?yield e.secretStorage.store(`m.cross_signing.self_signing`,t.self_signing_key):e.logger.error(`Cannot export SSK to secret storage, private key unknown`),t!=null&&t.userSigningKey?yield e.secretStorage.store(`m.cross_signing.user_signing`,t.userSigningKey):e.logger.error(`Cannot export USK to secret storage, private key unknown`)})()}};function wl(e){return Tl.apply(this,arguments)}function Tl(){return Tl=T(function*(e){return El(e,[`m.cross_signing.master`,`m.cross_signing.user_signing`,`m.cross_signing.self_signing`])}),Tl.apply(this,arguments)}function El(e,t){return Dl.apply(this,arguments)}function Dl(){return Dl=T(function*(e,t){var n=yield e.getDefaultKeyId();if(!n)return!1;for(var r of t)if(!(n in((yield e.isStored(r))||{})))return!1;return!0}),Dl.apply(this,arguments)}var Q=function(e){return e.Sas=`m.sas.v1`,e.ShowQrCode=`m.qr_code.show.v1`,e.ScanQrCode=`m.qr_code.scan.v1`,e.Reciprocate=`m.reciprocate.v1`,e}({}),Ol=class extends ie{constructor(e,t,n,r,a){super(),this.logger=e,this.olmMachine=t,this.inner=n,this.outgoingRequestProcessor=r,this.supportedVerificationMethods=a,i(this,`reEmitter`,void 0),i(this,`_accepting`,!1),i(this,`_cancelling`,!1),i(this,`_verifier`,void 0),this.reEmitter=new we(this);var o=new WeakRef(this);n.registerChangesCallback(T(function*(){return o.deref()?.onChange()}))}onChange(){var e=this.inner.getVerification();e instanceof Jt?this._verifier===void 0||this._verifier instanceof Al?this.setVerifier(new jl(e,this,this.outgoingRequestProcessor)):this._verifier instanceof jl&&this._verifier.replaceInner(e):e instanceof Nt&&this._verifier===void 0&&this.setVerifier(new Al(e,this.outgoingRequestProcessor)),this.emit(pe.Change)}setVerifier(e){this._verifier&&this.reEmitter.stopReEmitting(this._verifier,[pe.Change]),this._verifier=e,this.reEmitter.reEmit(this._verifier,[pe.Change])}get transactionId(){return this.inner.flowId}get roomId(){return this.inner.roomId?.toString()}get initiatedByMe(){return this.inner.weStarted()}get otherUserId(){return this.inner.otherUserId.toString()}get otherDeviceId(){return this.inner.otherDeviceId?.toString()}getOtherDevice(){var e=this;return T(function*(){var t=e.inner.otherDeviceId;if(t)return yield e.olmMachine.getDevice(e.inner.otherUserId,t,5)})()}get isSelfVerification(){return this.inner.isSelfVerification()}get phase(){var e=this.inner.phase();switch(e){case R.Created:case R.Requested:return g.Requested;case R.Ready:return this._accepting?g.Requested:g.Ready;case R.Transitioned:if(!this._verifier)throw Error(`VerificationRequest: inner phase == Transitioned but no verifier!`);return this._verifier.verificationPhase;case R.Done:return g.Done;case R.Cancelled:return g.Cancelled}throw Error(`Unknown verification phase ${e}`)}get pending(){if(this.inner.isPassive())return!1;var e=this.phase;return e!==g.Done&&e!==g.Cancelled}get accepting(){return this._accepting}get declining(){return this._cancelling}get timeout(){return this.inner.timeRemainingMillis()}get methods(){throw Error(`not implemented`)}get chosenMethod(){if(this.phase!==g.Started)return null;var e=this.inner.getVerification();return e instanceof Jt?Q.Sas:e instanceof Nt?Q.Reciprocate:null}otherPartySupportsMethod(e){var t=this.inner.theirSupportedMethods;if(t===void 0)return!1;var n=Ml[e];return t.some(e=>e===n)}accept(){var e=this;return T(function*(){if(e.inner.phase()!==R.Requested||e._accepting)throw Error(`Cannot accept a verification request in phase ${e.phase}`);e._accepting=!0;try{var t=e.inner.acceptWithMethods(e.supportedVerificationMethods.map(Nl));t&&(yield e.outgoingRequestProcessor.makeOutgoingRequest(t))}finally{e._accepting=!1}e.emit(pe.Change)})()}cancel(e){var t=this;return T(function*(){if(!t._cancelling){t.logger.info(`Cancelling verification request with params:`,e),t._cancelling=!0;try{var n=t.inner.cancel();n&&(yield t.outgoingRequestProcessor.makeOutgoingRequest(n))}finally{t._cancelling=!1}}})()}beginKeyVerification(e,t){throw Error(`not implemented`)}startVerification(e){var t=this;return T(function*(){if(e!==Q.Sas)throw Error(`Unsupported verification method ${e}`);if(!(yield t.getOtherDevice()))throw Error(`startVerification(): other device is unknown`);var n=yield t.inner.startSas();if(n){var r=E(n,2)[1];yield t.outgoingRequestProcessor.makeOutgoingRequest(r)}if(!t._verifier)throw Error(`Still no verifier after startSas() call`);return t._verifier})()}scanQRCode(e){var t=this;return T(function*(){var n=Rt.fromBytes(e),r=yield t.inner.scanQrCode(n);if(!t._verifier)throw Error(`Still no verifier after scanQrCode() call`);var i=r.reciprocate();return i&&(yield t.outgoingRequestProcessor.makeOutgoingRequest(i)),t._verifier})()}get verifier(){return this.phase===g.Started?this._verifier:void 0}getQRCodeBytes(){throw Error(`getQRCodeBytes() unsupported in Rust Crypto; use generateQRCode() instead.`)}generateQRCode(){var e=this;return T(function*(){if(!(yield e.getOtherDevice()))throw Error(`generateQRCode(): other device is unknown`);var t=yield e.inner.generateQrCode();if(t)return t.toBytes()})()}get cancellationCode(){return this.inner.cancelInfo?.cancelCode()??null}get cancellingUserId(){var e=this.inner.cancelInfo;if(e)return e.cancelledbyUs()?this.olmMachine.userId.toString():this.inner.otherUserId.toString()}},kl=class extends ie{constructor(e,t){super(),this.inner=e,this.outgoingRequestProcessor=t,i(this,`completionDeferred`,void 0),this.completionDeferred=Promise.withResolvers();var n=new WeakRef(this);e.registerChangesCallback(T(function*(){return n.deref()?.onChange()})),this.completionDeferred.promise.catch(()=>null)}onChange(){if(this.inner.isDone())this.completionDeferred.resolve(void 0);else if(this.inner.isCancelled()){var e=this.inner.cancelInfo();this.completionDeferred.reject(Error(`Verification cancelled by ${e.cancelledbyUs()?`us`:`them`} with code ${e.cancelCode()}: ${e.reason()}`))}this.emit(pe.Change)}get hasBeenCancelled(){return this.inner.isCancelled()}get userId(){return this.inner.otherUserId.toString()}cancel(e){var t=this.inner.cancel();t&&this.outgoingRequestProcessor.makeOutgoingRequest(t)}getShowSasCallbacks(){return null}getReciprocateQrCodeCallbacks(){return null}},Al=class extends kl{constructor(e,t){super(e,t),i(this,`callbacks`,null)}onChange(){this.callbacks===null&&this.inner.hasBeenScanned()&&(this.callbacks={confirm:()=>{this.confirmScanning()},cancel:()=>this.cancel()}),super.onChange()}verify(){var e=this;return T(function*(){e.callbacks!==null&&e.emit(a.ShowReciprocateQr,e.callbacks),yield e.completionDeferred.promise})()}get verificationPhase(){switch(this.inner.state()){case P.Created:return g.Ready;case P.Scanned:return g.Started;case P.Confirmed:return g.Started;case P.Reciprocated:return g.Started;case P.Done:return g.Done;case P.Cancelled:return g.Cancelled;default:throw Error(`Unknown qr code state ${this.inner.state()}`)}}getReciprocateQrCodeCallbacks(){return this.callbacks}confirmScanning(){var e=this;return T(function*(){var t=e.inner.confirmScanning();t&&(yield e.outgoingRequestProcessor.makeOutgoingRequest(t))})()}},jl=class extends kl{constructor(e,t,n){super(e,n),i(this,`callbacks`,null)}verify(){var e=this;return T(function*(){yield e.sendAccept(),yield e.completionDeferred.promise})()}sendAccept(){var e=this;return T(function*(){var t=e.inner.accept();t&&(yield e.outgoingRequestProcessor.makeOutgoingRequest(t))})()}onChange(){var e=this;if(super.onChange(),this.callbacks===null){var t=this.inner.emoji(),n=this.inner.decimals();if(t===void 0&&n===void 0)return;var r={};t&&(r.emoji=t.map(e=>[e.symbol,e.description])),n&&(r.decimal=[n[0],n[1],n[2]]),this.callbacks={sas:r,confirm:function(){var t=T(function*(){for(var t of yield e.inner.confirm())yield e.outgoingRequestProcessor.makeOutgoingRequest(t)});function n(){return t.apply(this,arguments)}return n}(),mismatch:()=>{var e=this.inner.cancelWithCode(`m.mismatched_sas`);e&&this.outgoingRequestProcessor.makeOutgoingRequest(e)},cancel:()=>{var e=this.inner.cancelWithCode(`m.user`);e&&this.outgoingRequestProcessor.makeOutgoingRequest(e)}},this.emit(a.ShowSas,this.callbacks)}}get verificationPhase(){return g.Started}getShowSasCallbacks(){return this.callbacks}replaceInner(e){if(this.inner!=e){this.inner=e;var t=new WeakRef(this);e.registerChangesCallback(T(function*(){return t.deref()?.onChange()})),this.sendAccept(),this.onChange()}}},Ml={[Q.Sas]:gn.SasV1,[Q.ScanQrCode]:gn.QrCodeScanV1,[Q.ShowQrCode]:gn.QrCodeShowV1,[Q.Reciprocate]:gn.ReciprocateV1};function Nl(e){var t=Ml[e];if(t===void 0)throw Error(`Unknown verification method ${e}`);return t}function Pl(e){switch(e.getType()){case x.KeyVerificationCancel:case x.KeyVerificationDone:case x.KeyVerificationMac:case x.KeyVerificationStart:case x.KeyVerificationKey:case x.KeyVerificationReady:case x.KeyVerificationAccept:return!0;case x.RoomMessage:return e.getContent().msgtype===f.KeyVerificationRequest;default:return!1}}var Fl=class extends ie{constructor(e,t,n,r){super(),this.olmMachine=t,this.http=n,this.outgoingRequestProcessor=r,i(this,`checkedForBackup`,!1),i(this,`serverBackupInfo`,void 0),i(this,`activeBackupVersion`,null),i(this,`stopped`,!1),i(this,`backupKeysLoopRunning`,!1),i(this,`logger`,void 0),i(this,`keyBackupCheckInProgress`,null),this.logger=e.getChild(`[RustBackupManager]`)}stop(){this.stopped=!0}getActiveBackupVersion(){var e=this;return T(function*(){return(yield e.olmMachine.isBackupEnabled())?e.activeBackupVersion:null})()}getServerBackupInfo(){var e=this;return T(function*(){return yield e.checkKeyBackupAndEnable(!1),e.serverBackupInfo})()}isKeyBackupTrusted(e){var t=this;return T(function*(){var n=yield t.olmMachine.verifyBackup(e),r=(yield t.olmMachine.getBackupKeys())?.decryptionKey;return{matchesDecryptionKey:!!r&&t.backupInfoMatchesBackupDecryptionKey(e,r),trusted:n.trusted()}})()}checkKeyBackupAndEnable(e){return!e&&this.checkedForBackup?Promise.resolve(null):(this.keyBackupCheckInProgress||=this.doCheckKeyBackup().finally(()=>{this.keyBackupCheckInProgress=null}),this.keyBackupCheckInProgress)}handleBackupSecretReceived(e){var t=this;return T(function*(){var n,r;try{r=yield t.requestKeyBackupVersion()}catch(e){return t.logger.warn(`handleBackupSecretReceived: Error checking for latest key backup`,e),!1}if(!((n=r)!=null&&n.version))return t.logger.warn(`handleBackupSecretReceived: Received a backup decryption key, but there is no server-side key backup`),!1;var i;try{i=D.fromBase64(e)}catch(e){return t.logger.warn(`handleBackupSecretReceived: Invalid backup decryption key`,e),!1}try{return t.backupInfoMatchesBackupDecryptionKey(r,i)?(t.logger.info(`handleBackupSecretReceived: Valid decryption key for the current server-side backup version (${r.version}) received`),yield t.saveBackupDecryptionKey(i,r.version),t.keyBackupCheckInProgress&&(t.logger.debug(`handleBackupSecretReceived: waiting for ongoing keybackup check to complete`),yield t.keyBackupCheckInProgress),t.logger.debug(`handleBackupSecretReceived: checking if we can enable keybackup upload`),t.keyBackupCheckInProgress=t.doCheckKeyBackup(r).finally(()=>{t.keyBackupCheckInProgress=null}),yield t.keyBackupCheckInProgress,!0):(t.logger.warn(`handleBackupSecretReceived: Private decryption key does not match the public key of the current server-side backup version (${r.version})`),!1)}catch(e){t.logger.warn(`handleBackupSecretReceived: Unable to validate backup decryption key`,e)}return!1})()}saveBackupDecryptionKey(e,t){var n=this;return T(function*(){yield n.olmMachine.saveBackupDecryptionKey(e,t),n.emit(b.KeyBackupDecryptionKeyCached,t)})()}importRoomKeys(e,t){var n=this;return T(function*(){yield n.importRoomKeysAsJson(JSON.stringify(e),t)})()}importRoomKeysAsJson(e,t){var n=this;return T(function*(){yield n.olmMachine.importExportedRoomKeys(e,(e,n)=>{var r,i={total:Number(n),successes:Number(e),stage:s.LoadKeys,failures:0};t==null||(r=t.progressCallback)==null||r.call(t,i)})})()}importBackedUpRoomKeys(e,t,n){var r=this;return T(function*(){var i=new Map;for(var a of e){var o=new F(a.room_id);i.has(o)||i.set(o,new Map),i.get(o).set(a.session_id,a)}yield r.olmMachine.importBackedUpRoomKeys(i,(e,t,r)=>{var i,a={total:Number(t),successes:Number(e),stage:s.LoadKeys,failures:Number(r)};n==null||(i=n.progressCallback)==null||i.call(n,a)},t)})()}doCheckKeyBackup(e){var t=this;return T(function*(){t.logger.debug(`Checking key backup status...`);try{e||=yield t.requestKeyBackupVersion()}catch(e){return t.logger.warn(`Error checking for active key backup`,e),t.serverBackupInfo=void 0,null}t.checkedForBackup=!0,e&&!e.version&&(t.logger.warn(`active backup lacks a useful 'version'; ignoring it`),e=void 0),t.serverBackupInfo=e;var n=yield t.getActiveBackupVersion();if(!e)return n===null?t.logger.debug(`No key backup present on server: not enabling key backup`):(t.logger.debug(`No key backup present on server: disabling key backup`),yield t.disableKeyBackup()),null;var r=yield t.isKeyBackupTrusted(e);return!r.matchesDecryptionKey&&!r.trusted?n===null?t.logger.debug(`Key backup present on server but not trusted: not enabling key backup`):(t.logger.debug(`Key backup present on server but not trusted: disabling key backup`),yield t.disableKeyBackup()):n===null?(t.logger.debug(`Found usable key backup v${e.version}: enabling key backups`),yield t.enableKeyBackup(e)):n===e.version?t.logger.debug(`Backup version ${e.version} still current`):(t.logger.debug(`On backup version ${n} but found version ${e.version}: switching.`),yield t.disableKeyBackup(),yield t.enableKeyBackup(e)),{backupInfo:e,trustInfo:r}})()}enableKeyBackup(e){var t=this;return T(function*(){yield t.olmMachine.enableBackupV1(e.auth_data.public_key,e.version),t.activeBackupVersion=e.version,t.emit(b.KeyBackupStatus,!0),t.backupKeysLoop()})()}maybeUploadKey(){var e=this;return T(function*(){e.activeBackupVersion!=null&&e.backupKeysLoop()})()}disableKeyBackup(){var e=this;return T(function*(){yield e.olmMachine.disableBackup(),e.activeBackupVersion=null,e.emit(b.KeyBackupStatus,!1)})()}backupKeysLoop(){var e=arguments,t=this;return T(function*(){var n=e.length>0&&e[0]!==void 0?e[0]:1e4;if(t.backupKeysLoopRunning){t.logger.debug(`Backup loop already running`);return}t.backupKeysLoopRunning=!0,t.logger.debug(`Backup: Starting keys upload loop for backup version:${t.activeBackupVersion}.`),yield _(Math.random()*n);try{for(var r=0,i=null,a=!0;!t.stopped;){var o=void 0;try{o=yield S(t.logger,`BackupRoomKeys: Get keys to backup from rust crypto-sdk`,T(function*(){return yield t.olmMachine.backupRoomKeys()}))}catch(e){t.logger.error(`Backup: Failed to get keys to backup from rust crypto-sdk`,e)}if(!o||t.stopped||!t.activeBackupVersion){t.logger.debug(`Backup: Ending loop for version ${t.activeBackupVersion}.`),o||t.emit(b.KeyBackupSessionsRemaining,0);return}try{if(yield t.outgoingRequestProcessor.makeOutgoingRequest(o),r=0,t.stopped)break;if(!a&&i===null)try{var s=yield t.olmMachine.roomKeyCounts();i=s.total-s.backedUp}catch(e){t.logger.error(`Backup: Failed to get key counts from rust crypto-sdk`,e)}if(i!==null){t.emit(b.KeyBackupSessionsRemaining,i);var c=t.keysCountInBatch(o);i=Math.max(i-c,0)}}catch(e){if(r++,t.logger.error(`Backup: Error processing backup request for rust crypto-sdk`,e),e instanceof ee){var l=e.data.errcode;if(l==`M_NOT_FOUND`||l==`M_WRONG_ROOM_KEYS_VERSION`){t.logger.debug(`Backup: Failed to upload keys to current vesion: ${l}.`);try{yield t.disableKeyBackup()}catch(e){t.logger.error(`Backup: An error occurred while disabling key backup:`,e)}t.emit(b.KeyBackupFailed,e.data.errcode),t.backupKeysLoopRunning=!1,t.checkKeyBackupAndEnable(!0);return}else if(e.isRateLimitError())try{var u=e.getRetryAfterMs();if(u&&u>0){yield _(u);continue}}catch(e){t.logger.warn(`Backup: An error occurred while retrieving a rate-limit retry delay`,e)}}yield _(1e3*2**Math.min(r-1,4))}a=!1}}finally{t.backupKeysLoopRunning=!1}})()}keysCountInBatch(e){return Bl(JSON.parse(e.body))}requestKeyBackupVersion(e){var t=this;return T(function*(){return yield Ll(t.http,e)})()}setupKeyBackup(e){var t=this;return T(function*(){yield t.deleteAllKeyBackupVersions();var n=D.createRandomKey(),r=n.megolmV1PublicKey,i={public_key:r.publicKeyBase64};yield e(i);var a=yield t.http.authedRequest(v.Post,`/room_keys/version`,void 0,{algorithm:r.algorithm,auth_data:i},{prefix:u.V3});return yield t.saveBackupDecryptionKey(n,a.version),{version:a.version,algorithm:r.algorithm,authData:i,decryptionKey:n}})()}deleteAllKeyBackupVersions(){var e=this;return T(function*(){for(var t=(yield e.requestKeyBackupVersion())?.version??null;t!=null;)yield e.deleteKeyBackupVersion(t),t=(yield e.requestKeyBackupVersion())?.version??null})()}deleteKeyBackupVersion(e){var t=this;return T(function*(){t.logger.debug(`deleteKeyBackupVersion v:${e}`);var n=ae(`/room_keys/version/$version`,{$version:e});yield t.http.authedRequest(v.Delete,n,void 0,void 0,{prefix:u.V3}),t.activeBackupVersion===e&&(t.serverBackupInfo=null,yield t.disableKeyBackup())})()}createBackupDecryptor(e){return new Il(this.logger,e)}restoreKeyBackup(e,t,n){var r=this;return T(function*(){var i=yield r.downloadKeyBackup(e);return r.importKeyBackup(i,e,t,n)})()}downloadLatestRoomKeyBackup(e){var t=this;return T(function*(){var n=yield t.olmMachine.getBackupKeys(),r=n.backupVersion,i=n.decryptionKey;if(!r||!i){t.logger.warn(`downloadLatestRoomKeyBackup: Could not download backup (backupVersion=${r}, hasDecryptionKey=${!!i})`);return}var a=yield t.downloadRoomKeyBackup(r,e),o=t.createBackupDecryptor(i);t.importKeyBackup({rooms:{[e]:{sessions:a}}},r,o)})()}downloadKeyBackup(e){return this.http.authedRequest(v.Get,`/room_keys/keys`,{version:e},void 0,{prefix:u.V3})}downloadRoomKeyBackup(e,t){var n=ae(`/room_keys/keys/$roomId`,{$roomId:t});return this.http.authedRequest(v.Get,n,{version:e},void 0,{prefix:u.V3})}importKeyBackup(e,t,n,r){var i=this;return T(function*(){var a,o=200,c=Bl(e),l=0,u=0;r==null||(a=r.progressCallback)==null||a.call(r,{total:c,successes:l,stage:s.LoadKeys,failures:u});var d=function(){var e=T(function*(e){var a,o=[],d=function*(t){(yield n.decryptSessions(e.get(t))).forEach(e=>{e.room_id=t,o.push(e)})};for(var f of e.keys())yield*d(f);try{yield i.importBackedUpRoomKeys(o,t),l+=o.length}catch(e){u+=o.length,i.logger.error(`Error importing keys from backup`,e)}r==null||(a=r.progressCallback)==null||a.call(r,{total:c,successes:l,stage:s.LoadKeys,failures:u})});return function(t){return e.apply(this,arguments)}}(),f=0,p=new Map;for(var m of Object.entries(e.rooms)){var ee=E(m,2),h=ee[0],te=ee[1];if(te.sessions){p.set(h,{});for(var g of Object.entries(te.sessions)){var ne=E(g,2),_=ne[0],v=ne[1],y=p.get(h);y[_]=v,f+=1,f>=o&&(yield d(p),p=new Map,p.set(h,{}),f=0)}}}return f>0&&(yield d(p)),{total:c,imported:l}})()}backupInfoMatchesBackupDecryptionKey(e,t){return e.algorithm===`m.megolm_backup.v1.curve25519-aes-sha2`?e.auth_data?.public_key===t.megolmV1PublicKey.publicKeyBase64:(this.logger.warn(`backupMatchesPrivateKey: Unsupported backup algorithm`,e.algorithm),!1)}},Il=class{constructor(e,t){this.logger=e,i(this,`decryptionKey`,void 0),i(this,`sourceTrusted`,void 0),this.decryptionKey=t,this.sourceTrusted=!1}decryptSessions(e){var t=this;return T(function*(){var n=[];for(var r of Object.entries(e)){var i=E(r,2),a=i[0],o=i[1];try{var s=JSON.parse(t.decryptionKey.decryptV1(o.session_data.ephemeral,o.session_data.mac,o.session_data.ciphertext));s.session_id=a,n.push(s)}catch(e){t.logger.debug(`Failed to decrypt megolm session from backup`,e,o)}}return n})()}free(){this.decryptionKey.free()}};function Ll(e,t){return Rl.apply(this,arguments)}function Rl(){return Rl=T(function*(e,t){try{var n=t?ae(`/room_keys/version/$version`,{$version:t}):`/room_keys/version`;return yield e.authedRequest(v.Get,n,void 0,void 0,{prefix:u.V3})}catch(e){if(e.errcode===`M_NOT_FOUND`)return null;throw e}}),Rl.apply(this,arguments)}function zl(e,t){return t.auth_data.public_key===e.megolmV1PublicKey.publicKeyBase64}function Bl(e){var t=0;for(var n of Object.values(e.rooms)){var r=n.sessions;t+=Object.keys(r).length}return t}var Vl=class{constructor(e,t,n){this.logger=e,this.olmMachine=t,this.outgoingRequestProcessor=n,i(this,`stopped`,!1),i(this,`outgoingRequestLoopRunning`,!1),i(this,`nextLoopDeferred`,void 0)}stop(){this.stopped=!0}doProcessOutgoingRequests(){this.nextLoopDeferred||=Promise.withResolvers();var e=this.nextLoopDeferred.promise;return this.outgoingRequestLoopRunning||this.outgoingRequestLoop().catch(e=>{this.logger.error(`Uncaught error in outgoing request loop`,e)}),e}outgoingRequestLoop(){var e=this;return T(function*(){if(e.outgoingRequestLoopRunning)throw Error(`Cannot run two outgoing request loops`);e.outgoingRequestLoopRunning=!0;try{for(;!e.stopped&&e.nextLoopDeferred;){var t=e.nextLoopDeferred;e.nextLoopDeferred=void 0,yield e.processOutgoingRequests().then(t.resolve,t.reject)}}finally{e.outgoingRequestLoopRunning=!1}e.nextLoopDeferred&&e.nextLoopDeferred.reject(Error(`OutgoingRequestsManager was stopped`))})()}processOutgoingRequests(){var e=this;return T(function*(){if(!e.stopped){var t=yield e.olmMachine.outgoingRequests(),n=0,r=function*(t){if(e.stopped)return{v:void 0};try{yield S(e.logger,`Make outgoing request ${t.type}`,T(function*(){yield e.outgoingRequestProcessor.makeOutgoingRequest(t),n++}))}catch(n){e.logger.error(`Failed to process outgoing request ${t.type}: ${n}`)}},i;for(var a of t)if(i=yield*r(a),i)return i.v;n>0&&e.doProcessOutgoingRequests().catch(t=>{e.logger.warn(`processOutgoingRequests: Error re-checking outgoing requests`,t)})}})()}},Hl=5e3,$=function(e){return e.MISSING_DECRYPTION_KEY=`MISSING_DECRYPTION_KEY`,e.NETWORK_ERROR=`NETWORK_ERROR`,e.STOPPED=`STOPPED`,e}($||{}),Ul=class extends Error{constructor(e){super(`Failed to get key from backup: ${e}`),this.code=e,this.name=`KeyDownloadError`}},Wl=class extends Error{constructor(e){super(`Failed to get key from backup: rate limited`),this.retryMillis=e,this.name=`KeyDownloadRateLimitError`}},Gl=class{constructor(e,t,n,r){this.olmMachine=t,this.http=n,this.backupManager=r,i(this,`stopped`,!1),i(this,`configuration`,null),i(this,`sessionLastCheckAttemptedTime`,new Map),i(this,`logger`,void 0),i(this,`downloadLoopRunning`,!1),i(this,`queuedRequests`,[]),i(this,`hasConfigurationProblem`,!1),i(this,`currentBackupVersionCheck`,null),i(this,`onBackupStatusChanged`,()=>{this.hasConfigurationProblem=!1,this.configuration=null,this.getOrCreateBackupConfiguration().then(e=>{e&&this.downloadKeysLoop()})}),this.logger=e.getChild(`[PerSessionKeyBackupDownloader]`),r.on(b.KeyBackupStatus,this.onBackupStatusChanged),r.on(b.KeyBackupFailed,this.onBackupStatusChanged),r.on(b.KeyBackupDecryptionKeyCached,this.onBackupStatusChanged)}isKeyBackupDownloadConfigured(){return this.configuration!==null}getServerBackupInfo(){var e=this;return T(function*(){return yield e.backupManager.getServerBackupInfo()})()}onDecryptionKeyMissingError(e,t){if(this.isAlreadyInQueue(e,t)){this.logger.trace(`Not checking key backup for session ${t} as it is already queued`);return}if(this.wasRequestedRecently(t)){this.logger.trace(`Not checking key backup for session ${t} as it was already requested recently`);return}this.queuedRequests.push({roomId:e,megolmSessionId:t}),this.downloadKeysLoop()}stop(){this.stopped=!0,this.backupManager.off(b.KeyBackupStatus,this.onBackupStatusChanged),this.backupManager.off(b.KeyBackupFailed,this.onBackupStatusChanged),this.backupManager.off(b.KeyBackupDecryptionKeyCached,this.onBackupStatusChanged)}isAlreadyInQueue(e,t){return this.queuedRequests.some(n=>n.roomId==e&&n.megolmSessionId==t)}markAsNotFoundInBackup(e){var t=Date.now();this.sessionLastCheckAttemptedTime.set(e,t),this.sessionLastCheckAttemptedTime.size>100&&(this.sessionLastCheckAttemptedTime=new Map(Array.from(this.sessionLastCheckAttemptedTime).filter((e,n)=>Math.max(t-n,0)<Hl)))}wasRequestedRecently(e){var t=this.sessionLastCheckAttemptedTime.get(e);return t?Math.max(Date.now()-t,0)<Hl:!1}getBackupDecryptionKey(){var e=this;return T(function*(){try{return yield e.olmMachine.getBackupKeys()}catch{return null}})()}requestRoomKeyFromBackup(e,t,n){var r=this;return T(function*(){var i=ae(`/room_keys/keys/$roomId/$sessionId`,{$roomId:t,$sessionId:n});return yield r.http.authedRequest(v.Get,i,{version:e},void 0,{prefix:u.V3})})()}downloadKeysLoop(){var e=this;return T(function*(){if(!e.downloadLoopRunning&&!e.hasConfigurationProblem){e.downloadLoopRunning=!0;try{for(;e.queuedRequests.length>0;){var t=e.queuedRequests[0];try{var n=yield e.getOrCreateBackupConfiguration();if(!n){e.downloadLoopRunning=!1;return}var r=yield e.queryKeyBackup(t.roomId,t.megolmSessionId,n);if(e.stopped)return;try{yield e.decryptAndImport(t,r,n)}catch(n){e.logger.error(`Error while decrypting and importing key backup for session ${t.megolmSessionId}`,n)}e.queuedRequests.shift()}catch(n){if(n instanceof Ul)switch(n.code){case $.MISSING_DECRYPTION_KEY:e.markAsNotFoundInBackup(t.megolmSessionId),e.queuedRequests.shift();break;case $.NETWORK_ERROR:yield _(Hl);break;case $.STOPPED:e.downloadLoopRunning=!1;return}else n instanceof Wl&&(yield _(n.retryMillis))}}}finally{e.downloadLoopRunning=!1}}})()}queryKeyBackup(e,t,n){var r=this;return T(function*(){if(r.logger.debug(`Checking key backup for session ${t}`),r.stopped)throw new Ul($.STOPPED);try{var i=yield r.requestRoomKeyFromBackup(n.backupVersion,e,t);return r.logger.debug(`Got key from backup for sessionId:${t}`),i}catch(e){if(r.stopped)throw new Ul($.STOPPED);if(r.logger.info(`No luck requesting key backup for session ${t}: ${e}`),e instanceof ee){if(e.data.errcode==`M_NOT_FOUND`)throw new Ul($.MISSING_DECRYPTION_KEY);if(e.isRateLimitError()){var a;try{a=e.getRetryAfterMs()??void 0}catch(e){r.logger.warn(`Error while retrieving a rate-limit retry delay`,e)}throw a&&a>0&&r.logger.info(`Rate limited by server, waiting ${a}ms`),new Wl(a??Hl)}}throw new Ul($.NETWORK_ERROR)}})()}decryptAndImport(e,t,n){var r=this;return T(function*(){var i={[e.megolmSessionId]:t},a=yield n.decryptor.decryptSessions(i);for(var o of a)o.room_id=e.roomId;yield r.backupManager.importBackedUpRoomKeys(a,n.backupVersion)})()}getOrCreateBackupConfiguration(){var e=this;return T(function*(){if(e.configuration)return e.configuration;if(e.hasConfigurationProblem)return null;if(e.currentBackupVersionCheck!=null)return e.logger.debug(`Already checking server version, use current promise`),yield e.currentBackupVersionCheck;e.currentBackupVersionCheck=e.internalCheckFromServer();try{return yield e.currentBackupVersionCheck}finally{e.currentBackupVersionCheck=null}})()}internalCheckFromServer(){var e=this;return T(function*(){var t,n=null;try{n=yield e.backupManager.getServerBackupInfo()}catch(t){return e.logger.debug(`Backup: error while checking server version: ${t}`),e.hasConfigurationProblem=!0,null}if(e.logger.debug(`Got current backup version from server: ${n?.version}`),n?.algorithm!=`m.megolm_backup.v1.curve25519-aes-sha2`)return e.logger.info(`Unsupported algorithm ${n?.algorithm}`),e.hasConfigurationProblem=!0,null;if(!((t=n)!=null&&t.version))return e.logger.info(`No current key backup`),e.hasConfigurationProblem=!0,null;var r=yield e.backupManager.getActiveBackupVersion();if(r==null||n.version!=r)return e.logger.info(`The current backup version on the server (${n.version}) is not trusted. Version we are currently backing up to: ${r}`),e.hasConfigurationProblem=!0,null;var i=yield e.getBackupDecryptionKey();if(!(i!=null&&i.decryptionKey))return e.logger.debug(`Not checking key backup for session (no decryption key)`),e.hasConfigurationProblem=!0,null;if(r!=i.backupVersion)return e.logger.debug(`Version for which we have a decryption key (${i.backupVersion}) doesn't match the version we are backing up to (${r})`),e.hasConfigurationProblem=!0,null;if(n.auth_data.public_key!=i.decryptionKey.megolmV1PublicKey.publicKeyBase64)return e.logger.debug(`Key backup on server does not match our decryption key`),e.hasConfigurationProblem=!0,null;var a=e.backupManager.createBackupDecryptor(i.decryptionKey);return e.hasConfigurationProblem=!1,e.configuration={decryptor:a,backupVersion:r},e.configuration})()}};function Kl(e,t){if(!e.private_key_salt||!e.private_key_iterations)throw Error(`Salt and/or iterations not found: this backup cannot be restored with a passphrase`);return l(t,e.private_key_salt,e.private_key_iterations,e.private_key_bits)}function ql(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Jl(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ql(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ql(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}var Yl=[Q.Sas,Q.ScanQrCode,Q.ShowQrCode,Q.Reciprocate],Xl=class extends ie{constructor(e,t,n,r,a,o,s){var c=arguments.length>7&&arguments[7]!==void 0?arguments[7]:!1;super(),this.logger=e,this.olmMachine=t,this.http=n,this.userId=r,this.secretStorage=o,this.cryptoCallbacks=s,this.enableEncryptedStateEvents=c,i(this,`RECOVERY_KEY_DERIVATION_ITERATIONS`,5e5),i(this,`_trustCrossSignedDevices`,!0),i(this,`deviceIsolationMode`,new de(!1)),i(this,`stopped`,!1),i(this,`roomEncryptors`,{}),i(this,`eventDecryptor`,void 0),i(this,`keyClaimManager`,void 0),i(this,`outgoingRequestProcessor`,void 0),i(this,`crossSigningIdentity`,void 0),i(this,`backupManager`,void 0),i(this,`outgoingRequestsManager`,void 0),i(this,`perSessionBackupDownloader`,void 0),i(this,`dehydratedDeviceManager`,void 0),i(this,`reemitter`,new we(this)),i(this,`globalBlacklistUnverifiedDevices`,!1),i(this,`_supportedVerificationMethods`,Yl),this.outgoingRequestProcessor=new vl(e,t,n),this.outgoingRequestsManager=new Vl(this.logger,t,this.outgoingRequestProcessor),this.keyClaimManager=new yl(t,this.outgoingRequestProcessor),this.backupManager=new Fl(e,t,n,this.outgoingRequestProcessor),this.perSessionBackupDownloader=new Gl(this.logger,this.olmMachine,this.http,this.backupManager),this.dehydratedDeviceManager=new hl(this.logger,t,n,this.outgoingRequestProcessor,o),this.eventDecryptor=new Zl(this.logger,t,this.perSessionBackupDownloader),this.reemitter.reEmit(this.backupManager,[b.KeyBackupStatus,b.KeyBackupSessionsRemaining,b.KeyBackupFailed,b.KeyBackupDecryptionKeyCached]),this.reemitter.reEmit(this.dehydratedDeviceManager,[b.DehydratedDeviceCreated,b.DehydratedDeviceUploaded,b.RehydrationStarted,b.RehydrationProgress,b.RehydrationCompleted,b.RehydrationError,b.DehydrationKeyCached,b.DehydratedDeviceRotationError]),this.crossSigningIdentity=new Cl(e,t,this.outgoingRequestProcessor,o),this.checkKeyBackupAndEnable()}getOlmMachineOrThrow(){if(this.stopped)throw new le;return this.olmMachine}set globalErrorOnUnknownDevices(e){}get globalErrorOnUnknownDevices(){return!1}stop(){this.stopped||(this.stopped=!0,this.keyClaimManager.stop(),this.backupManager.stop(),this.outgoingRequestsManager.stop(),this.perSessionBackupDownloader.stop(),this.dehydratedDeviceManager.stop(),this.olmMachine.close())}encryptEvent(e,t){var n=this;return T(function*(){var t=e.getRoomId(),r=n.roomEncryptors[t];if(!r)throw Error(`Cannot encrypt event in unconfigured room ${t}`);yield r.encryptEvent(e,n.globalBlacklistUnverifiedDevices,n.deviceIsolationMode)})()}decryptEvent(e){var t=this;return T(function*(){if(!e.getRoomId())throw Error(`to-device event was not decrypted in preprocessToDeviceMessages`);return yield t.eventDecryptor.attemptEventDecryption(e,t.deviceIsolationMode)})()}getBackupDecryptor(e,t){var n=this;return T(function*(){if(!(t instanceof Uint8Array))throw Error(`getBackupDecryptor: expects Uint8Array`);if(e.algorithm!=`m.megolm_backup.v1.curve25519-aes-sha2`)throw Error(`getBackupDecryptor: Unsupported algorithm ${e.algorithm}`);var r=D.fromBase64(ne(t));if(!zl(r,e))throw Error(`getBackupDecryptor: key backup on server does not match the decryption key`);return n.backupManager.createBackupDecryptor(r)})()}importBackedUpRoomKeys(e,t,n){var r=this;return T(function*(){return yield r.backupManager.importBackedUpRoomKeys(e,t,n)})()}maybeAcceptKeyBundle(e,t){var n=this;return T(function*(){var r=new d(n.logger,`maybeAcceptKeyBundle(${e}, ${t})`);r.info(`Checking inviter cross-signing keys`);var i=n.olmMachine.queryKeysForUsers([new L(t)]);yield n.outgoingRequestProcessor.makeOutgoingRequest(i);var a=yield n.olmMachine.getReceivedRoomKeyBundleData(new F(e),new L(t));if(!a)return r.info(`No key bundle found for user`),!1;r.info(`Fetching key bundle ${a.url}`);var o=_e(n.http.opts.baseUrl,a.url,void 0,void 0,void 0,!1,!0,!0),s;try{var c=new URL(o),l=yield n.http.authedRequest(v.Get,c.pathname+c.search,{},void 0,{rawResponseBody:!0,prefix:``});r.info(`Received blob of length ${l.size}`),s=new Uint8Array(yield l.arrayBuffer())}catch(e){throw r.warn(`Error downloading encrypted bundle from ${o}:`,e),e}try{yield n.olmMachine.receiveRoomKeyBundle(a,s)}catch(e){throw r.warn(`Error receiving encrypted bundle:`,e),e}finally{yield n.olmMachine.clearRoomPendingKeyBundle(new F(e))}return!0})()}markRoomAsPendingKeyBundle(e,t){var n=this;return T(function*(){yield n.olmMachine.storeRoomPendingKeyBundle(new F(e),new L(t))})()}getVersion(){var e=yn();return`Rust SDK ${e.matrix_sdk_crypto} (${e.git_sha}), Vodozemac ${e.vodozemac}`}setDeviceIsolationMode(e){this.deviceIsolationMode=e}isEncryptionEnabledInRoom(e){var t=this;return T(function*(){return!!(yield t.olmMachine.getRoomSettings(new F(e)))?.algorithm})()}isStateEncryptionEnabledInRoom(e){var t=this;return T(function*(){return!!(yield t.olmMachine.getRoomSettings(new F(e)))?.encryptStateEvents})()}getOwnDeviceKeys(){var e=this;return T(function*(){var t=e.olmMachine.identityKeys;return{ed25519:t.ed25519.toBase64(),curve25519:t.curve25519.toBase64()}})()}prepareToEncrypt(e){var t=this.roomEncryptors[e.roomId];t&&t.prepareForEncryption(this.globalBlacklistUnverifiedDevices,this.deviceIsolationMode)}forceDiscardSession(e){return this.roomEncryptors[e]?.forceDiscardSession()}exportRoomKeys(){var e=this;return T(function*(){var t=yield e.olmMachine.exportRoomKeys(()=>!0);return JSON.parse(t)})()}exportRoomKeysAsJson(){var e=this;return T(function*(){return yield e.olmMachine.exportRoomKeys(()=>!0)})()}importRoomKeys(e,t){var n=this;return T(function*(){return yield n.backupManager.importRoomKeys(e,t)})()}importRoomKeysAsJson(e,t){var n=this;return T(function*(){return yield n.backupManager.importRoomKeysAsJson(e,t)})()}userHasCrossSigningKeys(){var e=arguments,t=this;return T(function*(){var n=e.length>0&&e[0]!==void 0?e[0]:t.userId,r=e.length>1&&e[1]!==void 0?e[1]:!1,i=yield t.olmMachine.trackedUsers(),a;for(var o of i)if(n===o.toString()){a=o;break}if(a!==void 0){if(n===t.userId){var s=t.olmMachine.queryKeysForUsers([a.clone()]);yield t.outgoingRequestProcessor.makeOutgoingRequest(s)}var c=yield t.olmMachine.getIdentity(a);return c?.free(),c!==void 0}else if(r){var l=(yield t.downloadDeviceList(new Set([n]))).master_keys?.[n];return l?!!Object.values(l.keys)[0]:!1}else return!1})()}getUserDeviceInfo(e){var t=arguments,n=this;return T(function*(){var r=t.length>1&&t[1]!==void 0?t[1]:!1,i=new Map,a=yield n.getOlmMachineOrThrow().trackedUsers(),o=new Set;a.forEach(e=>o.add(e.toString()));var s=new Set;for(var c of e)o.has(c)?i.set(c,yield n.getUserDevices(c)):s.add(c);if(r&&s.size>=1){var l=yield n.downloadDeviceList(s);Object.entries(l.device_keys).forEach(e=>{var t=E(e,2),n=t[0],r=t[1];return i.set(n,xl(r))})}return i})()}getUserDevices(e){var t=this;return T(function*(){var n=new L(e),r=yield t.olmMachine.getUserDevices(n,1);try{var i=r.devices();try{return new Map(i.map(e=>[e.deviceId.toString(),bl(e,n)]))}finally{i.forEach(e=>e.free())}}finally{r.free()}})()}downloadDeviceList(e){var t=this;return T(function*(){var n={device_keys:{}};return e.forEach(e=>n.device_keys[e]=[]),yield t.http.authedRequest(v.Post,`/_matrix/client/v3/keys/query`,void 0,n,{prefix:``})})()}getTrustCrossSignedDevices(){return this._trustCrossSignedDevices}setTrustCrossSignedDevices(e){this._trustCrossSignedDevices=e}setDeviceVerified(e,t){var n=arguments,r=this;return T(function*(){var i=n.length>2&&n[2]!==void 0?n[2]:!0,a=yield r.olmMachine.getDevice(new L(e),new M(t));if(!a)throw Error(`Unknown device ${e}|${t}`);try{yield a.setLocalTrust(i?mt.Verified:mt.Unset)}finally{a.free()}})()}crossSignDevice(e){var t=this;return T(function*(){var n=yield t.olmMachine.getDevice(new L(t.userId),new M(e));if(!n)throw Error(`Unknown device ${e}`);try{var r=yield n.verify();yield t.outgoingRequestProcessor.makeOutgoingRequest(r)}finally{n.free()}})()}getDeviceVerificationStatus(e,t){var n=this;return T(function*(){var r=yield n.olmMachine.getDevice(new L(e),new M(t));if(!r)return null;try{return new se({signedByOwner:r.isCrossSignedByOwner(),crossSigningVerified:r.isCrossSigningTrusted(),localVerified:r.isLocallyTrusted(),trustCrossSignedDevices:n._trustCrossSignedDevices})}finally{r.free()}})()}getUserVerificationStatus(e){var t=this;return T(function*(){var n=yield t.getOlmMachineOrThrow().getIdentity(new L(e));if(n===void 0)return new xe(!1,!1,!1);var r=n.isVerified(),i=n.wasPreviouslyVerified(),a=n instanceof Ct?n.identityNeedsUserApproval():!1;return n.free(),new xe(r,i,!0,a)})()}pinCurrentUserIdentity(e){var t=this;return T(function*(){var n=yield t.getOlmMachineOrThrow().getIdentity(new L(e));if(n===void 0)throw Error(`Cannot pin identity of unknown user`);if(n instanceof Tt)throw Error(`Cannot pin identity of own user`);yield n.pinCurrentMasterKey()})()}withdrawVerificationRequirement(e){var t=this;return T(function*(){var n=yield t.getOlmMachineOrThrow().getIdentity(new L(e));if(n===void 0)throw Error(`Cannot withdraw verification of unknown user`);yield n.withdrawVerification()})()}isCrossSigningReady(){var e=this;return T(function*(){var t=yield e.getCrossSigningStatus(),n=t.privateKeysInSecretStorage,r=t.privateKeysCachedLocally,i=!!r.masterKey&&!!r.selfSigningKey&&!!r.userSigningKey,a=yield e.getOwnIdentity();return!!(a!=null&&a.isVerified())&&(i||n)})()}getCrossSigningKeyId(){var e=arguments,t=this;return T(function*(){var n=e.length>0&&e[0]!==void 0?e[0]:ue.Master,r=yield t.getOwnIdentity();if(!r)return null;try{var i=yield t.olmMachine.crossSigningStatus();if(!(i.hasMaster&&i.hasUserSigning&&i.hasSelfSigning)||!r.isVerified())return null;var a;switch(n){case ue.Master:a=r.masterKey;break;case ue.SelfSigning:a=r.selfSigningKey;break;case ue.UserSigning:a=r.userSigningKey;break;default:return null}var o=JSON.parse(a);return Object.values(o.keys)[0]}finally{r.free()}})()}bootstrapCrossSigning(e){var t=this;return T(function*(){yield t.crossSigningIdentity.bootstrapCrossSigning(e)})()}isSecretStorageReady(){var e=this;return T(function*(){return(yield e.getSecretStorageStatus()).ready})()}getSecretStorageStatus(){var e=this;return T(function*(){var t=[`m.cross_signing.master`,`m.cross_signing.user_signing`,`m.cross_signing.self_signing`];(yield e.backupManager.getActiveBackupVersion())!=null&&t.push(`m.megolm_backup.v1`);var n=yield e.secretStorage.getDefaultKeyId(),r={ready:!0,defaultKeyId:n,secretStorageKeyValidityMap:{}};for(var i of t){var a=(yield e.secretStorage.isStored(i))||{},o=!!n&&n in a;r.secretStorageKeyValidityMap[i]=o,r.ready=r.ready&&o}return r})()}bootstrapSecretStorage(){var e=arguments,t=this;return T(function*(){var n=e.length>0&&e[0]!==void 0?e[0]:{},r=n.createSecretStorageKey,i=n.setupNewSecretStorage,a=n.setupNewKeyBackup,o=i||!(yield t.secretStorageHasAESKey());if(o){if(!r)throw Error(`unable to create a new secret storage key, createSecretStorageKey is not set`);t.logger.info(`bootstrapSecretStorage: creating new secret storage key`);var s=yield r();if(!s)throw Error(`createSecretStorageKey() callback did not return a secret storage key`);yield t.addSecretStorageKeyToSecretStorage(s)}var c=yield t.olmMachine.exportCrossSigningKeys();c&&c.masterKey!==void 0&&c.self_signing_key!==void 0&&c.userSigningKey!==void 0&&(o||!(yield wl(t.secretStorage)))&&(t.logger.info(`bootstrapSecretStorage: cross-signing keys not yet exported; doing so now.`),yield t.secretStorage.store(`m.cross_signing.master`,c.masterKey),yield t.secretStorage.store(`m.cross_signing.user_signing`,c.userSigningKey),yield t.secretStorage.store(`m.cross_signing.self_signing`,c.self_signing_key)),a?yield t.resetKeyBackup():yield t.saveBackupKeyToStorage()})()}saveBackupKeyToStorage(){var e=this;return T(function*(){var t=yield e.backupManager.getServerBackupInfo();if(!t||!t.version){e.logger.info(`Not saving backup key to secret storage: no backup info`);return}var n=yield e.olmMachine.getBackupKeys();if(!n.decryptionKey){e.logger.info(`Not saving backup key to secret storage: no backup key`);return}if(!zl(n.decryptionKey,t)){e.logger.info(`Not saving backup key to secret storage: decryption key does not match backup info`);return}var r=n.decryptionKey.toBase64();yield e.secretStorage.store(`m.megolm_backup.v1`,r)})()}addSecretStorageKeyToSecretStorage(e){var t=this;return T(function*(){var n,r,i=yield t.secretStorage.addKey(ge,{passphrase:e.keyInfo?.passphrase,name:e.keyInfo?.name,key:e.privateKey});yield t.secretStorage.setDefaultKeyId(i.keyId),(n=(r=t.cryptoCallbacks).cacheSecretStorageKey)==null||n.call(r,i.keyId,i.keyInfo,e.privateKey)})()}secretStorageHasAESKey(){var e=this;return T(function*(){var t=yield e.secretStorage.getKey();return t?E(t,2)[1].algorithm===ge:!1})()}getCrossSigningStatus(){var e=this;return T(function*(){var t=yield e.getOwnIdentity(),n=!!t?.masterKey&&!!t?.selfSigningKey&&!!t?.userSigningKey;t?.free();var r=yield wl(e.secretStorage),i=yield e.getOlmMachineOrThrow().crossSigningStatus();return{publicKeysOnDevice:n,privateKeysInSecretStorage:r,privateKeysCachedLocally:{masterKey:!!i?.hasMaster,userSigningKey:!!i?.hasUserSigning,selfSigningKey:!!i?.hasSelfSigning}}})()}createRecoveryKeyFromPassphrase(e){var t=this;return T(function*(){if(e){var n=h(32),r=yield l(e,n,t.RECOVERY_KEY_DERIVATION_ITERATIONS);return{keyInfo:{passphrase:{algorithm:`m.pbkdf2`,iterations:t.RECOVERY_KEY_DERIVATION_ITERATIONS,salt:n}},privateKey:r,encodedPrivateKey:c(r)}}else{var i=new Uint8Array(32);return globalThis.crypto.getRandomValues(i),{privateKey:i,encodedPrivateKey:c(i)}}})()}getEncryptionInfoForEvent(e){var t=this;return T(function*(){return t.eventDecryptor.getEncryptionInfoForEvent(e)})()}getVerificationRequestsToDeviceInProgress(e){return this.olmMachine.getVerificationRequests(new L(e)).filter(e=>e.roomId===void 0&&!e.isCancelled()).map(e=>this.makeVerificationRequest(e))}findVerificationRequestDMInProgress(e,t){if(!t)throw Error(`missing userId`);var n=this.olmMachine.getVerificationRequests(new L(t)).find(t=>t.roomId?.toString()===e&&!t.isCancelled());if(n)return this.makeVerificationRequest(n)}requestVerificationDM(e,t){var n=this;return T(function*(){var r=yield n.olmMachine.getIdentity(new L(e));if(!r)throw Error(`unknown userId ${e}`);try{var i=n._supportedVerificationMethods.map(e=>Nl(e)),a=yield r.verificationRequestContent(i),o=JSON.parse(a);o.msgtype=`m.key.verification.request`;var s=JSON.stringify(o),c=yield n.sendVerificationRequestContent(t,s),l=yield r.requestVerification(new F(t),new it(c),i);return n.makeVerificationRequest(l)}finally{r.free()}})()}sendVerificationRequestContent(e,t){var n=this;return T(function*(){var r=h(32);return(yield n.http.authedRequest(v.Put,`/_matrix/client/v3/rooms/${encodeURIComponent(e)}/send/m.room.message/${encodeURIComponent(r)}`,void 0,t,{prefix:``})).event_id})()}setSupportedVerificationMethods(e){this._supportedVerificationMethods=e??Yl}requestOwnUserVerification(){var e=this;return T(function*(){var t=yield e.getOwnIdentity();if(t===void 0)throw Error(`cannot request verification for this device when there is no existing cross-signing key`);try{var n=E(yield t.requestVerification(e._supportedVerificationMethods.map(Nl)),2),r=n[0],i=n[1];return yield e.outgoingRequestProcessor.makeOutgoingRequest(i),e.makeVerificationRequest(r)}finally{t.free()}})()}requestDeviceVerification(e,t){var n=this;return T(function*(){var r=yield n.olmMachine.getDevice(new L(e),new M(t));if(!r)throw Error(`Not a known device`);try{var i=E(r.requestVerification(n._supportedVerificationMethods.map(Nl)),2),a=i[0],o=i[1];return yield n.outgoingRequestProcessor.makeOutgoingRequest(o),n.makeVerificationRequest(a)}finally{r.free()}})()}getSessionBackupPrivateKey(){var e=this;return T(function*(){var t=yield e.olmMachine.getBackupKeys();return t.decryptionKey?te(t.decryptionKey.toBase64()):null})()}storeSessionBackupPrivateKey(e,t){var n=this;return T(function*(){var r=ne(e);if(!t)throw Error(`storeSessionBackupPrivateKey: version is required`);yield n.backupManager.saveBackupDecryptionKey(D.fromBase64(r),t)})()}loadSessionBackupPrivateKeyFromSecretStorage(){var e=this;return T(function*(){var t=yield e.secretStorage.get(`m.megolm_backup.v1`);if(!t)throw Error(`loadSessionBackupPrivateKeyFromSecretStorage: missing decryption key in secret storage`);var n=yield e.backupManager.getServerBackupInfo();if(!n||!n.version)throw Error(`loadSessionBackupPrivateKeyFromSecretStorage: unable to get backup version`);var r=D.fromBase64(t);if(!zl(r,n))throw new be(`loadSessionBackupPrivateKeyFromSecretStorage: decryption key does not match backup info`);yield e.backupManager.saveBackupDecryptionKey(r,n.version)})()}getActiveSessionBackupVersion(){var e=this;return T(function*(){return yield e.backupManager.getActiveBackupVersion()})()}getKeyBackupInfo(){var e=this;return T(function*(){return(yield e.backupManager.getServerBackupInfo())||null})()}isKeyBackupTrusted(e){var t=this;return T(function*(){return yield t.backupManager.isKeyBackupTrusted(e)})()}checkKeyBackupAndEnable(){var e=this;return T(function*(){return yield e.backupManager.checkKeyBackupAndEnable(!0)})()}deleteKeyBackupVersion(e){var t=this;return T(function*(){yield t.backupManager.deleteKeyBackupVersion(e)})()}resetKeyBackup(){var e=this;return T(function*(){var t=yield e.backupManager.setupKeyBackup(t=>e.signObject(t));yield e.pushSecretToVerifiedDevices(`m.megolm_backup.v1`),(yield e.secretStorageHasAESKey())&&(yield e.secretStorage.store(`m.megolm_backup.v1`,t.decryptionKey.toBase64())),e.checkKeyBackupAndEnable()})()}disableKeyStorage(){var e=this;return T(function*(){var t=yield e.getKeyBackupInfo();t!=null&&t.version?yield e.deleteKeyBackupVersion(t.version):e.logger.error(`Can't delete key backup version: no version available`),yield e.deleteSecretStorage(),yield e.dehydratedDeviceManager.delete()})()}signObject(e){var t=this;return T(function*(){var n=new Map(Object.entries(e.signatures||{})),r=e.unsigned;delete e.signatures,delete e.unsigned;var i=n.get(t.userId)||{},a=ll.default.stringify(e),o=yield t.olmMachine.sign(a),s=JSON.parse(o.asJSON());n.set(t.userId,Jl(Jl({},i),s[t.userId])),r!==void 0&&(e.unsigned=r),e.signatures=Object.fromEntries(n.entries())})()}restoreKeyBackupWithPassphrase(e,t){var n=this;return T(function*(){var r=yield n.backupManager.getServerBackupInfo();if(!(r!=null&&r.version))throw Error(`No backup info available`);var i=yield Kl(r.auth_data,e);return yield n.storeSessionBackupPrivateKey(i,r.version),n.restoreKeyBackup(t)})()}restoreKeyBackup(e){var t=this;return T(function*(){var n=yield t.olmMachine.getBackupKeys(),r=n.decryptionKey,i=n.backupVersion;if(!r||!i)throw Error(`No decryption key found in crypto store`);var a=te(r.toBase64()),o=yield t.backupManager.requestKeyBackupVersion(i);if(!o)throw Error(`Backup version to restore ${i} not found on server`);var c=yield t.getBackupDecryptor(o,a);try{var l;return e==null||(l=e.progressCallback)==null||l.call(e,{stage:s.Fetch}),yield t.backupManager.restoreKeyBackup(i,c,e)}finally{c.free()}})()}isDehydrationSupported(){var e=this;return T(function*(){return yield e.dehydratedDeviceManager.isSupported()})()}startDehydration(){var e=arguments,t=this;return T(function*(){var n=e.length>0&&e[0]!==void 0?e[0]:{};if(!(yield t.isCrossSigningReady())||!(yield t.isSecretStorageReady()))throw Error(`Device dehydration requires cross-signing and secret storage to be set up`);return yield t.dehydratedDeviceManager.start(n||{})})()}importSecretsBundle(e){var t=this;return T(function*(){var n=Yt.from_json(e);yield t.getOlmMachineOrThrow().importSecretsBundle(n)})()}exportSecretsBundle(){var e=this;return T(function*(){var t=yield e.getOlmMachineOrThrow().exportSecretsBundle(),n=t.to_json();return t.free(),n})()}encryptToDeviceMessages(e,t,n){var r=this;return T(function*(){var i=new d(r.logger,`encryptToDeviceMessages`),a=new Set(t.map(e=>e.userId));yield r.keyClaimManager.ensureSessionsForUsers(i,Array.from(a).map(e=>new L(e)));var o={batch:[],eventType:x.RoomMessageEncrypted};return yield Promise.all(t.map(function(){var t=T(function*(t){var i=t.userId,a=t.deviceId,s=yield r.olmMachine.getDevice(new L(i),new M(a));if(s){var c=JSON.parse(yield s.encryptToDeviceEvent(e,n));o.batch.push({deviceId:a,userId:i,payload:c})}else r.logger.warn(`encryptToDeviceMessages: unknown device ${i}:${a}`)});return function(e){return t.apply(this,arguments)}}())),o})()}resetEncryption(e){var t=this;return T(function*(){t.logger.debug(`resetEncryption: resetting encryption`),t.dehydratedDeviceManager.delete(),yield t.backupManager.deleteAllKeyBackupVersions(),yield t.deleteSecretStorage(),yield t.crossSigningIdentity.bootstrapCrossSigning({setupNewCrossSigning:!0,authUploadDeviceSigningKeys:e}),yield t.resetKeyBackup(),t.logger.debug(`resetEncryption: ended`)})()}deleteSecretStorage(){var e=this;return T(function*(){yield e.secretStorage.store(`m.cross_signing.master`,null),yield e.secretStorage.store(`m.cross_signing.self_signing`,null),yield e.secretStorage.store(`m.cross_signing.user_signing`,null),yield e.secretStorage.store(`m.megolm_backup.v1`,null);var t=yield e.secretStorage.getDefaultKeyId();t&&(yield e.secretStorage.store(`m.secret_storage.key.${t}`,null)),yield e.secretStorage.setDefaultKeyId(null)})()}shareRoomHistoryWithUser(e,t){var n=this;return T(function*(){var r=new d(n.logger,`shareRoomHistoryWithUser(${e}, ${t})`),i=yield n.getOwnIdentity();if(!(i!=null&&i.isVerified())){r.warn(`Not sharing message history as the current device is not verified by our cross-signing identity`);return}r.info(`Sharing message history`),(yield n.getOlmMachineOrThrow().hasDownloadedAllRoomKeys(new F(e)))||(yield n.backupManager.downloadLatestRoomKeyBackup(e),yield n.getOlmMachineOrThrow().setHasDownloadedAllRoomKeys(new F(e)));var a=yield n.getOlmMachineOrThrow().buildRoomKeyBundle(new F(e));if(!a){r.info(`No keys to share`);return}var o=yield n.http.uploadContent(a.encryptedData);r.info(`Uploaded encrypted key blob: ${JSON.stringify(o)}`);var s=n.getOlmMachineOrThrow().queryKeysForUsers([new L(t)]);yield n.outgoingRequestProcessor.makeOutgoingRequest(s),yield n.keyClaimManager.ensureSessionsForUsers(r,[new L(t)]);for(var c of yield n.getOlmMachineOrThrow().shareRoomKeyBundleData(new L(t),new F(e),o.content_uri,a.mediaEncryptionInfo,O.identityBasedStrategy()))yield n.outgoingRequestProcessor.makeOutgoingRequest(c)})()}receiveSyncChanges(e){var t=this;return T(function*(){var n=e.events,r=e.oneTimeKeysCounts,i=r===void 0?new Map:r,a=e.unusedFallbackKeys,o=e.devices,s=o===void 0?new Je:o;return yield t.olmMachine.receiveSyncChanges(n?JSON.stringify(n):`[]`,s,i,a)})()}preprocessToDeviceMessages(e){var t=this;return T(function*(){var n=yield t.receiveSyncChanges({events:e}),r=[],i=function*(){var e=JSON.parse(a.rawEvent);if(e.type===x.KeyVerificationRequest){var n=e.sender,i=e.content.transaction_id;i&&n&&t.onIncomingKeyVerificationRequest(n,i)}switch(a.type){case jt.Decrypted:var o=a.encryptionInfo;if(r.push({message:e,encryptionInfo:{sender:o.sender.toString(),senderDevice:o.senderDevice?.toString(),senderCurve25519KeyBase64:o.senderCurve25519Key,senderVerified:o.isSenderVerified()}}),eu(e)){var s=e.content.room_id,c=yield t.olmMachine.getPendingKeyBundleDetailsForRoom(new F(s));c?Date.now()-c.inviteAcceptedAtMillis>864e5?t.logger.info(`Ignoring key bundle for room we joined too long ago: ${s}, joining time: ${new Date(c.inviteAcceptedAtMillis).toISOString()}`):(t.logger.info(`Considering key bundle for recently-joined room ${s}`),t.maybeAcceptKeyBundle(s,c.inviterId.toString()).catch(e=>{t.logger.error(`Error attempting to download key bundle for room ${s}`),t.logger.error(e)})):t.logger.debug(`Not yet accepting key bundle for room where we are not awaiting a bundle: ${s}`)}break;case jt.PlainText:r.push({message:e,encryptionInfo:null});break;case jt.UnableToDecrypt:break;case jt.Invalid:break}};for(var a of n)yield*i();return r})()}processKeyCounts(e,t){var n=this;return T(function*(){var r=e&&new Map(Object.entries(e)),i=t&&new Set(t);(r!==void 0||i!==void 0)&&(yield n.receiveSyncChanges({oneTimeKeysCounts:r,unusedFallbackKeys:i}))})()}processDeviceLists(e){var t=this;return T(function*(){var n=new Je(e.changed?.map(e=>new L(e)),e.left?.map(e=>new L(e)));yield t.receiveSyncChanges({devices:n})})()}onCryptoEvent(e,t){var n=this;return T(function*(){var r=t.getContent(),i=new qt;if(r.algorithm===`m.megolm.v1.aes-sha2`)i.algorithm=et.MegolmV1AesSha2;else{n.logger.warn(`Room ${e.roomId}: ignoring crypto event with invalid algorithm ${r.algorithm}`);return}r[`io.element.msc4362.encrypt_state_events`]&&n.enableEncryptedStateEvents&&(n.logger.info(`crypto Enabling state event encryption...`),i.encryptStateEvents=!0);try{i.sessionRotationPeriodMs=r.rotation_period_ms,i.sessionRotationPeriodMessages=r.rotation_period_msgs,yield n.olmMachine.setRoomSettings(new F(e.roomId),i)}catch(t){n.logger.warn(`Room ${e.roomId}: ignoring crypto event which caused error: ${t}`);return}var a=n.roomEncryptors[e.roomId];a?a.onCryptoEvent(r):n.roomEncryptors[e.roomId]=new ul(n.logger.getChild(`[${e.roomId} encryption]`),n.olmMachine,n.keyClaimManager,n.outgoingRequestsManager,e,r)})()}onSyncCompleted(e){this.outgoingRequestsManager.doProcessOutgoingRequests().catch(e=>{this.logger.warn(`onSyncCompleted: Error processing outgoing requests`,e)})}markAllTrackedUsersAsDirty(){var e=this;return T(function*(){yield e.olmMachine.markAllTrackedUsersAsDirty()})()}onIncomingKeyVerificationRequest(e,t){var n=this.olmMachine.getVerificationRequest(new L(e),t);n?this.emit(b.VerificationRequestReceived,this.makeVerificationRequest(n)):this.logger.info(`Ignoring just-received verification request ${t} which did not start a rust-side verification`)}makeVerificationRequest(e){return new Ol(this.logger,this.olmMachine,e,this.outgoingRequestProcessor,this._supportedVerificationMethods)}onRoomMembership(e,t,n){var r=e.getRoomId();n===o.Join&&t.membership!==o.Join&&t.userId===this.olmMachine.userId.toString()&&this.olmMachine.clearRoomPendingKeyBundle(new F(r)).catch(e=>{this.logger.error(`Error clearing room pending key bundle indicator for ${r}: ${e}`)});var i=this.roomEncryptors[r];i&&i.onRoomMembership(t)}onRoomStateEvent(e,t,n){e.getType()==x.RoomMember&&e.getStateKey()!==this.olmMachine.userId.toString()&&e.getContent().membership!==o.Join&&(this.logger.info(`Rotating session for room ${e.getRoomId()} due to member leaving the room`),this.forceDiscardSession(e.getRoomId()))}onRoomKeysUpdated(e){var t=this;return T(function*(){for(var n of e)t.onRoomKeyUpdated(n);t.backupManager.maybeUploadKey()})()}onRoomKeyUpdated(e){var t=this;if(!this.stopped){this.logger.debug(`Got update for session ${e.sessionId} from sender ${e.senderKey.toBase64()} in ${e.roomId.toString()}`);var n=this.eventDecryptor.getEventsPendingRoomKey(e.roomId.toString(),e.sessionId);if(n.length!==0){this.logger.debug(`Retrying decryption on events:`,n.map(e=>`${e.getId()}`));var r=function(e){e.attemptDecryption(t,{isRetry:!0}).catch(n=>{t.logger.info(`Still unable to decrypt event ${e.getId()} after receiving key`)})};for(var i of n)r(i)}}}onRoomKeysWithheld(e){var t=this;return T(function*(){for(var n of e){t.logger.debug(`Got withheld message for session ${n.sessionId} in ${n.roomId.toString()}`);var r=t.eventDecryptor.getEventsPendingRoomKey(n.roomId.toString(),n.sessionId);if(r.length===0)return;t.logger.debug(`Retrying decryption on events:`,r.map(e=>`${e.getId()}`));for(var i of r)i.attemptDecryption(t,{isRetry:!0}).catch(e=>{})}})()}onUserIdentityUpdated(e){var t=this;return T(function*(){var n=yield t.getUserVerificationStatus(e.toString());t.emit(b.UserTrustStatusChanged,e.toString(),n),e.toString()===t.userId&&(t.emit(b.KeysChanged,{}),yield t.checkKeyBackupAndEnable())})()}onDevicesUpdated(e){var t=this;return T(function*(){t.emit(b.WillUpdateDevices,e,!1),t.emit(b.DevicesUpdated,e,!1)})()}handleSecretReceived(e,t){var n=this;return T(function*(){return n.logger.debug(`onReceiveSecret: Received secret ${e}`),e===`m.megolm_backup.v1`?yield n.backupManager.handleBackupSecretReceived(t):!1})()}checkSecrets(e){var t=this;return T(function*(){for(var n of yield t.olmMachine.getSecretsFromInbox(e))if(yield t.handleSecretReceived(e,n))break;yield t.olmMachine.deleteSecretsFromInbox(e)})()}onLiveEventFromSync(e){var t=this;return T(function*(){if(!(e.isState()||e.getUnsigned().transaction_id)){var n=function(){var n=T(function*(n){Pl(e)&&(yield t.onKeyVerificationEvent(n))});return function(e){return n.apply(this,arguments)}}();if(e.isDecryptionFailure()||e.isEncrypted()){var r=setTimeout(()=>e.off(ye.Decrypted,i),300*1e3),i=(t,a)=>{a||(clearTimeout(r),e.off(ye.Decrypted,i),n(t))};e.on(ye.Decrypted,i)}else yield n(e)}})()}onKeyVerificationEvent(e){var t=this;return T(function*(){var n=e.getRoomId(),r=e.getSender();if(!n)throw Error(`missing roomId in the event`);if(!r)throw Error(`missing sender in the event`);t.logger.debug(`Incoming verification event ${e.getId()} type ${e.getType()} from ${e.getSender()}`);var i=e.getType()===x.RoomMessage&&e.getContent().msgtype===f.KeyVerificationRequest;if(i){var a=t.getOlmMachineOrThrow().queryKeysForUsers([new L(r)]);yield t.outgoingRequestProcessor.makeOutgoingRequest(a)}yield t.getOlmMachineOrThrow().receiveVerificationEvent(JSON.stringify({event_id:e.getId(),type:e.getType(),sender:r,state_key:e.getStateKey(),content:e.getContent(),origin_server_ts:e.getTs()}),new F(n)),i&&t.onIncomingKeyVerificationRequest(r,e.getId()),t.outgoingRequestsManager.doProcessOutgoingRequests().catch(e=>{t.logger.warn(`onKeyVerificationRequest: Error processing outgoing requests`,e)})})()}getOwnIdentity(){var e=this;return T(function*(){return yield e.getOlmMachineOrThrow().getIdentity(new L(e.userId))})()}pushSecretToVerifiedDevices(e){var t=this;return T(function*(){var n=new d(t.logger,`pushSecretToVerifiedDevices`);yield t.keyClaimManager.ensureSessionsForUsers(n,[new L(t.userId)]),yield t.olmMachine.pushSecretToVerifiedDevices(e),t.outgoingRequestsManager.doProcessOutgoingRequests().catch(e=>{n.warn(`pushSecretToVerifiedDevices: Error processing outgoing requests`,e)})})()}},Zl=class{constructor(e,t,n){this.logger=e,this.olmMachine=t,this.perSessionBackupDownloader=n,i(this,`eventsPendingKey`,new oe(()=>new oe(()=>new Set)))}attemptEventDecryption(e,t){var n=this;return T(function*(){n.addEventToPendingList(e);var r;switch(t.kind){case Ce.AllDevicesIsolationMode:r=fn.Untrusted;break;case Ce.OnlySignedDevicesIsolationMode:r=fn.CrossSignedOrLegacy;break}try{var i=yield n.olmMachine.decryptRoomEvent(Ql(e),new F(e.getRoomId()),new ze(r));return n.removeEventFromPendingList(e),{clearEvent:JSON.parse(i.event),claimedEd25519Key:i.senderClaimedEd25519Key,senderCurve25519Key:i.senderCurve25519Key,keyForwardedBy:i.forwarder?.toString()}}catch(t){if(t instanceof _t)n.onMegolmDecryptionError(e,t,yield n.perSessionBackupDownloader.getServerBackupInfo());else throw new w(C.UNKNOWN_ERROR,`Unknown error`)}})()}onMegolmDecryptionError(e,t,n){var r=e.getWireContent(),i={sender_key:r.sender_key,session_id:r.session_id};if(t.code===A.MissingRoomKey||t.code===A.UnknownMessageIndex){this.perSessionBackupDownloader.onDecryptionKeyMissingError(e.getRoomId(),r.session_id);var a=e.getMembershipAtEvent();if(a&&a!==o.Join&&a!==o.Invite)throw new w(C.HISTORICAL_MESSAGE_USER_NOT_JOINED,`This message was sent when we were not a member of the room.`,i);if(e.getTs()<=this.olmMachine.deviceCreationTimeMs)throw n===null?new w(C.HISTORICAL_MESSAGE_NO_KEY_BACKUP,`This message was sent before this device logged in, and there is no key backup on the server.`,i):this.perSessionBackupDownloader.isKeyBackupDownloadConfigured()?new w(C.HISTORICAL_MESSAGE_WORKING_BACKUP,`This message was sent before this device logged in. Key backup is working, but we still do not (yet) have the key.`,i):new w(C.HISTORICAL_MESSAGE_BACKUP_UNCONFIGURED,`This message was sent before this device logged in, and key backup is not working.`,i)}if(t.maybe_withheld)throw new w(t.maybe_withheld===`The sender has disabled encrypting to unverified devices.`?C.MEGOLM_KEY_WITHHELD_FOR_UNVERIFIED_DEVICE:C.MEGOLM_KEY_WITHHELD,t.maybe_withheld,i);switch(t.code){case A.MissingRoomKey:throw new w(C.MEGOLM_UNKNOWN_INBOUND_SESSION_ID,`The sender's device has not sent us the keys for this message.`,i);case A.UnknownMessageIndex:throw new w(C.OLM_UNKNOWN_MESSAGE_INDEX,`The sender's device has not sent us the keys for this message at this index.`,i);case A.SenderIdentityVerificationViolation:throw this.removeEventFromPendingList(e),new w(C.SENDER_IDENTITY_PREVIOUSLY_VERIFIED,`The sender identity is unverified, but was previously verified.`);case A.UnknownSenderDevice:throw this.removeEventFromPendingList(e),new w(C.UNKNOWN_SENDER_DEVICE,`The sender device is not known.`);case A.UnsignedSenderDevice:throw this.removeEventFromPendingList(e),new w(C.UNSIGNED_SENDER_DEVICE,`The sender identity is not cross-signed.`);default:throw new w(C.UNKNOWN_ERROR,t.description,i)}}getEncryptionInfoForEvent(e){var t=this;return T(function*(){if(!e.getClearContent()||e.isDecryptionFailure())return null;if(e.status!==null)return{shieldColour:Se.NONE,shieldReason:null};var n=yield t.olmMachine.getRoomEventEncryptionInfo(Ql(e),new F(e.getRoomId()));return $l(t.logger,n)})()}getEventsPendingRoomKey(e,t){var n=this.eventsPendingKey.get(e);if(!n)return[];var r=n.get(t);return r?[...r]:[]}addEventToPendingList(e){var t=e.getRoomId();t&&this.eventsPendingKey.getOrCreate(t).getOrCreate(e.getWireContent().session_id).add(e)}removeEventFromPendingList(e){var t=e.getRoomId();if(t){var n=this.eventsPendingKey.getOrCreate(t);if(n){var r=n.get(e.getWireContent().session_id);r&&(r.delete(e),r.size===0&&(n.delete(e.getWireContent().session_id),n.size===0&&this.eventsPendingKey.delete(t)))}}}};function Ql(e){return JSON.stringify({event_id:e.getId(),type:e.getWireType(),sender:e.getSender(),state_key:e.getStateKey(),content:e.getWireContent(),origin_server_ts:e.getTs()})}function $l(e,t){if(t===void 0)return null;var n=t.shieldState(!1),r;switch(n.color){case Zt.Grey:r=Se.GREY;break;case Zt.None:r=Se.NONE;break;default:r=Se.RED}var i;switch(n.code){case void 0:case null:i=null;break;case $t.AuthenticityNotGuaranteed:i=y.AUTHENTICITY_NOT_GUARANTEED;break;case $t.UnknownDevice:i=y.UNKNOWN_DEVICE;break;case $t.UnsignedDevice:i=y.UNSIGNED_DEVICE;break;case $t.UnverifiedIdentity:i=y.UNVERIFIED_IDENTITY;break;case $t.VerificationViolation:i=y.VERIFICATION_VIOLATION;break;case $t.MismatchedSender:i=y.MISMATCHED_SENDER;break;default:i=y.UNKNOWN;break}return{shieldColour:r,shieldReason:i}}function eu(e){return(e.type===`io.element.msc4268.room_key_bundle`||e.type===`m.room_key_bundle`)&&typeof e.content.room_id==`string`}function tu(e){return nu.apply(this,arguments)}function nu(){return nu=T(function*(e){var t,n=e.logger,r=e.legacyStore;if(yield cl(),!(yield r.containsData()))return;yield r.startup();var i=null;if(yield r.doTxn(`readonly`,[ve.STORE_ACCOUNT],e=>{r.getAccount(e,e=>{i=e})}),!i){n.debug(`Legacy crypto store is not set up (no account found). Not migrating.`);return}var a=yield r.getMigrationState();if(a>=m.MEGOLM_SESSIONS_MIGRATED)return;var o=yield au(n,r),s=yield su(n,r),c=1+o+s;n.info(`Migrating data from legacy crypto store. ${o} olm sessions and ${s} megolm sessions to migrate.`);var l=0;function u(t){var n;l+=t,(n=e.legacyMigrationProgressListener)==null||n.call(e,l,c)}u(0);var d=new TextEncoder().encode(e.legacyPickleKey).slice();a===m.NOT_STARTED&&(n.info(`Migrating data from legacy crypto store. Step 1: base data`),yield ru(e.http,e.userId,e.deviceId,r,d,e.storeHandle,n),a=m.INITIAL_DATA_MIGRATED,yield r.setMigrationState(a)),u(1),a===m.INITIAL_DATA_MIGRATED&&(n.info(`Migrating data from legacy crypto store. Step 2: olm sessions (${o} sessions to migrate).`),yield lu(n,r,d,e.storeHandle,u),a=m.OLM_SESSIONS_MIGRATED,yield r.setMigrationState(a)),a===m.OLM_SESSIONS_MIGRATED&&(n.info(`Migrating data from legacy crypto store. Step 3: megolm sessions (${s} sessions to migrate).`),yield du(n,r,d,e.storeHandle,u),a=m.MEGOLM_SESSIONS_MIGRATED,yield r.setMigrationState(a)),(t=e.legacyMigrationProgressListener)==null||t.call(e,-1,-1),n.info(`Migration from legacy crypto store complete`)}),nu.apply(this,arguments)}function ru(e,t,n,r,i,a,o){return iu.apply(this,arguments)}function iu(){return iu=T(function*(e,t,n,r,i,a,o){var s=new Ae;s.userId=new L(t),s.deviceId=new M(n),yield r.doTxn(`readonly`,[ve.STORE_ACCOUNT],e=>r.getAccount(e,e=>{s.pickledAccount=e??``}));var c=yield hu(r,i,`m.megolm_backup.v1`);if(c){for(var l=!1,u=null;!l;)try{u=yield Ll(e),l=!0}catch(e){o.info(`Failed to get backup version during migration, retrying in 2 seconds`,e),yield _(2e3)}if(u&&u.algorithm==`m.megolm_backup.v1.curve25519-aes-sha2`)try{var d=D.fromBase64(c),f=u.auth_data?.public_key;d.megolmV1PublicKey.publicKeyBase64==f?(s.backupVersion=u.version,s.backupRecoveryKey=c):o.debug(`The backup key to migrate does not match the active backup version`,`Cached pub key: ${d.megolmV1PublicKey.publicKeyBase64}`,`Active pub key: ${f}`)}catch(e){o.warn(`Failed to check if the backup key to migrate matches the active backup version`,e)}}s.privateCrossSigningMasterKey=yield hu(r,i,`master`),s.privateCrossSigningSelfSigningKey=yield hu(r,i,`self_signing`),s.privateCrossSigningUserSigningKey=yield hu(r,i,`user_signing`),yield yt.migrateBaseData(s,i,a,o)}),iu.apply(this,arguments)}function au(e,t){return ou.apply(this,arguments)}function ou(){return ou=T(function*(e,t){e.debug(`Counting olm sessions to be migrated`);var n;return yield t.doTxn(`readonly`,[ve.STORE_SESSIONS],e=>t.countEndToEndSessions(e,e=>n=e)),n}),ou.apply(this,arguments)}function su(e,t){return cu.apply(this,arguments)}function cu(){return cu=T(function*(e,t){return e.debug(`Counting megolm sessions to be migrated`),yield t.countEndToEndInboundGroupSessions()}),cu.apply(this,arguments)}function lu(e,t,n,r,i){return uu.apply(this,arguments)}function uu(){return uu=T(function*(e,t,n,r,i){for(;;){var a=yield t.getEndToEndSessionsBatch();if(a===null)return;e.debug(`Migrating batch of ${a.length} olm sessions`);var o=[];for(var s of a){var c=new Dt;c.senderKey=s.deviceKey,c.pickle=s.session,c.lastUseTime=c.creationTime=new Date(s.lastReceivedMessageTs),o.push(c)}yield yt.migrateOlmSessions(o,n,r,e),yield t.deleteEndToEndSessionsBatch(a),i(a.length)}}),uu.apply(this,arguments)}function du(e,t,n,r,i){return fu.apply(this,arguments)}function fu(){return fu=T(function*(e,t,n,r,i){for(;;){var a=yield t.getEndToEndInboundGroupSessionsBatch();if(a===null)return;e.debug(`Migrating batch of ${a.length} megolm sessions`);var o=[];for(var s of a){var c=s.sessionData,l=new Et;l.pickle=c.session,l.roomId=new F(c.room_id),l.senderKey=s.senderKey,l.senderSigningKey=c.keysClaimed?.ed25519,l.backedUp=!s.needsBackup,l.imported=c.untrusted===!0,o.push(l)}yield yt.migrateMegolmSessions(o,n,r,e),yield t.deleteEndToEndInboundGroupSessionsBatch(a),i(a.length)}}),fu.apply(this,arguments)}function pu(e){return mu.apply(this,arguments)}function mu(){return mu=T(function*(e){var t=e.logger,n=e.legacyStore,r=e.olmMachine;if((yield n.containsData())&&!((yield n.getMigrationState())>=m.ROOM_SETTINGS_MIGRATED)){var i={};yield n.doTxn(`readwrite`,[ve.STORE_ROOMS],e=>{n.getEndToEndRooms(e,e=>{i=e})}),t.debug(`Migrating ${Object.keys(i).length} sets of room settings`);for(var a of Object.entries(i)){var o=E(a,2),s=o[0],c=o[1];try{var l=new qt;if(c.algorithm!==`m.megolm.v1.aes-sha2`){t.warn(`Room ${s}: ignoring room with invalid algorithm ${c.algorithm}`);continue}l.algorithm=et.MegolmV1AesSha2,l.sessionRotationPeriodMs=c.rotation_period_ms,l.sessionRotationPeriodMessages=c.rotation_period_msgs,yield r.setRoomSettings(new F(s),l)}catch(e){t.warn(`Room ${s}: ignoring settings ${JSON.stringify(c)} which caused error ${e}`)}}t.debug(`Completed room settings migration`),yield n.setMigrationState(m.ROOM_SETTINGS_MIGRATED)}}),mu.apply(this,arguments)}function hu(e,t,n){return gu.apply(this,arguments)}function gu(){return gu=T(function*(e,t,n){var r=yield new Promise(t=>{e.doTxn(`readonly`,[ve.STORE_ACCOUNT],r=>{e.getSecretStorePrivateKey(r,t,n)})});if(r&&r.ciphertext&&r.iv&&r.mac)return yield he(r,t,n);if(r instanceof Uint8Array)return ne(r)}),gu.apply(this,arguments)}function _u(e){return vu.apply(this,arguments)}function vu(){return vu=T(function*(e){var t=e.legacyCryptoStore,n=e.rustCrypto,r=e.logger,i=yield n.getOwnIdentity();if(i&&!i.isVerified()){var a=yield yu(t);if(a){var o=JSON.parse(i.masterKey);if(!o.keys||Object.keys(o.keys).length===0){r.error(`Post Migration | Unexpected error: no master key in the rust session.`);return}var s=Object.values(o.keys)[0];s&&s==a&&(r.info(`Post Migration: Migrating legacy trusted MSK: ${a} to locally verified.`),yield i.verify())}}}),vu.apply(this,arguments)}function yu(e){return bu.apply(this,arguments)}function bu(){return bu=T(function*(e){var t=null;return yield e.doTxn(`readonly`,`account`,n=>{e.getCrossSigningKeys(n,e=>{var n=e?.master;n&&Object.keys(n.keys).length!=0&&(t=Object.values(n.keys)[0])})}),t}),bu.apply(this,arguments)}function xu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Su(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xu(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xu(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Cu(e){return wu.apply(this,arguments)}function wu(){return wu=T(function*(e){var t=e.logger;t.debug(`Initialising Rust crypto-sdk WASM artifact`),yield cl(),t.debug(`Opening Rust CryptoStore`);var n=e.storePrefix?e.storeKey?yield I.openWithKey(e.storePrefix,e.storeKey,t):yield I.open(e.storePrefix,e.storePassphrase,t):yield I.open(null,null,t);e.legacyCryptoStore&&(yield tu(Su({legacyStore:e.legacyCryptoStore,storeHandle:n},e)));var r=yield Tu(t,e.http,e.userId,e.deviceId,e.secretStorage,e.cryptoCallbacks,n,e.legacyCryptoStore,e.enableEncryptedStateEvents);return n.free(),t.debug(`Completed rust crypto-sdk setup`),r}),wu.apply(this,arguments)}function Tu(e,t,n,r,i,a,o,s,c){return Eu.apply(this,arguments)}function Eu(){return Eu=T(function*(e,t,n,r,i,a,o,s,c){e.debug(`Init OlmMachine`);var l=yield St.initFromStore(new L(n),new M(r),o,e);s&&(yield pu({logger:e,legacyStore:s,olmMachine:l})),l.roomKeyRequestsEnabled=!1;var u=new Xl(e,l,t,n,r,i,a,c);if(yield l.registerRoomKeyUpdatedCallback(e=>u.onRoomKeysUpdated(e)),yield l.registerRoomKeysWithheldCallback(e=>u.onRoomKeysWithheld(e)),yield l.registerUserIdentityUpdatedCallback(e=>u.onUserIdentityUpdated(e)),yield l.registerDevicesUpdatedCallback(e=>u.onDevicesUpdated(e)),u.checkSecrets(`m.megolm_backup.v1`),yield l.registerReceiveSecretCallback((e,t)=>u.checkSecrets(e)),yield l.outgoingRequests(),s&&(yield s.containsData())&&(yield s.getMigrationState())<m.INITIAL_OWN_KEY_QUERY_DONE){e.debug(`Performing initial key query after migration`);for(var d=!1;!d;)try{yield u.userHasCrossSigningKeys(n),d=!0}catch(t){e.error(`Failed to check for cross-signing keys after migration, retrying`,t)}yield _u({legacyCryptoStore:s,rustCrypto:u,logger:e}),yield s.setMigrationState(m.INITIAL_OWN_KEY_QUERY_DONE)}for(var f of yield l.getAllRoomsPendingKeyBundles()){var p=f.roomId.toString();Date.now()-f.inviteAcceptedAtMillis<=864e5?(e.info(`Checking for pending key bundle for recently-joined room ${p} (joined ${new Date(f.inviteAcceptedAtMillis).toISOString()})`),yield u.maybeAcceptKeyBundle(p,f.inviterId.toString())):(e.info(`Clearing pending-key-bundle flag for room ${p} (too old: joined ${new Date(f.inviteAcceptedAtMillis).toISOString()})`),yield l.clearRoomPendingKeyBundle(new F(p)))}return u}),Eu.apply(this,arguments)}export{Cu as initRustCrypto};
      3 //# sourceMappingURL=rust-crypto-Bko3GkMP.js.map