import { Mutex } from './snippets/account-wasm-35da9c7350cbc3ae/src/wasm-mutex.js';

let wasm;
export function __wbg_set_wasm(val) {
    wasm = val;
}


let cachedUint8ArrayMemory0 = null;

function getUint8ArrayMemory0() {
    if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
        cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
    }
    return cachedUint8ArrayMemory0;
}

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });

cachedTextDecoder.decode();

const MAX_SAFARI_DECODE_BYTES = 2146435072;
let numBytesDecoded = 0;
function decodeText(ptr, len) {
    numBytesDecoded += len;
    if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
        cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
        cachedTextDecoder.decode();
        numBytesDecoded = len;
    }
    return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}

function getStringFromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    return decodeText(ptr, len);
}

let heap = new Array(128).fill(undefined);

heap.push(undefined, null, true, false);

let heap_next = heap.length;

function addHeapObject(obj) {
    if (heap_next === heap.length) heap.push(heap.length + 1);
    const idx = heap_next;
    heap_next = heap[idx];

    heap[idx] = obj;
    return idx;
}

function getObject(idx) { return heap[idx]; }

let WASM_VECTOR_LEN = 0;

const cachedTextEncoder = new TextEncoder();

if (!('encodeInto' in cachedTextEncoder)) {
    cachedTextEncoder.encodeInto = function (arg, view) {
        const buf = cachedTextEncoder.encode(arg);
        view.set(buf);
        return {
            read: arg.length,
            written: buf.length
        };
    }
}

function passStringToWasm0(arg, malloc, realloc) {

    if (realloc === undefined) {
        const buf = cachedTextEncoder.encode(arg);
        const ptr = malloc(buf.length, 1) >>> 0;
        getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
        WASM_VECTOR_LEN = buf.length;
        return ptr;
    }

    let len = arg.length;
    let ptr = malloc(len, 1) >>> 0;

    const mem = getUint8ArrayMemory0();

    let offset = 0;

    for (; offset < len; offset++) {
        const code = arg.charCodeAt(offset);
        if (code > 0x7F) break;
        mem[ptr + offset] = code;
    }

    if (offset !== len) {
        if (offset !== 0) {
            arg = arg.slice(offset);
        }
        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
        const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
        const ret = cachedTextEncoder.encodeInto(arg, view);

        offset += ret.written;
        ptr = realloc(ptr, len, offset, 1) >>> 0;
    }

    WASM_VECTOR_LEN = offset;
    return ptr;
}

let cachedDataViewMemory0 = null;

function getDataViewMemory0() {
    if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
        cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
    }
    return cachedDataViewMemory0;
}

function handleError(f, args) {
    try {
        return f.apply(this, args);
    } catch (e) {
        wasm.__wbindgen_export_2(addHeapObject(e));
    }
}

function dropObject(idx) {
    if (idx < 132) return;
    heap[idx] = heap_next;
    heap_next = idx;
}

function takeObject(idx) {
    const ret = getObject(idx);
    dropObject(idx);
    return ret;
}

function isLikeNone(x) {
    return x === undefined || x === null;
}

function getArrayU8FromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}

function debugString(val) {
    // primitive types
    const type = typeof val;
    if (type == 'number' || type == 'boolean' || val == null) {
        return  `${val}`;
    }
    if (type == 'string') {
        return `"${val}"`;
    }
    if (type == 'symbol') {
        const description = val.description;
        if (description == null) {
            return 'Symbol';
        } else {
            return `Symbol(${description})`;
        }
    }
    if (type == 'function') {
        const name = val.name;
        if (typeof name == 'string' && name.length > 0) {
            return `Function(${name})`;
        } else {
            return 'Function';
        }
    }
    // objects
    if (Array.isArray(val)) {
        const length = val.length;
        let debug = '[';
        if (length > 0) {
            debug += debugString(val[0]);
        }
        for(let i = 1; i < length; i++) {
            debug += ', ' + debugString(val[i]);
        }
        debug += ']';
        return debug;
    }
    // Test for built-in
    const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
    let className;
    if (builtInMatches && builtInMatches.length > 1) {
        className = builtInMatches[1];
    } else {
        // Failed to match the standard '[object ClassName]'
        return toString.call(val);
    }
    if (className == 'Object') {
        // we're a user defined class or Object
        // JSON.stringify avoids problems with cycles, and is generally much
        // easier than looping through ownProperties of `val`.
        try {
            return 'Object(' + JSON.stringify(val) + ')';
        } catch (_) {
            return 'Object';
        }
    }
    // errors
    if (val instanceof Error) {
        return `${val.name}: ${val.message}\n${val.stack}`;
    }
    // TODO we could test for more things here, like `Set`s and `Map`s.
    return className;
}

const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(
state => {
    wasm.__wbindgen_export_4.get(state.dtor)(state.a, state.b);
}
);

function makeClosure(arg0, arg1, dtor, f) {
    const state = { a: arg0, b: arg1, cnt: 1, dtor };
    const real = (...args) => {

        // First up with a closure we increment the internal reference
        // count. This ensures that the Rust closure environment won't
        // be deallocated while we're invoking it.
        state.cnt++;
        try {
            return f(state.a, state.b, ...args);
        } finally {
            if (--state.cnt === 0) {
                wasm.__wbindgen_export_4.get(state.dtor)(state.a, state.b); state.a = 0;
                CLOSURE_DTORS.unregister(state);
            }
        }
    };
    real.original = state;
    CLOSURE_DTORS.register(real, state, state);
    return real;
}

function makeMutClosure(arg0, arg1, dtor, f) {
    const state = { a: arg0, b: arg1, cnt: 1, dtor };
    const real = (...args) => {

        // First up with a closure we increment the internal reference
        // count. This ensures that the Rust closure environment won't
        // be deallocated while we're invoking it.
        state.cnt++;
        const a = state.a;
        state.a = 0;
        try {
            return f(a, state.b, ...args);
        } finally {
            if (--state.cnt === 0) {
                wasm.__wbindgen_export_4.get(state.dtor)(a, state.b);
                CLOSURE_DTORS.unregister(state);
            } else {
                state.a = a;
            }
        }
    };
    real.original = state;
    CLOSURE_DTORS.register(real, state, state);
    return real;
}

function passArrayJsValueToWasm0(array, malloc) {
    const ptr = malloc(array.length * 4, 4) >>> 0;
    const mem = getDataViewMemory0();
    for (let i = 0; i < array.length; i++) {
        mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
    }
    WASM_VECTOR_LEN = array.length;
    return ptr;
}
/**
 * Computes the Starknet contract address for a controller account without needing a full instance.
 *
 * # Arguments
 *
 * * `class_hash` - The class hash of the account contract (JsFelt).
 * * `owner` - The owner configuration for the account.
 * * `salt` - The salt used for address calculation (JsFelt).
 *
 * # Returns
 *
 * The computed Starknet contract address as a `JsFelt`.
 * @param {JsFelt} class_hash
 * @param {Owner} owner
 * @param {JsFelt} salt
 * @returns {JsFelt}
 */
export function computeAccountAddress(class_hash, owner, salt) {
    try {
        const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
        wasm.computeAccountAddress(retptr, addHeapObject(class_hash), addHeapObject(owner), addHeapObject(salt));
        var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
        var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
        var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
        if (r2) {
            throw takeObject(r1);
        }
        return takeObject(r0);
    } finally {
        wasm.__wbindgen_add_to_stack_pointer(16);
    }
}

/**
 * Subscribes to the creation of a session for a given controller, session_key_guid and cartridge api url.
 * The goal of this function is to know from any place when the register session flow has been completed, and to
 * get the authorization.
 * @param {JsFelt} session_key_guid
 * @param {string} cartridge_api_url
 * @returns {Promise<JsSubscribeSessionResult>}
 */
export function subscribeCreateSession(session_key_guid, cartridge_api_url) {
    const ptr0 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len0 = WASM_VECTOR_LEN;
    const ret = wasm.subscribeCreateSession(addHeapObject(session_key_guid), ptr0, len0);
    return takeObject(ret);
}

/**
 * @param {Signer} signer
 * @returns {JsFelt}
 */
export function signerToGuid(signer) {
    const ret = wasm.signerToGuid(addHeapObject(signer));
    return takeObject(ret);
}

function __wbg_adapter_4(arg0, arg1) {
    wasm.__wbindgen_export_5(arg0, arg1);
}

function __wbg_adapter_11(arg0, arg1, arg2) {
    wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_14(arg0, arg1, arg2) {
    wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2));
}

function __wbg_adapter_257(arg0, arg1, arg2, arg3) {
    wasm.__wbindgen_export_8(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
}

/**
 * @enum {1 | 20 | 24 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 40 | 41 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 10 | 64 | 65 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143}
 */
export const ErrorCode = Object.freeze({
    StarknetFailedToReceiveTransaction: 1, "1": "StarknetFailedToReceiveTransaction",
    StarknetContractNotFound: 20, "20": "StarknetContractNotFound",
    StarknetBlockNotFound: 24, "24": "StarknetBlockNotFound",
    StarknetInvalidTransactionIndex: 27, "27": "StarknetInvalidTransactionIndex",
    StarknetClassHashNotFound: 28, "28": "StarknetClassHashNotFound",
    StarknetTransactionHashNotFound: 29, "29": "StarknetTransactionHashNotFound",
    StarknetPageSizeTooBig: 31, "31": "StarknetPageSizeTooBig",
    StarknetNoBlocks: 32, "32": "StarknetNoBlocks",
    StarknetInvalidContinuationToken: 33, "33": "StarknetInvalidContinuationToken",
    StarknetTooManyKeysInFilter: 34, "34": "StarknetTooManyKeysInFilter",
    StarknetContractError: 40, "40": "StarknetContractError",
    StarknetTransactionExecutionError: 41, "41": "StarknetTransactionExecutionError",
    StarknetClassAlreadyDeclared: 51, "51": "StarknetClassAlreadyDeclared",
    StarknetInvalidTransactionNonce: 52, "52": "StarknetInvalidTransactionNonce",
    StarknetInsufficientMaxFee: 53, "53": "StarknetInsufficientMaxFee",
    StarknetInsufficientAccountBalance: 54, "54": "StarknetInsufficientAccountBalance",
    StarknetValidationFailure: 55, "55": "StarknetValidationFailure",
    StarknetCompilationFailed: 56, "56": "StarknetCompilationFailed",
    StarknetContractClassSizeIsTooLarge: 57, "57": "StarknetContractClassSizeIsTooLarge",
    StarknetNonAccount: 58, "58": "StarknetNonAccount",
    StarknetDuplicateTx: 59, "59": "StarknetDuplicateTx",
    StarknetCompiledClassHashMismatch: 60, "60": "StarknetCompiledClassHashMismatch",
    StarknetUnsupportedTxVersion: 61, "61": "StarknetUnsupportedTxVersion",
    StarknetUnsupportedContractClassVersion: 62, "62": "StarknetUnsupportedContractClassVersion",
    StarknetUnexpectedError: 63, "63": "StarknetUnexpectedError",
    StarknetNoTraceAvailable: 10, "10": "StarknetNoTraceAvailable",
    StarknetReplacementTransactionUnderpriced: 64, "64": "StarknetReplacementTransactionUnderpriced",
    StarknetFeeBelowMinimum: 65, "65": "StarknetFeeBelowMinimum",
    SignError: 101, "101": "SignError",
    StorageError: 102, "102": "StorageError",
    AccountFactoryError: 103, "103": "AccountFactoryError",
    PaymasterExecutionTimeNotReached: 104, "104": "PaymasterExecutionTimeNotReached",
    PaymasterExecutionTimePassed: 105, "105": "PaymasterExecutionTimePassed",
    PaymasterInvalidCaller: 106, "106": "PaymasterInvalidCaller",
    PaymasterRateLimitExceeded: 107, "107": "PaymasterRateLimitExceeded",
    PaymasterNotSupported: 108, "108": "PaymasterNotSupported",
    PaymasterHttp: 109, "109": "PaymasterHttp",
    PaymasterExcecution: 110, "110": "PaymasterExcecution",
    PaymasterSerialization: 111, "111": "PaymasterSerialization",
    CartridgeControllerNotDeployed: 112, "112": "CartridgeControllerNotDeployed",
    InsufficientBalance: 113, "113": "InsufficientBalance",
    OriginError: 114, "114": "OriginError",
    EncodingError: 115, "115": "EncodingError",
    SerdeWasmBindgenError: 116, "116": "SerdeWasmBindgenError",
    CairoSerdeError: 117, "117": "CairoSerdeError",
    CairoShortStringToFeltError: 118, "118": "CairoShortStringToFeltError",
    DeviceCreateCredential: 119, "119": "DeviceCreateCredential",
    DeviceGetAssertion: 120, "120": "DeviceGetAssertion",
    DeviceBadAssertion: 121, "121": "DeviceBadAssertion",
    DeviceChannel: 122, "122": "DeviceChannel",
    DeviceOrigin: 123, "123": "DeviceOrigin",
    AccountSigning: 124, "124": "AccountSigning",
    AccountProvider: 125, "125": "AccountProvider",
    AccountClassHashCalculation: 126, "126": "AccountClassHashCalculation",
    AccountFeeOutOfRange: 128, "128": "AccountFeeOutOfRange",
    ProviderRateLimited: 129, "129": "ProviderRateLimited",
    ProviderArrayLengthMismatch: 130, "130": "ProviderArrayLengthMismatch",
    ProviderOther: 131, "131": "ProviderOther",
    SessionAlreadyRegistered: 132, "132": "SessionAlreadyRegistered",
    UrlParseError: 133, "133": "UrlParseError",
    Base64DecodeError: 134, "134": "Base64DecodeError",
    CoseError: 135, "135": "CoseError",
    PolicyChainIdMismatch: 136, "136": "PolicyChainIdMismatch",
    InvalidOwner: 137, "137": "InvalidOwner",
    GasPriceTooHigh: 138, "138": "GasPriceTooHigh",
    TransactionTimeout: 139, "139": "TransactionTimeout",
    ConversionError: 140, "140": "ConversionError",
    InvalidChainId: 141, "141": "InvalidChainId",
    SessionRefreshRequired: 142, "142": "SessionRefreshRequired",
    ManualExecutionRequired: 143, "143": "ManualExecutionRequired",
});

const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];

const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];

const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];

const CartridgeAccountFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_cartridgeaccount_free(ptr >>> 0, 1));

export class CartridgeAccount {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(CartridgeAccount.prototype);
        obj.__wbg_ptr = ptr;
        CartridgeAccountFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        CartridgeAccountFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_cartridgeaccount_free(ptr, 0);
    }
    /**
     * Creates a new `CartridgeAccount` instance.
     *
     * # Parameters
     * - `app_id`: Application identifier.
     * - `rpc_url`: The URL of the JSON-RPC endpoint.
     * - `address`: The blockchain address associated with the account.
     * - `username`: Username associated with the account.
     * - `owner`: A Owner struct containing the owner signer and associated data.
     * @param {string} app_id
     * @param {JsFelt} class_hash
     * @param {string} rpc_url
     * @param {JsFelt} address
     * @param {string} username
     * @param {Owner} owner
     * @param {string} cartridge_api_url
     * @returns {Promise<CartridgeAccountWithMeta>}
     */
    static new(app_id, class_hash, rpc_url, address, username, owner, cartridge_api_url) {
        const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len1 = WASM_VECTOR_LEN;
        const ptr2 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len2 = WASM_VECTOR_LEN;
        const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len3 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_new(ptr0, len0, addHeapObject(class_hash), ptr1, len1, addHeapObject(address), ptr2, len2, addHeapObject(owner), ptr3, len3);
        return takeObject(ret);
    }
    /**
     * Creates a new `CartridgeAccount` instance with a randomly generated Starknet signer.
     * The controller address is computed internally based on the generated signer.
     *
     * # Parameters
     * - `app_id`: Application identifier.
     * - `rpc_url`: The URL of the JSON-RPC endpoint.
     * - `username`: Username associated with the account.
     * @param {string} app_id
     * @param {JsFelt} class_hash
     * @param {string} rpc_url
     * @param {string} username
     * @param {string} cartridge_api_url
     * @returns {Promise<CartridgeAccountWithMeta>}
     */
    static newHeadless(app_id, class_hash, rpc_url, username, cartridge_api_url) {
        const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len1 = WASM_VECTOR_LEN;
        const ptr2 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len2 = WASM_VECTOR_LEN;
        const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len3 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_newHeadless(ptr0, len0, addHeapObject(class_hash), ptr1, len1, ptr2, len2, ptr3, len3);
        return takeObject(ret);
    }
    /**
     * @param {string} app_id
     * @param {string} cartridge_api_url
     * @returns {Promise<CartridgeAccountWithMeta | undefined>}
     */
    static fromStorage(app_id, cartridge_api_url) {
        const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len1 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_fromStorage(ptr0, len0, ptr1, len1);
        return takeObject(ret);
    }
    /**
     * @returns {Promise<void>}
     */
    disconnect() {
        const ret = wasm.cartridgeaccount_disconnect(this.__wbg_ptr);
        return takeObject(ret);
    }
    /**
     * @param {Policy[]} policies
     * @param {bigint} expires_at
     * @param {JsFelt} public_key
     * @param {JsFeeEstimate | null} [max_fee]
     * @returns {Promise<any>}
     */
    registerSession(policies, expires_at, public_key, max_fee) {
        const ptr0 = passArrayJsValueToWasm0(policies, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_registerSession(this.__wbg_ptr, ptr0, len0, expires_at, addHeapObject(public_key), isLikeNone(max_fee) ? 0 : addHeapObject(max_fee));
        return takeObject(ret);
    }
    /**
     * @param {Policy[]} policies
     * @param {bigint} expires_at
     * @param {JsFelt} public_key
     * @returns {Promise<any>}
     */
    registerSessionCalldata(policies, expires_at, public_key) {
        const ptr0 = passArrayJsValueToWasm0(policies, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_registerSessionCalldata(this.__wbg_ptr, ptr0, len0, expires_at, addHeapObject(public_key));
        return takeObject(ret);
    }
    /**
     * @param {JsFelt} new_class_hash
     * @returns {Promise<JsCall>}
     */
    upgrade(new_class_hash) {
        const ret = wasm.cartridgeaccount_upgrade(this.__wbg_ptr, addHeapObject(new_class_hash));
        return takeObject(ret);
    }
    /**
     * @param {JsRegister} register
     * @returns {Promise<JsRegisterResponse>}
     */
    register(register) {
        const ret = wasm.cartridgeaccount_register(this.__wbg_ptr, addHeapObject(register));
        return takeObject(ret);
    }
    /**
     * @param {Policy[]} policies
     * @param {bigint} expires_at
     * @returns {Promise<AuthorizedSession | undefined>}
     */
    createSession(policies, expires_at) {
        const ptr0 = passArrayJsValueToWasm0(policies, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_createSession(this.__wbg_ptr, ptr0, len0, expires_at);
        return takeObject(ret);
    }
    /**
     * @param {Policy[]} policies
     * @returns {Promise<void>}
     */
    skipSession(policies) {
        const ptr0 = passArrayJsValueToWasm0(policies, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_skipSession(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {Signer | null} [owner]
     * @param {JsAddSignerInput | null} [signer_input]
     * @param {string | null} [rp_id]
     * @returns {Promise<void>}
     */
    addOwner(owner, signer_input, rp_id) {
        var ptr0 = isLikeNone(rp_id) ? 0 : passStringToWasm0(rp_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        var len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_addOwner(this.__wbg_ptr, isLikeNone(owner) ? 0 : addHeapObject(owner), isLikeNone(signer_input) ? 0 : addHeapObject(signer_input), ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {JsRemoveSignerInput} signer
     * @returns {Promise<void>}
     */
    removeOwner(signer) {
        const ret = wasm.cartridgeaccount_removeOwner(this.__wbg_ptr, addHeapObject(signer));
        return takeObject(ret);
    }
    /**
     * @param {string} rp_id
     * @returns {Promise<JsAddSignerInput>}
     */
    createPasskeySigner(rp_id) {
        const ptr0 = passStringToWasm0(rp_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_createPasskeySigner(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {JsCall[]} calls
     * @returns {Promise<JsFeeEstimate>}
     */
    estimateInvokeFee(calls) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_estimateInvokeFee(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {JsCall[]} calls
     * @param {JsFeeEstimate | null} [max_fee]
     * @param {JsFeeSource | null} [fee_source]
     * @returns {Promise<any>}
     */
    execute(calls, max_fee, fee_source) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_execute(this.__wbg_ptr, ptr0, len0, isLikeNone(max_fee) ? 0 : addHeapObject(max_fee), isLikeNone(fee_source) ? 0 : addHeapObject(fee_source));
        return takeObject(ret);
    }
    /**
     * @param {JsCall[]} calls
     * @param {JsFeeSource | null} [fee_source]
     * @returns {Promise<any>}
     */
    executeFromOutsideV2(calls, fee_source) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_executeFromOutsideV2(this.__wbg_ptr, ptr0, len0, isLikeNone(fee_source) ? 0 : addHeapObject(fee_source));
        return takeObject(ret);
    }
    /**
     * @param {JsCall[]} calls
     * @param {JsFeeSource | null} [fee_source]
     * @returns {Promise<any>}
     */
    executeFromOutsideV3(calls, fee_source) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_executeFromOutsideV3(this.__wbg_ptr, ptr0, len0, isLikeNone(fee_source) ? 0 : addHeapObject(fee_source));
        return takeObject(ret);
    }
    /**
     * @param {JsCall[]} calls
     * @param {JsFeeSource | null} [fee_source]
     * @returns {Promise<any>}
     */
    trySessionExecute(calls, fee_source) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_trySessionExecute(this.__wbg_ptr, ptr0, len0, isLikeNone(fee_source) ? 0 : addHeapObject(fee_source));
        return takeObject(ret);
    }
    /**
     * @param {Policy[]} policies
     * @param {JsFelt | null} [public_key]
     * @returns {Promise<AuthorizedSession | undefined>}
     */
    isRegisteredSessionAuthorized(policies, public_key) {
        const ptr0 = passArrayJsValueToWasm0(policies, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_isRegisteredSessionAuthorized(this.__wbg_ptr, ptr0, len0, isLikeNone(public_key) ? 0 : addHeapObject(public_key));
        return takeObject(ret);
    }
    /**
     * @param {Policy[]} policies
     * @returns {Promise<boolean>}
     */
    hasRequestedSession(policies) {
        const ptr0 = passArrayJsValueToWasm0(policies, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_hasRequestedSession(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {JsRevokableSession} session
     * @returns {Promise<void>}
     */
    revokeSession(session) {
        const ret = wasm.cartridgeaccount_revokeSession(this.__wbg_ptr, addHeapObject(session));
        return takeObject(ret);
    }
    /**
     * @param {JsRevokableSession[]} sessions
     * @returns {Promise<void>}
     */
    revokeSessions(sessions) {
        const ptr0 = passArrayJsValueToWasm0(sessions, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_revokeSessions(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {string} typed_data
     * @returns {Promise<Felts>}
     */
    signMessage(typed_data) {
        const ptr0 = passStringToWasm0(typed_data, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_signMessage(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @returns {Promise<any>}
     */
    getNonce() {
        const ret = wasm.cartridgeaccount_getNonce(this.__wbg_ptr);
        return takeObject(ret);
    }
    /**
     * @param {JsFeeEstimate | null} [max_fee]
     * @returns {Promise<any>}
     */
    deploySelf(max_fee) {
        const ret = wasm.cartridgeaccount_deploySelf(this.__wbg_ptr, isLikeNone(max_fee) ? 0 : addHeapObject(max_fee));
        return takeObject(ret);
    }
    /**
     * @returns {Promise<JsFelt>}
     */
    delegateAccount() {
        const ret = wasm.cartridgeaccount_delegateAccount(this.__wbg_ptr);
        return takeObject(ret);
    }
    /**
     * @param {JsCall[]} calls
     * @returns {Promise<boolean>}
     */
    hasAuthorizedPoliciesForCalls(calls) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_hasAuthorizedPoliciesForCalls(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * @param {string} typed_data
     * @returns {Promise<boolean>}
     */
    hasAuthorizedPoliciesForMessage(typed_data) {
        const ptr0 = passStringToWasm0(typed_data, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_hasAuthorizedPoliciesForMessage(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
    /**
     * Signs an OutsideExecution V3 transaction and returns both the OutsideExecution object and its signature.
     *
     * # Parameters
     * - `calls`: Array of calls to execute from outside
     *
     * # Returns
     * A `JsSignedOutsideExecution` containing the OutsideExecution V3 object and its signature
     * @param {JsCall[]} calls
     * @returns {Promise<JsSignedOutsideExecution>}
     */
    signExecuteFromOutside(calls) {
        const ptr0 = passArrayJsValueToWasm0(calls, wasm.__wbindgen_export_0);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.cartridgeaccount_signExecuteFromOutside(this.__wbg_ptr, ptr0, len0);
        return takeObject(ret);
    }
}
if (Symbol.dispose) CartridgeAccount.prototype[Symbol.dispose] = CartridgeAccount.prototype.free;

const CartridgeAccountMetaFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_cartridgeaccountmeta_free(ptr >>> 0, 1));
/**
 * A type for accessing fixed attributes of `CartridgeAccount`.
 *
 * This type exists as concurrent mutable and immutable calls to `CartridgeAccount` are guarded
 * with `WasmMutex`, which only operates under an `async` context. If these getters were directly
 * implemented under `CartridgeAccount`:
 *
 * - calls to them would unnecessarily have to be `async` as well;
 * - there would be excessive locking.
 *
 * This type is supposed to only ever be borrowed immutably. So no concurrent access control would
 * be needed.
 */
export class CartridgeAccountMeta {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(CartridgeAccountMeta.prototype);
        obj.__wbg_ptr = ptr;
        CartridgeAccountMetaFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        CartridgeAccountMetaFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_cartridgeaccountmeta_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    appId() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.cartridgeaccountmeta_appId(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {string}
     */
    username() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.cartridgeaccountmeta_username(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {string}
     */
    address() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.cartridgeaccountmeta_address(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {string}
     */
    classHash() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.cartridgeaccountmeta_classHash(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {string}
     */
    rpcUrl() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.cartridgeaccountmeta_rpcUrl(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {string}
     */
    chainId() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.cartridgeaccountmeta_chainId(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {Owner}
     */
    owner() {
        const ret = wasm.cartridgeaccountmeta_owner(this.__wbg_ptr);
        return takeObject(ret);
    }
    /**
     * @returns {JsFelt}
     */
    ownerGuid() {
        const ret = wasm.cartridgeaccountmeta_ownerGuid(this.__wbg_ptr);
        return takeObject(ret);
    }
}
if (Symbol.dispose) CartridgeAccountMeta.prototype[Symbol.dispose] = CartridgeAccountMeta.prototype.free;

const CartridgeAccountWithMetaFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_cartridgeaccountwithmeta_free(ptr >>> 0, 1));
/**
 * A type used as the return type for constructing `CartridgeAccount` to provide an extra,
 * separately borrowable `meta` field for synchronously accessing fixed fields.
 *
 * This type exists instead of simply having `CartridgeAccount::new()` return a tuple as tuples
 * don't implement `IntoWasmAbi` which is needed for crossing JS-WASM boundary.
 */
export class CartridgeAccountWithMeta {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(CartridgeAccountWithMeta.prototype);
        obj.__wbg_ptr = ptr;
        CartridgeAccountWithMetaFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        CartridgeAccountWithMetaFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_cartridgeaccountwithmeta_free(ptr, 0);
    }
    /**
     * @returns {CartridgeAccountMeta}
     */
    meta() {
        const ret = wasm.cartridgeaccountwithmeta_meta(this.__wbg_ptr);
        return CartridgeAccountMeta.__wrap(ret);
    }
    /**
     * @returns {CartridgeAccount}
     */
    intoAccount() {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.cartridgeaccountwithmeta_intoAccount(ptr);
        return CartridgeAccount.__wrap(ret);
    }
}
if (Symbol.dispose) CartridgeAccountWithMeta.prototype[Symbol.dispose] = CartridgeAccountWithMeta.prototype.free;

const ControllerFactoryFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_controllerfactory_free(ptr >>> 0, 1));

export class ControllerFactory {

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        ControllerFactoryFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_controllerfactory_free(ptr, 0);
    }
    /**
     * @param {string} app_id
     * @param {string} cartridge_api_url
     * @returns {Promise<CartridgeAccountWithMeta | undefined>}
     */
    static fromStorage(app_id, cartridge_api_url) {
        const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len1 = WASM_VECTOR_LEN;
        const ret = wasm.controllerfactory_fromStorage(ptr0, len0, ptr1, len1);
        return takeObject(ret);
    }
    /**
     * @param {string} app_id
     * @param {string} username
     * @param {JsFelt} class_hash
     * @param {string} rpc_url
     * @param {JsFelt} address
     * @param {Owner} owner
     * @param {string} cartridge_api_url
     * @param {bigint} session_expires_at_s
     * @param {boolean | null} [is_controller_registered]
     * @returns {Promise<LoginResult>}
     */
    static login(app_id, username, class_hash, rpc_url, address, owner, cartridge_api_url, session_expires_at_s, is_controller_registered) {
        const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len1 = WASM_VECTOR_LEN;
        const ptr2 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len2 = WASM_VECTOR_LEN;
        const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len3 = WASM_VECTOR_LEN;
        const ret = wasm.controllerfactory_login(ptr0, len0, ptr1, len1, addHeapObject(class_hash), ptr2, len2, addHeapObject(address), addHeapObject(owner), ptr3, len3, session_expires_at_s, isLikeNone(is_controller_registered) ? 0xFFFFFF : is_controller_registered ? 1 : 0);
        return takeObject(ret);
    }
    /**
     * This should only be used with webauthn signers
     * @param {string} app_id
     * @param {string} username
     * @param {JsFelt} class_hash
     * @param {string} rpc_url
     * @param {JsFelt} address
     * @param {Owner} owner
     * @param {string} cartridge_api_url
     * @returns {Promise<CartridgeAccountWithMeta>}
     */
    static apiLogin(app_id, username, class_hash, rpc_url, address, owner, cartridge_api_url) {
        const ptr0 = passStringToWasm0(app_id, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(username, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len1 = WASM_VECTOR_LEN;
        const ptr2 = passStringToWasm0(rpc_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len2 = WASM_VECTOR_LEN;
        const ptr3 = passStringToWasm0(cartridge_api_url, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len3 = WASM_VECTOR_LEN;
        const ret = wasm.controllerfactory_apiLogin(ptr0, len0, ptr1, len1, addHeapObject(class_hash), ptr2, len2, addHeapObject(address), addHeapObject(owner), ptr3, len3);
        return takeObject(ret);
    }
}
if (Symbol.dispose) ControllerFactory.prototype[Symbol.dispose] = ControllerFactory.prototype.free;

const JsControllerErrorFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_jscontrollererror_free(ptr >>> 0, 1));

export class JsControllerError {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(JsControllerError.prototype);
        obj.__wbg_ptr = ptr;
        JsControllerErrorFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        JsControllerErrorFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_jscontrollererror_free(ptr, 0);
    }
    /**
     * @returns {ErrorCode}
     */
    get code() {
        const ret = wasm.__wbg_get_jscontrollererror_code(this.__wbg_ptr);
        return ret;
    }
    /**
     * @param {ErrorCode} arg0
     */
    set code(arg0) {
        wasm.__wbg_set_jscontrollererror_code(this.__wbg_ptr, arg0);
    }
    /**
     * @returns {string}
     */
    get message() {
        let deferred1_0;
        let deferred1_1;
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.__wbg_get_jscontrollererror_message(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            deferred1_0 = r0;
            deferred1_1 = r1;
            return getStringFromWasm0(r0, r1);
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
            wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @param {string} arg0
     */
    set message(arg0) {
        const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        const len0 = WASM_VECTOR_LEN;
        wasm.__wbg_set_jscontrollererror_message(this.__wbg_ptr, ptr0, len0);
    }
    /**
     * @returns {string | undefined}
     */
    get data() {
        try {
            const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
            wasm.__wbg_get_jscontrollererror_data(retptr, this.__wbg_ptr);
            var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
            var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
            let v1;
            if (r0 !== 0) {
                v1 = getStringFromWasm0(r0, r1).slice();
                wasm.__wbindgen_export_3(r0, r1 * 1, 1);
            }
            return v1;
        } finally {
            wasm.__wbindgen_add_to_stack_pointer(16);
        }
    }
    /**
     * @param {string | null} [arg0]
     */
    set data(arg0) {
        var ptr0 = isLikeNone(arg0) ? 0 : passStringToWasm0(arg0, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
        var len0 = WASM_VECTOR_LEN;
        wasm.__wbg_set_jscontrollererror_data(this.__wbg_ptr, ptr0, len0);
    }
}
if (Symbol.dispose) JsControllerError.prototype[Symbol.dispose] = JsControllerError.prototype.free;

const LoginResultFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_loginresult_free(ptr >>> 0, 1));

export class LoginResult {

    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(LoginResult.prototype);
        obj.__wbg_ptr = ptr;
        LoginResultFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }

    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        LoginResultFinalization.unregister(this);
        return ptr;
    }

    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_loginresult_free(ptr, 0);
    }
    /**
     * @returns {Array<any>}
     */
    intoValues() {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.loginresult_intoValues(ptr);
        return takeObject(ret);
    }
}
if (Symbol.dispose) LoginResult.prototype[Symbol.dispose] = LoginResult.prototype.free;

export function __wbg_Error_e17e777aac105295(arg0, arg1) {
    const ret = Error(getStringFromWasm0(arg0, arg1));
    return addHeapObject(ret);
};

export function __wbg_String_8f0eb39a4a4c2f66(arg0, arg1) {
    const ret = String(getObject(arg1));
    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

export function __wbg_abort_67e1b49bf6614565(arg0) {
    getObject(arg0).abort();
};

export function __wbg_abort_d830bf2e9aa6ec5b(arg0, arg1) {
    getObject(arg0).abort(getObject(arg1));
};

export function __wbg_addEventListener_775911544ac9d643() { return handleError(function (arg0, arg1, arg2, arg3) {
    getObject(arg0).addEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
}, arguments) };

export function __wbg_append_72a3c0addd2bce38() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
    getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
}, arguments) };

export function __wbg_arrayBuffer_9c99b8e2809e8cbb() { return handleError(function (arg0) {
    const ret = getObject(arg0).arrayBuffer();
    return addHeapObject(ret);
}, arguments) };

export function __wbg_call_13410aac570ffff7() { return handleError(function (arg0, arg1) {
    const ret = getObject(arg0).call(getObject(arg1));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_call_a5400b25a865cfd8() { return handleError(function (arg0, arg1, arg2) {
    const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_cartridgeaccountwithmeta_new(arg0) {
    const ret = CartridgeAccountWithMeta.__wrap(arg0);
    return addHeapObject(ret);
};

export function __wbg_clearTimeout_6222fede17abcb1a(arg0) {
    const ret = clearTimeout(takeObject(arg0));
    return addHeapObject(ret);
};

export function __wbg_clear_376ed5fc63920fe9() { return handleError(function (arg0) {
    getObject(arg0).clear();
}, arguments) };

export function __wbg_create_c28725879a96569c() { return handleError(function (arg0, arg1) {
    const ret = getObject(arg0).create(getObject(arg1));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_credentials_f1f893c6da3e9ee4(arg0) {
    const ret = getObject(arg0).credentials;
    return addHeapObject(ret);
};

export function __wbg_crypto_574e78ad8b13b65f(arg0) {
    const ret = getObject(arg0).crypto;
    return addHeapObject(ret);
};

export function __wbg_data_9ab529722bcc4e6c(arg0) {
    const ret = getObject(arg0).data;
    return addHeapObject(ret);
};

export function __wbg_done_75ed0ee6dd243d9d(arg0) {
    const ret = getObject(arg0).done;
    return ret;
};

export function __wbg_error_99981e16d476aa5c(arg0) {
    console.error(getObject(arg0));
};

export function __wbg_fetch_87aed7f306ec6d63(arg0, arg1) {
    const ret = getObject(arg0).fetch(getObject(arg1));
    return addHeapObject(ret);
};

export function __wbg_fetch_f156d10be9a5c88a(arg0) {
    const ret = fetch(getObject(arg0));
    return addHeapObject(ret);
};

export function __wbg_fetch_f1856afdb49415d1(arg0) {
    const ret = fetch(getObject(arg0));
    return addHeapObject(ret);
};

export function __wbg_getClientExtensionResults_b9c10fd2534468bc(arg0) {
    const ret = getObject(arg0).getClientExtensionResults();
    return addHeapObject(ret);
};

export function __wbg_getItem_9fc74b31b896f95a() { return handleError(function (arg0, arg1, arg2, arg3) {
    const ret = getObject(arg1).getItem(getStringFromWasm0(arg2, arg3));
    var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    var len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
}, arguments) };

export function __wbg_getRandomValues_b8f5dbd5f3995a9e() { return handleError(function (arg0, arg1) {
    getObject(arg0).getRandomValues(getObject(arg1));
}, arguments) };

export function __wbg_getTime_6bb3f64e0f18f817(arg0) {
    const ret = getObject(arg0).getTime();
    return ret;
};

export function __wbg_get_1cbe414461579d6e() { return handleError(function (arg0, arg1) {
    const ret = getObject(arg0).get(getObject(arg1));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_get_458e874b43b18b25() { return handleError(function (arg0, arg1) {
    const ret = Reflect.get(getObject(arg0), getObject(arg1));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_getwithrefkey_1dc361bd10053bfe(arg0, arg1) {
    const ret = getObject(arg0)[getObject(arg1)];
    return addHeapObject(ret);
};

export function __wbg_has_b89e451f638123e3() { return handleError(function (arg0, arg1) {
    const ret = Reflect.has(getObject(arg0), getObject(arg1));
    return ret;
}, arguments) };

export function __wbg_headers_29fec3c72865cd75(arg0) {
    const ret = getObject(arg0).headers;
    return addHeapObject(ret);
};

export function __wbg_instanceof_ArrayBuffer_67f3012529f6a2dd(arg0) {
    let result;
    try {
        result = getObject(arg0) instanceof ArrayBuffer;
    } catch (_) {
        result = false;
    }
    const ret = result;
    return ret;
};

export function __wbg_instanceof_Object_fbf5fef4952ff29b(arg0) {
    let result;
    try {
        result = getObject(arg0) instanceof Object;
    } catch (_) {
        result = false;
    }
    const ret = result;
    return ret;
};

export function __wbg_instanceof_Response_50fde2cd696850bf(arg0) {
    let result;
    try {
        result = getObject(arg0) instanceof Response;
    } catch (_) {
        result = false;
    }
    const ret = result;
    return ret;
};

export function __wbg_instanceof_Uint8Array_9a8378d955933db7(arg0) {
    let result;
    try {
        result = getObject(arg0) instanceof Uint8Array;
    } catch (_) {
        result = false;
    }
    const ret = result;
    return ret;
};

export function __wbg_instanceof_Window_12d20d558ef92592(arg0) {
    let result;
    try {
        result = getObject(arg0) instanceof Window;
    } catch (_) {
        result = false;
    }
    const ret = result;
    return ret;
};

export function __wbg_instanceof_WorkerGlobalScope_85d487cc157fd065(arg0) {
    let result;
    try {
        result = getObject(arg0) instanceof WorkerGlobalScope;
    } catch (_) {
        result = false;
    }
    const ret = result;
    return ret;
};

export function __wbg_iterator_f370b34483c71a1c() {
    const ret = Symbol.iterator;
    return addHeapObject(ret);
};

export function __wbg_jscontrollererror_new(arg0) {
    const ret = JsControllerError.__wrap(arg0);
    return addHeapObject(ret);
};

export function __wbg_length_6bb7e81f9d7713e4(arg0) {
    const ret = getObject(arg0).length;
    return ret;
};

export function __wbg_localStorage_9330af8bf39365ba() { return handleError(function (arg0) {
    const ret = getObject(arg0).localStorage;
    return isLikeNone(ret) ? 0 : addHeapObject(ret);
}, arguments) };

export function __wbg_location_92d89c32ae076cab(arg0) {
    const ret = getObject(arg0).location;
    return addHeapObject(ret);
};

export function __wbg_log_6c7b5f4f00b8ce3f(arg0) {
    console.log(getObject(arg0));
};

export function __wbg_loginresult_new(arg0) {
    const ret = LoginResult.__wrap(arg0);
    return addHeapObject(ret);
};

export function __wbg_msCrypto_a61aeb35a24c1329(arg0) {
    const ret = getObject(arg0).msCrypto;
    return addHeapObject(ret);
};

export function __wbg_navigator_65d5ad763926b868(arg0) {
    const ret = getObject(arg0).navigator;
    return addHeapObject(ret);
};

export function __wbg_new0_b0a0a38c201e6df5() {
    const ret = new Date();
    return addHeapObject(ret);
};

export function __wbg_new_19c25a3f2fa63a02() {
    const ret = new Object();
    return addHeapObject(ret);
};

export function __wbg_new_1f3a344cf3123716() {
    const ret = new Array();
    return addHeapObject(ret);
};

export function __wbg_new_2658d63118834d8e() {
    const ret = new Mutex();
    return addHeapObject(ret);
};

export function __wbg_new_2e3c58a15f39f5f9(arg0, arg1) {
    try {
        var state0 = {a: arg0, b: arg1};
        var cb0 = (arg0, arg1) => {
            const a = state0.a;
            state0.a = 0;
            try {
                return __wbg_adapter_257(a, state0.b, arg0, arg1);
            } finally {
                state0.a = a;
            }
        };
        const ret = new Promise(cb0);
        return addHeapObject(ret);
    } finally {
        state0.a = state0.b = 0;
    }
};

export function __wbg_new_2ff1f68f3676ea53() {
    const ret = new Map();
    return addHeapObject(ret);
};

export function __wbg_new_638ebfaedbf32a5e(arg0) {
    const ret = new Uint8Array(getObject(arg0));
    return addHeapObject(ret);
};

export function __wbg_new_66b9434b4e59b63e() { return handleError(function () {
    const ret = new AbortController();
    return addHeapObject(ret);
}, arguments) };

export function __wbg_new_f6e53210afea8e45() { return handleError(function () {
    const ret = new Headers();
    return addHeapObject(ret);
}, arguments) };

export function __wbg_newfromslice_074c56947bd43469(arg0, arg1) {
    const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
    return addHeapObject(ret);
};

export function __wbg_newnoargs_254190557c45b4ec(arg0, arg1) {
    const ret = new Function(getStringFromWasm0(arg0, arg1));
    return addHeapObject(ret);
};

export function __wbg_newwithlength_a167dcc7aaa3ba77(arg0) {
    const ret = new Uint8Array(arg0 >>> 0);
    return addHeapObject(ret);
};

export function __wbg_newwithstrandinit_b5d168a29a3fd85f() { return handleError(function (arg0, arg1, arg2) {
    const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_next_5b3530e612fde77d(arg0) {
    const ret = getObject(arg0).next;
    return addHeapObject(ret);
};

export function __wbg_next_692e82279131b03c() { return handleError(function (arg0) {
    const ret = getObject(arg0).next();
    return addHeapObject(ret);
}, arguments) };

export function __wbg_node_905d3e251edff8a2(arg0) {
    const ret = getObject(arg0).node;
    return addHeapObject(ret);
};

export function __wbg_now_1e80617bcee43265() {
    const ret = Date.now();
    return ret;
};

export function __wbg_obtain_a9626b3b96e6dc2c(arg0) {
    const ret = getObject(arg0).obtain();
    return addHeapObject(ret);
};

export function __wbg_open_fbf9d84c3371fb48() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5, arg6) {
    const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), getStringFromWasm0(arg5, arg6));
    return isLikeNone(ret) ? 0 : addHeapObject(ret);
}, arguments) };

export function __wbg_origin_00892013881c6e2b() { return handleError(function (arg0, arg1) {
    const ret = getObject(arg1).origin;
    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
}, arguments) };

export function __wbg_origin_e705505d7b153144(arg0, arg1) {
    const ret = getObject(arg1).origin;
    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

export function __wbg_parse_037c33ab58f9eabf(arg0, arg1) {
    let deferred0_0;
    let deferred0_1;
    try {
        deferred0_0 = arg0;
        deferred0_1 = arg1;
        const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
        return addHeapObject(ret);
    } finally {
        wasm.__wbindgen_export_3(deferred0_0, deferred0_1, 1);
    }
};

export function __wbg_process_dc0fbacc7c1c06f7(arg0) {
    const ret = getObject(arg0).process;
    return addHeapObject(ret);
};

export function __wbg_prototypesetcall_3d4a26c1ed734349(arg0, arg1, arg2) {
    Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
};

export function __wbg_push_330b2eb93e4e1212(arg0, arg1) {
    const ret = getObject(arg0).push(getObject(arg1));
    return ret;
};

export function __wbg_queueMicrotask_25d0739ac89e8c88(arg0) {
    queueMicrotask(getObject(arg0));
};

export function __wbg_queueMicrotask_4488407636f5bf24(arg0) {
    const ret = getObject(arg0).queueMicrotask;
    return addHeapObject(ret);
};

export function __wbg_randomFillSync_ac0988aba3254290() { return handleError(function (arg0, arg1) {
    getObject(arg0).randomFillSync(takeObject(arg1));
}, arguments) };

export function __wbg_removeEventListener_6d5be9c2821a511e() { return handleError(function (arg0, arg1, arg2, arg3) {
    getObject(arg0).removeEventListener(getStringFromWasm0(arg1, arg2), getObject(arg3));
}, arguments) };

export function __wbg_removeItem_487c5a070c7adaf7() { return handleError(function (arg0, arg1, arg2) {
    getObject(arg0).removeItem(getStringFromWasm0(arg1, arg2));
}, arguments) };

export function __wbg_require_60cc747a6bc5215a() { return handleError(function () {
    const ret = module.require;
    return addHeapObject(ret);
}, arguments) };

export function __wbg_resolve_4055c623acdd6a1b(arg0) {
    const ret = Promise.resolve(getObject(arg0));
    return addHeapObject(ret);
};

export function __wbg_setItem_7add5eb06a28b38f() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
    getObject(arg0).setItem(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
}, arguments) };

export function __wbg_setTimeout_2966518f28aef92e() { return handleError(function (arg0, arg1, arg2) {
    const ret = getObject(arg0).setTimeout(getObject(arg1), arg2);
    return ret;
}, arguments) };

export function __wbg_setTimeout_2b339866a2aa3789(arg0, arg1) {
    const ret = setTimeout(getObject(arg0), arg1);
    return addHeapObject(ret);
};

export function __wbg_setTimeout_98aff77124ecfa08() { return handleError(function (arg0, arg1, arg2) {
    const ret = getObject(arg0).setTimeout(getObject(arg1), arg2);
    return ret;
}, arguments) };

export function __wbg_set_3f1d0b984ed272ed(arg0, arg1, arg2) {
    getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
};

export function __wbg_set_3fda3bac07393de4(arg0, arg1, arg2) {
    getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
};

export function __wbg_set_453345bcda80b89a() { return handleError(function (arg0, arg1, arg2) {
    const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
    return ret;
}, arguments) };

export function __wbg_set_90f6c0f7bd8c0415(arg0, arg1, arg2) {
    getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
};

export function __wbg_set_b7f1cf4fae26fe2a(arg0, arg1, arg2) {
    const ret = getObject(arg0).set(getObject(arg1), getObject(arg2));
    return addHeapObject(ret);
};

export function __wbg_setbody_c8460bdf44147df8(arg0, arg1) {
    getObject(arg0).body = getObject(arg1);
};

export function __wbg_setcache_90ca4ad8a8ad40d3(arg0, arg1) {
    getObject(arg0).cache = __wbindgen_enum_RequestCache[arg1];
};

export function __wbg_setcredentials_9cd60d632c9d5dfc(arg0, arg1) {
    getObject(arg0).credentials = __wbindgen_enum_RequestCredentials[arg1];
};

export function __wbg_setheaders_0052283e2f3503d1(arg0, arg1) {
    getObject(arg0).headers = getObject(arg1);
};

export function __wbg_setmethod_9b504d5b855b329c(arg0, arg1, arg2) {
    getObject(arg0).method = getStringFromWasm0(arg1, arg2);
};

export function __wbg_setmode_a23e1a2ad8b512f8(arg0, arg1) {
    getObject(arg0).mode = __wbindgen_enum_RequestMode[arg1];
};

export function __wbg_setsignal_8c45ad1247a74809(arg0, arg1) {
    getObject(arg0).signal = getObject(arg1);
};

export function __wbg_signMessage_c732ea9d998cac79() { return handleError(function (arg0, arg1, arg2, arg3) {
    let deferred0_0;
    let deferred0_1;
    let deferred1_0;
    let deferred1_1;
    try {
        deferred0_0 = arg0;
        deferred0_1 = arg1;
        deferred1_0 = arg2;
        deferred1_1 = arg3;
        const ret = window.keychain_wallets.signMessage(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3));
        return addHeapObject(ret);
    } finally {
        wasm.__wbindgen_export_3(deferred0_0, deferred0_1, 1);
        wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
    }
}, arguments) };

export function __wbg_signal_da4d466ce86118b5(arg0) {
    const ret = getObject(arg0).signal;
    return addHeapObject(ret);
};

export function __wbg_static_accessor_GLOBAL_8921f820c2ce3f12() {
    const ret = typeof global === 'undefined' ? null : global;
    return isLikeNone(ret) ? 0 : addHeapObject(ret);
};

export function __wbg_static_accessor_GLOBAL_THIS_f0a4409105898184() {
    const ret = typeof globalThis === 'undefined' ? null : globalThis;
    return isLikeNone(ret) ? 0 : addHeapObject(ret);
};

export function __wbg_static_accessor_SELF_995b214ae681ff99() {
    const ret = typeof self === 'undefined' ? null : self;
    return isLikeNone(ret) ? 0 : addHeapObject(ret);
};

export function __wbg_static_accessor_WINDOW_cde3890479c675ea() {
    const ret = typeof window === 'undefined' ? null : window;
    return isLikeNone(ret) ? 0 : addHeapObject(ret);
};

export function __wbg_status_3fea3036088621d6(arg0) {
    const ret = getObject(arg0).status;
    return ret;
};

export function __wbg_stringify_4a34a65f0d4e236f(arg0, arg1) {
    const ret = JSON.stringify(getObject(arg1));
    var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    var len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

export function __wbg_stringify_b98c93d0a190446a() { return handleError(function (arg0) {
    const ret = JSON.stringify(getObject(arg0));
    return addHeapObject(ret);
}, arguments) };

export function __wbg_subarray_70fd07feefe14294(arg0, arg1, arg2) {
    const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
    return addHeapObject(ret);
};

export function __wbg_text_0f69a215637b9b34() { return handleError(function (arg0) {
    const ret = getObject(arg0).text();
    return addHeapObject(ret);
}, arguments) };

export function __wbg_then_b33a773d723afa3e(arg0, arg1, arg2) {
    const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
    return addHeapObject(ret);
};

export function __wbg_then_e22500defe16819f(arg0, arg1) {
    const ret = getObject(arg0).then(getObject(arg1));
    return addHeapObject(ret);
};

export function __wbg_url_e5720dfacf77b05e(arg0, arg1) {
    const ret = getObject(arg1).url;
    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

export function __wbg_userAgent_2e89808dc5dc17d7() { return handleError(function (arg0, arg1) {
    const ret = getObject(arg1).userAgent;
    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
}, arguments) };

export function __wbg_value_dd9372230531eade(arg0) {
    const ret = getObject(arg0).value;
    return addHeapObject(ret);
};

export function __wbg_versions_c01dfd4722a88165(arg0) {
    const ret = getObject(arg0).versions;
    return addHeapObject(ret);
};

export function __wbg_wbindgenbooleanget_3fe6f642c7d97746(arg0) {
    const v = getObject(arg0);
    const ret = typeof(v) === 'boolean' ? v : undefined;
    return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
};

export function __wbg_wbindgencbdrop_eb10308566512b88(arg0) {
    const obj = getObject(arg0).original;
    if (obj.cnt-- == 1) {
        obj.a = 0;
        return true;
    }
    const ret = false;
    return ret;
};

export function __wbg_wbindgendebugstring_99ef257a3ddda34d(arg0, arg1) {
    const ret = debugString(getObject(arg1));
    const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    const len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

export function __wbg_wbindgenin_d7a1ee10933d2d55(arg0, arg1) {
    const ret = getObject(arg0) in getObject(arg1);
    return ret;
};

export function __wbg_wbindgenisfunction_8cee7dce3725ae74(arg0) {
    const ret = typeof(getObject(arg0)) === 'function';
    return ret;
};

export function __wbg_wbindgenisobject_307a53c6bd97fbf8(arg0) {
    const val = getObject(arg0);
    const ret = typeof(val) === 'object' && val !== null;
    return ret;
};

export function __wbg_wbindgenisstring_d4fa939789f003b0(arg0) {
    const ret = typeof(getObject(arg0)) === 'string';
    return ret;
};

export function __wbg_wbindgenisundefined_c4b71d073b92f3c5(arg0) {
    const ret = getObject(arg0) === undefined;
    return ret;
};

export function __wbg_wbindgenjsvallooseeq_9bec8c9be826bed1(arg0, arg1) {
    const ret = getObject(arg0) == getObject(arg1);
    return ret;
};

export function __wbg_wbindgennumberget_f74b4c7525ac05cb(arg0, arg1) {
    const obj = getObject(arg1);
    const ret = typeof(obj) === 'number' ? obj : undefined;
    getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
};

export function __wbg_wbindgenstringget_0f16a6ddddef376f(arg0, arg1) {
    const obj = getObject(arg1);
    const ret = typeof(obj) === 'string' ? obj : undefined;
    var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1);
    var len1 = WASM_VECTOR_LEN;
    getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
    getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
};

export function __wbg_wbindgenthrow_451ec1a8469d7eb6(arg0, arg1) {
    throw new Error(getStringFromWasm0(arg0, arg1));
};

export function __wbindgen_cast_2241b6af4c4b2941(arg0, arg1) {
    // Cast intrinsic for `Ref(String) -> Externref`.
    const ret = getStringFromWasm0(arg0, arg1);
    return addHeapObject(ret);
};

export function __wbindgen_cast_3ab31798e812bcf8(arg0, arg1) {
    // Cast intrinsic for `Closure(Closure { dtor_idx: 13, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 14, ret: Unit, inner_ret: Some(Unit) }, mutable: false }) -> Externref`.
    const ret = makeClosure(arg0, arg1, 13, __wbg_adapter_11);
    return addHeapObject(ret);
};

export function __wbindgen_cast_9ae0607507abb057(arg0) {
    // Cast intrinsic for `I64 -> Externref`.
    const ret = arg0;
    return addHeapObject(ret);
};

export function __wbindgen_cast_a428de4fc2820fa4(arg0, arg1) {
    // Cast intrinsic for `Closure(Closure { dtor_idx: 938, function: Function { arguments: [Externref], shim_idx: 939, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
    const ret = makeMutClosure(arg0, arg1, 938, __wbg_adapter_14);
    return addHeapObject(ret);
};

export function __wbindgen_cast_cb9088102bce6b30(arg0, arg1) {
    // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
    const ret = getArrayU8FromWasm0(arg0, arg1);
    return addHeapObject(ret);
};

export function __wbindgen_cast_d6cd19b81560fd6e(arg0) {
    // Cast intrinsic for `F64 -> Externref`.
    const ret = arg0;
    return addHeapObject(ret);
};

export function __wbindgen_cast_ed712f6666cb3532(arg0, arg1) {
    // Cast intrinsic for `Closure(Closure { dtor_idx: 904, function: Function { arguments: [], shim_idx: 905, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
    const ret = makeMutClosure(arg0, arg1, 904, __wbg_adapter_4);
    return addHeapObject(ret);
};

export function __wbindgen_object_clone_ref(arg0) {
    const ret = getObject(arg0);
    return addHeapObject(ret);
};

export function __wbindgen_object_drop_ref(arg0) {
    takeObject(arg0);
};

