'use strict';

var quickMessage = require('./quick-message-DIxFV-j6.js');
var utils = require('./utils-ByWMmAEg.js');

class BlobCache {
    cache = new Map();
    pending = new Map();
    /**
     * Generates a cache key from media parameters
     */
    getCacheKey(channel, sessionId, messageId) {
        return `${channel}:${sessionId}:${messageId}`;
    }
    /**
     * Gets a cached blob URL if it exists
     */
    get(channel, sessionId, messageId) {
        return null;
    }
    /**
     * Gets a pending request if it exists
     */
    getPending(channel, sessionId, messageId) {
        return null;
    }
    /**
     * Sets a pending request
     */
    setPending(channel, sessionId, messageId, promise) {
        return;
    }
    /**
     * Clears a pending request
     */
    clearPending(channel, sessionId, messageId) {
        const key = this.getCacheKey(channel, sessionId, messageId);
        this.pending.delete(key);
    }
    /**
     * Stores a blob URL in the cache
     */
    set(channel, sessionId, messageId, url, type) {
        return;
    }
    /**
     * Marks a media entry as having an error (failed to load)
     */
    setError(channel, sessionId, messageId) {
        return;
    }
    /**
     * Decrements reference count and optionally revokes the blob URL
     * Returns true if the entry was removed
     */
    release(channel, sessionId, messageId) {
        const key = this.getCacheKey(channel, sessionId, messageId);
        const entry = this.cache.get(key);
        if (entry) {
            entry.refCount--;
            // Keep the blob URL cached even if refCount reaches 0
            // This prevents re-fetching when scrolling back to the same message
            // Only revoke when explicitly cleared or cache is full
            return false;
        }
        return false;
    }
    /**
     * Clears all cached blob URLs
     */
    clear() {
        this.cache.forEach(entry => {
            if (entry.url) {
                URL.revokeObjectURL(entry.url);
            }
        });
        this.cache.clear();
    }
    /**
     * Gets the current cache size
     */
    size() {
        return this.cache.size;
    }
    /**
     * Removes least recently used entries if cache exceeds size limit
     */
    cleanup(maxSize = 100) {
        if (this.cache.size <= maxSize) {
            return;
        }
        const entriesToRemove = this.cache.size - maxSize;
        let removed = 0;
        // Remove entries with lowest refCount first
        const sortedEntries = Array.from(this.cache.entries())
            .sort((a, b) => a[1].refCount - b[1].refCount);
        for (const [key, entry] of sortedEntries) {
            if (removed >= entriesToRemove) {
                break;
            }
            if (entry.url) {
                URL.revokeObjectURL(entry.url);
            }
            this.cache.delete(key);
            removed++;
        }
    }
}
// Export a singleton instance
const blobCache = new BlobCache();

const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);

let idbProxyableTypes;
let cursorAdvanceMethods;
// This is a function to prevent it throwing up in node environments.
function getIdbProxyableTypes() {
    return (idbProxyableTypes ||
        (idbProxyableTypes = [
            IDBDatabase,
            IDBObjectStore,
            IDBIndex,
            IDBCursor,
            IDBTransaction,
        ]));
}
// This is a function to prevent it throwing up in node environments.
function getCursorAdvanceMethods() {
    return (cursorAdvanceMethods ||
        (cursorAdvanceMethods = [
            IDBCursor.prototype.advance,
            IDBCursor.prototype.continue,
            IDBCursor.prototype.continuePrimaryKey,
        ]));
}
const transactionDoneMap = new WeakMap();
const transformCache = new WeakMap();
const reverseTransformCache = new WeakMap();
function promisifyRequest(request) {
    const promise = new Promise((resolve, reject) => {
        const unlisten = () => {
            request.removeEventListener('success', success);
            request.removeEventListener('error', error);
        };
        const success = () => {
            resolve(wrap(request.result));
            unlisten();
        };
        const error = () => {
            reject(request.error);
            unlisten();
        };
        request.addEventListener('success', success);
        request.addEventListener('error', error);
    });
    // This mapping exists in reverseTransformCache but doesn't exist in transformCache. This
    // is because we create many promises from a single IDBRequest.
    reverseTransformCache.set(promise, request);
    return promise;
}
function cacheDonePromiseForTransaction(tx) {
    // Early bail if we've already created a done promise for this transaction.
    if (transactionDoneMap.has(tx))
        return;
    const done = new Promise((resolve, reject) => {
        const unlisten = () => {
            tx.removeEventListener('complete', complete);
            tx.removeEventListener('error', error);
            tx.removeEventListener('abort', error);
        };
        const complete = () => {
            resolve();
            unlisten();
        };
        const error = () => {
            reject(tx.error || new DOMException('AbortError', 'AbortError'));
            unlisten();
        };
        tx.addEventListener('complete', complete);
        tx.addEventListener('error', error);
        tx.addEventListener('abort', error);
    });
    // Cache it for later retrieval.
    transactionDoneMap.set(tx, done);
}
let idbProxyTraps = {
    get(target, prop, receiver) {
        if (target instanceof IDBTransaction) {
            // Special handling for transaction.done.
            if (prop === 'done')
                return transactionDoneMap.get(target);
            // Make tx.store return the only store in the transaction, or undefined if there are many.
            if (prop === 'store') {
                return receiver.objectStoreNames[1]
                    ? undefined
                    : receiver.objectStore(receiver.objectStoreNames[0]);
            }
        }
        // Else transform whatever we get back.
        return wrap(target[prop]);
    },
    set(target, prop, value) {
        target[prop] = value;
        return true;
    },
    has(target, prop) {
        if (target instanceof IDBTransaction &&
            (prop === 'done' || prop === 'store')) {
            return true;
        }
        return prop in target;
    },
};
function replaceTraps(callback) {
    idbProxyTraps = callback(idbProxyTraps);
}
function wrapFunction(func) {
    // Due to expected object equality (which is enforced by the caching in `wrap`), we
    // only create one new func per func.
    // Cursor methods are special, as the behaviour is a little more different to standard IDB. In
    // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the
    // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense
    // with real promises, so each advance methods returns a new promise for the cursor object, or
    // undefined if the end of the cursor has been reached.
    if (getCursorAdvanceMethods().includes(func)) {
        return function (...args) {
            // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
            // the original object.
            func.apply(unwrap(this), args);
            return wrap(this.request);
        };
    }
    return function (...args) {
        // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
        // the original object.
        return wrap(func.apply(unwrap(this), args));
    };
}
function transformCachableValue(value) {
    if (typeof value === 'function')
        return wrapFunction(value);
    // This doesn't return, it just creates a 'done' promise for the transaction,
    // which is later returned for transaction.done (see idbObjectHandler).
    if (value instanceof IDBTransaction)
        cacheDonePromiseForTransaction(value);
    if (instanceOfAny(value, getIdbProxyableTypes()))
        return new Proxy(value, idbProxyTraps);
    // Return the same value back if we're not going to transform it.
    return value;
}
function wrap(value) {
    // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
    // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
    if (value instanceof IDBRequest)
        return promisifyRequest(value);
    // If we've already transformed this value before, reuse the transformed value.
    // This is faster, but it also provides object equality.
    if (transformCache.has(value))
        return transformCache.get(value);
    const newValue = transformCachableValue(value);
    // Not all types are transformed.
    // These may be primitive types, so they can't be WeakMap keys.
    if (newValue !== value) {
        transformCache.set(value, newValue);
        reverseTransformCache.set(newValue, value);
    }
    return newValue;
}
const unwrap = (value) => reverseTransformCache.get(value);

/**
 * Open a database.
 *
 * @param name Name of the database.
 * @param version Schema version.
 * @param callbacks Additional callbacks.
 */
function openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {
    const request = indexedDB.open(name, version);
    const openPromise = wrap(request);
    if (upgrade) {
        request.addEventListener('upgradeneeded', (event) => {
            upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
        });
    }
    if (blocked) {
        request.addEventListener('blocked', (event) => blocked(
        // Casting due to https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1405
        event.oldVersion, event.newVersion, event));
    }
    openPromise
        .then((db) => {
        if (terminated)
            db.addEventListener('close', () => terminated());
        if (blocking) {
            db.addEventListener('versionchange', (event) => blocking(event.oldVersion, event.newVersion, event));
        }
    })
        .catch(() => { });
    return openPromise;
}

const readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];
const writeMethods = ['put', 'add', 'delete', 'clear'];
const cachedMethods = new Map();
function getMethod(target, prop) {
    if (!(target instanceof IDBDatabase &&
        !(prop in target) &&
        typeof prop === 'string')) {
        return;
    }
    if (cachedMethods.get(prop))
        return cachedMethods.get(prop);
    const targetFuncName = prop.replace(/FromIndex$/, '');
    const useIndex = prop !== targetFuncName;
    const isWrite = writeMethods.includes(targetFuncName);
    if (
    // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
    !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||
        !(isWrite || readMethods.includes(targetFuncName))) {
        return;
    }
    const method = async function (storeName, ...args) {
        // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(
        const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');
        let target = tx.store;
        if (useIndex)
            target = target.index(args.shift());
        // Must reject if op rejects.
        // If it's a write operation, must reject if tx.done rejects.
        // Must reject with op rejection first.
        // Must resolve with op value.
        // Must handle both promises (no unhandled rejections)
        return (await Promise.all([
            target[targetFuncName](...args),
            isWrite && tx.done,
        ]))[0];
    };
    cachedMethods.set(prop, method);
    return method;
}
replaceTraps((oldTraps) => ({
    ...oldTraps,
    get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),
    has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),
}));

const advanceMethodProps = ['continue', 'continuePrimaryKey', 'advance'];
const methodMap = {};
const advanceResults = new WeakMap();
const ittrProxiedCursorToOriginalProxy = new WeakMap();
const cursorIteratorTraps = {
    get(target, prop) {
        if (!advanceMethodProps.includes(prop))
            return target[prop];
        let cachedFunc = methodMap[prop];
        if (!cachedFunc) {
            cachedFunc = methodMap[prop] = function (...args) {
                advanceResults.set(this, ittrProxiedCursorToOriginalProxy.get(this)[prop](...args));
            };
        }
        return cachedFunc;
    },
};
async function* iterate(...args) {
    // tslint:disable-next-line:no-this-assignment
    let cursor = this;
    if (!(cursor instanceof IDBCursor)) {
        cursor = await cursor.openCursor(...args);
    }
    if (!cursor)
        return;
    cursor = cursor;
    const proxiedCursor = new Proxy(cursor, cursorIteratorTraps);
    ittrProxiedCursorToOriginalProxy.set(proxiedCursor, cursor);
    // Map this double-proxy back to the original, so other cursor methods work.
    reverseTransformCache.set(proxiedCursor, unwrap(cursor));
    while (cursor) {
        yield proxiedCursor;
        // If one of the advancing methods was not called, call continue().
        cursor = await (advanceResults.get(proxiedCursor) || cursor.continue());
        advanceResults.delete(proxiedCursor);
    }
}
function isIteratorProp(target, prop) {
    return ((prop === Symbol.asyncIterator &&
        instanceOfAny(target, [IDBIndex, IDBObjectStore, IDBCursor])) ||
        (prop === 'iterate' && instanceOfAny(target, [IDBIndex, IDBObjectStore])));
}
replaceTraps((oldTraps) => ({
    ...oldTraps,
    get(target, prop, receiver) {
        if (isIteratorProp(target, prop))
            return iterate;
        return oldTraps.get(target, prop, receiver);
    },
    has(target, prop) {
        return isIteratorProp(target, prop) || oldTraps.has(target, prop);
    },
}));

// Chat
async function getCachedChats() {
    return [];
}
async function persistChats(chats) {
    return;
}
async function persistChat(chat) {
    return;
}
async function updateChatSyncState() {
    return;
}
// Message
async function getCachedMessages(chatId) {
    return [];
}
async function persistMessages(chatId, messages) {
    return;
}
async function persistMessage(chatId, message) {
    return;
}
async function updateMessageSyncState(chatId) {
    return;
}
async function invalidateMessageSyncState(chatId) {
    return;
}
// User
async function getCachedUser(channel, userId) {
    return null;
}
async function persistUser(channel, userId, user) {
    return;
}
async function getCachedMetadata(type) {
    return null;
}
async function persistMetadata(type, data) {
    return;
}
// Media
async function getCachedMedia(channel, sessionId, messageId) {
    return null;
}
async function persistMedia(channel, sessionId, messageId, arrayBuffer, contentType) {
    return;
}

function getProfile({ connectionId, token }) {
    const url = `/auth/profile`;
    return quickMessage.apiServiceZdesk({ connectionId, token }).get(url);
}
const default_path = '/business-users';
function getBusinessUsers({ connectionId, token, data }) {
    const params = transformApiRequestPayload(data);
    return quickMessage.apiServiceZdesk({ connectionId, token }).get(default_path, {
        params
    });
}
const transformApiRequestPayload = (payload) => {
    try {
        const transformedPayload = {};
        for (const [key, value] of Object.entries(payload)) {
            if (value !== undefined && value !== null) {
                transformedPayload[key] = value;
            }
        }
        return transformedPayload;
    }
    catch (error) {
        console.error('Error transforming API request payload:', error);
        return payload;
    }
};
const default_path_group = '/business-groups';
function getBusinessGroups({ connectionId, token, data }) {
    const params = transformApiRequestPayload(data);
    return quickMessage.apiServiceZdesk({ connectionId, token }).get(default_path_group, {
        params
    });
}

var business = /*#__PURE__*/Object.freeze({
    __proto__: null,
    getBusinessGroups: getBusinessGroups,
    getBusinessUsers: getBusinessUsers,
    getProfile: getProfile,
    transformApiRequestPayload: transformApiRequestPayload
});

const defaultPath$1 = '/customer-custom-field-configs';
async function postCustomerCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPath$1, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postCustomerCustomFieldConfigs');
}
async function getCustomerCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPath$1, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getCustomerCustomFieldConfigs');
}
async function patchCustomerCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPath$1, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchCustomerCustomFieldConfigs');
}
async function putCustomerCustomFieldConfigsOrder(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).put(`${defaultPath$1}/order`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putCustomerCustomFieldConfigsOrder');
}
async function deleteCustomerCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPath$1, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteCustomerCustomFieldConfigs');
}
async function getCustomerCustomFieldConfigsCustomer(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(`${defaultPath$1}/customer`, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getCustomerCustomFieldConfigsCustomer');
}
const defaultPathCustomerCustomFields = '/customer-custom-fields';
async function postCustomerCustomField(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathCustomerCustomFields, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postCustomerCustomField');
}
async function getCustomerCustomField(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathCustomerCustomFields, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getCustomerCustomField');
}
async function patchCustomerCustomField(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathCustomerCustomFields, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchCustomerCustomField');
}
const defaultPathCustomerComment = '/customer-comment';
async function getCustomerComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathCustomerComment, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getCustomerComment');
}
async function postCustomerComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathCustomerComment, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postCustomerComment');
}
async function patchCustomerComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathCustomerComment, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchCustomerComment');
}
async function deleteCustomerComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathCustomerComment, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteCustomerComment');
}
const defaultPathCustomerCommentReply = '/customer-reply-comment';
async function postCustomerCommentReply(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathCustomerCommentReply, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postCustomerCommentReply');
}
async function patchCustomerCommentReply(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathCustomerCommentReply, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchCustomerCommentReply');
}
async function deleteCustomerCommentReply(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathCustomerCommentReply, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteCustomerCommentReply');
}
const defaultPathCustomerCommentLog = '/customer-comment-log';
async function getCustomerCommentLog(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathCustomerCommentLog, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getCustomerCommentLog');
}
const defaultPathTagConfigs = '/customer-tag-configs';
async function postCustomerTagConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathTagConfigs, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postCustomerTagConfigs');
}
async function getCustomerTagConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathTagConfigs, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getCustomerTagConfigs');
}
async function deleteCustomerTagConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathTagConfigs, { data: payload.data });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteCustomerTagConfigs');
}

var customer = /*#__PURE__*/Object.freeze({
    __proto__: null,
    deleteCustomerComment: deleteCustomerComment,
    deleteCustomerCommentReply: deleteCustomerCommentReply,
    deleteCustomerCustomFieldConfigs: deleteCustomerCustomFieldConfigs,
    deleteCustomerTagConfigs: deleteCustomerTagConfigs,
    getCustomerComment: getCustomerComment,
    getCustomerCommentLog: getCustomerCommentLog,
    getCustomerCustomField: getCustomerCustomField,
    getCustomerCustomFieldConfigs: getCustomerCustomFieldConfigs,
    getCustomerCustomFieldConfigsCustomer: getCustomerCustomFieldConfigsCustomer,
    getCustomerTagConfigs: getCustomerTagConfigs,
    patchCustomerComment: patchCustomerComment,
    patchCustomerCommentReply: patchCustomerCommentReply,
    patchCustomerCustomField: patchCustomerCustomField,
    patchCustomerCustomFieldConfigs: patchCustomerCustomFieldConfigs,
    postCustomerComment: postCustomerComment,
    postCustomerCommentReply: postCustomerCommentReply,
    postCustomerCustomField: postCustomerCustomField,
    postCustomerCustomFieldConfigs: postCustomerCustomFieldConfigs,
    postCustomerTagConfigs: postCustomerTagConfigs,
    putCustomerCustomFieldConfigsOrder: putCustomerCustomFieldConfigsOrder
});

const defaultPath = '/ticket';
async function getTicket(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPath, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicket');
}
async function postTicketFilter(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(`${defaultPath}/filter`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketFilter');
}
async function putTicket(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).put(defaultPath, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTicket');
}
async function putTransferTicket(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).put(`${defaultPath}/transfer`, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTransferTicket');
}
async function patchUpdateStatusTicket(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(`${defaultPath}/status`, payload.data);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchUpdateStatusTicket');
}
const defaultPathCustomField = '/ticket-custom-fields';
async function postTicketCustomField(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathCustomField, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketCustomField');
}
async function getTicketCustomField(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathCustomField, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketCustomField');
}
async function patchTicketCustomField(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathCustomField, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketCustomField');
}
async function putTicketCustomFieldBatchUpdate(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).put(`${defaultPathCustomField}/batch-update`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTicketCustomFieldBatchUpdate');
}
const defaultPathCustomFieldConfig = '/ticket-custom-field-configs';
async function postTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathCustomFieldConfig, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketCustomFieldConfigs');
}
async function getTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathCustomFieldConfig, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketCustomFieldConfigs');
}
async function patchTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathCustomFieldConfig, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketCustomFieldConfigs');
}
async function putTicketCustomFieldConfigsOrder(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).put(`${defaultPathCustomFieldConfig}/order`, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to putTicketCustomFieldConfigsOrder');
}
async function deleteTicketCustomFieldConfigs(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathCustomFieldConfig, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketCustomFieldConfigs');
}
const defaultPathTicketComment = '/ticket-comment';
async function getTicketComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathTicketComment, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketComment');
}
async function postTicketComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathTicketComment, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketComment');
}
async function patchTicketComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathTicketComment, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketComment');
}
async function deleteTicketComment(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathTicketComment, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketComment');
}
const defaultPathTicketReply = '/ticket-reply-comment';
async function postTicketCommentReply(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathTicketReply, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketCommentReply');
}
async function patchTicketCommentReply(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).patch(defaultPathTicketReply, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to patchTicketCommentReply');
}
async function deleteTicketCommentReply(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathTicketReply, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketCommentReply');
}
const defaultPathTicketCommentLog = '/ticket-comment-logs';
async function getTicketCommentLog(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathTicketCommentLog, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketCommentLog');
}
const defaultPathTicketActivities = '/ticket-activities';
async function getTicketActivities(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(`${defaultPathTicketActivities}/info`, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketActivities');
}
const defaultPathTicketFollowing = '/ticket-following';
async function deleteTicketFollowing(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathTicketFollowing, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketFollowing');
}
async function createTicketFollowing(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathTicketFollowing, { ...payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to createTicketFollowing');
}
const defaultPathTicketStatus = '/ticket-status';
async function getTicketStatusSetting(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).get(defaultPathTicketStatus, {
        params: payload
    });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to getTicketStatusSetting');
}
async function postTicketStatusSetting(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).post(defaultPathTicketStatus, payload);
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to postTicketStatusSetting');
}
async function deleteTicketStatusSetting(service, payload) {
    const { data, status } = await quickMessage.apiServiceZdesk(service).delete(defaultPathTicketStatus, { data: payload });
    // Status code 20x is success
    if (status.toString().startsWith('20')) {
        return data;
    }
    throw new Error('Failed to deleteTicketStatusSetting');
}

var ticket = /*#__PURE__*/Object.freeze({
    __proto__: null,
    createTicketFollowing: createTicketFollowing,
    deleteTicketComment: deleteTicketComment,
    deleteTicketCommentReply: deleteTicketCommentReply,
    deleteTicketCustomFieldConfigs: deleteTicketCustomFieldConfigs,
    deleteTicketFollowing: deleteTicketFollowing,
    deleteTicketStatusSetting: deleteTicketStatusSetting,
    getTicket: getTicket,
    getTicketActivities: getTicketActivities,
    getTicketComment: getTicketComment,
    getTicketCommentLog: getTicketCommentLog,
    getTicketCustomField: getTicketCustomField,
    getTicketCustomFieldConfigs: getTicketCustomFieldConfigs,
    getTicketStatusSetting: getTicketStatusSetting,
    patchTicketComment: patchTicketComment,
    patchTicketCommentReply: patchTicketCommentReply,
    patchTicketCustomField: patchTicketCustomField,
    patchTicketCustomFieldConfigs: patchTicketCustomFieldConfigs,
    patchUpdateStatusTicket: patchUpdateStatusTicket,
    postTicketComment: postTicketComment,
    postTicketCommentReply: postTicketCommentReply,
    postTicketCustomField: postTicketCustomField,
    postTicketCustomFieldConfigs: postTicketCustomFieldConfigs,
    postTicketFilter: postTicketFilter,
    postTicketStatusSetting: postTicketStatusSetting,
    putTicket: putTicket,
    putTicketCustomFieldBatchUpdate: putTicketCustomFieldBatchUpdate,
    putTicketCustomFieldConfigsOrder: putTicketCustomFieldConfigsOrder,
    putTransferTicket: putTransferTicket
});

var index$1 = /*#__PURE__*/Object.freeze({
    __proto__: null,
    business: business,
    customer: customer,
    ticket: ticket
});

const getChats = async (params) => {
    const { connections, lastAnswerByIds, statusIds, tagIds, userIds, zrmzCustomerIds, verifySlip, verifySlipValue, ...rest } = params;
    if (connections?.length === 0) {
        return {
            chats: []
        };
    }
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    let verifySlipParams = {};
    if (verifySlip && verifySlipValue) {
        if (verifySlip === 'total_completed_verify_slip') {
            verifySlipParams = { total_completed_verify_slip: verifySlipValue };
        }
        else {
            verifySlipParams = { total_completed_verify_slip_more_than: verifySlipValue };
        }
    }
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat`, {
        params: {
            ...rest,
            session_id: params.sessionId,
            connections: connections && connections.length > 0 ? JSON.stringify(connections.map(connection => ({
                id: connection.id,
                channel: connection.channel
            }))) : undefined,
            last_answer_by_id: lastAnswerByIds && lastAnswerByIds.length === utils.configStore.get('memberList').length
                ? undefined
                : lastAnswerByIds,
            status_id: statusIds,
            tag_id: tagIds,
            user_id: userIds ? [...new Set(userIds)] : [],
            zrmz_customer_id: zrmzCustomerIds,
            ...verifySlipParams,
        },
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChats');
};
const searchChats = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/search`, { params });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to searchChats');
};
const getChatByUserId = async (params) => {
    const { userId } = params;
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/user`, {
        params: {
            user_id: userId,
        }
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChat');
};
const getChat = async (params) => {
    const { sessionId } = params;
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/${sessionId}`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChat');
};
const updateChat = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId, ...rest } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/chat/${sessionId}`, rest);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateUser');
};
const translateChatMessage = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId, text, messageIds } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/translate`, {
        text,
        message_ids: messageIds,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateUser');
};
const getChatMessages = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId, startMessageId, ...rest } = params;
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/${sessionId}/message`, {
        params: {
            start_message_id: startMessageId,
            ...rest,
        },
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChatMessages');
};
const searchChatMessages = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId, search } = params;
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/${sessionId}/search-message`, { params: { search } });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to searchChatMessages');
};
const getChatFiles = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/${sessionId}/files`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChatFiles');
};
const sendMessage = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId, messages } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/send-message`, {
        messages: (messages || []).map(({ mimeType, replyMessageId, buttons, menu_list, packageId, stickerId, fileId, ...rest }) => ({
            ...rest,
            package_id: packageId,
            sticker_id: stickerId,
            file_id: fileId,
            mime_type: mimeType,
            reply_message_id: replyMessageId,
            buttons: (buttons || undefined)?.map(({ action_type, text, action }) => ({ alt_text: text, action_type, text, action: action || undefined })),
            menu_list: (menu_list || undefined)?.map(({ file_url, file_id, title, description, buttons }) => ({ file_url, file_id, title, description, buttons: (buttons || []).map(({ action_type, text, action }) => ({ action_type, text, action: action || undefined })), })),
        })),
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to sendMessage');
};
const readMessage = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/read`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to readMessage');
};
const unReadMessage = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/mark-as-unread`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to unReadMessage');
};
const getMessageMedia = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { channel, sessionId, messageId, file } = params;
    // Check in-memory cache first (fastest)
    const cached = blobCache.get(channel, sessionId, messageId);
    if (cached) {
        if (cached.hasError) {
            return null;
        }
        return cached;
    }
    // Check if there's already a pending request for this media
    const pending = blobCache.getPending(channel, sessionId, messageId);
    if (pending) {
        return pending;
    }
    try {
        const idbCached = await getCachedMedia();
        if (idbCached) {
            const blob = new Blob([idbCached.arrayBuffer], { type: idbCached.contentType });
            const blobUrl = URL.createObjectURL(blob);
            const blobType = quickMessage.getFileTypeFromMime(blob.type);
            blobCache.set(channel, sessionId, messageId, blobUrl, blobType);
            return { url: blobUrl, type: blobType };
        }
    }
    catch (error) {
        console.warn('IndexedDB read failed — fall through to network', error);
    }
    // Create the fetch promise
    const fetchPromise = (async () => {
        const baseUrl = utils.BASE_URL();
        const isExternalUrl = file?.url && !file.url.includes(baseUrl);
        const url = file ? file.url : `${baseUrl}/api/${businessId}/${shopId}/${channel}/${sessionId}/${messageId}/content`;
        let attempts = 0;
        const maxRetries = isExternalUrl ? 1 : 3;
        while (attempts < maxRetries) {
            try {
                const response = await quickMessage.axios.get(url, { responseType: 'arraybuffer' });
                const arrayBuffer = response.data;
                const contentType = response.headers['content-type'];
                const blob = new Blob([arrayBuffer], { type: contentType });
                const blobUrl = URL.createObjectURL(blob);
                const blobType = quickMessage.getFileTypeFromMime(blob.type);
                blobCache.set(channel, sessionId, messageId, blobUrl, blobType);
                blobCache.cleanup(100);
                if (!isExternalUrl) {
                    persistMedia().catch((error) => {
                        console.warn('Failed to persist media', error);
                    });
                }
                return { url: blobUrl, type: blobType };
            }
            catch (error) {
                attempts++;
                if (isExternalUrl && file?.url) {
                    console.warn('CORS blocked for external URL, using direct URL instead:', file.url);
                    const fileType = file.mime_type ? quickMessage.getFileTypeFromMime(file.mime_type) : { type: 'unknown' };
                    blobCache.set(channel, sessionId, messageId, file.url, fileType);
                    return { url: file.url, type: fileType };
                }
                if (attempts >= maxRetries) {
                    const errorMessage = error instanceof Error ? error.message : 'Failed to fetch media';
                    console.error(`Failed to fetch media after ${maxRetries} attempts`, errorMessage);
                    blobCache.setError(channel, sessionId, messageId);
                    return null;
                }
                await new Promise(resolve => setTimeout(resolve, 500));
            }
        }
        return null;
    })();
    // Store the pending promise
    blobCache.setPending(channel, sessionId, messageId, fetchPromise);
    try {
        return await fetchPromise;
    }
    finally {
        // Clear pending after completion
        blobCache.clearPending(channel, sessionId, messageId);
    }
};
//Waiting for resolve expired attachments from facebook eg. attachments.find((item) => item.type === 'video'|'image').payload.url;
const getMessageAttachment = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { channel, sessionId, messageId } = params;
    const baseUrl = utils.BASE_URL();
    const url = `${baseUrl}/api/${businessId}/${shopId}/${channel}/${sessionId}/${messageId}/attachment`;
    let attempts = 0;
    const maxRetries = 3;
    while (attempts < maxRetries) {
        try {
            const response = await quickMessage.axios.get(url, {
                responseType: 'blob',
            });
            const blobUrl = URL.createObjectURL(response.data);
            return blobUrl;
        }
        catch (error) {
            attempts++;
            if (attempts >= maxRetries) {
                const errorMessage = error instanceof Error ? error.message : 'Failed to fetch attachment';
                console.error(`Failed to fetch attachment after ${maxRetries} attempts`, errorMessage);
                return null;
            }
            await new Promise(resolve => setTimeout(resolve, 500));
        }
    }
    return null;
};
const getUser = async (params) => {
    const { type = 'user', channel, id, sessionId } = params;
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    let route = `user/${channel}/${id}`;
    if (type === 'group') {
        route = `${channel}/group/${id}`;
    }
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/${route}`, { params: { session_id: sessionId } });
    if (status === 200) {
        let addressFormat = null;
        if (data.address && Object.keys(data.address).length > 0) {
            addressFormat = {
                address: data.address ? data.address.address || '' : '',
                province: data.address ? data.address.province || '' : '',
                district: data.address ? data.address.district || '' : '',
                sub_district: data.address ? data.address.sub_district || data.address.subdistrict || '' : '',
                zip_code: data.address ? data.address.zip_code || '' : '',
            };
        }
        return {
            ...data, address: addressFormat
        };
    }
    throw new Error('Failed to getUser');
};
const getActivityLogs = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { type = 'user', channel, id } = params;
    let route = `user/${channel}/${id}/activity-log`;
    if (type === 'group') {
        route = `${channel}/group/${id}/activity_logs`;
    }
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/${route}`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getActivityLogs');
};
const updateUser = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { type = 'user', channel, id } = params;
    let _channel = channel;
    if (type === 'group') {
        _channel = 'line';
    }
    let route = `user/${_channel}/${id}`;
    if (type === 'group') {
        route = `${_channel}/group/${id}`;
    }
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/${route}`, {
        nickname: params.nickname,
        email: params.email,
        phone_number: params.phone_number,
        address: params.address,
        gender: params.gender,
        locale: params.locale,
        note: params.note,
        status_id: params.status_id,
        add_tag_ids: params.add_tag_ids,
        remove_tag_ids: params.remove_tag_ids,
        context: params.context,
        session: params.session,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateUser');
};
const mergeUser = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { matchUserId, matchDecision } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/user/merge`, {
        match_user_id: matchUserId,
        match_decision: matchDecision,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to mergeUser');
};
const unlinkUser = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { zignalUserId, channel, userId } = params;
    const { data, status } = await quickMessage.apiService().request({
        method: 'DELETE',
        url: `api/${businessId}/${shopId}/user/unlink`,
        data: {
            zignal_user_id: zignalUserId,
            channel: channel,
            user_id: userId,
        },
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to unlinkUser');
};
const getUserStatuses = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/user/status`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getUserStatuses');
};
const createUserStatus = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/user/status`, params);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to createUserStatus');
};
const getUserTags = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { search, limit = utils.GET_USER_TAG_PAGE_LIMIT, offset = 0 } = params;
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/user/tag`, { params: { search, limit, offset } });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getUserTags');
};
const createUserTag = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/user/tag`, params);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to createUserTag');
};
const updateUserStatus = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, ...rest } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/user/status/${id}`, rest);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateUserStatus');
};
const deleteUserStatus = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, force, checkOnly } = params;
    const { data, status } = await quickMessage.apiService().delete(`api/${businessId}/${shopId}/user/status/${id}`, {
        data: { force, check_only: checkOnly }
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to deleteUserStatus');
};
const reorderUserStatus = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, sequence } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/user/status/${id}`, {
        sequence
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to reorderUserStatus');
};
const resequenceUserStatus = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/user/status/resequence`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to resequenceUserStatus');
};
const updateUserTag = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, ...rest } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/user/tag/${id}`, rest);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateUserTag');
};
const deleteUserTag = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, force, checkOnly } = params;
    const { data, status } = await quickMessage.apiService().delete(`api/${businessId}/${shopId}/user/tag/${id}`, {
        data: { force, check_only: checkOnly }
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to deleteUserTag');
};
const reorderUserTag = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, sequence } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/user/tag/${id}`, {
        sequence
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to reorderUserTag');
};
const resequenceUserTag = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/user/tag/resequence`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to resequenceUserTag');
};
const createUserContext = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/user/context`, params);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to createUserContext');
};
const saveUserEvent = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/zwiz/save-user-event`, params);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to saveUserEvent');
};
const getReplyTokenInfo = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/${sessionId}/reply-token-info`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getReplyTokenInfo');
};
const syncMessage = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/sync-message`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to syncMessage');
};
const syncTags = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { sessionId } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/${sessionId}/sync-tag`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to syncTags');
};
const syncUser = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { channel, id } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/user/${channel}/${id}/sync`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to syncUser');
};
// Custom Filter API Functions
const getChatFilters = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/filters`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChatFilters');
};
const createChatFilter = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { connections, last_answer_by_ids, status_ids, tag_ids, ...rest } = params;
    const { data, status } = await quickMessage.apiService().post(`api/${businessId}/${shopId}/chat/filters`, {
        ...rest,
        connections,
        last_answer_by_ids,
        status_ids,
        tag_ids,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to createChatFilter');
};
const updateChatFilter = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { id, connections, last_answer_by_ids, status_ids, tag_ids, ...rest } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/${businessId}/${shopId}/chat/filters/${id}`, {
        ...rest,
        connections,
        last_answer_by_ids,
        status_ids,
        tag_ids,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateChatFilter');
};
const deleteChatFilter = async (params) => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().delete(`api/${businessId}/${shopId}/chat/filters/${params.id}`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to deleteChatFilter');
};
const getChatFilterConfig = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/chat/filter-config`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getChatFilterConfig');
};
const getShopUrl = async ({ connectionId, channel, userId, urlType }) => {
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/${connectionId}/shop-url`, {
        channel,
        user_id: userId,
        url_type: urlType,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getShopUrl');
};
const initConnection = async (params) => {
    const { channel, connectionId, syncChatMessage = true, syncTag = true } = params;
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const url = `api/connection/${businessId}/${shopId}/${channel}/${connectionId}/init`;
    const { status, data } = await quickMessage.apiService().post(url, channel === 'facebook' ? {
        sync_chat_message: syncChatMessage,
        sync_tag: syncTag
    } : {});
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to initConnection');
};
const getConnectionJobs = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/connection/${businessId}/${shopId}/job`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getConnectionJobs');
};
const deleteConnectionJob = async (params) => {
    const { connectionId } = params;
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const url = `api/connection/${businessId}/${shopId}/job/${connectionId}`;
    const { status, data } = await quickMessage.apiService().delete(url);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to deleteConnectionJob');
};
const getUserCart = async (params) => {
    const { connectionId, channel, userId } = params;
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/${connectionId}/user/${channel}/${userId}/cart`);
    if (status === 200) {
        return data.carts;
    }
    throw new Error('Failed to getUserCart');
};
const clearUserCart = async (params) => {
    const { connectionId, channel, userId } = params;
    const { data, status } = await quickMessage.apiService().delete(`api/zwiz/${connectionId}/user/${channel}/${userId}/cart`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to clearUserCart');
};
const getZwizCheckBotPage = async (connectionId) => {
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/${connectionId}/check-bot-page`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZwizCheckBotPage');
};
const getZervaProfile = async (connectionId) => {
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/zerva/${connectionId}/profile`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZervaProfile');
};
const getZervaShopUrl = async (connectionId, params) => {
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/zerva/${connectionId}/shop-url`, params);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZervaShopUrl');
};
const getZrmzShopUrl = async (connectionId, params) => {
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/zrmz/${connectionId}/shop-url`, params);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZrmzShopUrl');
};
const getZrmzShopProfile = async (connectionId) => {
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/zrmz/${connectionId}/profile`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZrmzShopProfile');
};
const getZrmzCustomerInfo = async (connectionId, customerId) => {
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/zrmz/${connectionId}/customer`, {
        params: {
            customer_id: customerId,
        },
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZrmzCustomerInfo');
};
const getZrmzPointHistory = async (params) => {
    const { connectionId, customerId, limit, offset } = params;
    const { data, status } = await quickMessage.apiService().get(`/api/zwiz/zrmz/${connectionId}/point-history`, {
        params: {
            customer_id: customerId,
            limit,
            offset,
        },
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZrmzPointHistory');
};
const createZrmzCustomer = async (params) => {
    const { connectionId, ...rest } = params;
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/zrmz/${connectionId}/customer`, rest);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to createZrmzCustomer');
};
const getZwizUserProfile = async (connectionId, channel, userId) => {
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/${connectionId}/get-user-only`, {
        params: {
            channel,
            user_id: userId,
        },
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZwizUserProfile');
};
const updateZrmzCustomer = async (params) => {
    const { connectionId, customer_id, ...rest } = params;
    const { data, status } = await quickMessage.apiService().patch(`api/zwiz/zrmz/${connectionId}/customer`, {
        customer_id,
        ...rest,
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to updateZrmzCustomer');
};
const disconnectZrmzCustomer = async (params) => {
    const { connectionId, ...rest } = params;
    const { data, status } = await quickMessage.apiService().request({
        method: 'DELETE',
        url: `api/zwiz/zrmz/${connectionId}/disconnect-customer`,
        data: rest
    });
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to disconnectZrmzCustomer');
};
const getZrmzCondition = async (params) => {
    const { connectionId } = params;
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/zrmz/${connectionId}/condition`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getZrmzCondition');
};
const adjustZrmzCustomerPoint = async (params) => {
    const { connectionId, ...rest } = params;
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/zrmz/${connectionId}/adjust-point`, rest);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to adjustZrmzCustomerPoint');
};
const adjustZrmzCustomerPointByCondition = async (params) => {
    const { connectionId, ...rest } = params;
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/zrmz/${connectionId}/adjust-point-by-condition`, rest);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to adjustZrmzCustomerPointByCondition');
};
const getUserOrders = async (params) => {
    const { connectionId, channel, userId } = params;
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/${connectionId}/user/${channel}/${userId}/order`);
    if (status === 200) {
        return data.orders;
    }
    throw new Error('Failed to getUserOrders');
};
const updateUserOrder = async (params) => {
    const { connectionId, channel, userId, orderId, amount, status, trackingNo, sendTrackingStatus, reason, sendReason, shipping_address } = params;
    const data = {};
    if (amount !== undefined) {
        data.amount = amount;
    }
    if (status !== undefined) {
        data.status = status;
        // Add tracking number and send tracking status only if status is 'shipped'
        if (status === 'shipped') {
            if (trackingNo !== undefined && trackingNo.length > 0) {
                data.tracking_no = trackingNo;
            }
            if (sendTrackingStatus !== undefined) {
                data.send_tracking_status = sendTrackingStatus;
            }
        }
        // Add reason and send reason only if status is 'canceled'
        if (status === 'canceled') {
            if (reason !== undefined && reason.length > 0) {
                data.reason = reason;
            }
            if (sendReason !== undefined) {
                data.send_reason = sendReason;
            }
        }
    }
    if (shipping_address !== undefined) {
        data.shipping_address = shipping_address;
    }
    const { data: responseData, status: responseStatus } = await quickMessage.apiService().patch(`api/zwiz/${connectionId}/user/${channel}/${userId}/order/${orderId}`, data);
    if (responseStatus === 200) {
        return responseData;
    }
    throw new Error('Failed to updateUserOrder');
};
const getUserToken = async (params) => {
    const { connectionId } = params;
    const userInfo = utils.userInfosStore.get(connectionId);
    if (userInfo?.token?.access_token) {
        return userInfo.token;
    }
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/${connectionId}/user/token`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getUserToken');
};
const getPlatformConnections = async () => {
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().get(`api/zwiz/${businessId}/${shopId}/platform-connection`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getPlatformConnections');
};
const getSessionToken = async (params) => {
    const { connectionId, botId, channel, type, userId, groupId } = params;
    const cacheKey = [connectionId, botId, channel, type, userId || '', groupId || ''].join('::');
    const cachedToken = utils.sessionTokensStore.get(cacheKey);
    if (cachedToken?.token && cachedToken.cachedAt) {
        const isExpired = Date.now() - cachedToken.cachedAt >= utils.CACHE_LIMITS.SESSION_TOKEN_TTL_MS;
        if (!isExpired) {
            return cachedToken.token;
        }
        utils.sessionTokensStore.set(cacheKey, {});
    }
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    const { data, status } = await quickMessage.apiService().post(`api/zwiz/${businessId}/${shopId}/${connectionId}/${channel}/get-session-token`, {
        bot_id: botId,
        type,
        user_id: userId,
        group_id: groupId,
    });
    if (status === 200) {
        utils.sessionTokensStore.set(cacheKey, { token: data, cachedAt: Date.now() });
        return data;
    }
    throw new Error('Failed to getSessionToken');
};
const getGroupMembers = async (params) => {
    const { type = 'user', channel, id } = params;
    const businessId = utils.configStore.get('businessId');
    const shopId = utils.configStore.get('shopId');
    if (type !== 'group')
        return;
    const route = `${channel}/group/${id}/member`;
    const { data, status } = await quickMessage.apiService().get(`api/${businessId}/${shopId}/${route}`);
    if (status === 200) {
        return data;
    }
    throw new Error('Failed to getUser');
};

var index = /*#__PURE__*/Object.freeze({
    __proto__: null,
    adjustZrmzCustomerPoint: adjustZrmzCustomerPoint,
    adjustZrmzCustomerPointByCondition: adjustZrmzCustomerPointByCondition,
    clearUserCart: clearUserCart,
    createChatFilter: createChatFilter,
    createQuickMessageLibraryFiles: quickMessage.createQuickMessageLibraryFiles,
    createQuickMessageTemplate: quickMessage.createQuickMessageTemplate,
    createUserContext: createUserContext,
    createUserStatus: createUserStatus,
    createUserTag: createUserTag,
    createZrmzCustomer: createZrmzCustomer,
    deleteChatFilter: deleteChatFilter,
    deleteConnectionJob: deleteConnectionJob,
    deleteQuickMessageTemplate: quickMessage.deleteQuickMessageTemplate,
    deleteUserStatus: deleteUserStatus,
    deleteUserTag: deleteUserTag,
    disconnectZrmzCustomer: disconnectZrmzCustomer,
    getActivityLogs: getActivityLogs,
    getChat: getChat,
    getChatByUserId: getChatByUserId,
    getChatFiles: getChatFiles,
    getChatFilterConfig: getChatFilterConfig,
    getChatFilters: getChatFilters,
    getChatMessages: getChatMessages,
    getChats: getChats,
    getConnectionJobs: getConnectionJobs,
    getGroupMembers: getGroupMembers,
    getMessageAttachment: getMessageAttachment,
    getMessageMedia: getMessageMedia,
    getPlatformConnections: getPlatformConnections,
    getQuickMessageLibraryFiles: quickMessage.getQuickMessageLibraryFiles,
    getQuickMessageTemplates: quickMessage.getQuickMessageTemplates,
    getReplyTokenInfo: getReplyTokenInfo,
    getSessionToken: getSessionToken,
    getShopUrl: getShopUrl,
    getUser: getUser,
    getUserCart: getUserCart,
    getUserOrders: getUserOrders,
    getUserStatuses: getUserStatuses,
    getUserTags: getUserTags,
    getUserToken: getUserToken,
    getZervaProfile: getZervaProfile,
    getZervaShopUrl: getZervaShopUrl,
    getZrmzCondition: getZrmzCondition,
    getZrmzCustomerInfo: getZrmzCustomerInfo,
    getZrmzPointHistory: getZrmzPointHistory,
    getZrmzShopProfile: getZrmzShopProfile,
    getZrmzShopUrl: getZrmzShopUrl,
    getZwizCheckBotPage: getZwizCheckBotPage,
    getZwizUserProfile: getZwizUserProfile,
    initConnection: initConnection,
    mergeUser: mergeUser,
    readMessage: readMessage,
    reorderUserStatus: reorderUserStatus,
    reorderUserTag: reorderUserTag,
    resequenceUserStatus: resequenceUserStatus,
    resequenceUserTag: resequenceUserTag,
    saveUserEvent: saveUserEvent,
    searchChatMessages: searchChatMessages,
    searchChats: searchChats,
    sendMessage: sendMessage,
    syncMessage: syncMessage,
    syncTags: syncTags,
    syncUser: syncUser,
    translateChatMessage: translateChatMessage,
    unReadMessage: unReadMessage,
    unlinkUser: unlinkUser,
    updateChat: updateChat,
    updateChatFilter: updateChatFilter,
    updateQuickMessageLibraryFileName: quickMessage.updateQuickMessageLibraryFileName,
    updateQuickMessageTemplate: quickMessage.updateQuickMessageTemplate,
    updateUser: updateUser,
    updateUserOrder: updateUserOrder,
    updateUserStatus: updateUserStatus,
    updateUserTag: updateUserTag,
    updateZrmzCustomer: updateZrmzCustomer,
    zdesk: index$1
});

exports.adjustZrmzCustomerPoint = adjustZrmzCustomerPoint;
exports.adjustZrmzCustomerPointByCondition = adjustZrmzCustomerPointByCondition;
exports.blobCache = blobCache;
exports.clearUserCart = clearUserCart;
exports.createChatFilter = createChatFilter;
exports.createTicketFollowing = createTicketFollowing;
exports.createUserStatus = createUserStatus;
exports.createUserTag = createUserTag;
exports.createZrmzCustomer = createZrmzCustomer;
exports.deleteChatFilter = deleteChatFilter;
exports.deleteConnectionJob = deleteConnectionJob;
exports.deleteCustomerComment = deleteCustomerComment;
exports.deleteCustomerCommentReply = deleteCustomerCommentReply;
exports.deleteTicketComment = deleteTicketComment;
exports.deleteTicketCommentReply = deleteTicketCommentReply;
exports.deleteTicketFollowing = deleteTicketFollowing;
exports.deleteUserStatus = deleteUserStatus;
exports.deleteUserTag = deleteUserTag;
exports.disconnectZrmzCustomer = disconnectZrmzCustomer;
exports.getActivityLogs = getActivityLogs;
exports.getBusinessGroups = getBusinessGroups;
exports.getBusinessUsers = getBusinessUsers;
exports.getCachedChats = getCachedChats;
exports.getCachedMessages = getCachedMessages;
exports.getCachedMetadata = getCachedMetadata;
exports.getCachedUser = getCachedUser;
exports.getChat = getChat;
exports.getChatByUserId = getChatByUserId;
exports.getChatFiles = getChatFiles;
exports.getChatFilterConfig = getChatFilterConfig;
exports.getChatFilters = getChatFilters;
exports.getChatMessages = getChatMessages;
exports.getChats = getChats;
exports.getConnectionJobs = getConnectionJobs;
exports.getCustomerComment = getCustomerComment;
exports.getCustomerCustomFieldConfigsCustomer = getCustomerCustomFieldConfigsCustomer;
exports.getGroupMembers = getGroupMembers;
exports.getMessageMedia = getMessageMedia;
exports.getPlatformConnections = getPlatformConnections;
exports.getProfile = getProfile;
exports.getReplyTokenInfo = getReplyTokenInfo;
exports.getSessionToken = getSessionToken;
exports.getShopUrl = getShopUrl;
exports.getTicket = getTicket;
exports.getTicketActivities = getTicketActivities;
exports.getTicketComment = getTicketComment;
exports.getTicketCustomField = getTicketCustomField;
exports.getTicketCustomFieldConfigs = getTicketCustomFieldConfigs;
exports.getTicketStatusSetting = getTicketStatusSetting;
exports.getUser = getUser;
exports.getUserCart = getUserCart;
exports.getUserOrders = getUserOrders;
exports.getUserStatuses = getUserStatuses;
exports.getUserTags = getUserTags;
exports.getUserToken = getUserToken;
exports.getZervaProfile = getZervaProfile;
exports.getZervaShopUrl = getZervaShopUrl;
exports.getZrmzCondition = getZrmzCondition;
exports.getZrmzCustomerInfo = getZrmzCustomerInfo;
exports.getZrmzPointHistory = getZrmzPointHistory;
exports.getZrmzShopProfile = getZrmzShopProfile;
exports.getZrmzShopUrl = getZrmzShopUrl;
exports.getZwizCheckBotPage = getZwizCheckBotPage;
exports.getZwizUserProfile = getZwizUserProfile;
exports.index = index;
exports.initConnection = initConnection;
exports.invalidateMessageSyncState = invalidateMessageSyncState;
exports.mergeUser = mergeUser;
exports.openDB = openDB;
exports.patchCustomerComment = patchCustomerComment;
exports.patchCustomerCommentReply = patchCustomerCommentReply;
exports.patchCustomerCustomField = patchCustomerCustomField;
exports.patchTicketComment = patchTicketComment;
exports.patchTicketCommentReply = patchTicketCommentReply;
exports.patchTicketCustomField = patchTicketCustomField;
exports.patchUpdateStatusTicket = patchUpdateStatusTicket;
exports.persistChat = persistChat;
exports.persistChats = persistChats;
exports.persistMessage = persistMessage;
exports.persistMessages = persistMessages;
exports.persistMetadata = persistMetadata;
exports.persistUser = persistUser;
exports.postCustomerComment = postCustomerComment;
exports.postCustomerCommentReply = postCustomerCommentReply;
exports.postCustomerCustomField = postCustomerCustomField;
exports.postCustomerTagConfigs = postCustomerTagConfigs;
exports.postTicketComment = postTicketComment;
exports.postTicketCommentReply = postTicketCommentReply;
exports.postTicketCustomField = postTicketCustomField;
exports.putTicket = putTicket;
exports.putTransferTicket = putTransferTicket;
exports.readMessage = readMessage;
exports.reorderUserStatus = reorderUserStatus;
exports.reorderUserTag = reorderUserTag;
exports.resequenceUserStatus = resequenceUserStatus;
exports.resequenceUserTag = resequenceUserTag;
exports.saveUserEvent = saveUserEvent;
exports.searchChatMessages = searchChatMessages;
exports.searchChats = searchChats;
exports.sendMessage = sendMessage;
exports.syncMessage = syncMessage;
exports.syncTags = syncTags;
exports.syncUser = syncUser;
exports.translateChatMessage = translateChatMessage;
exports.unReadMessage = unReadMessage;
exports.unlinkUser = unlinkUser;
exports.updateChat = updateChat;
exports.updateChatFilter = updateChatFilter;
exports.updateChatSyncState = updateChatSyncState;
exports.updateMessageSyncState = updateMessageSyncState;
exports.updateUser = updateUser;
exports.updateUserOrder = updateUserOrder;
exports.updateUserStatus = updateUserStatus;
exports.updateUserTag = updateUserTag;
exports.updateZrmzCustomer = updateZrmzCustomer;
