text: define(["exports", "../../../../../lit-element/lit-element.js", "../../core/haxcms-site-store.js"], function (_exports, _litElement, _haxcmsSiteStore) {
    "use strict";
  
    Object.defineProperty(_exports, "__esModule", {
      value: true
    });
    _exports.ActiveWhenVisible = void 0;
  
    var _templateObject_c297e650af6311ebbe560fe9c4727db1, _templateObject2_c297e650af6311ebbe560fe9c4727db1;
  
    function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
  
    function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  
    function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  
    function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = babelHelpers.getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = babelHelpers.getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return babelHelpers.possibleConstructorReturn(this, result); }; }
  
    function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
  
    /**
     * `active-when-visible`
     * `Title of the site`
     *
     * @demo demo/index.html
     */
    var ActiveWhenVisible = /*#__PURE__*/function (_LitElement) {
      babelHelpers.inherits(ActiveWhenVisible, _LitElement);
  
      var _super = _createSuper(ActiveWhenVisible);
  
      function ActiveWhenVisible() {
        var _this;
  
        babelHelpers.classCallCheck(this, ActiveWhenVisible);
        _this = _super.call(this);
        _this.thresholds = [0.0, 0.25, 0.5, 0.75, 1.0];
        _this.rootMargin = "0px";
        _this.visibleLimit = 0.5;
        _this.isVisible = false;
        return _this;
      }
  
      babelHelpers.createClass(ActiveWhenVisible, [{
        key: "render",
        value: // render function
        function render() {
          return (0, _litElement.html)(_templateObject_c297e650af6311ebbe560fe9c4727db1 || (_templateObject_c297e650af6311ebbe560fe9c4727db1 = babelHelpers.taggedTemplateLiteral(["\n      <div>\n        <a\n          id=\"a\"\n          .href=\"", "\"\n          .name=\"#", "\"\n          aria-hidden=\"true\"\n        ></a>\n        <slot></slot>\n      </div>\n    "])), this._a, this.itemId);
        }
      }, {
        key: "updated",
        value: function updated(changedProperties) {
          var _this2 = this;
  
          changedProperties.forEach(function (oldValue, propName) {
            if (propName == "isVisible") {
              // fire an event that this is a core piece of the system
              _this2.dispatchEvent(new CustomEvent("is-visible-changed", {
                detail: _this2[propName]
              }));
            }
          });
        }
        /**
         * LitElement / popular convention
         */
  
      }, {
        key: "connectedCallback",
        value: function connectedCallback() {
          babelHelpers.get(babelHelpers.getPrototypeOf(ActiveWhenVisible.prototype), "connectedCallback", this).call(this); // setup the intersection observer
  
          this.observer = new IntersectionObserver(this.handleIntersectionCallback.bind(this), {
            root: document.rootElement,
            rootMargin: this.rootMargin,
            threshold: this.thresholds
          });
          this.observer.observe(this);
        }
        /**
         * Handle this being visible
         */
  
      }, {
        key: "handleIntersectionCallback",
        value: function handleIntersectionCallback(entries) {
          var _this3 = this;
  
          var _iterator = _createForOfIteratorHelper(entries),
              _step;
  
          try {
            for (_iterator.s(); !(_step = _iterator.n()).done;) {
              var entry = _step.value;
  
              if (Number(entry.intersectionRatio).toFixed(2) >= this.visibleLimit) {
                // now we care
                if (this.itemId) {
                  var item = _haxcmsSiteStore.store.findItem(this.itemId);
  
                  this._a = item.slug;
                  this.isVisible = true;
                  setTimeout(function () {
                    _this3.shadowRoot.querySelector("#a").click();
                  }, 25);
                }
              }
            }
          } catch (err) {
            _iterator.e(err);
          } finally {
            _iterator.f();
          }
        }
      }], [{
        key: "styles",
        get: function get() {
          return [(0, _litElement.css)(_templateObject2_c297e650af6311ebbe560fe9c4727db1 || (_templateObject2_c297e650af6311ebbe560fe9c4727db1 = babelHelpers.taggedTemplateLiteral(["\n        :host {\n          display: block;\n        }\n        a {\n          height: 10px;\n          width: 10px;\n          float: left;\n          pointer-events: none;\n          background-color: transparent;\n        }\n      "])))];
        }
        /**
         * Store the tag name to make it easier to obtain directly.
         */
  
      }, {
        key: "tag",
        get: function get() {
          return "active-when-visible";
        }
      }, {
        key: "properties",
        get: function get() {
          return {
            itemId: {
              type: String,
              attribute: "item-id"
            },
            _a: {
              type: String
            },
            thresholds: {
              type: Array
            },
            rootMargin: {
              type: String,
              attribute: "root-margin"
            },
            visibleLimit: {
              type: Number,
              reflect: true,
              attribute: "visible-limit"
            },
            isVisible: {
              type: Boolean,
              attribute: "is-visible"
            }
          };
        }
      }]);
      return ActiveWhenVisible;
    }(_litElement.LitElement);
  
    _exports.ActiveWhenVisible = ActiveWhenVisible;
    window.customElements.define(ActiveWhenVisible.tag, ActiveWhenVisible);
  });