"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const index_es = require("../../../inherits-browser/dist/index.es.js");
const BaseRenderer = require("./BaseRenderer.js");
const RenderUtil = require("../util/RenderUtil.js");
const index_esm = require("../../../tiny-svg/dist/index.esm.js");
const index_esm$1 = require("../../../min-dash/dist/index.esm.js");
const Elements = require("../util/Elements.js");
var DEFAULT_RENDER_PRIORITY = 1;
function DefaultRenderer(eventBus, styles) {
  BaseRenderer.default.call(this, eventBus, DEFAULT_RENDER_PRIORITY);
  this.CONNECTION_STYLE = styles.style(["no-fill"], { strokeWidth: 5, stroke: "fuchsia" });
  this.SHAPE_STYLE = styles.style({ fill: "white", stroke: "fuchsia", strokeWidth: 2 });
  this.FRAME_STYLE = styles.style(["no-fill"], { stroke: "fuchsia", strokeDasharray: 4, strokeWidth: 2 });
}
index_es.default(DefaultRenderer, BaseRenderer.default);
DefaultRenderer.prototype.canRender = function() {
  return true;
};
DefaultRenderer.prototype.drawShape = function drawShape(visuals, element, attrs) {
  var rect = index_esm.create("rect");
  index_esm.attr(rect, {
    x: 0,
    y: 0,
    width: element.width || 0,
    height: element.height || 0
  });
  if (Elements.isFrameElement(element)) {
    index_esm.attr(rect, index_esm$1.assign({}, this.FRAME_STYLE, attrs || {}));
  } else {
    index_esm.attr(rect, index_esm$1.assign({}, this.SHAPE_STYLE, attrs || {}));
  }
  index_esm.append(visuals, rect);
  return rect;
};
DefaultRenderer.prototype.drawConnection = function drawConnection(visuals, connection, attrs) {
  var line = RenderUtil.createLine(connection.waypoints, index_esm$1.assign({}, this.CONNECTION_STYLE, attrs || {}));
  index_esm.append(visuals, line);
  return line;
};
DefaultRenderer.prototype.getShapePath = function getShapePath(shape) {
  var x = shape.x, y = shape.y, width = shape.width, height = shape.height;
  var shapePath = [
    ["M", x, y],
    ["l", width, 0],
    ["l", 0, height],
    ["l", -width, 0],
    ["z"]
  ];
  return RenderUtil.componentsToPath(shapePath);
};
DefaultRenderer.prototype.getConnectionPath = function getConnectionPath(connection) {
  var waypoints = connection.waypoints;
  var idx, point, connectionPath = [];
  for (idx = 0; point = waypoints[idx]; idx++) {
    point = point.original || point;
    connectionPath.push([idx === 0 ? "M" : "L", point.x, point.y]);
  }
  return RenderUtil.componentsToPath(connectionPath);
};
DefaultRenderer.$inject = ["eventBus", "styles"];
exports.default = DefaultRenderer;
