"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = function(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 = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(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__, {
    PluginDetail: ()=>PluginDetail
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const external_antd_namespaceObject = require("antd");
const external_dayjs_namespaceObject = require("dayjs");
var external_dayjs_default = /*#__PURE__*/ __webpack_require__.n(external_dayjs_namespaceObject);
const relativeTime_namespaceObject = require("dayjs/plugin/relativeTime");
var relativeTime_default = /*#__PURE__*/ __webpack_require__.n(relativeTime_namespaceObject);
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../../api-client/index.js");
const external_PluginDocument_js_namespaceObject = require("./PluginDocument.js");
const external_style_js_namespaceObject = require("./style.js");
external_dayjs_default().extend(relativeTime_default());
const PluginDetail = (param)=>{
    let { plugin, onCancel } = param;
    var _data_data, _data_data1, _data_data2, _data_data3, _data_data4, _data_data5, _data_data6, _data_data7, _data_data8, _data_data9;
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const dependenciesCompatibleTableColumns = (0, external_react_namespaceObject.useMemo)(()=>[
            {
                title: t('Name'),
                dataIndex: 'name',
                key: 'name'
            },
            {
                title: t('Version range'),
                dataIndex: 'versionRange',
                key: 'versionRange'
            },
            {
                title: t("Plugin's version"),
                dataIndex: 'packageVersion',
                key: 'packageVersion'
            },
            {
                title: t('Result'),
                dataIndex: 'result',
                key: 'result',
                render: (result)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tag, {
                        color: result ? 'success' : 'error',
                        children: result ? 'Yes' : 'No'
                    })
            }
        ], [
        t
    ]);
    const { data, loading } = (0, index_js_namespaceObject.useRequest)({
        url: "pm:get",
        params: {
            filterByTk: plugin.name
        }
    }, {
        refreshDeps: [
            plugin.name
        ],
        ready: !!plugin.name
    });
    const repository = (0, external_react_namespaceObject.useMemo)(()=>{
        var _data_data_packageJson, _data_data, _data_data1;
        if (!(null == data ? void 0 : null === (_data_data = data.data) || void 0 === _data_data ? void 0 : null === (_data_data_packageJson = _data_data.packageJson) || void 0 === _data_data_packageJson ? void 0 : _data_data_packageJson.repository)) return null;
        const repository = null == data ? void 0 : null === (_data_data1 = data.data) || void 0 === _data_data1 ? void 0 : _data_data1.packageJson.repository;
        const url = 'string' == typeof repository ? repository : repository.url;
        return url.replace(/\.git$/, '').replace(/^git\+/, '');
    }, [
        data
    ]);
    const author = (0, external_react_namespaceObject.useMemo)(()=>{
        var _data_data;
        const author = null == data ? void 0 : null === (_data_data = data.data) || void 0 === _data_data ? void 0 : _data_data.packageJson.author;
        if (!author) return null;
        if ('string' == typeof author) return author;
        return author.name;
    }, [
        data
    ]);
    const { styles, theme } = (0, external_style_js_namespaceObject.useStyles)();
    const tabItems = [
        {
            key: 'readme',
            label: t('Readme'),
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Row, {
                gutter: 20,
                children: [
                    plugin.name && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 12,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Name')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: plugin.name
                                })
                            ]
                        })
                    }),
                    plugin.displayName && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 12,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('DisplayName')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: plugin.displayName
                                })
                            ]
                        })
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 24,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('PackageName')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: plugin.packageName
                                })
                            ]
                        })
                    }),
                    repository && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 24,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Repository')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: repository
                                })
                            ]
                        })
                    }),
                    (null == data ? void 0 : null === (_data_data = data.data) || void 0 === _data_data ? void 0 : _data_data.packageJson.homepage) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 24,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Homepage')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("a", {
                                    href: null == data ? void 0 : null === (_data_data1 = data.data) || void 0 === _data_data1 ? void 0 : _data_data1.packageJson.homepage,
                                    target: "_blank",
                                    rel: "noreferrer",
                                    children: null == data ? void 0 : null === (_data_data2 = data.data) || void 0 === _data_data2 ? void 0 : _data_data2.packageJson.homepage
                                })
                            ]
                        })
                    }),
                    plugin.description && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 24,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Description')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: plugin.description
                                })
                            ]
                        })
                    }),
                    (null == data ? void 0 : null === (_data_data3 = data.data) || void 0 === _data_data3 ? void 0 : _data_data3.packageJson.license) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 12,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('License')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: null == data ? void 0 : null === (_data_data4 = data.data) || void 0 === _data_data4 ? void 0 : _data_data4.packageJson.license
                                })
                            ]
                        })
                    }),
                    author && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 12,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Author')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: author
                                })
                            ]
                        })
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 12,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Last updated')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: external_dayjs_default()(null == data ? void 0 : null === (_data_data5 = data.data) || void 0 === _data_data5 ? void 0 : _data_data5.lastUpdated).fromNow()
                                })
                            ]
                        })
                    }),
                    /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Col, {
                        span: 12,
                        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            className: styles.PluginDetailBaseInfo,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    type: "secondary",
                                    children: t('Version')
                                }),
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                                    strong: true,
                                    children: null == plugin ? void 0 : plugin.version
                                })
                            ]
                        })
                    })
                ]
            })
        },
        {
            key: 'dependencies',
            label: t('Dependencies compatibility check'),
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
                children: (null == data ? void 0 : null === (_data_data6 = data.data) || void 0 === _data_data6 ? void 0 : _data_data6.depsCompatible) === false ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Text, {
                    type: "danger",
                    children: t('`dist/externalVersion.js` not found or failed to `require`. Please rebuild this plugin.')
                }) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
                    children: [
                        !(null == data ? void 0 : null === (_data_data7 = data.data) || void 0 === _data_data7 ? void 0 : _data_data7['isCompatible']) && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Alert, {
                            showIcon: true,
                            type: 'error',
                            message: t('Plugin dependencies check failed, you should change the dependent version to meet the version requirements.')
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Table, {
                            style: {
                                marginTop: theme.margin
                            },
                            rowKey: 'name',
                            pagination: false,
                            columns: dependenciesCompatibleTableColumns,
                            dataSource: null == data ? void 0 : null === (_data_data8 = data.data) || void 0 === _data_data8 ? void 0 : _data_data8.depsCompatible
                        })
                    ]
                })
            })
        },
        {
            key: 'changelog',
            label: t('Changelog'),
            children: (null == plugin ? void 0 : plugin.changelogUrl) ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_PluginDocument_js_namespaceObject.PluginDocument, {
                url: null == plugin ? void 0 : plugin.changelogUrl
            }) : t('No CHANGELOG.md file')
        }
    ];
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Modal, {
        open: !!plugin,
        footer: false,
        destroyOnClose: true,
        width: 600,
        onCancel: onCancel,
        children: loading ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Spin, {}) : plugin && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
            children: [
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Typography.Title, {
                    level: 3,
                    children: plugin.packageName
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_antd_namespaceObject.Space, {
                    split: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                        children: "\xa0•\xa0"
                    }),
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                            children: plugin.version
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
                            children: [
                                t('Last updated'),
                                " ",
                                external_dayjs_default()(null == data ? void 0 : null === (_data_data9 = data.data) || void 0 === _data_data9 ? void 0 : _data_data9.lastUpdated).fromNow()
                            ]
                        })
                    ]
                }),
                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_antd_namespaceObject.Tabs, {
                    style: {
                        minHeight: '50vh'
                    },
                    items: tabItems,
                    defaultActiveKey: plugin.isCompatible ? void 0 : 'dependencies'
                })
            ]
        })
    });
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
