"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const collection = require("../../../_virtual/collection.js");
var hasRequiredCollection;
function requireCollection() {
  if (hasRequiredCollection) return collection.__exports;
  hasRequiredCollection = 1;
  function extend(collection2, refs, property, target) {
    var inverseProperty = property.inverse;
    Object.defineProperty(collection2, "remove", {
      value: function(element) {
        var idx = this.indexOf(element);
        if (idx !== -1) {
          this.splice(idx, 1);
          refs.unset(element, inverseProperty, target);
        }
        return element;
      }
    });
    Object.defineProperty(collection2, "contains", {
      value: function(element) {
        return this.indexOf(element) !== -1;
      }
    });
    Object.defineProperty(collection2, "add", {
      value: function(element, idx) {
        var currentIdx = this.indexOf(element);
        if (typeof idx === "undefined") {
          if (currentIdx !== -1) {
            return;
          }
          idx = this.length;
        }
        if (currentIdx !== -1) {
          this.splice(currentIdx, 1);
        }
        this.splice(idx, 0, element);
        if (currentIdx === -1) {
          refs.set(element, inverseProperty, target);
        }
      }
    });
    Object.defineProperty(collection2, "__refs_collection", {
      value: true
    });
    return collection2;
  }
  function isExtended(collection2) {
    return collection2.__refs_collection === true;
  }
  collection.__exports.extend = extend;
  collection.__exports.isExtended = isExtended;
  return collection.__exports;
}
exports.__require = requireCollection;
