import { s as sectionsData, _ as _imports_0, b as _sfc_main$9, c as _sfc_main$a, d as _sfc_main$c, e as _sfc_main$e, f as _sfc_main$f, a as _sfc_main$g, g as _sfc_main$h } from "./index.516cc5d3.js";
import { _ as __unplugin_components_1 } from "./VControl.c1dfb3fe.js";
import { p as provideApi, b as _sfc_main$6, u as useUserSession, c as useNotyf, e as __unplugin_components_4 } from "./index.9ce64bc9.js";
import { _ as _sfc_main$7 } from "./VModal.12b66599.js";
import { d as defineComponent, Y as reactive, a4 as watch, m as resolveComponent, o as openBlock, H as createBlock, v as withCtx, p as createBaseVNode, x as withDirectives, ag as vModelText, s as unref, t as createVNode, A as createTextVNode, r as ref, b as createElementBlock, F as Fragment, Z as renderList, B as toDisplayString, n as normalizeClass, _ as createCommentVNode, h as computed, C as renderSlot, X as Transition, G as onMounted, y as vModelCheckbox, av as TransitionGroup, O as Notyf, a6 as onUnmounted, aq as vModelSelect, E as useHead } from "./vendor.55da2271.js";
import { b as useMesaSession, d as MESA_SHAPES, D as DEFAULT_ENVIRONMENT, e as MESA_SHAPES_CIRCLE, f as MESA_NO_DISPONIBLE, g as MESA_DISPONIBLE, u as useCompanySession, M as MesaService } from "./mesaService.4fc9e848.js";
import { _ as _sfc_main$8 } from "./VIcon.c393c789.js";
import { _ as __unplugin_components_5 } from "./VPlaceloadWrap.6c1d3fee.js";
import { _ as _sfc_main$b } from "./VField.b2ff2f2a.js";
import { _ as _sfc_main$d } from "./VAvatar.4c1ed57a.js";
import { u as useProductSession } from "./masterService.5f2c4e3c.js";
import { p as pageTitle } from "./sidebarLayoutState.41819060.js";
import "./VLoader.7fe927ed.js";
import "./VIconButton.0ec33bf6.js";
const _hoisted_1$5 = { class: "modal-form" };
const _hoisted_2$4 = { class: "field" };
const _hoisted_3$4 = /* @__PURE__ */ createBaseVNode("label", null, "Nombre *", -1);
const _hoisted_4$4 = { class: "control" };
const _hoisted_5$3 = { class: "field" };
const _hoisted_6$2 = /* @__PURE__ */ createBaseVNode("label", null, "Forma *", -1);
const _hoisted_7$2 = /* @__PURE__ */ createBaseVNode("br", null, null, -1);
const _hoisted_8$2 = /* @__PURE__ */ createTextVNode("Guardar");
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  props: {
    open: { type: Boolean, required: true },
    model: { type: null, required: true }
  },
  emits: ["close", "save"],
  setup(__props, { emit }) {
    const props = __props;
    const mesasSession = reactive(useMesaSession());
    let stateFormMesa = reactive({
      id: props.model.id,
      label: props.model.label,
      shape: props.model.shape,
      environment: props.model.environment
    });
    const save = () => {
      const { id, label, shape, environment } = stateFormMesa;
      mesasSession.setFormLabelMesa(id, label, shape, environment ? environment : DEFAULT_ENVIRONMENT);
      saveLabelMesa();
      emit("close");
    };
    const saveLabelMesa = async () => {
      const payload = {
        id: stateFormMesa.id,
        label: stateFormMesa.label,
        shape: stateFormMesa.shape,
        enviroment: stateFormMesa
      };
      try {
        const response = await provideApi().post("restaurant/label-table/save", payload);
        const data = response.data;
        if (data.success) {
        }
      } catch (error) {
        console.error("Error data:", error);
      }
    };
    watch(() => props.open, (newValue, oldValue) => {
      if (newValue) {
        const { id, label, shape, environment } = props.model;
        stateFormMesa.id = id;
        stateFormMesa.label = label;
        stateFormMesa.shape = shape;
        stateFormMesa.environment = environment;
      }
    });
    return (_ctx, _cache) => {
      const _component_Multiselect = resolveComponent("Multiselect");
      const _component_VControl = __unplugin_components_1;
      const _component_VButton = _sfc_main$6;
      const _component_VModal = _sfc_main$7;
      return openBlock(), createBlock(_component_VModal, {
        open: props.open,
        title: "Editar Mesa",
        size: "small",
        actions: "right",
        onClose: _cache[3] || (_cache[3] = ($event) => emit("close"))
      }, {
        content: withCtx(() => [
          createBaseVNode("form", _hoisted_1$5, [
            createBaseVNode("div", _hoisted_2$4, [
              _hoisted_3$4,
              createBaseVNode("div", _hoisted_4$4, [
                withDirectives(createBaseVNode("input", {
                  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => unref(stateFormMesa).label = $event),
                  type: "text",
                  class: "input",
                  placeholder: "Nombre"
                }, null, 512), [
                  [vModelText, unref(stateFormMesa).label]
                ])
              ])
            ]),
            createBaseVNode("div", _hoisted_5$3, [
              _hoisted_6$2,
              createVNode(_component_VControl, null, {
                default: withCtx(() => [
                  createVNode(_component_Multiselect, {
                    modelValue: unref(stateFormMesa).shape,
                    "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => unref(stateFormMesa).shape = $event),
                    placeholder: "Forma",
                    options: unref(MESA_SHAPES)
                  }, null, 8, ["modelValue", "options"])
                ]),
                _: 1
              })
            ]),
            _hoisted_7$2
          ])
        ]),
        action: withCtx(() => [
          createVNode(_component_VButton, {
            color: "primary",
            raised: "",
            onClick: _cache[2] || (_cache[2] = ($event) => save())
          }, {
            default: withCtx(() => [
              _hoisted_8$2
            ]),
            _: 1
          })
        ]),
        _: 1
      }, 8, ["open"]);
    };
  }
});
const _hoisted_1$4 = { class: "container" };
const _hoisted_2$3 = ["onClick"];
const _hoisted_3$3 = ["onClick"];
const _hoisted_4$3 = {
  key: 0,
  class: "is-size-7 has-text-weight-normal"
};
const _hoisted_5$2 = {
  key: 1,
  class: "is-size-7"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  props: {
    mesas: { type: Array, required: true, default: () => [] },
    selected: { type: null, required: true },
    modeEdit: { type: Boolean, required: true }
  },
  emits: ["select", "edit"],
  setup(__props, { emit }) {
    const props = __props;
    const mesasSession = useMesaSession();
    const mesaSelected = ref(mesasSession.mesaSelected);
    const select = (item) => {
      emit("select", item);
    };
    const edit = (item) => {
      emit("edit", item);
    };
    const ordersServed = (products) => {
      let served = false;
      for (let prod of products) {
        if (prod.statusBar == 4 || prod.statusKitchen == 4) {
          served = true;
          break;
        }
      }
      return served;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$4, [
        __props.modeEdit ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(props.mesas, (item) => {
          return openBlock(), createElementBlock("div", {
            key: item.id + "M",
            class: "mesa mesa-parent-edit"
          }, [
            createBaseVNode("div", {
              class: normalizeClass(["mesa-child edit", {
                circle: item.shape == unref(MESA_SHAPES_CIRCLE)
              }]),
              onClick: ($event) => edit(item)
            }, toDisplayString(item.label), 11, _hoisted_2$3)
          ]);
        }), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(props.mesas, (item) => {
          return openBlock(), createElementBlock("div", {
            key: item.id + "M",
            ref: (_value, _refs) => {
              _refs["mesaElement"] = _value;
            },
            class: "mesa"
          }, [
            createBaseVNode("div", {
              class: normalizeClass(["mesa-child", {
                notavailableandorderserved: item.status == unref(MESA_NO_DISPONIBLE) && ordersServed(item.products),
                notavailable: item.status == unref(MESA_NO_DISPONIBLE),
                available: item.status == unref(MESA_DISPONIBLE),
                circle: item.shape == unref(MESA_SHAPES_CIRCLE),
                selected: mesaSelected.value && mesaSelected.value.id == item.id
              }]),
              onClick: ($event) => select(item)
            }, [
              createTextVNode(toDisplayString(item.label) + " ", 1),
              item.quantityOrders > 0 ? (openBlock(), createElementBlock("div", _hoisted_4$3, toDisplayString(item.quantityOrders) + " Pedidos ", 1)) : createCommentVNode("", true),
              item.timeOpening ? (openBlock(), createElementBlock("div", _hoisted_5$2, toDisplayString(item.timeOpening), 1)) : createCommentVNode("", true)
            ], 10, _hoisted_3$3)
          ], 512);
        }), 128))
      ]);
    };
  }
});
const _hoisted_1$3 = { class: "tabs-inner" };
const _hoisted_2$2 = ["onClick"];
const _hoisted_3$2 = {
  key: 0,
  class: "tab-naver"
};
const _hoisted_4$2 = { class: "tab-content is-active" };
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  props: {
    tabs: { type: Array, required: true },
    selected: { type: String, required: false, default: void 0 },
    type: { type: String, required: false, default: void 0 },
    align: { type: String, required: false, default: void 0 },
    slider: { type: Boolean, required: false },
    slow: { type: Boolean, required: false }
  },
  setup(__props) {
    const props = __props;
    const activeValue = ref(props.selected);
    const sliderClass = computed(() => {
      if (!props.slider) {
        return "";
      }
      if (props.type === "rounded") {
        if (props.tabs.length === 3) {
          return "is-triple-slider";
        }
        if (props.tabs.length === 2) {
          return "is-slider";
        }
        return "";
      }
      if (!props.type) {
        if (props.tabs.length === 3) {
          return "is-squared is-triple-slider";
        }
        if (props.tabs.length === 2) {
          return "is-squared is-slider";
        }
      }
      return "";
    });
    return (_ctx, _cache) => {
      const _component_VIcon = _sfc_main$8;
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(["tabs-wrapper", [unref(sliderClass)]])
      }, [
        createBaseVNode("div", _hoisted_1$3, [
          createBaseVNode("div", {
            class: normalizeClass(["tabs", [
              props.align === "centered" && "is-centered",
              props.align === "right" && "is-right",
              props.type === "rounded" && !props.slider && "is-toggle is-toggle-rounded",
              props.type === "toggle" && "is-toggle",
              props.type === "boxed" && "is-boxed"
            ]])
          }, [
            createBaseVNode("ul", null, [
              (openBlock(true), createElementBlock(Fragment, null, renderList(__props.tabs, (tab, key) => {
                return openBlock(), createElementBlock("li", {
                  key,
                  class: normalizeClass([activeValue.value === tab.value && "is-active"])
                }, [
                  createBaseVNode("a", {
                    onClick: ($event) => activeValue.value = tab.value
                  }, [
                    tab.icon ? (openBlock(), createBlock(_component_VIcon, {
                      key: 0,
                      icon: tab.icon
                    }, null, 8, ["icon"])) : createCommentVNode("", true),
                    createBaseVNode("span", null, toDisplayString(tab.label), 1)
                  ], 8, _hoisted_2$2)
                ], 2);
              }), 128)),
              unref(sliderClass) ? (openBlock(), createElementBlock("li", _hoisted_3$2)) : createCommentVNode("", true)
            ])
          ], 2)
        ]),
        createBaseVNode("div", _hoisted_4$2, [
          createVNode(Transition, {
            name: props.slow ? "fade-slow" : "fade-fast",
            mode: "out-in"
          }, {
            default: withCtx(() => [
              renderSlot(_ctx.$slots, "tab", { activeValue: activeValue.value })
            ]),
            _: 3
          }, 8, ["name"])
        ])
      ], 2);
    };
  }
});
var MesaRestaurantPos_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$2 = { class: "food-delivery-dashboard" };
const _hoisted_2$1 = { class: "left" };
const _hoisted_3$1 = { class: "left-body" };
const _hoisted_4$1 = { class: "restaurants" };
const _hoisted_5$1 = { class: "columns is-multiline is-mobile" };
const _hoisted_6$1 = {
  class: "column is-12 category-content",
  style: { "padding-bottom": "0px" }
};
const _hoisted_7$1 = { class: "pt-5 searchCategory-content columns" };
const _hoisted_8$1 = /* @__PURE__ */ createBaseVNode("img", {
  src: _imports_0,
  alt: "Buscar",
  class: "search-icon"
}, null, -1);
const _hoisted_9$1 = {
  xmlns: "http://www.w3.org/2000/svg",
  width: "24",
  height: "24",
  viewBox: "0 0 14 14"
};
const _hoisted_10$1 = ["stroke"];
const _hoisted_11$1 = { class: "tooltip-text" };
const _hoisted_12$1 = { class: "column is-2 px-0" };
const _hoisted_13$1 = { class: "tabs-wrapper" };
const _hoisted_14$1 = { class: "tabs-inner" };
const _hoisted_15$1 = { class: "tabs tabs-list is-centered mb-1" };
const _hoisted_16$1 = {
  style: { "border": "none" },
  class: "m-0"
};
const _hoisted_17$1 = /* @__PURE__ */ createBaseVNode("span", null, [
  /* @__PURE__ */ createBaseVNode("i", {
    "aria-hidden": "true",
    class: "iconify",
    "data-icon": "feather:grid"
  })
], -1);
const _hoisted_18$1 = [
  _hoisted_17$1
];
const _hoisted_19$1 = /* @__PURE__ */ createBaseVNode("span", null, [
  /* @__PURE__ */ createBaseVNode("i", {
    "aria-hidden": "true",
    class: "iconify",
    "data-icon": "feather:list"
  })
], -1);
const _hoisted_20$1 = [
  _hoisted_19$1
];
const _hoisted_21$1 = /* @__PURE__ */ createBaseVNode("li", { class: "tab-naver" }, null, -1);
const _hoisted_22$1 = {
  key: 0,
  class: "restaurants-list"
};
const _hoisted_23$1 = { class: "columns is-mobile is-multiline" };
const _hoisted_24$1 = {
  key: 1,
  style: { "padding-top": "1%" },
  class: "flex-table"
};
const _hoisted_25$1 = /* @__PURE__ */ createBaseVNode("div", { class: "flex-table-header" }, [
  /* @__PURE__ */ createBaseVNode("span", { class: "is-grow" }, "Producto"),
  /* @__PURE__ */ createBaseVNode("span", null, "Codigo"),
  /* @__PURE__ */ createBaseVNode("span", { class: "cell-end" }, "Precio")
], -1);
const _hoisted_26$1 = { class: "flex-list-inner" };
const _hoisted_27 = ["onClick"];
const _hoisted_28 = { class: "flex-table-cell is-media is-grow" };
const _hoisted_29 = { class: "item-name dark-inverted" };
const _hoisted_30 = {
  class: "flex-table-cell",
  "data-th": "C\xF3digo"
};
const _hoisted_31 = { class: "light-text" };
const _hoisted_32 = {
  class: "flex-table-cell cell-end",
  "data-th": "Precio"
};
const _hoisted_33 = { class: "is-primary" };
const _hoisted_34 = /* @__PURE__ */ createBaseVNode("div", {
  class: "is-hidden-desktop",
  style: { "min-height": "150px" }
}, null, -1);
const _hoisted_35 = { class: "is-hidden-desktop cart-bottom-fixed h-hidden-tablet-l" };
const _hoisted_36 = { class: "columns is-mobile is-centered m-custom" };
const _hoisted_37 = { class: "column is-11" };
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  props: {
    mesaid: { type: Number, required: false, default: void 0 }
  },
  emits: ["viewMesas"],
  setup(__props, { emit }) {
    const userSession = useUserSession();
    ref("cart");
    const textSearch = ref("");
    const searchByBarcode = ref(false);
    ref(0);
    const mesasSession = useMesaSession();
    const productSession = useProductSession();
    mesasSession.getMesasNotAvailable();
    ref(false);
    const isBarcodeActive = ref(false);
    const tooltipMessage = ref("Activar b\xFAsqueda por c\xF3digo de barras");
    reactive({
      description: ""
    });
    const chunks = ref([]);
    const chunkSize = 500;
    const mesaSelected = ref(mesasSession.mesaSelected);
    const isListItems = ref(false);
    const notif = useNotyf();
    const posBag = reactive({
      products: mesaSelected.value.products,
      total: mesaSelected.value.total,
      barman: userSession.name,
      waiter: mesaSelected.value.waiter,
      enterAmount: 0
    });
    const state = reactive({
      products: productSession.products,
      products_filter: productSession.products,
      openDialogDocument: false,
      loading: false,
      generatedDocument: false,
      sections: sectionsData,
      categories: productSession.categories
    });
    const productIndexByBarcode = new Map();
    const productIndexByInternalId = new Map();
    const filteredProducts = ref(state.products);
    state.products.forEach((product) => {
      if (product.barcode) {
        productIndexByBarcode.set(product.barcode, product);
      }
      if (product.internalId) {
        productIndexByInternalId.set(product.internalId.toLowerCase(), product);
      }
    });
    const clickAddProduct = (item) => {
      mesasSession.addProduct(item);
    };
    const openDialogDocument = () => {
      if (mesaSelected.value.total > 0) {
        posBag.total = mesaSelected.value.total;
        state.openDialogDocument = true;
      }
    };
    const closeDialogDocument = () => {
      mesasSession.setAvailableMesa();
      state.openDialogDocument = false;
      emit("viewMesas");
    };
    const changeToMesas = () => {
      emit("viewMesas");
    };
    const back = () => {
      state.openDialogDocument = false;
    };
    const selectMesa = (id) => {
      mesasSession.setMesaSelected(id);
    };
    let debounceTimeout = null;
    const debouncedSearch = (callback, delay = 200) => {
      if (debounceTimeout)
        clearTimeout(debounceTimeout);
      debounceTimeout = setTimeout(callback, delay);
    };
    const loadProducts = () => {
      const allProducts = state.products;
      chunks.value = [];
      for (let i = 0; i < allProducts.length; i += chunkSize) {
        chunks.value.push(allProducts.slice(i, i + chunkSize));
      }
    };
    const removeAccents = (name) => {
      return name ? name.normalize("NFD").replace(/[\u0300-\u036f]/g, "") : "";
    };
    const products_filter = computed(() => filteredProducts.value);
    watch(textSearch, () => {
      if (textSearch.value.length > 0) {
        if (searchByBarcode.value) {
          const itemFound = productIndexByBarcode.get(textSearch.value);
          if (itemFound) {
            mesasSession.addProduct(itemFound);
            notif.success("Producto a\xF1adido!");
          } else {
            notif.error("Producto no encontrado");
          }
          textSearch.value = "";
          filteredProducts.value = itemFound ? [itemFound] : [];
        } else {
          debouncedSearch(() => {
            const lowerSearchText = textSearch.value.toLowerCase();
            filteredProducts.value = chunks.value.flatMap((chunk) => chunk.filter((item) => {
              var _a;
              return removeAccents(item.name || "").toLowerCase().includes(removeAccents(lowerSearchText)) || productIndexByInternalId.has(lowerSearchText) && ((_a = productIndexByInternalId.get(lowerSearchText)) == null ? void 0 : _a.internalId) === item.internalId;
            }));
          });
        }
      } else {
        filteredProducts.value = state.products.length >= 500 ? state.products.slice(0, 500) : state.products;
      }
    });
    const selectCategory = (id) => {
      if (id === 0) {
        state.products = state.products_filter;
      } else {
        state.products = state.products_filter.filter((x) => x.categoryId === id);
      }
    };
    const cancelTable = () => {
      closeDialogDocument();
    };
    const changeSearchByBarcode = () => {
      isBarcodeActive.value = !isBarcodeActive.value;
      tooltipMessage.value = isBarcodeActive.value ? "Desactivar b\xFAsqueda por c\xF3digo de barras" : "Activar b\xFAsqueda por c\xF3digo de barras";
      let byBarcode = searchByBarcode.value ? 1 : 0;
      userSession.setSearchByBarcode(byBarcode);
    };
    onMounted(() => {
      searchByBarcode.value = userSession.searchByBarcode ? true : false;
      isBarcodeActive.value = userSession.searchByBarcode ? true : false;
      const searchCategoryContent = document.querySelector(".searchCategory-content");
      const categoryContent = document.querySelector(".category-content");
      if (!searchCategoryContent || !categoryContent)
        return;
      const offsetTop = searchCategoryContent.offsetTop;
      const handleScroll = () => {
        const shouldStick = window.scrollY >= offsetTop;
        searchCategoryContent.classList.toggle("is-sticky", shouldStick);
        if (shouldStick) {
          categoryContent.style.marginBottom = "90px";
        } else {
          categoryContent.style.marginBottom = "0";
        }
      };
      window.addEventListener("scroll", handleScroll);
      loadProducts();
    });
    return (_ctx, _cache) => {
      const _component_DocumentDialog = _sfc_main$9;
      const _component_CategoriesNavBar = _sfc_main$a;
      const _component_VControl = __unplugin_components_1;
      const _component_VField = _sfc_main$b;
      const _component_ProductPos = _sfc_main$c;
      const _component_VAvatar = _sfc_main$d;
      const _component_CartMobile = _sfc_main$e;
      const _component_Bag = _sfc_main$f;
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_DocumentDialog, {
          "pos-bag": unref(posBag),
          open: unref(state).openDialogDocument,
          onClose: closeDialogDocument,
          onBack: back
        }, null, 8, ["pos-bag", "open"]),
        createBaseVNode("div", _hoisted_1$2, [
          createBaseVNode("div", _hoisted_2$1, [
            createBaseVNode("div", _hoisted_3$1, [
              createBaseVNode("div", _hoisted_4$1, [
                createBaseVNode("div", _hoisted_5$1, [
                  createBaseVNode("div", _hoisted_6$1, [
                    createVNode(_component_CategoriesNavBar, { onSelectcategory: selectCategory })
                  ]),
                  createBaseVNode("div", _hoisted_7$1, [
                    createVNode(_component_VField, { class: "search-conteiner column is-10" }, {
                      default: withCtx(() => [
                        createVNode(_component_VControl, null, {
                          default: withCtx(() => [
                            _hoisted_8$1,
                            withDirectives(createBaseVNode("input", {
                              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => textSearch.value = $event),
                              type: "text",
                              class: "input input-search-mesa is-rounded",
                              placeholder: "Busca un producto ..."
                            }, null, 512), [
                              [vModelText, textSearch.value]
                            ]),
                            createBaseVNode("label", null, [
                              withDirectives(createBaseVNode("input", {
                                "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => searchByBarcode.value = $event),
                                class: "barcode-toggle",
                                type: "checkbox",
                                onChange: changeSearchByBarcode
                              }, null, 544), [
                                [vModelCheckbox, searchByBarcode.value]
                              ]),
                              createBaseVNode("span", {
                                class: normalizeClass(["barcode-icon-mesa", { active: isBarcodeActive.value }])
                              }, [
                                (openBlock(), createElementBlock("svg", _hoisted_9$1, [
                                  createBaseVNode("path", {
                                    fill: "none",
                                    stroke: isBarcodeActive.value ? "#4caf50" : "#cfcfcf",
                                    "stroke-linecap": "round",
                                    "stroke-linejoin": "round",
                                    d: "M5.11.656H1.208a.49.49 0 0 0-.488.488v3.904m12.686 0V1.144a.49.49 0 0 0-.488-.488H9.014m0 12.688h3.904a.49.49 0 0 0 .488-.488V8.952m-12.687 0v3.904a.49.49 0 0 0 .488.488H5.11m5.696-9.552v6.416M3.194 3.792v6.416m5.709-6.416v4.666m0 1.75v-.291M7 3.792v4.666m0 1.75v-.291M5.097 3.792v4.666m0 1.75v-.291"
                                  }, null, 8, _hoisted_10$1)
                                ]))
                              ], 2),
                              createBaseVNode("span", _hoisted_11$1, toDisplayString(tooltipMessage.value), 1)
                            ])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    }),
                    createBaseVNode("div", _hoisted_12$1, [
                      createBaseVNode("div", _hoisted_13$1, [
                        createBaseVNode("div", _hoisted_14$1, [
                          createBaseVNode("div", _hoisted_15$1, [
                            createBaseVNode("ul", _hoisted_16$1, [
                              createBaseVNode("li", {
                                class: normalizeClass([isListItems.value == false && "is-active"])
                              }, [
                                createBaseVNode("a", {
                                  onClick: _cache[2] || (_cache[2] = ($event) => isListItems.value = false)
                                }, _hoisted_18$1)
                              ], 2),
                              createBaseVNode("li", {
                                class: normalizeClass([isListItems.value == true && "is-active"])
                              }, [
                                createBaseVNode("a", {
                                  onClick: _cache[3] || (_cache[3] = ($event) => isListItems.value = true)
                                }, _hoisted_20$1)
                              ], 2),
                              _hoisted_21$1
                            ])
                          ])
                        ])
                      ])
                    ])
                  ])
                ]),
                !isListItems.value ? (openBlock(), createElementBlock("div", _hoisted_22$1, [
                  createBaseVNode("div", _hoisted_23$1, [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(products_filter), (product) => {
                      return openBlock(), createElementBlock("div", {
                        key: product.id,
                        class: "column is-6-mobile is-4-tablet is-3-desktop"
                      }, [
                        createVNode(_component_ProductPos, {
                          product,
                          onClickAddProduct: clickAddProduct
                        }, null, 8, ["product"])
                      ]);
                    }), 128))
                  ])
                ])) : (openBlock(), createElementBlock("div", _hoisted_24$1, [
                  _hoisted_25$1,
                  createBaseVNode("div", _hoisted_26$1, [
                    createVNode(TransitionGroup, {
                      name: "list",
                      tag: "div"
                    }, {
                      default: withCtx(() => [
                        (openBlock(true), createElementBlock(Fragment, null, renderList(unref(products_filter), (item) => {
                          return openBlock(), createElementBlock("div", {
                            key: item.id,
                            class: "flex-table-item restaurants-list-item",
                            style: { "cursor": "pointer" },
                            onClick: ($event) => clickAddProduct(item)
                          }, [
                            createBaseVNode("div", _hoisted_28, [
                              createVNode(_component_VAvatar, {
                                picture: item.imageUrl,
                                size: "medium"
                              }, null, 8, ["picture"]),
                              createBaseVNode("div", null, [
                                createBaseVNode("span", _hoisted_29, toDisplayString(item.name), 1)
                              ])
                            ]),
                            createBaseVNode("div", _hoisted_30, [
                              createBaseVNode("span", _hoisted_31, toDisplayString(item.internalId), 1)
                            ]),
                            createBaseVNode("div", _hoisted_32, [
                              createBaseVNode("span", _hoisted_33, toDisplayString(item.currencyTypeSymbol) + " " + toDisplayString(item.price.toFixed(2)), 1)
                            ])
                          ], 8, _hoisted_27);
                        }), 128))
                      ]),
                      _: 1
                    })
                  ])
                ]))
              ])
            ]),
            _hoisted_34
          ]),
          createBaseVNode("div", _hoisted_35, [
            createBaseVNode("div", _hoisted_36, [
              createBaseVNode("div", _hoisted_37, [
                createVNode(_component_CartMobile, {
                  parent: "mesas",
                  onSelectMesa: selectMesa,
                  onFinalizeSale: openDialogDocument,
                  onCancelTable: cancelTable,
                  onChangeToMesas: changeToMesas
                })
              ])
            ])
          ]),
          createVNode(_component_Bag, {
            parent: "mesas",
            onSelectMesa: selectMesa,
            onFinalizeSale: openDialogDocument,
            onCancelTable: cancelTable,
            onChangeToMesas: changeToMesas
          })
        ])
      ], 64);
    };
  }
});
var MesaRestaurant_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$1 = {
  key: 0,
  class: "ecommerce-dashboard ecommerce-dashboard-v1"
};
const _hoisted_2 = { class: "columns is-multiline" };
const _hoisted_3 = { class: "column is-9" };
const _hoisted_4 = { class: "stat-widget line-stats-widget is-straight" };
const _hoisted_5 = /* @__PURE__ */ createTextVNode(" Editar mesas ");
const _hoisted_6 = /* @__PURE__ */ createTextVNode(" Finalizar ");
const _hoisted_7 = { class: "column is-3" };
const _hoisted_8 = {
  key: 0,
  class: "stat-widget area-stats-widget is-straight"
};
const _hoisted_9 = { class: "fieldset-heading pb-4" };
const _hoisted_10 = { style: { "font-size": "13px" } };
const _hoisted_11 = { class: "columns is-multiline" };
const _hoisted_12 = { class: "column is-12" };
const _hoisted_13 = /* @__PURE__ */ createBaseVNode("label", null, "Personas en la mesa", -1);
const _hoisted_14 = { class: "column is-12" };
const _hoisted_15 = /* @__PURE__ */ createBaseVNode("label", null, "Cliente", -1);
const _hoisted_16 = { class: "column is-12" };
const _hoisted_17 = /* @__PURE__ */ createBaseVNode("label", null, "Mozo", -1);
const _hoisted_18 = {
  class: "select",
  placeholder: "Seleccione mozo"
};
const _hoisted_19 = ["value"];
const _hoisted_20 = { class: "column is-12" };
const _hoisted_21 = /* @__PURE__ */ createBaseVNode("label", null, "Comentarios", -1);
const _hoisted_22 = { class: "column is-12" };
const _hoisted_23 = /* @__PURE__ */ createTextVNode(" Abrir mesa ");
const _hoisted_24 = {
  key: 1,
  class: "stat-widget area-stats-widget is-straight"
};
const _hoisted_25 = /* @__PURE__ */ createBaseVNode("h3", null, "SELECCIONE UNA MESA", -1);
const _hoisted_26 = [
  _hoisted_25
];
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  setup(__props) {
    new Notyf();
    const mesasSession = reactive(useMesaSession());
    const companySession = reactive(useCompanySession());
    const mesaSelected = ref(mesasSession.mesaSelected);
    let mesas = ref([]);
    const userSession = useUserSession();
    const userRole = userSession.getRole();
    let viewPos = ref(false);
    let canUpdate = ref(false);
    let openModalEditMesa = ref(false);
    let loadingRefresh = ref(false);
    let intervalId = void 0;
    const environments = mesasSession.environments;
    const environment_1 = environments[0];
    const environment_2 = environments[1];
    const environment_3 = environments[2];
    const environment_4 = environments[3];
    let stateFormMesa = reactive({
      id: 0,
      label: "",
      shape: "",
      environment: DEFAULT_ENVIRONMENT
    });
    let modeEditMesas = ref(false);
    const customerDefault = companySession.getCustomerDefault();
    const selectMesa = (item) => {
      if (item.status == MESA_DISPONIBLE) {
        mesasSession.setMesaSelected(item.id, customerDefault.apellidos_y_nombres_o_razon_social);
        canUpdate.value = true;
      } else {
        mesasSession.setMesaSelected(item.id);
        viewPos.value = true;
      }
    };
    const openMesa = () => {
      if (mesaSelected.value) {
        mesasSession.openMesa(mesaSelected.value);
        viewPos.value = true;
      }
    };
    const viewMesas = () => {
      viewPos.value = false;
    };
    const editMesaForm = (item) => {
      const { id, label, shape, environment } = item;
      stateFormMesa.id = id;
      stateFormMesa.label = label;
      stateFormMesa.shape = shape;
      stateFormMesa.environment = environment;
      openModalEditMesa.value = true;
    };
    const editMesas = () => {
      modeEditMesas.value = true;
      if (intervalId !== void 0) {
        clearInterval(intervalId);
      }
    };
    const finishEditMesas = () => {
      modeEditMesas.value = false;
      intervalId = window.setInterval(syncMesasEnviroments, 5e3);
    };
    const setMesas = () => {
      mesas.value = mesasSession.mesas;
    };
    const closeFormMesa = () => {
      openModalEditMesa.value = false;
    };
    const syncMesasEnviroments = async () => {
      await MesaService.syncMesasAndEnvironments();
      setMesas();
    };
    watch(() => [...mesasSession.mesas], () => {
      setMesas();
    });
    onMounted(() => {
      setMesas();
      syncMesasEnviroments();
      intervalId = window.setInterval(syncMesasEnviroments, 5e3);
    });
    onUnmounted(() => {
      if (intervalId !== void 0) {
        clearInterval(intervalId);
      }
    });
    return (_ctx, _cache) => {
      const _component_MesaForm = _sfc_main$5;
      const _component_CashDialog = _sfc_main$g;
      const _component_MesaEnvironment = _sfc_main$4;
      const _component_VTabs = _sfc_main$3;
      const _component_VPlaceload = __unplugin_components_4;
      const _component_VPlaceloadWrap = __unplugin_components_5;
      const _component_VButton = _sfc_main$6;
      const _component_VControl = __unplugin_components_1;
      const _component_VField = _sfc_main$b;
      const _component_MesaRestaurantPos = _sfc_main$2;
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_MesaForm, {
          open: unref(openModalEditMesa),
          model: unref(stateFormMesa),
          onClose: closeFormMesa
        }, null, 8, ["open", "model"]),
        createVNode(_component_CashDialog),
        !unref(viewPos) ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
          createBaseVNode("div", _hoisted_2, [
            createBaseVNode("div", _hoisted_3, [
              createBaseVNode("div", _hoisted_4, [
                createVNode(_component_VTabs, {
                  selected: unref(environments)[0].name,
                  tabs: unref(environments).filter((item) => item.active === true).map((item) => {
                    return { label: item.name, value: item.name };
                  })
                }, {
                  tab: withCtx(({ activeValue }) => [
                    activeValue === unref(environment_1).name ? (openBlock(), createBlock(_component_MesaEnvironment, {
                      key: 0,
                      mesas: unref(mesas).filter((x) => x.environment == unref(environment_1).name),
                      selected: mesaSelected.value,
                      "mode-edit": unref(modeEditMesas),
                      onSelect: selectMesa,
                      onEdit: editMesaForm
                    }, null, 8, ["mesas", "selected", "mode-edit"])) : activeValue === unref(environment_2).name ? (openBlock(), createBlock(_component_MesaEnvironment, {
                      key: 1,
                      mesas: unref(mesas).filter((x) => x.environment == unref(environment_2).name),
                      selected: mesaSelected.value,
                      "mode-edit": unref(modeEditMesas),
                      onSelect: selectMesa,
                      onEdit: editMesaForm
                    }, null, 8, ["mesas", "selected", "mode-edit"])) : activeValue === unref(environment_3).name ? (openBlock(), createBlock(_component_MesaEnvironment, {
                      key: 2,
                      mesas: unref(mesas).filter((x) => x.environment == unref(environment_3).name),
                      selected: mesaSelected.value,
                      "mode-edit": unref(modeEditMesas),
                      onSelect: selectMesa,
                      onEdit: editMesaForm
                    }, null, 8, ["mesas", "selected", "mode-edit"])) : activeValue === unref(environment_4).name ? (openBlock(), createBlock(_component_MesaEnvironment, {
                      key: 3,
                      mesas: unref(mesas).filter((x) => x.environment == unref(environment_4).name),
                      selected: mesaSelected.value,
                      "mode-edit": unref(modeEditMesas),
                      onSelect: selectMesa,
                      onEdit: editMesaForm
                    }, null, 8, ["mesas", "selected", "mode-edit"])) : createCommentVNode("", true)
                  ]),
                  _: 1
                }, 8, ["selected", "tabs"]),
                unref(loadingRefresh) ? (openBlock(), createBlock(_component_VPlaceloadWrap, { key: 0 }, {
                  default: withCtx(() => [
                    createVNode(_component_VPlaceload, {
                      height: "25px",
                      width: "20%",
                      class: "mx-2"
                    })
                  ]),
                  _: 1
                })) : createCommentVNode("", true),
                !unref(modeEditMesas) && unref(userRole) != "MOZO" ? (openBlock(), createBlock(_component_VButton, {
                  key: 1,
                  class: "mt-3",
                  onClick: editMesas
                }, {
                  default: withCtx(() => [
                    _hoisted_5
                  ]),
                  _: 1
                })) : createCommentVNode("", true),
                unref(modeEditMesas) && unref(userRole) != "MOZO" ? (openBlock(), createBlock(_component_VButton, {
                  key: 2,
                  class: "mt-3",
                  onClick: finishEditMesas
                }, {
                  default: withCtx(() => [
                    _hoisted_6
                  ]),
                  _: 1
                })) : createCommentVNode("", true)
              ])
            ]),
            createBaseVNode("div", _hoisted_7, [
              mesaSelected.value && mesaSelected.value.id !== 0 ? (openBlock(), createElementBlock("div", _hoisted_8, [
                createBaseVNode("div", _hoisted_9, [
                  createBaseVNode("h4", null, [
                    createTextVNode(" MESA " + toDisplayString(mesaSelected.value.label) + " ", 1),
                    createBaseVNode("span", _hoisted_10, toDisplayString(mesaSelected.value.environment), 1)
                  ])
                ]),
                createBaseVNode("div", _hoisted_11, [
                  createBaseVNode("div", _hoisted_12, [
                    createVNode(_component_VField, null, {
                      default: withCtx(() => [
                        _hoisted_13,
                        createVNode(_component_VControl, { icon: "feather:hash" }, {
                          default: withCtx(() => [
                            withDirectives(createBaseVNode("input", {
                              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => mesaSelected.value.personas = $event),
                              type: "number",
                              class: "input",
                              placeholder: "",
                              autocomplete: "given-name"
                            }, null, 512), [
                              [vModelText, mesaSelected.value.personas]
                            ])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ]),
                  createBaseVNode("div", _hoisted_14, [
                    createVNode(_component_VField, null, {
                      default: withCtx(() => [
                        _hoisted_15,
                        createVNode(_component_VControl, { icon: "feather:user" }, {
                          default: withCtx(() => [
                            withDirectives(createBaseVNode("input", {
                              "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => mesaSelected.value.cliente = $event),
                              type: "text",
                              class: "input",
                              placeholder: "",
                              autocomplete: "family-name"
                            }, null, 512), [
                              [vModelText, mesaSelected.value.cliente]
                            ])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ]),
                  createBaseVNode("div", _hoisted_16, [
                    createVNode(_component_VField, null, {
                      default: withCtx(() => [
                        _hoisted_17,
                        createVNode(_component_VControl, { icon: "feather:user-check" }, {
                          default: withCtx(() => [
                            createBaseVNode("div", _hoisted_18, [
                              withDirectives(createBaseVNode("select", {
                                "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => mesaSelected.value.waiter = $event)
                              }, [
                                (openBlock(true), createElementBlock(Fragment, null, renderList(unref(companySession).waiters, (item, index) => {
                                  return openBlock(), createElementBlock("option", {
                                    key: index + "Wa",
                                    value: `${item.name}`
                                  }, toDisplayString(`${item.name}`), 9, _hoisted_19);
                                }), 128))
                              ], 512), [
                                [vModelSelect, mesaSelected.value.waiter]
                              ])
                            ])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ]),
                  createBaseVNode("div", _hoisted_20, [
                    createVNode(_component_VField, null, {
                      default: withCtx(() => [
                        _hoisted_21,
                        createVNode(_component_VControl, null, {
                          default: withCtx(() => [
                            withDirectives(createBaseVNode("textarea", {
                              "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => mesaSelected.value.comentarios = $event),
                              class: "textarea",
                              rows: "4",
                              placeholder: "",
                              autocomplete: "off",
                              autocapitalize: "off",
                              spellcheck: "true"
                            }, null, 512), [
                              [vModelText, mesaSelected.value.comentarios]
                            ])
                          ]),
                          _: 1
                        })
                      ]),
                      _: 1
                    })
                  ]),
                  createBaseVNode("div", _hoisted_22, [
                    createVNode(_component_VButton, {
                      color: "primary",
                      raised: "",
                      class: "is-fullwidth",
                      onClick: openMesa
                    }, {
                      default: withCtx(() => [
                        _hoisted_23
                      ]),
                      _: 1
                    })
                  ])
                ])
              ])) : createCommentVNode("", true),
              mesaSelected.value.id == 0 ? (openBlock(), createElementBlock("div", _hoisted_24, _hoisted_26)) : createCommentVNode("", true)
            ])
          ])
        ])) : createCommentVNode("", true),
        unref(viewPos) ? (openBlock(), createBlock(_component_MesaRestaurantPos, {
          key: 1,
          onViewMesas: viewMesas
        })) : createCommentVNode("", true)
      ], 64);
    };
  }
});
const _hoisted_1 = { class: "page-content-inner" };
const _sfc_main = /* @__PURE__ */ defineComponent({
  setup(__props) {
    pageTitle.value = "Mesas";
    useHead({
      title: "Main Mesas"
    });
    return (_ctx, _cache) => {
      const _component_LockedScreen = _sfc_main$h;
      const _component_MesaRestaurant = _sfc_main$1;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(_component_LockedScreen),
        createVNode(_component_MesaRestaurant)
      ]);
    };
  }
});
export { _sfc_main as default };
