import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
import { g as globalExportedParts } from './utils.js';
import { d as defineCustomElement$1 } from './klevu-dropdown2.js';
import { K as KlevuSearchSorting } from './KlevuSearchSorting.js';

const klevuSortCss = ":host{display:block}";

var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
  if (kind === "m")
    throw new TypeError("Private method is not writable");
  if (kind === "a" && !f)
    throw new TypeError("Private accessor was defined without a setter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
    throw new TypeError("Cannot write private member to an object whose class did not declare it");
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
  if (kind === "a" && !f)
    throw new TypeError("Private accessor was defined without a getter");
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
    throw new TypeError("Cannot read private member from an object whose class did not declare it");
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _KlevuSort_instances, _KlevuSort_selected, _KlevuSort_onChange;
const KlevuSort = /*@__PURE__*/ proxyCustomElement(class KlevuSort extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.__attachShadow();
    this.klevuSortChanged = createEvent(this, "klevuSortChanged", 7);
    _KlevuSort_instances.add(this);
    _KlevuSort_selected.set(this, KlevuSearchSorting.Relevance);
    this.variant = "default";
    this.options = [
      { value: KlevuSearchSorting.Relevance, text: "Relevance" },
      { value: KlevuSearchSorting.NameAsc, text: "Name ▲" },
      { value: KlevuSearchSorting.NameDesc, text: "Name ▼" },
      { value: KlevuSearchSorting.NewArrivalAsc, text: "New arrivals ▲" },
      { value: KlevuSearchSorting.NewArrivalDesc, text: "New arrivals ▼" },
      { value: KlevuSearchSorting.PriceAsc, text: "Price ▲" },
      { value: KlevuSearchSorting.PriceDesc, text: "Price ▼" },
      { value: KlevuSearchSorting.RatingAsc, text: "Rating ▲" },
      { value: KlevuSearchSorting.RatingDesc, text: "Rating ▼" },
    ];
  }
  render() {
    return (h(Host, null, h("klevu-dropdown", { exportparts: globalExportedParts, name: "sort", options: this.options, selected: __classPrivateFieldGet(this, _KlevuSort_selected, "f"), variant: this.variant, onKlevuDropdownChanged: __classPrivateFieldGet(this, _KlevuSort_instances, "m", _KlevuSort_onChange).bind(this) })));
  }
  static get style() { return klevuSortCss; }
}, [1, "klevu-sort", {
    "variant": [1],
    "options": [16]
  }]);
_KlevuSort_selected = new WeakMap(), _KlevuSort_instances = new WeakSet(), _KlevuSort_onChange = function _KlevuSort_onChange(event) {
  const newSort = event.detail;
  __classPrivateFieldSet(this, _KlevuSort_selected, newSort, "f");
  this.klevuSortChanged.emit(newSort);
};
function defineCustomElement() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["klevu-sort", "klevu-dropdown"];
  components.forEach(tagName => { switch (tagName) {
    case "klevu-sort":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, KlevuSort);
      }
      break;
    case "klevu-dropdown":
      if (!customElements.get(tagName)) {
        defineCustomElement$1();
      }
      break;
  } });
}
defineCustomElement();

export { KlevuSort as K, defineCustomElement as d };

//# sourceMappingURL=klevu-sort2.js.map