"use strict";
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/Cube.ts
var Cube_exports = {};
__export(Cube_exports, {
  CUBE_ATTRIBUTES: () => CUBE_ATTRIBUTES,
  default: () => Cube
});
module.exports = __toCommonJS(Cube_exports);
var import_Cube = __toESM(require("@boxslider/slider/effects/Cube"), 1);

// src/Slider.ts
var import_BoxSlider = __toESM(require("@boxslider/slider/BoxSlider"), 1);
function camelize(str) {
  return str.replace(/-./g, (m) => m[1].toUpperCase());
}
function getNumericAttribute(el, attribute, defaultValue) {
  const attributeValue = el.getAttribute(attribute);
  let value = NaN;
  if (attributeValue !== null) {
    value = parseInt(attributeValue, 10);
  }
  return isNaN(value) ? defaultValue : value;
}
function getBbooleanAttribute(el, attribute, defaultValue) {
  if (el.hasAttribute(attribute)) {
    return el.getAttribute(attribute) !== "false";
  }
  return defaultValue;
}
var BOOLEAN_ATTRIBUTES = ["auto-scroll", "pause-on-hover"];
var NUMBER_ATTRIBUTES = [
  "speed",
  "timeout",
  "start-index",
  "swipe",
  "swipe-tolerance"
];
var SLIDER_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...NUMBER_ATTRIBUTES];
var Slider = class extends HTMLElement {
  #slider;
  get slider() {
    return this.#slider;
  }
  get autoScroll() {
    return getBbooleanAttribute(this, "auto-scroll", import_BoxSlider.defaultOptions.autoScroll);
  }
  get pauseOnHover() {
    return getBbooleanAttribute(
      this,
      "pause-on-hover",
      import_BoxSlider.defaultOptions.pauseOnHover
    );
  }
  get speed() {
    return getNumericAttribute(this, "speed", import_BoxSlider.defaultOptions.speed);
  }
  get startIndex() {
    return getNumericAttribute(this, "start-index", import_BoxSlider.defaultOptions.startIndex);
  }
  get swipe() {
    return getBbooleanAttribute(this, "swipe", import_BoxSlider.defaultOptions.swipe);
  }
  get swipeTolerance() {
    return getNumericAttribute(
      this,
      "swipe-tolerance",
      import_BoxSlider.defaultOptions.swipeTolerance
    );
  }
  get timeout() {
    return getNumericAttribute(this, "timeout", import_BoxSlider.defaultOptions.timeout);
  }
  get options() {
    return {
      autoScroll: this.autoScroll,
      pauseOnHover: this.pauseOnHover,
      speed: this.speed,
      startIndex: this.startIndex,
      swipe: this.swipe,
      swipeTolerance: this.swipeTolerance,
      timeout: this.timeout
    };
  }
  init(effect) {
    const slider = new import_BoxSlider.default(this, effect, this.options);
    const events = [
      "play",
      "pause",
      "before",
      "after",
      "destroy"
    ];
    events.forEach(
      (ev) => slider.addEventListener(
        ev,
        (detail) => this.dispatchEvent(new CustomEvent(ev, { detail }))
      )
    );
    this.#slider = slider;
  }
  reset(options, effect) {
    this.slider?.reset(options, effect);
  }
  attributeChangedCallback(name) {
    if (SLIDER_ATTRIBUTES.includes(name)) {
      const propName = camelize(name);
      this.reset({ [propName]: this[propName] });
    }
  }
  disconnectedCallback() {
    this.slider?.destroy();
    this.#slider = void 0;
  }
};

// src/Cube.ts
var CUBE_ATTRIBUTES = ["direction", "perspective"];
var Cube = class extends Slider {
  static observedAttributes = [...SLIDER_ATTRIBUTES, ...CUBE_ATTRIBUTES];
  get direction() {
    const propDirection = this.getAttribute("direction")?.trim();
    if (propDirection === "horizontal" || propDirection === "vertical") {
      return propDirection;
    }
    return "horizontal";
  }
  get perspective() {
    return getNumericAttribute(this, "perspective", 1e3);
  }
  attributeChangedCallback(name) {
    if (CUBE_ATTRIBUTES.includes(name)) {
      const propName = camelize(name);
      this.reset(
        { [propName]: this[propName] },
        new import_Cube.default({
          direction: this.direction,
          perspective: this.perspective
        })
      );
    } else {
      super.attributeChangedCallback(name);
    }
  }
  connectedCallback() {
    this.init(
      new import_Cube.default({
        direction: this.direction,
        perspective: this.perspective
      })
    );
  }
};
if (typeof customElements !== "undefined") {
  customElements.define("bs-cube", Cube);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  CUBE_ATTRIBUTES
});
