"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PageNavigationBar = void 0;
const react_1 = __importStar(require("react"));
const Icon_1 = require("../../../Icon");
const Typography_1 = require("../../../core/Typography");
const constant_1 = require("./constant");
const style_constants_1 = require("../../../constants/style.constants");
const Styled = __importStar(require("./index.styled"));
const BaseNavigation = ({ title, titleColor, leftChildren, rightChildren, zIndex = style_constants_1.zIndex.gnb, backgroundColor, }) => {
    return (react_1.default.createElement(Styled.Wrapper, { backgroundColor: backgroundColor, zIndex: zIndex },
        leftChildren && react_1.default.createElement(Styled.LeftChildrenWrapper, null, leftChildren),
        title && react_1.default.createElement(Typography_1.Headline5, { color: titleColor }, title),
        rightChildren && react_1.default.createElement(Styled.RightChildrenWrapper, null, rightChildren)));
};
const PageNavigationBar = (_a) => {
    var { contentColor, hasBackgroundColor, leftArea, rightArea } = _a, commonProps = __rest(_a, ["contentColor", "hasBackgroundColor", "leftArea", "rightArea"]);
    const iconColor = constant_1.CONTENT_COLOR_MAP[contentColor].icon;
    const titleColor = constant_1.CONTENT_COLOR_MAP[contentColor].title;
    const rightTextColor = constant_1.CONTENT_COLOR_MAP[contentColor].rightText;
    const backgroundColor = constant_1.CONTENT_COLOR_MAP[contentColor].backgroundColor;
    const leftChildren = (0, react_1.useMemo)(() => {
        const handleClickButton = () => {
            leftArea === null || leftArea === void 0 ? void 0 : leftArea.handleClickButton();
        };
        switch (leftArea === null || leftArea === void 0 ? void 0 : leftArea.type) {
            case 'backIcon':
                return (react_1.default.createElement(Styled.IconWrapper, { onClick: handleClickButton },
                    react_1.default.createElement(Icon_1.ChevronLeftMIcon, { fillColor: titleColor })));
            default:
                return;
        }
    }, [leftArea, titleColor]);
    const rightChildren = (0, react_1.useMemo)(() => {
        const handleClickButton = () => {
            rightArea === null || rightArea === void 0 ? void 0 : rightArea.handleClickButton();
        };
        switch (rightArea === null || rightArea === void 0 ? void 0 : rightArea.type) {
            case 'closeIcon':
                return (react_1.default.createElement(Styled.IconWrapper, { onClick: handleClickButton },
                    react_1.default.createElement(Icon_1.CancelMIcon, { fillColor: iconColor })));
            case 'icon':
                return (react_1.default.createElement(Styled.IconWrapper, { onClick: handleClickButton },
                    react_1.default.createElement(rightArea.children, { fillColor: titleColor })));
            case 'text':
                return (react_1.default.createElement(Styled.TextWrapper, { onClick: handleClickButton },
                    react_1.default.createElement(Typography_1.Title3, { color: rightTextColor }, rightArea.children)));
            default:
                return;
        }
    }, [iconColor, titleColor, rightTextColor, rightArea]);
    return (react_1.default.createElement(BaseNavigation, Object.assign({ backgroundColor: hasBackgroundColor ? backgroundColor : 'transparent', leftChildren: leftChildren, titleColor: titleColor, rightChildren: rightChildren }, commonProps)));
};
exports.PageNavigationBar = PageNavigationBar;
