import { css, LitElement, html } from "lit";
import { property } from "lit/decorators.js";
import { LineMedium, LineType, lineColor, lineWidth } from "../index.js";
import { customElement } from "../../decorator.js";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
var EndPointDirection = /* @__PURE__ */ ((EndPointDirection2) => {
  EndPointDirection2["top"] = "top";
  EndPointDirection2["right"] = "right";
  EndPointDirection2["bottom"] = "bottom";
  EndPointDirection2["left"] = "left";
  return EndPointDirection2;
})(EndPointDirection || {});
let ObcEndPointLine = class extends LitElement {
  constructor() {
    super(...arguments);
    this.medium = LineMedium.normal;
    this.direction = "top";
    this.lineType = LineType.fluid;
  }
  render() {
    let rotation = 0;
    if (this.direction === "top") {
      rotation = 180;
    } else if (this.direction === "right") {
      rotation = 270;
    } else if (this.direction === "bottom") {
      rotation = 0;
    } else if (this.direction === "left") {
      rotation = 90;
    }
    if (this.lineType === LineType.connector) {
      throw new Error(
        "Connector line type is not supported for end-point line"
      );
    }
    const color = lineColor(this.medium);
    const width = lineWidth(this.lineType) + 1;
    const h = width / 2;
    let terminalWidth;
    if (this.lineType === LineType.electric) {
      terminalWidth = 15;
    } else if (this.lineType === LineType.air) {
      terminalWidth = 22;
    } else if (this.lineType === LineType.fluid) {
      terminalWidth = 16;
    } else {
      throw new Error("Invalid line type");
    }
    terminalWidth -= 1;
    return html`
      <svg
        class="line"
        width="24"
        height="24"
        viewBox="0 0 24 24"
        fill="none"
        xmlns="http://www.w3.org/2000/svg"
        transform="rotate(${rotation})"
        class="${this.direction}"
      >
        <path
          d="M${12 - h} 25 V${12 + h}h-${(terminalWidth - width) / 2}v-${width}h${terminalWidth}v${width}h-${(terminalWidth - width) / 2}V25Z"
          fill="var(${color.inner})"
          stroke="var(${color.outer})"
        />
      </svg>
    `;
  }
};
ObcEndPointLine.styles = css`
    :host {
      display: block;
      line-height: 0;
    }

    svg {
      position: relative;

      &.top,
      &.bottom {
        left: -12px;
      }

      &.bottom {
        top: -24px;
      }

      &.left,
      &.right {
        top: -12px;
      }

      &.right {
        left: -24px;
      }
    }
  `;
__decorateClass([
  property({ type: String })
], ObcEndPointLine.prototype, "medium", 2);
__decorateClass([
  property({ type: String })
], ObcEndPointLine.prototype, "direction", 2);
__decorateClass([
  property({ type: String })
], ObcEndPointLine.prototype, "lineType", 2);
ObcEndPointLine = __decorateClass([
  customElement("obc-end-point-line")
], ObcEndPointLine);
export {
  EndPointDirection,
  ObcEndPointLine
};
//# sourceMappingURL=end-point-line.js.map
