"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
require("../../../node_modules/grid-layout-plus/es/index.js");
const all = require("./components/all.js");
const pageHistory = require("./utils/pageHistory.js");
;/* empty css           */
const _pluginVue_exportHelper = require("../../../_virtual/_plugin-vue_export-helper.js");
const gridLayout_vue = require("../../../node_modules/grid-layout-plus/es/components/grid-layout.vue.js");
const _hoisted_1 = { class: "grid-wrapper no-scrollbar" };
const _hoisted_2 = { class: "component-content" };
const colNum = 24;
const rowHeight = 10;
const _sfc_main = {
  __name: "page",
  props: {
    parentPage: {
      type: Object,
      required: true
    },
    routePage: {
      type: Object
    }
  },
  setup(__props) {
    const props = __props;
    const formData = Vue.ref({});
    function getComp(type) {
      return all[type];
    }
    const layoutData = Vue.computed(() => {
      var _a;
      if (Array.isArray(props.parentPage.layoutData)) {
        return ((_a = props.parentPage.layoutData) == null ? void 0 : _a.map((item) => {
          item.isResizable = false;
          return item;
        })) || [];
      }
      return props.parentPage.layoutData;
    });
    const tabbarActive = Vue.ref(0);
    const childPage = Vue.ref(null);
    function onTabbarChange(pageId) {
      if (!pageId) {
        return;
      }
      const page = props.parentPage.children.find((item) => item.id == pageId);
      if (!page) ;
      else {
        childPage.value = page;
        pageHistory.pageHistory.replace(page);
      }
      console.log("🚀 ~ onTabbarChange ~ page:", page);
    }
    const currentPage = Vue.computed(() => {
      return childPage.value || props.parentPage || {};
    });
    Vue.watch(
      [() => props.parentPage, () => props.routePage],
      () => {
        var _a;
        childPage.value = props.routePage;
        if (props.parentPage.footerType == "tabbar") {
          tabbarActive.value = ((_a = props.routePage) == null ? void 0 : _a.id) || props.parentPage.tabbarConfig.tabbarOptions[0].pageId;
        }
      },
      {
        immediate: true
      }
    );
    return (_ctx, _cache) => {
      const _component_FecMobileNavBar = Vue.resolveComponent("FecMobileNavBar");
      const _component_page = Vue.resolveComponent("page", true);
      const _component_FecMobileMenuGrid = Vue.resolveComponent("FecMobileMenuGrid");
      const _component_FecMobileNoticeBar = Vue.resolveComponent("FecMobileNoticeBar");
      const _component_FecMobileDataStat = Vue.resolveComponent("FecMobileDataStat");
      const _component_FecMobileTabbar = Vue.resolveComponent("FecMobileTabbar");
      const _component_FecMobileActionBar = Vue.resolveComponent("FecMobileActionBar");
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        __props.parentPage.isNavBar ? (Vue.openBlock(), Vue.createBlock(_component_FecMobileNavBar, Vue.normalizeProps(Vue.mergeProps({ key: 0 }, __props.parentPage.navBarConfig)), null, 16)) : Vue.createCommentVNode("", true),
        Vue.createElementVNode("div", _hoisted_1, [
          __props.parentPage.footerType == "tabbar" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
            Vue.unref(childPage) ? (Vue.openBlock(), Vue.createBlock(_component_page, {
              key: 0,
              parentPage: Vue.unref(childPage)
            }, null, 8, ["parentPage"])) : Vue.createCommentVNode("", true)
          ], 64)) : (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 1 }, [
            __props.parentPage.type == "home" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
              Vue.createVNode(_component_FecMobileMenuGrid, Vue.normalizeProps(Vue.guardReactiveProps(__props.parentPage.layoutData.menuGridProps)), null, 16),
              Vue.createVNode(_component_FecMobileNoticeBar),
              Vue.createVNode(_component_FecMobileDataStat)
            ], 64)) : __props.parentPage.type == "approval" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 1 }, [], 64)) : (Vue.openBlock(), Vue.createBlock(Vue.unref(gridLayout_vue.default), {
              key: 2,
              ref: "gridLayout",
              layout: Vue.unref(layoutData),
              "onUpdate:layout": _cache[0] || (_cache[0] = ($event) => Vue.isRef(layoutData) ? layoutData.value = $event : null),
              "row-height": rowHeight,
              margin: [0, 0],
              "col-num": colNum,
              "use-css-transforms": false,
              "is-draggable": false,
              "is-resizable": false,
              style: { "height": "100%" }
            }, {
              item: Vue.withCtx(({ item: { component } }) => [
                Vue.createElementVNode("div", _hoisted_2, [
                  (Vue.openBlock(), Vue.createBlock(Vue.resolveDynamicComponent(getComp(component.fieldType)), Vue.mergeProps(component.props, {
                    modelValue: Vue.unref(formData)[component.props.fieldName],
                    "onUpdate:modelValue": ($event) => Vue.unref(formData)[component.props.fieldName] = $event,
                    dataSources: Vue.unref(currentPage).dataSources,
                    compId: component.id,
                    currentPage: Vue.unref(currentPage)
                  }), null, 16, ["modelValue", "onUpdate:modelValue", "dataSources", "compId", "currentPage"]))
                ])
              ]),
              _: 1
            }, 8, ["layout"]))
          ], 64))
        ]),
        __props.parentPage.footerType == "tabbar" ? (Vue.openBlock(), Vue.createBlock(_component_FecMobileTabbar, Vue.mergeProps({
          key: 1,
          modelValue: Vue.unref(tabbarActive),
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => Vue.isRef(tabbarActive) ? tabbarActive.value = $event : null)
        }, __props.parentPage.tabbarConfig, { onChange: onTabbarChange }), null, 16, ["modelValue"])) : Vue.createCommentVNode("", true),
        __props.parentPage.footerType == "actionBar" ? (Vue.openBlock(), Vue.createBlock(_component_FecMobileActionBar, Vue.normalizeProps(Vue.mergeProps({ key: 2 }, __props.parentPage.actionBarConfig)), null, 16)) : Vue.createCommentVNode("", true)
      ], 64);
    };
  }
};
const MobilePage = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-71059c96"]]);
exports.default = MobilePage;
