import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';

function isEqualTag(a, b) {
  return typeof a.tagName === 'undefined' ? a.nodeType === b.nodeType : a.tagName === b.tagName;
}
function parseChildNodes(items, targets) {
  const list = Array.from(targets.values());
  for (let i = 0, j = 0; i < list.length; i++, j++) {
    const target = list[i];
    let item = items.item(j);
    while (item && !isEqualTag(item, target)) {
      item.remove();
      j++;
      item = items.item(j);
    }
    if (item && !item.isEqualNode(target)) {
      parseChildNodes(item.childNodes, target.childNodes);
    }
    while (i === list.length - 1 && j < items.length) {
      j++;
      item = items.item(j);
      item === null || item === void 0 ? void 0 : item.remove();
    }
  }
}
const SwiperItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  constructor() {
    super();
    this.__registerHost();
    this.itemId = undefined;
  }
  componentDidRender() {
    var _a, _b, _c;
    const el = this.el;
    if (el.classList.contains('swiper-slide-duplicate')) {
      const list = Array
        .from(((_b = (_a = el.parentElement) === null || _a === void 0 ? void 0 : _a.childNodes) === null || _b === void 0 ? void 0 : _b.values()) || [])
        .filter((e) => e.tagName === 'TARO-SWIPER-ITEM-CORE');
      if (list.length > 0) {
        parseChildNodes(el.childNodes, (_c = list[list.indexOf(el) === 0 ? list.length - 2 : 1]) === null || _c === void 0 ? void 0 : _c.childNodes);
      }
    }
  }
  render() {
    return (h(Host, { class: 'swiper-slide', "item-id": this.itemId }));
  }
  get el() { return this; }
}, [0, "taro-swiper-item-core", {
    "itemId": [1, "item-id"]
  }]);
function defineCustomElement$1() {
  if (typeof customElements === "undefined") {
    return;
  }
  const components = ["taro-swiper-item-core"];
  components.forEach(tagName => { switch (tagName) {
    case "taro-swiper-item-core":
      if (!customElements.get(tagName)) {
        customElements.define(tagName, SwiperItem);
      }
      break;
  } });
}

const TaroSwiperItemCore = SwiperItem;
const defineCustomElement = defineCustomElement$1;

export { TaroSwiperItemCore, defineCustomElement };

//# sourceMappingURL=taro-swiper-item-core.js.map