"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateSystemPackageDependencies = exports.generateLibDependencies = exports.generatePackageDependencies = void 0;
const cals_1 = require("@cloudbase/cals");
const CLOUDBASE_VERSION = '2.19.2';
const BASE_DEPS = {
    'miniprogram-gesture': '^1.0.6',
    mobx: '^5',
    'lodash.get': '^4',
    'lodash.set': '^4',
};
/**
 * 注意锁版本
 */
const CLOUDBASE_DEPS = {
    '@cloudbase/weda-client': '1.1.33',
    '@cloudbase/weda-cloud-sdk': '1.0.104',
};
const COMPONENT_DEPS = {
    '@cloudbase/lowcode-render': '^1.1.10',
};
const SYS_CLOUDBASE_DEPS = {
    '@cloudbase/adapter-wx_mp': '^1.0.3',
    '@cloudbase/auth': CLOUDBASE_VERSION,
    '@cloudbase/ai': CLOUDBASE_VERSION,
};
function generatePackageDependencies({ importJSSDK, mode, officialLibVersion, uin, }) {
    const deps = {};
    if (mode === 'lib') {
        if (importJSSDK) {
            deps['@cloudbase/js-sdk'] = CLOUDBASE_VERSION;
        }
        Object.assign(deps, generateLibDependencies('mp', officialLibVersion));
    }
    else {
        for (const key in CLOUDBASE_DEPS) {
            deps[key] = CLOUDBASE_DEPS[key];
        }
    }
    return {
        ...deps,
        ...BASE_DEPS,
    };
}
exports.generatePackageDependencies = generatePackageDependencies;
function generateLibDependencies(mode, officialLibVersion) {
    const deps = {};
    const modeDeps = mode === 'mp' ? { ...CLOUDBASE_DEPS, ...SYS_CLOUDBASE_DEPS } : COMPONENT_DEPS;
    for (const key in modeDeps) {
        const version = modeDeps[key];
        deps[key] = /^\d/.test(version) ? `^${version}` : version;
    }
    if (officialLibVersion) {
        const officialLibPackageName = mode === 'mp' ? cals_1.OFFICIAL_LIB_MP_NPM_PACKAGENAME : cals_1.OFFICIAL_LIB_NPM_PACKAGENAME;
        deps[officialLibPackageName] = officialLibVersion;
    }
    return deps;
}
exports.generateLibDependencies = generateLibDependencies;
function generateSystemPackageDependencies({ importJSSDK }) {
    const deps = {};
    if (importJSSDK) {
        deps['@cloudbase/js-sdk'] = CLOUDBASE_VERSION;
    }
    return {
        ...deps,
        ...SYS_CLOUDBASE_DEPS,
    };
}
exports.generateSystemPackageDependencies = generateSystemPackageDependencies;
