"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index_esm = require("../../../min-dash/dist/index.esm.js");
const index_es = require("../../../inherits-browser/dist/index.es.js");
const index = require("../../../../_virtual/index.js");
var parentRefs = new index.default({ name: "children", enumerable: true, collection: true }, { name: "parent" }), labelRefs = new index.default({ name: "labels", enumerable: true, collection: true }, { name: "labelTarget" }), attacherRefs = new index.default({ name: "attachers", collection: true }, { name: "host" }), outgoingRefs = new index.default({ name: "outgoing", collection: true }, { name: "source" }), incomingRefs = new index.default({ name: "incoming", collection: true }, { name: "target" });
function Base() {
  Object.defineProperty(this, "businessObject", {
    writable: true
  });
  Object.defineProperty(this, "label", {
    get: function() {
      return this.labels[0];
    },
    set: function(newLabel) {
      var label = this.label, labels = this.labels;
      if (!newLabel && label) {
        labels.remove(label);
      } else {
        labels.add(newLabel, 0);
      }
    }
  });
  parentRefs.bind(this, "parent");
  labelRefs.bind(this, "labels");
  outgoingRefs.bind(this, "outgoing");
  incomingRefs.bind(this, "incoming");
}
function Shape() {
  Base.call(this);
  parentRefs.bind(this, "children");
  attacherRefs.bind(this, "host");
  attacherRefs.bind(this, "attachers");
}
index_es.default(Shape, Base);
function Root() {
  Shape.call(this);
}
index_es.default(Root, Shape);
function Label() {
  Shape.call(this);
  labelRefs.bind(this, "labelTarget");
}
index_es.default(Label, Shape);
function Connection() {
  Base.call(this);
  outgoingRefs.bind(this, "source");
  incomingRefs.bind(this, "target");
}
index_es.default(Connection, Base);
var types = {
  connection: Connection,
  shape: Shape,
  label: Label,
  root: Root
};
function create(type, attrs) {
  var Type = types[type];
  if (!Type) {
    throw new Error("unknown type: <" + type + ">");
  }
  return index_esm.assign(new Type(), attrs);
}
exports.Base = Base;
exports.Connection = Connection;
exports.Label = Label;
exports.Root = Root;
exports.Shape = Shape;
exports.create = create;
