var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/appointmentBooking/index.tsx
var appointmentBooking_exports = {};
__export(appointmentBooking_exports, {
  default: () => appointmentBooking_default
});
module.exports = __toCommonJS(appointmentBooking_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var import_context = require("./context");
var import_Content = __toESM(require("./components/Content"));
var import_locales = __toESM(require("./locales"));
var import_hooks = require("./hooks");
var import_utils2 = require("./utils");
var import_index = require("./index.less");
var AppointmentBooking = () => {
  var _a, _b;
  const context = (0, import_useEngineContext.default)();
  import_utils.locales.init(import_locales.default, ((_b = (_a = context == null ? void 0 : context.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.locale) || "en");
  const utils = (0, import_hooks.contextUtils)();
  const appointmentBooking = (0, import_hooks.useAppointmentBooking)();
  const isMobileLayout = (0, import_react.useMemo)(() => (0, import_utils.isMobile)() && !(0, import_utils.isIpad)(), []);
  (0, import_react.useEffect)(() => {
    var _a2;
    const { bookingSubject } = ((_a2 = appointmentBooking == null ? void 0 : appointmentBooking.otherParams) == null ? void 0 : _a2.productModuleParams) || {};
    if ((bookingSubject == null ? void 0 : bookingSubject.type) === "form") return;
    appointmentBooking.getAccounts().then((data) => {
      if (!data.length) {
        const currentUser = (0, import_utils2.formatCurrentUser)(utils);
        appointmentBooking.addAccounts([currentUser]);
      } else if (data.length >= 1) {
        const meAccount = data == null ? void 0 : data.find((d) => !(d == null ? void 0 : d.isGuest));
        const currentUser = (0, import_utils2.formatCurrentUser)(utils);
        if (currentUser && meAccount.id !== currentUser.id) {
          appointmentBooking.setLoginAccount(meAccount.id, currentUser);
        }
      }
    });
  }, []);
  (0, import_react.useEffect)(() => {
    const setRealVH = () => {
      let height = window.innerHeight;
      const urlParams = new URLSearchParams(window.location.search);
      if (urlParams.has("fromTabbar")) {
        height = height - 54;
      }
      const vh = height * 0.01;
      document.documentElement.style.setProperty("--vh", `${vh}px`);
    };
    setRealVH();
    window.addEventListener("resize", setRealVH);
    return () => {
      window.removeEventListener("resize", setRealVH);
    };
  }, []);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `parallel-booking-wrap ${isMobileLayout ? "parallel-booking-mobile-wrap" : ""}`
    },
    /* @__PURE__ */ import_react.default.createElement(import_context.AppointmentBookingProvider, null, /* @__PURE__ */ import_react.default.createElement(import_Content.default, null))
  );
};
var appointmentBooking_default = AppointmentBooking;
