"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    SystemVersionProvider: ()=>SystemVersionProvider
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const external_react_i18next_namespaceObject = require("react-i18next");
const CurrentAppInfoProvider_js_namespaceObject = require("../../common/appInfo/CurrentAppInfoProvider.js");
const CurrentUserSettingsMenuProvider_js_namespaceObject = require("../../user/CurrentUserSettingsMenuProvider.js");
const CORE_REPO_URL = 'https://github.com/tegojs/tego';
const APP_REPO_URL = 'https://github.com/tegojs/tego-standard';
function getVersionUrl(version, repoUrl) {
    if (!version) return null;
    const hashMatch = version.match(/^\d+\.\d+\.\d+-([0-9a-f]{7})(?:@.+)?$/i);
    if (hashMatch) {
        const hash = hashMatch[1];
        return "".concat(repoUrl, "/commit/").concat(hash);
    }
    {
        const tag = version.startsWith('v') ? version : "v".concat(version);
        return "".concat(repoUrl, "/releases/tag/").concat(tag);
    }
}
const CoreVersion = ()=>{
    var _info_data_version, _info_data;
    const info = (0, CurrentAppInfoProvider_js_namespaceObject.useCurrentAppInfo)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const version = null == info ? void 0 : null == (_info_data = info.data) ? void 0 : null == (_info_data_version = _info_data.version) ? void 0 : _info_data_version.core;
    const url = getVersionUrl(version, CORE_REPO_URL);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
        children: [
            t('Core Version'),
            " -",
            ' ',
            url ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
                href: url,
                target: "_blank",
                children: version
            }) : version
        ]
    });
};
const AppVersion = ()=>{
    var _info_data_version, _info_data;
    const info = (0, CurrentAppInfoProvider_js_namespaceObject.useCurrentAppInfo)();
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const version = null == info ? void 0 : null == (_info_data = info.data) ? void 0 : null == (_info_data_version = _info_data.version) ? void 0 : _info_data_version.app;
    const url = getVersionUrl(version, APP_REPO_URL);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
        children: [
            t('App Version'),
            " -",
            ' ',
            url ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
                href: url,
                target: "_blank",
                children: version
            }) : version
        ]
    });
};
const SystemVersionProvider = (param)=>{
    let { children } = param;
    const { addMenuItem } = (0, CurrentUserSettingsMenuProvider_js_namespaceObject.useCurrentUserSettingsMenu)();
    (0, external_react_namespaceObject.useEffect)(()=>{
        addMenuItem({
            key: 'system-version-app',
            label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(AppVersion, {})
        }, {
            before: 'divider_1'
        });
        addMenuItem({
            key: 'system-version-core',
            label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CoreVersion, {})
        }, {
            before: 'divider_1'
        });
    }, [
        addMenuItem
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
        children: children
    });
};
exports.SystemVersionProvider = __webpack_exports__.SystemVersionProvider;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
    "SystemVersionProvider"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
    value: true
});
