text: "use strict";
  /********************************************************************************
   * Copyright (c) 2017-2020 TypeFox and others.
   *
   * This program and the accompanying materials are made available under the
   * terms of the Eclipse Public License v. 2.0 which is available at
   * http://www.eclipse.org/legal/epl-2.0.
   *
   * This Source Code may also be made available under the following Secondary
   * Licenses when the conditions for such availability set forth in the Eclipse
   * Public License v. 2.0 are satisfied: GNU General Public License, version 2
   * with the GNU Classpath Exception which is available at
   * https://www.gnu.org/software/classpath/license.html.
   *
   * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
   ********************************************************************************/
  var __extends = (this && this.__extends) || (function () {
      var extendStatics = function (d, b) {
          extendStatics = Object.setPrototypeOf ||
              ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
              function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
          return extendStatics(d, b);
      };
      return function (d, b) {
          extendStatics(d, b);
          function __() { this.constructor = d; }
          d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
      };
  })();
  Object.defineProperty(exports, "__esModule", { value: true });
  var smodel_1 = require("../base/model/smodel");
  var geometry_1 = require("../utils/geometry");
  var model_1 = require("../features/bounds/model");
  var model_2 = require("../features/move/model");
  var model_3 = require("../features/select/model");
  var sgraph_1 = require("../graph/sgraph");
  var anchor_1 = require("../features/routing/anchor");
  /**
   * A node that is represented by a circle.
   */
  var CircularNode = /** @class */ (function (_super) {
      __extends(CircularNode, _super);
      function CircularNode() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      Object.defineProperty(CircularNode.prototype, "anchorKind", {
          get: function () {
              return anchor_1.ELLIPTIC_ANCHOR_KIND;
          },
          enumerable: true,
          configurable: true
      });
      return CircularNode;
  }(sgraph_1.SNode));
  exports.CircularNode = CircularNode;
  /**
   * A node that is represented by a rectangle.
   */
  var RectangularNode = /** @class */ (function (_super) {
      __extends(RectangularNode, _super);
      function RectangularNode() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      Object.defineProperty(RectangularNode.prototype, "anchorKind", {
          get: function () {
              return anchor_1.RECTANGULAR_ANCHOR_KIND;
          },
          enumerable: true,
          configurable: true
      });
      return RectangularNode;
  }(sgraph_1.SNode));
  exports.RectangularNode = RectangularNode;
  /**
   * A node that is represented by a diamond.
   */
  var DiamondNode = /** @class */ (function (_super) {
      __extends(DiamondNode, _super);
      function DiamondNode() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      Object.defineProperty(DiamondNode.prototype, "anchorKind", {
          get: function () {
              return anchor_1.DIAMOND_ANCHOR_KIND;
          },
          enumerable: true,
          configurable: true
      });
      return DiamondNode;
  }(sgraph_1.SNode));
  exports.DiamondNode = DiamondNode;
  /**
   * A port that is represented by a circle.
   */
  var CircularPort = /** @class */ (function (_super) {
      __extends(CircularPort, _super);
      function CircularPort() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      Object.defineProperty(CircularPort.prototype, "anchorKind", {
          get: function () {
              return anchor_1.ELLIPTIC_ANCHOR_KIND;
          },
          enumerable: true,
          configurable: true
      });
      return CircularPort;
  }(sgraph_1.SPort));
  exports.CircularPort = CircularPort;
  /**
   * A port that is represented by a rectangle.
   */
  var RectangularPort = /** @class */ (function (_super) {
      __extends(RectangularPort, _super);
      function RectangularPort() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      Object.defineProperty(RectangularPort.prototype, "anchorKind", {
          get: function () {
              return anchor_1.RECTANGULAR_ANCHOR_KIND;
          },
          enumerable: true,
          configurable: true
      });
      return RectangularPort;
  }(sgraph_1.SPort));
  exports.RectangularPort = RectangularPort;
  /**
   * Root model element class for HTML content. Usually this is rendered with a `div` DOM element.
   */
  var HtmlRoot = /** @class */ (function (_super) {
      __extends(HtmlRoot, _super);
      function HtmlRoot() {
          var _this = _super !== null && _super.apply(this, arguments) || this;
          _this.classes = [];
          return _this;
      }
      return HtmlRoot;
  }(smodel_1.SModelRoot));
  exports.HtmlRoot = HtmlRoot;
  /**
   * Pre-rendered elements contain HTML or SVG code to be transferred to the DOM. This can be useful to
   * render complex figures or to compute the view on the server instead of the client code.
   */
  var PreRenderedElement = /** @class */ (function (_super) {
      __extends(PreRenderedElement, _super);
      function PreRenderedElement() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      return PreRenderedElement;
  }(smodel_1.SChildElement));
  exports.PreRenderedElement = PreRenderedElement;
  /**
   * Same as PreRenderedElement, but with a position and a size.
   */
  var ShapedPreRenderedElement = /** @class */ (function (_super) {
      __extends(ShapedPreRenderedElement, _super);
      function ShapedPreRenderedElement() {
          var _this = _super !== null && _super.apply(this, arguments) || this;
          _this.position = geometry_1.ORIGIN_POINT;
          _this.size = geometry_1.EMPTY_DIMENSION;
          _this.selected = false;
          _this.alignment = geometry_1.ORIGIN_POINT;
          return _this;
      }
      Object.defineProperty(ShapedPreRenderedElement.prototype, "bounds", {
          get: function () {
              return {
                  x: this.position.x,
                  y: this.position.y,
                  width: this.size.width,
                  height: this.size.height
              };
          },
          set: function (newBounds) {
              this.position = {
                  x: newBounds.x,
                  y: newBounds.y
              };
              this.size = {
                  width: newBounds.width,
                  height: newBounds.height
              };
          },
          enumerable: true,
          configurable: true
      });
      ShapedPreRenderedElement.DEFAULT_FEATURES = [model_2.moveFeature, model_1.boundsFeature, model_3.selectFeature, model_1.alignFeature];
      return ShapedPreRenderedElement;
  }(PreRenderedElement));
  exports.ShapedPreRenderedElement = ShapedPreRenderedElement;
  /**
   * A `foreignObject` element to be transferred to the DOM within the SVG.
   *
   * This can be useful to to benefit from e.g. HTML rendering features, such as line wrapping, inside of
   * the SVG diagram.  Note that `foreignObject` is not supported by all browsers and SVG viewers may not
   * support rendering the `foreignObject` content.
   *
   * If no dimensions are specified in the schema element, this element will obtain the dimension of
   * its parent to fill the entire available room. Thus, this element requires specified bounds itself
   * or bounds to be available for its parent.
   */
  var ForeignObjectElement = /** @class */ (function (_super) {
      __extends(ForeignObjectElement, _super);
      function ForeignObjectElement() {
          return _super !== null && _super.apply(this, arguments) || this;
      }
      Object.defineProperty(ForeignObjectElement.prototype, "bounds", {
          get: function () {
              if (geometry_1.isValidDimension(this.size)) {
                  return {
                      x: this.position.x,
                      y: this.position.y,
                      width: this.size.width,
                      height: this.size.height
                  };
              }
              else if (model_1.isBoundsAware(this.parent)) {
                  return {
                      x: this.position.x,
                      y: this.position.y,
                      width: this.parent.bounds.width,
                      height: this.parent.bounds.height
                  };
              }
              return geometry_1.EMPTY_BOUNDS;
          },
          enumerable: true,
          configurable: true
      });
      return ForeignObjectElement;
  }(ShapedPreRenderedElement));
  exports.ForeignObjectElement = ForeignObjectElement;
  //# sourceMappingURL=model.js.map