var __classPrivateFieldGet = (this && this.__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 _KlevuUtilDomEvents_clickSendEventHandler, _KlevuUtilDomEvents_filtersAppliedEventHandler, _KlevuUtilDomEvents_filterSelectionUpdateEventHandler, _KlevuUtilDomEvents_lastSearchUpdateEventHandler;
import { KlevuDomEvents } from "@klevu/core";
import { Host, h } from "@stencil/core";
/**
 * Utility compoenent that simplifies listening Klevu SDK Dom events
 * https://docs.klevu.com/headless-sdk/events-analytics#dhk6Y
 *
 */
export class KlevuUtilDomEvents {
  constructor() {
    _KlevuUtilDomEvents_clickSendEventHandler.set(this, (e) => {
      this.klevuClickEventSent.emit(e.detail);
    });
    _KlevuUtilDomEvents_filtersAppliedEventHandler.set(this, (e) => {
      this.klevuFiltersApplied.emit(e.detail);
    });
    _KlevuUtilDomEvents_filterSelectionUpdateEventHandler.set(this, (e) => {
      this.klevuFilterSelectionUpdate.emit(e.detail);
    });
    _KlevuUtilDomEvents_lastSearchUpdateEventHandler.set(this, (e) => {
      this.klevuLastSearchUpdate.emit(e.detail);
    });
  }
  connectedCallback() {
    document.addEventListener(KlevuDomEvents.ClickEventSent, __classPrivateFieldGet(this, _KlevuUtilDomEvents_clickSendEventHandler, "f"));
    document.addEventListener(KlevuDomEvents.FiltersApplied, __classPrivateFieldGet(this, _KlevuUtilDomEvents_filtersAppliedEventHandler, "f"));
    document.addEventListener(KlevuDomEvents.FilterSelectionUpdate, __classPrivateFieldGet(this, _KlevuUtilDomEvents_filterSelectionUpdateEventHandler, "f"));
    document.addEventListener(KlevuDomEvents.LastSearchUpdate, __classPrivateFieldGet(this, _KlevuUtilDomEvents_lastSearchUpdateEventHandler, "f"));
  }
  disconnectedCallback() {
    document.removeEventListener(KlevuDomEvents.ClickEventSent, __classPrivateFieldGet(this, _KlevuUtilDomEvents_clickSendEventHandler, "f"));
    document.removeEventListener(KlevuDomEvents.FiltersApplied, __classPrivateFieldGet(this, _KlevuUtilDomEvents_filtersAppliedEventHandler, "f"));
    document.removeEventListener(KlevuDomEvents.FilterSelectionUpdate, __classPrivateFieldGet(this, _KlevuUtilDomEvents_filterSelectionUpdateEventHandler, "f"));
    document.removeEventListener(KlevuDomEvents.LastSearchUpdate, __classPrivateFieldGet(this, _KlevuUtilDomEvents_lastSearchUpdateEventHandler, "f"));
  }
  render() {
    return (h(Host, null, h("slot", null)));
  }
  static get is() { return "klevu-util-dom-events"; }
  static get encapsulation() { return "shadow"; }
  static get events() {
    return [{
        "method": "klevuLastSearchUpdate",
        "name": "klevuLastSearchUpdate",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "void",
          "resolved": "void",
          "references": {}
        }
      }, {
        "method": "klevuFilterSelectionUpdate",
        "name": "klevuFilterSelectionUpdate",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "{\n    key: string\n    name: string\n    selected: boolean\n  }",
          "resolved": "{ key: string; name: string; selected: boolean; }",
          "references": {}
        }
      }, {
        "method": "klevuFiltersApplied",
        "name": "klevuFiltersApplied",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "{\n    filters: FilterManagerFilters[]\n  }",
          "resolved": "{ filters: FilterManagerFilters[]; }",
          "references": {
            "FilterManagerFilters": {
              "location": "import",
              "path": "@klevu/core",
              "id": "../klevu-core/dist/cjs/index.d.ts::FilterManagerFilters"
            }
          }
        }
      }, {
        "method": "klevuClickEventSent",
        "name": "klevuClickEventSent",
        "bubbles": true,
        "cancelable": true,
        "composed": true,
        "docs": {
          "tags": [],
          "text": ""
        },
        "complexType": {
          "original": "{\n    productId: string\n    product?: Partial<KlevuRecord>\n  }",
          "resolved": "{ productId: string; product?: Partial<KlevuRecord> | undefined; }",
          "references": {
            "Partial": {
              "location": "global",
              "id": "global::Partial"
            },
            "KlevuRecord": {
              "location": "import",
              "path": "@klevu/core",
              "id": "../klevu-core/dist/cjs/index.d.ts::KlevuRecord"
            }
          }
        }
      }];
  }
}
_KlevuUtilDomEvents_clickSendEventHandler = new WeakMap(), _KlevuUtilDomEvents_filtersAppliedEventHandler = new WeakMap(), _KlevuUtilDomEvents_filterSelectionUpdateEventHandler = new WeakMap(), _KlevuUtilDomEvents_lastSearchUpdateEventHandler = new WeakMap();
//# sourceMappingURL=klevu-util-dom-events.js.map
