/*! * Copyright (c) 2023, 2026, Oracle and/or its affiliates. */ import Link from "./Link.mjs"; const COLOR_NORMAL = "var(--a-diagram-link-border-color, #666)"; const COLOR_ERROR = "var(--a-palette-danger, #f00)"; const COLOR_ROUTE = "var(--a-diagram-route-default, #808080)"; export default class SingleLink extends Link { preinitialize() { super.preinitialize( ...arguments ); this.markup = [{ tagName: "path", selector: "wrapper", attributes: { "fill": "none", "stroke": "transparent", "stroke-linecap": "round" } }, { tagName: "path", selector: "line", attributes: { "fill": "none", "pointer-events": "none" } }]; } constructor() { super( ...arguments ); if ( this.prop( "error" ) ) { this.attr( "line/stroke", COLOR_ERROR ); this.attr( "line/targetMarker/stroke", COLOR_ERROR ); } } defaults() { return { ...super.defaults, type: "apex.SingleLink", designation: null, attrs: { ...super.defaults.attrs, line: { ...super.defaults.attrs.line, stroke: COLOR_NORMAL, targetMarker: { type: "path", stroke: COLOR_NORMAL, "stroke-width": 2, fill: "none", d: "M 6 -6 L 0 0 L 6 6", } } } }; } error( b ) { if ( !arguments.length ) { return this.prop( "error" ) || false; } else { this.prop( "error", b ); const color = b ? COLOR_ERROR : COLOR_NORMAL; this.attr( "line/stroke", color ); this.attr( "line/targetMarker/stroke", color ); } } route( b, color = COLOR_ROUTE ) { if ( b ) { this.attr( { line: { stroke: color, "stroke-width": 4, targetMarker: { stroke: color, fill: color, d: "M 11 -7 L -3 0 L 11 7Z" } } } ); } else { this.attr( { line: { "stroke-width": 2, targetMarker: { fill: "none", d: "M 6 -6 L 0 0 L 6 6" } } } ); // redraw in correct color this.error() ? this.error( true ) : this.error( false ); } } designation( des ) { if ( !arguments.length ) { return this.prop( "designation" ); } else { this.prop( "designation", des ); } } }