var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React from 'react';
import p from 'prefix-classname';
import { Button, Divider, Tooltip } from 'antd';
import { MobileOutlined, MobileTwoTone, EditOutlined, EditTwoTone, LinkOutlined } from '@ant-design/icons';
import { createReactBehaviorSubject } from '@rcp/use.behaviorsubject';
import { CLS_PREFIX } from '../../../config/const';
import './style.scss';
import { symbol } from '../../utils/utils';
const cn = p('');
const c = p(`${CLS_PREFIX}-header`);
function createReactBehaviorSubjectStored(d, _a) {
    var { storeKey } = _a, opts = __rest(_a, ["storeKey"]);
    try {
        const prev = JSON.parse(localStorage.getItem(storeKey));
        if (prev && typeof prev === 'object') {
            d = Object.assign(Object.assign({}, d), prev);
        }
    }
    catch (e) { }
    const { useSubject, subject } = createReactBehaviorSubject(d, opts);
    subject.subscribe((value) => {
        localStorage.setItem(storeKey, JSON.stringify(value));
    });
    return {
        subject,
        useSubject
    };
}
const { useSubject, subject } = createReactBehaviorSubjectStored({
    canSelect: false,
    showLocation: true,
    isMobileMode: false
}, { storeKey: symbol(`headerStatus`) });
export const useHeaderStatus = useSubject;
export const headerStatusSubject = subject;
const Header = React.memo(({ className, bundlerURL }) => {
    const [{ canSelect, showLocation, isMobileMode }, setValue] = useHeaderStatus();
    return (React.createElement("div", { className: cn(c(), className) },
        React.createElement("div", { className: c('__logo') },
            React.createElement("a", { target: '_blank', href: 'https://github.com/imcuttle/mometa', style: { color: 'inherit' } }, "mometa")),
        React.createElement(Divider, { type: 'vertical' }),
        React.createElement("div", { className: c('__switch') },
            React.createElement(Tooltip, { title: '编辑模式' },
                React.createElement(Button, { shape: 'circle', onClick: () => setValue((x) => (Object.assign(Object.assign({}, x), { canSelect: !x.canSelect }))), icon: canSelect ? React.createElement(EditTwoTone, null) : React.createElement(EditOutlined, null), type: 'text' })),
            React.createElement(Tooltip, { title: '地址栏' },
                React.createElement(Button, { shape: 'circle', onClick: () => setValue((x) => (Object.assign(Object.assign({}, x), { showLocation: !x.showLocation }))), icon: React.createElement(LinkOutlined, { style: { color: showLocation ? '#1890ff' : '' } }), type: 'text' })),
            React.createElement(Tooltip, { title: '响应式布局' },
                React.createElement(Button, { shape: 'circle', onClick: () => setValue((x) => (Object.assign(Object.assign({}, x), { isMobileMode: !x.isMobileMode }))), icon: isMobileMode ? React.createElement(MobileTwoTone, null) : React.createElement(MobileOutlined, null), type: 'text' }))),
        React.createElement(Divider, { type: 'vertical' }),
        React.createElement(Button, { type: "link", href: bundlerURL, target: '_blank' }, "\u5728\u65B0\u7A97\u53E3\u9884\u89C8")));
});
Header.defaultProps = {};
export default Header;
//# sourceMappingURL=index.js.map