/**
 * 整体应用的信息,一个 app 通用的配置信息
 */
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const mobx_1 = require('mobx');
const event_1 = require('./event');
class Application {
    constructor() {
        this.event = new event_1.default();
        /**
         * 头部栏高度
         */
        this.headerHeight = 37;
        /**
         * 侧边栏宽度
         */
        this.sidebarWidth = 240;
        /**
         * 底部栏高度
         */
        this.footerHeight = 25;
        /**
         * 编辑区域宽度百分比 1~100
         */
        this.viewportWidth = 100;
        /**
         * 是否正在移动侧边栏
         */
        this.isSidebarMoving = false;
        /**
         * 是否在预览状态
         */
        this.isPreview = false;
        /**
         * 标题名称
         */
        this.title = '';
        /**
         * 基础组件
         */
        this.baseComponents = [];
        /**
         * 定制组件
         */
        this.customComponents = [];
        /**
         * 组合组件
         */
        this.comboComponents = [];
        /**
         * 是否隐藏通用组件
         */
        this.isHideCustomComponents = false;
    }
    setViewportWidth(width) {
        this.viewportWidth = width;
    }
    /**
     * 设置侧边栏宽度
     */
    setSidebarWidth(value) {
        if (value < 180) {
            value = 180;
        }
        if (value > 600) {
            value = 600;
        }
        this.sidebarWidth = value;
    }
    /**
     * 设置侧边栏是否在移动状态
     */
    setSidebarMoving(isMoving) {
        this.isSidebarMoving = isMoving;
    }
    /**
     * 修改预览状态
     */
    setPreview(isPreview) {
        this.isPreview = isPreview;
    }
    /**
     * 将接收到的 props 赋值到 application 中
     */
    setInitPropsToApplication(props) {
        this.title = props.title;
        this.baseComponents = props.baseComponents;
        this.setCustomComponents(props.customComponents);
        this.isHideCustomComponents = props.isHideCustomComponents;
        this.defaultValue = props.defaultValue;
        this.height = props.height;
        this.isReactNative = props.isReactNative;
    }
    /**
     * 设置定制组件
     */
    setCustomComponents(customComponents) {
        this.customComponents = customComponents;
    }
    /**
     * 添加一个组合
     */
    addComboComponent(comboComponent) {
        this.comboComponents.push(comboComponent);
    }
    /**
     * 根据 uniqueKey 获取组件
     */
    getComponentByUniqueKey(uniqueKey) {
        if (this.baseComponents) {
            for (let component of this.baseComponents) {
                if (component.defaultProps.gaeaUniqueKey === uniqueKey) {
                    return component;
                }
            }
        }
        for (let component of this.customComponents) {
            if (component.defaultProps.gaeaUniqueKey === uniqueKey) {
                return component;
            }
        }
        return null;
    }
}
__decorate([
    mobx_1.observable
], Application.prototype, "headerHeight", void 0);
__decorate([
    mobx_1.observable
], Application.prototype, "sidebarWidth", void 0);
__decorate([
    mobx_1.observable
], Application.prototype, "footerHeight", void 0);
__decorate([
    mobx_1.observable
], Application.prototype, "viewportWidth", void 0);
__decorate([
    mobx_1.observable
], Application.prototype, "isSidebarMoving", void 0);
__decorate([
    mobx_1.observable
], Application.prototype, "isPreview", void 0);
__decorate([
    mobx_1.observable
], Application.prototype, "comboComponents", void 0);
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Application;
