(function() {
  "use strict";
  try {
    if (typeof document != "undefined") {
      var elementStyle = document.createElement("style");
      elementStyle.appendChild(document.createTextNode('@charset "UTF-8";\n.bflex-widget {\n  display: none;\n}\n.bflex-widget.is-open {\n  display: block;\n}\n.bflex-widget__overlay {\n  position: fixed;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  display: flex;\n  justify-content: center;\n  align-items: center;\n  background: color-mix(in srgb, var(--bflex-on-surface, #1a202c) 38%, transparent);\n  -webkit-backdrop-filter: blur(4px);\n  backdrop-filter: blur(4px);\n  z-index: 100000;\n}\n.bflex-widget__container {\n  display: flex;\n  flex-direction: column;\n  justify-content: center;\n  box-sizing: border-box;\n  width: 960px;\n  max-height: calc(var(--bflex-vh, 1vh) * 95);\n  background: var(--bflex-surface, #ffffff);\n  border-radius: 20px;\n  border: 1px solid color-mix(in srgb, var(--bflex-on-surface, #1a202c) 10%, var(--bflex-surface, #ffffff));\n  box-shadow: 0 24px 60px color-mix(in srgb, var(--bflex-on-surface, #1a202c) 18%, transparent), 0 2px 10px color-mix(in srgb, var(--bflex-on-surface, #1a202c) 8%, transparent);\n  overflow: hidden;\n}\n.bflex-widget[aria-hidden=false] .bflex-widget__overlay {\n  animation: bflexWidgetFadeIn 0.2s cubic-bezier(0, 0, 0.2, 1);\n}\n.bflex-widget[aria-hidden=false] .bflex-widget__container {\n  animation: bflexWidgetSlideIn 0.2s cubic-bezier(0, 0, 0.2, 1);\n}\n.bflex-widget .bflex-widget__container,\n.bflex-widget .bflex-widget__overlay {\n  will-change: transform;\n}\n\n.modal__header {\n  display: flex;\n  align-items: center;\n  justify-content: end;\n  flex-shrink: 0;\n  padding: 10px 12px 10px 20px;\n}\n.modal__header .modal__close {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  width: 38px;\n  height: 38px;\n  border-radius: 50%;\n  border: 1px solid color-mix(in srgb, var(--bflex-on-surface, #1a202c) 12%, var(--bflex-surface, #ffffff));\n  outline: none;\n  background: var(--bflex-surface, #ffffff);\n  color: var(--bflex-muted, #718096);\n  font-size: 18px;\n  cursor: pointer;\n  padding: 0;\n  transition: background-color 0.15s ease, color 0.15s ease;\n}\n.modal__header .modal__close:hover {\n  background: color-mix(in srgb, var(--bflex-on-surface, #1a202c) 6%, var(--bflex-surface, #ffffff));\n  color: var(--bflex-on-surface, #1a202c);\n  border-color: color-mix(in srgb, var(--bflex-on-surface, #1a202c) 12%, var(--bflex-surface, #ffffff));\n  outline: none;\n}\n.modal__header .modal__close:before {\n  content: "✕";\n}\n\n.modal__content {\n  overflow-y: auto;\n  height: max-content;\n  min-height: 0;\n  padding: 16px;\n  scrollbar-color: var(--bflex-muted, #718096) var(--bflex-surface, #ffffff);\n  scrollbar-width: thin;\n}\n\n@media (max-width: 768px) {\n  .modal__content {\n    padding: 0;\n  }\n  .bflex-widget__overlay {\n    align-items: end;\n  }\n  .bflex-widget__container {\n    justify-content: start;\n    border-radius: 20px 20px 0 0;\n    border-bottom: none;\n  }\n  .bflex-widget[aria-hidden=false] .bflex-widget__container {\n    animation: bflexWidgetSlideInMobile 0.35s cubic-bezier(0, 0, 0.2, 1);\n  }\n}\n@keyframes bflexWidgetFadeIn {\n  from {\n    opacity: 0;\n  }\n  to {\n    opacity: 1;\n  }\n}\n@keyframes bflexWidgetSlideIn {\n  from {\n    transform: translateY(15%);\n  }\n  to {\n    transform: translateY(0);\n  }\n}\n@keyframes bflexWidgetSlideInMobile {\n  from {\n    transform: translateY(100%);\n  }\n  to {\n    transform: translateY(0);\n  }\n}'));
      document.head.appendChild(elementStyle);
    }
  } catch (e) {
    console.error("vite-plugin-css-injected-by-js", e);
  }
})();
/*!
 * BookiFlex Booking Widget Controller
 * License: GPL-2.0-or-later
 * © 2026 BookiFlex
 *
 * This bundle includes third-party code:
 * - MicroModal (ISC)
 *   https://github.com/ghosh/Micromodal
 */
function e(e2) {
  return (function(e3) {
    if (Array.isArray(e3)) return t(e3);
  })(e2) || (function(e3) {
    if ("undefined" != typeof Symbol && Symbol.iterator in Object(e3)) return Array.from(e3);
  })(e2) || (function(e3, o2) {
    if (e3) {
      if ("string" == typeof e3) return t(e3, o2);
      var n2 = Object.prototype.toString.call(e3).slice(8, -1);
      return "Object" === n2 && e3.constructor && (n2 = e3.constructor.name), "Map" === n2 || "Set" === n2 ? Array.from(e3) : "Arguments" === n2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2) ? t(e3, o2) : void 0;
    }
  })(e2) || (function() {
    throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  })();
}
function t(e2, t2) {
  (null == t2 || t2 > e2.length) && (t2 = e2.length);
  for (var o2 = 0, n2 = new Array(t2); o2 < t2; o2++) n2[o2] = e2[o2];
  return n2;
}
var o, n, i, a, s, r = (o = ["a[href]", "area[href]", 'input:not([disabled]):not([type="hidden"]):not([aria-hidden])', "select:not([disabled]):not([aria-hidden])", "textarea:not([disabled]):not([aria-hidden])", "button:not([disabled]):not([aria-hidden])", "iframe", "object", "embed", "[contenteditable]", '[tabindex]:not([tabindex^="-"])'], n = (function() {
  function t2(o2) {
    var n3 = o2.targetModal, i2 = o2.triggers, a2 = void 0 === i2 ? [] : i2, s2 = o2.onShow, r2 = void 0 === s2 ? function() {
    } : s2, d2 = o2.onClose, l2 = void 0 === d2 ? function() {
    } : d2, c2 = o2.openTrigger, h2 = void 0 === c2 ? "data-micromodal-trigger" : c2, u2 = o2.closeTrigger, g2 = void 0 === u2 ? "data-micromodal-close" : u2, m = o2.openClass, f = void 0 === m ? "is-open" : m, v = o2.disableScroll, w = void 0 !== v && v, b = o2.disableFocus, p = void 0 !== b && b, y = o2.awaitCloseAnimation, E = void 0 !== y && y, k = o2.awaitOpenAnimation, C = void 0 !== k && k, A = o2.debugMode, M = void 0 !== A && A;
    !(function(e2, t3) {
      if (!(e2 instanceof t3)) throw new TypeError("Cannot call a class as a function");
    })(this, t2), this.modal = "string" == typeof n3 ? document.getElementById(n3) : n3, this.config = { debugMode: M, disableScroll: w, openTrigger: h2, closeTrigger: g2, openClass: f, onShow: r2, onClose: l2, awaitCloseAnimation: E, awaitOpenAnimation: C, disableFocus: p }, a2.length > 0 && this.registerTriggers.apply(this, e(a2)), this.onClick = this.onClick.bind(this), this.onKeydown = this.onKeydown.bind(this);
  }
  var n2;
  return (n2 = [{ key: "registerTriggers", value: function() {
    for (var e2 = this, t3 = arguments.length, o2 = new Array(t3), n3 = 0; n3 < t3; n3++) o2[n3] = arguments[n3];
    o2.filter(Boolean).forEach(function(t4) {
      t4.addEventListener("click", function(t5) {
        return e2.showModal(t5);
      });
    });
  } }, { key: "showModal", value: function() {
    var e2 = this, t3 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null;
    if (this.activeElement = document.activeElement, this.modal.setAttribute("aria-hidden", "false"), this.modal.classList.add(this.config.openClass), this.scrollBehaviour("disable"), this.addEventListeners(), this.config.awaitOpenAnimation) {
      this.modal.addEventListener("animationend", function t4() {
        e2.modal.removeEventListener("animationend", t4, false), e2.setFocusToFirstNode();
      }, false);
    } else this.setFocusToFirstNode();
    this.config.onShow(this.modal, this.activeElement, t3);
  } }, { key: "closeModal", value: function() {
    var e2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null, t3 = this.modal;
    if (this.modal.setAttribute("aria-hidden", "true"), this.removeEventListeners(), this.scrollBehaviour("enable"), this.activeElement && this.activeElement.focus && this.activeElement.focus(), this.config.onClose(this.modal, this.activeElement, e2), this.config.awaitCloseAnimation) {
      var o2 = this.config.openClass;
      this.modal.addEventListener("animationend", function e3() {
        t3.classList.remove(o2), t3.removeEventListener("animationend", e3, false);
      }, false);
    } else t3.classList.remove(this.config.openClass);
  } }, { key: "closeModalByIdOrElement", value: function(e2) {
    this.modal = "string" == typeof e2 ? document.getElementById(e2) : e2, this.modal && this.closeModal();
  } }, { key: "scrollBehaviour", value: function(e2) {
    if (this.config.disableScroll) {
      var t3 = document.querySelector("body");
      switch (e2) {
        case "enable":
          Object.assign(t3.style, { overflow: "" });
          break;
        case "disable":
          Object.assign(t3.style, { overflow: "hidden" });
      }
    }
  } }, { key: "addEventListeners", value: function() {
    this.modal.addEventListener("touchstart", this.onClick), this.modal.addEventListener("click", this.onClick), document.addEventListener("keydown", this.onKeydown);
  } }, { key: "removeEventListeners", value: function() {
    this.modal.removeEventListener("touchstart", this.onClick), this.modal.removeEventListener("click", this.onClick), document.removeEventListener("keydown", this.onKeydown);
  } }, { key: "onClick", value: function(e2) {
    (e2.target.hasAttribute(this.config.closeTrigger) || e2.target.parentNode.hasAttribute(this.config.closeTrigger)) && (e2.preventDefault(), e2.stopPropagation(), this.closeModal(e2));
  } }, { key: "onKeydown", value: function(e2) {
    27 === e2.keyCode && this.closeModal(e2), 9 === e2.keyCode && this.retainFocus(e2);
  } }, { key: "getFocusableNodes", value: function() {
    var t3 = this.modal.querySelectorAll(o);
    return Array.apply(void 0, e(t3));
  } }, { key: "setFocusToFirstNode", value: function() {
    var e2 = this;
    if (!this.config.disableFocus) {
      var t3 = this.getFocusableNodes();
      if (0 !== t3.length) {
        var o2 = t3.filter(function(t4) {
          return !t4.hasAttribute(e2.config.closeTrigger);
        });
        o2.length > 0 && o2[0].focus(), 0 === o2.length && t3[0].focus();
      }
    }
  } }, { key: "retainFocus", value: function(e2) {
    var t3 = this.getFocusableNodes();
    if (0 !== t3.length) if (t3 = t3.filter(function(e3) {
      return null !== e3.offsetParent;
    }), this.modal.contains(document.activeElement)) {
      var o2 = t3.indexOf(document.activeElement);
      e2.shiftKey && 0 === o2 && (t3[t3.length - 1].focus(), e2.preventDefault()), !e2.shiftKey && t3.length > 0 && o2 === t3.length - 1 && (t3[0].focus(), e2.preventDefault());
    } else t3[0].focus();
  } }]) && (function(e2, t3) {
    for (var o2 = 0; o2 < t3.length; o2++) {
      var n3 = t3[o2];
      n3.enumerable = n3.enumerable || false, n3.configurable = true, "value" in n3 && (n3.writable = true), Object.defineProperty(e2, n3.key, n3);
    }
  })(t2.prototype, n2), t2;
})(), i = null, a = function(e2) {
  if ("string" == typeof id ? !document.getElementById(e2) : !e2) return console.warn("MicroModal: ❗Seems like you have missed %c'".concat(e2, "'"), "background-color: #f8f9fa;color: #50596c;font-weight: bold;", "ID somewhere in your code. Refer example below to resolve it."), console.warn("%cExample:", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", '<div class="modal" id="'.concat(e2, '"></div>')), false;
}, s = function(e2, t2) {
  if ((function(e3) {
    e3.length <= 0 && (console.warn("MicroModal: ❗Please specify at least one %c'micromodal-trigger'", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", "data attribute."), console.warn("%cExample:", "background-color: #f8f9fa;color: #50596c;font-weight: bold;", '<a href="#" data-micromodal-trigger="my-modal"></a>'));
  })(e2), !t2) return true;
  for (var o2 in t2) a(o2);
  return true;
}, { init: function(t2) {
  var o2 = Object.assign({}, { openTrigger: "data-micromodal-trigger" }, t2), a2 = e(document.querySelectorAll("[".concat(o2.openTrigger, "]"))), r2 = (function(e2, t3) {
    var o3 = [];
    return e2.forEach(function(e3) {
      var n2 = e3.attributes[t3].value;
      void 0 === o3[n2] && (o3[n2] = []), o3[n2].push(e3);
    }), o3;
  })(a2, o2.openTrigger);
  if (true !== o2.debugMode || false !== s(a2, r2)) for (var d2 in r2) {
    var l2 = r2[d2];
    o2.targetModal = d2, o2.triggers = e(l2), i = new n(o2);
  }
}, show: function(e2, t2) {
  var o2 = t2 || {};
  o2.targetModal = e2, true === o2.debugMode && false === a(e2) || (i && i.removeEventListeners(), (i = new n(o2)).showModal());
}, close: function(e2) {
  e2 ? i.closeModalByIdOrElement(e2) : i.closeModal();
} });
"undefined" != typeof window && (window.MicroModal = r);
const d = "bflex:open-search-modal", l = "bflex:search-bar:search", c = "bflex:booking-widget:ready", h = "bflex:booking-widget:removed", u = "[data-open-bflex-widget], .open-bflex-widget";
class g {
  constructor({ scripts: e2, css: t2, autoOpenFromUrl: o2 = true }) {
    this.isBookingWidgetReady = false, this.isModalShown = false, this.widgetContainerId = "booking-widget-101", this.autoOpenFromUrl = o2, this.scripts = [], this.css = [], e2 && e2?.length && (this.scripts = e2), t2 && t2?.length && (this.css = t2), this.loadScripts(), this.loadCss(), this.observeTriggers(), this.registerEventListeners(), this.updateModalHeight(), this.checkUrlAndAutoOpen();
  }
  loadScripts() {
    this.scripts.map((e2) => ((e3) => {
      const t2 = document.createElement("script");
      t2.type = "text/javascript", t2.src = e3, document.body.appendChild(t2);
    })(e2));
  }
  loadCss() {
    this.css.map((e2) => ((e3) => {
      const t2 = document.createElement("link");
      t2.href = e3, t2.rel = "stylesheet", document.head.appendChild(t2);
    })(e2));
  }
  observeTriggers() {
    !(function(e2) {
      const t2 = /* @__PURE__ */ new WeakSet(), o2 = (o3) => {
        t2.has(o3) || (t2.add(o3), e2(o3));
      };
      ((e3 = document) => {
        e3.querySelectorAll(u).forEach(o2);
      })(), new MutationObserver((e3) => {
        e3.forEach(({ addedNodes: e4 }) => {
          e4.forEach((e5) => {
            e5.nodeType === Node.ELEMENT_NODE && (e5.matches(u) && o2(e5), e5.querySelectorAll?.(u).forEach(o2));
          });
        });
      }).observe(document.body, { childList: true, subtree: true });
    })((e2) => {
      e2.addEventListener("click", () => {
        if (!this.isBookingWidgetReady) {
          const t2 = this.getPayloadFromElement(e2);
          window.dispatchEvent(new CustomEvent(d, { detail: { payload: t2 } }));
        }
      });
    });
  }
  getPayloadFromElement(e2) {
    const { start: t2, end: o2, promoCode: n2, accommodationTypes: i2, ratePlans: a2 } = e2.dataset, s2 = {};
    return t2 && o2 && (s2.start = t2, s2.end = o2), n2 && (s2.promoCode = n2), i2 && (s2.accommodationTypes = i2), a2 && (s2.ratePlans = a2), s2;
  }
  registerEventListeners() {
    window.addEventListener(c, () => {
      this.isBookingWidgetReady = true;
    }), window.addEventListener(h, () => {
      this.isBookingWidgetReady = false;
    }), window.addEventListener(l, (e2) => {
      this.isBookingWidgetReady || this.isModalShown || window.dispatchEvent(new CustomEvent(d, { detail: { payload: e2.detail } }));
    }), window.addEventListener("booking-click", () => {
      window.dispatchEvent(new CustomEvent(l, { detail: { promoCode: "" } }));
    }), window.addEventListener(d, (e2) => {
      this.insertModal(e2.detail?.payload), this.showModal();
    }), window.addEventListener("resize", this.updateModalHeight), window.addEventListener("orientationchange", this.updateModalHeight);
  }
  insertModal(e2 = {}) {
    if (document.getElementById(this.widgetContainerId)) return;
    const t2 = document.createElement("div");
    t2.id = this.widgetContainerId, t2.innerHTML = '\n  <div id="booking-widget" aria-hidden="true" class="bflex-widget">\n    <div tabindex="-1" class="bflex-widget__overlay">\n      <div role="dialog" aria-modal="true" aria-labelledby="booking-widget-title" class="bflex-widget__container">\n        <header class="modal__header">\n            <button class="modal__close" aria-label="Close modal" data-micromodal-close=""></button>\n        </header>\n        <div id="booking-widget-content" class="modal__content">\n          <bflex-booking-widget></bflex-booking-widget>\n        </div>\n      </div>\n    </div>\n  </div>\n';
    const o2 = t2.querySelector("bflex-booking-widget");
    o2 && (e2.start && o2.setAttribute("start", e2.start), e2.end && o2.setAttribute("end", e2.end), e2.promoCode && o2.setAttribute("promo-code", e2.promoCode), null != e2.adults && o2.setAttribute("adults", String(e2.adults)), e2.childrenAges?.length && o2.setAttribute("children-ages", e2.childrenAges.join(",")), e2.accommodationTypes && o2.setAttribute("accommodation-types", e2.accommodationTypes), e2.ratePlans && o2.setAttribute("rate-plans", e2.ratePlans)), document.body.appendChild(t2);
  }
  actionUpdate({ detail: e2 }) {
    const t2 = e2.action.replaceAll("_", "-"), o2 = document.getElementById(this.widgetContainerId);
    o2.classList.forEach((e3) => o2.classList.remove(e3)), o2.classList.add(t2);
    const n2 = o2.querySelector("#booking-widget-content");
    n2 && n2.scrollTo({ top: 0, behavior: "instant" });
  }
  showModal() {
    setTimeout(() => {
      r.show("booking-widget", { onShow: (e2) => {
        window.addEventListener("bflex:booking-widget:action", this.actionUpdate.bind(this)), this.isModalShown = true;
      }, onClose: (e2) => {
        document.getElementById(this.widgetContainerId)?.remove(), window.removeEventListener("bflex:booking-widget:action", this.actionUpdate.bind(this)), this.isModalShown = false;
      }, openTrigger: "data-booking-widget-open", openClass: "is-open", disableScroll: true, disableFocus: false, awaitOpenAnimation: false, awaitCloseAnimation: false, debugMode: true });
    }, 0);
  }
  updateModalHeight() {
    const e2 = 0.01 * window.innerHeight;
    document.documentElement.style.setProperty("--bflex-vh", `${e2}px`);
  }
  checkUrlAndAutoOpen() {
    if (!this.autoOpenFromUrl) return;
    const e2 = new URLSearchParams(window.location.search), t2 = e2.get("cancel"), o2 = e2.get("start"), n2 = e2.get("end"), i2 = e2.get("promoCode"), a2 = e2.get("accommodationTypes"), s2 = e2.get("ratePlans");
    if (t2) this.waitForWidgetAndOpen({ cancel: t2 });
    else if (o2 && n2) {
      const e3 = { start: o2, end: n2 };
      i2 && (e3.promoCode = i2), a2 && (e3.accommodationTypes = a2), s2 && (e3.ratePlans = s2), this.waitForWidgetAndOpen(e3);
    }
  }
  waitForWidgetAndOpen(e2) {
    const t2 = setInterval(() => {
      window.customElements.get("bflex-booking-widget") && (clearInterval(t2), window.dispatchEvent(new CustomEvent(d, { detail: { payload: e2 } })));
    }, 100);
    setTimeout(() => clearInterval(t2), 1e4);
  }
}
"undefined" != typeof window && window.BookiFlex?.controller && document.addEventListener("DOMContentLoaded", () => {
  new g(window.BookiFlex.controller);
});
export {
  g as SearchWidgetController
};
