lightweight-charts-drawing 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lightweight-charts-drawing.umd.js","sources":["../src/core/types.ts","../src/core/geometry.ts","../src/core/drawing.ts","../src/core/drawing-manager.ts","../src/interaction/interaction-handler.ts","../src/rendering/canvas-utils.ts","../src/rendering/preview-renderer.ts","../src/rendering/drawing-pane-view.ts","../src/tools/lines/base-line.ts","../src/tools/lines/trend-line-pane-view.ts","../src/tools/lines/trend-line.ts","../src/tools/lines/horizontal-line-pane-view.ts","../src/tools/lines/horizontal-line.ts","../src/tools/lines/vertical-line-pane-view.ts","../src/tools/lines/vertical-line.ts","../src/tools/lines/ray-pane-view.ts","../src/tools/lines/ray.ts","../src/tools/lines/arrow-pane-view.ts","../src/tools/lines/arrow.ts","../src/tools/lines/extended-line-pane-view.ts","../src/tools/lines/extended-line.ts","../src/tools/lines/cross-line-pane-view.ts","../src/tools/lines/cross-line.ts","../src/tools/lines/info-line-pane-view.ts","../src/tools/lines/info-line.ts","../src/tools/lines/trend-angle-pane-view.ts","../src/tools/lines/trend-angle.ts","../src/tools/lines/horizontal-ray-pane-view.ts","../src/tools/lines/horizontal-ray.ts","../src/tools/shapes/rectangle-pane-view.ts","../src/tools/shapes/rectangle.ts","../src/tools/shapes/rotated-rectangle-pane-view.ts","../src/tools/shapes/rotated-rectangle.ts","../src/tools/shapes/circle-pane-view.ts","../src/tools/shapes/circle.ts","../src/tools/shapes/triangle-pane-view.ts","../src/tools/shapes/triangle.ts","../src/tools/shapes/price-range-pane-view.ts","../src/tools/shapes/price-range.ts","../src/tools/shapes/ellipse-pane-view.ts","../src/tools/shapes/ellipse.ts","../src/tools/shapes/arc-pane-view.ts","../src/tools/shapes/arc.ts","../src/tools/shapes/path-pane-view.ts","../src/tools/shapes/path.ts","../src/tools/shapes/polyline-pane-view.ts","../src/tools/shapes/polyline.ts","../src/tools/shapes/curve-pane-view.ts","../src/tools/shapes/curve.ts","../src/tools/shapes/double-curve-pane-view.ts","../src/tools/shapes/double-curve.ts","../src/tools/channels/parallel-channel-pane-view.ts","../src/tools/channels/parallel-channel.ts","../src/tools/channels/regression-trend-pane-view.ts","../src/tools/channels/regression-trend.ts","../src/tools/channels/flat-top-bottom-pane-view.ts","../src/tools/channels/flat-top-bottom.ts","../src/tools/channels/disjoint-channel-pane-view.ts","../src/tools/channels/disjoint-channel.ts","../src/tools/channels/fib-retracement-pane-view.ts","../src/tools/channels/fib-retracement.ts","../src/tools/fibonacci/fib-extension-pane-view.ts","../src/tools/fibonacci/fib-extension.ts","../src/tools/fibonacci/fib-channel-pane-view.ts","../src/tools/fibonacci/fib-channel.ts","../src/tools/fibonacci/fib-time-zone-pane-view.ts","../src/tools/fibonacci/fib-time-zone.ts","../src/tools/fibonacci/fib-speed-fan-pane-view.ts","../src/tools/fibonacci/fib-speed-fan.ts","../src/tools/fibonacci/fib-time-extension-pane-view.ts","../src/tools/fibonacci/fib-time-extension.ts","../src/tools/fibonacci/fib-circles-pane-view.ts","../src/tools/fibonacci/fib-circles.ts","../src/tools/fibonacci/fib-spiral-pane-view.ts","../src/tools/fibonacci/fib-spiral.ts","../src/tools/fibonacci/fib-arcs-pane-view.ts","../src/tools/fibonacci/fib-arcs.ts","../src/tools/fibonacci/fib-wedge-pane-view.ts","../src/tools/fibonacci/fib-wedge.ts","../src/tools/fibonacci/pitchfan-pane-view.ts","../src/tools/fibonacci/pitchfan.ts","../src/tools/pitchforks/andrews-pitchfork-pane-view.ts","../src/tools/pitchforks/andrews-pitchfork.ts","../src/tools/pitchforks/schiff-pitchfork-pane-view.ts","../src/tools/pitchforks/schiff-pitchfork.ts","../src/tools/pitchforks/modified-schiff-pitchfork-pane-view.ts","../src/tools/pitchforks/modified-schiff-pitchfork.ts","../src/tools/pitchforks/inside-pitchfork-pane-view.ts","../src/tools/pitchforks/inside-pitchfork.ts","../src/tools/gann/gann-box-pane-view.ts","../src/tools/gann/gann-box.ts","../src/tools/gann/gann-fan-pane-view.ts","../src/tools/gann/gann-fan.ts","../src/tools/gann/gann-square-fixed-pane-view.ts","../src/tools/gann/gann-square-fixed.ts","../src/tools/gann/gann-square-pane-view.ts","../src/tools/gann/gann-square.ts","../src/tools/forecasting/long-position-pane-view.ts","../src/tools/forecasting/long-position.ts","../src/tools/forecasting/short-position-pane-view.ts","../src/tools/forecasting/short-position.ts","../src/tools/forecasting/date-range-pane-view.ts","../src/tools/forecasting/date-range.ts","../src/tools/forecasting/date-price-range-pane-view.ts","../src/tools/forecasting/date-price-range.ts","../src/tools/forecasting/projection-pane-view.ts","../src/tools/forecasting/projection.ts","../src/tools/forecasting/forecast-pane-view.ts","../src/tools/forecasting/forecast.ts","../src/tools/forecasting/bars-pattern-pane-view.ts","../src/tools/forecasting/bars-pattern.ts","../src/tools/annotations/text-annotation-pane-view.ts","../src/tools/annotations/text-annotation.ts","../src/tools/annotations/callout-pane-view.ts","../src/tools/annotations/callout.ts","../src/tools/annotations/brush-pane-view.ts","../src/tools/annotations/brush.ts","../src/tools/annotations/highlighter-pane-view.ts","../src/tools/annotations/highlighter.ts","../src/tools/annotations/arrow-marker-pane-view.ts","../src/tools/annotations/arrow-marker.ts","../src/tools/annotations/arrow-mark-up-pane-view.ts","../src/tools/annotations/arrow-mark-up.ts","../src/tools/annotations/arrow-mark-down-pane-view.ts","../src/tools/annotations/arrow-mark-down.ts","../src/tools/annotations/anchored-text-pane-view.ts","../src/tools/annotations/anchored-text.ts","../src/tools/annotations/note-pane-view.ts","../src/tools/annotations/note.ts","../src/tools/annotations/price-note-pane-view.ts","../src/tools/annotations/price-note.ts","../src/tools/annotations/price-label-pane-view.ts","../src/tools/annotations/price-label.ts","../src/tools/annotations/flag-mark-pane-view.ts","../src/tools/annotations/flag-mark.ts","../src/tools/annotations/pin-pane-view.ts","../src/tools/annotations/pin.ts","../src/tools/annotations/comment-pane-view.ts","../src/tools/annotations/comment.ts","../src/tools/annotations/signpost-pane-view.ts","../src/tools/annotations/signpost.ts","../src/tools/annotations/table-pane-view.ts","../src/tools/annotations/table.ts","../src/registry/tool-registry.ts","../src/index.ts"],"sourcesContent":["import type {\n IChartApi,\n ISeriesApi,\n SeriesType,\n Time,\n Coordinate,\n Logical,\n IPrimitivePaneView,\n} from 'lightweight-charts';\n\n/**\n * Anchor point in chart coordinates (time/price)\n */\nexport interface Anchor {\n time: Time;\n price: number;\n}\n\n/**\n * Point in pixel coordinates\n */\nexport interface Point {\n x: number;\n y: number;\n}\n\n/**\n * Visual style for drawings\n */\nexport interface DrawingStyle {\n lineColor: string;\n lineWidth: number;\n lineDash?: number[];\n fillColor?: string;\n fillOpacity?: number;\n showLabels?: boolean;\n labelFont?: string;\n labelColor?: string;\n}\n\n/**\n * Default drawing style\n */\nexport const DEFAULT_DRAWING_STYLE: DrawingStyle = {\n lineColor: '#2962FF',\n lineWidth: 2,\n lineDash: [],\n fillColor: 'rgba(41, 98, 255, 0.1)',\n fillOpacity: 0.1,\n showLabels: true,\n labelFont: '12px sans-serif',\n labelColor: '#2962FF',\n};\n\n/**\n * Drawing options beyond style\n */\nexport interface DrawingOptions {\n visible?: boolean;\n locked?: boolean;\n zIndex?: number;\n extendLeft?: boolean;\n extendRight?: boolean;\n}\n\n/**\n * Drawing state for selection/editing\n */\nexport type DrawingState = 'normal' | 'hovered' | 'selected' | 'editing';\n\n/**\n * Serialized drawing data for persistence\n */\nexport interface SerializedDrawing {\n id: string;\n type: string;\n anchors: Anchor[];\n style: DrawingStyle;\n options: DrawingOptions;\n}\n\n/**\n * Viewport information for rendering\n */\nexport interface Viewport {\n width: number;\n height: number;\n timeScale: {\n coordinateToTime(x: number): Time | null;\n timeToCoordinate(time: Time): Coordinate | null;\n logicalToCoordinate(logical: Logical): Coordinate | null;\n };\n priceScale: {\n coordinateToPrice(y: number): number | null;\n priceToCoordinate(price: number): Coordinate | null;\n };\n}\n\n/**\n * Mouse event data passed to interaction handlers\n */\nexport interface MouseEventData {\n point: Point;\n time: Time | null;\n price: number | null;\n srcEvent: MouseEvent;\n}\n\n/**\n * Pixel to chart coordinate conversion function\n */\nexport type PixelToChartFn = (point: Point) => Anchor | null;\n\n/**\n * Chart to pixel coordinate conversion function\n */\nexport type ChartToPixelFn = (anchor: Anchor) => Point | null;\n\n/**\n * Snap configuration for interaction\n */\nexport interface SnapConfig {\n snapToPrice: boolean;\n snapToBar: boolean;\n snapThreshold: number;\n}\n\n/**\n * Drawing tool metadata for registration\n */\nexport interface DrawingToolDefinition {\n type: string;\n name: string;\n category: DrawingCategory;\n icon?: string;\n shortcut?: string;\n requiredAnchors: number;\n defaultStyle?: Partial<DrawingStyle>;\n defaultOptions?: Partial<DrawingOptions>;\n}\n\n/**\n * Drawing categories for organization\n */\nexport type DrawingCategory =\n | 'line'\n | 'channel'\n | 'fibonacci'\n | 'gann'\n | 'pitchfork'\n | 'shape'\n | 'annotation'\n | 'trading'\n | 'forecasting'\n | 'measurement';\n\n/**\n * Event types emitted by DrawingManager\n */\nexport type DrawingEventType =\n | 'drawing:added'\n | 'drawing:removed'\n | 'drawing:selected'\n | 'drawing:deselected'\n | 'drawing:updated'\n | 'drawing:cleared'\n | 'tool:changed';\n\n/**\n * Drawing event payload\n */\nexport interface DrawingEvent {\n type: DrawingEventType;\n drawingId?: string;\n drawing?: IDrawing;\n toolType?: string;\n}\n\n/**\n * Event callback type\n */\nexport type DrawingEventCallback = (event: DrawingEvent) => void;\n\n/**\n * Base drawing interface\n */\nexport interface IDrawing {\n readonly id: string;\n readonly type: string;\n anchors: Anchor[];\n style: DrawingStyle;\n options: DrawingOptions;\n state: DrawingState;\n\n // Lifecycle\n attach(series: ISeriesApi<SeriesType>, chart: IChartApi, container?: HTMLElement): void;\n detach(): void;\n isAttached(): boolean;\n\n // State\n isValid(): boolean;\n setAnchors(anchors: Anchor[]): void;\n updateAnchor(index: number, anchor: Anchor): void;\n updateStyle(style: Partial<DrawingStyle>): void;\n updateOptions(options: Partial<DrawingOptions>): void;\n setState(state: DrawingState): void;\n\n // Hit testing\n testHit(point: Point, viewport: Viewport): boolean;\n hitTestAnchor(point: Point, viewport: Viewport): number | null;\n getControlPoints(viewport: Viewport): ControlPoint[];\n\n // Serialization\n toJSON(): SerializedDrawing;\n fromJSON(data: SerializedDrawing): void;\n\n // Clone\n clone(newId: string): IDrawing;\n\n // Viewport\n getViewport(): Viewport | null;\n\n // Request update\n requestUpdate(): void;\n\n // Pane views for rendering\n paneViews(): IPrimitivePaneView[];\n}\n\n/**\n * Control point for anchor manipulation\n */\nexport interface ControlPoint {\n index: number;\n x: number;\n y: number;\n radius: number;\n}\n\n","import type { Point } from './types';\n\n/**\n * Line geometry with optional extensions\n */\nexport interface LineGeometry {\n type: 'line';\n start: Point;\n end: Point;\n extendLeft?: boolean;\n extendRight?: boolean;\n}\n\n/**\n * Arc/circle geometry\n */\nexport interface ArcGeometry {\n type: 'arc';\n center: Point;\n radius: number;\n startAngle: number;\n endAngle: number;\n counterClockwise?: boolean;\n}\n\n/**\n * Rectangle geometry\n */\nexport interface RectangleGeometry {\n type: 'rectangle';\n topLeft: Point;\n width: number;\n height: number;\n rotation?: number;\n}\n\n/**\n * Polygon geometry (closed or open path)\n */\nexport interface PolygonGeometry {\n type: 'polygon';\n points: Point[];\n closed: boolean;\n}\n\n/**\n * Text geometry\n */\nexport interface TextGeometry {\n type: 'text';\n position: Point;\n text: string;\n font?: string;\n color?: string;\n align?: CanvasTextAlign;\n baseline?: CanvasTextBaseline;\n rotation?: number;\n}\n\n/**\n * Union of all geometry types\n */\nexport type Geometry =\n | LineGeometry\n | ArcGeometry\n | RectangleGeometry\n | PolygonGeometry\n | TextGeometry;\n\n/**\n * Calculate distance from point to line segment\n */\nexport function distanceToLineSegment(\n point: Point,\n lineStart: Point,\n lineEnd: Point\n): number {\n const dx = lineEnd.x - lineStart.x;\n const dy = lineEnd.y - lineStart.y;\n const lengthSquared = dx * dx + dy * dy;\n\n if (lengthSquared === 0) {\n // Line segment is a point\n const ex = point.x - lineStart.x;\n const ey = point.y - lineStart.y;\n return Math.sqrt(ex * ex + ey * ey);\n }\n\n // Project point onto line, clamping to segment\n let t = ((point.x - lineStart.x) * dx + (point.y - lineStart.y) * dy) / lengthSquared;\n t = Math.max(0, Math.min(1, t));\n\n const projectionX = lineStart.x + t * dx;\n const projectionY = lineStart.y + t * dy;\n const px = point.x - projectionX;\n const py = point.y - projectionY;\n\n return Math.sqrt(px * px + py * py);\n}\n\n/**\n * Calculate distance from point to infinite line\n */\nexport function distanceToLine(\n point: Point,\n lineStart: Point,\n lineEnd: Point\n): number {\n const dx = lineEnd.x - lineStart.x;\n const dy = lineEnd.y - lineStart.y;\n const lengthSquared = dx * dx + dy * dy;\n\n if (lengthSquared === 0) {\n const ex = point.x - lineStart.x;\n const ey = point.y - lineStart.y;\n return Math.sqrt(ex * ex + ey * ey);\n }\n\n // Distance using cross product\n const numerator = Math.abs(\n dy * point.x - dx * point.y + lineEnd.x * lineStart.y - lineEnd.y * lineStart.x\n );\n const denominator = Math.sqrt(lengthSquared);\n\n return numerator / denominator;\n}\n\n/**\n * Calculate distance between two points\n */\nexport function distanceBetweenPoints(p1: Point, p2: Point): number {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n return Math.sqrt(dx * dx + dy * dy);\n}\n\n/**\n * Check if point is within distance of another point\n */\nexport function isPointNear(p1: Point, p2: Point, threshold: number): boolean {\n return distanceBetweenPoints(p1, p2) <= threshold;\n}\n\n/**\n * Extend line to viewport boundaries\n */\nexport function extendLineToViewport(\n start: Point,\n end: Point,\n viewportWidth: number,\n viewportHeight: number,\n extendLeft: boolean,\n extendRight: boolean\n): { start: Point; end: Point } {\n const dx = end.x - start.x;\n const dy = end.y - start.y;\n\n let newStart = { ...start };\n let newEnd = { ...end };\n\n if (dx === 0) {\n // Vertical line\n if (extendLeft) newStart = { x: start.x, y: 0 };\n if (extendRight) newEnd = { x: end.x, y: viewportHeight };\n return { start: newStart, end: newEnd };\n }\n\n const slope = dy / dx;\n const intercept = start.y - slope * start.x;\n\n if (extendLeft) {\n // Extend towards x = 0 or viewport boundaries\n const yAtX0 = intercept;\n if (yAtX0 >= 0 && yAtX0 <= viewportHeight) {\n newStart = { x: 0, y: yAtX0 };\n } else if (yAtX0 < 0) {\n newStart = { x: -intercept / slope, y: 0 };\n } else {\n newStart = { x: (viewportHeight - intercept) / slope, y: viewportHeight };\n }\n }\n\n if (extendRight) {\n // Extend towards x = viewportWidth or viewport boundaries\n const yAtXMax = slope * viewportWidth + intercept;\n if (yAtXMax >= 0 && yAtXMax <= viewportHeight) {\n newEnd = { x: viewportWidth, y: yAtXMax };\n } else if (yAtXMax < 0) {\n newEnd = { x: -intercept / slope, y: 0 };\n } else {\n newEnd = { x: (viewportHeight - intercept) / slope, y: viewportHeight };\n }\n }\n\n return { start: newStart, end: newEnd };\n}\n\n/**\n * Get angle of line in radians\n */\nexport function getLineAngle(start: Point, end: Point): number {\n return Math.atan2(end.y - start.y, end.x - start.x);\n}\n\n/**\n * Get angle of line in degrees\n */\nexport function getLineAngleDegrees(start: Point, end: Point): number {\n return getLineAngle(start, end) * (180 / Math.PI);\n}\n\n/**\n * Rotate point around center\n */\nexport function rotatePoint(point: Point, center: Point, angle: number): Point {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const dx = point.x - center.x;\n const dy = point.y - center.y;\n return {\n x: center.x + dx * cos - dy * sin,\n y: center.y + dx * sin + dy * cos,\n };\n}\n\n/**\n * Calculate midpoint between two points\n */\nexport function midpoint(p1: Point, p2: Point): Point {\n return {\n x: (p1.x + p2.x) / 2,\n y: (p1.y + p2.y) / 2,\n };\n}\n\n/**\n * Linear interpolation between two points\n */\nexport function lerp(p1: Point, p2: Point, t: number): Point {\n return {\n x: p1.x + (p2.x - p1.x) * t,\n y: p1.y + (p2.y - p1.y) * t,\n };\n}\n","import type {\n IChartApi,\n ISeriesApi,\n SeriesType,\n Time,\n IPrimitivePaneView,\n PrimitiveHoveredItem,\n AutoscaleInfo,\n PrimitivePaneViewZOrder,\n} from 'lightweight-charts';\n\nimport type {\n IDrawing,\n Anchor,\n Point,\n DrawingStyle,\n DrawingOptions,\n DrawingState,\n SerializedDrawing,\n Viewport,\n ControlPoint,\n} from './types';\nimport { DEFAULT_DRAWING_STYLE } from './types';\nimport type { Geometry } from './geometry';\n\n/**\n * Abstract base class for all drawing tools.\n * Implements ISeriesPrimitive for integration with lightweight-charts.\n */\nexport abstract class Drawing implements IDrawing {\n readonly id: string;\n abstract readonly type: string;\n\n protected _anchors: Anchor[] = [];\n protected _style: DrawingStyle;\n protected _options: DrawingOptions;\n protected _state: DrawingState = 'normal';\n\n protected _series: ISeriesApi<SeriesType> | null = null;\n protected _chart: IChartApi | null = null;\n protected _container: HTMLElement | null = null;\n protected _requestUpdateFn: (() => void) | null = null;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<DrawingOptions> = {}\n ) {\n this.id = id;\n this._anchors = [...anchors];\n this._style = { ...DEFAULT_DRAWING_STYLE, ...style };\n this._options = {\n visible: true,\n locked: false,\n zIndex: 0,\n extendLeft: false,\n extendRight: false,\n ...options,\n };\n }\n\n // ============ Getters/Setters ============\n\n get anchors(): Anchor[] {\n return this._anchors;\n }\n\n get style(): DrawingStyle {\n return this._style;\n }\n\n get options(): DrawingOptions {\n return this._options;\n }\n\n get state(): DrawingState {\n return this._state;\n }\n\n set anchors(value: Anchor[]) {\n this._anchors = [...value];\n this.requestUpdate();\n }\n\n set style(value: DrawingStyle) {\n this._style = { ...value };\n this.requestUpdate();\n }\n\n set options(value: DrawingOptions) {\n this._options = { ...value };\n this.requestUpdate();\n }\n\n set state(value: DrawingState) {\n this._state = value;\n this.requestUpdate();\n }\n\n // ============ Lifecycle ============\n\n attach(series: ISeriesApi<SeriesType>, chart: IChartApi, container?: HTMLElement): void {\n if (this._series) {\n this.detach();\n }\n this._series = series;\n this._chart = chart;\n this._container = container ?? null;\n series.attachPrimitive(this);\n }\n\n detach(): void {\n if (this._series) {\n this._series.detachPrimitive(this);\n this._series = null;\n this._chart = null;\n this._container = null;\n this._requestUpdateFn = null;\n }\n }\n\n isAttached(): boolean {\n return this._series !== null;\n }\n\n // ============ ISeriesPrimitive Implementation ============\n\n requestUpdate(): void {\n if (this._requestUpdateFn) {\n this._requestUpdateFn();\n }\n }\n\n attached(params: { chart: IChartApi; series: ISeriesApi<SeriesType>; requestUpdate: () => void }): void {\n this._chart = params.chart;\n this._series = params.series;\n this._requestUpdateFn = params.requestUpdate;\n }\n\n detached(): void {\n this._chart = null;\n this._series = null;\n this._container = null;\n this._requestUpdateFn = null;\n }\n\n /**\n * Returns pane views for rendering. Must be implemented by subclasses.\n */\n abstract paneViews(): IPrimitivePaneView[];\n\n /**\n * Optional: Provide hit testing for the primitive (lightweight-charts interface)\n */\n hitTest(x: number, y: number): PrimitiveHoveredItem | null {\n const viewport = this.getViewport();\n if (!viewport) return null;\n\n const point: Point = { x, y };\n const hit = this.testHit(point, viewport);\n\n if (hit) {\n return {\n cursorStyle: this._options.locked ? 'default' : 'pointer',\n externalId: this.id,\n zOrder: 'normal' as PrimitivePaneViewZOrder,\n };\n }\n\n return null;\n }\n\n /**\n * Optional: Provide autoscale info\n */\n autoscaleInfo(): AutoscaleInfo | null {\n if (this._anchors.length === 0) return null;\n\n const prices = this._anchors.map((a) => a.price);\n return {\n priceRange: {\n minValue: Math.min(...prices),\n maxValue: Math.max(...prices),\n },\n };\n }\n\n // ============ State Management ============\n\n setAnchors(anchors: Anchor[]): void {\n this._anchors = [...anchors];\n this.requestUpdate();\n }\n\n updateAnchor(index: number, anchor: Anchor): void {\n if (index >= 0 && index < this._anchors.length) {\n this._anchors[index] = { ...anchor };\n this.requestUpdate();\n }\n }\n\n updateStyle(style: Partial<DrawingStyle>): void {\n this._style = { ...this._style, ...style };\n this.requestUpdate();\n }\n\n updateOptions(options: Partial<DrawingOptions>): void {\n this._options = { ...this._options, ...options };\n this.requestUpdate();\n }\n\n setState(state: DrawingState): void {\n this._state = state;\n this.requestUpdate();\n }\n\n // ============ Hit Testing ============\n\n /**\n * Test if point hits the drawing. Must be implemented by subclasses.\n */\n abstract testHit(point: Point, viewport: Viewport): boolean;\n\n /**\n * Test if point hits an anchor control point\n */\n hitTestAnchor(point: Point, viewport: Viewport): number | null {\n const controlPoints = this.getControlPoints(viewport);\n const threshold = 8; // pixels\n\n for (const cp of controlPoints) {\n const dx = point.x - cp.x;\n const dy = point.y - cp.y;\n const distance = Math.sqrt(dx * dx + dy * dy);\n\n if (distance <= threshold) {\n return cp.index;\n }\n }\n\n return null;\n }\n\n /**\n * Get control points for anchor manipulation\n */\n getControlPoints(viewport: Viewport): ControlPoint[] {\n const points: ControlPoint[] = [];\n\n for (let i = 0; i < this._anchors.length; i++) {\n const anchor = this._anchors[i];\n const pixel = this.anchorToPixel(anchor, viewport);\n\n if (pixel) {\n points.push({\n index: i,\n x: pixel.x,\n y: pixel.y,\n radius: 6,\n });\n }\n }\n\n return points;\n }\n\n // ============ Coordinate Conversion ============\n\n anchorToPixel(anchor: Anchor, viewport: Viewport): Point | null {\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return null;\n\n return { x, y };\n }\n\n protected pixelToAnchor(point: Point, viewport: Viewport): Anchor | null {\n const time = viewport.timeScale.coordinateToTime(point.x);\n const price = viewport.priceScale.coordinateToPrice(point.y);\n\n if (time === null || price === null) return null;\n\n return { time, price };\n }\n\n getViewport(): Viewport | null {\n if (!this._chart || !this._series) return null;\n\n const timeScale = this._chart.timeScale();\n const height = this._container?.clientHeight ?? 400;\n\n return {\n width: timeScale.width(),\n height,\n timeScale: {\n coordinateToTime: (x: number) => timeScale.coordinateToTime(x),\n timeToCoordinate: (time: Time) => timeScale.timeToCoordinate(time),\n logicalToCoordinate: (logical) => timeScale.logicalToCoordinate(logical),\n },\n priceScale: {\n coordinateToPrice: (y: number) => this._series!.coordinateToPrice(y),\n priceToCoordinate: (price: number) => this._series!.priceToCoordinate(price),\n },\n };\n }\n\n // ============ Geometry ============\n\n /**\n * Compute geometry for rendering. Must be implemented by subclasses.\n */\n abstract computeGeometry(viewport: Viewport): Geometry[];\n\n // ============ Validation ============\n\n /**\n * Check if drawing is valid (has required anchors). Must be implemented by subclasses.\n */\n abstract isValid(): boolean;\n\n // ============ Serialization ============\n\n toJSON(): SerializedDrawing {\n return {\n id: this.id,\n type: this.type,\n anchors: [...this._anchors],\n style: { ...this._style },\n options: { ...this._options },\n };\n }\n\n fromJSON(data: SerializedDrawing): void {\n this._anchors = [...data.anchors];\n this._style = { ...DEFAULT_DRAWING_STYLE, ...data.style };\n this._options = { ...this._options, ...data.options };\n this.requestUpdate();\n }\n\n // ============ Clone ============\n\n /**\n * Create a clone of this drawing. Must be implemented by subclasses.\n */\n abstract clone(newId: string): IDrawing;\n}\n","import type {\n IChartApi,\n ISeriesApi,\n SeriesType,\n MouseEventParams,\n} from 'lightweight-charts';\n\nimport type {\n IDrawing,\n Point,\n Viewport,\n DrawingEvent,\n DrawingEventType,\n DrawingEventCallback,\n SerializedDrawing,\n} from './types';\n\n/**\n * DrawingManager - Central orchestration system for managing drawings.\n *\n * Responsibilities:\n * - Creating, storing, removing drawings\n * - Attaching/detaching to chart series\n * - Hit detection and selection\n * - Interaction state management\n * - JSON import/export\n * - Event emission\n */\nexport class DrawingManager {\n private _drawings: Map<string, IDrawing> = new Map();\n private _selectedId: string | null = null;\n private _chart: IChartApi | null = null;\n private _series: ISeriesApi<SeriesType> | null = null;\n private _container: HTMLElement | null = null;\n private _listeners: Map<DrawingEventType, Set<DrawingEventCallback>> = new Map();\n private _isAttached: boolean = false;\n\n // Interaction state\n private _activeTool: string | null = null;\n private _isDragging: boolean = false;\n private _dragAnchorIndex: number | null = null;\n\n constructor() {\n this.handleMouseDown = this.handleMouseDown.bind(this);\n this.handleMouseMove = this.handleMouseMove.bind(this);\n this.handleMouseUp = this.handleMouseUp.bind(this);\n this.handleClick = this.handleClick.bind(this);\n }\n\n // ============ Lifecycle ============\n\n /**\n * Attach manager to a chart and series\n */\n attach(\n chart: IChartApi,\n series: ISeriesApi<SeriesType>,\n container: HTMLElement\n ): void {\n if (this._isAttached) {\n this.detach();\n }\n\n this._chart = chart;\n this._series = series;\n this._container = container;\n this._isAttached = true;\n\n // Attach all existing drawings\n for (const drawing of this._drawings.values()) {\n drawing.attach(series, chart, this._container ?? undefined);\n }\n\n // Subscribe to chart events\n chart.subscribeClick(this.handleClick);\n\n // Add container event listeners for interaction\n container.addEventListener('mousedown', this.handleMouseDown);\n container.addEventListener('mousemove', this.handleMouseMove);\n container.addEventListener('mouseup', this.handleMouseUp);\n }\n\n /**\n * Detach manager from chart\n */\n detach(): void {\n if (!this._isAttached) return;\n\n // Detach all drawings\n for (const drawing of this._drawings.values()) {\n drawing.detach();\n }\n\n // Unsubscribe from chart events\n if (this._chart) {\n this._chart.unsubscribeClick(this.handleClick);\n }\n\n // Remove container event listeners\n if (this._container) {\n this._container.removeEventListener('mousedown', this.handleMouseDown);\n this._container.removeEventListener('mousemove', this.handleMouseMove);\n this._container.removeEventListener('mouseup', this.handleMouseUp);\n }\n\n this._chart = null;\n this._series = null;\n this._container = null;\n this._isAttached = false;\n }\n\n /**\n * Check if manager is attached\n */\n isAttached(): boolean {\n return this._isAttached;\n }\n\n // ============ Drawing Management ============\n\n /**\n * Add a drawing to the manager\n */\n addDrawing(drawing: IDrawing): void {\n if (this._drawings.has(drawing.id)) {\n console.warn(`Drawing with id ${drawing.id} already exists`);\n return;\n }\n\n this._drawings.set(drawing.id, drawing);\n\n // Attach to chart if manager is attached\n if (this._isAttached && this._series && this._chart) {\n drawing.attach(this._series, this._chart, this._container ?? undefined);\n }\n\n this.emit('drawing:added', { drawingId: drawing.id, drawing });\n }\n\n /**\n * Remove a drawing by id\n */\n removeDrawing(id: string): void {\n const drawing = this._drawings.get(id);\n if (!drawing) return;\n\n // Deselect if selected\n if (this._selectedId === id) {\n this.deselectAll();\n }\n\n // Detach from chart\n drawing.detach();\n\n this._drawings.delete(id);\n this.emit('drawing:removed', { drawingId: id });\n }\n\n /**\n * Get a drawing by id\n */\n getDrawing(id: string): IDrawing | undefined {\n return this._drawings.get(id);\n }\n\n /**\n * Get all drawings\n */\n getAllDrawings(): IDrawing[] {\n return Array.from(this._drawings.values());\n }\n\n /**\n * Clear all drawings\n */\n clearAll(): void {\n for (const drawing of this._drawings.values()) {\n drawing.detach();\n }\n this._drawings.clear();\n this._selectedId = null;\n this.emit('drawing:cleared', {});\n }\n\n // ============ Selection ============\n\n /**\n * Select a drawing by id\n */\n selectDrawing(id: string): void {\n const drawing = this._drawings.get(id);\n if (!drawing) return;\n\n // Deselect current\n if (this._selectedId && this._selectedId !== id) {\n const current = this._drawings.get(this._selectedId);\n if (current) {\n current.setState('normal');\n }\n }\n\n drawing.setState('selected');\n this._selectedId = id;\n this.emit('drawing:selected', { drawingId: id, drawing });\n }\n\n /**\n * Deselect all drawings\n */\n deselectAll(): void {\n if (this._selectedId) {\n const drawing = this._drawings.get(this._selectedId);\n if (drawing) {\n drawing.setState('normal');\n }\n const id = this._selectedId;\n this._selectedId = null;\n this.emit('drawing:deselected', { drawingId: id });\n }\n }\n\n /**\n * Get selected drawing\n */\n getSelectedDrawing(): IDrawing | null {\n if (!this._selectedId) return null;\n return this._drawings.get(this._selectedId) || null;\n }\n\n // ============ Tool Management ============\n\n /**\n * Set the active drawing tool\n */\n setActiveTool(toolType: string | null): void {\n this._activeTool = toolType;\n this.emit('tool:changed', { toolType: toolType || undefined });\n }\n\n /**\n * Get the active drawing tool\n */\n getActiveTool(): string | null {\n return this._activeTool;\n }\n\n // ============ Hit Testing ============\n\n /**\n * Find drawing at point\n */\n hitTest(point: Point): IDrawing | null {\n const viewport = this.getViewport();\n if (!viewport) return null;\n\n // Test in reverse order (top to bottom)\n const drawings = Array.from(this._drawings.values()).reverse();\n\n for (const drawing of drawings) {\n if (!drawing.options.visible) continue;\n if (drawing.testHit(point, viewport)) {\n return drawing;\n }\n }\n\n return null;\n }\n\n /**\n * Find anchor at point for selected drawing\n */\n hitTestAnchor(point: Point): number | null {\n if (!this._selectedId) return null;\n\n const drawing = this._drawings.get(this._selectedId);\n if (!drawing) return null;\n\n const viewport = this.getViewport();\n if (!viewport) return null;\n\n return drawing.hitTestAnchor(point, viewport);\n }\n\n // ============ Event Handling ============\n\n private handleClick(params: MouseEventParams): void {\n if (!params.point) return;\n\n const point: Point = { x: params.point.x, y: params.point.y };\n\n // If no active tool, try to select a drawing\n if (!this._activeTool) {\n const hitDrawing = this.hitTest(point);\n if (hitDrawing) {\n this.selectDrawing(hitDrawing.id);\n } else {\n this.deselectAll();\n }\n }\n }\n\n private handleMouseDown(event: MouseEvent): void {\n const point = this.getPointFromEvent(event);\n if (!point) return;\n\n // Check for anchor hit on selected drawing\n if (this._selectedId) {\n const anchorIndex = this.hitTestAnchor(point);\n if (anchorIndex !== null) {\n const drawing = this._drawings.get(this._selectedId);\n if (drawing && !drawing.options.locked) {\n this._isDragging = true;\n this._dragAnchorIndex = anchorIndex;\n drawing.setState('editing');\n return;\n }\n }\n }\n }\n\n private handleMouseMove(event: MouseEvent): void {\n if (!this._isDragging || this._dragAnchorIndex === null) return;\n if (!this._selectedId) return;\n\n const drawing = this._drawings.get(this._selectedId);\n if (!drawing) return;\n\n const point = this.getPointFromEvent(event);\n if (!point) return;\n\n const viewport = this.getViewport();\n if (!viewport) return;\n\n // Convert point to anchor\n const time = viewport.timeScale.coordinateToTime(point.x);\n const price = viewport.priceScale.coordinateToPrice(point.y);\n\n if (time !== null && price !== null) {\n drawing.updateAnchor(this._dragAnchorIndex, { time, price });\n this.emit('drawing:updated', { drawingId: drawing.id, drawing });\n }\n }\n\n private handleMouseUp(_event: MouseEvent): void {\n if (this._isDragging && this._selectedId) {\n const drawing = this._drawings.get(this._selectedId);\n if (drawing) {\n drawing.setState('selected');\n }\n }\n\n this._isDragging = false;\n this._dragAnchorIndex = null;\n }\n\n private getPointFromEvent(event: MouseEvent): Point | null {\n if (!this._container) return null;\n\n const rect = this._container.getBoundingClientRect();\n return {\n x: event.clientX - rect.left,\n y: event.clientY - rect.top,\n };\n }\n\n // ============ Viewport ============\n\n private getViewport(): Viewport | null {\n if (!this._chart || !this._series) return null;\n\n const timeScale = this._chart.timeScale();\n // Get container height as fallback\n const height = this._container?.clientHeight ?? 400;\n\n return {\n width: timeScale.width(),\n height,\n timeScale: {\n coordinateToTime: (x: number) => timeScale.coordinateToTime(x),\n timeToCoordinate: (time) => timeScale.timeToCoordinate(time),\n logicalToCoordinate: (logical) => timeScale.logicalToCoordinate(logical),\n },\n priceScale: {\n coordinateToPrice: (y: number) => this._series!.coordinateToPrice(y),\n priceToCoordinate: (price: number) => this._series!.priceToCoordinate(price),\n },\n };\n }\n\n // ============ Serialization ============\n\n /**\n * Export all drawings as JSON\n */\n exportDrawings(): SerializedDrawing[] {\n return this.getAllDrawings().map((d) => d.toJSON());\n }\n\n /**\n * Import drawings from JSON (requires a factory function)\n */\n importDrawings(\n data: SerializedDrawing[],\n factory: (type: string, data: SerializedDrawing) => IDrawing | null\n ): void {\n for (const item of data) {\n const drawing = factory(item.type, item);\n if (drawing) {\n this.addDrawing(drawing);\n }\n }\n }\n\n // ============ Events ============\n\n /**\n * Subscribe to an event\n */\n on(event: DrawingEventType, callback: DrawingEventCallback): () => void {\n if (!this._listeners.has(event)) {\n this._listeners.set(event, new Set());\n }\n this._listeners.get(event)!.add(callback);\n\n // Return unsubscribe function\n return () => {\n this._listeners.get(event)?.delete(callback);\n };\n }\n\n /**\n * Emit an event\n */\n private emit(type: DrawingEventType, data: Partial<DrawingEvent>): void {\n const event: DrawingEvent = { type, ...data };\n const listeners = this._listeners.get(type);\n if (listeners) {\n for (const callback of listeners) {\n callback(event);\n }\n }\n }\n}\n","import type { Anchor, Point, MouseEventData, PixelToChartFn, SnapConfig } from '../core/types';\n\n/**\n * Interaction states for the FSM\n */\nexport type InteractionState = 'idle' | 'placing' | 'editing' | 'complete';\n\n/**\n * Configuration for interaction handler\n */\nexport interface InteractionConfig {\n requiredAnchors: number;\n pixelToChart: PixelToChartFn;\n snapConfig?: SnapConfig;\n onAnchorAdded?: (anchor: Anchor, index: number) => void;\n onAnchorUpdated?: (anchor: Anchor, index: number) => void;\n onPreviewMove?: (previewAnchor: Anchor) => void;\n onComplete?: () => void;\n onCancel?: () => void;\n}\n\n/**\n * Interface for interaction handlers\n */\nexport interface IInteractionHandler {\n getState(): InteractionState;\n getAnchors(): Anchor[];\n getPreviewAnchor(): Anchor | null;\n\n onMouseDown(data: MouseEventData): void;\n onMouseMove(data: MouseEventData): void;\n onMouseUp(data: MouseEventData): void;\n onKeyDown(key: string): void;\n\n isComplete(): boolean;\n reset(): void;\n}\n\n/**\n * Base interaction handler implementing FSM for drawing placement.\n * Handles the state machine for placing anchors and completing drawings.\n */\nexport class InteractionHandler implements IInteractionHandler {\n protected _state: InteractionState = 'idle';\n protected _anchors: Anchor[] = [];\n protected _previewAnchor: Anchor | null = null;\n protected _editingAnchorIndex: number | null = null;\n protected _config: InteractionConfig;\n\n constructor(config: InteractionConfig) {\n this._config = config;\n }\n\n getState(): InteractionState {\n return this._state;\n }\n\n getAnchors(): Anchor[] {\n return [...this._anchors];\n }\n\n getPreviewAnchor(): Anchor | null {\n return this._previewAnchor;\n }\n\n onMouseDown(data: MouseEventData): void {\n const anchor = this.pointToAnchor(data.point);\n if (!anchor) return;\n\n switch (this._state) {\n case 'idle':\n // Start placing first anchor\n this._anchors = [anchor];\n this._state = 'placing';\n this.notifyAnchorAdded(anchor, 0);\n break;\n\n case 'placing':\n // Add next anchor\n if (this._anchors.length < this._config.requiredAnchors) {\n this._anchors.push(anchor);\n this.notifyAnchorAdded(anchor, this._anchors.length - 1);\n\n if (this._anchors.length >= this._config.requiredAnchors) {\n this._state = 'complete';\n this._previewAnchor = null;\n this.notifyComplete();\n }\n }\n break;\n\n case 'editing':\n // Already handled by mouse up\n break;\n }\n }\n\n onMouseMove(data: MouseEventData): void {\n const anchor = this.pointToAnchor(data.point);\n if (!anchor) return;\n\n switch (this._state) {\n case 'placing':\n // Update preview anchor\n this._previewAnchor = anchor;\n this.notifyPreviewMove(anchor);\n break;\n\n case 'editing':\n // Update the anchor being edited\n if (this._editingAnchorIndex !== null) {\n this._anchors[this._editingAnchorIndex] = anchor;\n this.notifyAnchorUpdated(anchor, this._editingAnchorIndex);\n }\n break;\n }\n }\n\n onMouseUp(_data: MouseEventData): void {\n if (this._state === 'editing') {\n this._editingAnchorIndex = null;\n this._state = 'complete';\n }\n }\n\n onKeyDown(key: string): void {\n if (key === 'Escape') {\n this.cancel();\n }\n }\n\n isComplete(): boolean {\n return this._state === 'complete';\n }\n\n reset(): void {\n this._state = 'idle';\n this._anchors = [];\n this._previewAnchor = null;\n this._editingAnchorIndex = null;\n }\n\n /**\n * Start editing a specific anchor\n */\n startEditingAnchor(index: number): void {\n if (index >= 0 && index < this._anchors.length) {\n this._state = 'editing';\n this._editingAnchorIndex = index;\n }\n }\n\n /**\n * Set anchors externally (for loading from saved data)\n */\n setAnchors(anchors: Anchor[]): void {\n this._anchors = [...anchors];\n if (anchors.length >= this._config.requiredAnchors) {\n this._state = 'complete';\n }\n }\n\n protected pointToAnchor(point: Point): Anchor | null {\n let anchor = this._config.pixelToChart(point);\n\n if (anchor && this._config.snapConfig) {\n anchor = this.applySnap(anchor, point);\n }\n\n return anchor;\n }\n\n protected applySnap(anchor: Anchor, _point: Point): Anchor {\n // Snap logic would be implemented here\n // For now, return anchor as-is\n return anchor;\n }\n\n protected cancel(): void {\n this.reset();\n this._config.onCancel?.();\n }\n\n protected notifyAnchorAdded(anchor: Anchor, index: number): void {\n this._config.onAnchorAdded?.(anchor, index);\n }\n\n protected notifyAnchorUpdated(anchor: Anchor, index: number): void {\n this._config.onAnchorUpdated?.(anchor, index);\n }\n\n protected notifyPreviewMove(anchor: Anchor): void {\n this._config.onPreviewMove?.(anchor);\n }\n\n protected notifyComplete(): void {\n this._config.onComplete?.();\n }\n}\n\n/**\n * Two-point interaction handler for line-based drawings\n */\nexport class TwoPointInteractionHandler extends InteractionHandler {\n constructor(config: Omit<InteractionConfig, 'requiredAnchors'>) {\n super({ ...config, requiredAnchors: 2 });\n }\n}\n\n/**\n * Three-point interaction handler for channel/pitchfork drawings\n */\nexport class ThreePointInteractionHandler extends InteractionHandler {\n constructor(config: Omit<InteractionConfig, 'requiredAnchors'>) {\n super({ ...config, requiredAnchors: 3 });\n }\n}\n\n/**\n * Single-point interaction handler for vertical/horizontal lines\n */\nexport class SinglePointInteractionHandler extends InteractionHandler {\n constructor(config: Omit<InteractionConfig, 'requiredAnchors'>) {\n super({ ...config, requiredAnchors: 1 });\n }\n}\n","import type { Point, DrawingStyle, ControlPoint } from '../core/types';\n\n/**\n * Set up canvas context with drawing style\n */\nexport function applyStyle(\n ctx: CanvasRenderingContext2D,\n style: DrawingStyle,\n pixelRatio: number = 1\n): void {\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n\n if (style.lineDash && style.lineDash.length > 0) {\n ctx.setLineDash(style.lineDash.map((d) => d * pixelRatio));\n } else {\n ctx.setLineDash([]);\n }\n\n if (style.fillColor) {\n ctx.fillStyle = style.fillColor;\n }\n}\n\n/**\n * Draw a line between two points\n */\nexport function drawLine(\n ctx: CanvasRenderingContext2D,\n start: Point,\n end: Point,\n pixelRatio: number = 1\n): void {\n ctx.beginPath();\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n ctx.lineTo(end.x * pixelRatio, end.y * pixelRatio);\n ctx.stroke();\n}\n\n/**\n * Draw a dashed line between two points\n */\nexport function drawDashedLine(\n ctx: CanvasRenderingContext2D,\n start: Point,\n end: Point,\n dashPattern: number[] = [5, 5],\n pixelRatio: number = 1\n): void {\n ctx.save();\n ctx.setLineDash(dashPattern.map((d) => d * pixelRatio));\n drawLine(ctx, start, end, pixelRatio);\n ctx.restore();\n}\n\n/**\n * Draw a control point (anchor handle) in TradingView style:\n * dark filled center with a colored ring.\n */\nexport function drawControlPoint(\n ctx: CanvasRenderingContext2D,\n point: ControlPoint,\n isActive: boolean = false,\n pixelRatio: number = 1,\n lineColor: string = '#2962FF'\n): void {\n const x = point.x * pixelRatio;\n const y = point.y * pixelRatio;\n const radius = 4 * pixelRatio;\n const ringWidth = 1.5 * pixelRatio;\n\n // Dark filled center\n ctx.beginPath();\n ctx.arc(x, y, radius, 0, Math.PI * 2);\n ctx.fillStyle = '#131722';\n ctx.fill();\n\n // Colored ring\n ctx.beginPath();\n ctx.arc(x, y, radius - ringWidth / 2, 0, Math.PI * 2);\n ctx.strokeStyle = isActive ? '#ffffff' : lineColor;\n ctx.lineWidth = ringWidth;\n ctx.stroke();\n}\n\n/**\n * Draw all control points for a drawing\n */\nexport function drawControlPoints(\n ctx: CanvasRenderingContext2D,\n points: ControlPoint[],\n activeIndex: number | null = null,\n pixelRatio: number = 1,\n lineColor: string = '#2962FF'\n): void {\n for (const point of points) {\n drawControlPoint(ctx, point, point.index === activeIndex, pixelRatio, lineColor);\n }\n}\n\n/**\n * Draw an arrow head at the end of a line\n */\nexport function drawArrowHead(\n ctx: CanvasRenderingContext2D,\n from: Point,\n to: Point,\n size: number = 10,\n pixelRatio: number = 1\n): void {\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const arrowSize = size * pixelRatio;\n\n const x = to.x * pixelRatio;\n const y = to.y * pixelRatio;\n\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(\n x - arrowSize * Math.cos(angle - Math.PI / 6),\n y - arrowSize * Math.sin(angle - Math.PI / 6)\n );\n ctx.moveTo(x, y);\n ctx.lineTo(\n x - arrowSize * Math.cos(angle + Math.PI / 6),\n y - arrowSize * Math.sin(angle + Math.PI / 6)\n );\n ctx.stroke();\n}\n\n/**\n * Draw a filled arrow head\n */\nexport function drawFilledArrowHead(\n ctx: CanvasRenderingContext2D,\n from: Point,\n to: Point,\n size: number = 10,\n pixelRatio: number = 1\n): void {\n const angle = Math.atan2(to.y - from.y, to.x - from.x);\n const arrowSize = size * pixelRatio;\n\n const x = to.x * pixelRatio;\n const y = to.y * pixelRatio;\n\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(\n x - arrowSize * Math.cos(angle - Math.PI / 6),\n y - arrowSize * Math.sin(angle - Math.PI / 6)\n );\n ctx.lineTo(\n x - arrowSize * Math.cos(angle + Math.PI / 6),\n y - arrowSize * Math.sin(angle + Math.PI / 6)\n );\n ctx.closePath();\n ctx.fill();\n}\n\n/**\n * Draw a circle\n */\nexport function drawCircle(\n ctx: CanvasRenderingContext2D,\n center: Point,\n radius: number,\n fill: boolean = false,\n pixelRatio: number = 1\n): void {\n ctx.beginPath();\n ctx.arc(\n center.x * pixelRatio,\n center.y * pixelRatio,\n radius * pixelRatio,\n 0,\n Math.PI * 2\n );\n\n if (fill) {\n ctx.fill();\n }\n ctx.stroke();\n}\n\n/**\n * Draw a rectangle\n */\nexport function drawRect(\n ctx: CanvasRenderingContext2D,\n topLeft: Point,\n width: number,\n height: number,\n fill: boolean = false,\n pixelRatio: number = 1\n): void {\n const x = topLeft.x * pixelRatio;\n const y = topLeft.y * pixelRatio;\n const w = width * pixelRatio;\n const h = height * pixelRatio;\n\n if (fill) {\n ctx.fillRect(x, y, w, h);\n }\n ctx.strokeRect(x, y, w, h);\n}\n\n/**\n * Draw text at a position\n */\nexport function drawText(\n ctx: CanvasRenderingContext2D,\n text: string,\n position: Point,\n font: string = '12px sans-serif',\n color: string = '#000000',\n align: CanvasTextAlign = 'left',\n baseline: CanvasTextBaseline = 'middle',\n pixelRatio: number = 1\n): void {\n ctx.save();\n ctx.font = font;\n ctx.fillStyle = color;\n ctx.textAlign = align;\n ctx.textBaseline = baseline;\n ctx.fillText(text, position.x * pixelRatio, position.y * pixelRatio);\n ctx.restore();\n}\n\n/**\n * Draw a label with background\n */\nexport function drawLabel(\n ctx: CanvasRenderingContext2D,\n text: string,\n position: Point,\n style: {\n font?: string;\n textColor?: string;\n backgroundColor?: string;\n padding?: number;\n borderRadius?: number;\n } = {},\n pixelRatio: number = 1\n): void {\n const {\n font = '12px sans-serif',\n textColor = '#ffffff',\n backgroundColor = 'rgba(0, 0, 0, 0.7)',\n padding = 4,\n borderRadius = 3,\n } = style;\n\n ctx.save();\n ctx.font = font;\n\n const metrics = ctx.measureText(text);\n const textWidth = metrics.width;\n const textHeight = parseInt(font.match(/(\\d+)px/)?.[1] ?? '12');\n\n const x = position.x * pixelRatio;\n const y = position.y * pixelRatio;\n const pad = padding * pixelRatio;\n const radius = borderRadius * pixelRatio;\n\n // Draw background\n ctx.fillStyle = backgroundColor;\n ctx.beginPath();\n ctx.roundRect(\n x - pad,\n y - textHeight / 2 - pad,\n textWidth + pad * 2,\n textHeight + pad * 2,\n radius\n );\n ctx.fill();\n\n // Draw text\n ctx.fillStyle = textColor;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n ctx.fillText(text, x, y);\n\n ctx.restore();\n}\n\n/**\n * Calculate price change percentage between two prices\n */\nexport function calculatePriceChange(startPrice: number, endPrice: number): {\n change: number;\n percentage: number;\n} {\n const change = endPrice - startPrice;\n const percentage = startPrice !== 0 ? (change / startPrice) * 100 : 0;\n return { change, percentage };\n}\n\n/**\n * Format price for display\n */\nexport function formatPrice(price: number, precision: number = 2): string {\n return price.toFixed(precision);\n}\n\n/**\n * Format percentage for display\n */\nexport function formatPercentage(percentage: number, precision: number = 2): string {\n const sign = percentage >= 0 ? '+' : '';\n return `${sign}${percentage.toFixed(precision)}%`;\n}\n","import type { Anchor, Point, DrawingStyle, Viewport } from '../core/types';\nimport { drawLine, drawDashedLine, drawControlPoint } from './canvas-utils';\n\n/**\n * Interface for preview renderers\n */\nexport interface IPreviewRenderer {\n render(\n ctx: CanvasRenderingContext2D,\n anchors: Anchor[],\n previewAnchor: Anchor | null,\n viewport: Viewport,\n style: DrawingStyle,\n pixelRatio: number\n ): void;\n}\n\n/**\n * Base preview renderer with common functionality\n */\nexport abstract class PreviewRenderer implements IPreviewRenderer {\n abstract render(\n ctx: CanvasRenderingContext2D,\n anchors: Anchor[],\n previewAnchor: Anchor | null,\n viewport: Viewport,\n style: DrawingStyle,\n pixelRatio: number\n ): void;\n\n protected anchorToPixel(anchor: Anchor, viewport: Viewport): Point | null {\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return null;\n\n return { x, y };\n }\n\n protected drawAnchorPoint(\n ctx: CanvasRenderingContext2D,\n point: Point,\n pixelRatio: number\n ): void {\n drawControlPoint(\n ctx,\n { index: 0, x: point.x, y: point.y, radius: 5 },\n true,\n pixelRatio\n );\n }\n}\n\n/**\n * Preview renderer for two-point line drawings\n */\nexport class LinePreviewRenderer extends PreviewRenderer {\n render(\n ctx: CanvasRenderingContext2D,\n anchors: Anchor[],\n previewAnchor: Anchor | null,\n viewport: Viewport,\n style: DrawingStyle,\n pixelRatio: number\n ): void {\n if (anchors.length === 0) return;\n\n // Convert first anchor to pixel\n const startPoint = this.anchorToPixel(anchors[0], viewport);\n if (!startPoint) return;\n\n // Draw first anchor point\n this.drawAnchorPoint(ctx, startPoint, pixelRatio);\n\n // If we have a preview anchor, draw the preview line\n if (previewAnchor) {\n const endPoint = this.anchorToPixel(previewAnchor, viewport);\n if (!endPoint) return;\n\n // Set up style for preview (dashed)\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n ctx.globalAlpha = 0.7;\n\n // Draw dashed preview line\n drawDashedLine(ctx, startPoint, endPoint, [5, 5], pixelRatio);\n\n // Draw preview endpoint\n this.drawAnchorPoint(ctx, endPoint, pixelRatio);\n\n ctx.globalAlpha = 1;\n }\n }\n}\n\n/**\n * Preview renderer for horizontal line (single point)\n */\nexport class HorizontalLinePreviewRenderer extends PreviewRenderer {\n render(\n ctx: CanvasRenderingContext2D,\n anchors: Anchor[],\n previewAnchor: Anchor | null,\n viewport: Viewport,\n style: DrawingStyle,\n pixelRatio: number\n ): void {\n const anchor = anchors[0] || previewAnchor;\n if (!anchor) return;\n\n const point = this.anchorToPixel(anchor, viewport);\n if (!point) return;\n\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n ctx.globalAlpha = anchors.length === 0 ? 0.5 : 0.7;\n\n // Draw horizontal line across viewport\n const startPoint: Point = { x: 0, y: point.y };\n const endPoint: Point = { x: viewport.width, y: point.y };\n\n if (anchors.length === 0) {\n drawDashedLine(ctx, startPoint, endPoint, [5, 5], pixelRatio);\n } else {\n drawLine(ctx, startPoint, endPoint, pixelRatio);\n }\n\n // Draw anchor point\n this.drawAnchorPoint(ctx, point, pixelRatio);\n\n ctx.globalAlpha = 1;\n }\n}\n\n/**\n * Preview renderer for vertical line (single point)\n */\nexport class VerticalLinePreviewRenderer extends PreviewRenderer {\n render(\n ctx: CanvasRenderingContext2D,\n anchors: Anchor[],\n previewAnchor: Anchor | null,\n viewport: Viewport,\n style: DrawingStyle,\n pixelRatio: number\n ): void {\n const anchor = anchors[0] || previewAnchor;\n if (!anchor) return;\n\n const point = this.anchorToPixel(anchor, viewport);\n if (!point) return;\n\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n ctx.globalAlpha = anchors.length === 0 ? 0.5 : 0.7;\n\n // Draw vertical line across viewport\n const startPoint: Point = { x: point.x, y: 0 };\n const endPoint: Point = { x: point.x, y: viewport.height };\n\n if (anchors.length === 0) {\n drawDashedLine(ctx, startPoint, endPoint, [5, 5], pixelRatio);\n } else {\n drawLine(ctx, startPoint, endPoint, pixelRatio);\n }\n\n // Draw anchor point\n this.drawAnchorPoint(ctx, point, pixelRatio);\n\n ctx.globalAlpha = 1;\n }\n}\n\n/**\n * Preview renderer for three-point drawings (channels, pitchforks)\n */\nexport class ThreePointPreviewRenderer extends PreviewRenderer {\n render(\n ctx: CanvasRenderingContext2D,\n anchors: Anchor[],\n previewAnchor: Anchor | null,\n viewport: Viewport,\n style: DrawingStyle,\n pixelRatio: number\n ): void {\n if (anchors.length === 0) return;\n\n const points: Point[] = [];\n\n // Convert all anchors to pixels\n for (const anchor of anchors) {\n const point = this.anchorToPixel(anchor, viewport);\n if (point) points.push(point);\n }\n\n // Add preview anchor if present\n if (previewAnchor) {\n const previewPoint = this.anchorToPixel(previewAnchor, viewport);\n if (previewPoint) points.push(previewPoint);\n }\n\n if (points.length === 0) return;\n\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n ctx.globalAlpha = 0.7;\n\n // Draw lines connecting points\n for (let i = 0; i < points.length - 1; i++) {\n if (i === points.length - 2 && previewAnchor) {\n // Last segment is preview\n drawDashedLine(ctx, points[i], points[i + 1], [5, 5], pixelRatio);\n } else {\n drawLine(ctx, points[i], points[i + 1], pixelRatio);\n }\n }\n\n // Draw anchor points\n for (const point of points) {\n this.drawAnchorPoint(ctx, point, pixelRatio);\n }\n\n ctx.globalAlpha = 1;\n }\n}\n","import type {\n IPrimitivePaneView,\n IPrimitivePaneRenderer,\n} from 'lightweight-charts';\nimport type {\n CanvasRenderingTarget2D,\n BitmapCoordinatesRenderingScope,\n} from 'fancy-canvas';\n\nimport type { Drawing } from '../core/drawing';\nimport type { Point, Viewport } from '../core/types';\nimport type { Geometry, LineGeometry } from '../core/geometry';\nimport { extendLineToViewport } from '../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints } from './canvas-utils';\n\n/**\n * Pane view implementation for Drawing primitives\n */\nexport class DrawingPaneView implements IPrimitivePaneView {\n private _renderer: DrawingPaneRenderer;\n\n constructor(drawing: Drawing) {\n this._renderer = new DrawingPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\n/**\n * Pane renderer for Drawing primitives\n */\nclass DrawingPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Drawing;\n\n constructor(drawing: Drawing) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n // Get viewport\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n\n // Check visibility\n if (!this._drawing.options.visible) return;\n\n // Compute geometry\n const geometries = this._drawing.computeGeometry(viewport);\n\n // Apply style\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Render each geometry\n for (const geometry of geometries) {\n this.renderGeometry(ctx, geometry, viewport, pixelRatio);\n }\n\n // Draw control points if selected, editing, or hovered\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing' || state === 'hovered') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio, this._drawing.style.lineColor);\n }\n }\n\n private renderGeometry(\n ctx: CanvasRenderingContext2D,\n geometry: Geometry,\n viewport: Viewport,\n pixelRatio: number\n ): void {\n switch (geometry.type) {\n case 'line':\n this.renderLine(ctx, geometry, viewport, pixelRatio);\n break;\n case 'arc':\n this.renderArc(ctx, geometry, pixelRatio);\n break;\n case 'rectangle':\n this.renderRectangle(ctx, geometry, pixelRatio);\n break;\n case 'polygon':\n this.renderPolygon(ctx, geometry, pixelRatio);\n break;\n case 'text':\n this.renderText(ctx, geometry, pixelRatio);\n break;\n }\n }\n\n private renderLine(\n ctx: CanvasRenderingContext2D,\n line: LineGeometry,\n viewport: Viewport,\n pixelRatio: number\n ): void {\n let start = line.start;\n let end = line.end;\n\n // Handle line extensions\n if (line.extendLeft || line.extendRight) {\n const extended = extendLineToViewport(\n start,\n end,\n viewport.width,\n viewport.height,\n line.extendLeft ?? false,\n line.extendRight ?? false\n );\n start = extended.start;\n end = extended.end;\n }\n\n drawLine(ctx, start, end, pixelRatio);\n }\n\n private renderArc(\n ctx: CanvasRenderingContext2D,\n arc: { center: Point; radius: number; startAngle: number; endAngle: number; counterClockwise?: boolean },\n pixelRatio: number\n ): void {\n ctx.beginPath();\n ctx.arc(\n arc.center.x * pixelRatio,\n arc.center.y * pixelRatio,\n arc.radius * pixelRatio,\n arc.startAngle,\n arc.endAngle,\n arc.counterClockwise\n );\n ctx.stroke();\n }\n\n private renderRectangle(\n ctx: CanvasRenderingContext2D,\n rect: { topLeft: Point; width: number; height: number; rotation?: number },\n pixelRatio: number\n ): void {\n const x = rect.topLeft.x * pixelRatio;\n const y = rect.topLeft.y * pixelRatio;\n const w = rect.width * pixelRatio;\n const h = rect.height * pixelRatio;\n\n if (rect.rotation) {\n ctx.save();\n ctx.translate(x + w / 2, y + h / 2);\n ctx.rotate(rect.rotation);\n ctx.strokeRect(-w / 2, -h / 2, w, h);\n ctx.restore();\n } else {\n ctx.strokeRect(x, y, w, h);\n }\n }\n\n private renderPolygon(\n ctx: CanvasRenderingContext2D,\n polygon: { points: Point[]; closed: boolean },\n pixelRatio: number\n ): void {\n if (polygon.points.length < 2) return;\n\n ctx.beginPath();\n ctx.moveTo(polygon.points[0].x * pixelRatio, polygon.points[0].y * pixelRatio);\n\n for (let i = 1; i < polygon.points.length; i++) {\n ctx.lineTo(polygon.points[i].x * pixelRatio, polygon.points[i].y * pixelRatio);\n }\n\n if (polygon.closed) {\n ctx.closePath();\n ctx.fill();\n }\n ctx.stroke();\n }\n\n private renderText(\n ctx: CanvasRenderingContext2D,\n text: { position: Point; text: string; font?: string; color?: string; align?: CanvasTextAlign; baseline?: CanvasTextBaseline; rotation?: number },\n pixelRatio: number\n ): void {\n ctx.save();\n\n if (text.font) ctx.font = text.font;\n if (text.color) ctx.fillStyle = text.color;\n if (text.align) ctx.textAlign = text.align;\n if (text.baseline) ctx.textBaseline = text.baseline;\n\n const x = text.position.x * pixelRatio;\n const y = text.position.y * pixelRatio;\n\n if (text.rotation) {\n ctx.translate(x, y);\n ctx.rotate(text.rotation);\n ctx.fillText(text.text, 0, 0);\n } else {\n ctx.fillText(text.text, x, y);\n }\n\n ctx.restore();\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, distanceToLine } from '../../core/geometry';\nimport { DrawingPaneView } from '../../rendering/drawing-pane-view';\n\n/**\n * Base class for two-point line drawings.\n * Provides common functionality for trend lines, rays, arrows, etc.\n */\nexport abstract class BaseLine extends Drawing {\n protected static readonly HIT_THRESHOLD = 5; // pixels\n protected static readonly REQUIRED_ANCHORS = 2;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<DrawingOptions> = {}\n ) {\n super(id, anchors, style, options);\n }\n\n // ============ Validation ============\n\n isValid(): boolean {\n return this._anchors.length >= BaseLine.REQUIRED_ANCHORS;\n }\n\n // ============ Pane Views ============\n\n paneViews(): IPrimitivePaneView[] {\n return [new DrawingPaneView(this)];\n }\n\n // ============ Geometry ============\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n extendLeft: this._options.extendLeft,\n extendRight: this._options.extendRight,\n };\n\n return [lineGeometry];\n }\n\n // ============ Hit Testing ============\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return false;\n\n // Check if line is extended\n const isExtended = this._options.extendLeft || this._options.extendRight;\n\n let distance: number;\n if (isExtended) {\n // Use infinite line distance\n distance = distanceToLine(point, start, end);\n } else {\n // Use segment distance\n distance = distanceToLineSegment(point, start, end);\n }\n\n return distance <= BaseLine.HIT_THRESHOLD;\n }\n\n // ============ Utility Methods ============\n\n /**\n * Convert a Time value to epoch seconds.\n * Handles numeric timestamps, \"YYYY-MM-DD\" strings, and BusinessDay objects.\n */\n protected static timeToSeconds(time: any): number {\n if (typeof time === 'number') return time;\n if (typeof time === 'string') return new Date(time).getTime() / 1000;\n if (typeof time === 'object' && time !== null && 'year' in time) {\n return new Date(time.year, time.month - 1, time.day).getTime() / 1000;\n }\n return NaN;\n }\n\n /**\n * Get the angle of the line in degrees\n */\n getAngle(): number {\n if (!this.isValid()) return 0;\n\n const dx = this._anchors[1].price - this._anchors[0].price;\n const dt = BaseLine.timeToSeconds(this._anchors[1].time) - BaseLine.timeToSeconds(this._anchors[0].time);\n\n return Math.atan2(dx, dt) * (180 / Math.PI);\n }\n\n /**\n * Get the price change between anchors\n */\n getPriceChange(): { absolute: number; percentage: number } {\n if (!this.isValid()) return { absolute: 0, percentage: 0 };\n\n const startPrice = this._anchors[0].price;\n const endPrice = this._anchors[1].price;\n const absolute = endPrice - startPrice;\n const percentage = startPrice !== 0 ? (absolute / startPrice) * 100 : 0;\n\n return { absolute, percentage };\n }\n\n /**\n * Get the time span between anchors in bars (calendar days)\n */\n getTimeSpan(): number {\n if (!this.isValid()) return 0;\n const t0 = BaseLine.timeToSeconds(this._anchors[0].time);\n const t1 = BaseLine.timeToSeconds(this._anchors[1].time);\n return Math.round(Math.abs(t1 - t0) / 86400);\n }\n}\n","import type {\n IPrimitivePaneView,\n IPrimitivePaneRenderer,\n} from 'lightweight-charts';\nimport type {\n CanvasRenderingTarget2D,\n BitmapCoordinatesRenderingScope,\n} from 'fancy-canvas';\n\nimport type { TrendLine } from './trend-line';\nimport type { Point, Viewport } from '../../core/types';\nimport { extendLineToViewport, midpoint, getLineAngleDegrees } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\n/**\n * Specialized pane view for TrendLine with label support\n */\nexport class TrendLinePaneView implements IPrimitivePaneView {\n private _renderer: TrendLinePaneRenderer;\n\n constructor(drawing: TrendLine) {\n this._renderer = new TrendLinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\n/**\n * Renderer for TrendLine\n */\nclass TrendLinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: TrendLine;\n\n constructor(drawing: TrendLine) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n // Get viewport\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n\n // Check visibility\n if (!this._drawing.options.visible) return;\n\n // Check validity\n if (!this._drawing.isValid()) return;\n\n // Get anchor points\n const anchors = this._drawing.anchors;\n const start = this._drawing.anchorToPixel(anchors[0], viewport);\n const end = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!start || !end) return;\n\n // Apply style\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Render line with extensions\n this.renderLine(ctx, start, end, viewport, pixelRatio);\n\n // Render labels if enabled\n this.renderLabels(ctx, start, end, pixelRatio);\n\n // Draw control points if selected, editing, or hovered\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing' || state === 'hovered') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio, this._drawing.style.lineColor);\n }\n }\n\n private renderLine(\n ctx: CanvasRenderingContext2D,\n start: Point,\n end: Point,\n viewport: Viewport,\n pixelRatio: number\n ): void {\n let drawStart = start;\n let drawEnd = end;\n\n const options = this._drawing.options;\n\n // Extend line if needed\n if (options.extendLeft || options.extendRight) {\n const extended = extendLineToViewport(\n start,\n end,\n viewport.width,\n viewport.height,\n options.extendLeft ?? false,\n options.extendRight ?? false\n );\n drawStart = extended.start;\n drawEnd = extended.end;\n }\n\n drawLine(ctx, drawStart, drawEnd, pixelRatio);\n }\n\n private renderLabels(\n ctx: CanvasRenderingContext2D,\n start: Point,\n end: Point,\n pixelRatio: number\n ): void {\n const options = this._drawing.trendLineOptions;\n\n if (!options.showAngle &&\n !options.showPriceChange &&\n !options.showPercentChange &&\n !options.showBars) {\n return;\n }\n\n // Calculate label parts\n const labelParts: string[] = [];\n\n if (options.showAngle) {\n const angle = getLineAngleDegrees(start, end);\n labelParts.push(`${angle.toFixed(1)}°`);\n }\n\n if (options.showPriceChange) {\n const { absolute } = this._drawing.getPriceChange();\n const sign = absolute >= 0 ? '+' : '';\n labelParts.push(`${sign}${absolute.toFixed(2)}`);\n }\n\n if (options.showPercentChange) {\n const { percentage } = this._drawing.getPriceChange();\n const sign = percentage >= 0 ? '+' : '';\n labelParts.push(`${sign}${percentage.toFixed(2)}%`);\n }\n\n if (options.showBars) {\n const bars = this._drawing.getTimeSpan();\n labelParts.push(`${bars} bars`);\n }\n\n if (labelParts.length === 0) return;\n\n // Position label at midpoint, above the line\n const labelPosition = midpoint(start, end);\n const offset = 20;\n\n // Determine if line goes up or down to position label appropriately\n const goesUp = end.y < start.y;\n const labelY = goesUp ? labelPosition.y - offset : labelPosition.y + offset;\n\n const text = labelParts.join(' | ');\n\n drawLabel(\n ctx,\n text,\n { x: labelPosition.x, y: labelY },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { BaseLine } from './base-line';\nimport type { Anchor, Point, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry, TextGeometry } from '../../core/geometry';\nimport { getLineAngleDegrees, midpoint } from '../../core/geometry';\nimport { TrendLinePaneView } from './trend-line-pane-view';\n\n/**\n * TrendLine options beyond base drawing options\n */\nexport interface TrendLineOptions extends DrawingOptions {\n showAngle?: boolean;\n showPriceChange?: boolean;\n showPercentChange?: boolean;\n showBars?: boolean;\n}\n\n/**\n * TrendLine - The most advanced line drawing tool.\n *\n * Features:\n * - Two-point line drawing\n * - Optional line extensions (left/right)\n * - Optional angle display\n * - Optional price/percentage change display\n * - Optional bar count display\n * - Hit testing for selection\n * - Anchor manipulation\n */\nexport class TrendLine extends BaseLine {\n readonly type = 'trend-line';\n\n private _trendLineOptions: TrendLineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<TrendLineOptions> = {}\n ) {\n const { showAngle, showPriceChange, showPercentChange, showBars, ...baseOptions } = options;\n\n super(id, anchors, style, baseOptions);\n\n this._trendLineOptions = {\n ...this._options,\n showAngle: showAngle ?? false,\n showPriceChange: showPriceChange ?? false,\n showPercentChange: showPercentChange ?? false,\n showBars: showBars ?? false,\n };\n }\n\n // ============ Getters/Setters ============\n\n get trendLineOptions(): TrendLineOptions {\n return this._trendLineOptions;\n }\n\n setTrendLineOptions(options: Partial<TrendLineOptions>): void {\n this._trendLineOptions = { ...this._trendLineOptions, ...options };\n this.requestUpdate();\n }\n\n // ============ Pane Views ============\n\n paneViews(): IPrimitivePaneView[] {\n return [new TrendLinePaneView(this)];\n }\n\n // ============ Geometry ============\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const geometries: Geometry[] = [];\n\n // Main line\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n extendLeft: this._options.extendLeft,\n extendRight: this._options.extendRight,\n };\n geometries.push(lineGeometry);\n\n // Add labels if enabled\n if (this._trendLineOptions.showAngle ||\n this._trendLineOptions.showPriceChange ||\n this._trendLineOptions.showPercentChange ||\n this._trendLineOptions.showBars) {\n const labelGeometries = this.computeLabelGeometry(start, end);\n geometries.push(...labelGeometries);\n }\n\n return geometries;\n }\n\n private computeLabelGeometry(start: Point, end: Point): Geometry[] {\n const labels: TextGeometry[] = [];\n const labelPosition = midpoint(start, end);\n const offset = 15; // pixels above the line\n\n // Calculate label text\n const labelParts: string[] = [];\n\n if (this._trendLineOptions.showAngle) {\n const angle = getLineAngleDegrees(start, end);\n labelParts.push(`${angle.toFixed(1)}°`);\n }\n\n if (this._trendLineOptions.showPriceChange) {\n const { absolute } = this.getPriceChange();\n const sign = absolute >= 0 ? '+' : '';\n labelParts.push(`${sign}${absolute.toFixed(2)}`);\n }\n\n if (this._trendLineOptions.showPercentChange) {\n const { percentage } = this.getPriceChange();\n const sign = percentage >= 0 ? '+' : '';\n labelParts.push(`${sign}${percentage.toFixed(2)}%`);\n }\n\n if (this._trendLineOptions.showBars) {\n const bars = this.getTimeSpan();\n labelParts.push(`${bars} bars`);\n }\n\n if (labelParts.length > 0) {\n labels.push({\n type: 'text',\n position: { x: labelPosition.x, y: labelPosition.y - offset },\n text: labelParts.join(' | '),\n font: this._style.labelFont,\n color: this._style.labelColor,\n align: 'center',\n baseline: 'bottom',\n });\n }\n\n return labels;\n }\n\n // ============ Clone ============\n\n clone(newId: string): IDrawing {\n return new TrendLine(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._trendLineOptions }\n );\n }\n\n // ============ Serialization ============\n\n toJSON() {\n const base = super.toJSON();\n return {\n ...base,\n options: { ...this._trendLineOptions },\n };\n }\n\n fromJSON(data: any): void {\n super.fromJSON(data);\n if (data.options) {\n this._trendLineOptions = { ...this._trendLineOptions, ...data.options };\n }\n }\n\n // ============ Static Factory ============\n\n static create(\n id: string,\n startAnchor: Anchor,\n endAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<TrendLineOptions>\n ): TrendLine {\n return new TrendLine(id, [startAnchor, endAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { HorizontalLine } from './horizontal-line';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class HorizontalLinePaneView implements IPrimitivePaneView {\n private _renderer: HorizontalLinePaneRenderer;\n\n constructor(drawing: HorizontalLine) {\n this._renderer = new HorizontalLinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass HorizontalLinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: HorizontalLine;\n\n constructor(drawing: HorizontalLine) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n if (y === null) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw horizontal line\n const start: Point = { x: 0, y };\n const end: Point = { x: viewport.width, y };\n drawLine(ctx, start, end, pixelRatio);\n\n // Draw price label\n const options = this._drawing.horizontalLineOptions;\n if (options.showPrice) {\n const priceText = options.labelText || anchor.price.toFixed(2);\n drawLabel(\n ctx,\n priceText,\n { x: viewport.width - 10, y },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry, TextGeometry } from '../../core/geometry';\nimport { HorizontalLinePaneView } from './horizontal-line-pane-view';\n\n/**\n * HorizontalLine options\n */\nexport interface HorizontalLineOptions extends DrawingOptions {\n showPrice?: boolean;\n showLabel?: boolean;\n labelText?: string;\n}\n\n/**\n * HorizontalLine - A horizontal line at a specific price level.\n *\n * Features:\n * - Single anchor point (price level)\n * - Extends across entire viewport\n * - Optional price label\n * - Optional custom label text\n */\nexport class HorizontalLine extends Drawing {\n readonly type = 'horizontal-line';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _horizontalLineOptions: HorizontalLineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<HorizontalLineOptions> = {}\n ) {\n const { showPrice, showLabel, labelText, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._horizontalLineOptions = {\n ...this._options,\n showPrice: showPrice ?? true,\n showLabel: showLabel ?? false,\n labelText: labelText ?? '',\n };\n }\n\n get horizontalLineOptions(): HorizontalLineOptions {\n return this._horizontalLineOptions;\n }\n\n setHorizontalLineOptions(options: Partial<HorizontalLineOptions>): void {\n this._horizontalLineOptions = { ...this._horizontalLineOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= HorizontalLine.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new HorizontalLinePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const anchor = this._anchors[0];\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n if (y === null) return [];\n\n const geometries: Geometry[] = [];\n\n // Horizontal line spanning viewport\n const lineGeometry: LineGeometry = {\n type: 'line',\n start: { x: 0, y },\n end: { x: viewport.width, y },\n };\n geometries.push(lineGeometry);\n\n // Price label\n if (this._horizontalLineOptions.showPrice) {\n const priceText = anchor.price.toFixed(2);\n geometries.push({\n type: 'text',\n position: { x: viewport.width - 5, y: y - 10 },\n text: priceText,\n align: 'right',\n baseline: 'bottom',\n color: this._style.labelColor,\n font: this._style.labelFont,\n } as TextGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const anchor = this._anchors[0];\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n if (y === null) return false;\n\n return Math.abs(point.y - y) <= HorizontalLine.HIT_THRESHOLD;\n }\n\n clone(newId: string): IDrawing {\n return new HorizontalLine(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._horizontalLineOptions }\n );\n }\n\n static create(\n id: string,\n price: number,\n time: number | string,\n style?: Partial<DrawingStyle>,\n options?: Partial<HorizontalLineOptions>\n ): HorizontalLine {\n return new HorizontalLine(id, [{ time: time as any, price }], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { VerticalLine } from './vertical-line';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class VerticalLinePaneView implements IPrimitivePaneView {\n private _renderer: VerticalLinePaneRenderer;\n\n constructor(drawing: VerticalLine) {\n this._renderer = new VerticalLinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass VerticalLinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: VerticalLine;\n\n constructor(drawing: VerticalLine) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n if (x === null) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw vertical line\n const start: Point = { x, y: 0 };\n const end: Point = { x, y: viewport.height };\n drawLine(ctx, start, end, pixelRatio);\n\n // Draw time label\n const options = this._drawing.verticalLineOptions;\n if (options.showTime) {\n const timeText = options.labelText || String(anchor.time);\n drawLabel(\n ctx,\n timeText,\n { x, y: viewport.height - 10 },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { VerticalLinePaneView } from './vertical-line-pane-view';\n\n/**\n * VerticalLine options\n */\nexport interface VerticalLineOptions extends DrawingOptions {\n showTime?: boolean;\n showLabel?: boolean;\n labelText?: string;\n}\n\n/**\n * VerticalLine - A vertical line at a specific time.\n *\n * Features:\n * - Single anchor point (time)\n * - Extends across entire viewport height\n * - Optional time label\n * - Optional custom label text\n */\nexport class VerticalLine extends Drawing {\n readonly type = 'vertical-line';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _verticalLineOptions: VerticalLineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<VerticalLineOptions> = {}\n ) {\n const { showTime, showLabel, labelText, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._verticalLineOptions = {\n ...this._options,\n showTime: showTime ?? true,\n showLabel: showLabel ?? false,\n labelText: labelText ?? '',\n };\n }\n\n get verticalLineOptions(): VerticalLineOptions {\n return this._verticalLineOptions;\n }\n\n setVerticalLineOptions(options: Partial<VerticalLineOptions>): void {\n this._verticalLineOptions = { ...this._verticalLineOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= VerticalLine.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new VerticalLinePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const anchor = this._anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n if (x === null) return [];\n\n const geometries: Geometry[] = [];\n\n // Vertical line spanning viewport\n const lineGeometry: LineGeometry = {\n type: 'line',\n start: { x, y: 0 },\n end: { x, y: viewport.height },\n };\n geometries.push(lineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const anchor = this._anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n if (x === null) return false;\n\n return Math.abs(point.x - x) <= VerticalLine.HIT_THRESHOLD;\n }\n\n clone(newId: string): IDrawing {\n return new VerticalLine(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._verticalLineOptions }\n );\n }\n\n static create(\n id: string,\n time: number | string,\n price: number,\n style?: Partial<DrawingStyle>,\n options?: Partial<VerticalLineOptions>\n ): VerticalLine {\n return new VerticalLine(id, [{ time: time as any, price }], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Ray } from './ray';\nimport { extendLineToViewport, getLineAngleDegrees, midpoint } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class RayPaneView implements IPrimitivePaneView {\n private _renderer: RayPaneRenderer;\n\n constructor(drawing: Ray) {\n this._renderer = new RayPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass RayPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Ray;\n\n constructor(drawing: Ray) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const start = this._drawing.anchorToPixel(anchors[0], viewport);\n const end = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!start || !end) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Extend line to the right\n const extended = extendLineToViewport(\n start,\n end,\n viewport.width,\n viewport.height,\n false,\n true\n );\n\n drawLine(ctx, start, extended.end, pixelRatio);\n\n // Draw angle label if enabled\n if (this._drawing.rayOptions.showAngle) {\n const angle = getLineAngleDegrees(start, end);\n const labelPos = midpoint(start, end);\n drawLabel(\n ctx,\n `${angle.toFixed(1)}°`,\n { x: labelPos.x, y: labelPos.y - 15 },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { BaseLine } from './base-line';\nimport type { Anchor, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { RayPaneView } from './ray-pane-view';\n\n/**\n * Ray options\n */\nexport interface RayOptions extends DrawingOptions {\n showAngle?: boolean;\n}\n\n/**\n * Ray - A line that extends infinitely in one direction from the first anchor.\n *\n * Features:\n * - Two anchor points define the direction\n * - Extends infinitely from first anchor through second anchor\n * - Optional angle display\n */\nexport class Ray extends BaseLine {\n readonly type = 'ray';\n\n private _rayOptions: RayOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<RayOptions> = {}\n ) {\n const { showAngle, ...baseOptions } = options;\n // Force extendRight to true for ray behavior\n super(id, anchors, style, { ...baseOptions, extendRight: true });\n\n this._rayOptions = {\n ...this._options,\n showAngle: showAngle ?? false,\n };\n }\n\n get rayOptions(): RayOptions {\n return this._rayOptions;\n }\n\n setRayOptions(options: Partial<RayOptions>): void {\n this._rayOptions = { ...this._rayOptions, ...options };\n this.requestUpdate();\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new RayPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n extendLeft: false,\n extendRight: true, // Always extend right for ray\n };\n\n return [lineGeometry];\n }\n\n clone(newId: string): IDrawing {\n return new Ray(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._rayOptions }\n );\n }\n\n static create(\n id: string,\n startAnchor: Anchor,\n endAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<RayOptions>\n ): Ray {\n return new Ray(id, [startAnchor, endAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Arrow } from './arrow';\nimport { applyStyle, drawLine, drawControlPoints, drawFilledArrowHead } from '../../rendering/canvas-utils';\n\nexport class ArrowPaneView implements IPrimitivePaneView {\n private _renderer: ArrowPaneRenderer;\n\n constructor(drawing: Arrow) {\n this._renderer = new ArrowPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ArrowPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Arrow;\n\n constructor(drawing: Arrow) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const start = this._drawing.anchorToPixel(anchors[0], viewport);\n const end = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!start || !end) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw the line\n drawLine(ctx, start, end, pixelRatio);\n\n // Draw arrowhead at end\n ctx.fillStyle = this._drawing.style.lineColor;\n const arrowSize = this._drawing.arrowOptions.arrowSize ?? 12;\n drawFilledArrowHead(ctx, start, end, arrowSize, pixelRatio);\n\n // Draw arrowhead at start if both ends enabled\n if (this._drawing.arrowOptions.showBothEnds) {\n drawFilledArrowHead(ctx, end, start, arrowSize, pixelRatio);\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { BaseLine } from './base-line';\nimport type { Anchor, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { ArrowPaneView } from './arrow-pane-view';\n\n/**\n * Arrow options\n */\nexport interface ArrowOptions extends DrawingOptions {\n arrowSize?: number;\n showBothEnds?: boolean;\n}\n\n/**\n * Arrow - A line with an arrowhead at the end.\n *\n * Features:\n * - Two anchor points\n * - Arrowhead at the end point\n * - Optional arrowhead at both ends\n * - Configurable arrow size\n */\nexport class Arrow extends BaseLine {\n readonly type = 'arrow';\n\n private _arrowOptions: ArrowOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ArrowOptions> = {}\n ) {\n const { arrowSize, showBothEnds, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._arrowOptions = {\n ...this._options,\n arrowSize: arrowSize ?? 12,\n showBothEnds: showBothEnds ?? false,\n };\n }\n\n get arrowOptions(): ArrowOptions {\n return this._arrowOptions;\n }\n\n setArrowOptions(options: Partial<ArrowOptions>): void {\n this._arrowOptions = { ...this._arrowOptions, ...options };\n this.requestUpdate();\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ArrowPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n };\n\n return [lineGeometry];\n }\n\n clone(newId: string): IDrawing {\n return new Arrow(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._arrowOptions }\n );\n }\n\n static create(\n id: string,\n startAnchor: Anchor,\n endAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ArrowOptions>\n ): Arrow {\n return new Arrow(id, [startAnchor, endAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ExtendedLine } from './extended-line';\nimport { extendLineToViewport, getLineAngleDegrees, midpoint } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class ExtendedLinePaneView implements IPrimitivePaneView {\n private _renderer: ExtendedLinePaneRenderer;\n\n constructor(drawing: ExtendedLine) {\n this._renderer = new ExtendedLinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ExtendedLinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ExtendedLine;\n\n constructor(drawing: ExtendedLine) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const start = this._drawing.anchorToPixel(anchors[0], viewport);\n const end = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!start || !end) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Extend line in both directions\n const extended = extendLineToViewport(\n start,\n end,\n viewport.width,\n viewport.height,\n true,\n true\n );\n\n drawLine(ctx, extended.start, extended.end, pixelRatio);\n\n // Draw angle label if enabled\n if (this._drawing.extendedLineOptions.showAngle) {\n const angle = getLineAngleDegrees(start, end);\n const labelPos = midpoint(start, end);\n drawLabel(\n ctx,\n `${angle.toFixed(1)}°`,\n { x: labelPos.x, y: labelPos.y - 15 },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { BaseLine } from './base-line';\nimport type { Anchor, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { ExtendedLinePaneView } from './extended-line-pane-view';\n\n/**\n * ExtendedLine options\n */\nexport interface ExtendedLineOptions extends DrawingOptions {\n showAngle?: boolean;\n}\n\n/**\n * ExtendedLine - A line that extends infinitely in both directions.\n *\n * Features:\n * - Two anchor points define the line\n * - Extends infinitely in both directions\n * - Optional angle display\n */\nexport class ExtendedLine extends BaseLine {\n readonly type = 'extended-line';\n\n private _extendedLineOptions: ExtendedLineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ExtendedLineOptions> = {}\n ) {\n const { showAngle, ...baseOptions } = options;\n // Force both extensions to true\n super(id, anchors, style, { ...baseOptions, extendLeft: true, extendRight: true });\n\n this._extendedLineOptions = {\n ...this._options,\n showAngle: showAngle ?? false,\n };\n }\n\n get extendedLineOptions(): ExtendedLineOptions {\n return this._extendedLineOptions;\n }\n\n setExtendedLineOptions(options: Partial<ExtendedLineOptions>): void {\n this._extendedLineOptions = { ...this._extendedLineOptions, ...options };\n this.requestUpdate();\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ExtendedLinePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n extendLeft: true,\n extendRight: true,\n };\n\n return [lineGeometry];\n }\n\n clone(newId: string): IDrawing {\n return new ExtendedLine(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._extendedLineOptions }\n );\n }\n\n static create(\n id: string,\n startAnchor: Anchor,\n endAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ExtendedLineOptions>\n ): ExtendedLine {\n return new ExtendedLine(id, [startAnchor, endAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { CrossLine } from './cross-line';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class CrossLinePaneView implements IPrimitivePaneView {\n private _renderer: CrossLinePaneRenderer;\n\n constructor(drawing: CrossLine) {\n this._renderer = new CrossLinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass CrossLinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: CrossLine;\n\n constructor(drawing: CrossLine) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw horizontal line\n drawLine(ctx, { x: 0, y }, { x: viewport.width, y }, pixelRatio);\n\n // Draw vertical line\n drawLine(ctx, { x, y: 0 }, { x, y: viewport.height }, pixelRatio);\n\n // Draw labels\n const options = this._drawing.crossLineOptions;\n\n if (options.showPrice) {\n drawLabel(\n ctx,\n anchor.price.toFixed(2),\n { x: viewport.width - 10, y },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n if (options.showTime) {\n drawLabel(\n ctx,\n String(anchor.time),\n { x, y: viewport.height - 10 },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { CrossLinePaneView } from './cross-line-pane-view';\n\n/**\n * CrossLine options\n */\nexport interface CrossLineOptions extends DrawingOptions {\n showPrice?: boolean;\n showTime?: boolean;\n}\n\n/**\n * CrossLine - A crosshair at a specific point (horizontal + vertical lines).\n *\n * Features:\n * - Single anchor point\n * - Horizontal and vertical lines through the point\n * - Optional price and time labels\n */\nexport class CrossLine extends Drawing {\n readonly type = 'cross-line';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _crossLineOptions: CrossLineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<CrossLineOptions> = {}\n ) {\n const { showPrice, showTime, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._crossLineOptions = {\n ...this._options,\n showPrice: showPrice ?? true,\n showTime: showTime ?? true,\n };\n }\n\n get crossLineOptions(): CrossLineOptions {\n return this._crossLineOptions;\n }\n\n setCrossLineOptions(options: Partial<CrossLineOptions>): void {\n this._crossLineOptions = { ...this._crossLineOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= CrossLine.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new CrossLinePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const anchor = this._anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return [];\n\n const geometries: Geometry[] = [];\n\n // Horizontal line\n geometries.push({\n type: 'line',\n start: { x: 0, y },\n end: { x: viewport.width, y },\n } as LineGeometry);\n\n // Vertical line\n geometries.push({\n type: 'line',\n start: { x, y: 0 },\n end: { x, y: viewport.height },\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const anchor = this._anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return false;\n\n // Hit if near either the horizontal or vertical line\n return Math.abs(point.x - x) <= CrossLine.HIT_THRESHOLD ||\n Math.abs(point.y - y) <= CrossLine.HIT_THRESHOLD;\n }\n\n clone(newId: string): IDrawing {\n return new CrossLine(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._crossLineOptions }\n );\n }\n\n static create(\n id: string,\n anchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<CrossLineOptions>\n ): CrossLine {\n return new CrossLine(id, [anchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { InfoLine } from './info-line';\nimport { getLineAngleDegrees, midpoint, distanceBetweenPoints } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class InfoLinePaneView implements IPrimitivePaneView {\n private _renderer: InfoLinePaneRenderer;\n\n constructor(drawing: InfoLine) {\n this._renderer = new InfoLinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass InfoLinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: InfoLine;\n\n constructor(drawing: InfoLine) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const start = this._drawing.anchorToPixel(anchors[0], viewport);\n const end = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!start || !end) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw line\n drawLine(ctx, start, end, pixelRatio);\n\n // Draw endpoint markers (circles)\n ctx.fillStyle = this._drawing.style.lineColor;\n ctx.beginPath();\n ctx.arc(start.x * pixelRatio, start.y * pixelRatio, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n ctx.beginPath();\n ctx.arc(end.x * pixelRatio, end.y * pixelRatio, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Build info label\n const options = this._drawing.infoLineOptions;\n const labelParts: string[] = [];\n\n if (options.showDistance) {\n const distance = distanceBetweenPoints(start, end);\n labelParts.push(`${distance.toFixed(0)}px`);\n }\n\n if (options.showAngle) {\n const angle = getLineAngleDegrees(start, end);\n labelParts.push(`${angle.toFixed(1)}°`);\n }\n\n if (options.showPriceChange) {\n const priceChange = this._drawing.getPriceChange();\n const sign = priceChange.absolute >= 0 ? '+' : '';\n labelParts.push(`${sign}${priceChange.absolute.toFixed(2)}`);\n }\n\n if (options.showPercentChange) {\n const priceChange = this._drawing.getPriceChange();\n const sign = priceChange.percentage >= 0 ? '+' : '';\n labelParts.push(`${sign}${priceChange.percentage.toFixed(2)}%`);\n }\n\n if (options.showBars) {\n const bars = this._drawing.getTimeSpan();\n labelParts.push(`${bars} bars`);\n }\n\n // Draw info label\n if (labelParts.length > 0) {\n const labelPos = midpoint(start, end);\n drawLabel(\n ctx,\n labelParts.join(' | '),\n { x: labelPos.x, y: labelPos.y - 20 },\n {\n font: this._drawing.style.labelFont || '11px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'DD',\n padding: 6,\n borderRadius: 4,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { BaseLine } from './base-line';\nimport type { Anchor, Point, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry, TextGeometry } from '../../core/geometry';\nimport { getLineAngleDegrees, midpoint, distanceBetweenPoints } from '../../core/geometry';\nimport { InfoLinePaneView } from './info-line-pane-view';\n\n/**\n * InfoLine options\n */\nexport interface InfoLineOptions extends DrawingOptions {\n showDistance?: boolean;\n showAngle?: boolean;\n showPriceChange?: boolean;\n showPercentChange?: boolean;\n showBars?: boolean;\n showTime?: boolean;\n}\n\n/**\n * InfoLine - A line that displays measurement information.\n *\n * Features:\n * - Two anchor points\n * - Shows distance, angle, price/percent change\n * - Shows bar count and time duration\n * - Comprehensive measurement tool\n */\nexport class InfoLine extends BaseLine {\n readonly type = 'info-line';\n\n private _infoLineOptions: InfoLineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<InfoLineOptions> = {}\n ) {\n const { showDistance, showAngle, showPriceChange, showPercentChange, showBars, showTime, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._infoLineOptions = {\n ...this._options,\n showDistance: showDistance ?? true,\n showAngle: showAngle ?? true,\n showPriceChange: showPriceChange ?? true,\n showPercentChange: showPercentChange ?? true,\n showBars: showBars ?? true,\n showTime: showTime ?? false,\n };\n }\n\n get infoLineOptions(): InfoLineOptions {\n return this._infoLineOptions;\n }\n\n setInfoLineOptions(options: Partial<InfoLineOptions>): void {\n this._infoLineOptions = { ...this._infoLineOptions, ...options };\n this.requestUpdate();\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new InfoLinePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const geometries: Geometry[] = [];\n\n // Main line\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n };\n geometries.push(lineGeometry);\n\n // Add info label\n const labelGeometries = this.computeLabelGeometry(start, end);\n geometries.push(...labelGeometries);\n\n return geometries;\n }\n\n private computeLabelGeometry(start: Point, end: Point): Geometry[] {\n const labels: TextGeometry[] = [];\n const labelPosition = midpoint(start, end);\n const offset = 20;\n\n const labelParts: string[] = [];\n\n if (this._infoLineOptions.showDistance) {\n const distance = distanceBetweenPoints(start, end);\n labelParts.push(`${distance.toFixed(0)}px`);\n }\n\n if (this._infoLineOptions.showAngle) {\n const angle = getLineAngleDegrees(start, end);\n labelParts.push(`${angle.toFixed(1)}°`);\n }\n\n if (this._infoLineOptions.showPriceChange) {\n const { absolute } = this.getPriceChange();\n const sign = absolute >= 0 ? '+' : '';\n labelParts.push(`${sign}${absolute.toFixed(2)}`);\n }\n\n if (this._infoLineOptions.showPercentChange) {\n const { percentage } = this.getPriceChange();\n const sign = percentage >= 0 ? '+' : '';\n labelParts.push(`${sign}${percentage.toFixed(2)}%`);\n }\n\n if (this._infoLineOptions.showBars) {\n const bars = this.getTimeSpan();\n labelParts.push(`${bars} bars`);\n }\n\n if (labelParts.length > 0) {\n labels.push({\n type: 'text',\n position: { x: labelPosition.x, y: labelPosition.y - offset },\n text: labelParts.join(' | '),\n font: this._style.labelFont,\n color: this._style.labelColor,\n align: 'center',\n baseline: 'bottom',\n });\n }\n\n return labels;\n }\n\n /**\n * Get all measurement info as an object\n */\n getMeasurements(viewport: Viewport): {\n distance: number;\n angle: number;\n priceChange: number;\n percentChange: number;\n bars: number;\n } | null {\n if (!this.isValid()) return null;\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return null;\n\n const { absolute, percentage } = this.getPriceChange();\n\n return {\n distance: distanceBetweenPoints(start, end),\n angle: getLineAngleDegrees(start, end),\n priceChange: absolute,\n percentChange: percentage,\n bars: this.getTimeSpan(),\n };\n }\n\n clone(newId: string): IDrawing {\n return new InfoLine(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._infoLineOptions }\n );\n }\n\n static create(\n id: string,\n startAnchor: Anchor,\n endAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<InfoLineOptions>\n ): InfoLine {\n return new InfoLine(id, [startAnchor, endAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { TrendAngle } from './trend-angle';\nimport { getLineAngleDegrees } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class TrendAnglePaneView implements IPrimitivePaneView {\n private _renderer: TrendAnglePaneRenderer;\n\n constructor(drawing: TrendAngle) {\n this._renderer = new TrendAnglePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass TrendAnglePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: TrendAngle;\n\n constructor(drawing: TrendAngle) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const start = this._drawing.anchorToPixel(anchors[0], viewport);\n const end = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!start || !end) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw main line\n drawLine(ctx, start, end, pixelRatio);\n\n const options = this._drawing.trendAngleOptions;\n\n // Draw angle arc\n if (options.showArc) {\n const arcRadius = (options.arcRadius ?? 40) * pixelRatio;\n const angle = Math.atan2(start.y - end.y, end.x - start.x);\n\n // Draw horizontal reference line (dashed)\n ctx.save();\n ctx.setLineDash([4 * pixelRatio, 4 * pixelRatio]);\n ctx.strokeStyle = this._drawing.style.lineColor + '80';\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n ctx.lineTo((start.x + arcRadius / pixelRatio + 20) * pixelRatio, start.y * pixelRatio);\n ctx.stroke();\n ctx.restore();\n\n // Draw arc\n ctx.beginPath();\n ctx.strokeStyle = this._drawing.style.lineColor;\n ctx.lineWidth = 2 * pixelRatio;\n\n // Arc from 0 (horizontal right) to the angle\n if (angle >= 0) {\n ctx.arc(start.x * pixelRatio, start.y * pixelRatio, arcRadius, 0, -angle, true);\n } else {\n ctx.arc(start.x * pixelRatio, start.y * pixelRatio, arcRadius, 0, -angle, false);\n }\n ctx.stroke();\n\n // Fill arc area with semi-transparent color\n ctx.beginPath();\n ctx.fillStyle = this._drawing.style.lineColor + '20';\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n if (angle >= 0) {\n ctx.arc(start.x * pixelRatio, start.y * pixelRatio, arcRadius, 0, -angle, true);\n } else {\n ctx.arc(start.x * pixelRatio, start.y * pixelRatio, arcRadius, 0, -angle, false);\n }\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw angle label\n if (options.showDegrees) {\n const angleDeg = getLineAngleDegrees(start, end);\n const labelRadius = (options.arcRadius ?? 40) + 15;\n\n // Position label at the midpoint of the arc\n const midAngle = Math.atan2(start.y - end.y, end.x - start.x) / 2;\n const labelX = start.x + labelRadius * Math.cos(-midAngle);\n const labelY = start.y - labelRadius * Math.sin(-midAngle);\n\n drawLabel(\n ctx,\n `${angleDeg.toFixed(1)}°`,\n { x: labelX, y: labelY },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { BaseLine } from './base-line';\nimport type { Anchor, Point, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry, ArcGeometry } from '../../core/geometry';\nimport { getLineAngleDegrees } from '../../core/geometry';\nimport { TrendAnglePaneView } from './trend-angle-pane-view';\n\n/**\n * TrendAngle options\n */\nexport interface TrendAngleOptions extends DrawingOptions {\n showArc?: boolean;\n arcRadius?: number;\n showDegrees?: boolean;\n}\n\n/**\n * TrendAngle - A line that displays its angle with a visual arc indicator.\n *\n * Features:\n * - Two anchor points\n * - Visual arc showing the angle from horizontal\n * - Degree label display\n * - Useful for measuring trend slopes\n */\nexport class TrendAngle extends BaseLine {\n readonly type = 'trend-angle';\n\n private _trendAngleOptions: TrendAngleOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<TrendAngleOptions> = {}\n ) {\n const { showArc, arcRadius, showDegrees, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._trendAngleOptions = {\n ...this._options,\n showArc: showArc ?? true,\n arcRadius: arcRadius ?? 40,\n showDegrees: showDegrees ?? true,\n };\n }\n\n get trendAngleOptions(): TrendAngleOptions {\n return this._trendAngleOptions;\n }\n\n setTrendAngleOptions(options: Partial<TrendAngleOptions>): void {\n this._trendAngleOptions = { ...this._trendAngleOptions, ...options };\n this.requestUpdate();\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new TrendAnglePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const end = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!start || !end) return [];\n\n const geometries: Geometry[] = [];\n\n // Main line\n const lineGeometry: LineGeometry = {\n type: 'line',\n start,\n end,\n };\n geometries.push(lineGeometry);\n\n // Arc showing angle\n if (this._trendAngleOptions.showArc) {\n const angle = this.getAngleRadians(start, end);\n const arcGeometry: ArcGeometry = {\n type: 'arc',\n center: start,\n radius: this._trendAngleOptions.arcRadius ?? 40,\n startAngle: 0,\n endAngle: angle,\n };\n geometries.push(arcGeometry);\n }\n\n return geometries;\n }\n\n /**\n * Get the angle in radians (from horizontal)\n */\n private getAngleRadians(start: Point, end: Point): number {\n return Math.atan2(start.y - end.y, end.x - start.x);\n }\n\n /**\n * Get the angle in degrees\n */\n getAngle(): number {\n if (!this.isValid()) return 0;\n return getLineAngleDegrees(\n { x: 0, y: 0 },\n {\n x: this._anchors[1].price - this._anchors[0].price,\n y: 0,\n }\n );\n }\n\n clone(newId: string): IDrawing {\n return new TrendAngle(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._trendAngleOptions }\n );\n }\n\n static create(\n id: string,\n startAnchor: Anchor,\n endAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<TrendAngleOptions>\n ): TrendAngle {\n return new TrendAngle(id, [startAnchor, endAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { HorizontalRay } from './horizontal-ray';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class HorizontalRayPaneView implements IPrimitivePaneView {\n private _renderer: HorizontalRayPaneRenderer;\n\n constructor(drawing: HorizontalRay) {\n this._renderer = new HorizontalRayPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass HorizontalRayPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: HorizontalRay;\n\n constructor(drawing: HorizontalRay) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n const options = this._drawing.horizontalRayOptions;\n const direction = options.direction ?? 'right';\n\n // Draw horizontal ray\n const start: Point = { x, y };\n const end: Point = {\n x: direction === 'right' ? viewport.width : 0,\n y,\n };\n\n drawLine(ctx, start, end, pixelRatio);\n\n // Draw start point marker\n ctx.fillStyle = this._drawing.style.lineColor;\n ctx.beginPath();\n ctx.arc(x * pixelRatio, y * pixelRatio, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw arrow indicator at the extending end\n const arrowSize = 8 * pixelRatio;\n const arrowX = direction === 'right'\n ? (viewport.width - 15) * pixelRatio\n : 15 * pixelRatio;\n\n ctx.beginPath();\n if (direction === 'right') {\n ctx.moveTo(arrowX, y * pixelRatio);\n ctx.lineTo(arrowX - arrowSize, y * pixelRatio - arrowSize / 2);\n ctx.lineTo(arrowX - arrowSize, y * pixelRatio + arrowSize / 2);\n } else {\n ctx.moveTo(arrowX, y * pixelRatio);\n ctx.lineTo(arrowX + arrowSize, y * pixelRatio - arrowSize / 2);\n ctx.lineTo(arrowX + arrowSize, y * pixelRatio + arrowSize / 2);\n }\n ctx.closePath();\n ctx.fill();\n\n // Draw price label\n if (options.showPrice) {\n const labelX = direction === 'right' ? viewport.width - 10 : 10;\n drawLabel(\n ctx,\n anchor.price.toFixed(2),\n { x: labelX, y },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, DrawingStyle, DrawingOptions, IDrawing, Viewport } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { HorizontalRayPaneView } from './horizontal-ray-pane-view';\n\n/**\n * HorizontalRay options\n */\nexport interface HorizontalRayOptions extends DrawingOptions {\n showPrice?: boolean;\n direction?: 'right' | 'left';\n}\n\n/**\n * HorizontalRay - A horizontal ray extending from a single point.\n *\n * Features:\n * - Single anchor point (price level)\n * - Extends horizontally to the right (or left) edge\n * - Optional price label\n * - Useful for support/resistance levels with direction\n */\nexport class HorizontalRay extends Drawing {\n readonly type = 'horizontal-ray';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _horizontalRayOptions: HorizontalRayOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<HorizontalRayOptions> = {}\n ) {\n const { showPrice, direction, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._horizontalRayOptions = {\n ...this._options,\n showPrice: showPrice ?? true,\n direction: direction ?? 'right',\n };\n }\n\n get horizontalRayOptions(): HorizontalRayOptions {\n return this._horizontalRayOptions;\n }\n\n setHorizontalRayOptions(options: Partial<HorizontalRayOptions>): void {\n this._horizontalRayOptions = { ...this._horizontalRayOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= HorizontalRay.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new HorizontalRayPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const anchor = this._anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return [];\n\n const geometries: Geometry[] = [];\n\n // Horizontal ray\n const lineGeometry: LineGeometry = {\n type: 'line',\n start: { x, y },\n end: {\n x: this._horizontalRayOptions.direction === 'right' ? viewport.width : 0,\n y,\n },\n };\n geometries.push(lineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const anchor = this._anchors[0];\n const x = viewport.timeScale.timeToCoordinate(anchor.time);\n const y = viewport.priceScale.priceToCoordinate(anchor.price);\n\n if (x === null || y === null) return false;\n\n // Check if within vertical threshold\n if (Math.abs(point.y - y) > HorizontalRay.HIT_THRESHOLD) return false;\n\n // Check if within horizontal range\n if (this._horizontalRayOptions.direction === 'right') {\n return point.x >= x;\n } else {\n return point.x <= x;\n }\n }\n\n clone(newId: string): IDrawing {\n return new HorizontalRay(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._horizontalRayOptions }\n );\n }\n\n static create(\n id: string,\n time: number | string,\n price: number,\n style?: Partial<DrawingStyle>,\n options?: Partial<HorizontalRayOptions>\n ): HorizontalRay {\n return new HorizontalRay(id, [{ time: time as any, price }], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Rectangle } from './rectangle';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawRect, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class RectanglePaneView implements IPrimitivePaneView {\n private _renderer: RectanglePaneRenderer;\n\n constructor(drawing: Rectangle) {\n this._renderer = new RectanglePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass RectanglePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Rectangle;\n\n constructor(drawing: Rectangle) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const topLeft: Point = {\n x: Math.min(p1.x, p2.x),\n y: Math.min(p1.y, p2.y),\n };\n const width = Math.abs(p2.x - p1.x);\n const height = Math.abs(p2.y - p1.y);\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (this._drawing.rectangleOptions.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.fillRect(\n topLeft.x * pixelRatio,\n topLeft.y * pixelRatio,\n width * pixelRatio,\n height * pixelRatio\n );\n }\n\n // Draw border\n drawRect(ctx, topLeft, width, height, false, pixelRatio);\n\n // Draw dimensions if enabled\n if (this._drawing.rectangleOptions.showDimensions) {\n const priceRange = this._drawing.getPriceRange();\n const labelText = `$${priceRange.range.toFixed(2)}`;\n const centerX = topLeft.x + width / 2;\n const centerY = topLeft.y + height / 2;\n\n drawLabel(\n ctx,\n labelText,\n { x: centerX, y: centerY },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 4,\n borderRadius: 3,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, RectangleGeometry } from '../../core/geometry';\nimport { RectanglePaneView } from './rectangle-pane-view';\n\n/**\n * Rectangle options\n */\nexport interface RectangleOptions extends DrawingOptions {\n filled?: boolean;\n showDimensions?: boolean;\n}\n\n/**\n * Rectangle - A rectangular shape defined by two corner points.\n *\n * Features:\n * - Two anchor points (opposite corners)\n * - Optional fill\n * - Optional dimension labels\n */\nexport class Rectangle extends Drawing {\n readonly type = 'rectangle';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _rectangleOptions: RectangleOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<RectangleOptions> = {}\n ) {\n const { filled, showDimensions, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._rectangleOptions = {\n ...this._options,\n filled: filled ?? true,\n showDimensions: showDimensions ?? false,\n };\n }\n\n get rectangleOptions(): RectangleOptions {\n return this._rectangleOptions;\n }\n\n setRectangleOptions(options: Partial<RectangleOptions>): void {\n this._rectangleOptions = { ...this._rectangleOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Rectangle.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new RectanglePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const topLeft: Point = {\n x: Math.min(p1.x, p2.x),\n y: Math.min(p1.y, p2.y),\n };\n const width = Math.abs(p2.x - p1.x);\n const height = Math.abs(p2.y - p1.y);\n\n const rectGeometry: RectangleGeometry = {\n type: 'rectangle',\n topLeft,\n width,\n height,\n };\n\n return [rectGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n\n // Check if inside the rectangle\n if (this._rectangleOptions.filled) {\n return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;\n }\n\n // Check if near the border\n const nearLeft = Math.abs(point.x - left) <= Rectangle.HIT_THRESHOLD && point.y >= top && point.y <= bottom;\n const nearRight = Math.abs(point.x - right) <= Rectangle.HIT_THRESHOLD && point.y >= top && point.y <= bottom;\n const nearTop = Math.abs(point.y - top) <= Rectangle.HIT_THRESHOLD && point.x >= left && point.x <= right;\n const nearBottom = Math.abs(point.y - bottom) <= Rectangle.HIT_THRESHOLD && point.x >= left && point.x <= right;\n\n return nearLeft || nearRight || nearTop || nearBottom;\n }\n\n /**\n * Get price range of the rectangle\n */\n getPriceRange(): { min: number; max: number; range: number } {\n if (!this.isValid()) return { min: 0, max: 0, range: 0 };\n const min = Math.min(this._anchors[0].price, this._anchors[1].price);\n const max = Math.max(this._anchors[0].price, this._anchors[1].price);\n return { min, max, range: max - min };\n }\n\n clone(newId: string): IDrawing {\n return new Rectangle(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._rectangleOptions }\n );\n }\n\n static create(\n id: string,\n corner1: Anchor,\n corner2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<RectangleOptions>\n ): Rectangle {\n return new Rectangle(id, [corner1, corner2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { RotatedRectangle } from './rotated-rectangle';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class RotatedRectanglePaneView implements IPrimitivePaneView {\n private _renderer: RotatedRectanglePaneRenderer;\n\n constructor(drawing: RotatedRectangle) {\n this._renderer = new RotatedRectanglePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass RotatedRectanglePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: RotatedRectangle;\n\n constructor(drawing: RotatedRectangle) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const corners = this._drawing.getCorners(viewport);\n if (!corners || corners.length < 4) return;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (this._drawing.rotatedRectangleOptions.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(corners[0].x * pixelRatio, corners[0].y * pixelRatio);\n for (let i = 1; i < corners.length; i++) {\n ctx.lineTo(corners[i].x * pixelRatio, corners[i].y * pixelRatio);\n }\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw border\n ctx.beginPath();\n ctx.moveTo(corners[0].x * pixelRatio, corners[0].y * pixelRatio);\n for (let i = 1; i < corners.length; i++) {\n ctx.lineTo(corners[i].x * pixelRatio, corners[i].y * pixelRatio);\n }\n ctx.closePath();\n ctx.stroke();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { RotatedRectanglePaneView } from './rotated-rectangle-pane-view';\n\n/**\n * Rotated Rectangle options\n */\nexport interface RotatedRectangleOptions extends DrawingOptions {\n filled?: boolean;\n showDimensions?: boolean;\n}\n\n/**\n * RotatedRectangle - A rectangular shape that can be rotated to any angle.\n *\n * Features:\n * - Three anchor points: first two define one edge, third defines height\n * - Rotation determined by the angle of the first edge\n * - Optional fill\n * - Optional dimension labels\n */\nexport class RotatedRectangle extends Drawing {\n readonly type = 'rotated-rectangle';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _rotatedRectangleOptions: RotatedRectangleOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<RotatedRectangleOptions> = {}\n ) {\n const { filled, showDimensions, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._rotatedRectangleOptions = {\n ...this._options,\n filled: filled ?? true,\n showDimensions: showDimensions ?? false,\n };\n }\n\n get rotatedRectangleOptions(): RotatedRectangleOptions {\n return this._rotatedRectangleOptions;\n }\n\n setRotatedRectangleOptions(options: Partial<RotatedRectangleOptions>): void {\n this._rotatedRectangleOptions = { ...this._rotatedRectangleOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= RotatedRectangle.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new RotatedRectanglePaneView(this)];\n }\n\n /**\n * Get the four corners of the rotated rectangle\n */\n getCorners(viewport: Viewport): Point[] | null {\n if (!this.isValid()) return null;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return null;\n\n // First two points define one edge\n // Calculate perpendicular direction\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const edgeLength = Math.sqrt(dx * dx + dy * dy);\n\n if (edgeLength === 0) return null;\n\n // Perpendicular unit vector\n const perpX = -dy / edgeLength;\n const perpY = dx / edgeLength;\n\n // Project p3 onto the perpendicular to get height\n const v3x = p3.x - p1.x;\n const v3y = p3.y - p1.y;\n const height = v3x * perpX + v3y * perpY;\n\n // Four corners\n const corners: Point[] = [\n p1,\n p2,\n { x: p2.x + perpX * height, y: p2.y + perpY * height },\n { x: p1.x + perpX * height, y: p1.y + perpY * height },\n ];\n\n return corners;\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const corners = this.getCorners(viewport);\n if (!corners) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points: corners,\n closed: true,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const corners = this.getCorners(viewport);\n if (!corners) return false;\n\n // Check if inside the polygon using ray casting\n if (this._rotatedRectangleOptions.filled) {\n return this.pointInPolygon(point, corners);\n }\n\n // Check if near any edge\n for (let i = 0; i < corners.length; i++) {\n const next = (i + 1) % corners.length;\n const dist = distanceToLineSegment(point, corners[i], corners[next]);\n if (dist <= RotatedRectangle.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n private pointInPolygon(point: Point, polygon: Point[]): boolean {\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x, yi = polygon[i].y;\n const xj = polygon[j].x, yj = polygon[j].y;\n\n if (((yi > point.y) !== (yj > point.y)) &&\n (point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi)) {\n inside = !inside;\n }\n }\n return inside;\n }\n\n clone(newId: string): IDrawing {\n return new RotatedRectangle(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._rotatedRectangleOptions }\n );\n }\n\n static create(\n id: string,\n p1: Anchor,\n p2: Anchor,\n p3: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<RotatedRectangleOptions>\n ): RotatedRectangle {\n return new RotatedRectangle(id, [p1, p2, p3], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Circle } from './circle';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { applyStyle, drawCircle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class CirclePaneView implements IPrimitivePaneView {\n private _renderer: CirclePaneRenderer;\n\n constructor(drawing: Circle) {\n this._renderer = new CirclePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass CirclePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Circle;\n\n constructor(drawing: Circle) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const center = this._drawing.anchorToPixel(anchors[0], viewport);\n const edge = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!center || !edge) return;\n\n const radius = distanceBetweenPoints(center, edge);\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (this._drawing.circleOptions.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n }\n\n drawCircle(ctx, center, radius, this._drawing.circleOptions.filled ?? false, pixelRatio);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, ArcGeometry } from '../../core/geometry';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { CirclePaneView } from './circle-pane-view';\n\n/**\n * Circle options\n */\nexport interface CircleOptions extends DrawingOptions {\n filled?: boolean;\n}\n\n/**\n * Circle - A circular shape defined by center and edge point.\n *\n * Features:\n * - Two anchor points (center and edge)\n * - Radius determined by distance between points\n * - Optional fill\n */\nexport class Circle extends Drawing {\n readonly type = 'circle';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _circleOptions: CircleOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<CircleOptions> = {}\n ) {\n const { filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._circleOptions = {\n ...this._options,\n filled: filled ?? true,\n };\n }\n\n get circleOptions(): CircleOptions {\n return this._circleOptions;\n }\n\n setCircleOptions(options: Partial<CircleOptions>): void {\n this._circleOptions = { ...this._circleOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Circle.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new CirclePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n const edge = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!center || !edge) return [];\n\n const radius = distanceBetweenPoints(center, edge);\n\n const arcGeometry: ArcGeometry = {\n type: 'arc',\n center,\n radius,\n startAngle: 0,\n endAngle: Math.PI * 2,\n };\n\n return [arcGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n const edge = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!center || !edge) return false;\n\n const radius = distanceBetweenPoints(center, edge);\n const distToCenter = distanceBetweenPoints(point, center);\n\n if (this._circleOptions.filled) {\n return distToCenter <= radius;\n }\n\n // Check if near the circumference\n return Math.abs(distToCenter - radius) <= Circle.HIT_THRESHOLD;\n }\n\n /**\n * Get the radius in pixels (requires viewport)\n */\n getRadius(viewport: Viewport): number {\n if (!this.isValid()) return 0;\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n const edge = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!center || !edge) return 0;\n\n return distanceBetweenPoints(center, edge);\n }\n\n clone(newId: string): IDrawing {\n return new Circle(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._circleOptions }\n );\n }\n\n static create(\n id: string,\n center: Anchor,\n edge: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<CircleOptions>\n ): Circle {\n return new Circle(id, [center, edge], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Triangle } from './triangle';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class TrianglePaneView implements IPrimitivePaneView {\n private _renderer: TrianglePaneRenderer;\n\n constructor(drawing: Triangle) {\n this._renderer = new TrianglePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass TrianglePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Triangle;\n\n constructor(drawing: Triangle) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const points: Point[] = [];\n for (const anchor of anchors) {\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n points.push(p);\n }\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw the triangle\n ctx.beginPath();\n ctx.moveTo(points[0].x * pixelRatio, points[0].y * pixelRatio);\n ctx.lineTo(points[1].x * pixelRatio, points[1].y * pixelRatio);\n ctx.lineTo(points[2].x * pixelRatio, points[2].y * pixelRatio);\n ctx.closePath();\n\n // Fill if enabled\n if (this._drawing.triangleOptions.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.fill();\n }\n\n ctx.stroke();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { TrianglePaneView } from './triangle-pane-view';\n\n/**\n * Triangle options\n */\nexport interface TriangleOptions extends DrawingOptions {\n filled?: boolean;\n}\n\n/**\n * Triangle - A triangular shape defined by three points.\n *\n * Features:\n * - Three anchor points (vertices)\n * - Optional fill\n */\nexport class Triangle extends Drawing {\n readonly type = 'triangle';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _triangleOptions: TriangleOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<TriangleOptions> = {}\n ) {\n const { filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._triangleOptions = {\n ...this._options,\n filled: filled ?? true,\n };\n }\n\n get triangleOptions(): TriangleOptions {\n return this._triangleOptions;\n }\n\n setTriangleOptions(options: Partial<TriangleOptions>): void {\n this._triangleOptions = { ...this._triangleOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Triangle.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new TrianglePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (!p) return [];\n points.push(p);\n }\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points,\n closed: true,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (!p) return false;\n points.push(p);\n }\n\n if (this._triangleOptions.filled) {\n return this.isPointInTriangle(point, points[0], points[1], points[2]);\n }\n\n // Check if near any edge\n for (let i = 0; i < 3; i++) {\n const next = (i + 1) % 3;\n const dist = distanceToLineSegment(point, points[i], points[next]);\n if (dist <= Triangle.HIT_THRESHOLD) return true;\n }\n\n return false;\n }\n\n private isPointInTriangle(p: Point, a: Point, b: Point, c: Point): boolean {\n const sign = (p1: Point, p2: Point, p3: Point) =>\n (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);\n\n const d1 = sign(p, a, b);\n const d2 = sign(p, b, c);\n const d3 = sign(p, c, a);\n\n const hasNeg = d1 < 0 || d2 < 0 || d3 < 0;\n const hasPos = d1 > 0 || d2 > 0 || d3 > 0;\n\n return !(hasNeg && hasPos);\n }\n\n clone(newId: string): IDrawing {\n return new Triangle(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._triangleOptions }\n );\n }\n\n static create(\n id: string,\n p1: Anchor,\n p2: Anchor,\n p3: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<TriangleOptions>\n ): Triangle {\n return new Triangle(id, [p1, p2, p3], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { PriceRange } from './price-range';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\nexport class PriceRangePaneView implements IPrimitivePaneView {\n private _renderer: PriceRangePaneRenderer;\n\n constructor(drawing: PriceRange) {\n this._renderer = new PriceRangePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'bottom'; // Price range should be behind other drawings\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PriceRangePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: PriceRange;\n\n constructor(drawing: PriceRange) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const y1 = viewport.priceScale.priceToCoordinate(anchors[0].price);\n const y2 = viewport.priceScale.priceToCoordinate(anchors[1].price);\n\n if (y1 === null || y2 === null) return;\n\n const top = Math.min(y1, y2);\n const bottom = Math.max(y1, y2);\n const height = bottom - top;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw filled rectangle\n if (this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.fillRect(0, top * pixelRatio, viewport.width * pixelRatio, height * pixelRatio);\n }\n\n // Draw top and bottom borders\n drawLine(ctx, { x: 0, y: top }, { x: viewport.width, y: top }, pixelRatio);\n drawLine(ctx, { x: 0, y: bottom }, { x: viewport.width, y: bottom }, pixelRatio);\n\n // Draw labels\n const options = this._drawing.priceRangeOptions;\n const rangeInfo = this._drawing.getRangeInfo();\n const centerY = (top + bottom) / 2;\n\n const labelParts: string[] = [];\n\n if (options.showRange) {\n labelParts.push(`$${rangeInfo.range.toFixed(2)}`);\n }\n\n if (options.showPercentage) {\n const sign = rangeInfo.percentage >= 0 ? '+' : '';\n labelParts.push(`${sign}${rangeInfo.percentage.toFixed(2)}%`);\n }\n\n if (labelParts.length > 0) {\n drawLabel(\n ctx,\n labelParts.join(' | '),\n { x: viewport.width / 2, y: centerY },\n {\n font: this._drawing.style.labelFont || '12px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'CC',\n padding: 6,\n borderRadius: 4,\n },\n pixelRatio\n );\n }\n\n // Draw price labels on the sides\n if (options.showPrices) {\n drawLabel(\n ctx,\n rangeInfo.max.toFixed(2),\n { x: viewport.width - 10, y: top },\n {\n font: '11px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'AA',\n padding: 3,\n borderRadius: 2,\n },\n pixelRatio\n );\n\n drawLabel(\n ctx,\n rangeInfo.min.toFixed(2),\n { x: viewport.width - 10, y: bottom },\n {\n font: '11px sans-serif',\n textColor: '#ffffff',\n backgroundColor: this._drawing.style.lineColor + 'AA',\n padding: 3,\n borderRadius: 2,\n },\n pixelRatio\n );\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, RectangleGeometry } from '../../core/geometry';\nimport { PriceRangePaneView } from './price-range-pane-view';\n\n/**\n * PriceRange options\n */\nexport interface PriceRangeOptions extends DrawingOptions {\n showPrices?: boolean;\n showRange?: boolean;\n showPercentage?: boolean;\n}\n\n/**\n * PriceRange - A highlighted price zone between two price levels.\n *\n * Features:\n * - Two anchor points (top and bottom of range)\n * - Shows price range and percentage change\n * - Spans full viewport width\n */\nexport class PriceRange extends Drawing {\n readonly type = 'price-range';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _priceRangeOptions: PriceRangeOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PriceRangeOptions> = {}\n ) {\n const { showPrices, showRange, showPercentage, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._priceRangeOptions = {\n ...this._options,\n showPrices: showPrices ?? true,\n showRange: showRange ?? true,\n showPercentage: showPercentage ?? true,\n };\n }\n\n get priceRangeOptions(): PriceRangeOptions {\n return this._priceRangeOptions;\n }\n\n setPriceRangeOptions(options: Partial<PriceRangeOptions>): void {\n this._priceRangeOptions = { ...this._priceRangeOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= PriceRange.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PriceRangePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const y1 = viewport.priceScale.priceToCoordinate(this._anchors[0].price);\n const y2 = viewport.priceScale.priceToCoordinate(this._anchors[1].price);\n\n if (y1 === null || y2 === null) return [];\n\n const top = Math.min(y1, y2);\n const height = Math.abs(y2 - y1);\n\n const geometries: Geometry[] = [];\n\n // Rectangle spanning viewport width\n const rectGeometry: RectangleGeometry = {\n type: 'rectangle',\n topLeft: { x: 0, y: top },\n width: viewport.width,\n height,\n };\n geometries.push(rectGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const y1 = viewport.priceScale.priceToCoordinate(this._anchors[0].price);\n const y2 = viewport.priceScale.priceToCoordinate(this._anchors[1].price);\n\n if (y1 === null || y2 === null) return false;\n\n const top = Math.min(y1, y2);\n const bottom = Math.max(y1, y2);\n\n return point.y >= top && point.y <= bottom;\n }\n\n /**\n * Get the price range information\n */\n getRangeInfo(): { min: number; max: number; range: number; percentage: number } {\n if (!this.isValid()) return { min: 0, max: 0, range: 0, percentage: 0 };\n\n const min = Math.min(this._anchors[0].price, this._anchors[1].price);\n const max = Math.max(this._anchors[0].price, this._anchors[1].price);\n const range = max - min;\n const percentage = min !== 0 ? (range / min) * 100 : 0;\n\n return { min, max, range, percentage };\n }\n\n clone(newId: string): IDrawing {\n return new PriceRange(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._priceRangeOptions }\n );\n }\n\n static create(\n id: string,\n price1: number,\n price2: number,\n time: number | string,\n style?: Partial<DrawingStyle>,\n options?: Partial<PriceRangeOptions>\n ): PriceRange {\n return new PriceRange(\n id,\n [\n { time: time as any, price: price1 },\n { time: time as any, price: price2 },\n ],\n style,\n options\n );\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Ellipse } from './ellipse';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class EllipsePaneView implements IPrimitivePaneView {\n private _renderer: EllipsePaneRenderer;\n\n constructor(drawing: Ellipse) {\n this._renderer = new EllipsePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass EllipsePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Ellipse;\n\n constructor(drawing: Ellipse) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const params = this._drawing.getEllipseParams(viewport);\n if (!params) return;\n\n const { center, radiusX, radiusY } = params;\n const options = this._drawing.ellipseOptions;\n const style = this._drawing.style;\n\n ctx.save();\n\n // Draw fill if enabled\n if (options.filled && style.fillColor) {\n ctx.fillStyle = style.fillColor;\n ctx.globalAlpha = style.fillOpacity ?? 0.1;\n ctx.beginPath();\n ctx.ellipse(\n center.x * pixelRatio,\n center.y * pixelRatio,\n radiusX * pixelRatio,\n radiusY * pixelRatio,\n 0,\n 0,\n Math.PI * 2\n );\n ctx.fill();\n ctx.globalAlpha = 1;\n }\n\n // Draw stroke\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n if (style.lineDash && style.lineDash.length > 0) {\n ctx.setLineDash(style.lineDash.map(d => d * pixelRatio));\n }\n\n ctx.beginPath();\n ctx.ellipse(\n center.x * pixelRatio,\n center.y * pixelRatio,\n radiusX * pixelRatio,\n radiusY * pixelRatio,\n 0,\n 0,\n Math.PI * 2\n );\n ctx.stroke();\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { EllipsePaneView } from './ellipse-pane-view';\n\n/**\n * Ellipse options\n */\nexport interface EllipseOptions extends DrawingOptions {\n filled?: boolean;\n}\n\n/**\n * Ellipse - An elliptical shape defined by two corner points of bounding box.\n *\n * Features:\n * - Two anchor points (opposite corners of bounding rectangle)\n * - Optional fill\n * - Axis-aligned ellipse\n */\nexport class Ellipse extends Drawing {\n readonly type = 'ellipse';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _ellipseOptions: EllipseOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<EllipseOptions> = {}\n ) {\n const { filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._ellipseOptions = {\n ...this._options,\n filled: filled ?? true,\n };\n }\n\n get ellipseOptions(): EllipseOptions {\n return this._ellipseOptions;\n }\n\n setEllipseOptions(options: Partial<EllipseOptions>): void {\n this._ellipseOptions = { ...this._ellipseOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Ellipse.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new EllipsePaneView(this)];\n }\n\n /**\n * Get ellipse parameters\n */\n getEllipseParams(viewport: Viewport): {\n center: Point;\n radiusX: number;\n radiusY: number;\n } | null {\n if (!this.isValid()) return null;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return null;\n\n const center: Point = {\n x: (p1.x + p2.x) / 2,\n y: (p1.y + p2.y) / 2,\n };\n\n const radiusX = Math.abs(p2.x - p1.x) / 2;\n const radiusY = Math.abs(p2.y - p1.y) / 2;\n\n return { center, radiusX, radiusY };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const params = this.getEllipseParams(viewport);\n if (!params) return [];\n\n // Return an arc geometry representing full ellipse\n return [{\n type: 'arc',\n center: params.center,\n radius: Math.max(params.radiusX, params.radiusY),\n startAngle: 0,\n endAngle: Math.PI * 2,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const params = this.getEllipseParams(viewport);\n if (!params) return false;\n\n const { center, radiusX, radiusY } = params;\n\n if (radiusX === 0 || radiusY === 0) return false;\n\n // Check if point is inside or near the ellipse\n // Ellipse equation: (x-cx)^2/rx^2 + (y-cy)^2/ry^2 = 1\n const dx = point.x - center.x;\n const dy = point.y - center.y;\n const normalizedDist = (dx * dx) / (radiusX * radiusX) + (dy * dy) / (radiusY * radiusY);\n\n if (this._ellipseOptions.filled) {\n return normalizedDist <= 1;\n }\n\n // Check if near the border\n const innerThreshold = (radiusX - Ellipse.HIT_THRESHOLD) / radiusX;\n const outerThreshold = (radiusX + Ellipse.HIT_THRESHOLD) / radiusX;\n\n return normalizedDist >= innerThreshold * innerThreshold && normalizedDist <= outerThreshold * outerThreshold;\n }\n\n clone(newId: string): IDrawing {\n return new Ellipse(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._ellipseOptions }\n );\n }\n\n static create(\n id: string,\n corner1: Anchor,\n corner2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<EllipseOptions>\n ): Ellipse {\n return new Ellipse(id, [corner1, corner2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Arc } from './arc';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class ArcPaneView implements IPrimitivePaneView {\n private _renderer: ArcPaneRenderer;\n\n constructor(drawing: Arc) {\n this._renderer = new ArcPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ArcPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Arc;\n\n constructor(drawing: Arc) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const params = this._drawing.getArcParams(viewport);\n if (!params) return;\n\n const { center, radius, startAngle, endAngle } = params;\n const options = this._drawing.arcOptions;\n const style = this._drawing.style;\n\n ctx.save();\n\n // Draw fill if enabled (pie slice)\n if (options.filled && style.fillColor) {\n ctx.fillStyle = style.fillColor;\n ctx.globalAlpha = style.fillOpacity ?? 0.1;\n ctx.beginPath();\n ctx.moveTo(center.x * pixelRatio, center.y * pixelRatio);\n ctx.arc(\n center.x * pixelRatio,\n center.y * pixelRatio,\n radius * pixelRatio,\n startAngle,\n endAngle\n );\n ctx.closePath();\n ctx.fill();\n ctx.globalAlpha = 1;\n }\n\n // Draw arc stroke\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n if (style.lineDash && style.lineDash.length > 0) {\n ctx.setLineDash(style.lineDash.map(d => d * pixelRatio));\n }\n\n ctx.beginPath();\n ctx.arc(\n center.x * pixelRatio,\n center.y * pixelRatio,\n radius * pixelRatio,\n startAngle,\n endAngle\n );\n ctx.stroke();\n\n // Draw radial lines from center to endpoints if filled\n if (options.filled) {\n ctx.beginPath();\n ctx.moveTo(center.x * pixelRatio, center.y * pixelRatio);\n ctx.lineTo(\n (center.x + radius * Math.cos(startAngle)) * pixelRatio,\n (center.y + radius * Math.sin(startAngle)) * pixelRatio\n );\n ctx.moveTo(center.x * pixelRatio, center.y * pixelRatio);\n ctx.lineTo(\n (center.x + radius * Math.cos(endAngle)) * pixelRatio,\n (center.y + radius * Math.sin(endAngle)) * pixelRatio\n );\n ctx.stroke();\n }\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { ArcPaneView } from './arc-pane-view';\n\n/**\n * Arc options\n */\nexport interface ArcOptions extends DrawingOptions {\n filled?: boolean;\n}\n\n/**\n * Arc - A circular arc defined by three points.\n *\n * Features:\n * - Three anchor points: center, start point (defines radius and start angle), end point (defines end angle)\n * - Optional fill (pie slice)\n * - Draws the shorter arc between start and end angles\n */\nexport class Arc extends Drawing {\n readonly type = 'arc';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _arcOptions: ArcOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ArcOptions> = {}\n ) {\n const { filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._arcOptions = {\n ...this._options,\n filled: filled ?? false,\n };\n }\n\n get arcOptions(): ArcOptions {\n return this._arcOptions;\n }\n\n setArcOptions(options: Partial<ArcOptions>): void {\n this._arcOptions = { ...this._arcOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Arc.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ArcPaneView(this)];\n }\n\n /**\n * Get arc parameters from the three anchor points\n */\n getArcParams(viewport: Viewport): {\n center: Point;\n radius: number;\n startAngle: number;\n endAngle: number;\n } | null {\n if (!this.isValid()) return null;\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n const startPoint = this.anchorToPixel(this._anchors[1], viewport);\n const endPoint = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!center || !startPoint || !endPoint) return null;\n\n // Calculate radius from center to start point\n const dx = startPoint.x - center.x;\n const dy = startPoint.y - center.y;\n const radius = Math.sqrt(dx * dx + dy * dy);\n\n if (radius === 0) return null;\n\n // Calculate angles\n const startAngle = Math.atan2(startPoint.y - center.y, startPoint.x - center.x);\n const endAngle = Math.atan2(endPoint.y - center.y, endPoint.x - center.x);\n\n return { center, radius, startAngle, endAngle };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const params = this.getArcParams(viewport);\n if (!params) return [];\n\n return [{\n type: 'arc',\n center: params.center,\n radius: params.radius,\n startAngle: params.startAngle,\n endAngle: params.endAngle,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const params = this.getArcParams(viewport);\n if (!params) return false;\n\n const { center, radius, startAngle, endAngle } = params;\n\n // Check distance from center\n const dx = point.x - center.x;\n const dy = point.y - center.y;\n const dist = Math.sqrt(dx * dx + dy * dy);\n\n // Check if within radius range\n const innerRadius = radius - Arc.HIT_THRESHOLD;\n const outerRadius = radius + Arc.HIT_THRESHOLD;\n\n if (this._arcOptions.filled) {\n // For filled arc (pie slice), check if within the sector\n if (dist > radius + Arc.HIT_THRESHOLD) return false;\n } else {\n // For unfilled arc, check if near the arc line\n if (dist < innerRadius || dist > outerRadius) return false;\n }\n\n // Check if angle is within arc range\n let angle = Math.atan2(dy, dx);\n\n // Normalize angles to [0, 2π]\n let normStart = startAngle;\n let normEnd = endAngle;\n let normAngle = angle;\n\n while (normStart < 0) normStart += Math.PI * 2;\n while (normEnd < 0) normEnd += Math.PI * 2;\n while (normAngle < 0) normAngle += Math.PI * 2;\n\n // Check if angle is between start and end (considering wrap-around)\n if (normStart <= normEnd) {\n return normAngle >= normStart && normAngle <= normEnd;\n } else {\n return normAngle >= normStart || normAngle <= normEnd;\n }\n }\n\n clone(newId: string): IDrawing {\n return new Arc(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._arcOptions }\n );\n }\n\n static create(\n id: string,\n center: Anchor,\n startPoint: Anchor,\n endPoint: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ArcOptions>\n ): Arc {\n return new Arc(id, [center, startPoint, endPoint], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Path } from './path';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class PathPaneView implements IPrimitivePaneView {\n private _renderer: PathPaneRenderer;\n\n constructor(drawing: Path) {\n this._renderer = new PathPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PathPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Path;\n\n constructor(drawing: Path) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const points: Point[] = [];\n for (const anchor of anchors) {\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return;\n\n const options = this._drawing.pathOptions;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled and closed\n if (options.filled && options.closed && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(points[0].x * pixelRatio, points[0].y * pixelRatio);\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x * pixelRatio, points[i].y * pixelRatio);\n }\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw the path\n ctx.beginPath();\n ctx.moveTo(points[0].x * pixelRatio, points[0].y * pixelRatio);\n\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x * pixelRatio, points[i].y * pixelRatio);\n }\n\n if (options.closed) {\n ctx.closePath();\n }\n\n ctx.stroke();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = points.map((p, i) => ({\n index: i,\n x: p.x,\n y: p.y,\n radius: 6,\n }));\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { PathPaneView } from './path-pane-view';\n\n/**\n * Path options\n */\nexport interface PathOptions extends DrawingOptions {\n closed?: boolean;\n filled?: boolean;\n}\n\n/**\n * Path - Freeform path drawing with straight line segments.\n *\n * Features:\n * - Multiple anchor points connected by straight lines\n * - Optional closed path\n * - Optional fill (when closed)\n */\nexport class Path extends Drawing {\n readonly type = 'path';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _pathOptions: PathOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PathOptions> = {}\n ) {\n const { closed, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._pathOptions = {\n ...this._options,\n closed: closed ?? false,\n filled: filled ?? false,\n };\n }\n\n get pathOptions(): PathOptions {\n return this._pathOptions;\n }\n\n setPathOptions(options: Partial<PathOptions>): void {\n this._pathOptions = { ...this._pathOptions, ...options };\n this.requestUpdate();\n }\n\n /**\n * Add a point to the path\n */\n addPoint(anchor: Anchor): void {\n this._anchors.push(anchor);\n this.requestUpdate();\n }\n\n /**\n * Close or open the path\n */\n setClosed(closed: boolean): void {\n this._pathOptions.closed = closed;\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Path.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PathPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points,\n closed: this._pathOptions.closed ?? false,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return false;\n\n // Check if filled and closed - test point in polygon\n if (this._pathOptions.filled && this._pathOptions.closed) {\n if (this.pointInPolygon(point, points)) {\n return true;\n }\n }\n\n // Check if near any segment\n const segmentCount = this._pathOptions.closed ? points.length : points.length - 1;\n for (let i = 0; i < segmentCount; i++) {\n const next = (i + 1) % points.length;\n const dist = distanceToLineSegment(point, points[i], points[next]);\n if (dist <= Path.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n private pointInPolygon(point: Point, polygon: Point[]): boolean {\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x, yi = polygon[i].y;\n const xj = polygon[j].x, yj = polygon[j].y;\n\n if (((yi > point.y) !== (yj > point.y)) &&\n (point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi)) {\n inside = !inside;\n }\n }\n return inside;\n }\n\n clone(newId: string): IDrawing {\n return new Path(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._pathOptions }\n );\n }\n\n static create(\n id: string,\n points: Anchor[],\n style?: Partial<DrawingStyle>,\n options?: Partial<PathOptions>\n ): Path {\n return new Path(id, points, style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Polyline } from './polyline';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class PolylinePaneView implements IPrimitivePaneView {\n private _renderer: PolylinePaneRenderer;\n\n constructor(drawing: Polyline) {\n this._renderer = new PolylinePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PolylinePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Polyline;\n\n constructor(drawing: Polyline) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const points: Point[] = [];\n for (const anchor of anchors) {\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return;\n\n const options = this._drawing.polylineOptions;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw the polyline\n ctx.beginPath();\n ctx.moveTo(points[0].x * pixelRatio, points[0].y * pixelRatio);\n\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x * pixelRatio, points[i].y * pixelRatio);\n }\n\n ctx.stroke();\n\n // Draw vertex markers if enabled\n if (options.showVertices) {\n const vertexRadius = (options.vertexRadius ?? 4) * pixelRatio;\n ctx.fillStyle = this._drawing.style.lineColor || '#2962FF';\n\n for (const point of points) {\n ctx.beginPath();\n ctx.arc(\n point.x * pixelRatio,\n point.y * pixelRatio,\n vertexRadius,\n 0,\n Math.PI * 2\n );\n ctx.fill();\n }\n\n // Draw white center for visibility\n ctx.fillStyle = '#ffffff';\n const innerRadius = vertexRadius * 0.5;\n for (const point of points) {\n ctx.beginPath();\n ctx.arc(\n point.x * pixelRatio,\n point.y * pixelRatio,\n innerRadius,\n 0,\n Math.PI * 2\n );\n ctx.fill();\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = points.map((p, i) => ({\n index: i,\n x: p.x,\n y: p.y,\n radius: 6,\n }));\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, distanceBetweenPoints } from '../../core/geometry';\nimport { PolylinePaneView } from './polyline-pane-view';\n\n/**\n * Polyline options\n */\nexport interface PolylineOptions extends DrawingOptions {\n showVertices?: boolean;\n vertexRadius?: number;\n}\n\n/**\n * Polyline - Multi-point connected line with vertex markers.\n *\n * Features:\n * - Multiple anchor points connected by straight lines\n * - Optional vertex markers at each point\n * - Interactive point adding during creation\n */\nexport class Polyline extends Drawing {\n readonly type = 'polyline';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _polylineOptions: PolylineOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PolylineOptions> = {}\n ) {\n const { showVertices, vertexRadius, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._polylineOptions = {\n ...this._options,\n showVertices: showVertices ?? true,\n vertexRadius: vertexRadius ?? 4,\n };\n }\n\n get polylineOptions(): PolylineOptions {\n return this._polylineOptions;\n }\n\n setPolylineOptions(options: Partial<PolylineOptions>): void {\n this._polylineOptions = { ...this._polylineOptions, ...options };\n this.requestUpdate();\n }\n\n /**\n * Add a point to the polyline\n */\n addPoint(anchor: Anchor): void {\n this._anchors.push(anchor);\n this.requestUpdate();\n }\n\n /**\n * Insert a point at a specific index\n */\n insertPoint(index: number, anchor: Anchor): void {\n this._anchors.splice(index, 0, anchor);\n this.requestUpdate();\n }\n\n /**\n * Remove a point at a specific index\n */\n removePoint(index: number): void {\n if (this._anchors.length > 2) {\n this._anchors.splice(index, 1);\n this.requestUpdate();\n }\n }\n\n isValid(): boolean {\n return this._anchors.length >= Polyline.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PolylinePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points,\n closed: false,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return false;\n\n // Check if near any vertex\n const vertexRadius = this._polylineOptions.vertexRadius ?? 4;\n for (const p of points) {\n if (distanceBetweenPoints(point, p) <= vertexRadius + Polyline.HIT_THRESHOLD) {\n return true;\n }\n }\n\n // Check if near any segment\n for (let i = 0; i < points.length - 1; i++) {\n const dist = distanceToLineSegment(point, points[i], points[i + 1]);\n if (dist <= Polyline.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Get total length of the polyline\n */\n getTotalLength(viewport: Viewport): number {\n if (!this.isValid()) return 0;\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n let totalLength = 0;\n for (let i = 0; i < points.length - 1; i++) {\n totalLength += distanceBetweenPoints(points[i], points[i + 1]);\n }\n\n return totalLength;\n }\n\n clone(newId: string): IDrawing {\n return new Polyline(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._polylineOptions }\n );\n }\n\n static create(\n id: string,\n points: Anchor[],\n style?: Partial<DrawingStyle>,\n options?: Partial<PolylineOptions>\n ): Polyline {\n return new Polyline(id, points, style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Curve } from './curve';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class CurvePaneView implements IPrimitivePaneView {\n private _renderer: CurvePaneRenderer;\n\n constructor(drawing: Curve) {\n this._renderer = new CurvePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass CurvePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Curve;\n\n constructor(drawing: Curve) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const controlPts = this._drawing.getControlPointsPixels(viewport);\n if (!controlPts) return;\n\n const { start, control1, control2, end } = controlPts;\n const options = this._drawing.curveOptions;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw control lines if enabled (before the curve)\n if (options.showControlLines) {\n ctx.save();\n ctx.strokeStyle = this._drawing.style.lineColor || '#2962FF';\n ctx.globalAlpha = 0.3;\n ctx.setLineDash([4 * pixelRatio, 4 * pixelRatio]);\n ctx.lineWidth = 1 * pixelRatio;\n\n // Start to control1\n ctx.beginPath();\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n ctx.lineTo(control1.x * pixelRatio, control1.y * pixelRatio);\n ctx.stroke();\n\n // Control2 to end\n ctx.beginPath();\n ctx.moveTo(control2.x * pixelRatio, control2.y * pixelRatio);\n ctx.lineTo(end.x * pixelRatio, end.y * pixelRatio);\n ctx.stroke();\n\n ctx.restore();\n }\n\n // Draw the bezier curve\n applyStyle(ctx, this._drawing.style, pixelRatio);\n ctx.beginPath();\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n ctx.bezierCurveTo(\n control1.x * pixelRatio,\n control1.y * pixelRatio,\n control2.x * pixelRatio,\n control2.y * pixelRatio,\n end.x * pixelRatio,\n end.y * pixelRatio\n );\n ctx.stroke();\n\n // Draw control point markers if showing control lines\n if (options.showControlLines) {\n const markerRadius = 4 * pixelRatio;\n ctx.fillStyle = this._drawing.style.lineColor || '#2962FF';\n\n // Control point 1 (hollow)\n ctx.beginPath();\n ctx.arc(control1.x * pixelRatio, control1.y * pixelRatio, markerRadius, 0, Math.PI * 2);\n ctx.strokeStyle = this._drawing.style.lineColor || '#2962FF';\n ctx.lineWidth = 2 * pixelRatio;\n ctx.stroke();\n ctx.fillStyle = '#ffffff';\n ctx.fill();\n\n // Control point 2 (hollow)\n ctx.beginPath();\n ctx.arc(control2.x * pixelRatio, control2.y * pixelRatio, markerRadius, 0, Math.PI * 2);\n ctx.stroke();\n ctx.fill();\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = [\n { index: 0, x: start.x, y: start.y, radius: 6 },\n { index: 1, x: control1.x, y: control1.y, radius: 6 },\n { index: 2, x: control2.x, y: control2.y, radius: 6 },\n { index: 3, x: end.x, y: end.y, radius: 6 },\n ];\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { CurvePaneView } from './curve-pane-view';\n\n/**\n * Curve options\n */\nexport interface CurveOptions extends DrawingOptions {\n showControlLines?: boolean;\n resolution?: number;\n}\n\n/**\n * Curve - Cubic Bezier curve with two endpoints and two control points.\n *\n * Features:\n * - Four anchor points: start, control1, control2, end\n * - Smooth curve using cubic bezier interpolation\n * - Optional control line visualization\n */\nexport class Curve extends Drawing {\n readonly type = 'curve';\n\n protected static readonly REQUIRED_ANCHORS = 4;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _curveOptions: CurveOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<CurveOptions> = {}\n ) {\n const { showControlLines, resolution, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._curveOptions = {\n ...this._options,\n showControlLines: showControlLines ?? true,\n resolution: resolution ?? 50,\n };\n }\n\n get curveOptions(): CurveOptions {\n return this._curveOptions;\n }\n\n setCurveOptions(options: Partial<CurveOptions>): void {\n this._curveOptions = { ...this._curveOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Curve.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new CurvePaneView(this)];\n }\n\n /**\n * Get points along the bezier curve\n */\n getCurvePoints(viewport: Viewport): Point[] | null {\n if (!this.isValid()) return null;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n const p3 = this.anchorToPixel(this._anchors[3], viewport);\n\n if (!p0 || !p1 || !p2 || !p3) return null;\n\n const resolution = this._curveOptions.resolution ?? 50;\n const points: Point[] = [];\n\n for (let i = 0; i <= resolution; i++) {\n const t = i / resolution;\n points.push(this.cubicBezier(p0, p1, p2, p3, t));\n }\n\n return points;\n }\n\n /**\n * Get the control points for visualization\n */\n getControlPointsPixels(viewport: Viewport): { start: Point; control1: Point; control2: Point; end: Point } | null {\n if (!this.isValid()) return null;\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const control1 = this.anchorToPixel(this._anchors[1], viewport);\n const control2 = this.anchorToPixel(this._anchors[2], viewport);\n const end = this.anchorToPixel(this._anchors[3], viewport);\n\n if (!start || !control1 || !control2 || !end) return null;\n\n return { start, control1, control2, end };\n }\n\n private cubicBezier(p0: Point, p1: Point, p2: Point, p3: Point, t: number): Point {\n const t2 = t * t;\n const t3 = t2 * t;\n const mt = 1 - t;\n const mt2 = mt * mt;\n const mt3 = mt2 * mt;\n\n return {\n x: mt3 * p0.x + 3 * mt2 * t * p1.x + 3 * mt * t2 * p2.x + t3 * p3.x,\n y: mt3 * p0.y + 3 * mt2 * t * p1.y + 3 * mt * t2 * p2.y + t3 * p3.y,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const curvePoints = this.getCurvePoints(viewport);\n if (!curvePoints || curvePoints.length < 2) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points: curvePoints,\n closed: false,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const curvePoints = this.getCurvePoints(viewport);\n if (!curvePoints || curvePoints.length < 2) return false;\n\n // Check distance to curve segments\n for (let i = 0; i < curvePoints.length - 1; i++) {\n const p1 = curvePoints[i];\n const p2 = curvePoints[i + 1];\n const dist = this.distanceToSegment(point, p1, p2);\n if (dist <= Curve.HIT_THRESHOLD) {\n return true;\n }\n }\n\n // Check control points\n const controlPts = this.getControlPointsPixels(viewport);\n if (controlPts) {\n if (distanceBetweenPoints(point, controlPts.start) <= Curve.HIT_THRESHOLD * 2) return true;\n if (distanceBetweenPoints(point, controlPts.control1) <= Curve.HIT_THRESHOLD * 2) return true;\n if (distanceBetweenPoints(point, controlPts.control2) <= Curve.HIT_THRESHOLD * 2) return true;\n if (distanceBetweenPoints(point, controlPts.end) <= Curve.HIT_THRESHOLD * 2) return true;\n }\n\n return false;\n }\n\n private distanceToSegment(point: Point, p1: Point, p2: Point): number {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const lengthSq = dx * dx + dy * dy;\n\n if (lengthSq === 0) {\n return distanceBetweenPoints(point, p1);\n }\n\n let t = ((point.x - p1.x) * dx + (point.y - p1.y) * dy) / lengthSq;\n t = Math.max(0, Math.min(1, t));\n\n const projection: Point = {\n x: p1.x + t * dx,\n y: p1.y + t * dy,\n };\n\n return distanceBetweenPoints(point, projection);\n }\n\n clone(newId: string): IDrawing {\n return new Curve(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._curveOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n control1: Anchor,\n control2: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<CurveOptions>\n ): Curve {\n return new Curve(id, [start, control1, control2, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { DoubleCurve } from './double-curve';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class DoubleCurvePaneView implements IPrimitivePaneView {\n private _renderer: DoubleCurvePaneRenderer;\n\n constructor(drawing: DoubleCurve) {\n this._renderer = new DoubleCurvePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass DoubleCurvePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: DoubleCurve;\n\n constructor(drawing: DoubleCurve) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const mainPts = this._drawing.getMainPoints(viewport);\n const ctrlPts = this._drawing.getBezierControlPoints(viewport);\n if (!mainPts || !ctrlPts) return;\n\n const { start, middle, end } = mainPts;\n const { cp1, cp2, cp3, cp4 } = ctrlPts;\n const options = this._drawing.doubleCurveOptions;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw control lines if enabled\n if (options.showControlPoints) {\n ctx.save();\n ctx.strokeStyle = this._drawing.style.lineColor || '#2962FF';\n ctx.globalAlpha = 0.3;\n ctx.setLineDash([4 * pixelRatio, 4 * pixelRatio]);\n ctx.lineWidth = 1 * pixelRatio;\n\n // First curve control lines\n ctx.beginPath();\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n ctx.lineTo(cp1.x * pixelRatio, cp1.y * pixelRatio);\n ctx.stroke();\n\n ctx.beginPath();\n ctx.moveTo(cp2.x * pixelRatio, cp2.y * pixelRatio);\n ctx.lineTo(middle.x * pixelRatio, middle.y * pixelRatio);\n ctx.stroke();\n\n // Second curve control lines\n ctx.beginPath();\n ctx.moveTo(middle.x * pixelRatio, middle.y * pixelRatio);\n ctx.lineTo(cp3.x * pixelRatio, cp3.y * pixelRatio);\n ctx.stroke();\n\n ctx.beginPath();\n ctx.moveTo(cp4.x * pixelRatio, cp4.y * pixelRatio);\n ctx.lineTo(end.x * pixelRatio, end.y * pixelRatio);\n ctx.stroke();\n\n ctx.restore();\n }\n\n // Draw the S-curve using two bezier curves\n applyStyle(ctx, this._drawing.style, pixelRatio);\n ctx.beginPath();\n ctx.moveTo(start.x * pixelRatio, start.y * pixelRatio);\n\n // First curve: start to middle\n ctx.bezierCurveTo(\n cp1.x * pixelRatio,\n cp1.y * pixelRatio,\n cp2.x * pixelRatio,\n cp2.y * pixelRatio,\n middle.x * pixelRatio,\n middle.y * pixelRatio\n );\n\n // Second curve: middle to end\n ctx.bezierCurveTo(\n cp3.x * pixelRatio,\n cp3.y * pixelRatio,\n cp4.x * pixelRatio,\n cp4.y * pixelRatio,\n end.x * pixelRatio,\n end.y * pixelRatio\n );\n\n ctx.stroke();\n\n // Draw control point markers if enabled\n if (options.showControlPoints) {\n const markerRadius = 3 * pixelRatio;\n ctx.fillStyle = this._drawing.style.lineColor || '#2962FF';\n ctx.globalAlpha = 0.5;\n\n for (const pt of [cp1, cp2, cp3, cp4]) {\n ctx.beginPath();\n ctx.arc(pt.x * pixelRatio, pt.y * pixelRatio, markerRadius, 0, Math.PI * 2);\n ctx.fill();\n }\n ctx.globalAlpha = 1;\n }\n\n // Draw anchor point markers\n const markerRadius = 4 * pixelRatio;\n ctx.fillStyle = this._drawing.style.lineColor || '#2962FF';\n\n for (const pt of [start, middle, end]) {\n ctx.beginPath();\n ctx.arc(pt.x * pixelRatio, pt.y * pixelRatio, markerRadius, 0, Math.PI * 2);\n ctx.fill();\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = [\n { index: 0, x: start.x, y: start.y, radius: 6 },\n { index: 1, x: middle.x, y: middle.y, radius: 6 },\n { index: 2, x: end.x, y: end.y, radius: 6 },\n ];\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { DoubleCurvePaneView } from './double-curve-pane-view';\n\n/**\n * Double Curve options\n */\nexport interface DoubleCurveOptions extends DrawingOptions {\n showControlPoints?: boolean;\n curvature?: number;\n resolution?: number;\n}\n\n/**\n * DoubleCurve - S-curve with two control points creating an S-shape.\n *\n * Features:\n * - Three anchor points: start, middle (inflection), end\n * - Automatic control point calculation for smooth S-curve\n * - Adjustable curvature\n */\nexport class DoubleCurve extends Drawing {\n readonly type = 'double-curve';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _doubleCurveOptions: DoubleCurveOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<DoubleCurveOptions> = {}\n ) {\n const { showControlPoints, curvature, resolution, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._doubleCurveOptions = {\n ...this._options,\n showControlPoints: showControlPoints ?? false,\n curvature: curvature ?? 0.5,\n resolution: resolution ?? 50,\n };\n }\n\n get doubleCurveOptions(): DoubleCurveOptions {\n return this._doubleCurveOptions;\n }\n\n setDoubleCurveOptions(options: Partial<DoubleCurveOptions>): void {\n this._doubleCurveOptions = { ...this._doubleCurveOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= DoubleCurve.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new DoubleCurvePaneView(this)];\n }\n\n /**\n * Get the three main points\n */\n getMainPoints(viewport: Viewport): { start: Point; middle: Point; end: Point } | null {\n if (!this.isValid()) return null;\n\n const start = this.anchorToPixel(this._anchors[0], viewport);\n const middle = this.anchorToPixel(this._anchors[1], viewport);\n const end = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!start || !middle || !end) return null;\n\n return { start, middle, end };\n }\n\n /**\n * Calculate bezier control points for the S-curve\n */\n getBezierControlPoints(viewport: Viewport): {\n cp1: Point;\n cp2: Point;\n cp3: Point;\n cp4: Point;\n } | null {\n const mainPts = this.getMainPoints(viewport);\n if (!mainPts) return null;\n\n const { start, middle, end } = mainPts;\n const curvature = this._doubleCurveOptions.curvature ?? 0.5;\n\n // Calculate direction vectors\n const dx1 = middle.x - start.x;\n const dx2 = end.x - middle.x;\n\n // Control points for first curve (start to middle)\n const cp1: Point = {\n x: start.x + dx1 * curvature,\n y: start.y,\n };\n const cp2: Point = {\n x: middle.x - dx1 * curvature,\n y: middle.y,\n };\n\n // Control points for second curve (middle to end)\n const cp3: Point = {\n x: middle.x + dx2 * curvature,\n y: middle.y,\n };\n const cp4: Point = {\n x: end.x - dx2 * curvature,\n y: end.y,\n };\n\n return { cp1, cp2, cp3, cp4 };\n }\n\n /**\n * Get points along the S-curve\n */\n getCurvePoints(viewport: Viewport): Point[] | null {\n const mainPts = this.getMainPoints(viewport);\n const ctrlPts = this.getBezierControlPoints(viewport);\n if (!mainPts || !ctrlPts) return null;\n\n const { start, middle, end } = mainPts;\n const { cp1, cp2, cp3, cp4 } = ctrlPts;\n\n const resolution = this._doubleCurveOptions.resolution ?? 50;\n const halfRes = Math.floor(resolution / 2);\n const points: Point[] = [];\n\n // First curve: start to middle\n for (let i = 0; i <= halfRes; i++) {\n const t = i / halfRes;\n points.push(this.cubicBezier(start, cp1, cp2, middle, t));\n }\n\n // Second curve: middle to end\n for (let i = 1; i <= halfRes; i++) {\n const t = i / halfRes;\n points.push(this.cubicBezier(middle, cp3, cp4, end, t));\n }\n\n return points;\n }\n\n private cubicBezier(p0: Point, p1: Point, p2: Point, p3: Point, t: number): Point {\n const t2 = t * t;\n const t3 = t2 * t;\n const mt = 1 - t;\n const mt2 = mt * mt;\n const mt3 = mt2 * mt;\n\n return {\n x: mt3 * p0.x + 3 * mt2 * t * p1.x + 3 * mt * t2 * p2.x + t3 * p3.x,\n y: mt3 * p0.y + 3 * mt2 * t * p1.y + 3 * mt * t2 * p2.y + t3 * p3.y,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const curvePoints = this.getCurvePoints(viewport);\n if (!curvePoints || curvePoints.length < 2) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points: curvePoints,\n closed: false,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const curvePoints = this.getCurvePoints(viewport);\n if (!curvePoints || curvePoints.length < 2) return false;\n\n // Check distance to curve segments\n for (let i = 0; i < curvePoints.length - 1; i++) {\n const p1 = curvePoints[i];\n const p2 = curvePoints[i + 1];\n const dist = this.distanceToSegment(point, p1, p2);\n if (dist <= DoubleCurve.HIT_THRESHOLD) {\n return true;\n }\n }\n\n // Check main anchor points\n const mainPts = this.getMainPoints(viewport);\n if (mainPts) {\n if (distanceBetweenPoints(point, mainPts.start) <= DoubleCurve.HIT_THRESHOLD * 2) return true;\n if (distanceBetweenPoints(point, mainPts.middle) <= DoubleCurve.HIT_THRESHOLD * 2) return true;\n if (distanceBetweenPoints(point, mainPts.end) <= DoubleCurve.HIT_THRESHOLD * 2) return true;\n }\n\n return false;\n }\n\n private distanceToSegment(point: Point, p1: Point, p2: Point): number {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const lengthSq = dx * dx + dy * dy;\n\n if (lengthSq === 0) {\n return distanceBetweenPoints(point, p1);\n }\n\n let t = ((point.x - p1.x) * dx + (point.y - p1.y) * dy) / lengthSq;\n t = Math.max(0, Math.min(1, t));\n\n const projection: Point = {\n x: p1.x + t * dx,\n y: p1.y + t * dy,\n };\n\n return distanceBetweenPoints(point, projection);\n }\n\n clone(newId: string): IDrawing {\n return new DoubleCurve(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._doubleCurveOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n middle: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<DoubleCurveOptions>\n ): DoubleCurve {\n return new DoubleCurve(id, [start, middle, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ParallelChannel } from './parallel-channel';\nimport type { Point } from '../../core/types';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class ParallelChannelPaneView implements IPrimitivePaneView {\n private _renderer: ParallelChannelPaneRenderer;\n\n constructor(drawing: ParallelChannel) {\n this._renderer = new ParallelChannelPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ParallelChannelPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ParallelChannel;\n\n constructor(drawing: ParallelChannel) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p3 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return;\n\n // Calculate parallel line offset\n const offset = this.calculateOffset(p1, p2, p3);\n const p1Parallel = { x: p1.x + offset.x, y: p1.y + offset.y };\n const p2Parallel = { x: p2.x + offset.x, y: p2.y + offset.y };\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n const options = this._drawing.channelOptions;\n\n // Handle extensions\n let drawP1 = p1, drawP2 = p2;\n let drawP1P = p1Parallel, drawP2P = p2Parallel;\n\n if (options.extendLines) {\n const extended1 = extendLineToViewport(p1, p2, viewport.width, viewport.height, true, true);\n const extended2 = extendLineToViewport(p1Parallel, p2Parallel, viewport.width, viewport.height, true, true);\n drawP1 = extended1.start;\n drawP2 = extended1.end;\n drawP1P = extended2.start;\n drawP2P = extended2.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(drawP1.x * pixelRatio, drawP1.y * pixelRatio);\n ctx.lineTo(drawP2.x * pixelRatio, drawP2.y * pixelRatio);\n ctx.lineTo(drawP2P.x * pixelRatio, drawP2P.y * pixelRatio);\n ctx.lineTo(drawP1P.x * pixelRatio, drawP1P.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw baseline\n drawLine(ctx, drawP1, drawP2, pixelRatio);\n\n // Draw parallel line\n drawLine(ctx, drawP1P, drawP2P, pixelRatio);\n\n // Draw middle line\n if (options.showMiddleLine) {\n const p1Middle = { x: (p1.x + p1Parallel.x) / 2, y: (p1.y + p1Parallel.y) / 2 };\n const p2Middle = { x: (p2.x + p2Parallel.x) / 2, y: (p2.y + p2Parallel.y) / 2 };\n\n let drawP1M = p1Middle, drawP2M = p2Middle;\n if (options.extendLines) {\n const extendedM = extendLineToViewport(p1Middle, p2Middle, viewport.width, viewport.height, true, true);\n drawP1M = extendedM.start;\n drawP2M = extendedM.end;\n }\n\n drawDashedLine(ctx, drawP1M, drawP2M, [5, 5], pixelRatio);\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n\n private calculateOffset(p1: Point, p2: Point, p3: Point): Point {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const len = Math.sqrt(dx * dx + dy * dy);\n\n if (len === 0) return { x: 0, y: p3.y - p1.y };\n\n const nx = -dy / len;\n const ny = dx / len;\n\n const vx = p3.x - p1.x;\n const vy = p3.y - p1.y;\n\n const dist = vx * nx + vy * ny;\n\n return { x: nx * dist, y: ny * dist };\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { ParallelChannelPaneView } from './parallel-channel-pane-view';\n\n/**\n * ParallelChannel options\n */\nexport interface ParallelChannelOptions extends DrawingOptions {\n filled?: boolean;\n showMiddleLine?: boolean;\n extendLines?: boolean;\n}\n\n/**\n * ParallelChannel - Two parallel lines forming a channel.\n *\n * Features:\n * - Three anchor points (two for baseline, one for channel width)\n * - Optional fill between lines\n * - Optional middle line\n * - Optional line extensions\n */\nexport class ParallelChannel extends Drawing {\n readonly type = 'parallel-channel';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _channelOptions: ParallelChannelOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ParallelChannelOptions> = {}\n ) {\n const { filled, showMiddleLine, extendLines, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._channelOptions = {\n ...this._options,\n filled: filled ?? true,\n showMiddleLine: showMiddleLine ?? true,\n extendLines: extendLines ?? false,\n };\n }\n\n get channelOptions(): ParallelChannelOptions {\n return this._channelOptions;\n }\n\n setChannelOptions(options: Partial<ParallelChannelOptions>): void {\n this._channelOptions = { ...this._channelOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= ParallelChannel.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ParallelChannelPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return [];\n\n const geometries: Geometry[] = [];\n\n // Baseline (p1 to p2)\n geometries.push({\n type: 'line',\n start: p1,\n end: p2,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Project p3 onto baseline and calculate perpendicular offset\n const offset = this.calculateOffset(p1, p2, p3);\n\n // Parallel line\n const p1Parallel = { x: p1.x + offset.x, y: p1.y + offset.y };\n const p2Parallel = { x: p2.x + offset.x, y: p2.y + offset.y };\n\n geometries.push({\n type: 'line',\n start: p1Parallel,\n end: p2Parallel,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Middle line\n if (this._channelOptions.showMiddleLine) {\n const p1Middle = { x: (p1.x + p1Parallel.x) / 2, y: (p1.y + p1Parallel.y) / 2 };\n const p2Middle = { x: (p2.x + p2Parallel.x) / 2, y: (p2.y + p2Parallel.y) / 2 };\n\n geometries.push({\n type: 'line',\n start: p1Middle,\n end: p2Middle,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n private calculateOffset(p1: Point, p2: Point, p3: Point): Point {\n // Vector from p1 to p2\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const len = Math.sqrt(dx * dx + dy * dy);\n\n if (len === 0) return { x: 0, y: p3.y - p1.y };\n\n // Unit normal vector (perpendicular to baseline)\n const nx = -dy / len;\n const ny = dx / len;\n\n // Vector from p1 to p3\n const vx = p3.x - p1.x;\n const vy = p3.y - p1.y;\n\n // Project onto normal to get distance\n const dist = vx * nx + vy * ny;\n\n return { x: nx * dist, y: ny * dist };\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return false;\n\n // Check baseline\n if (distanceToLineSegment(point, p1, p2) <= ParallelChannel.HIT_THRESHOLD) return true;\n\n // Check parallel line\n const offset = this.calculateOffset(p1, p2, p3);\n const p1Parallel = { x: p1.x + offset.x, y: p1.y + offset.y };\n const p2Parallel = { x: p2.x + offset.x, y: p2.y + offset.y };\n\n if (distanceToLineSegment(point, p1Parallel, p2Parallel) <= ParallelChannel.HIT_THRESHOLD) return true;\n\n // If filled, check if inside channel\n if (this._channelOptions.filled) {\n // Simple bounding check\n const minX = Math.min(p1.x, p2.x, p1Parallel.x, p2Parallel.x);\n const maxX = Math.max(p1.x, p2.x, p1Parallel.x, p2Parallel.x);\n const minY = Math.min(p1.y, p2.y, p1Parallel.y, p2Parallel.y);\n const maxY = Math.max(p1.y, p2.y, p1Parallel.y, p2Parallel.y);\n\n if (point.x >= minX && point.x <= maxX && point.y >= minY && point.y <= maxY) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new ParallelChannel(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._channelOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n width: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ParallelChannelOptions>\n ): ParallelChannel {\n return new ParallelChannel(id, [start, end, width], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { RegressionTrend } from './regression-trend';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class RegressionTrendPaneView implements IPrimitivePaneView {\n private _renderer: RegressionTrendPaneRenderer;\n\n constructor(drawing: RegressionTrend) {\n this._renderer = new RegressionTrendPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass RegressionTrendPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: RegressionTrend;\n\n constructor(drawing: RegressionTrend) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.channelOptions;\n const { slope, stdDev } = this._drawing.calculateRegression(p1, p2);\n const offset = stdDev * (options.standardDeviations ?? 2);\n\n // Calculate perpendicular offset\n const len = Math.sqrt(1 + slope * slope);\n const nx = -slope / len;\n const ny = 1 / len;\n const offsetX = nx * offset;\n const offsetY = ny * offset;\n\n // Calculate channel points\n const p1Upper = { x: p1.x + offsetX, y: p1.y + offsetY };\n const p2Upper = { x: p2.x + offsetX, y: p2.y + offsetY };\n const p1Lower = { x: p1.x - offsetX, y: p1.y - offsetY };\n const p2Lower = { x: p2.x - offsetX, y: p2.y - offsetY };\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Handle extensions\n let drawP1 = p1, drawP2 = p2;\n let drawP1U = p1Upper, drawP2U = p2Upper;\n let drawP1L = p1Lower, drawP2L = p2Lower;\n\n if (options.extendLines) {\n const extendedMid = extendLineToViewport(p1, p2, viewport.width, viewport.height, true, true);\n const extendedUpper = extendLineToViewport(p1Upper, p2Upper, viewport.width, viewport.height, true, true);\n const extendedLower = extendLineToViewport(p1Lower, p2Lower, viewport.width, viewport.height, true, true);\n drawP1 = extendedMid.start;\n drawP2 = extendedMid.end;\n drawP1U = extendedUpper.start;\n drawP2U = extendedUpper.end;\n drawP1L = extendedLower.start;\n drawP2L = extendedLower.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(drawP1U.x * pixelRatio, drawP1U.y * pixelRatio);\n ctx.lineTo(drawP2U.x * pixelRatio, drawP2U.y * pixelRatio);\n ctx.lineTo(drawP2L.x * pixelRatio, drawP2L.y * pixelRatio);\n ctx.lineTo(drawP1L.x * pixelRatio, drawP1L.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw upper band\n drawLine(ctx, drawP1U, drawP2U, pixelRatio);\n\n // Draw lower band\n drawLine(ctx, drawP1L, drawP2L, pixelRatio);\n\n // Draw middle line (regression line) - dashed\n if (options.showMiddleLine) {\n drawDashedLine(ctx, drawP1, drawP2, [5, 5], pixelRatio);\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { RegressionTrendPaneView } from './regression-trend-pane-view';\n\n/**\n * RegressionTrend options\n */\nexport interface RegressionTrendOptions extends DrawingOptions {\n filled?: boolean;\n showMiddleLine?: boolean;\n extendLines?: boolean;\n standardDeviations?: number; // Number of standard deviations for channel width\n}\n\n/**\n * RegressionTrend - Linear regression channel with standard deviation bands.\n *\n * Features:\n * - Two anchor points define the regression range\n * - Linear regression calculates the best-fit line\n * - Channel width based on standard deviation\n * - Optional fill between lines\n * - Optional line extensions\n */\nexport class RegressionTrend extends Drawing {\n readonly type = 'regression-trend';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _channelOptions: RegressionTrendOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<RegressionTrendOptions> = {}\n ) {\n const { filled, showMiddleLine, extendLines, standardDeviations, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._channelOptions = {\n ...this._options,\n filled: filled ?? true,\n showMiddleLine: showMiddleLine ?? true,\n extendLines: extendLines ?? false,\n standardDeviations: standardDeviations ?? 2,\n };\n }\n\n get channelOptions(): RegressionTrendOptions {\n return this._channelOptions;\n }\n\n setChannelOptions(options: Partial<RegressionTrendOptions>): void {\n this._channelOptions = { ...this._channelOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= RegressionTrend.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new RegressionTrendPaneView(this)];\n }\n\n /**\n * Calculate linear regression parameters\n */\n calculateRegression(p1: Point, p2: Point): { slope: number; intercept: number; stdDev: number } {\n // Simple two-point linear regression\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n\n if (Math.abs(dx) < 0.001) {\n return { slope: 0, intercept: p1.y, stdDev: 20 }; // Default stdDev for vertical lines\n }\n\n const slope = dy / dx;\n const intercept = p1.y - slope * p1.x;\n\n // For a two-point line, we simulate a standard deviation based on the line length\n const lineLength = Math.sqrt(dx * dx + dy * dy);\n const stdDev = Math.max(10, lineLength * 0.1); // 10% of line length or minimum 10px\n\n return { slope, intercept, stdDev };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const { slope, stdDev } = this.calculateRegression(p1, p2);\n const offset = stdDev * (this._channelOptions.standardDeviations ?? 2);\n\n // Calculate perpendicular offset\n const len = Math.sqrt(1 + slope * slope);\n const nx = -slope / len;\n const ny = 1 / len;\n const offsetX = nx * offset;\n const offsetY = ny * offset;\n\n // Middle (regression) line\n geometries.push({\n type: 'line',\n start: p1,\n end: p2,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Upper band\n const p1Upper = { x: p1.x + offsetX, y: p1.y + offsetY };\n const p2Upper = { x: p2.x + offsetX, y: p2.y + offsetY };\n geometries.push({\n type: 'line',\n start: p1Upper,\n end: p2Upper,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Lower band\n const p1Lower = { x: p1.x - offsetX, y: p1.y - offsetY };\n const p2Lower = { x: p2.x - offsetX, y: p2.y - offsetY };\n geometries.push({\n type: 'line',\n start: p1Lower,\n end: p2Lower,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n // Check middle line\n if (distanceToLineSegment(point, p1, p2) <= RegressionTrend.HIT_THRESHOLD) return true;\n\n const { slope, stdDev } = this.calculateRegression(p1, p2);\n const offset = stdDev * (this._channelOptions.standardDeviations ?? 2);\n\n const len = Math.sqrt(1 + slope * slope);\n const nx = -slope / len;\n const ny = 1 / len;\n const offsetX = nx * offset;\n const offsetY = ny * offset;\n\n // Check upper band\n const p1Upper = { x: p1.x + offsetX, y: p1.y + offsetY };\n const p2Upper = { x: p2.x + offsetX, y: p2.y + offsetY };\n if (distanceToLineSegment(point, p1Upper, p2Upper) <= RegressionTrend.HIT_THRESHOLD) return true;\n\n // Check lower band\n const p1Lower = { x: p1.x - offsetX, y: p1.y - offsetY };\n const p2Lower = { x: p2.x - offsetX, y: p2.y - offsetY };\n if (distanceToLineSegment(point, p1Lower, p2Lower) <= RegressionTrend.HIT_THRESHOLD) return true;\n\n // If filled, check if inside channel\n if (this._channelOptions.filled) {\n const minX = Math.min(p1Upper.x, p2Upper.x, p1Lower.x, p2Lower.x);\n const maxX = Math.max(p1Upper.x, p2Upper.x, p1Lower.x, p2Lower.x);\n const minY = Math.min(p1Upper.y, p2Upper.y, p1Lower.y, p2Lower.y);\n const maxY = Math.max(p1Upper.y, p2Upper.y, p1Lower.y, p2Lower.y);\n\n if (point.x >= minX && point.x <= maxX && point.y >= minY && point.y <= maxY) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new RegressionTrend(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._channelOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<RegressionTrendOptions>\n ): RegressionTrend {\n return new RegressionTrend(id, [start, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FlatTopBottom } from './flat-top-bottom';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class FlatTopBottomPaneView implements IPrimitivePaneView {\n private _renderer: FlatTopBottomPaneRenderer;\n\n constructor(drawing: FlatTopBottom) {\n this._renderer = new FlatTopBottomPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FlatTopBottomPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FlatTopBottom;\n\n constructor(drawing: FlatTopBottom) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p3 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return;\n\n const options = this._drawing.channelOptions;\n\n // Calculate flat line points\n const flatY = p3.y;\n const flatStart = { x: p1.x, y: flatY };\n const flatEnd = { x: p2.x, y: flatY };\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Handle extensions\n let drawP1 = p1, drawP2 = p2;\n let drawFlatStart = flatStart, drawFlatEnd = flatEnd;\n\n if (options.extendLines) {\n const extendedTrend = extendLineToViewport(p1, p2, viewport.width, viewport.height, true, true);\n const extendedFlat = extendLineToViewport(flatStart, flatEnd, viewport.width, viewport.height, true, true);\n drawP1 = extendedTrend.start;\n drawP2 = extendedTrend.end;\n drawFlatStart = extendedFlat.start;\n drawFlatEnd = extendedFlat.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(drawP1.x * pixelRatio, drawP1.y * pixelRatio);\n ctx.lineTo(drawP2.x * pixelRatio, drawP2.y * pixelRatio);\n ctx.lineTo(drawFlatEnd.x * pixelRatio, drawFlatEnd.y * pixelRatio);\n ctx.lineTo(drawFlatStart.x * pixelRatio, drawFlatStart.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw trend line\n drawLine(ctx, drawP1, drawP2, pixelRatio);\n\n // Draw flat line\n drawLine(ctx, drawFlatStart, drawFlatEnd, pixelRatio);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { FlatTopBottomPaneView } from './flat-top-bottom-pane-view';\n\n/**\n * FlatTopBottom options\n */\nexport interface FlatTopBottomOptions extends DrawingOptions {\n filled?: boolean;\n extendLines?: boolean;\n flatPosition?: 'top' | 'bottom'; // Which line is flat (horizontal)\n}\n\n/**\n * FlatTopBottom - A channel where one side is flat (horizontal) and the other follows a trend.\n *\n * Features:\n * - Three anchor points: two for the trend line, one for the flat line level\n * - One horizontal line (flat)\n * - One diagonal line (trend)\n * - Optional fill between lines\n * - Optional line extensions\n */\nexport class FlatTopBottom extends Drawing {\n readonly type = 'flat-top-bottom';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _channelOptions: FlatTopBottomOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FlatTopBottomOptions> = {}\n ) {\n const { filled, extendLines, flatPosition, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._channelOptions = {\n ...this._options,\n filled: filled ?? true,\n extendLines: extendLines ?? false,\n flatPosition: flatPosition ?? 'top',\n };\n }\n\n get channelOptions(): FlatTopBottomOptions {\n return this._channelOptions;\n }\n\n setChannelOptions(options: Partial<FlatTopBottomOptions>): void {\n this._channelOptions = { ...this._channelOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FlatTopBottom.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FlatTopBottomPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n // p1, p2 define the trend line\n // p3 defines the flat line level (uses the price)\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return [];\n\n const geometries: Geometry[] = [];\n\n // Trend line (p1 to p2)\n geometries.push({\n type: 'line',\n start: p1,\n end: p2,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Flat line (horizontal at p3.y, spanning from p1.x to p2.x)\n const flatY = p3.y;\n const flatStart = { x: p1.x, y: flatY };\n const flatEnd = { x: p2.x, y: flatY };\n\n geometries.push({\n type: 'line',\n start: flatStart,\n end: flatEnd,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return false;\n\n // Check trend line\n if (distanceToLineSegment(point, p1, p2) <= FlatTopBottom.HIT_THRESHOLD) return true;\n\n // Check flat line\n const flatY = p3.y;\n const flatStart = { x: p1.x, y: flatY };\n const flatEnd = { x: p2.x, y: flatY };\n if (distanceToLineSegment(point, flatStart, flatEnd) <= FlatTopBottom.HIT_THRESHOLD) return true;\n\n // If filled, check if inside channel\n if (this._channelOptions.filled) {\n const minX = Math.min(p1.x, p2.x);\n const maxX = Math.max(p1.x, p2.x);\n const minY = Math.min(p1.y, p2.y, flatY);\n const maxY = Math.max(p1.y, p2.y, flatY);\n\n if (point.x >= minX && point.x <= maxX && point.y >= minY && point.y <= maxY) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FlatTopBottom(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._channelOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n flatLevel: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FlatTopBottomOptions>\n ): FlatTopBottom {\n return new FlatTopBottom(id, [start, end, flatLevel], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { DisjointChannel } from './disjoint-channel';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class DisjointChannelPaneView implements IPrimitivePaneView {\n private _renderer: DisjointChannelPaneRenderer;\n\n constructor(drawing: DisjointChannel) {\n this._renderer = new DisjointChannelPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass DisjointChannelPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: DisjointChannel;\n\n constructor(drawing: DisjointChannel) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p3 = this._drawing.anchorToPixel(anchors[2], viewport);\n const p4 = this._drawing.anchorToPixel(anchors[3], viewport);\n\n if (!p1 || !p2 || !p3 || !p4) return;\n\n const options = this._drawing.channelOptions;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Handle extensions\n let drawP1 = p1, drawP2 = p2;\n let drawP3 = p3, drawP4 = p4;\n\n if (options.extendLines) {\n const extended1 = extendLineToViewport(p1, p2, viewport.width, viewport.height, true, true);\n const extended2 = extendLineToViewport(p3, p4, viewport.width, viewport.height, true, true);\n drawP1 = extended1.start;\n drawP2 = extended1.end;\n drawP3 = extended2.start;\n drawP4 = extended2.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(drawP1.x * pixelRatio, drawP1.y * pixelRatio);\n ctx.lineTo(drawP2.x * pixelRatio, drawP2.y * pixelRatio);\n ctx.lineTo(drawP4.x * pixelRatio, drawP4.y * pixelRatio);\n ctx.lineTo(drawP3.x * pixelRatio, drawP3.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw first line\n drawLine(ctx, drawP1, drawP2, pixelRatio);\n\n // Draw second line\n drawLine(ctx, drawP3, drawP4, pixelRatio);\n\n // Draw middle line if enabled\n if (options.showMiddleLine) {\n const midStart = {\n x: (p1.x + p3.x) / 2,\n y: (p1.y + p3.y) / 2,\n };\n const midEnd = {\n x: (p2.x + p4.x) / 2,\n y: (p2.y + p4.y) / 2,\n };\n\n let drawMidStart = midStart, drawMidEnd = midEnd;\n if (options.extendLines) {\n const extendedMid = extendLineToViewport(midStart, midEnd, viewport.width, viewport.height, true, true);\n drawMidStart = extendedMid.start;\n drawMidEnd = extendedMid.end;\n }\n\n drawDashedLine(ctx, drawMidStart, drawMidEnd, [5, 5], pixelRatio);\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { DisjointChannelPaneView } from './disjoint-channel-pane-view';\n\n/**\n * DisjointChannel options\n */\nexport interface DisjointChannelOptions extends DrawingOptions {\n filled?: boolean;\n extendLines?: boolean;\n showMiddleLine?: boolean;\n}\n\n/**\n * DisjointChannel - A channel with two independent lines that don't have to be parallel.\n *\n * Features:\n * - Four anchor points: two for upper line, two for lower line\n * - Lines can be at any angle (not necessarily parallel)\n * - Optional fill between lines\n * - Optional middle line\n * - Optional line extensions\n *\n * Points:\n * - Anchor 0-1: First line\n * - Anchor 2-3: Second line\n */\nexport class DisjointChannel extends Drawing {\n readonly type = 'disjoint-channel';\n\n protected static readonly REQUIRED_ANCHORS = 4;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _channelOptions: DisjointChannelOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<DisjointChannelOptions> = {}\n ) {\n const { filled, extendLines, showMiddleLine, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._channelOptions = {\n ...this._options,\n filled: filled ?? true,\n extendLines: extendLines ?? false,\n showMiddleLine: showMiddleLine ?? false,\n };\n }\n\n get channelOptions(): DisjointChannelOptions {\n return this._channelOptions;\n }\n\n setChannelOptions(options: Partial<DisjointChannelOptions>): void {\n this._channelOptions = { ...this._channelOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= DisjointChannel.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new DisjointChannelPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n const p4 = this.anchorToPixel(this._anchors[3], viewport);\n\n if (!p1 || !p2 || !p3 || !p4) return [];\n\n const geometries: Geometry[] = [];\n\n // First line (p1 to p2)\n geometries.push({\n type: 'line',\n start: p1,\n end: p2,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Second line (p3 to p4)\n geometries.push({\n type: 'line',\n start: p3,\n end: p4,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n\n // Middle line (average of both lines)\n if (this._channelOptions.showMiddleLine) {\n const midStart = {\n x: (p1.x + p3.x) / 2,\n y: (p1.y + p3.y) / 2,\n };\n const midEnd = {\n x: (p2.x + p4.x) / 2,\n y: (p2.y + p4.y) / 2,\n };\n\n geometries.push({\n type: 'line',\n start: midStart,\n end: midEnd,\n extendLeft: this._channelOptions.extendLines,\n extendRight: this._channelOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n const p4 = this.anchorToPixel(this._anchors[3], viewport);\n\n if (!p1 || !p2 || !p3 || !p4) return false;\n\n // Check first line\n if (distanceToLineSegment(point, p1, p2) <= DisjointChannel.HIT_THRESHOLD) return true;\n\n // Check second line\n if (distanceToLineSegment(point, p3, p4) <= DisjointChannel.HIT_THRESHOLD) return true;\n\n // If filled, check if inside channel polygon\n if (this._channelOptions.filled) {\n if (this.isPointInPolygon(point, [p1, p2, p4, p3])) {\n return true;\n }\n }\n\n return false;\n }\n\n private isPointInPolygon(point: Point, polygon: Point[]): boolean {\n let inside = false;\n for (let i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {\n const xi = polygon[i].x, yi = polygon[i].y;\n const xj = polygon[j].x, yj = polygon[j].y;\n\n const intersect = ((yi > point.y) !== (yj > point.y)) &&\n (point.x < (xj - xi) * (point.y - yi) / (yj - yi) + xi);\n if (intersect) inside = !inside;\n }\n return inside;\n }\n\n clone(newId: string): IDrawing {\n return new DisjointChannel(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._channelOptions }\n );\n }\n\n static create(\n id: string,\n line1Start: Anchor,\n line1End: Anchor,\n line2Start: Anchor,\n line2End: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<DisjointChannelOptions>\n ): DisjointChannel {\n return new DisjointChannel(id, [line1Start, line1End, line2Start, line2End], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibRetracement } from './fib-retracement';\nimport { FIBONACCI_LEVELS } from './fib-retracement';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\n// Colors for different Fib levels\nconst FIB_COLORS: Record<number, string> = {\n 0: '#787B86',\n 0.236: '#F7525F',\n 0.382: '#FF9800',\n 0.5: '#4CAF50',\n 0.618: '#2196F3',\n 0.786: '#9C27B0',\n 1: '#787B86',\n 1.618: '#00BCD4',\n 2.618: '#E91E63',\n};\n\nexport class FibRetracementPaneView implements IPrimitivePaneView {\n private _renderer: FibRetracementPaneRenderer;\n\n constructor(drawing: FibRetracement) {\n this._renderer = new FibRetracementPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibRetracementPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibRetracement;\n\n constructor(drawing: FibRetracement) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIBONACCI_LEVELS;\n const price1 = anchors[0].price;\n const price2 = anchors[1].price;\n const priceRange = price2 - price1;\n\n const minX = options.extendLines ? 0 : Math.min(p1.x, p2.x);\n const maxX = options.extendLines ? viewport.width : Math.max(p1.x, p2.x);\n\n // Draw fill between levels\n if (this._drawing.style.fillColor) {\n const sortedLevels = [...levels].sort((a, b) => a - b);\n for (let i = 0; i < sortedLevels.length - 1; i++) {\n const level1 = sortedLevels[i];\n const level2 = sortedLevels[i + 1];\n\n const levelPrice1 = options.reverseDirection\n ? price2 - priceRange * level1\n : price1 + priceRange * level1;\n const levelPrice2 = options.reverseDirection\n ? price2 - priceRange * level2\n : price1 + priceRange * level2;\n\n const y1 = viewport.priceScale.priceToCoordinate(levelPrice1);\n const y2 = viewport.priceScale.priceToCoordinate(levelPrice2);\n\n if (y1 === null || y2 === null) continue;\n\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.globalAlpha = 0.1;\n ctx.fillRect(\n minX * pixelRatio,\n Math.min(y1, y2) * pixelRatio,\n (maxX - minX) * pixelRatio,\n Math.abs(y2 - y1) * pixelRatio\n );\n ctx.globalAlpha = 1;\n }\n }\n\n // Draw level lines\n for (const level of levels) {\n const price = options.reverseDirection\n ? price2 - priceRange * level\n : price1 + priceRange * level;\n\n const y = viewport.priceScale.priceToCoordinate(price);\n if (y === null) continue;\n\n // Use level-specific color or default\n const color = FIB_COLORS[level] ?? this._drawing.style.lineColor;\n ctx.strokeStyle = color;\n ctx.lineWidth = this._drawing.style.lineWidth * pixelRatio;\n\n drawLine(ctx, { x: minX, y }, { x: maxX, y }, pixelRatio);\n\n // Draw labels\n const labelParts: string[] = [];\n\n if (options.showPercentages) {\n labelParts.push(`${(level * 100).toFixed(1)}%`);\n }\n\n if (options.showPrices) {\n labelParts.push(price.toFixed(2));\n }\n\n if (labelParts.length > 0) {\n drawLabel(\n ctx,\n labelParts.join(' - '),\n { x: maxX - 5, y },\n {\n font: '11px sans-serif',\n textColor: '#ffffff',\n backgroundColor: color + 'CC',\n padding: 3,\n borderRadius: 2,\n },\n pixelRatio\n );\n }\n }\n\n // Draw the main trend line connecting anchors\n applyStyle(ctx, this._drawing.style, pixelRatio);\n ctx.setLineDash([5, 5]);\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.setLineDash([]);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { FibRetracementPaneView } from './fib-retracement-pane-view';\n\n/**\n * Standard Fibonacci ratios\n */\nexport const FIBONACCI_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618, 2.618];\n\n/**\n * FibRetracement options\n */\nexport interface FibRetracementOptions extends DrawingOptions {\n levels?: number[];\n showPrices?: boolean;\n showPercentages?: boolean;\n extendLines?: boolean;\n reverseDirection?: boolean;\n}\n\n/**\n * FibRetracement - Fibonacci retracement levels between two price points.\n *\n * Features:\n * - Two anchor points (high and low)\n * - Multiple Fibonacci level lines\n * - Optional price and percentage labels\n * - Optional line extensions\n * - Customizable levels\n */\nexport class FibRetracement extends Drawing {\n readonly type = 'fib-retracement';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibRetracementOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibRetracementOptions> = {}\n ) {\n const { levels, showPrices, showPercentages, extendLines, reverseDirection, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIBONACCI_LEVELS,\n showPrices: showPrices ?? true,\n showPercentages: showPercentages ?? true,\n extendLines: extendLines ?? false,\n reverseDirection: reverseDirection ?? false,\n };\n }\n\n get fibOptions(): FibRetracementOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibRetracementOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibRetracement.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibRetracementPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIBONACCI_LEVELS;\n const price1 = this._anchors[0].price;\n const price2 = this._anchors[1].price;\n const priceRange = price2 - price1;\n\n for (const level of levels) {\n const price = this._fibOptions.reverseDirection\n ? price2 - priceRange * level\n : price1 + priceRange * level;\n\n const y = viewport.priceScale.priceToCoordinate(price);\n if (y === null) continue;\n\n geometries.push({\n type: 'line',\n start: { x: this._fibOptions.extendLines ? 0 : Math.min(p1.x, p2.x), y },\n end: { x: this._fibOptions.extendLines ? viewport.width : Math.max(p1.x, p2.x), y },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n /**\n * Calculate price at a specific Fibonacci level\n */\n getPriceAtLevel(level: number): number {\n if (!this.isValid()) return 0;\n\n const price1 = this._anchors[0].price;\n const price2 = this._anchors[1].price;\n const priceRange = price2 - price1;\n\n return this._fibOptions.reverseDirection\n ? price2 - priceRange * level\n : price1 + priceRange * level;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const levels = this._fibOptions.levels ?? FIBONACCI_LEVELS;\n const price1 = this._anchors[0].price;\n const price2 = this._anchors[1].price;\n const priceRange = price2 - price1;\n\n const minX = this._fibOptions.extendLines ? 0 : Math.min(p1.x, p2.x);\n const maxX = this._fibOptions.extendLines ? viewport.width : Math.max(p1.x, p2.x);\n\n // Check if near any level line\n for (const level of levels) {\n const price = this._fibOptions.reverseDirection\n ? price2 - priceRange * level\n : price1 + priceRange * level;\n\n const y = viewport.priceScale.priceToCoordinate(price);\n if (y === null) continue;\n\n if (point.x >= minX && point.x <= maxX && Math.abs(point.y - y) <= FibRetracement.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibRetracement(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibRetracementOptions>\n ): FibRetracement {\n return new FibRetracement(id, [start, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibExtension } from './fib-extension';\nimport { FIB_EXTENSION_LEVELS } from './fib-extension';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel, drawDashedLine } from '../../rendering/canvas-utils';\n\nconst FIB_COLORS: Record<number, string> = {\n 0: '#787B86',\n 0.236: '#F7525F',\n 0.382: '#FF9800',\n 0.5: '#4CAF50',\n 0.618: '#2196F3',\n 0.786: '#9C27B0',\n 1: '#787B86',\n 1.272: '#00BCD4',\n 1.618: '#E91E63',\n 2: '#795548',\n 2.618: '#607D8B',\n 3.618: '#9E9E9E',\n 4.236: '#FF5722',\n};\n\nexport class FibExtensionPaneView implements IPrimitivePaneView {\n private _renderer: FibExtensionPaneRenderer;\n\n constructor(drawing: FibExtension) {\n this._renderer = new FibExtensionPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibExtensionPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibExtension;\n\n constructor(drawing: FibExtension) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const pA = this._drawing.anchorToPixel(anchors[0], viewport);\n const pB = this._drawing.anchorToPixel(anchors[1], viewport);\n const pC = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!pA || !pB || !pC) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIB_EXTENSION_LEVELS;\n const priceA = anchors[0].price;\n const priceB = anchors[1].price;\n const priceC = anchors[2].price;\n const range = priceB - priceA;\n\n // Draw connecting lines A-B-C\n applyStyle(ctx, this._drawing.style, pixelRatio);\n drawDashedLine(ctx, pA, pB, [5, 5], pixelRatio);\n drawDashedLine(ctx, pB, pC, [5, 5], pixelRatio);\n\n // Draw extension levels\n for (const level of levels) {\n const price = priceC + range * level;\n const y = viewport.priceScale.priceToCoordinate(price);\n if (y === null) continue;\n\n const color = FIB_COLORS[level] ?? this._drawing.style.lineColor;\n ctx.strokeStyle = color;\n ctx.lineWidth = this._drawing.style.lineWidth * pixelRatio;\n\n const startX = options.extendLines ? 0 : pC.x;\n drawLine(ctx, { x: startX, y }, { x: viewport.width, y }, pixelRatio);\n\n // Draw labels\n const labelParts: string[] = [];\n\n if (options.showPercentages) {\n labelParts.push(`${(level * 100).toFixed(1)}%`);\n }\n\n if (options.showPrices) {\n labelParts.push(price.toFixed(2));\n }\n\n if (labelParts.length > 0) {\n drawLabel(\n ctx,\n labelParts.join(' - '),\n { x: viewport.width - 5, y },\n {\n font: '11px sans-serif',\n textColor: '#ffffff',\n backgroundColor: color + 'CC',\n padding: 3,\n borderRadius: 2,\n },\n pixelRatio\n );\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { FibExtensionPaneView } from './fib-extension-pane-view';\n\n/**\n * Standard Fibonacci extension levels\n */\nexport const FIB_EXTENSION_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.272, 1.618, 2, 2.618, 3.618, 4.236];\n\n/**\n * FibExtension options\n */\nexport interface FibExtensionOptions extends DrawingOptions {\n levels?: number[];\n showPrices?: boolean;\n showPercentages?: boolean;\n extendLines?: boolean;\n}\n\n/**\n * FibExtension - Fibonacci extension levels based on three points.\n *\n * Features:\n * - Three anchor points (A, B, C - swing high/low/retracement)\n * - Extension levels projected from point C\n * - Optional price and percentage labels\n */\nexport class FibExtension extends Drawing {\n readonly type = 'fib-extension';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibExtensionOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibExtensionOptions> = {}\n ) {\n const { levels, showPrices, showPercentages, extendLines, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIB_EXTENSION_LEVELS,\n showPrices: showPrices ?? true,\n showPercentages: showPercentages ?? true,\n extendLines: extendLines ?? false,\n };\n }\n\n get fibOptions(): FibExtensionOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibExtensionOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibExtension.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibExtensionPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const pA = this.anchorToPixel(this._anchors[0], viewport);\n const pB = this.anchorToPixel(this._anchors[1], viewport);\n const pC = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!pA || !pB || !pC) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIB_EXTENSION_LEVELS;\n\n // Price range from A to B\n const priceA = this._anchors[0].price;\n const priceB = this._anchors[1].price;\n const priceC = this._anchors[2].price;\n const range = priceB - priceA;\n\n for (const level of levels) {\n // Extension from C\n const price = priceC + range * level;\n const y = viewport.priceScale.priceToCoordinate(price);\n if (y === null) continue;\n\n const startX = this._fibOptions.extendLines ? 0 : pC.x;\n const endX = this._fibOptions.extendLines ? viewport.width : viewport.width;\n\n geometries.push({\n type: 'line',\n start: { x: startX, y },\n end: { x: endX, y },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n /**\n * Get price at a specific extension level\n */\n getPriceAtLevel(level: number): number {\n if (!this.isValid()) return 0;\n\n const priceA = this._anchors[0].price;\n const priceB = this._anchors[1].price;\n const priceC = this._anchors[2].price;\n const range = priceB - priceA;\n\n return priceC + range * level;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const pC = this.anchorToPixel(this._anchors[2], viewport);\n if (!pC) return false;\n\n const levels = this._fibOptions.levels ?? FIB_EXTENSION_LEVELS;\n const priceA = this._anchors[0].price;\n const priceB = this._anchors[1].price;\n const priceC = this._anchors[2].price;\n const range = priceB - priceA;\n\n for (const level of levels) {\n const price = priceC + range * level;\n const y = viewport.priceScale.priceToCoordinate(price);\n if (y === null) continue;\n\n if (Math.abs(point.y - y) <= FibExtension.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibExtension(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n pointA: Anchor,\n pointB: Anchor,\n pointC: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibExtensionOptions>\n ): FibExtension {\n return new FibExtension(id, [pointA, pointB, pointC], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibChannel } from './fib-channel';\nimport { FIB_CHANNEL_LEVELS } from './fib-channel';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibChannelPaneView implements IPrimitivePaneView {\n private _renderer: FibChannelPaneRenderer;\n\n constructor(drawing: FibChannel) {\n this._renderer = new FibChannelPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibChannelPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibChannel;\n\n constructor(drawing: FibChannel) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p3 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIB_CHANNEL_LEVELS;\n const offset = this._drawing.calculateOffset(p1, p2, p3);\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill between levels if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n for (let i = 0; i < levels.length - 1; i++) {\n const level1 = levels[i];\n const level2 = levels[i + 1];\n\n const start1 = { x: p1.x + offset.x * level1, y: p1.y + offset.y * level1 };\n const end1 = { x: p2.x + offset.x * level1, y: p2.y + offset.y * level1 };\n const start2 = { x: p1.x + offset.x * level2, y: p1.y + offset.y * level2 };\n const end2 = { x: p2.x + offset.x * level2, y: p2.y + offset.y * level2 };\n\n ctx.beginPath();\n ctx.moveTo(start1.x * pixelRatio, start1.y * pixelRatio);\n ctx.lineTo(end1.x * pixelRatio, end1.y * pixelRatio);\n ctx.lineTo(end2.x * pixelRatio, end2.y * pixelRatio);\n ctx.lineTo(start2.x * pixelRatio, start2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n }\n\n // Draw level lines\n for (const level of levels) {\n const offsetX = offset.x * level;\n const offsetY = offset.y * level;\n\n let start = { x: p1.x + offsetX, y: p1.y + offsetY };\n let end = { x: p2.x + offsetX, y: p2.y + offsetY };\n\n if (options.extendLines) {\n const extended = extendLineToViewport(start, end, viewport.width, viewport.height, true, true);\n start = extended.start;\n end = extended.end;\n }\n\n // Vary line opacity based on level importance\n const isMainLevel = level === 0 || level === 0.5 || level === 1 || level === 0.618;\n ctx.globalAlpha = isMainLevel ? 1 : 0.6;\n drawLine(ctx, start, end, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw level label\n if (options.showPercentages) {\n const labelX = end.x + 5;\n const labelY = end.y;\n const text = `${(level * 100).toFixed(1)}%`;\n drawText(ctx, text, { x: labelX, y: labelY }, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { FibChannelPaneView } from './fib-channel-pane-view';\n\n/**\n * Standard Fibonacci channel levels\n */\nexport const FIB_CHANNEL_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618, 2.618];\n\n/**\n * FibChannel options\n */\nexport interface FibChannelOptions extends DrawingOptions {\n levels?: number[];\n showPrices?: boolean;\n showPercentages?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * FibChannel - Fibonacci Channel with parallel trend lines at Fibonacci ratios.\n *\n * Features:\n * - Three anchor points (two for baseline, one for channel width)\n * - Multiple parallel lines at Fibonacci levels\n * - Optional fill between levels\n * - Optional line extensions\n */\nexport class FibChannel extends Drawing {\n readonly type = 'fib-channel';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibChannelOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibChannelOptions> = {}\n ) {\n const { levels, showPrices, showPercentages, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIB_CHANNEL_LEVELS,\n showPrices: showPrices ?? true,\n showPercentages: showPercentages ?? true,\n extendLines: extendLines ?? false,\n filled: filled ?? true,\n };\n }\n\n get fibOptions(): FibChannelOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibChannelOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibChannel.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibChannelPaneView(this)];\n }\n\n /**\n * Calculate the perpendicular offset from baseline to p3\n */\n calculateOffset(p1: Point, p2: Point, p3: Point): Point {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const len = Math.sqrt(dx * dx + dy * dy);\n\n if (len === 0) return { x: 0, y: p3.y - p1.y };\n\n const nx = -dy / len;\n const ny = dx / len;\n\n const vx = p3.x - p1.x;\n const vy = p3.y - p1.y;\n\n const dist = vx * nx + vy * ny;\n\n return { x: nx * dist, y: ny * dist };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIB_CHANNEL_LEVELS;\n const offset = this.calculateOffset(p1, p2, p3);\n\n for (const level of levels) {\n const offsetX = offset.x * level;\n const offsetY = offset.y * level;\n\n const start = { x: p1.x + offsetX, y: p1.y + offsetY };\n const end = { x: p2.x + offsetX, y: p2.y + offsetY };\n\n geometries.push({\n type: 'line',\n start,\n end,\n extendLeft: this._fibOptions.extendLines,\n extendRight: this._fibOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return false;\n\n const levels = this._fibOptions.levels ?? FIB_CHANNEL_LEVELS;\n const offset = this.calculateOffset(p1, p2, p3);\n\n for (const level of levels) {\n const offsetX = offset.x * level;\n const offsetY = offset.y * level;\n\n const start = { x: p1.x + offsetX, y: p1.y + offsetY };\n const end = { x: p2.x + offsetX, y: p2.y + offsetY };\n\n if (distanceToLineSegment(point, start, end) <= FibChannel.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibChannel(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n width: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibChannelOptions>\n ): FibChannel {\n return new FibChannel(id, [start, end, width], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibTimeZone } from './fib-time-zone';\nimport { FIB_TIME_INTERVALS } from './fib-time-zone';\nimport { applyStyle, drawLine, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibTimeZonePaneView implements IPrimitivePaneView {\n private _renderer: FibTimeZonePaneRenderer;\n\n constructor(drawing: FibTimeZone) {\n this._renderer = new FibTimeZonePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibTimeZonePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibTimeZone;\n\n constructor(drawing: FibTimeZone) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const intervals = options.intervals ?? FIB_TIME_INTERVALS;\n const unitWidth = p2.x - p1.x;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill between zones if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n for (let i = 0; i < intervals.length - 1; i++) {\n const x1 = p1.x + unitWidth * intervals[i];\n const x2 = p1.x + unitWidth * intervals[i + 1];\n\n // Alternate fill for visual distinction\n if (i % 2 === 0) {\n ctx.fillRect(\n x1 * pixelRatio,\n 0,\n (x2 - x1) * pixelRatio,\n viewport.height * pixelRatio\n );\n }\n }\n }\n\n // Draw vertical lines\n for (let i = 0; i < intervals.length; i++) {\n const interval = intervals[i];\n const x = p1.x + unitWidth * interval;\n\n // Skip if off screen\n if (x < 0 || x > viewport.width) continue;\n\n const start = { x, y: 0 };\n const end = { x, y: viewport.height };\n\n // Main Fibonacci numbers get solid lines, others get lighter\n const isFibNumber = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89].includes(interval);\n ctx.globalAlpha = isFibNumber ? 1 : 0.5;\n drawLine(ctx, start, end, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw label at top\n if (options.showLabels) {\n const text = String(interval);\n drawText(ctx, text, { x: x + 3, y: 15 }, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { FibTimeZonePaneView } from './fib-time-zone-pane-view';\n\n/**\n * Fibonacci time zone intervals (0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89...)\n */\nexport const FIB_TIME_INTERVALS = [0, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89];\n\n/**\n * FibTimeZone options\n */\nexport interface FibTimeZoneOptions extends DrawingOptions {\n intervals?: number[];\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * FibTimeZone - Vertical lines at Fibonacci time intervals.\n *\n * Features:\n * - Two anchor points define the unit interval\n * - Vertical lines at Fibonacci sequence positions\n * - Optional labels showing interval number\n * - Optional fill between zones\n */\nexport class FibTimeZone extends Drawing {\n readonly type = 'fib-time-zone';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibTimeZoneOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibTimeZoneOptions> = {}\n ) {\n const { intervals, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n intervals: intervals ?? FIB_TIME_INTERVALS,\n showLabels: showLabels ?? true,\n filled: filled ?? true,\n };\n }\n\n get fibOptions(): FibTimeZoneOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibTimeZoneOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibTimeZone.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibTimeZonePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const intervals = this._fibOptions.intervals ?? FIB_TIME_INTERVALS;\n const unitWidth = p2.x - p1.x;\n\n for (const interval of intervals) {\n const x = p1.x + unitWidth * interval;\n\n geometries.push({\n type: 'line',\n start: { x, y: 0 },\n end: { x, y: viewport.height },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const intervals = this._fibOptions.intervals ?? FIB_TIME_INTERVALS;\n const unitWidth = p2.x - p1.x;\n\n for (const interval of intervals) {\n const x = p1.x + unitWidth * interval;\n if (Math.abs(point.x - x) <= FibTimeZone.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibTimeZone(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibTimeZoneOptions>\n ): FibTimeZone {\n return new FibTimeZone(id, [start, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibSpeedFan } from './fib-speed-fan';\nimport { FIB_SPEED_RATIOS } from './fib-speed-fan';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibSpeedFanPaneView implements IPrimitivePaneView {\n private _renderer: FibSpeedFanPaneRenderer;\n\n constructor(drawing: FibSpeedFan) {\n this._renderer = new FibSpeedFanPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibSpeedFanPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibSpeedFan;\n\n constructor(drawing: FibSpeedFan) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const ratios = options.ratios ?? FIB_SPEED_RATIOS;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill between fan lines if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n const sortedRatios = [...ratios].sort((a, b) => a - b);\n\n for (let i = 0; i < sortedRatios.length - 1; i++) {\n const end1 = this._drawing.getFanLineEnd(p1, p2, sortedRatios[i], viewport.width);\n const end2 = this._drawing.getFanLineEnd(p1, p2, sortedRatios[i + 1], viewport.width);\n\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(end1.x * pixelRatio, end1.y * pixelRatio);\n ctx.lineTo(end2.x * pixelRatio, end2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n }\n\n // Draw fan lines\n for (const ratio of ratios) {\n let end = this._drawing.getFanLineEnd(p1, p2, ratio, viewport.width);\n\n if (options.extendLines) {\n const extended = extendLineToViewport(p1, end, viewport.width, viewport.height, false, true);\n end = extended.end;\n }\n\n // Main ratios get solid lines\n const isMainRatio = ratio === 0.382 || ratio === 0.5 || ratio === 0.618 || ratio === 1;\n ctx.globalAlpha = isMainRatio ? 1 : 0.6;\n drawLine(ctx, p1, end, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw label\n if (options.showLabels) {\n const labelPos = {\n x: (p1.x + end.x) / 2,\n y: (p1.y + end.y) / 2,\n };\n const text = ratio === 1 ? '1:1' : `${ratio}`;\n drawText(ctx, text, labelPos, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw main trend line\n drawLine(ctx, p1, p2, pixelRatio);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { FibSpeedFanPaneView } from './fib-speed-fan-pane-view';\n\n/**\n * Fibonacci speed fan ratios\n */\nexport const FIB_SPEED_RATIOS = [0.25, 0.382, 0.5, 0.618, 0.75, 1, 1.618, 2, 4];\n\n/**\n * FibSpeedFan options\n */\nexport interface FibSpeedFanOptions extends DrawingOptions {\n ratios?: number[];\n showLabels?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * FibSpeedFan - Speed/Resistance fan lines at Fibonacci ratios.\n *\n * Features:\n * - Two anchor points define the main trend\n * - Fan lines emanating from first point at Fibonacci slope ratios\n * - Optional labels showing ratio\n * - Optional line extensions\n */\nexport class FibSpeedFan extends Drawing {\n readonly type = 'fib-speed-fan';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibSpeedFanOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibSpeedFanOptions> = {}\n ) {\n const { ratios, showLabels, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n ratios: ratios ?? FIB_SPEED_RATIOS,\n showLabels: showLabels ?? true,\n extendLines: extendLines ?? true,\n filled: filled ?? true,\n };\n }\n\n get fibOptions(): FibSpeedFanOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibSpeedFanOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibSpeedFan.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibSpeedFanPaneView(this)];\n }\n\n /**\n * Calculate fan line endpoint for a given ratio\n */\n getFanLineEnd(p1: Point, p2: Point, ratio: number, viewportWidth: number): Point {\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n\n // Adjust slope by ratio\n const adjustedDy = dy * ratio;\n\n // Extend to viewport edge\n const extendFactor = (viewportWidth - p1.x) / Math.max(1, dx);\n return {\n x: p1.x + dx * extendFactor,\n y: p1.y + adjustedDy * extendFactor,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const ratios = this._fibOptions.ratios ?? FIB_SPEED_RATIOS;\n\n for (const ratio of ratios) {\n const end = this.getFanLineEnd(p1, p2, ratio, viewport.width);\n\n geometries.push({\n type: 'line',\n start: p1,\n end,\n extendRight: this._fibOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const ratios = this._fibOptions.ratios ?? FIB_SPEED_RATIOS;\n\n for (const ratio of ratios) {\n const end = this.getFanLineEnd(p1, p2, ratio, viewport.width);\n if (distanceToLineSegment(point, p1, end) <= FibSpeedFan.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibSpeedFan(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibSpeedFanOptions>\n ): FibSpeedFan {\n return new FibSpeedFan(id, [start, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibTimeExtension } from './fib-time-extension';\nimport { FIB_TIME_EXTENSION_LEVELS } from './fib-time-extension';\nimport { applyStyle, drawLine, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibTimeExtensionPaneView implements IPrimitivePaneView {\n private _renderer: FibTimeExtensionPaneRenderer;\n\n constructor(drawing: FibTimeExtension) {\n this._renderer = new FibTimeExtensionPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibTimeExtensionPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibTimeExtension;\n\n constructor(drawing: FibTimeExtension) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p3 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIB_TIME_EXTENSION_LEVELS;\n const baseTimeWidth = p2.x - p1.x;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill between levels if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n for (let i = 0; i < levels.length - 1; i++) {\n const x1 = p3.x + baseTimeWidth * levels[i];\n const x2 = p3.x + baseTimeWidth * levels[i + 1];\n\n if (i % 2 === 0) {\n ctx.fillRect(\n x1 * pixelRatio,\n 0,\n (x2 - x1) * pixelRatio,\n viewport.height * pixelRatio\n );\n }\n }\n }\n\n // Draw vertical lines at each level\n for (const level of levels) {\n const x = p3.x + baseTimeWidth * level;\n\n if (x < 0 || x > viewport.width) continue;\n\n const start = { x, y: 0 };\n const end = { x, y: viewport.height };\n\n const isMainLevel = level === 0 || level === 0.5 || level === 1 || level === 1.618;\n ctx.globalAlpha = isMainLevel ? 1 : 0.6;\n drawLine(ctx, start, end, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw label\n if (options.showLabels) {\n const text = `${(level * 100).toFixed(1)}%`;\n drawText(ctx, text, { x: x + 3, y: 15 }, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw connecting lines between anchor points\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p1, p2, pixelRatio);\n drawLine(ctx, p2, p3, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { FibTimeExtensionPaneView } from './fib-time-extension-pane-view';\n\n/**\n * Fibonacci time extension levels\n */\nexport const FIB_TIME_EXTENSION_LEVELS = [0, 0.382, 0.5, 0.618, 1, 1.618, 2, 2.618, 4.236];\n\n/**\n * FibTimeExtension options\n */\nexport interface FibTimeExtensionOptions extends DrawingOptions {\n levels?: number[];\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * FibTimeExtension - Trend-Based Fibonacci Time extension.\n *\n * Features:\n * - Three anchor points (start, end of trend, extension point)\n * - Vertical lines at Fibonacci time projections\n * - Optional labels showing level\n * - Optional fill between zones\n */\nexport class FibTimeExtension extends Drawing {\n readonly type = 'fib-time-extension';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibTimeExtensionOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibTimeExtensionOptions> = {}\n ) {\n const { levels, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIB_TIME_EXTENSION_LEVELS,\n showLabels: showLabels ?? true,\n filled: filled ?? true,\n };\n }\n\n get fibOptions(): FibTimeExtensionOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibTimeExtensionOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibTimeExtension.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibTimeExtensionPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIB_TIME_EXTENSION_LEVELS;\n\n // Base time distance (from p1 to p2)\n const baseTimeWidth = p2.x - p1.x;\n\n for (const level of levels) {\n // Project from p3 using the base time width\n const x = p3.x + baseTimeWidth * level;\n\n geometries.push({\n type: 'line',\n start: { x, y: 0 },\n end: { x, y: viewport.height },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return false;\n\n const levels = this._fibOptions.levels ?? FIB_TIME_EXTENSION_LEVELS;\n const baseTimeWidth = p2.x - p1.x;\n\n for (const level of levels) {\n const x = p3.x + baseTimeWidth * level;\n if (Math.abs(point.x - x) <= FibTimeExtension.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibTimeExtension(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n extension: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibTimeExtensionOptions>\n ): FibTimeExtension {\n return new FibTimeExtension(id, [start, end, extension], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibCircles } from './fib-circles';\nimport { FIB_CIRCLE_LEVELS } from './fib-circles';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { applyStyle, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibCirclesPaneView implements IPrimitivePaneView {\n private _renderer: FibCirclesPaneRenderer;\n\n constructor(drawing: FibCircles) {\n this._renderer = new FibCirclesPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibCirclesPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibCircles;\n\n constructor(drawing: FibCircles) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport); // Center\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport); // Radius point\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIB_CIRCLE_LEVELS;\n const baseRadius = distanceBetweenPoints(p1, p2);\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw circles from largest to smallest for proper layering\n const sortedLevels = [...levels].sort((a, b) => b - a);\n\n for (const level of sortedLevels) {\n const radius = baseRadius * level;\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.arc(p1.x * pixelRatio, p1.y * pixelRatio, radius * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n }\n\n // Draw circle outline\n const isMainLevel = level === 0.382 || level === 0.5 || level === 0.618 || level === 1;\n ctx.globalAlpha = isMainLevel ? 1 : 0.6;\n ctx.beginPath();\n ctx.arc(p1.x * pixelRatio, p1.y * pixelRatio, radius * pixelRatio, 0, Math.PI * 2);\n ctx.stroke();\n ctx.globalAlpha = 1;\n\n // Draw label\n if (options.showLabels) {\n const text = `${(level * 100).toFixed(1)}%`;\n const labelPos = { x: p1.x + radius, y: p1.y };\n drawText(ctx, text, labelPos, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw radius line\n ctx.globalAlpha = 0.5;\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.stroke();\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, ArcGeometry } from '../../core/geometry';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { FibCirclesPaneView } from './fib-circles-pane-view';\n\n/**\n * Fibonacci circle levels\n */\nexport const FIB_CIRCLE_LEVELS = [0.236, 0.382, 0.5, 0.618, 0.786, 1, 1.618, 2.618];\n\n/**\n * FibCircles options\n */\nexport interface FibCirclesOptions extends DrawingOptions {\n levels?: number[];\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * FibCircles - Concentric circles at Fibonacci ratios.\n *\n * Features:\n * - Two anchor points (center and radius point)\n * - Concentric circles at Fibonacci ratio distances\n * - Optional labels showing level\n * - Optional fill between circles\n */\nexport class FibCircles extends Drawing {\n readonly type = 'fib-circles';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibCirclesOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibCirclesOptions> = {}\n ) {\n const { levels, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIB_CIRCLE_LEVELS,\n showLabels: showLabels ?? true,\n filled: filled ?? false,\n };\n }\n\n get fibOptions(): FibCirclesOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibCirclesOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibCircles.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibCirclesPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport); // Center\n const p2 = this.anchorToPixel(this._anchors[1], viewport); // Radius point\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIB_CIRCLE_LEVELS;\n const baseRadius = distanceBetweenPoints(p1, p2);\n\n for (const level of levels) {\n const radius = baseRadius * level;\n\n geometries.push({\n type: 'arc',\n center: p1,\n radius,\n startAngle: 0,\n endAngle: Math.PI * 2,\n } as ArcGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const levels = this._fibOptions.levels ?? FIB_CIRCLE_LEVELS;\n const baseRadius = distanceBetweenPoints(p1, p2);\n const distFromCenter = distanceBetweenPoints(point, p1);\n\n for (const level of levels) {\n const radius = baseRadius * level;\n if (Math.abs(distFromCenter - radius) <= FibCircles.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibCircles(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n center: Anchor,\n radiusPoint: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibCirclesOptions>\n ): FibCircles {\n return new FibCircles(id, [center, radiusPoint], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibSpiral } from './fib-spiral';\nimport { GOLDEN_RATIO } from './fib-spiral';\nimport type { Point } from '../../core/types';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class FibSpiralPaneView implements IPrimitivePaneView {\n private _renderer: FibSpiralPaneRenderer;\n\n constructor(drawing: FibSpiral) {\n this._renderer = new FibSpiralPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibSpiralPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibSpiral;\n\n constructor(drawing: FibSpiral) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport); // Center\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport); // Size reference\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const startRadius = distanceBetweenPoints(p1, p2) / GOLDEN_RATIO;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Get spiral points\n const spiralPoints = this._drawing.getSpiralPoints(\n p1,\n startRadius,\n options.rotations ?? 4,\n options.clockwise ?? true\n );\n\n // Draw optional Fibonacci squares\n if (options.showSquares) {\n this.drawFibSquares(ctx, p1, startRadius, options.clockwise ?? true, pixelRatio);\n }\n\n // Draw spiral\n if (spiralPoints.length > 1) {\n ctx.beginPath();\n ctx.moveTo(spiralPoints[0].x * pixelRatio, spiralPoints[0].y * pixelRatio);\n\n for (let i = 1; i < spiralPoints.length; i++) {\n ctx.lineTo(spiralPoints[i].x * pixelRatio, spiralPoints[i].y * pixelRatio);\n }\n\n ctx.stroke();\n }\n\n // Draw radius line\n ctx.globalAlpha = 0.5;\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.stroke();\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n\n private drawFibSquares(\n ctx: CanvasRenderingContext2D,\n center: Point,\n startSize: number,\n _clockwise: boolean,\n pixelRatio: number\n ): void {\n ctx.globalAlpha = 0.3;\n\n // Draw Fibonacci sequence squares\n const fibSizes = [1, 1, 2, 3, 5, 8];\n let x = center.x;\n let y = center.y;\n const scale = startSize / 8; // Normalize to largest Fibonacci number\n\n for (let i = 0; i < fibSizes.length; i++) {\n const size = fibSizes[i] * scale;\n ctx.strokeRect(\n x * pixelRatio,\n y * pixelRatio,\n size * pixelRatio,\n size * pixelRatio\n );\n\n // Move to next position (simplified spiral layout)\n if (i % 4 === 0) x += size;\n else if (i % 4 === 1) y += size;\n else if (i % 4 === 2) x -= size;\n else y -= size;\n }\n\n ctx.globalAlpha = 1;\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { FibSpiralPaneView } from './fib-spiral-pane-view';\n\n/**\n * Golden ratio for spiral\n */\nexport const GOLDEN_RATIO = 1.618033988749895;\n\n/**\n * FibSpiral options\n */\nexport interface FibSpiralOptions extends DrawingOptions {\n rotations?: number;\n clockwise?: boolean;\n showSquares?: boolean;\n}\n\n/**\n * FibSpiral - Golden spiral based on Fibonacci sequence.\n *\n * Features:\n * - Two anchor points (center and size reference)\n * - Logarithmic spiral with golden ratio growth\n * - Optional Fibonacci squares overlay\n * - Configurable rotation direction\n */\nexport class FibSpiral extends Drawing {\n readonly type = 'fib-spiral';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 8;\n\n private _fibOptions: FibSpiralOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibSpiralOptions> = {}\n ) {\n const { rotations, clockwise, showSquares, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n rotations: rotations ?? 4,\n clockwise: clockwise ?? true,\n showSquares: showSquares ?? false,\n };\n }\n\n get fibOptions(): FibSpiralOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibSpiralOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibSpiral.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibSpiralPaneView(this)];\n }\n\n /**\n * Generate points along the golden spiral\n */\n getSpiralPoints(center: Point, startRadius: number, rotations: number, clockwise: boolean): Point[] {\n const points: Point[] = [];\n const segments = rotations * 90; // Points per quarter rotation\n const b = Math.log(GOLDEN_RATIO) / (Math.PI / 2); // Growth factor\n\n for (let i = 0; i <= segments; i++) {\n const theta = (i / segments) * rotations * Math.PI * 2;\n const r = startRadius * Math.exp(b * theta);\n\n const angle = clockwise ? -theta : theta;\n points.push({\n x: center.x + r * Math.cos(angle),\n y: center.y + r * Math.sin(angle),\n });\n }\n\n return points;\n }\n\n computeGeometry(_viewport: Viewport): Geometry[] {\n // Spiral uses custom rendering, not standard geometry\n return [];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const startRadius = distanceBetweenPoints(p1, p2) / GOLDEN_RATIO;\n const spiralPoints = this.getSpiralPoints(\n p1,\n startRadius,\n this._fibOptions.rotations ?? 4,\n this._fibOptions.clockwise ?? true\n );\n\n // Check if near any segment of the spiral\n for (let i = 0; i < spiralPoints.length - 1; i++) {\n const segStart = spiralPoints[i];\n const segEnd = spiralPoints[i + 1];\n\n // Simple distance check to line segment\n const dx = segEnd.x - segStart.x;\n const dy = segEnd.y - segStart.y;\n const len = Math.sqrt(dx * dx + dy * dy);\n\n if (len === 0) continue;\n\n const t = Math.max(0, Math.min(1,\n ((point.x - segStart.x) * dx + (point.y - segStart.y) * dy) / (len * len)\n ));\n\n const projX = segStart.x + t * dx;\n const projY = segStart.y + t * dy;\n const dist = Math.sqrt((point.x - projX) ** 2 + (point.y - projY) ** 2);\n\n if (dist <= FibSpiral.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibSpiral(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n center: Anchor,\n sizeRef: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibSpiralOptions>\n ): FibSpiral {\n return new FibSpiral(id, [center, sizeRef], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibArcs } from './fib-arcs';\nimport { FIB_ARC_LEVELS } from './fib-arcs';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibArcsPaneView implements IPrimitivePaneView {\n private _renderer: FibArcsPaneRenderer;\n\n constructor(drawing: FibArcs) {\n this._renderer = new FibArcsPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibArcsPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibArcs;\n\n constructor(drawing: FibArcs) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIB_ARC_LEVELS;\n const baseRadius = distanceBetweenPoints(p1, p2);\n\n // Calculate arc direction\n const angle = Math.atan2(p2.y - p1.y, p2.x - p1.x);\n const startAngle = options.fullCircle ? 0 : angle - Math.PI / 2;\n const endAngle = options.fullCircle ? Math.PI * 2 : angle + Math.PI / 2;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw arcs\n for (const level of levels) {\n const radius = baseRadius * level;\n\n const isMainLevel = level === 0.382 || level === 0.5 || level === 0.618 || level === 1;\n ctx.globalAlpha = isMainLevel ? 1 : 0.6;\n\n ctx.beginPath();\n ctx.arc(\n p1.x * pixelRatio,\n p1.y * pixelRatio,\n radius * pixelRatio,\n startAngle,\n endAngle\n );\n ctx.stroke();\n ctx.globalAlpha = 1;\n\n // Draw label\n if (options.showLabels) {\n const labelAngle = (startAngle + endAngle) / 2;\n const labelPos = {\n x: p1.x + radius * Math.cos(labelAngle),\n y: p1.y + radius * Math.sin(labelAngle),\n };\n const text = `${(level * 100).toFixed(1)}%`;\n drawText(ctx, text, labelPos, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw baseline\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, ArcGeometry } from '../../core/geometry';\nimport { distanceBetweenPoints } from '../../core/geometry';\nimport { FibArcsPaneView } from './fib-arcs-pane-view';\n\n/**\n * Fibonacci arc levels\n */\nexport const FIB_ARC_LEVELS = [0.236, 0.382, 0.5, 0.618, 0.786, 1];\n\n/**\n * FibArcs options\n */\nexport interface FibArcsOptions extends DrawingOptions {\n levels?: number[];\n showLabels?: boolean;\n fullCircle?: boolean;\n}\n\n/**\n * FibArcs - Speed/Resistance arcs at Fibonacci ratios.\n *\n * Features:\n * - Two anchor points (pivot and extent)\n * - Semi-circular or full arcs at Fibonacci distances\n * - Optional labels showing level\n * - Can show half or full circles\n */\nexport class FibArcs extends Drawing {\n readonly type = 'fib-arcs';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibArcsOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibArcsOptions> = {}\n ) {\n const { levels, showLabels, fullCircle, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIB_ARC_LEVELS,\n showLabels: showLabels ?? true,\n fullCircle: fullCircle ?? false,\n };\n }\n\n get fibOptions(): FibArcsOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibArcsOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibArcs.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibArcsPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIB_ARC_LEVELS;\n const baseRadius = distanceBetweenPoints(p1, p2);\n\n // Calculate arc direction based on anchor positions\n const angle = Math.atan2(p2.y - p1.y, p2.x - p1.x);\n const startAngle = this._fibOptions.fullCircle ? 0 : angle - Math.PI / 2;\n const endAngle = this._fibOptions.fullCircle ? Math.PI * 2 : angle + Math.PI / 2;\n\n for (const level of levels) {\n const radius = baseRadius * level;\n\n geometries.push({\n type: 'arc',\n center: p1,\n radius,\n startAngle,\n endAngle,\n } as ArcGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const levels = this._fibOptions.levels ?? FIB_ARC_LEVELS;\n const baseRadius = distanceBetweenPoints(p1, p2);\n const distFromCenter = distanceBetweenPoints(point, p1);\n\n for (const level of levels) {\n const radius = baseRadius * level;\n if (Math.abs(distFromCenter - radius) <= FibArcs.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibArcs(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n pivot: Anchor,\n extent: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibArcsOptions>\n ): FibArcs {\n return new FibArcs(id, [pivot, extent], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FibWedge } from './fib-wedge';\nimport { FIB_WEDGE_LEVELS } from './fib-wedge';\nimport { applyStyle, drawLine, drawControlPoints, drawText } from '../../rendering/canvas-utils';\n\nexport class FibWedgePaneView implements IPrimitivePaneView {\n private _renderer: FibWedgePaneRenderer;\n\n constructor(drawing: FibWedge) {\n this._renderer = new FibWedgePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FibWedgePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FibWedge;\n\n constructor(drawing: FibWedge) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const apex = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!apex || !p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? FIB_WEDGE_LEVELS;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(apex.x * pixelRatio, apex.y * pixelRatio);\n ctx.lineTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw boundary lines\n drawLine(ctx, apex, p1, pixelRatio);\n drawLine(ctx, apex, p2, pixelRatio);\n\n // Draw intermediate Fibonacci lines\n for (const level of levels) {\n if (level === 0 || level === 1) continue;\n\n const end = this._drawing.getWedgeLineEnd(apex, p1, p2, level);\n\n const isMainLevel = level === 0.382 || level === 0.5 || level === 0.618;\n ctx.globalAlpha = isMainLevel ? 0.8 : 0.5;\n drawLine(ctx, apex, end, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw label\n if (options.showLabels) {\n const labelPos = {\n x: (apex.x + end.x) / 2,\n y: (apex.y + end.y) / 2,\n };\n const text = `${(level * 100).toFixed(1)}%`;\n drawText(ctx, text, labelPos, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw base line connecting p1 and p2\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { FibWedgePaneView } from './fib-wedge-pane-view';\n\n/**\n * Fibonacci wedge levels\n */\nexport const FIB_WEDGE_LEVELS = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1];\n\n/**\n * FibWedge options\n */\nexport interface FibWedgeOptions extends DrawingOptions {\n levels?: number[];\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * FibWedge - Wedge pattern with Fibonacci level lines.\n *\n * Features:\n * - Three anchor points (apex and two boundary points)\n * - Lines radiating from apex at Fibonacci angle divisions\n * - Optional labels showing level\n * - Optional fill between lines\n */\nexport class FibWedge extends Drawing {\n readonly type = 'fib-wedge';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: FibWedgeOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FibWedgeOptions> = {}\n ) {\n const { levels, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? FIB_WEDGE_LEVELS,\n showLabels: showLabels ?? true,\n filled: filled ?? true,\n };\n }\n\n get fibOptions(): FibWedgeOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<FibWedgeOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= FibWedge.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FibWedgePaneView(this)];\n }\n\n /**\n * Get the endpoint for a wedge line at a given level\n */\n getWedgeLineEnd(_apex: Point, p1: Point, p2: Point, level: number): Point {\n // Interpolate between p1 and p2 based on level\n return {\n x: p1.x + (p2.x - p1.x) * level,\n y: p1.y + (p2.y - p1.y) * level,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const apex = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!apex || !p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? FIB_WEDGE_LEVELS;\n\n // Add boundary lines\n geometries.push({\n type: 'line',\n start: apex,\n end: p1,\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: apex,\n end: p2,\n } as LineGeometry);\n\n // Add intermediate Fibonacci lines\n for (const level of levels) {\n if (level === 0 || level === 1) continue; // Skip boundaries\n\n const end = this.getWedgeLineEnd(apex, p1, p2, level);\n geometries.push({\n type: 'line',\n start: apex,\n end,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const apex = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!apex || !p1 || !p2) return false;\n\n // Check boundary lines\n if (distanceToLineSegment(point, apex, p1) <= FibWedge.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, apex, p2) <= FibWedge.HIT_THRESHOLD) return true;\n\n // Check intermediate lines\n const levels = this._fibOptions.levels ?? FIB_WEDGE_LEVELS;\n for (const level of levels) {\n if (level === 0 || level === 1) continue;\n\n const end = this.getWedgeLineEnd(apex, p1, p2, level);\n if (distanceToLineSegment(point, apex, end) <= FibWedge.HIT_THRESHOLD) return true;\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new FibWedge(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n apex: Anchor,\n boundary1: Anchor,\n boundary2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<FibWedgeOptions>\n ): FibWedge {\n return new FibWedge(id, [apex, boundary1, boundary2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Pitchfan } from './pitchfan';\nimport { PITCHFAN_LEVELS } from './pitchfan';\nimport { midpoint, extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine, drawText } from '../../rendering/canvas-utils';\n\nexport class PitchfanPaneView implements IPrimitivePaneView {\n private _renderer: PitchfanPaneRenderer;\n\n constructor(drawing: Pitchfan) {\n this._renderer = new PitchfanPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PitchfanPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Pitchfan;\n\n constructor(drawing: Pitchfan) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p0 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return;\n\n const options = this._drawing.fibOptions;\n const levels = options.levels ?? PITCHFAN_LEVELS;\n const mid = midpoint(p1, p2);\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill between fan lines if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n const sortedLevels = [...levels].sort((a, b) => a - b);\n\n for (let i = 0; i < sortedLevels.length - 1; i++) {\n const end1 = this._drawing.getFanLineEnd(p0, p1, p2, sortedLevels[i]);\n const end2 = this._drawing.getFanLineEnd(p0, p1, p2, sortedLevels[i + 1]);\n\n ctx.beginPath();\n ctx.moveTo(p0.x * pixelRatio, p0.y * pixelRatio);\n ctx.lineTo(end1.x * pixelRatio, end1.y * pixelRatio);\n ctx.lineTo(end2.x * pixelRatio, end2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n }\n\n // Draw median line\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n let medianEnd = { x: p0.x + dx * 3, y: p0.y + dy * 3 };\n\n if (options.extendLines) {\n const extended = extendLineToViewport(p0, medianEnd, viewport.width, viewport.height, false, true);\n medianEnd = extended.end;\n }\n\n drawDashedLine(ctx, p0, medianEnd, [5, 5], pixelRatio);\n\n // Draw fan lines\n for (const level of levels) {\n let end = this._drawing.getFanLineEnd(p0, p1, p2, level);\n\n if (options.extendLines) {\n const extended = extendLineToViewport(p0, end, viewport.width, viewport.height, false, true);\n end = extended.end;\n }\n\n const isMainLevel = level === 0.382 || level === 0.5 || level === 0.618;\n ctx.globalAlpha = isMainLevel ? 1 : 0.6;\n drawLine(ctx, p0, end, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw label\n if (options.showLabels) {\n const labelPos = {\n x: (p0.x + end.x) / 2,\n y: (p0.y + end.y) / 2,\n };\n const text = `${(level * 100).toFixed(1)}%`;\n drawText(ctx, text, labelPos, '10px sans-serif', this._drawing.style.lineColor || '#fff', 'left', 'middle', pixelRatio);\n }\n }\n\n // Draw connecting lines to anchors\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p0, p1, pixelRatio);\n drawLine(ctx, p0, p2, pixelRatio);\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, midpoint } from '../../core/geometry';\nimport { PitchfanPaneView } from './pitchfan-pane-view';\n\n/**\n * Pitchfan levels (Fibonacci-based)\n */\nexport const PITCHFAN_LEVELS = [0.236, 0.382, 0.5, 0.618, 0.786, 1];\n\n/**\n * Pitchfan options\n */\nexport interface PitchfanOptions extends DrawingOptions {\n levels?: number[];\n showLabels?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * Pitchfan - Fan lines from a pitchfork-style base at Fibonacci levels.\n *\n * Features:\n * - Three anchor points (pivot and two swing points)\n * - Fan lines radiating from pivot through Fibonacci divisions\n * - Similar to pitchfork but with multiple fan lines\n * - Optional line extensions\n */\nexport class Pitchfan extends Drawing {\n readonly type = 'pitchfan';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _fibOptions: PitchfanOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PitchfanOptions> = {}\n ) {\n const { levels, showLabels, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._fibOptions = {\n ...this._options,\n levels: levels ?? PITCHFAN_LEVELS,\n showLabels: showLabels ?? true,\n extendLines: extendLines ?? true,\n filled: filled ?? true,\n };\n }\n\n get fibOptions(): PitchfanOptions {\n return this._fibOptions;\n }\n\n setFibOptions(options: Partial<PitchfanOptions>): void {\n this._fibOptions = { ...this._fibOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Pitchfan.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PitchfanPaneView(this)];\n }\n\n /**\n * Get the fan line endpoint for a given level\n */\n getFanLineEnd(pivot: Point, p1: Point, p2: Point, level: number): Point {\n // Get point on the p1-p2 line at the given level\n const targetPoint = {\n x: p1.x + (p2.x - p1.x) * level,\n y: p1.y + (p2.y - p1.y) * level,\n };\n\n // Extend from pivot through target point\n const dx = targetPoint.x - pivot.x;\n const dy = targetPoint.y - pivot.y;\n\n return {\n x: pivot.x + dx * 3,\n y: pivot.y + dy * 3,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport); // Pivot\n const p1 = this.anchorToPixel(this._anchors[1], viewport); // Swing 1\n const p2 = this.anchorToPixel(this._anchors[2], viewport); // Swing 2\n\n if (!p0 || !p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const levels = this._fibOptions.levels ?? PITCHFAN_LEVELS;\n\n // Median line (through midpoint)\n const mid = midpoint(p1, p2);\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n const medianEnd = { x: p0.x + dx * 3, y: p0.y + dy * 3 };\n\n geometries.push({\n type: 'line',\n start: p0,\n end: medianEnd,\n extendRight: this._fibOptions.extendLines,\n } as LineGeometry);\n\n // Fan lines at Fibonacci levels\n for (const level of levels) {\n const end = this.getFanLineEnd(p0, p1, p2, level);\n\n geometries.push({\n type: 'line',\n start: p0,\n end,\n extendRight: this._fibOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return false;\n\n // Check median line\n const mid = midpoint(p1, p2);\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n const medianEnd = { x: p0.x + dx * 3, y: p0.y + dy * 3 };\n if (distanceToLineSegment(point, p0, medianEnd) <= Pitchfan.HIT_THRESHOLD) return true;\n\n // Check fan lines\n const levels = this._fibOptions.levels ?? PITCHFAN_LEVELS;\n for (const level of levels) {\n const end = this.getFanLineEnd(p0, p1, p2, level);\n if (distanceToLineSegment(point, p0, end) <= Pitchfan.HIT_THRESHOLD) return true;\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new Pitchfan(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._fibOptions }\n );\n }\n\n static create(\n id: string,\n pivot: Anchor,\n swing1: Anchor,\n swing2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<PitchfanOptions>\n ): Pitchfan {\n return new Pitchfan(id, [pivot, swing1, swing2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { AndrewsPitchfork } from './andrews-pitchfork';\nimport { midpoint, extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class AndrewsPitchforkPaneView implements IPrimitivePaneView {\n private _renderer: AndrewsPitchforkPaneRenderer;\n\n constructor(drawing: AndrewsPitchfork) {\n this._renderer = new AndrewsPitchforkPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass AndrewsPitchforkPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: AndrewsPitchfork;\n\n constructor(drawing: AndrewsPitchfork) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p0 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return;\n\n const options = this._drawing.pitchforkOptions;\n const mid = midpoint(p1, p2);\n\n // Direction vector\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Calculate extended endpoints\n const medianEnd = { x: p0.x + dx * 3, y: p0.y + dy * 3 };\n const p1End = { x: p1.x + dx * 3, y: p1.y + dy * 3 };\n const p2End = { x: p2.x + dx * 3, y: p2.y + dy * 3 };\n\n // Extend if needed\n let drawMedianEnd = medianEnd;\n let drawP1End = p1End;\n let drawP2End = p2End;\n\n if (options.extendLines) {\n const extMedian = extendLineToViewport(p0, medianEnd, viewport.width, viewport.height, false, true);\n const extP1 = extendLineToViewport(p1, p1End, viewport.width, viewport.height, false, true);\n const extP2 = extendLineToViewport(p2, p2End, viewport.width, viewport.height, false, true);\n drawMedianEnd = extMedian.end;\n drawP1End = extP1.end;\n drawP2End = extP2.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(drawP1End.x * pixelRatio, drawP1End.y * pixelRatio);\n ctx.lineTo(drawP2End.x * pixelRatio, drawP2End.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw median line\n if (options.showMedianLine) {\n drawDashedLine(ctx, p0, drawMedianEnd, [5, 5], pixelRatio);\n }\n\n // Draw outer lines\n if (options.showOuterLines) {\n drawLine(ctx, p1, drawP1End, pixelRatio);\n drawLine(ctx, p2, drawP2End, pixelRatio);\n }\n\n // Draw connecting lines to anchors\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p0, p1, pixelRatio);\n drawLine(ctx, p0, p2, pixelRatio);\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, midpoint } from '../../core/geometry';\nimport { AndrewsPitchforkPaneView } from './andrews-pitchfork-pane-view';\n\n/**\n * AndrewsPitchfork options\n */\nexport interface AndrewsPitchforkOptions extends DrawingOptions {\n showMedianLine?: boolean;\n showOuterLines?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * AndrewsPitchfork - Andrews' Pitchfork pattern for channel analysis.\n *\n * Features:\n * - Three anchor points (pivot, and two swing points)\n * - Median line from pivot through midpoint of swings\n * - Parallel outer lines through swing points\n * - Optional fill between lines\n */\nexport class AndrewsPitchfork extends Drawing {\n readonly type = 'andrews-pitchfork';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _pitchforkOptions: AndrewsPitchforkOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<AndrewsPitchforkOptions> = {}\n ) {\n const { showMedianLine, showOuterLines, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._pitchforkOptions = {\n ...this._options,\n showMedianLine: showMedianLine ?? true,\n showOuterLines: showOuterLines ?? true,\n extendLines: extendLines ?? true,\n filled: filled ?? true,\n };\n }\n\n get pitchforkOptions(): AndrewsPitchforkOptions {\n return this._pitchforkOptions;\n }\n\n setPitchforkOptions(options: Partial<AndrewsPitchforkOptions>): void {\n this._pitchforkOptions = { ...this._pitchforkOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= AndrewsPitchfork.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new AndrewsPitchforkPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport); // Pivot\n const p1 = this.anchorToPixel(this._anchors[1], viewport); // Swing 1\n const p2 = this.anchorToPixel(this._anchors[2], viewport); // Swing 2\n\n if (!p0 || !p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n\n // Midpoint of p1 and p2\n const mid = midpoint(p1, p2);\n\n // Median line: from p0 through mid\n if (this._pitchforkOptions.showMedianLine) {\n geometries.push({\n type: 'line',\n start: p0,\n end: mid,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n // Calculate direction vector for median line\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n\n // Outer lines parallel to median, through p1 and p2\n if (this._pitchforkOptions.showOuterLines) {\n // Upper line through p1\n const p1End = { x: p1.x + dx * 2, y: p1.y + dy * 2 };\n geometries.push({\n type: 'line',\n start: p1,\n end: p1End,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n\n // Lower line through p2\n const p2End = { x: p2.x + dx * 2, y: p2.y + dy * 2 };\n geometries.push({\n type: 'line',\n start: p2,\n end: p2End,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return false;\n\n const mid = midpoint(p1, p2);\n\n // Check median line\n if (distanceToLineSegment(point, p0, mid) <= AndrewsPitchfork.HIT_THRESHOLD) return true;\n\n // Check outer lines\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n\n const p1End = { x: p1.x + dx * 2, y: p1.y + dy * 2 };\n const p2End = { x: p2.x + dx * 2, y: p2.y + dy * 2 };\n\n if (distanceToLineSegment(point, p1, p1End) <= AndrewsPitchfork.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, p2, p2End) <= AndrewsPitchfork.HIT_THRESHOLD) return true;\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new AndrewsPitchfork(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._pitchforkOptions }\n );\n }\n\n static create(\n id: string,\n pivot: Anchor,\n swing1: Anchor,\n swing2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<AndrewsPitchforkOptions>\n ): AndrewsPitchfork {\n return new AndrewsPitchfork(id, [pivot, swing1, swing2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { SchiffPitchfork } from './schiff-pitchfork';\nimport { midpoint, extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class SchiffPitchforkPaneView implements IPrimitivePaneView {\n private _renderer: SchiffPitchforkPaneRenderer;\n\n constructor(drawing: SchiffPitchfork) {\n this._renderer = new SchiffPitchforkPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass SchiffPitchforkPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: SchiffPitchfork;\n\n constructor(drawing: SchiffPitchfork) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p0 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return;\n\n const options = this._drawing.pitchforkOptions;\n\n // Schiff pivot: midpoint between p0 and p1\n const schiffPivot = this._drawing.getSchiffPivot(p0, p1);\n const mid = midpoint(p1, p2);\n\n // Direction vector\n const dx = mid.x - schiffPivot.x;\n const dy = mid.y - schiffPivot.y;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Calculate extended endpoints\n const medianEnd = { x: schiffPivot.x + dx * 3, y: schiffPivot.y + dy * 3 };\n const p1End = { x: p1.x + dx * 3, y: p1.y + dy * 3 };\n const p2End = { x: p2.x + dx * 3, y: p2.y + dy * 3 };\n\n // Extend if needed\n let drawMedianEnd = medianEnd;\n let drawP1End = p1End;\n let drawP2End = p2End;\n\n if (options.extendLines) {\n const extMedian = extendLineToViewport(schiffPivot, medianEnd, viewport.width, viewport.height, false, true);\n const extP1 = extendLineToViewport(p1, p1End, viewport.width, viewport.height, false, true);\n const extP2 = extendLineToViewport(p2, p2End, viewport.width, viewport.height, false, true);\n drawMedianEnd = extMedian.end;\n drawP1End = extP1.end;\n drawP2End = extP2.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(drawP1End.x * pixelRatio, drawP1End.y * pixelRatio);\n ctx.lineTo(drawP2End.x * pixelRatio, drawP2End.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw median line\n if (options.showMedianLine) {\n drawDashedLine(ctx, schiffPivot, drawMedianEnd, [5, 5], pixelRatio);\n }\n\n // Draw outer lines\n if (options.showOuterLines) {\n drawLine(ctx, p1, drawP1End, pixelRatio);\n drawLine(ctx, p2, drawP2End, pixelRatio);\n }\n\n // Draw connecting lines to anchors\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p0, p1, pixelRatio);\n drawLine(ctx, p0, p2, pixelRatio);\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, midpoint } from '../../core/geometry';\nimport { SchiffPitchforkPaneView } from './schiff-pitchfork-pane-view';\n\n/**\n * SchiffPitchfork options\n */\nexport interface SchiffPitchforkOptions extends DrawingOptions {\n showMedianLine?: boolean;\n showOuterLines?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * SchiffPitchfork - Schiff Pitchfork variant.\n *\n * The Schiff Pitchfork differs from Andrews' Pitchfork in that the median line\n * starts from the midpoint between the pivot (p0) and the first swing point (p1),\n * rather than from the pivot itself. This creates a less steep median line.\n *\n * Features:\n * - Three anchor points (pivot, and two swing points)\n * - Median line from midpoint(p0,p1) through midpoint of swings\n * - Parallel outer lines through swing points\n * - Optional fill between lines\n */\nexport class SchiffPitchfork extends Drawing {\n readonly type = 'schiff-pitchfork';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _pitchforkOptions: SchiffPitchforkOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<SchiffPitchforkOptions> = {}\n ) {\n const { showMedianLine, showOuterLines, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._pitchforkOptions = {\n ...this._options,\n showMedianLine: showMedianLine ?? true,\n showOuterLines: showOuterLines ?? true,\n extendLines: extendLines ?? true,\n filled: filled ?? true,\n };\n }\n\n get pitchforkOptions(): SchiffPitchforkOptions {\n return this._pitchforkOptions;\n }\n\n setPitchforkOptions(options: Partial<SchiffPitchforkOptions>): void {\n this._pitchforkOptions = { ...this._pitchforkOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= SchiffPitchfork.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new SchiffPitchforkPaneView(this)];\n }\n\n /**\n * Calculate the Schiff pivot point (midpoint between p0 and p1)\n */\n getSchiffPivot(p0: Point, p1: Point): Point {\n return midpoint(p0, p1);\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport); // Pivot\n const p1 = this.anchorToPixel(this._anchors[1], viewport); // Swing 1\n const p2 = this.anchorToPixel(this._anchors[2], viewport); // Swing 2\n\n if (!p0 || !p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n\n // Schiff pivot: midpoint between p0 and p1\n const schiffPivot = this.getSchiffPivot(p0, p1);\n\n // Midpoint of p1 and p2\n const mid = midpoint(p1, p2);\n\n // Median line: from schiffPivot through mid\n if (this._pitchforkOptions.showMedianLine) {\n geometries.push({\n type: 'line',\n start: schiffPivot,\n end: mid,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n // Calculate direction vector for median line\n const dx = mid.x - schiffPivot.x;\n const dy = mid.y - schiffPivot.y;\n\n // Outer lines parallel to median, through p1 and p2\n if (this._pitchforkOptions.showOuterLines) {\n const p1End = { x: p1.x + dx * 2, y: p1.y + dy * 2 };\n geometries.push({\n type: 'line',\n start: p1,\n end: p1End,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n\n const p2End = { x: p2.x + dx * 2, y: p2.y + dy * 2 };\n geometries.push({\n type: 'line',\n start: p2,\n end: p2End,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return false;\n\n const schiffPivot = this.getSchiffPivot(p0, p1);\n const mid = midpoint(p1, p2);\n\n // Check median line\n if (distanceToLineSegment(point, schiffPivot, mid) <= SchiffPitchfork.HIT_THRESHOLD) return true;\n\n // Check outer lines\n const dx = mid.x - schiffPivot.x;\n const dy = mid.y - schiffPivot.y;\n\n const p1End = { x: p1.x + dx * 2, y: p1.y + dy * 2 };\n const p2End = { x: p2.x + dx * 2, y: p2.y + dy * 2 };\n\n if (distanceToLineSegment(point, p1, p1End) <= SchiffPitchfork.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, p2, p2End) <= SchiffPitchfork.HIT_THRESHOLD) return true;\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new SchiffPitchfork(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._pitchforkOptions }\n );\n }\n\n static create(\n id: string,\n pivot: Anchor,\n swing1: Anchor,\n swing2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<SchiffPitchforkOptions>\n ): SchiffPitchfork {\n return new SchiffPitchfork(id, [pivot, swing1, swing2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ModifiedSchiffPitchfork } from './modified-schiff-pitchfork';\nimport { midpoint, extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class ModifiedSchiffPitchforkPaneView implements IPrimitivePaneView {\n private _renderer: ModifiedSchiffPitchforkPaneRenderer;\n\n constructor(drawing: ModifiedSchiffPitchfork) {\n this._renderer = new ModifiedSchiffPitchforkPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ModifiedSchiffPitchforkPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ModifiedSchiffPitchfork;\n\n constructor(drawing: ModifiedSchiffPitchfork) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p0 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return;\n\n const options = this._drawing.pitchforkOptions;\n\n // Modified Schiff pivot\n const modifiedPivot = this._drawing.getModifiedSchiffPivot(p0, p1);\n const mid = midpoint(p1, p2);\n\n // Direction vector\n const dx = mid.x - modifiedPivot.x;\n const dy = mid.y - modifiedPivot.y;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Calculate extended endpoints\n const medianEnd = { x: modifiedPivot.x + dx * 3, y: modifiedPivot.y + dy * 3 };\n const p1End = { x: p1.x + dx * 3, y: p1.y + dy * 3 };\n const p2End = { x: p2.x + dx * 3, y: p2.y + dy * 3 };\n\n // Extend if needed\n let drawMedianEnd = medianEnd;\n let drawP1End = p1End;\n let drawP2End = p2End;\n\n if (options.extendLines) {\n const extMedian = extendLineToViewport(modifiedPivot, medianEnd, viewport.width, viewport.height, false, true);\n const extP1 = extendLineToViewport(p1, p1End, viewport.width, viewport.height, false, true);\n const extP2 = extendLineToViewport(p2, p2End, viewport.width, viewport.height, false, true);\n drawMedianEnd = extMedian.end;\n drawP1End = extP1.end;\n drawP2End = extP2.end;\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(drawP1End.x * pixelRatio, drawP1End.y * pixelRatio);\n ctx.lineTo(drawP2End.x * pixelRatio, drawP2End.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw median line\n if (options.showMedianLine) {\n drawDashedLine(ctx, modifiedPivot, drawMedianEnd, [5, 5], pixelRatio);\n }\n\n // Draw outer lines\n if (options.showOuterLines) {\n drawLine(ctx, p1, drawP1End, pixelRatio);\n drawLine(ctx, p2, drawP2End, pixelRatio);\n }\n\n // Draw connecting lines to anchors\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p0, p1, pixelRatio);\n drawLine(ctx, p0, p2, pixelRatio);\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, midpoint } from '../../core/geometry';\nimport { ModifiedSchiffPitchforkPaneView } from './modified-schiff-pitchfork-pane-view';\n\n/**\n * ModifiedSchiffPitchfork options\n */\nexport interface ModifiedSchiffPitchforkOptions extends DrawingOptions {\n showMedianLine?: boolean;\n showOuterLines?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * ModifiedSchiffPitchfork - Modified Schiff Pitchfork variant.\n *\n * The Modified Schiff Pitchfork differs from the standard Schiff in that\n * the median line starts from the midpoint of a vertical line drawn from\n * the pivot point (p0) down/up to the price level of the first swing point (p1).\n * This creates a more horizontal median line than both Andrews' and Schiff.\n *\n * Features:\n * - Three anchor points (pivot, and two swing points)\n * - Median line from modified pivot through midpoint of swings\n * - Parallel outer lines through swing points\n * - Optional fill between lines\n */\nexport class ModifiedSchiffPitchfork extends Drawing {\n readonly type = 'modified-schiff-pitchfork';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _pitchforkOptions: ModifiedSchiffPitchforkOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ModifiedSchiffPitchforkOptions> = {}\n ) {\n const { showMedianLine, showOuterLines, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._pitchforkOptions = {\n ...this._options,\n showMedianLine: showMedianLine ?? true,\n showOuterLines: showOuterLines ?? true,\n extendLines: extendLines ?? true,\n filled: filled ?? true,\n };\n }\n\n get pitchforkOptions(): ModifiedSchiffPitchforkOptions {\n return this._pitchforkOptions;\n }\n\n setPitchforkOptions(options: Partial<ModifiedSchiffPitchforkOptions>): void {\n this._pitchforkOptions = { ...this._pitchforkOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= ModifiedSchiffPitchfork.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ModifiedSchiffPitchforkPaneView(this)];\n }\n\n /**\n * Calculate the Modified Schiff pivot point.\n * It's the midpoint between p0 and a point directly below/above p0 at p1's y-level.\n */\n getModifiedSchiffPivot(p0: Point, p1: Point): Point {\n // Point at p0.x but at p1.y level\n const verticalPoint = { x: p0.x, y: p1.y };\n // Midpoint between p0 and this vertical point\n return midpoint(p0, verticalPoint);\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport); // Pivot\n const p1 = this.anchorToPixel(this._anchors[1], viewport); // Swing 1\n const p2 = this.anchorToPixel(this._anchors[2], viewport); // Swing 2\n\n if (!p0 || !p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n\n // Modified Schiff pivot\n const modifiedPivot = this.getModifiedSchiffPivot(p0, p1);\n\n // Midpoint of p1 and p2\n const mid = midpoint(p1, p2);\n\n // Median line: from modifiedPivot through mid\n if (this._pitchforkOptions.showMedianLine) {\n geometries.push({\n type: 'line',\n start: modifiedPivot,\n end: mid,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n // Calculate direction vector for median line\n const dx = mid.x - modifiedPivot.x;\n const dy = mid.y - modifiedPivot.y;\n\n // Outer lines parallel to median, through p1 and p2\n if (this._pitchforkOptions.showOuterLines) {\n const p1End = { x: p1.x + dx * 2, y: p1.y + dy * 2 };\n geometries.push({\n type: 'line',\n start: p1,\n end: p1End,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n\n const p2End = { x: p2.x + dx * 2, y: p2.y + dy * 2 };\n geometries.push({\n type: 'line',\n start: p2,\n end: p2End,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return false;\n\n const modifiedPivot = this.getModifiedSchiffPivot(p0, p1);\n const mid = midpoint(p1, p2);\n\n // Check median line\n if (distanceToLineSegment(point, modifiedPivot, mid) <= ModifiedSchiffPitchfork.HIT_THRESHOLD) return true;\n\n // Check outer lines\n const dx = mid.x - modifiedPivot.x;\n const dy = mid.y - modifiedPivot.y;\n\n const p1End = { x: p1.x + dx * 2, y: p1.y + dy * 2 };\n const p2End = { x: p2.x + dx * 2, y: p2.y + dy * 2 };\n\n if (distanceToLineSegment(point, p1, p1End) <= ModifiedSchiffPitchfork.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, p2, p2End) <= ModifiedSchiffPitchfork.HIT_THRESHOLD) return true;\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new ModifiedSchiffPitchfork(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._pitchforkOptions }\n );\n }\n\n static create(\n id: string,\n pivot: Anchor,\n swing1: Anchor,\n swing2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ModifiedSchiffPitchforkOptions>\n ): ModifiedSchiffPitchfork {\n return new ModifiedSchiffPitchfork(id, [pivot, swing1, swing2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { InsidePitchfork } from './inside-pitchfork';\nimport { midpoint, extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class InsidePitchforkPaneView implements IPrimitivePaneView {\n private _renderer: InsidePitchforkPaneRenderer;\n\n constructor(drawing: InsidePitchfork) {\n this._renderer = new InsidePitchforkPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass InsidePitchforkPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: InsidePitchfork;\n\n constructor(drawing: InsidePitchfork) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p0 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return;\n\n const options = this._drawing.pitchforkOptions;\n const mid = midpoint(p1, p2);\n\n // Direction vector for median\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n\n // Convergence point\n const convergencePoint = this._drawing.getConvergencePoint(p0, mid, 3);\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Calculate extended endpoints\n const medianEnd = { x: p0.x + dx * 3, y: p0.y + dy * 3 };\n\n // Extend if needed\n let drawMedianEnd = medianEnd;\n let drawConvergence = convergencePoint;\n\n if (options.extendLines) {\n const extMedian = extendLineToViewport(p0, medianEnd, viewport.width, viewport.height, false, true);\n drawMedianEnd = extMedian.end;\n\n // Extend converging lines beyond convergence point\n const extP1 = extendLineToViewport(p1, convergencePoint, viewport.width, viewport.height, false, true);\n const extP2 = extendLineToViewport(p2, convergencePoint, viewport.width, viewport.height, false, true);\n // Use the furthest extended point\n drawConvergence = {\n x: Math.max(extP1.end.x, extP2.end.x, convergencePoint.x),\n y: (extP1.end.y + extP2.end.y) / 2,\n };\n }\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.beginPath();\n ctx.moveTo(p1.x * pixelRatio, p1.y * pixelRatio);\n ctx.lineTo(drawConvergence.x * pixelRatio, drawConvergence.y * pixelRatio);\n ctx.lineTo(p2.x * pixelRatio, p2.y * pixelRatio);\n ctx.closePath();\n ctx.fill();\n }\n\n // Draw median line\n if (options.showMedianLine) {\n drawDashedLine(ctx, p0, drawMedianEnd, [5, 5], pixelRatio);\n }\n\n // Draw converging outer lines\n if (options.showOuterLines) {\n // The lines converge, so we draw from swing points toward convergence\n if (options.extendLines) {\n // Extend lines beyond convergence\n const ext1 = extendLineToViewport(p1, convergencePoint, viewport.width, viewport.height, false, true);\n const ext2 = extendLineToViewport(p2, convergencePoint, viewport.width, viewport.height, false, true);\n drawLine(ctx, p1, ext1.end, pixelRatio);\n drawLine(ctx, p2, ext2.end, pixelRatio);\n } else {\n drawLine(ctx, p1, convergencePoint, pixelRatio);\n drawLine(ctx, p2, convergencePoint, pixelRatio);\n }\n }\n\n // Draw connecting lines to anchors\n ctx.globalAlpha = 0.5;\n drawLine(ctx, p0, p1, pixelRatio);\n drawLine(ctx, p0, p2, pixelRatio);\n drawLine(ctx, p1, p2, pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment, midpoint } from '../../core/geometry';\nimport { InsidePitchforkPaneView } from './inside-pitchfork-pane-view';\n\n/**\n * InsidePitchfork options\n */\nexport interface InsidePitchforkOptions extends DrawingOptions {\n showMedianLine?: boolean;\n showOuterLines?: boolean;\n extendLines?: boolean;\n filled?: boolean;\n}\n\n/**\n * InsidePitchfork - Inside Pitchfork variant.\n *\n * The Inside Pitchfork differs from Andrews' Pitchfork in that the outer\n * lines converge toward the median line rather than running parallel to it.\n * The outer lines start from the swing points (p1, p2) and converge toward\n * a point on the extended median line.\n *\n * Features:\n * - Three anchor points (pivot, and two swing points)\n * - Median line from pivot through midpoint of swings\n * - Converging outer lines from swing points toward median\n * - Optional fill between lines\n */\nexport class InsidePitchfork extends Drawing {\n readonly type = 'inside-pitchfork';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _pitchforkOptions: InsidePitchforkOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<InsidePitchforkOptions> = {}\n ) {\n const { showMedianLine, showOuterLines, extendLines, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._pitchforkOptions = {\n ...this._options,\n showMedianLine: showMedianLine ?? true,\n showOuterLines: showOuterLines ?? true,\n extendLines: extendLines ?? true,\n filled: filled ?? true,\n };\n }\n\n get pitchforkOptions(): InsidePitchforkOptions {\n return this._pitchforkOptions;\n }\n\n setPitchforkOptions(options: Partial<InsidePitchforkOptions>): void {\n this._pitchforkOptions = { ...this._pitchforkOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= InsidePitchfork.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new InsidePitchforkPaneView(this)];\n }\n\n /**\n * Calculate the convergence point on the median line where outer lines meet.\n * This is a point further along the median line.\n */\n getConvergencePoint(p0: Point, mid: Point, factor: number = 3): Point {\n const dx = mid.x - p0.x;\n const dy = mid.y - p0.y;\n return {\n x: p0.x + dx * factor,\n y: p0.y + dy * factor,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport); // Pivot\n const p1 = this.anchorToPixel(this._anchors[1], viewport); // Swing 1\n const p2 = this.anchorToPixel(this._anchors[2], viewport); // Swing 2\n\n if (!p0 || !p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n\n // Midpoint of p1 and p2\n const mid = midpoint(p1, p2);\n\n // Median line: from p0 through mid\n if (this._pitchforkOptions.showMedianLine) {\n geometries.push({\n type: 'line',\n start: p0,\n end: mid,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n // Convergence point on median line\n const convergencePoint = this.getConvergencePoint(p0, mid, 3);\n\n // Outer lines converge from p1 and p2 toward convergence point\n if (this._pitchforkOptions.showOuterLines) {\n geometries.push({\n type: 'line',\n start: p1,\n end: convergencePoint,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: p2,\n end: convergencePoint,\n extendRight: this._pitchforkOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n const p2 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p0 || !p1 || !p2) return false;\n\n const mid = midpoint(p1, p2);\n const convergencePoint = this.getConvergencePoint(p0, mid, 3);\n\n // Check median line\n if (distanceToLineSegment(point, p0, mid) <= InsidePitchfork.HIT_THRESHOLD) return true;\n\n // Check converging lines\n if (distanceToLineSegment(point, p1, convergencePoint) <= InsidePitchfork.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, p2, convergencePoint) <= InsidePitchfork.HIT_THRESHOLD) return true;\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new InsidePitchfork(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._pitchforkOptions }\n );\n }\n\n static create(\n id: string,\n pivot: Anchor,\n swing1: Anchor,\n swing2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<InsidePitchforkOptions>\n ): InsidePitchfork {\n return new InsidePitchfork(id, [pivot, swing1, swing2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { GannBox } from './gann-box';\nimport { GANN_LEVELS } from './gann-box';\nimport { applyStyle, drawLine, drawRect, drawControlPoints, drawDashedLine, drawLabel } from '../../rendering/canvas-utils';\n\nexport class GannBoxPaneView implements IPrimitivePaneView {\n private _renderer: GannBoxPaneRenderer;\n\n constructor(drawing: GannBox) {\n this._renderer = new GannBoxPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass GannBoxPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: GannBox;\n\n constructor(drawing: GannBox) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.gannOptions;\n const priceLevels = options.priceLevels ?? GANN_LEVELS;\n const timeLevels = options.timeLevels ?? GANN_LEVELS;\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n const width = right - left;\n const height = bottom - top;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.fillRect(left * pixelRatio, top * pixelRatio, width * pixelRatio, height * pixelRatio);\n }\n\n // Draw outer rectangle\n drawRect(ctx, { x: left, y: top }, width, height, false, pixelRatio);\n\n // Draw horizontal lines with labels\n ctx.globalAlpha = 0.6;\n for (const level of priceLevels) {\n if (level === 0 || level === 1) continue;\n const y = top + height * level;\n drawDashedLine(ctx, { x: left, y }, { x: right, y }, [3, 3], pixelRatio);\n\n // Level label\n drawLabel(\n ctx,\n `${(level * 100).toFixed(0)}%`,\n { x: right + 5, y },\n {\n font: '10px sans-serif',\n textColor: this._drawing.style.lineColor,\n backgroundColor: 'transparent',\n padding: 2,\n },\n pixelRatio\n );\n }\n\n // Draw vertical lines with labels\n for (const level of timeLevels) {\n if (level === 0 || level === 1) continue;\n const x = left + width * level;\n drawDashedLine(ctx, { x, y: top }, { x, y: bottom }, [3, 3], pixelRatio);\n }\n ctx.globalAlpha = 1;\n\n // Draw diagonals\n if (options.showDiagonals) {\n ctx.globalAlpha = 0.5;\n drawLine(ctx, { x: left, y: top }, { x: right, y: bottom }, pixelRatio);\n drawLine(ctx, { x: left, y: bottom }, { x: right, y: top }, pixelRatio);\n ctx.globalAlpha = 1;\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry, RectangleGeometry } from '../../core/geometry';\nimport { GannBoxPaneView } from './gann-box-pane-view';\n\n/**\n * Gann price levels\n */\nexport const GANN_LEVELS = [0, 0.25, 0.333, 0.5, 0.667, 0.75, 1];\n\n/**\n * GannBox options\n */\nexport interface GannBoxOptions extends DrawingOptions {\n priceLevels?: number[];\n timeLevels?: number[];\n showDiagonals?: boolean;\n filled?: boolean;\n}\n\n/**\n * GannBox - Gann grid/box for price and time analysis.\n *\n * Features:\n * - Two anchor points (corners)\n * - Horizontal price levels\n * - Vertical time levels\n * - Optional diagonal lines\n */\nexport class GannBox extends Drawing {\n readonly type = 'gann-box';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _gannOptions: GannBoxOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<GannBoxOptions> = {}\n ) {\n const { priceLevels, timeLevels, showDiagonals, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._gannOptions = {\n ...this._options,\n priceLevels: priceLevels ?? GANN_LEVELS,\n timeLevels: timeLevels ?? GANN_LEVELS,\n showDiagonals: showDiagonals ?? true,\n filled: filled ?? false,\n };\n }\n\n get gannOptions(): GannBoxOptions {\n return this._gannOptions;\n }\n\n setGannOptions(options: Partial<GannBoxOptions>): void {\n this._gannOptions = { ...this._gannOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= GannBox.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new GannBoxPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const priceLevels = this._gannOptions.priceLevels ?? GANN_LEVELS;\n const timeLevels = this._gannOptions.timeLevels ?? GANN_LEVELS;\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n const width = right - left;\n const height = bottom - top;\n\n // Outer rectangle\n geometries.push({\n type: 'rectangle',\n topLeft: { x: left, y: top },\n width,\n height,\n } as RectangleGeometry);\n\n // Horizontal lines (price levels)\n for (const level of priceLevels) {\n if (level === 0 || level === 1) continue;\n const y = top + height * level;\n geometries.push({\n type: 'line',\n start: { x: left, y },\n end: { x: right, y },\n } as LineGeometry);\n }\n\n // Vertical lines (time levels)\n for (const level of timeLevels) {\n if (level === 0 || level === 1) continue;\n const x = left + width * level;\n geometries.push({\n type: 'line',\n start: { x, y: top },\n end: { x, y: bottom },\n } as LineGeometry);\n }\n\n // Diagonal lines\n if (this._gannOptions.showDiagonals) {\n // Main diagonals\n geometries.push({\n type: 'line',\n start: { x: left, y: top },\n end: { x: right, y: bottom },\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: { x: left, y: bottom },\n end: { x: right, y: top },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n\n // Check if inside the box\n return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;\n }\n\n clone(newId: string): IDrawing {\n return new GannBox(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._gannOptions }\n );\n }\n\n static create(\n id: string,\n corner1: Anchor,\n corner2: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<GannBoxOptions>\n ): GannBox {\n return new GannBox(id, [corner1, corner2], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { GannFan } from './gann-fan';\nimport { GANN_FAN_ANGLES } from './gann-fan';\nimport type { Point } from '../../core/types';\nimport { extendLineToViewport } from '../../core/geometry';\nimport { applyStyle, drawLine, drawControlPoints, drawLabel } from '../../rendering/canvas-utils';\n\n// Colors for different Gann angles\nconst GANN_COLORS: Record<string, string> = {\n '8x1': '#F44336',\n '4x1': '#E91E63',\n '3x1': '#9C27B0',\n '2x1': '#673AB7',\n '1x1': '#2196F3',\n '1x2': '#00BCD4',\n '1x3': '#4CAF50',\n '1x4': '#8BC34A',\n '1x8': '#CDDC39',\n};\n\nexport class GannFanPaneView implements IPrimitivePaneView {\n private _renderer: GannFanPaneRenderer;\n\n constructor(drawing: GannFan) {\n this._renderer = new GannFanPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass GannFanPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: GannFan;\n\n constructor(drawing: GannFan) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.gannOptions;\n const angles = options.angles ?? GANN_FAN_ANGLES;\n\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const baseLen = Math.sqrt(dx * dx + dy * dy);\n\n if (baseLen === 0) return;\n\n const unitX = dx / baseLen;\n const unitY = dy / baseLen;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw each fan line\n for (const angle of angles) {\n const fanDx = unitX * baseLen * 3;\n const fanDy = unitY * baseLen * 3 * angle.ratio;\n\n let end: Point = {\n x: p1.x + fanDx,\n y: p1.y + fanDy,\n };\n\n // Extend to viewport if enabled\n if (options.extendLines) {\n const extended = extendLineToViewport(p1, end, viewport.width, viewport.height, false, true);\n end = extended.end;\n }\n\n // Use angle-specific color\n const color = GANN_COLORS[angle.label] ?? this._drawing.style.lineColor;\n ctx.strokeStyle = color;\n ctx.lineWidth = (angle.label === '1x1' ? 2 : 1) * this._drawing.style.lineWidth * pixelRatio;\n\n drawLine(ctx, p1, end, pixelRatio);\n\n // Draw label\n if (options.showLabels) {\n const labelPos = {\n x: p1.x + fanDx * 0.3,\n y: p1.y + fanDy * 0.3,\n };\n\n drawLabel(\n ctx,\n angle.label,\n labelPos,\n {\n font: '10px sans-serif',\n textColor: '#ffffff',\n backgroundColor: color + 'CC',\n padding: 2,\n borderRadius: 2,\n },\n pixelRatio\n );\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { GannFanPaneView } from './gann-fan-pane-view';\n\n/**\n * Standard Gann fan angles (rise/run ratios)\n */\nexport const GANN_FAN_ANGLES = [\n { ratio: 8, label: '8x1' },\n { ratio: 4, label: '4x1' },\n { ratio: 3, label: '3x1' },\n { ratio: 2, label: '2x1' },\n { ratio: 1, label: '1x1' },\n { ratio: 0.5, label: '1x2' },\n { ratio: 0.333, label: '1x3' },\n { ratio: 0.25, label: '1x4' },\n { ratio: 0.125, label: '1x8' },\n];\n\n/**\n * GannFan options\n */\nexport interface GannFanOptions extends DrawingOptions {\n angles?: { ratio: number; label: string }[];\n showLabels?: boolean;\n extendLines?: boolean;\n}\n\n/**\n * GannFan - Gann fan lines radiating from a point.\n *\n * Features:\n * - Two anchor points (origin and direction)\n * - Multiple fan lines at Gann angles\n * - Optional labels for each angle\n */\nexport class GannFan extends Drawing {\n readonly type = 'gann-fan';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _gannOptions: GannFanOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<GannFanOptions> = {}\n ) {\n const { angles, showLabels, extendLines, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._gannOptions = {\n ...this._options,\n angles: angles ?? GANN_FAN_ANGLES,\n showLabels: showLabels ?? true,\n extendLines: extendLines ?? true,\n };\n }\n\n get gannOptions(): GannFanOptions {\n return this._gannOptions;\n }\n\n setGannOptions(options: Partial<GannFanOptions>): void {\n this._gannOptions = { ...this._gannOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= GannFan.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new GannFanPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n const angles = this._gannOptions.angles ?? GANN_FAN_ANGLES;\n\n // Calculate base direction and scale\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const baseLen = Math.sqrt(dx * dx + dy * dy);\n\n if (baseLen === 0) return [];\n\n // Normalize direction (1x1 line)\n const unitX = dx / baseLen;\n const unitY = dy / baseLen;\n\n // For each angle, compute line\n for (const angle of angles) {\n // Adjust Y based on ratio\n const fanDx = unitX * baseLen * 2;\n const fanDy = unitY * baseLen * 2 * angle.ratio;\n\n const end: Point = {\n x: p1.x + fanDx,\n y: p1.y + fanDy,\n };\n\n geometries.push({\n type: 'line',\n start: p1,\n end,\n extendRight: this._gannOptions.extendLines,\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const angles = this._gannOptions.angles ?? GANN_FAN_ANGLES;\n const dx = p2.x - p1.x;\n const dy = p2.y - p1.y;\n const baseLen = Math.sqrt(dx * dx + dy * dy);\n\n if (baseLen === 0) return false;\n\n const unitX = dx / baseLen;\n const unitY = dy / baseLen;\n\n for (const angle of angles) {\n const fanDx = unitX * baseLen * 2;\n const fanDy = unitY * baseLen * 2 * angle.ratio;\n\n const end: Point = {\n x: p1.x + fanDx,\n y: p1.y + fanDy,\n };\n\n if (distanceToLineSegment(point, p1, end) <= GannFan.HIT_THRESHOLD) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new GannFan(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._gannOptions }\n );\n }\n\n static create(\n id: string,\n origin: Anchor,\n direction: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<GannFanOptions>\n ): GannFan {\n return new GannFan(id, [origin, direction], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { GannSquareFixed } from './gann-square-fixed';\nimport { GANN_SQUARE_LEVELS } from './gann-square-fixed';\nimport { applyStyle, drawLine, drawRect, drawControlPoints, drawDashedLine, drawLabel } from '../../rendering/canvas-utils';\n\nexport class GannSquareFixedPaneView implements IPrimitivePaneView {\n private _renderer: GannSquareFixedPaneRenderer;\n\n constructor(drawing: GannSquareFixed) {\n this._renderer = new GannSquareFixedPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass GannSquareFixedPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: GannSquareFixed;\n\n constructor(drawing: GannSquareFixed) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const center = this._drawing.anchorToPixel(anchors[0], viewport);\n\n if (!center) return;\n\n const options = this._drawing.gannOptions;\n const halfSize = this._drawing.getSquarePixelSize(viewport) / 2;\n const levels = options.levels ?? GANN_SQUARE_LEVELS;\n\n const left = center.x - halfSize;\n const right = center.x + halfSize;\n const top = center.y - halfSize;\n const bottom = center.y + halfSize;\n const size = halfSize * 2;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.fillRect(left * pixelRatio, top * pixelRatio, size * pixelRatio, size * pixelRatio);\n }\n\n // Draw outer rectangle\n drawRect(ctx, { x: left, y: top }, size, size, false, pixelRatio);\n\n // Draw horizontal lines\n ctx.globalAlpha = 0.5;\n for (const level of levels) {\n if (level === 0 || level === 1) continue;\n const y = top + size * level;\n const isCardinal = level === 0.5;\n\n if (isCardinal) {\n ctx.globalAlpha = 0.8;\n drawLine(ctx, { x: left, y }, { x: right, y }, pixelRatio);\n ctx.globalAlpha = 0.5;\n } else {\n drawDashedLine(ctx, { x: left, y }, { x: right, y }, [3, 3], pixelRatio);\n }\n\n // Level label\n if (options.showLabels) {\n drawLabel(\n ctx,\n `${(level * 100).toFixed(0)}%`,\n { x: right + 5, y },\n {\n font: '10px sans-serif',\n textColor: this._drawing.style.lineColor,\n backgroundColor: 'transparent',\n padding: 2,\n },\n pixelRatio\n );\n }\n }\n\n // Draw vertical lines\n for (const level of levels) {\n if (level === 0 || level === 1) continue;\n const x = left + size * level;\n const isCardinal = level === 0.5;\n\n if (isCardinal) {\n ctx.globalAlpha = 0.8;\n drawLine(ctx, { x, y: top }, { x, y: bottom }, pixelRatio);\n ctx.globalAlpha = 0.5;\n } else {\n drawDashedLine(ctx, { x, y: top }, { x, y: bottom }, [3, 3], pixelRatio);\n }\n }\n ctx.globalAlpha = 1;\n\n // Draw diagonals (ordinal cross)\n if (options.showDiagonals) {\n ctx.globalAlpha = 0.7;\n drawLine(ctx, { x: left, y: top }, { x: right, y: bottom }, pixelRatio);\n drawLine(ctx, { x: left, y: bottom }, { x: right, y: top }, pixelRatio);\n ctx.globalAlpha = 1;\n }\n\n // Draw arcs at corners if enabled\n if (options.showArcs) {\n ctx.globalAlpha = 0.4;\n const arcRadius = size / 4;\n\n // Top-left corner arc\n ctx.beginPath();\n ctx.arc(left * pixelRatio, top * pixelRatio, arcRadius * pixelRatio, 0, Math.PI / 2);\n ctx.stroke();\n\n // Top-right corner arc\n ctx.beginPath();\n ctx.arc(right * pixelRatio, top * pixelRatio, arcRadius * pixelRatio, Math.PI / 2, Math.PI);\n ctx.stroke();\n\n // Bottom-right corner arc\n ctx.beginPath();\n ctx.arc(right * pixelRatio, bottom * pixelRatio, arcRadius * pixelRatio, Math.PI, Math.PI * 1.5);\n ctx.stroke();\n\n // Bottom-left corner arc\n ctx.beginPath();\n ctx.arc(left * pixelRatio, bottom * pixelRatio, arcRadius * pixelRatio, Math.PI * 1.5, Math.PI * 2);\n ctx.stroke();\n\n ctx.globalAlpha = 1;\n }\n\n // Draw center point marker\n ctx.beginPath();\n ctx.arc(center.x * pixelRatio, center.y * pixelRatio, 3 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry, RectangleGeometry } from '../../core/geometry';\nimport { GannSquareFixedPaneView } from './gann-square-fixed-pane-view';\n\n/**\n * Gann square levels (cardinal and ordinal)\n */\nexport const GANN_SQUARE_LEVELS = [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1];\n\n/**\n * GannSquareFixed options\n */\nexport interface GannSquareFixedOptions extends DrawingOptions {\n squareSize?: number; // Size in price units\n levels?: number[];\n showDiagonals?: boolean;\n showArcs?: boolean;\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * GannSquareFixed - Fixed-size Gann square for price/time analysis.\n *\n * Features:\n * - Single anchor point (center)\n * - Fixed square size based on price units\n * - Cardinal cross (vertical/horizontal)\n * - Ordinal cross (45-degree diagonals)\n * - Optional arcs at corners\n */\nexport class GannSquareFixed extends Drawing {\n readonly type = 'gann-square-fixed';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _gannOptions: GannSquareFixedOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<GannSquareFixedOptions> = {}\n ) {\n const { squareSize, levels, showDiagonals, showArcs, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._gannOptions = {\n ...this._options,\n squareSize: squareSize ?? 50, // Default 50 price units\n levels: levels ?? GANN_SQUARE_LEVELS,\n showDiagonals: showDiagonals ?? true,\n showArcs: showArcs ?? false,\n showLabels: showLabels ?? true,\n filled: filled ?? false,\n };\n }\n\n get gannOptions(): GannSquareFixedOptions {\n return this._gannOptions;\n }\n\n setGannOptions(options: Partial<GannSquareFixedOptions>): void {\n this._gannOptions = { ...this._gannOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= GannSquareFixed.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new GannSquareFixedPaneView(this)];\n }\n\n /**\n * Get the square size based on price scale\n */\n getSquarePixelSize(viewport: Viewport): number {\n if (!this.isValid()) return 0;\n\n const center = this._anchors[0];\n const halfSize = (this._gannOptions.squareSize ?? 50) / 2;\n\n // Convert price range to pixels\n const topY = viewport.priceScale.priceToCoordinate(center.price + halfSize);\n const bottomY = viewport.priceScale.priceToCoordinate(center.price - halfSize);\n\n if (topY === null || bottomY === null) return 0;\n\n return Math.abs(bottomY - topY);\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n if (!center) return [];\n\n const geometries: Geometry[] = [];\n const halfSize = this.getSquarePixelSize(viewport) / 2;\n const levels = this._gannOptions.levels ?? GANN_SQUARE_LEVELS;\n\n const left = center.x - halfSize;\n const right = center.x + halfSize;\n const top = center.y - halfSize;\n const bottom = center.y + halfSize;\n const size = halfSize * 2;\n\n // Outer rectangle\n geometries.push({\n type: 'rectangle',\n topLeft: { x: left, y: top },\n width: size,\n height: size,\n } as RectangleGeometry);\n\n // Horizontal lines\n for (const level of levels) {\n if (level === 0 || level === 1) continue;\n const y = top + size * level;\n geometries.push({\n type: 'line',\n start: { x: left, y },\n end: { x: right, y },\n } as LineGeometry);\n }\n\n // Vertical lines\n for (const level of levels) {\n if (level === 0 || level === 1) continue;\n const x = left + size * level;\n geometries.push({\n type: 'line',\n start: { x, y: top },\n end: { x, y: bottom },\n } as LineGeometry);\n }\n\n // Diagonal lines (ordinal cross)\n if (this._gannOptions.showDiagonals) {\n geometries.push({\n type: 'line',\n start: { x: left, y: top },\n end: { x: right, y: bottom },\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: { x: left, y: bottom },\n end: { x: right, y: top },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n if (!center) return false;\n\n const halfSize = this.getSquarePixelSize(viewport) / 2;\n\n // Check if inside the square\n return (\n point.x >= center.x - halfSize &&\n point.x <= center.x + halfSize &&\n point.y >= center.y - halfSize &&\n point.y <= center.y + halfSize\n );\n }\n\n clone(newId: string): IDrawing {\n return new GannSquareFixed(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._gannOptions }\n );\n }\n\n static create(\n id: string,\n center: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<GannSquareFixedOptions>\n ): GannSquareFixed {\n return new GannSquareFixed(id, [center], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { GannSquare } from './gann-square';\nimport { GANN_SQUARE_DIVISIONS } from './gann-square';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawLine, drawRect, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class GannSquarePaneView implements IPrimitivePaneView {\n private _renderer: GannSquarePaneRenderer;\n\n constructor(drawing: GannSquare) {\n this._renderer = new GannSquarePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass GannSquarePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: GannSquare;\n\n constructor(drawing: GannSquare) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const center = this._drawing.anchorToPixel(anchors[0], viewport);\n\n if (!center) return;\n\n const options = this._drawing.gannOptions;\n const radius = this._drawing.getSquareRadius(viewport);\n const divisions = options.divisions ?? GANN_SQUARE_DIVISIONS;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n\n // Draw fill if enabled\n if (options.filled && this._drawing.style.fillColor) {\n ctx.fillStyle = this._drawing.style.fillColor;\n ctx.fillRect(\n (center.x - radius) * pixelRatio,\n (center.y - radius) * pixelRatio,\n radius * 2 * pixelRatio,\n radius * 2 * pixelRatio\n );\n }\n\n // Draw outer square\n drawRect(ctx, { x: center.x - radius, y: center.y - radius }, radius * 2, radius * 2, false, pixelRatio);\n\n // Draw concentric squares\n ctx.globalAlpha = 0.4;\n for (let i = 1; i < divisions; i++) {\n const r = (radius * i) / divisions;\n drawRect(ctx, { x: center.x - r, y: center.y - r }, r * 2, r * 2, false, pixelRatio);\n }\n ctx.globalAlpha = 1;\n\n // Draw cardinal cross (horizontal and vertical through center)\n if (options.showCardinalCross) {\n ctx.globalAlpha = 0.8;\n drawLine(ctx, { x: center.x - radius, y: center.y }, { x: center.x + radius, y: center.y }, pixelRatio);\n drawLine(ctx, { x: center.x, y: center.y - radius }, { x: center.x, y: center.y + radius }, pixelRatio);\n ctx.globalAlpha = 1;\n }\n\n // Draw ordinal cross (diagonals)\n if (options.showDiagonals) {\n ctx.globalAlpha = 0.6;\n drawLine(\n ctx,\n { x: center.x - radius, y: center.y - radius },\n { x: center.x + radius, y: center.y + radius },\n pixelRatio\n );\n drawLine(\n ctx,\n { x: center.x - radius, y: center.y + radius },\n { x: center.x + radius, y: center.y - radius },\n pixelRatio\n );\n ctx.globalAlpha = 1;\n }\n\n // Draw spiral if enabled (Square of Nine pattern)\n if (options.showSpiral) {\n this.drawSpiral(ctx, center, radius, divisions, pixelRatio);\n }\n\n // Draw number labels if enabled\n if (options.showLabels) {\n this.drawNumberLabels(ctx, center, radius, divisions, pixelRatio);\n }\n\n // Draw center point marker\n ctx.beginPath();\n ctx.arc(center.x * pixelRatio, center.y * pixelRatio, 3 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n\n private drawSpiral(\n ctx: CanvasRenderingContext2D,\n center: Point,\n radius: number,\n _divisions: number,\n pixelRatio: number\n ): void {\n ctx.globalAlpha = 0.5;\n ctx.beginPath();\n\n const totalRotations = 3;\n const steps = 100;\n\n for (let i = 0; i <= steps; i++) {\n const t = (i / steps) * totalRotations * Math.PI * 2;\n const r = (t / (totalRotations * Math.PI * 2)) * radius;\n const x = center.x + r * Math.cos(t - Math.PI / 2);\n const y = center.y + r * Math.sin(t - Math.PI / 2);\n\n if (i === 0) {\n ctx.moveTo(x * pixelRatio, y * pixelRatio);\n } else {\n ctx.lineTo(x * pixelRatio, y * pixelRatio);\n }\n }\n\n ctx.stroke();\n ctx.globalAlpha = 1;\n }\n\n private drawNumberLabels(\n ctx: CanvasRenderingContext2D,\n center: Point,\n radius: number,\n divisions: number,\n pixelRatio: number\n ): void {\n const cellSize = radius / divisions;\n const fontSize = Math.max(8, Math.min(12, cellSize * 0.4));\n\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n ctx.fillStyle = this._drawing.style.lineColor || '#fff';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n // Draw central 1\n ctx.fillText('1', center.x * pixelRatio, center.y * pixelRatio);\n\n // Draw numbers in spiral pattern (simplified)\n let num = 2;\n let layer = 1;\n const maxLayers = Math.min(divisions, 4); // Limit labels to prevent clutter\n\n while (layer <= maxLayers && num <= 81) {\n const offset = cellSize * layer;\n\n // Right side going up\n for (let i = -layer + 1; i <= layer && num <= 81; i++) {\n const x = center.x + offset;\n const y = center.y - cellSize * i;\n if (Math.abs(x - center.x) <= radius && Math.abs(y - center.y) <= radius) {\n ctx.fillText(String(num), x * pixelRatio, y * pixelRatio);\n }\n num++;\n }\n\n // Top going left\n for (let i = layer - 1; i >= -layer && num <= 81; i--) {\n const x = center.x + cellSize * i;\n const y = center.y - offset;\n if (Math.abs(x - center.x) <= radius && Math.abs(y - center.y) <= radius) {\n ctx.fillText(String(num), x * pixelRatio, y * pixelRatio);\n }\n num++;\n }\n\n // Left side going down\n for (let i = -layer + 1; i <= layer && num <= 81; i++) {\n const x = center.x - offset;\n const y = center.y + cellSize * i;\n if (Math.abs(x - center.x) <= radius && Math.abs(y - center.y) <= radius) {\n ctx.fillText(String(num), x * pixelRatio, y * pixelRatio);\n }\n num++;\n }\n\n // Bottom going right\n for (let i = -layer + 1; i <= layer && num <= 81; i++) {\n const x = center.x + cellSize * i;\n const y = center.y + offset;\n if (Math.abs(x - center.x) <= radius && Math.abs(y - center.y) <= radius) {\n ctx.fillText(String(num), x * pixelRatio, y * pixelRatio);\n }\n num++;\n }\n\n layer++;\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry, RectangleGeometry } from '../../core/geometry';\nimport { GannSquarePaneView } from './gann-square-pane-view';\n\n/**\n * Gann square divisions for the \"Square of Nine\" pattern\n */\nexport const GANN_SQUARE_DIVISIONS = 8;\n\n/**\n * GannSquare options\n */\nexport interface GannSquareOptions extends DrawingOptions {\n divisions?: number;\n showDiagonals?: boolean;\n showCardinalCross?: boolean;\n showSpiral?: boolean;\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * GannSquare - Resizable Gann square with \"Square of Nine\" pattern.\n *\n * Features:\n * - Two anchor points (center and corner)\n * - Concentric squares at regular intervals\n * - Cardinal cross (vertical/horizontal through center)\n * - Ordinal cross (45-degree diagonals)\n * - Optional spiral pattern\n */\nexport class GannSquare extends Drawing {\n readonly type = 'gann-square';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _gannOptions: GannSquareOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<GannSquareOptions> = {}\n ) {\n const { divisions, showDiagonals, showCardinalCross, showSpiral, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._gannOptions = {\n ...this._options,\n divisions: divisions ?? GANN_SQUARE_DIVISIONS,\n showDiagonals: showDiagonals ?? true,\n showCardinalCross: showCardinalCross ?? true,\n showSpiral: showSpiral ?? false,\n showLabels: showLabels ?? true,\n filled: filled ?? false,\n };\n }\n\n get gannOptions(): GannSquareOptions {\n return this._gannOptions;\n }\n\n setGannOptions(options: Partial<GannSquareOptions>): void {\n this._gannOptions = { ...this._gannOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= GannSquare.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new GannSquarePaneView(this)];\n }\n\n /**\n * Get the square size from center to corner\n */\n getSquareRadius(viewport: Viewport): number {\n if (!this.isValid()) return 0;\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n const corner = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!center || !corner) return 0;\n\n // Use the larger of dx or dy to maintain square aspect\n const dx = Math.abs(corner.x - center.x);\n const dy = Math.abs(corner.y - center.y);\n\n return Math.max(dx, dy);\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n if (!center) return [];\n\n const geometries: Geometry[] = [];\n const radius = this.getSquareRadius(viewport);\n const divisions = this._gannOptions.divisions ?? GANN_SQUARE_DIVISIONS;\n\n // Outer square\n geometries.push({\n type: 'rectangle',\n topLeft: { x: center.x - radius, y: center.y - radius },\n width: radius * 2,\n height: radius * 2,\n } as RectangleGeometry);\n\n // Concentric squares\n for (let i = 1; i < divisions; i++) {\n const r = (radius * i) / divisions;\n geometries.push({\n type: 'rectangle',\n topLeft: { x: center.x - r, y: center.y - r },\n width: r * 2,\n height: r * 2,\n } as RectangleGeometry);\n }\n\n // Cardinal cross (horizontal and vertical through center)\n if (this._gannOptions.showCardinalCross) {\n geometries.push({\n type: 'line',\n start: { x: center.x - radius, y: center.y },\n end: { x: center.x + radius, y: center.y },\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: { x: center.x, y: center.y - radius },\n end: { x: center.x, y: center.y + radius },\n } as LineGeometry);\n }\n\n // Ordinal cross (diagonals)\n if (this._gannOptions.showDiagonals) {\n geometries.push({\n type: 'line',\n start: { x: center.x - radius, y: center.y - radius },\n end: { x: center.x + radius, y: center.y + radius },\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: { x: center.x - radius, y: center.y + radius },\n end: { x: center.x + radius, y: center.y - radius },\n } as LineGeometry);\n }\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const center = this.anchorToPixel(this._anchors[0], viewport);\n if (!center) return false;\n\n const radius = this.getSquareRadius(viewport);\n\n // Check if inside the square\n return (\n point.x >= center.x - radius &&\n point.x <= center.x + radius &&\n point.y >= center.y - radius &&\n point.y <= center.y + radius\n );\n }\n\n clone(newId: string): IDrawing {\n return new GannSquare(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._gannOptions }\n );\n }\n\n static create(\n id: string,\n center: Anchor,\n corner: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<GannSquareOptions>\n ): GannSquare {\n return new GannSquare(id, [center, corner], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { LongPosition } from './long-position';\nimport { drawLine, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class LongPositionPaneView implements IPrimitivePaneView {\n private _renderer: LongPositionPaneRenderer;\n\n constructor(drawing: LongPosition) {\n this._renderer = new LongPositionPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass LongPositionPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: LongPosition;\n\n constructor(drawing: LongPosition) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const entry = this._drawing.anchorToPixel(anchors[0], viewport);\n const stopLoss = this._drawing.anchorToPixel(anchors[1], viewport);\n const takeProfit = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!entry || !stopLoss || !takeProfit) return;\n\n const options = this._drawing.positionOptions;\n const info = this._drawing.getPositionInfo();\n const width = 200;\n\n // Draw risk zone (entry to stop loss) - Red\n ctx.fillStyle = 'rgba(239, 83, 80, 0.3)';\n const riskTop = Math.min(entry.y, stopLoss.y);\n const riskHeight = Math.abs(stopLoss.y - entry.y);\n ctx.fillRect(entry.x * pixelRatio, riskTop * pixelRatio, width * pixelRatio, riskHeight * pixelRatio);\n\n // Draw risk zone border\n ctx.strokeStyle = '#ef5350';\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(entry.x * pixelRatio, riskTop * pixelRatio, width * pixelRatio, riskHeight * pixelRatio);\n\n // Draw reward zone (entry to take profit) - Green\n ctx.fillStyle = 'rgba(38, 166, 154, 0.3)';\n const rewardTop = Math.min(entry.y, takeProfit.y);\n const rewardHeight = Math.abs(takeProfit.y - entry.y);\n ctx.fillRect(entry.x * pixelRatio, rewardTop * pixelRatio, width * pixelRatio, rewardHeight * pixelRatio);\n\n // Draw reward zone border\n ctx.strokeStyle = '#26a69a';\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(entry.x * pixelRatio, rewardTop * pixelRatio, width * pixelRatio, rewardHeight * pixelRatio);\n\n // Draw entry line\n ctx.strokeStyle = '#2196F3';\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, { x: entry.x, y: entry.y }, { x: entry.x + width, y: entry.y }, pixelRatio);\n\n // Draw stop loss line\n ctx.strokeStyle = '#ef5350';\n ctx.lineWidth = 2 * pixelRatio;\n ctx.setLineDash([5 * pixelRatio, 3 * pixelRatio]);\n drawLine(ctx, { x: entry.x, y: stopLoss.y }, { x: entry.x + width, y: stopLoss.y }, pixelRatio);\n\n // Draw take profit line\n ctx.strokeStyle = '#26a69a';\n drawLine(ctx, { x: entry.x, y: takeProfit.y }, { x: entry.x + width, y: takeProfit.y }, pixelRatio);\n ctx.setLineDash([]);\n\n // Draw labels\n const fontSize = 11;\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n\n const labelX = entry.x + width + 5;\n\n // Entry label\n ctx.fillStyle = '#2196F3';\n let entryText = 'Entry';\n if (options.showPrices) {\n entryText += `: $${info.entry.toFixed(2)}`;\n }\n ctx.fillText(entryText, labelX * pixelRatio, entry.y * pixelRatio);\n\n // Stop loss label\n ctx.fillStyle = '#ef5350';\n let slText = 'Stop';\n if (options.showPrices) {\n slText += `: $${info.stopLoss.toFixed(2)}`;\n }\n if (options.showPercentage) {\n slText += ` (-${info.riskPercent.toFixed(2)}%)`;\n }\n ctx.fillText(slText, labelX * pixelRatio, stopLoss.y * pixelRatio);\n\n // Take profit label\n ctx.fillStyle = '#26a69a';\n let tpText = 'Target';\n if (options.showPrices) {\n tpText += `: $${info.takeProfit.toFixed(2)}`;\n }\n if (options.showPercentage) {\n tpText += ` (+${info.rewardPercent.toFixed(2)}%)`;\n }\n ctx.fillText(tpText, labelX * pixelRatio, takeProfit.y * pixelRatio);\n\n // Risk/Reward ratio\n if (options.showRiskReward) {\n ctx.fillStyle = '#ffffff';\n const rrText = `R:R = 1:${info.riskRewardRatio.toFixed(2)}`;\n const rrY = (entry.y + takeProfit.y) / 2;\n ctx.fillText(rrText, (entry.x + 10) * pixelRatio, rrY * pixelRatio);\n }\n\n // Position type indicator\n ctx.fillStyle = '#26a69a';\n ctx.font = `bold ${14 * pixelRatio}px sans-serif`;\n ctx.fillText('LONG', (entry.x + 10) * pixelRatio, (entry.y - 15) * pixelRatio);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, RectangleGeometry } from '../../core/geometry';\nimport { LongPositionPaneView } from './long-position-pane-view';\n\n/**\n * LongPosition options\n */\nexport interface LongPositionOptions extends DrawingOptions {\n showPrices?: boolean;\n showPercentage?: boolean;\n showRiskReward?: boolean;\n showPnL?: boolean;\n quantity?: number;\n accountSize?: number;\n}\n\n/**\n * LongPosition - Trade visualization for long positions.\n *\n * Features:\n * - Three anchor points: entry, stop loss, take profit\n * - Shows risk (red) and reward (green) zones\n * - Displays P&L, percentage change, and risk/reward ratio\n */\nexport class LongPosition extends Drawing {\n readonly type = 'long-position';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _positionOptions: LongPositionOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<LongPositionOptions> = {}\n ) {\n const { showPrices, showPercentage, showRiskReward, showPnL, quantity, accountSize, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._positionOptions = {\n ...this._options,\n showPrices: showPrices ?? true,\n showPercentage: showPercentage ?? true,\n showRiskReward: showRiskReward ?? true,\n showPnL: showPnL ?? true,\n quantity: quantity ?? 1,\n accountSize: accountSize ?? 10000,\n };\n }\n\n get positionOptions(): LongPositionOptions {\n return this._positionOptions;\n }\n\n setPositionOptions(options: Partial<LongPositionOptions>): void {\n this._positionOptions = { ...this._positionOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= LongPosition.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new LongPositionPaneView(this)];\n }\n\n /**\n * Get position info\n * Anchors: [0] = entry, [1] = stop loss, [2] = take profit\n */\n getPositionInfo(): {\n entry: number;\n stopLoss: number;\n takeProfit: number;\n risk: number;\n reward: number;\n riskRewardRatio: number;\n riskPercent: number;\n rewardPercent: number;\n } {\n if (!this.isValid()) {\n return {\n entry: 0,\n stopLoss: 0,\n takeProfit: 0,\n risk: 0,\n reward: 0,\n riskRewardRatio: 0,\n riskPercent: 0,\n rewardPercent: 0,\n };\n }\n\n const entry = this._anchors[0].price;\n const stopLoss = this._anchors[1].price;\n const takeProfit = this._anchors[2].price;\n\n const risk = Math.abs(entry - stopLoss);\n const reward = Math.abs(takeProfit - entry);\n const riskRewardRatio = risk !== 0 ? reward / risk : 0;\n const riskPercent = entry !== 0 ? (risk / entry) * 100 : 0;\n const rewardPercent = entry !== 0 ? (reward / entry) * 100 : 0;\n\n return {\n entry,\n stopLoss,\n takeProfit,\n risk,\n reward,\n riskRewardRatio,\n riskPercent,\n rewardPercent,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport); // Entry\n const p2 = this.anchorToPixel(this._anchors[1], viewport); // Stop loss\n const p3 = this.anchorToPixel(this._anchors[2], viewport); // Take profit\n\n if (!p1 || !p2 || !p3) return [];\n\n const geometries: Geometry[] = [];\n const width = 200; // Fixed width for position box\n\n // Risk zone (entry to stop loss)\n const riskTop = Math.min(p1.y, p2.y);\n const riskHeight = Math.abs(p2.y - p1.y);\n geometries.push({\n type: 'rectangle',\n topLeft: { x: p1.x, y: riskTop },\n width,\n height: riskHeight,\n } as RectangleGeometry);\n\n // Reward zone (entry to take profit)\n const rewardTop = Math.min(p1.y, p3.y);\n const rewardHeight = Math.abs(p3.y - p1.y);\n geometries.push({\n type: 'rectangle',\n topLeft: { x: p1.x, y: rewardTop },\n width,\n height: rewardHeight,\n } as RectangleGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return false;\n\n const width = 200;\n const left = p1.x;\n const right = p1.x + width;\n const top = Math.min(p2.y, p3.y);\n const bottom = Math.max(p2.y, p3.y);\n\n return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;\n }\n\n clone(newId: string): IDrawing {\n return new LongPosition(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._positionOptions }\n );\n }\n\n static create(\n id: string,\n entry: Anchor,\n stopLoss: Anchor,\n takeProfit: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<LongPositionOptions>\n ): LongPosition {\n return new LongPosition(id, [entry, stopLoss, takeProfit], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ShortPosition } from './short-position';\nimport { drawLine, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class ShortPositionPaneView implements IPrimitivePaneView {\n private _renderer: ShortPositionPaneRenderer;\n\n constructor(drawing: ShortPosition) {\n this._renderer = new ShortPositionPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ShortPositionPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ShortPosition;\n\n constructor(drawing: ShortPosition) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const entry = this._drawing.anchorToPixel(anchors[0], viewport);\n const stopLoss = this._drawing.anchorToPixel(anchors[1], viewport);\n const takeProfit = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!entry || !stopLoss || !takeProfit) return;\n\n const options = this._drawing.positionOptions;\n const info = this._drawing.getPositionInfo();\n const width = 200;\n\n // Draw risk zone (entry to stop loss) - Red (for short, stop is above entry)\n ctx.fillStyle = 'rgba(239, 83, 80, 0.3)';\n const riskTop = Math.min(entry.y, stopLoss.y);\n const riskHeight = Math.abs(stopLoss.y - entry.y);\n ctx.fillRect(entry.x * pixelRatio, riskTop * pixelRatio, width * pixelRatio, riskHeight * pixelRatio);\n\n // Draw risk zone border\n ctx.strokeStyle = '#ef5350';\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(entry.x * pixelRatio, riskTop * pixelRatio, width * pixelRatio, riskHeight * pixelRatio);\n\n // Draw reward zone (entry to take profit) - Green (for short, target is below entry)\n ctx.fillStyle = 'rgba(38, 166, 154, 0.3)';\n const rewardTop = Math.min(entry.y, takeProfit.y);\n const rewardHeight = Math.abs(takeProfit.y - entry.y);\n ctx.fillRect(entry.x * pixelRatio, rewardTop * pixelRatio, width * pixelRatio, rewardHeight * pixelRatio);\n\n // Draw reward zone border\n ctx.strokeStyle = '#26a69a';\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(entry.x * pixelRatio, rewardTop * pixelRatio, width * pixelRatio, rewardHeight * pixelRatio);\n\n // Draw entry line\n ctx.strokeStyle = '#2196F3';\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, { x: entry.x, y: entry.y }, { x: entry.x + width, y: entry.y }, pixelRatio);\n\n // Draw stop loss line\n ctx.strokeStyle = '#ef5350';\n ctx.lineWidth = 2 * pixelRatio;\n ctx.setLineDash([5 * pixelRatio, 3 * pixelRatio]);\n drawLine(ctx, { x: entry.x, y: stopLoss.y }, { x: entry.x + width, y: stopLoss.y }, pixelRatio);\n\n // Draw take profit line\n ctx.strokeStyle = '#26a69a';\n drawLine(ctx, { x: entry.x, y: takeProfit.y }, { x: entry.x + width, y: takeProfit.y }, pixelRatio);\n ctx.setLineDash([]);\n\n // Draw labels\n const fontSize = 11;\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n\n const labelX = entry.x + width + 5;\n\n // Entry label\n ctx.fillStyle = '#2196F3';\n let entryText = 'Entry';\n if (options.showPrices) {\n entryText += `: $${info.entry.toFixed(2)}`;\n }\n ctx.fillText(entryText, labelX * pixelRatio, entry.y * pixelRatio);\n\n // Stop loss label\n ctx.fillStyle = '#ef5350';\n let slText = 'Stop';\n if (options.showPrices) {\n slText += `: $${info.stopLoss.toFixed(2)}`;\n }\n if (options.showPercentage) {\n slText += ` (-${info.riskPercent.toFixed(2)}%)`;\n }\n ctx.fillText(slText, labelX * pixelRatio, stopLoss.y * pixelRatio);\n\n // Take profit label\n ctx.fillStyle = '#26a69a';\n let tpText = 'Target';\n if (options.showPrices) {\n tpText += `: $${info.takeProfit.toFixed(2)}`;\n }\n if (options.showPercentage) {\n tpText += ` (+${info.rewardPercent.toFixed(2)}%)`;\n }\n ctx.fillText(tpText, labelX * pixelRatio, takeProfit.y * pixelRatio);\n\n // Risk/Reward ratio\n if (options.showRiskReward) {\n ctx.fillStyle = '#ffffff';\n const rrText = `R:R = 1:${info.riskRewardRatio.toFixed(2)}`;\n const rrY = (entry.y + takeProfit.y) / 2;\n ctx.fillText(rrText, (entry.x + 10) * pixelRatio, rrY * pixelRatio);\n }\n\n // Position type indicator\n ctx.fillStyle = '#ef5350';\n ctx.font = `bold ${14 * pixelRatio}px sans-serif`;\n ctx.fillText('SHORT', (entry.x + 10) * pixelRatio, (entry.y + 15) * pixelRatio);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, RectangleGeometry } from '../../core/geometry';\nimport { ShortPositionPaneView } from './short-position-pane-view';\n\n/**\n * ShortPosition options\n */\nexport interface ShortPositionOptions extends DrawingOptions {\n showPrices?: boolean;\n showPercentage?: boolean;\n showRiskReward?: boolean;\n showPnL?: boolean;\n quantity?: number;\n accountSize?: number;\n}\n\n/**\n * ShortPosition - Trade visualization for short positions.\n *\n * Features:\n * - Three anchor points: entry, stop loss, take profit\n * - Shows risk (red) and reward (green) zones\n * - Displays P&L, percentage change, and risk/reward ratio\n */\nexport class ShortPosition extends Drawing {\n readonly type = 'short-position';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _positionOptions: ShortPositionOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ShortPositionOptions> = {}\n ) {\n const { showPrices, showPercentage, showRiskReward, showPnL, quantity, accountSize, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._positionOptions = {\n ...this._options,\n showPrices: showPrices ?? true,\n showPercentage: showPercentage ?? true,\n showRiskReward: showRiskReward ?? true,\n showPnL: showPnL ?? true,\n quantity: quantity ?? 1,\n accountSize: accountSize ?? 10000,\n };\n }\n\n get positionOptions(): ShortPositionOptions {\n return this._positionOptions;\n }\n\n setPositionOptions(options: Partial<ShortPositionOptions>): void {\n this._positionOptions = { ...this._positionOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= ShortPosition.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ShortPositionPaneView(this)];\n }\n\n /**\n * Get position info\n * Anchors: [0] = entry, [1] = stop loss (above entry), [2] = take profit (below entry)\n */\n getPositionInfo(): {\n entry: number;\n stopLoss: number;\n takeProfit: number;\n risk: number;\n reward: number;\n riskRewardRatio: number;\n riskPercent: number;\n rewardPercent: number;\n } {\n if (!this.isValid()) {\n return {\n entry: 0,\n stopLoss: 0,\n takeProfit: 0,\n risk: 0,\n reward: 0,\n riskRewardRatio: 0,\n riskPercent: 0,\n rewardPercent: 0,\n };\n }\n\n const entry = this._anchors[0].price;\n const stopLoss = this._anchors[1].price;\n const takeProfit = this._anchors[2].price;\n\n const risk = Math.abs(stopLoss - entry);\n const reward = Math.abs(entry - takeProfit);\n const riskRewardRatio = risk !== 0 ? reward / risk : 0;\n const riskPercent = entry !== 0 ? (risk / entry) * 100 : 0;\n const rewardPercent = entry !== 0 ? (reward / entry) * 100 : 0;\n\n return {\n entry,\n stopLoss,\n takeProfit,\n risk,\n reward,\n riskRewardRatio,\n riskPercent,\n rewardPercent,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return [];\n\n const geometries: Geometry[] = [];\n const width = 200;\n\n // Risk zone (entry to stop loss)\n const riskTop = Math.min(p1.y, p2.y);\n const riskHeight = Math.abs(p2.y - p1.y);\n geometries.push({\n type: 'rectangle',\n topLeft: { x: p1.x, y: riskTop },\n width,\n height: riskHeight,\n } as RectangleGeometry);\n\n // Reward zone (entry to take profit)\n const rewardTop = Math.min(p1.y, p3.y);\n const rewardHeight = Math.abs(p3.y - p1.y);\n geometries.push({\n type: 'rectangle',\n topLeft: { x: p1.x, y: rewardTop },\n width,\n height: rewardHeight,\n } as RectangleGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n const p3 = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!p1 || !p2 || !p3) return false;\n\n const width = 200;\n const left = p1.x;\n const right = p1.x + width;\n const top = Math.min(p2.y, p3.y);\n const bottom = Math.max(p2.y, p3.y);\n\n return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;\n }\n\n clone(newId: string): IDrawing {\n return new ShortPosition(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._positionOptions }\n );\n }\n\n static create(\n id: string,\n entry: Anchor,\n stopLoss: Anchor,\n takeProfit: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ShortPositionOptions>\n ): ShortPosition {\n return new ShortPosition(id, [entry, stopLoss, takeProfit], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { DateRange } from './date-range';\nimport { drawLine, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class DateRangePaneView implements IPrimitivePaneView {\n private _renderer: DateRangePaneRenderer;\n\n constructor(drawing: DateRange) {\n this._renderer = new DateRangePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'bottom';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass DateRangePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: DateRange;\n\n constructor(drawing: DateRange) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio, bitmapSize } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.dateRangeOptions;\n const info = this._drawing.getDateRangeInfo();\n const lineColor = this._drawing.style.lineColor || '#2196F3';\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const width = right - left;\n const height = bitmapSize.height / pixelRatio;\n\n // Draw filled background\n if (options.filled) {\n ctx.fillStyle = lineColor + '20';\n ctx.fillRect(left * pixelRatio, 0, width * pixelRatio, height * pixelRatio);\n }\n\n // Draw vertical lines at boundaries\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.setLineDash([5 * pixelRatio, 3 * pixelRatio]);\n\n drawLine(ctx, { x: p1.x, y: 0 }, { x: p1.x, y: height }, pixelRatio);\n drawLine(ctx, { x: p2.x, y: 0 }, { x: p2.x, y: height }, pixelRatio);\n\n ctx.setLineDash([]);\n\n // Draw horizontal connecting line\n const midY = height / 2;\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, { x: left, y: midY }, { x: right, y: midY }, pixelRatio);\n\n // Draw arrows at ends\n const arrowSize = 8;\n ctx.fillStyle = lineColor;\n\n // Left arrow\n ctx.beginPath();\n ctx.moveTo(left * pixelRatio, midY * pixelRatio);\n ctx.lineTo((left + arrowSize) * pixelRatio, (midY - arrowSize / 2) * pixelRatio);\n ctx.lineTo((left + arrowSize) * pixelRatio, (midY + arrowSize / 2) * pixelRatio);\n ctx.closePath();\n ctx.fill();\n\n // Right arrow\n ctx.beginPath();\n ctx.moveTo(right * pixelRatio, midY * pixelRatio);\n ctx.lineTo((right - arrowSize) * pixelRatio, (midY - arrowSize / 2) * pixelRatio);\n ctx.lineTo((right - arrowSize) * pixelRatio, (midY + arrowSize / 2) * pixelRatio);\n ctx.closePath();\n ctx.fill();\n\n // Draw info label\n const centerX = (left + right) / 2;\n const fontSize = 12;\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'bottom';\n\n // Background for text\n let labelText = '';\n if (options.showBars) {\n labelText += `${info.bars} bars`;\n }\n if (options.showDays) {\n if (labelText) labelText += ' | ';\n labelText += `${info.days} days`;\n }\n\n if (labelText) {\n const textMetrics = ctx.measureText(labelText);\n const textWidth = textMetrics.width / pixelRatio;\n const padding = 6;\n const labelY = midY - 10;\n\n // Draw label background\n ctx.fillStyle = '#1e222d';\n ctx.fillRect(\n (centerX - textWidth / 2 - padding) * pixelRatio,\n (labelY - fontSize - padding) * pixelRatio,\n (textWidth + padding * 2) * pixelRatio,\n (fontSize + padding * 2) * pixelRatio\n );\n\n // Draw label border\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(\n (centerX - textWidth / 2 - padding) * pixelRatio,\n (labelY - fontSize - padding) * pixelRatio,\n (textWidth + padding * 2) * pixelRatio,\n (fontSize + padding * 2) * pixelRatio\n );\n\n // Draw text\n ctx.fillStyle = '#ffffff';\n ctx.fillText(labelText, centerX * pixelRatio, labelY * pixelRatio);\n }\n\n // Draw date labels if enabled\n if (options.showDates) {\n ctx.font = `${10 * pixelRatio}px sans-serif`;\n ctx.fillStyle = lineColor;\n\n // Start date\n const startDate = this.formatTime(info.startTime);\n ctx.textAlign = 'center';\n ctx.textBaseline = 'top';\n ctx.fillText(startDate, p1.x * pixelRatio, (height - 25) * pixelRatio);\n\n // End date\n const endDate = this.formatTime(info.endTime);\n ctx.fillText(endDate, p2.x * pixelRatio, (height - 25) * pixelRatio);\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n\n private formatTime(time: any): string {\n if (typeof time === 'string') {\n return time;\n }\n if (typeof time === 'number') {\n const date = new Date(time * 1000);\n return date.toISOString().split('T')[0];\n }\n return String(time);\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, RectangleGeometry, LineGeometry } from '../../core/geometry';\nimport { DateRangePaneView } from './date-range-pane-view';\n\n/**\n * DateRange options\n */\nexport interface DateRangeOptions extends DrawingOptions {\n showBars?: boolean;\n showDays?: boolean;\n showDates?: boolean;\n filled?: boolean;\n}\n\n/**\n * DateRange - Time measurement tool.\n *\n * Features:\n * - Two anchor points for start and end time\n * - Shows number of bars between points\n * - Shows number of calendar days\n * - Highlighted time zone\n */\nexport class DateRange extends Drawing {\n readonly type = 'date-range';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _dateRangeOptions: DateRangeOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<DateRangeOptions> = {}\n ) {\n const { showBars, showDays, showDates, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._dateRangeOptions = {\n ...this._options,\n showBars: showBars ?? true,\n showDays: showDays ?? true,\n showDates: showDates ?? true,\n filled: filled ?? true,\n };\n }\n\n get dateRangeOptions(): DateRangeOptions {\n return this._dateRangeOptions;\n }\n\n setDateRangeOptions(options: Partial<DateRangeOptions>): void {\n this._dateRangeOptions = { ...this._dateRangeOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= DateRange.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new DateRangePaneView(this)];\n }\n\n /**\n * Get date range info\n */\n getDateRangeInfo(): {\n startTime: any;\n endTime: any;\n days: number;\n bars: number;\n } {\n if (!this.isValid()) {\n return { startTime: null, endTime: null, days: 0, bars: 0 };\n }\n\n const startTime = this._anchors[0].time;\n const endTime = this._anchors[1].time;\n\n // Calculate days difference\n let days = 0;\n if (typeof startTime === 'string' && typeof endTime === 'string') {\n const start = new Date(startTime);\n const end = new Date(endTime);\n days = Math.abs(Math.floor((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24)));\n } else if (typeof startTime === 'number' && typeof endTime === 'number') {\n days = Math.abs(Math.floor((endTime - startTime) / (60 * 60 * 24)));\n }\n\n // Bars count would need to be calculated based on actual data\n // For now, we'll approximate based on trading days (roughly 252 per year)\n const bars = days; // Simplified: 1 bar per day for daily chart\n\n return { startTime, endTime, days, bars };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n\n const left = Math.min(p1.x, p2.x);\n const width = Math.abs(p2.x - p1.x);\n\n // Full height rectangle\n geometries.push({\n type: 'rectangle',\n topLeft: { x: left, y: 0 },\n width,\n height: viewport.height,\n } as RectangleGeometry);\n\n // Vertical lines at start and end\n geometries.push({\n type: 'line',\n start: { x: p1.x, y: 0 },\n end: { x: p1.x, y: viewport.height },\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: { x: p2.x, y: 0 },\n end: { x: p2.x, y: viewport.height },\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n\n return point.x >= left && point.x <= right;\n }\n\n clone(newId: string): IDrawing {\n return new DateRange(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._dateRangeOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<DateRangeOptions>\n ): DateRange {\n return new DateRange(id, [start, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { DatePriceRange } from './date-price-range';\nimport { drawLine, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class DatePriceRangePaneView implements IPrimitivePaneView {\n private _renderer: DatePriceRangePaneRenderer;\n\n constructor(drawing: DatePriceRange) {\n this._renderer = new DatePriceRangePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass DatePriceRangePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: DatePriceRange;\n\n constructor(drawing: DatePriceRange) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p1 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p2 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p1 || !p2) return;\n\n const options = this._drawing.measureOptions;\n const info = this._drawing.getMeasureInfo();\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n const width = right - left;\n const height = bottom - top;\n\n // Choose color based on direction\n const color = info.isUp ? '#26a69a' : '#ef5350';\n\n // Draw filled background\n if (options.filled) {\n ctx.fillStyle = color + '20';\n ctx.fillRect(left * pixelRatio, top * pixelRatio, width * pixelRatio, height * pixelRatio);\n }\n\n // Draw border\n ctx.strokeStyle = color;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(left * pixelRatio, top * pixelRatio, width * pixelRatio, height * pixelRatio);\n\n // Draw diagonal measurement line\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, p1, p2, pixelRatio);\n\n // Draw horizontal and vertical guide lines\n ctx.setLineDash([3 * pixelRatio, 3 * pixelRatio]);\n ctx.lineWidth = 1 * pixelRatio;\n ctx.globalAlpha = 0.5;\n\n // Horizontal line from p1\n drawLine(ctx, p1, { x: p2.x, y: p1.y }, pixelRatio);\n // Vertical line from horizontal end to p2\n drawLine(ctx, { x: p2.x, y: p1.y }, p2, pixelRatio);\n\n ctx.setLineDash([]);\n ctx.globalAlpha = 1;\n\n // Draw info panel\n const centerX = (left + right) / 2;\n const centerY = (top + bottom) / 2;\n const fontSize = 11;\n const lineHeight = fontSize + 4;\n const padding = 8;\n\n // Build info lines\n const lines: string[] = [];\n\n if (options.showPrices) {\n const sign = info.priceChange >= 0 ? '+' : '';\n lines.push(`${sign}$${info.priceChange.toFixed(2)}`);\n }\n\n if (options.showPercentage) {\n const sign = info.priceChangePercent >= 0 ? '+' : '';\n lines.push(`${sign}${info.priceChangePercent.toFixed(2)}%`);\n }\n\n if (options.showBars) {\n lines.push(`${info.bars} bars`);\n }\n\n if (options.showDays) {\n lines.push(`${info.days} days`);\n }\n\n if (lines.length > 0) {\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n\n // Calculate panel dimensions\n let maxWidth = 0;\n for (const line of lines) {\n const textWidth = ctx.measureText(line).width / pixelRatio;\n maxWidth = Math.max(maxWidth, textWidth);\n }\n\n const panelWidth = maxWidth + padding * 2;\n const panelHeight = lines.length * lineHeight + padding * 2;\n const panelX = centerX - panelWidth / 2;\n const panelY = centerY - panelHeight / 2;\n\n // Draw panel background\n ctx.fillStyle = '#1e222d';\n ctx.fillRect(\n panelX * pixelRatio,\n panelY * pixelRatio,\n panelWidth * pixelRatio,\n panelHeight * pixelRatio\n );\n\n // Draw panel border\n ctx.strokeStyle = color;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(\n panelX * pixelRatio,\n panelY * pixelRatio,\n panelWidth * pixelRatio,\n panelHeight * pixelRatio\n );\n\n // Draw text\n ctx.fillStyle = color;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n for (let i = 0; i < lines.length; i++) {\n const textY = panelY + padding + (i + 0.5) * lineHeight;\n ctx.fillText(lines[i], centerX * pixelRatio, textY * pixelRatio);\n }\n }\n\n // Draw start/end markers\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.arc(p1.x * pixelRatio, p1.y * pixelRatio, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n ctx.beginPath();\n ctx.arc(p2.x * pixelRatio, p2.y * pixelRatio, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, RectangleGeometry, LineGeometry } from '../../core/geometry';\nimport { DatePriceRangePaneView } from './date-price-range-pane-view';\n\n/**\n * DatePriceRange options\n */\nexport interface DatePriceRangeOptions extends DrawingOptions {\n showPrices?: boolean;\n showPercentage?: boolean;\n showBars?: boolean;\n showDays?: boolean;\n filled?: boolean;\n}\n\n/**\n * DatePriceRange - Combined date and price measurement tool.\n *\n * Features:\n * - Two anchor points (diagonal corners)\n * - Shows price change (absolute and percentage)\n * - Shows time change (bars and days)\n * - Rectangular measurement zone\n */\nexport class DatePriceRange extends Drawing {\n readonly type = 'date-price-range';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _measureOptions: DatePriceRangeOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<DatePriceRangeOptions> = {}\n ) {\n const { showPrices, showPercentage, showBars, showDays, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._measureOptions = {\n ...this._options,\n showPrices: showPrices ?? true,\n showPercentage: showPercentage ?? true,\n showBars: showBars ?? true,\n showDays: showDays ?? true,\n filled: filled ?? true,\n };\n }\n\n get measureOptions(): DatePriceRangeOptions {\n return this._measureOptions;\n }\n\n setMeasureOptions(options: Partial<DatePriceRangeOptions>): void {\n this._measureOptions = { ...this._measureOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= DatePriceRange.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new DatePriceRangePaneView(this)];\n }\n\n /**\n * Get measurement info\n */\n getMeasureInfo(): {\n startPrice: number;\n endPrice: number;\n priceChange: number;\n priceChangePercent: number;\n startTime: any;\n endTime: any;\n days: number;\n bars: number;\n isUp: boolean;\n } {\n if (!this.isValid()) {\n return {\n startPrice: 0,\n endPrice: 0,\n priceChange: 0,\n priceChangePercent: 0,\n startTime: null,\n endTime: null,\n days: 0,\n bars: 0,\n isUp: true,\n };\n }\n\n const startPrice = this._anchors[0].price;\n const endPrice = this._anchors[1].price;\n const priceChange = endPrice - startPrice;\n const priceChangePercent = startPrice !== 0 ? (priceChange / startPrice) * 100 : 0;\n const isUp = priceChange >= 0;\n\n const startTime = this._anchors[0].time;\n const endTime = this._anchors[1].time;\n\n // Calculate days difference\n let days = 0;\n if (typeof startTime === 'string' && typeof endTime === 'string') {\n const start = new Date(startTime);\n const end = new Date(endTime);\n days = Math.abs(Math.floor((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24)));\n } else if (typeof startTime === 'number' && typeof endTime === 'number') {\n days = Math.abs(Math.floor((endTime - startTime) / (60 * 60 * 24)));\n }\n\n const bars = days;\n\n return {\n startPrice,\n endPrice,\n priceChange,\n priceChangePercent,\n startTime,\n endTime,\n days,\n bars,\n isUp,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return [];\n\n const geometries: Geometry[] = [];\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n const width = right - left;\n const height = bottom - top;\n\n // Rectangle\n geometries.push({\n type: 'rectangle',\n topLeft: { x: left, y: top },\n width,\n height,\n } as RectangleGeometry);\n\n // Diagonal line\n geometries.push({\n type: 'line',\n start: p1,\n end: p2,\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p1 = this.anchorToPixel(this._anchors[0], viewport);\n const p2 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p1 || !p2) return false;\n\n const left = Math.min(p1.x, p2.x);\n const right = Math.max(p1.x, p2.x);\n const top = Math.min(p1.y, p2.y);\n const bottom = Math.max(p1.y, p2.y);\n\n return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom;\n }\n\n clone(newId: string): IDrawing {\n return new DatePriceRange(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._measureOptions }\n );\n }\n\n static create(\n id: string,\n start: Anchor,\n end: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<DatePriceRangeOptions>\n ): DatePriceRange {\n return new DatePriceRange(id, [start, end], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Projection } from './projection';\nimport type { Point } from '../../core/types';\nimport { drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class ProjectionPaneView implements IPrimitivePaneView {\n private _renderer: ProjectionPaneRenderer;\n\n constructor(drawing: Projection) {\n this._renderer = new ProjectionPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ProjectionPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Projection;\n\n constructor(drawing: Projection) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const pA = this._drawing.anchorToPixel(anchors[0], viewport);\n const pB = this._drawing.anchorToPixel(anchors[1], viewport);\n const pC = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!pA || !pB || !pC) return;\n\n const options = this._drawing.projectionOptions;\n const info = this._drawing.getProjectionInfo();\n const lineColor = this._drawing.style.lineColor || '#9C27B0';\n\n // Calculate target point D\n const dy = pB.y - pA.y;\n const dx = pB.x - pA.x;\n const pD: Point = {\n x: pC.x + dx,\n y: pC.y + dy,\n };\n\n // Choose color based on direction\n const color = info.isUp ? '#26a69a' : '#ef5350';\n\n // Draw filled projection zone\n if (options.filled) {\n const left = Math.min(pC.x, pD.x);\n const top = Math.min(pC.y, pD.y);\n const width = Math.abs(pD.x - pC.x);\n const height = Math.abs(pD.y - pC.y);\n\n ctx.fillStyle = color + '20';\n ctx.fillRect(left * pixelRatio, top * pixelRatio, width * pixelRatio, height * pixelRatio);\n }\n\n // Draw reference line A-B\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, pA, pB, pixelRatio);\n\n // Draw projection line C-D\n ctx.strokeStyle = color;\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, pC, pD, pixelRatio);\n\n // Draw connecting lines (dashed)\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.globalAlpha = 0.5;\n drawDashedLine(ctx, pA, pC, [5, 3], pixelRatio);\n drawDashedLine(ctx, pB, pD, [5, 3], pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw point markers\n const points = [\n { point: pA, label: 'A' },\n { point: pB, label: 'B' },\n { point: pC, label: 'C' },\n { point: pD, label: 'D' },\n ];\n\n const fontSize = 11;\n ctx.font = `bold ${fontSize * pixelRatio}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n for (const { point, label } of points) {\n // Draw circle\n ctx.fillStyle = label === 'D' ? color : lineColor;\n ctx.beginPath();\n ctx.arc(point.x * pixelRatio, point.y * pixelRatio, 6 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw label\n ctx.fillStyle = '#ffffff';\n ctx.fillText(label, point.x * pixelRatio, point.y * pixelRatio);\n }\n\n // Draw info panel at target point D\n if (options.showLabels) {\n const panelX = pD.x + 15;\n const panelY = pD.y;\n const padding = 6;\n const lineHeight = fontSize + 3;\n\n const lines: string[] = [];\n\n if (options.showPrices) {\n lines.push(`Target: $${info.targetPrice.toFixed(2)}`);\n }\n\n if (options.showPercentage) {\n const sign = info.movePercent >= 0 ? '+' : '';\n lines.push(`Move: ${sign}${info.movePercent.toFixed(2)}%`);\n }\n\n if (lines.length > 0) {\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n\n let maxWidth = 0;\n for (const line of lines) {\n const textWidth = ctx.measureText(line).width / pixelRatio;\n maxWidth = Math.max(maxWidth, textWidth);\n }\n\n const boxWidth = maxWidth + padding * 2;\n const boxHeight = lines.length * lineHeight + padding * 2;\n\n // Draw background\n ctx.fillStyle = '#1e222d';\n ctx.fillRect(\n panelX * pixelRatio,\n (panelY - boxHeight / 2) * pixelRatio,\n boxWidth * pixelRatio,\n boxHeight * pixelRatio\n );\n\n // Draw border\n ctx.strokeStyle = color;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(\n panelX * pixelRatio,\n (panelY - boxHeight / 2) * pixelRatio,\n boxWidth * pixelRatio,\n boxHeight * pixelRatio\n );\n\n // Draw text\n ctx.fillStyle = color;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n\n for (let i = 0; i < lines.length; i++) {\n const textY = panelY - boxHeight / 2 + padding + i * lineHeight;\n ctx.fillText(lines[i], (panelX + padding) * pixelRatio, textY * pixelRatio);\n }\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry, RectangleGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { ProjectionPaneView } from './projection-pane-view';\n\n/**\n * Projection options\n */\nexport interface ProjectionOptions extends DrawingOptions {\n showPrices?: boolean;\n showPercentage?: boolean;\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * Projection - Price projection tool.\n *\n * Features:\n * - Three anchor points: initial move (A to B), projection start (C)\n * - Projects the A-B move from point C\n * - Shows target price and percentage\n */\nexport class Projection extends Drawing {\n readonly type = 'projection';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _projectionOptions: ProjectionOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ProjectionOptions> = {}\n ) {\n const { showPrices, showPercentage, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._projectionOptions = {\n ...this._options,\n showPrices: showPrices ?? true,\n showPercentage: showPercentage ?? true,\n showLabels: showLabels ?? true,\n filled: filled ?? true,\n };\n }\n\n get projectionOptions(): ProjectionOptions {\n return this._projectionOptions;\n }\n\n setProjectionOptions(options: Partial<ProjectionOptions>): void {\n this._projectionOptions = { ...this._projectionOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Projection.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ProjectionPaneView(this)];\n }\n\n /**\n * Get projection info\n * Anchors: [0] = A (start of reference move)\n * [1] = B (end of reference move)\n * [2] = C (projection start point)\n */\n getProjectionInfo(): {\n priceA: number;\n priceB: number;\n priceC: number;\n targetPrice: number;\n moveSize: number;\n movePercent: number;\n isUp: boolean;\n } {\n if (!this.isValid()) {\n return {\n priceA: 0,\n priceB: 0,\n priceC: 0,\n targetPrice: 0,\n moveSize: 0,\n movePercent: 0,\n isUp: true,\n };\n }\n\n const priceA = this._anchors[0].price;\n const priceB = this._anchors[1].price;\n const priceC = this._anchors[2].price;\n\n // Calculate the move from A to B\n const moveSize = priceB - priceA;\n const movePercent = priceA !== 0 ? (moveSize / priceA) * 100 : 0;\n\n // Project the same move from C\n const targetPrice = priceC + moveSize;\n const isUp = moveSize >= 0;\n\n return {\n priceA,\n priceB,\n priceC,\n targetPrice,\n moveSize,\n movePercent,\n isUp,\n };\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const pA = this.anchorToPixel(this._anchors[0], viewport);\n const pB = this.anchorToPixel(this._anchors[1], viewport);\n const pC = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!pA || !pB || !pC) return [];\n\n const geometries: Geometry[] = [];\n\n // Reference line A-B\n geometries.push({\n type: 'line',\n start: pA,\n end: pB,\n } as LineGeometry);\n\n // Calculate target point D (projection of A-B from C)\n const dy = pB.y - pA.y;\n const dx = pB.x - pA.x;\n const pD: Point = {\n x: pC.x + dx,\n y: pC.y + dy,\n };\n\n // Projection line C-D\n geometries.push({\n type: 'line',\n start: pC,\n end: pD,\n } as LineGeometry);\n\n // Connecting lines (optional visual aid)\n geometries.push({\n type: 'line',\n start: pA,\n end: pC,\n } as LineGeometry);\n\n geometries.push({\n type: 'line',\n start: pB,\n end: pD,\n } as LineGeometry);\n\n // Projection zone rectangle\n const left = Math.min(pC.x, pD.x);\n const right = Math.max(pC.x, pD.x);\n const top = Math.min(pC.y, pD.y);\n const bottom = Math.max(pC.y, pD.y);\n\n geometries.push({\n type: 'rectangle',\n topLeft: { x: left, y: top },\n width: right - left,\n height: bottom - top,\n } as RectangleGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const pA = this.anchorToPixel(this._anchors[0], viewport);\n const pB = this.anchorToPixel(this._anchors[1], viewport);\n const pC = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!pA || !pB || !pC) return false;\n\n const dy = pB.y - pA.y;\n const dx = pB.x - pA.x;\n const pD: Point = {\n x: pC.x + dx,\n y: pC.y + dy,\n };\n\n // Check if near any of the lines\n if (distanceToLineSegment(point, pA, pB) <= Projection.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, pC, pD) <= Projection.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, pA, pC) <= Projection.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, pB, pD) <= Projection.HIT_THRESHOLD) return true;\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new Projection(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._projectionOptions }\n );\n }\n\n static create(\n id: string,\n pointA: Anchor,\n pointB: Anchor,\n pointC: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ProjectionOptions>\n ): Projection {\n return new Projection(id, [pointA, pointB, pointC], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Forecast } from './forecast';\nimport type { Point } from '../../core/types';\nimport { drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class ForecastPaneView implements IPrimitivePaneView {\n private _renderer: ForecastPaneRenderer;\n\n constructor(drawing: Forecast) {\n this._renderer = new ForecastPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ForecastPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Forecast;\n\n constructor(drawing: Forecast) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const p0 = this._drawing.anchorToPixel(anchors[0], viewport);\n const p1 = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!p0 || !p1) return;\n\n const options = this._drawing.forecastOptions;\n const info = this._drawing.getForecastInfo();\n const color = info.isUp ? '#26a69a' : '#ef5350';\n const lineColor = this._drawing.style.lineColor || color;\n\n // Horizontal reference point\n const pH: Point = { x: p1.x, y: p0.y };\n\n // Draw filled zone\n if (options.filled) {\n const left = Math.min(p0.x, p1.x);\n const top = Math.min(p0.y, p1.y);\n const width = Math.abs(p1.x - p0.x);\n const height = Math.abs(p1.y - p0.y);\n\n ctx.fillStyle = color + '15';\n ctx.fillRect(left * pixelRatio, top * pixelRatio, width * pixelRatio, height * pixelRatio);\n }\n\n // Draw diagonal forecast line\n ctx.strokeStyle = color;\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, p0, p1, pixelRatio);\n\n // Draw horizontal reference line (dashed)\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.globalAlpha = 0.5;\n drawDashedLine(ctx, p0, pH, [5, 3], pixelRatio);\n\n // Draw vertical target line (dashed)\n drawDashedLine(ctx, pH, p1, [5, 3], pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw point markers\n const fontSize = 11;\n ctx.font = `bold ${fontSize * pixelRatio}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n // Start point\n ctx.fillStyle = lineColor;\n ctx.beginPath();\n ctx.arc(p0.x * pixelRatio, p0.y * pixelRatio, 5 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Target point\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.arc(p1.x * pixelRatio, p1.y * pixelRatio, 5 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw info labels\n if (options.showLabels) {\n const lines: string[] = [];\n\n if (options.showPrices) {\n lines.push(`Target: $${info.targetPrice.toFixed(2)}`);\n }\n\n if (options.showPercentage) {\n const sign = info.percentChange >= 0 ? '+' : '';\n lines.push(`${sign}${info.percentChange.toFixed(2)}%`);\n }\n\n if (lines.length > 0) {\n const panelX = p1.x + 10;\n const panelY = p1.y;\n const padding = 6;\n const lineHeight = fontSize + 3;\n\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n\n let maxWidth = 0;\n for (const line of lines) {\n const textWidth = ctx.measureText(line).width / pixelRatio;\n maxWidth = Math.max(maxWidth, textWidth);\n }\n\n const boxWidth = maxWidth + padding * 2;\n const boxHeight = lines.length * lineHeight + padding * 2;\n\n // Background\n ctx.fillStyle = '#1e222d';\n ctx.fillRect(\n panelX * pixelRatio,\n (panelY - boxHeight / 2) * pixelRatio,\n boxWidth * pixelRatio,\n boxHeight * pixelRatio\n );\n\n // Border\n ctx.strokeStyle = color;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(\n panelX * pixelRatio,\n (panelY - boxHeight / 2) * pixelRatio,\n boxWidth * pixelRatio,\n boxHeight * pixelRatio\n );\n\n // Text\n ctx.fillStyle = color;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n\n for (let i = 0; i < lines.length; i++) {\n const textY = panelY - boxHeight / 2 + padding + i * lineHeight;\n ctx.fillText(lines[i], (panelX + padding) * pixelRatio, textY * pixelRatio);\n }\n }\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { ForecastPaneView } from './forecast-pane-view';\n\n/**\n * Forecast options\n */\nexport interface ForecastOptions extends DrawingOptions {\n showPrices?: boolean;\n showPercentage?: boolean;\n showLabels?: boolean;\n filled?: boolean;\n}\n\n/**\n * Forecast - Price forecast projection tool.\n *\n * Features:\n * - Two anchor points defining a price range and time range\n * - Anchor 1: start price/time\n * - Anchor 2: target forecast price/time\n * - Shows projected zone with target price/percentage labels\n */\nexport class Forecast extends Drawing {\n readonly type = 'forecast';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _forecastOptions: ForecastOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ForecastOptions> = {}\n ) {\n const { showPrices, showPercentage, showLabels, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._forecastOptions = {\n ...this._options,\n showPrices: showPrices ?? true,\n showPercentage: showPercentage ?? true,\n showLabels: showLabels ?? true,\n filled: filled ?? true,\n };\n }\n\n get forecastOptions(): ForecastOptions {\n return this._forecastOptions;\n }\n\n setForecastOptions(options: Partial<ForecastOptions>): void {\n this._forecastOptions = { ...this._forecastOptions, ...options };\n this.requestUpdate();\n }\n\n getForecastInfo(): {\n startPrice: number;\n targetPrice: number;\n priceChange: number;\n percentChange: number;\n isUp: boolean;\n } {\n if (!this.isValid()) {\n return { startPrice: 0, targetPrice: 0, priceChange: 0, percentChange: 0, isUp: true };\n }\n\n const startPrice = this._anchors[0].price;\n const targetPrice = this._anchors[1].price;\n const priceChange = targetPrice - startPrice;\n const percentChange = startPrice !== 0 ? (priceChange / startPrice) * 100 : 0;\n const isUp = priceChange >= 0;\n\n return { startPrice, targetPrice, priceChange, percentChange, isUp };\n }\n\n isValid(): boolean {\n return this._anchors.length >= Forecast.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ForecastPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p0 || !p1) return [];\n\n const geometries: Geometry[] = [];\n\n // Main forecast line\n geometries.push({\n type: 'line',\n start: p0,\n end: p1,\n } as LineGeometry);\n\n // Horizontal reference from start\n geometries.push({\n type: 'line',\n start: p0,\n end: { x: p1.x, y: p0.y },\n } as LineGeometry);\n\n // Vertical target line\n geometries.push({\n type: 'line',\n start: { x: p1.x, y: p0.y },\n end: p1,\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p0 = this.anchorToPixel(this._anchors[0], viewport);\n const p1 = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!p0 || !p1) return false;\n\n // Check diagonal line\n if (distanceToLineSegment(point, p0, p1) <= Forecast.HIT_THRESHOLD) return true;\n\n // Check horizontal line\n const pH: Point = { x: p1.x, y: p0.y };\n if (distanceToLineSegment(point, p0, pH) <= Forecast.HIT_THRESHOLD) return true;\n\n // Check vertical line\n if (distanceToLineSegment(point, pH, p1) <= Forecast.HIT_THRESHOLD) return true;\n\n // Check if inside the filled zone\n if (this._forecastOptions.filled) {\n const left = Math.min(p0.x, p1.x);\n const right = Math.max(p0.x, p1.x);\n const top = Math.min(p0.y, p1.y);\n const bottom = Math.max(p0.y, p1.y);\n if (point.x >= left && point.x <= right && point.y >= top && point.y <= bottom) return true;\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new Forecast(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._forecastOptions }\n );\n }\n\n static create(\n id: string,\n startAnchor: Anchor,\n targetAnchor: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ForecastOptions>\n ): Forecast {\n return new Forecast(id, [startAnchor, targetAnchor], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { BarsPattern } from './bars-pattern';\nimport type { Point } from '../../core/types';\nimport { drawLine, drawControlPoints, drawDashedLine } from '../../rendering/canvas-utils';\n\nexport class BarsPatternPaneView implements IPrimitivePaneView {\n private _renderer: BarsPatternPaneRenderer;\n\n constructor(drawing: BarsPattern) {\n this._renderer = new BarsPatternPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass BarsPatternPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: BarsPattern;\n\n constructor(drawing: BarsPattern) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const pA = this._drawing.anchorToPixel(anchors[0], viewport);\n const pB = this._drawing.anchorToPixel(anchors[1], viewport);\n const pC = this._drawing.anchorToPixel(anchors[2], viewport);\n\n if (!pA || !pB || !pC) return;\n\n const options = this._drawing.barsPatternOptions;\n const lineColor = this._drawing.style.lineColor || '#FF9800';\n const patternColor = options.patternColor ?? '#FF9800';\n\n const dx = pB.x - pA.x;\n const dy = pB.y - pA.y;\n const pD: Point = { x: pC.x + dx, y: pC.y + dy };\n\n // Draw source pattern box\n if (options.filled) {\n const srcLeft = Math.min(pA.x, pB.x);\n const srcTop = Math.min(pA.y, pB.y);\n const srcW = Math.abs(pB.x - pA.x);\n const srcH = Math.abs(pB.y - pA.y);\n ctx.fillStyle = lineColor + '15';\n ctx.fillRect(srcLeft * pixelRatio, srcTop * pixelRatio, srcW * pixelRatio, srcH * pixelRatio);\n\n // Source border\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(srcLeft * pixelRatio, srcTop * pixelRatio, srcW * pixelRatio, srcH * pixelRatio);\n }\n\n // Draw source diagonal\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, pA, pB, pixelRatio);\n\n // Draw projected pattern box\n if (options.filled) {\n const projLeft = Math.min(pC.x, pD.x);\n const projTop = Math.min(pC.y, pD.y);\n const projW = Math.abs(pD.x - pC.x);\n const projH = Math.abs(pD.y - pC.y);\n ctx.fillStyle = patternColor + '20';\n ctx.fillRect(projLeft * pixelRatio, projTop * pixelRatio, projW * pixelRatio, projH * pixelRatio);\n\n // Projected border\n ctx.strokeStyle = patternColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.setLineDash([4 * pixelRatio, 3 * pixelRatio]);\n ctx.strokeRect(projLeft * pixelRatio, projTop * pixelRatio, projW * pixelRatio, projH * pixelRatio);\n ctx.setLineDash([]);\n }\n\n // Draw projected diagonal\n ctx.strokeStyle = patternColor;\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx, pC, pD, pixelRatio);\n\n // Draw connecting line B-C (dashed)\n ctx.strokeStyle = lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.globalAlpha = 0.5;\n drawDashedLine(ctx, pB, pC, [5, 3], pixelRatio);\n ctx.globalAlpha = 1;\n\n // Draw point markers\n const fontSize = 11;\n ctx.font = `bold ${fontSize * pixelRatio}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n const points = [\n { point: pA, label: 'A', color: lineColor },\n { point: pB, label: 'B', color: lineColor },\n { point: pC, label: 'C', color: patternColor },\n { point: pD, label: 'D', color: patternColor },\n ];\n\n for (const { point, label, color } of points) {\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.arc(point.x * pixelRatio, point.y * pixelRatio, 6 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n ctx.fillStyle = '#ffffff';\n ctx.fillText(label, point.x * pixelRatio, point.y * pixelRatio);\n }\n\n // Draw labels\n if (options.showLabels) {\n ctx.font = `${fontSize * pixelRatio}px sans-serif`;\n ctx.fillStyle = lineColor;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'bottom';\n ctx.fillText('Source', ((pA.x + pB.x) / 2) * pixelRatio, (Math.min(pA.y, pB.y) - 8) * pixelRatio);\n\n ctx.fillStyle = patternColor;\n ctx.fillText('Pattern', ((pC.x + pD.x) / 2) * pixelRatio, (Math.min(pC.y, pD.y) - 8) * pixelRatio);\n }\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, LineGeometry, RectangleGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { BarsPatternPaneView } from './bars-pattern-pane-view';\n\n/**\n * Bars Pattern options\n */\nexport interface BarsPatternOptions extends DrawingOptions {\n showLabels?: boolean;\n filled?: boolean;\n patternColor?: string;\n}\n\n/**\n * BarsPattern - Pattern projection tool.\n *\n * Features:\n * - Three anchor points: pattern start (A), pattern end (B), projection start (C)\n * - Copies the price pattern from A-B and projects it from C\n * - Shows the projected pattern zone\n */\nexport class BarsPattern extends Drawing {\n readonly type = 'bars-pattern';\n\n protected static readonly REQUIRED_ANCHORS = 3;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _barsPatternOptions: BarsPatternOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<BarsPatternOptions> = {}\n ) {\n const { showLabels, filled, patternColor, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._barsPatternOptions = {\n ...this._options,\n showLabels: showLabels ?? true,\n filled: filled ?? true,\n patternColor: patternColor ?? '#FF9800',\n };\n }\n\n get barsPatternOptions(): BarsPatternOptions {\n return this._barsPatternOptions;\n }\n\n setBarsPatternOptions(options: Partial<BarsPatternOptions>): void {\n this._barsPatternOptions = { ...this._barsPatternOptions, ...options };\n this.requestUpdate();\n }\n\n /**\n * Get pattern info.\n * A = pattern start, B = pattern end, C = projection start.\n * The pattern from A-B is projected starting at C.\n */\n getPatternInfo(): {\n priceRange: number;\n timeSpan: number;\n projectedEndPrice: number;\n } {\n if (!this.isValid()) {\n return { priceRange: 0, timeSpan: 0, projectedEndPrice: 0 };\n }\n\n const priceA = this._anchors[0].price;\n const priceB = this._anchors[1].price;\n const priceC = this._anchors[2].price;\n const priceRange = Math.abs(priceB - priceA);\n const projectedEndPrice = priceC + (priceB - priceA);\n\n return { priceRange, timeSpan: 0, projectedEndPrice };\n }\n\n isValid(): boolean {\n return this._anchors.length >= BarsPattern.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new BarsPatternPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const pA = this.anchorToPixel(this._anchors[0], viewport);\n const pB = this.anchorToPixel(this._anchors[1], viewport);\n const pC = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!pA || !pB || !pC) return [];\n\n const geometries: Geometry[] = [];\n\n // Source pattern box A-B\n const srcLeft = Math.min(pA.x, pB.x);\n const srcTop = Math.min(pA.y, pB.y);\n geometries.push({\n type: 'rectangle',\n topLeft: { x: srcLeft, y: srcTop },\n width: Math.abs(pB.x - pA.x),\n height: Math.abs(pB.y - pA.y),\n } as RectangleGeometry);\n\n // Source diagonal\n geometries.push({\n type: 'line',\n start: pA,\n end: pB,\n } as LineGeometry);\n\n // Projected pattern\n const dx = pB.x - pA.x;\n const dy = pB.y - pA.y;\n const pD: Point = { x: pC.x + dx, y: pC.y + dy };\n\n // Projected box C-D\n const projLeft = Math.min(pC.x, pD.x);\n const projTop = Math.min(pC.y, pD.y);\n geometries.push({\n type: 'rectangle',\n topLeft: { x: projLeft, y: projTop },\n width: Math.abs(pD.x - pC.x),\n height: Math.abs(pD.y - pC.y),\n } as RectangleGeometry);\n\n // Projected diagonal\n geometries.push({\n type: 'line',\n start: pC,\n end: pD,\n } as LineGeometry);\n\n // Connecting lines\n geometries.push({\n type: 'line',\n start: pB,\n end: pC,\n } as LineGeometry);\n\n return geometries;\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const pA = this.anchorToPixel(this._anchors[0], viewport);\n const pB = this.anchorToPixel(this._anchors[1], viewport);\n const pC = this.anchorToPixel(this._anchors[2], viewport);\n\n if (!pA || !pB || !pC) return false;\n\n const dx = pB.x - pA.x;\n const dy = pB.y - pA.y;\n const pD: Point = { x: pC.x + dx, y: pC.y + dy };\n\n // Check lines\n if (distanceToLineSegment(point, pA, pB) <= BarsPattern.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, pC, pD) <= BarsPattern.HIT_THRESHOLD) return true;\n if (distanceToLineSegment(point, pB, pC) <= BarsPattern.HIT_THRESHOLD) return true;\n\n // Check inside source box\n const srcLeft = Math.min(pA.x, pB.x);\n const srcRight = Math.max(pA.x, pB.x);\n const srcTop = Math.min(pA.y, pB.y);\n const srcBottom = Math.max(pA.y, pB.y);\n if (point.x >= srcLeft && point.x <= srcRight && point.y >= srcTop && point.y <= srcBottom) return true;\n\n // Check inside projected box\n const projLeft = Math.min(pC.x, pD.x);\n const projRight = Math.max(pC.x, pD.x);\n const projTop = Math.min(pC.y, pD.y);\n const projBottom = Math.max(pC.y, pD.y);\n if (point.x >= projLeft && point.x <= projRight && point.y >= projTop && point.y <= projBottom) return true;\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new BarsPattern(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._barsPatternOptions }\n );\n }\n\n static create(\n id: string,\n pointA: Anchor,\n pointB: Anchor,\n pointC: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<BarsPatternOptions>\n ): BarsPattern {\n return new BarsPattern(id, [pointA, pointB, pointC], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { TextAnnotation } from './text-annotation';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class TextAnnotationPaneView implements IPrimitivePaneView {\n private _renderer: TextAnnotationPaneRenderer;\n\n constructor(drawing: TextAnnotation) {\n this._renderer = new TextAnnotationPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass TextAnnotationPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: TextAnnotation;\n\n constructor(drawing: TextAnnotation) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.textOptions;\n const text = options.text ?? '';\n const fontSize = (options.fontSize ?? 14) * pixelRatio;\n const fontFamily = options.fontFamily ?? 'sans-serif';\n const fontWeight = options.fontWeight ?? 'normal';\n const padding = (options.padding ?? 8) * pixelRatio;\n\n // Set up font\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.textAlign = options.textAlign ?? 'left';\n ctx.textBaseline = 'middle';\n\n // Measure text\n const metrics = ctx.measureText(text);\n const textWidth = metrics.width;\n const textHeight = fontSize;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n // Calculate box position based on alignment\n let boxX = x;\n if (options.textAlign === 'center') {\n boxX = x - textWidth / 2;\n } else if (options.textAlign === 'right') {\n boxX = x - textWidth;\n }\n\n // Draw background\n if (options.backgroundColor) {\n ctx.fillStyle = options.backgroundColor;\n ctx.beginPath();\n ctx.roundRect(\n boxX - padding,\n y - textHeight / 2 - padding,\n textWidth + padding * 2,\n textHeight + padding * 2,\n 4 * pixelRatio\n );\n ctx.fill();\n }\n\n // Draw border\n if (options.borderColor) {\n ctx.strokeStyle = options.borderColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.roundRect(\n boxX - padding,\n y - textHeight / 2 - padding,\n textWidth + padding * 2,\n textHeight + padding * 2,\n 4 * pixelRatio\n );\n ctx.stroke();\n }\n\n // Draw text\n ctx.fillStyle = this._drawing.style.labelColor ?? '#000000';\n ctx.fillText(text, x, y);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, TextGeometry } from '../../core/geometry';\nimport { TextAnnotationPaneView } from './text-annotation-pane-view';\n\n/**\n * TextAnnotation options\n */\nexport interface TextAnnotationOptions extends DrawingOptions {\n text?: string;\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: string;\n textAlign?: CanvasTextAlign;\n backgroundColor?: string;\n borderColor?: string;\n padding?: number;\n}\n\n/**\n * TextAnnotation - A text label placed on the chart.\n *\n * Features:\n * - Single anchor point (position)\n * - Customizable text, font, alignment\n * - Optional background and border\n */\nexport class TextAnnotation extends Drawing {\n readonly type = 'text-annotation';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _textOptions: TextAnnotationOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<TextAnnotationOptions> = {}\n ) {\n const { text, fontSize, fontFamily, fontWeight, textAlign, backgroundColor, borderColor, padding, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._textOptions = {\n ...this._options,\n text: text ?? 'Text',\n fontSize: fontSize ?? 14,\n fontFamily: fontFamily ?? 'sans-serif',\n fontWeight: fontWeight ?? 'normal',\n textAlign: textAlign ?? 'left',\n backgroundColor: backgroundColor ?? 'rgba(255, 255, 255, 0.9)',\n borderColor: borderColor ?? this._style.lineColor,\n padding: padding ?? 8,\n };\n }\n\n get textOptions(): TextAnnotationOptions {\n return this._textOptions;\n }\n\n setTextOptions(options: Partial<TextAnnotationOptions>): void {\n this._textOptions = { ...this._textOptions, ...options };\n this.requestUpdate();\n }\n\n setText(text: string): void {\n this._textOptions.text = text;\n this.requestUpdate();\n }\n\n getText(): string {\n return this._textOptions.text ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= TextAnnotation.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new TextAnnotationPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n const textGeometry: TextGeometry = {\n type: 'text',\n position: p,\n text: this._textOptions.text ?? '',\n font: `${this._textOptions.fontWeight} ${this._textOptions.fontSize}px ${this._textOptions.fontFamily}`,\n color: this._style.labelColor,\n align: this._textOptions.textAlign,\n baseline: 'middle',\n };\n\n return [textGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n // Approximate hit box based on text dimensions\n const estimatedWidth = (this._textOptions.text?.length ?? 0) * (this._textOptions.fontSize ?? 14) * 0.6;\n const estimatedHeight = (this._textOptions.fontSize ?? 14) * 1.5;\n const padding = this._textOptions.padding ?? 8;\n\n return (\n point.x >= p.x - padding &&\n point.x <= p.x + estimatedWidth + padding &&\n point.y >= p.y - estimatedHeight / 2 - padding &&\n point.y <= p.y + estimatedHeight / 2 + padding\n );\n }\n\n clone(newId: string): IDrawing {\n return new TextAnnotation(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._textOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n text: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<TextAnnotationOptions>\n ): TextAnnotation {\n return new TextAnnotation(id, [position], style, { ...options, text });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Callout } from './callout';\nimport { drawControlPoints, drawLine } from '../../rendering/canvas-utils';\n\nexport class CalloutPaneView implements IPrimitivePaneView {\n private _renderer: CalloutPaneRenderer;\n\n constructor(drawing: Callout) {\n this._renderer = new CalloutPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass CalloutPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Callout;\n\n constructor(drawing: Callout) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const target = this._drawing.anchorToPixel(anchors[0], viewport);\n const boxPos = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!target || !boxPos) return;\n\n const options = this._drawing.calloutOptions;\n const text = options.text ?? '';\n const fontSize = (options.fontSize ?? 12) * pixelRatio;\n const fontFamily = options.fontFamily ?? 'sans-serif';\n const padding = (options.padding ?? 8) * pixelRatio;\n\n // Set up font\n ctx.font = `${fontSize}px ${fontFamily}`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n\n // Measure text\n const metrics = ctx.measureText(text);\n const textWidth = metrics.width;\n const textHeight = fontSize;\n\n const boxX = boxPos.x * pixelRatio;\n const boxY = boxPos.y * pixelRatio;\n const targetX = target.x * pixelRatio;\n const targetY = target.y * pixelRatio;\n\n const boxWidth = textWidth + padding * 2;\n const boxHeight = textHeight + padding * 2;\n\n // Draw pointer line\n ctx.strokeStyle = options.borderColor ?? '#FFC107';\n ctx.lineWidth = 2 * pixelRatio;\n drawLine(ctx,\n { x: target.x, y: target.y },\n { x: boxPos.x, y: boxPos.y },\n pixelRatio\n );\n\n // Draw target dot\n ctx.fillStyle = options.borderColor ?? '#FFC107';\n ctx.beginPath();\n ctx.arc(targetX, targetY, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw box background\n ctx.fillStyle = options.backgroundColor ?? 'rgba(255, 255, 200, 0.95)';\n ctx.beginPath();\n ctx.roundRect(\n boxX - padding,\n boxY - boxHeight / 2,\n boxWidth,\n boxHeight,\n 4 * pixelRatio\n );\n ctx.fill();\n\n // Draw box border\n ctx.strokeStyle = options.borderColor ?? '#FFC107';\n ctx.lineWidth = 1 * pixelRatio;\n ctx.stroke();\n\n // Draw text\n ctx.fillStyle = this._drawing.style.labelColor ?? '#000000';\n ctx.fillText(text, boxX, boxY);\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { CalloutPaneView } from './callout-pane-view';\n\n/**\n * Callout options\n */\nexport interface CalloutOptions extends DrawingOptions {\n text?: string;\n fontSize?: number;\n fontFamily?: string;\n backgroundColor?: string;\n borderColor?: string;\n padding?: number;\n pointerSize?: number;\n}\n\n/**\n * Callout - A text box with a pointer to a specific point.\n *\n * Features:\n * - Two anchor points (target and box position)\n * - Text box with pointer/arrow to target\n * - Customizable appearance\n */\nexport class Callout extends Drawing {\n readonly type = 'callout';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _calloutOptions: CalloutOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<CalloutOptions> = {}\n ) {\n const { text, fontSize, fontFamily, backgroundColor, borderColor, padding, pointerSize, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._calloutOptions = {\n ...this._options,\n text: text ?? 'Callout',\n fontSize: fontSize ?? 12,\n fontFamily: fontFamily ?? 'sans-serif',\n backgroundColor: backgroundColor ?? 'rgba(255, 255, 200, 0.95)',\n borderColor: borderColor ?? '#FFC107',\n padding: padding ?? 8,\n pointerSize: pointerSize ?? 10,\n };\n }\n\n get calloutOptions(): CalloutOptions {\n return this._calloutOptions;\n }\n\n setCalloutOptions(options: Partial<CalloutOptions>): void {\n this._calloutOptions = { ...this._calloutOptions, ...options };\n this.requestUpdate();\n }\n\n setText(text: string): void {\n this._calloutOptions.text = text;\n this.requestUpdate();\n }\n\n getText(): string {\n return this._calloutOptions.text ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= Callout.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new CalloutPaneView(this)];\n }\n\n computeGeometry(_viewport: Viewport): Geometry[] {\n // Callout uses custom rendering, no standard geometry\n return [];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const target = this.anchorToPixel(this._anchors[0], viewport);\n const boxPos = this.anchorToPixel(this._anchors[1], viewport);\n\n if (!target || !boxPos) return false;\n\n // Check if near target point\n const distToTarget = Math.sqrt(\n Math.pow(point.x - target.x, 2) + Math.pow(point.y - target.y, 2)\n );\n if (distToTarget <= Callout.HIT_THRESHOLD) return true;\n\n // Check if inside text box (approximate)\n const options = this._calloutOptions;\n const estimatedWidth = (options.text?.length ?? 0) * (options.fontSize ?? 12) * 0.6 + (options.padding ?? 8) * 2;\n const estimatedHeight = (options.fontSize ?? 12) * 1.5 + (options.padding ?? 8) * 2;\n\n return (\n point.x >= boxPos.x &&\n point.x <= boxPos.x + estimatedWidth &&\n point.y >= boxPos.y - estimatedHeight / 2 &&\n point.y <= boxPos.y + estimatedHeight / 2\n );\n }\n\n clone(newId: string): IDrawing {\n return new Callout(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._calloutOptions }\n );\n }\n\n static create(\n id: string,\n target: Anchor,\n boxPosition: Anchor,\n text: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<CalloutOptions>\n ): Callout {\n return new Callout(id, [target, boxPosition], style, { ...options, text });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Brush } from './brush';\nimport type { Point } from '../../core/types';\nimport { applyStyle, drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class BrushPaneView implements IPrimitivePaneView {\n private _renderer: BrushPaneRenderer;\n\n constructor(drawing: Brush) {\n this._renderer = new BrushPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'normal';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass BrushPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Brush;\n\n constructor(drawing: Brush) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const points: Point[] = [];\n for (const anchor of anchors) {\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return;\n\n const options = this._drawing.brushOptions;\n const brushSize = (options.brushSize ?? 3) * pixelRatio;\n\n applyStyle(ctx, this._drawing.style, pixelRatio);\n ctx.lineWidth = brushSize;\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n\n // Draw the path\n ctx.beginPath();\n ctx.moveTo(points[0].x * pixelRatio, points[0].y * pixelRatio);\n\n // Use quadratic curves for smoother lines\n for (let i = 1; i < points.length - 1; i++) {\n ctx.quadraticCurveTo(\n points[i].x * pixelRatio,\n points[i].y * pixelRatio,\n (points[i].x + points[i + 1].x) / 2 * pixelRatio,\n (points[i].y + points[i + 1].y) / 2 * pixelRatio\n );\n }\n\n // Last point\n if (points.length > 1) {\n ctx.lineTo(\n points[points.length - 1].x * pixelRatio,\n points[points.length - 1].y * pixelRatio\n );\n }\n\n ctx.stroke();\n\n // Draw control points if selected (only first and last for brush)\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n // Only show first and last control points for brush\n const controlPoints = [\n { index: 0, x: points[0].x, y: points[0].y, radius: 6 },\n { index: points.length - 1, x: points[points.length - 1].x, y: points[points.length - 1].y, radius: 6 },\n ];\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { BrushPaneView } from './brush-pane-view';\n\n/**\n * Brush options\n */\nexport interface BrushOptions extends DrawingOptions {\n brushSize?: number;\n smoothing?: number;\n}\n\n/**\n * Brush - Freehand drawing tool.\n *\n * Features:\n * - Multiple anchor points forming a path\n * - Variable brush size\n * - Smooth line rendering\n */\nexport class Brush extends Drawing {\n readonly type = 'brush';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _brushOptions: BrushOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<BrushOptions> = {}\n ) {\n const { brushSize, smoothing, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._brushOptions = {\n ...this._options,\n brushSize: brushSize ?? 3,\n smoothing: smoothing ?? 0.5,\n };\n }\n\n get brushOptions(): BrushOptions {\n return this._brushOptions;\n }\n\n setBrushOptions(options: Partial<BrushOptions>): void {\n this._brushOptions = { ...this._brushOptions, ...options };\n this.requestUpdate();\n }\n\n /**\n * Add a point to the brush path\n */\n addPoint(anchor: Anchor): void {\n this._anchors.push(anchor);\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Brush.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new BrushPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points,\n closed: false,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n // Check if near any segment\n for (let i = 0; i < points.length - 1; i++) {\n const dist = distanceToLineSegment(point, points[i], points[i + 1]);\n if (dist <= Brush.HIT_THRESHOLD + (this._brushOptions.brushSize ?? 3)) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new Brush(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._brushOptions }\n );\n }\n\n static create(\n id: string,\n points: Anchor[],\n style?: Partial<DrawingStyle>,\n options?: Partial<BrushOptions>\n ): Brush {\n return new Brush(id, points, style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Highlighter } from './highlighter';\nimport type { Point } from '../../core/types';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class HighlighterPaneView implements IPrimitivePaneView {\n private _renderer: HighlighterPaneRenderer;\n\n constructor(drawing: Highlighter) {\n this._renderer = new HighlighterPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'bottom';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass HighlighterPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Highlighter;\n\n constructor(drawing: Highlighter) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const options = this._drawing.highlighterOptions;\n const highlighterWidth = options.highlighterWidth ?? 20;\n const opacity = options.opacity ?? 0.4;\n\n // Get all points\n const points: Point[] = [];\n for (const anchor of this._drawing.anchors) {\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return;\n\n // Draw the highlighter stroke\n ctx.save();\n ctx.globalAlpha = opacity;\n ctx.strokeStyle = this._drawing.style.lineColor || '#FFEB3B';\n ctx.lineWidth = highlighterWidth * pixelRatio;\n ctx.lineCap = 'round';\n ctx.lineJoin = 'round';\n\n ctx.beginPath();\n ctx.moveTo(points[0].x * pixelRatio, points[0].y * pixelRatio);\n\n for (let i = 1; i < points.length; i++) {\n ctx.lineTo(points[i].x * pixelRatio, points[i].y * pixelRatio);\n }\n\n ctx.stroke();\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, PolygonGeometry } from '../../core/geometry';\nimport { distanceToLineSegment } from '../../core/geometry';\nimport { HighlighterPaneView } from './highlighter-pane-view';\n\n/**\n * Highlighter options\n */\nexport interface HighlighterOptions extends DrawingOptions {\n highlighterWidth?: number;\n opacity?: number;\n}\n\n/**\n * Highlighter - Semi-transparent highlight drawing tool.\n *\n * Features:\n * - Multiple anchor points forming a path\n * - Wide, semi-transparent stroke\n * - Ideal for marking important areas\n */\nexport class Highlighter extends Drawing {\n readonly type = 'highlighter';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 15;\n\n private _highlighterOptions: HighlighterOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<HighlighterOptions> = {}\n ) {\n const { highlighterWidth, opacity, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._highlighterOptions = {\n ...this._options,\n highlighterWidth: highlighterWidth ?? 20,\n opacity: opacity ?? 0.4,\n };\n }\n\n get highlighterOptions(): HighlighterOptions {\n return this._highlighterOptions;\n }\n\n setHighlighterOptions(options: Partial<HighlighterOptions>): void {\n this._highlighterOptions = { ...this._highlighterOptions, ...options };\n this.requestUpdate();\n }\n\n /**\n * Add a point to the highlighter path\n */\n addPoint(anchor: Anchor): void {\n this._anchors.push(anchor);\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= Highlighter.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new HighlighterPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n if (points.length < 2) return [];\n\n const polygonGeometry: PolygonGeometry = {\n type: 'polygon',\n points,\n closed: false,\n };\n\n return [polygonGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const points: Point[] = [];\n for (const anchor of this._anchors) {\n const p = this.anchorToPixel(anchor, viewport);\n if (p) points.push(p);\n }\n\n // Check if near any segment\n for (let i = 0; i < points.length - 1; i++) {\n const dist = distanceToLineSegment(point, points[i], points[i + 1]);\n if (dist <= Highlighter.HIT_THRESHOLD + (this._highlighterOptions.highlighterWidth ?? 20) / 2) {\n return true;\n }\n }\n\n return false;\n }\n\n clone(newId: string): IDrawing {\n return new Highlighter(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._highlighterOptions }\n );\n }\n\n static create(\n id: string,\n points: Anchor[],\n style?: Partial<DrawingStyle>,\n options?: Partial<HighlighterOptions>\n ): Highlighter {\n return new Highlighter(id, points, style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ArrowMarker } from './arrow-marker';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class ArrowMarkerPaneView implements IPrimitivePaneView {\n private _renderer: ArrowMarkerPaneRenderer;\n\n constructor(drawing: ArrowMarker) {\n this._renderer = new ArrowMarkerPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ArrowMarkerPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ArrowMarker;\n\n constructor(drawing: ArrowMarker) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const vertices = this._drawing.getArrowVertices(viewport);\n if (!vertices || vertices.length < 3) return;\n\n const options = this._drawing.arrowOptions;\n const style = this._drawing.style;\n\n ctx.save();\n\n // Draw the arrow triangle\n ctx.beginPath();\n ctx.moveTo(vertices[0].x * pixelRatio, vertices[0].y * pixelRatio);\n for (let i = 1; i < vertices.length; i++) {\n ctx.lineTo(vertices[i].x * pixelRatio, vertices[i].y * pixelRatio);\n }\n ctx.closePath();\n\n // Fill\n if (options.filled) {\n ctx.fillStyle = style.lineColor;\n ctx.fill();\n }\n\n // Stroke\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = style.lineWidth * pixelRatio;\n ctx.stroke();\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { ArrowMarkerPaneView } from './arrow-marker-pane-view';\n\n/**\n * Arrow direction\n */\nexport type ArrowDirection = 'up' | 'down' | 'left' | 'right';\n\n/**\n * Arrow marker options\n */\nexport interface ArrowMarkerOptions extends DrawingOptions {\n direction?: ArrowDirection;\n size?: number;\n filled?: boolean;\n}\n\n/**\n * Arrow Marker - A directional arrow placed at a single point.\n *\n * Features:\n * - Single anchor point\n * - Configurable direction (up, down, left, right)\n * - Configurable size\n * - Optional fill\n */\nexport class ArrowMarker extends Drawing {\n readonly type = 'arrow-marker';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _arrowOptions: ArrowMarkerOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ArrowMarkerOptions> = {}\n ) {\n const { direction, size, filled, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._arrowOptions = {\n ...this._options,\n direction: direction ?? 'up',\n size: size ?? 20,\n filled: filled ?? true,\n };\n }\n\n get arrowOptions(): ArrowMarkerOptions {\n return this._arrowOptions;\n }\n\n setArrowOptions(options: Partial<ArrowMarkerOptions>): void {\n this._arrowOptions = { ...this._arrowOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= ArrowMarker.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ArrowMarkerPaneView(this)];\n }\n\n /**\n * Get arrow vertices based on position and direction\n */\n getArrowVertices(viewport: Viewport): Point[] | null {\n if (!this.isValid()) return null;\n\n const anchor = this.anchorToPixel(this._anchors[0], viewport);\n if (!anchor) return null;\n\n const size = this._arrowOptions.size ?? 20;\n const direction = this._arrowOptions.direction ?? 'up';\n\n // Arrow is an isoceles triangle\n const halfBase = size * 0.5;\n const height = size;\n\n switch (direction) {\n case 'up':\n return [\n { x: anchor.x, y: anchor.y - height / 2 }, // tip\n { x: anchor.x - halfBase, y: anchor.y + height / 2 }, // bottom left\n { x: anchor.x + halfBase, y: anchor.y + height / 2 }, // bottom right\n ];\n case 'down':\n return [\n { x: anchor.x, y: anchor.y + height / 2 }, // tip\n { x: anchor.x - halfBase, y: anchor.y - height / 2 }, // top left\n { x: anchor.x + halfBase, y: anchor.y - height / 2 }, // top right\n ];\n case 'left':\n return [\n { x: anchor.x - height / 2, y: anchor.y }, // tip\n { x: anchor.x + height / 2, y: anchor.y - halfBase }, // top right\n { x: anchor.x + height / 2, y: anchor.y + halfBase }, // bottom right\n ];\n case 'right':\n return [\n { x: anchor.x + height / 2, y: anchor.y }, // tip\n { x: anchor.x - height / 2, y: anchor.y - halfBase }, // top left\n { x: anchor.x - height / 2, y: anchor.y + halfBase }, // bottom left\n ];\n default:\n return null;\n }\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const vertices = this.getArrowVertices(viewport);\n if (!vertices) return [];\n\n return [{\n type: 'polygon',\n points: vertices,\n closed: true,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const vertices = this.getArrowVertices(viewport);\n if (!vertices || vertices.length < 3) return false;\n\n // Point in triangle test using barycentric coordinates\n return this.pointInTriangle(point, vertices[0], vertices[1], vertices[2]);\n }\n\n private pointInTriangle(p: Point, v1: Point, v2: Point, v3: Point): boolean {\n const sign = (p1: Point, p2: Point, p3: Point): number => {\n return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);\n };\n\n const d1 = sign(p, v1, v2);\n const d2 = sign(p, v2, v3);\n const d3 = sign(p, v3, v1);\n\n const hasNeg = (d1 < 0) || (d2 < 0) || (d3 < 0);\n const hasPos = (d1 > 0) || (d2 > 0) || (d3 > 0);\n\n return !(hasNeg && hasPos);\n }\n\n clone(newId: string): IDrawing {\n return new ArrowMarker(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._arrowOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ArrowMarkerOptions>\n ): ArrowMarker {\n return new ArrowMarker(id, [position], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ArrowMarkUp } from './arrow-mark-up';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class ArrowMarkUpPaneView implements IPrimitivePaneView {\n private _renderer: ArrowMarkUpPaneRenderer;\n\n constructor(drawing: ArrowMarkUp) {\n this._renderer = new ArrowMarkUpPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ArrowMarkUpPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ArrowMarkUp;\n\n constructor(drawing: ArrowMarkUp) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const vertices = this._drawing.getArrowVertices(viewport);\n if (!vertices || vertices.length < 3) return;\n\n const style = this._drawing.style;\n\n ctx.save();\n\n // Draw filled arrow\n ctx.beginPath();\n ctx.moveTo(vertices[0].x * pixelRatio, vertices[0].y * pixelRatio);\n for (let i = 1; i < vertices.length; i++) {\n ctx.lineTo(vertices[i].x * pixelRatio, vertices[i].y * pixelRatio);\n }\n ctx.closePath();\n\n ctx.fillStyle = style.lineColor;\n ctx.fill();\n\n // Optional stroke for definition\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.stroke();\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { ArrowMarkUpPaneView } from './arrow-mark-up-pane-view';\n\n/**\n * Arrow Mark Up options\n */\nexport interface ArrowMarkUpOptions extends DrawingOptions {\n size?: number;\n}\n\n/**\n * Arrow Mark Up - An upward pointing arrow marker (bullish signal).\n *\n * Features:\n * - Single anchor point\n * - Always points up\n * - Typically placed below price bars\n * - Green color by default\n */\nexport class ArrowMarkUp extends Drawing {\n readonly type = 'arrow-mark-up';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _arrowOptions: ArrowMarkUpOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ArrowMarkUpOptions> = {}\n ) {\n const { size, ...baseOptions } = options;\n\n // Default to green for bullish\n const defaultStyle: Partial<DrawingStyle> = {\n lineColor: '#26a69a',\n ...style,\n };\n\n super(id, anchors, defaultStyle, baseOptions);\n\n this._arrowOptions = {\n ...this._options,\n size: size ?? 16,\n };\n }\n\n get arrowOptions(): ArrowMarkUpOptions {\n return this._arrowOptions;\n }\n\n setArrowOptions(options: Partial<ArrowMarkUpOptions>): void {\n this._arrowOptions = { ...this._arrowOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= ArrowMarkUp.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ArrowMarkUpPaneView(this)];\n }\n\n /**\n * Get arrow vertices (always points up)\n */\n getArrowVertices(viewport: Viewport): Point[] | null {\n if (!this.isValid()) return null;\n\n const anchor = this.anchorToPixel(this._anchors[0], viewport);\n if (!anchor) return null;\n\n const size = this._arrowOptions.size ?? 16;\n const halfBase = size * 0.6;\n const height = size;\n\n // Upward pointing arrow\n return [\n { x: anchor.x, y: anchor.y - height }, // tip (top)\n { x: anchor.x - halfBase, y: anchor.y }, // bottom left\n { x: anchor.x + halfBase, y: anchor.y }, // bottom right\n ];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const vertices = this.getArrowVertices(viewport);\n if (!vertices) return [];\n\n return [{\n type: 'polygon',\n points: vertices,\n closed: true,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const vertices = this.getArrowVertices(viewport);\n if (!vertices || vertices.length < 3) return false;\n\n return this.pointInTriangle(point, vertices[0], vertices[1], vertices[2]);\n }\n\n private pointInTriangle(p: Point, v1: Point, v2: Point, v3: Point): boolean {\n const sign = (p1: Point, p2: Point, p3: Point): number => {\n return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);\n };\n\n const d1 = sign(p, v1, v2);\n const d2 = sign(p, v2, v3);\n const d3 = sign(p, v3, v1);\n\n const hasNeg = (d1 < 0) || (d2 < 0) || (d3 < 0);\n const hasPos = (d1 > 0) || (d2 > 0) || (d3 > 0);\n\n return !(hasNeg && hasPos);\n }\n\n clone(newId: string): IDrawing {\n return new ArrowMarkUp(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._arrowOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ArrowMarkUpOptions>\n ): ArrowMarkUp {\n return new ArrowMarkUp(id, [position], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { ArrowMarkDown } from './arrow-mark-down';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class ArrowMarkDownPaneView implements IPrimitivePaneView {\n private _renderer: ArrowMarkDownPaneRenderer;\n\n constructor(drawing: ArrowMarkDown) {\n this._renderer = new ArrowMarkDownPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass ArrowMarkDownPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: ArrowMarkDown;\n\n constructor(drawing: ArrowMarkDown) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const vertices = this._drawing.getArrowVertices(viewport);\n if (!vertices || vertices.length < 3) return;\n\n const style = this._drawing.style;\n\n ctx.save();\n\n // Draw filled arrow\n ctx.beginPath();\n ctx.moveTo(vertices[0].x * pixelRatio, vertices[0].y * pixelRatio);\n for (let i = 1; i < vertices.length; i++) {\n ctx.lineTo(vertices[i].x * pixelRatio, vertices[i].y * pixelRatio);\n }\n ctx.closePath();\n\n ctx.fillStyle = style.lineColor;\n ctx.fill();\n\n // Optional stroke for definition\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.stroke();\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { ArrowMarkDownPaneView } from './arrow-mark-down-pane-view';\n\n/**\n * Arrow Mark Down options\n */\nexport interface ArrowMarkDownOptions extends DrawingOptions {\n size?: number;\n}\n\n/**\n * Arrow Mark Down - A downward pointing arrow marker (bearish signal).\n *\n * Features:\n * - Single anchor point\n * - Always points down\n * - Typically placed above price bars\n * - Red color by default\n */\nexport class ArrowMarkDown extends Drawing {\n readonly type = 'arrow-mark-down';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _arrowOptions: ArrowMarkDownOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<ArrowMarkDownOptions> = {}\n ) {\n const { size, ...baseOptions } = options;\n\n // Default to red for bearish\n const defaultStyle: Partial<DrawingStyle> = {\n lineColor: '#ef5350',\n ...style,\n };\n\n super(id, anchors, defaultStyle, baseOptions);\n\n this._arrowOptions = {\n ...this._options,\n size: size ?? 16,\n };\n }\n\n get arrowOptions(): ArrowMarkDownOptions {\n return this._arrowOptions;\n }\n\n setArrowOptions(options: Partial<ArrowMarkDownOptions>): void {\n this._arrowOptions = { ...this._arrowOptions, ...options };\n this.requestUpdate();\n }\n\n isValid(): boolean {\n return this._anchors.length >= ArrowMarkDown.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new ArrowMarkDownPaneView(this)];\n }\n\n /**\n * Get arrow vertices (always points down)\n */\n getArrowVertices(viewport: Viewport): Point[] | null {\n if (!this.isValid()) return null;\n\n const anchor = this.anchorToPixel(this._anchors[0], viewport);\n if (!anchor) return null;\n\n const size = this._arrowOptions.size ?? 16;\n const halfBase = size * 0.6;\n const height = size;\n\n // Downward pointing arrow\n return [\n { x: anchor.x, y: anchor.y + height }, // tip (bottom)\n { x: anchor.x - halfBase, y: anchor.y }, // top left\n { x: anchor.x + halfBase, y: anchor.y }, // top right\n ];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n const vertices = this.getArrowVertices(viewport);\n if (!vertices) return [];\n\n return [{\n type: 'polygon',\n points: vertices,\n closed: true,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n const vertices = this.getArrowVertices(viewport);\n if (!vertices || vertices.length < 3) return false;\n\n return this.pointInTriangle(point, vertices[0], vertices[1], vertices[2]);\n }\n\n private pointInTriangle(p: Point, v1: Point, v2: Point, v3: Point): boolean {\n const sign = (p1: Point, p2: Point, p3: Point): number => {\n return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);\n };\n\n const d1 = sign(p, v1, v2);\n const d2 = sign(p, v2, v3);\n const d3 = sign(p, v3, v1);\n\n const hasNeg = (d1 < 0) || (d2 < 0) || (d3 < 0);\n const hasPos = (d1 > 0) || (d2 > 0) || (d3 > 0);\n\n return !(hasNeg && hasPos);\n }\n\n clone(newId: string): IDrawing {\n return new ArrowMarkDown(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._arrowOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<ArrowMarkDownOptions>\n ): ArrowMarkDown {\n return new ArrowMarkDown(id, [position], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { AnchoredText } from './anchored-text';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class AnchoredTextPaneView implements IPrimitivePaneView {\n private _renderer: AnchoredTextPaneRenderer;\n\n constructor(drawing: AnchoredText) {\n this._renderer = new AnchoredTextPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass AnchoredTextPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: AnchoredText;\n\n constructor(drawing: AnchoredText) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchors = this._drawing.anchors;\n const anchorPos = this._drawing.anchorToPixel(anchors[0], viewport);\n const textPos = this._drawing.anchorToPixel(anchors[1], viewport);\n\n if (!anchorPos || !textPos) return;\n\n const options = this._drawing.textOptions;\n const style = this._drawing.style;\n const text = options.text ?? '';\n const fontSize = (options.fontSize ?? 12) * pixelRatio;\n const fontFamily = options.fontFamily ?? 'sans-serif';\n const fontWeight = options.fontWeight ?? 'normal';\n const padding = 6 * pixelRatio;\n\n ctx.save();\n\n // Draw connector line\n if (options.showConnector) {\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(anchorPos.x * pixelRatio, anchorPos.y * pixelRatio);\n ctx.lineTo(textPos.x * pixelRatio, textPos.y * pixelRatio);\n ctx.stroke();\n\n // Draw anchor point circle\n ctx.fillStyle = style.lineColor;\n ctx.beginPath();\n ctx.arc(anchorPos.x * pixelRatio, anchorPos.y * pixelRatio, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n }\n\n // Set up font\n ctx.font = `${fontWeight} ${fontSize}px ${fontFamily}`;\n ctx.textAlign = options.textAlign ?? 'left';\n ctx.textBaseline = 'middle';\n\n // Measure text\n const metrics = ctx.measureText(text);\n const textWidth = metrics.width;\n const textHeight = fontSize;\n\n const x = textPos.x * pixelRatio;\n const y = textPos.y * pixelRatio;\n\n // Calculate box position based on alignment\n let boxX = x;\n if (options.textAlign === 'center') {\n boxX = x - textWidth / 2;\n } else if (options.textAlign === 'right') {\n boxX = x - textWidth;\n }\n\n // Draw text background\n ctx.fillStyle = 'rgba(30, 34, 45, 0.95)';\n ctx.beginPath();\n ctx.roundRect(\n boxX - padding,\n y - textHeight / 2 - padding,\n textWidth + padding * 2,\n textHeight + padding * 2,\n 3 * pixelRatio\n );\n ctx.fill();\n\n // Draw border\n ctx.strokeStyle = style.lineColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.stroke();\n\n // Draw text\n ctx.fillStyle = style.labelColor ?? '#FFFFFF';\n ctx.fillText(text, x, y);\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry, TextGeometry } from '../../core/geometry';\nimport { AnchoredTextPaneView } from './anchored-text-pane-view';\n\n/**\n * Anchored Text options\n */\nexport interface AnchoredTextOptions extends DrawingOptions {\n text?: string;\n fontSize?: number;\n fontFamily?: string;\n fontWeight?: string;\n textAlign?: CanvasTextAlign;\n showConnector?: boolean;\n connectorLength?: number;\n}\n\n/**\n * Anchored Text - Text anchored to a specific point with a connector line.\n *\n * Features:\n * - Two anchor points: anchor position and text position\n * - Connector line between anchor and text\n * - Customizable text styling\n */\nexport class AnchoredText extends Drawing {\n readonly type = 'anchored-text';\n\n protected static readonly REQUIRED_ANCHORS = 2;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _textOptions: AnchoredTextOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<AnchoredTextOptions> = {}\n ) {\n const { text, fontSize, fontFamily, fontWeight, textAlign, showConnector, connectorLength, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._textOptions = {\n ...this._options,\n text: text ?? 'Anchored Text',\n fontSize: fontSize ?? 12,\n fontFamily: fontFamily ?? 'sans-serif',\n fontWeight: fontWeight ?? 'normal',\n textAlign: textAlign ?? 'left',\n showConnector: showConnector ?? true,\n connectorLength: connectorLength ?? 30,\n };\n }\n\n get textOptions(): AnchoredTextOptions {\n return this._textOptions;\n }\n\n setTextOptions(options: Partial<AnchoredTextOptions>): void {\n this._textOptions = { ...this._textOptions, ...options };\n this.requestUpdate();\n }\n\n setText(text: string): void {\n this._textOptions.text = text;\n this.requestUpdate();\n }\n\n getText(): string {\n return this._textOptions.text ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= AnchoredText.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new AnchoredTextPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const textPos = this.anchorToPixel(this._anchors[1], viewport);\n if (!textPos) return [];\n\n const textGeometry: TextGeometry = {\n type: 'text',\n position: textPos,\n text: this._textOptions.text ?? '',\n font: `${this._textOptions.fontWeight} ${this._textOptions.fontSize}px ${this._textOptions.fontFamily}`,\n color: this._style.labelColor,\n align: this._textOptions.textAlign,\n baseline: 'middle',\n };\n\n return [textGeometry];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n // Check if near anchor point\n const anchorPos = this.anchorToPixel(this._anchors[0], viewport);\n if (anchorPos) {\n const dx = point.x - anchorPos.x;\n const dy = point.y - anchorPos.y;\n if (Math.sqrt(dx * dx + dy * dy) <= AnchoredText.HIT_THRESHOLD) {\n return true;\n }\n }\n\n // Check if near text box\n const textPos = this.anchorToPixel(this._anchors[1], viewport);\n if (!textPos) return false;\n\n const estimatedWidth = (this._textOptions.text?.length ?? 0) * (this._textOptions.fontSize ?? 12) * 0.6;\n const estimatedHeight = (this._textOptions.fontSize ?? 12) * 1.5;\n const padding = 6;\n\n return (\n point.x >= textPos.x - padding &&\n point.x <= textPos.x + estimatedWidth + padding &&\n point.y >= textPos.y - estimatedHeight / 2 - padding &&\n point.y <= textPos.y + estimatedHeight / 2 + padding\n );\n }\n\n clone(newId: string): IDrawing {\n return new AnchoredText(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._textOptions }\n );\n }\n\n static create(\n id: string,\n anchorPoint: Anchor,\n textPoint: Anchor,\n text: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<AnchoredTextOptions>\n ): AnchoredText {\n return new AnchoredText(id, [anchorPoint, textPoint], style, { ...options, text });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Note } from './note';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class NotePaneView implements IPrimitivePaneView {\n private _renderer: NotePaneRenderer;\n\n constructor(drawing: Note) {\n this._renderer = new NotePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass NotePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Note;\n\n constructor(drawing: Note) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.noteOptions;\n const text = options.text ?? '';\n const fontSize = (options.fontSize ?? 11) * pixelRatio;\n const backgroundColor = options.backgroundColor ?? '#FFEB3B';\n const iconColor = options.iconColor ?? '#000000';\n const width = (options.width ?? 120) * pixelRatio;\n const padding = 8 * pixelRatio;\n const iconSize = 16 * pixelRatio;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Calculate text wrapping\n ctx.font = `${fontSize}px sans-serif`;\n const lines = this.wrapText(ctx, text, width - padding * 2 - (options.showIcon ? iconSize + padding : 0));\n const lineHeight = fontSize * 1.3;\n const contentHeight = Math.max(lines.length * lineHeight, iconSize);\n const totalHeight = contentHeight + padding * 2;\n\n // Draw note background with folded corner effect\n ctx.fillStyle = backgroundColor;\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(x + width - 10 * pixelRatio, y);\n ctx.lineTo(x + width, y + 10 * pixelRatio);\n ctx.lineTo(x + width, y + totalHeight);\n ctx.lineTo(x, y + totalHeight);\n ctx.closePath();\n ctx.fill();\n\n // Draw folded corner\n ctx.fillStyle = this.darkenColor(backgroundColor, 0.2);\n ctx.beginPath();\n ctx.moveTo(x + width - 10 * pixelRatio, y);\n ctx.lineTo(x + width - 10 * pixelRatio, y + 10 * pixelRatio);\n ctx.lineTo(x + width, y + 10 * pixelRatio);\n ctx.closePath();\n ctx.fill();\n\n // Draw border\n ctx.strokeStyle = this.darkenColor(backgroundColor, 0.3);\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(x + width - 10 * pixelRatio, y);\n ctx.lineTo(x + width, y + 10 * pixelRatio);\n ctx.lineTo(x + width, y + totalHeight);\n ctx.lineTo(x, y + totalHeight);\n ctx.closePath();\n ctx.stroke();\n\n // Draw icon if enabled\n let textX = x + padding;\n if (options.showIcon) {\n ctx.fillStyle = iconColor;\n ctx.font = `bold ${iconSize}px sans-serif`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n ctx.fillText('📝', x + padding, y + padding);\n textX = x + padding + iconSize + padding / 2;\n }\n\n // Draw text\n ctx.fillStyle = iconColor;\n ctx.font = `${fontSize}px sans-serif`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n\n for (let i = 0; i < lines.length; i++) {\n ctx.fillText(lines[i], textX, y + padding + i * lineHeight);\n }\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n\n private wrapText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string[] {\n const words = text.split(' ');\n const lines: string[] = [];\n let currentLine = '';\n\n for (const word of words) {\n const testLine = currentLine ? `${currentLine} ${word}` : word;\n const metrics = ctx.measureText(testLine);\n\n if (metrics.width > maxWidth && currentLine) {\n lines.push(currentLine);\n currentLine = word;\n } else {\n currentLine = testLine;\n }\n }\n\n if (currentLine) {\n lines.push(currentLine);\n }\n\n return lines.length > 0 ? lines : [''];\n }\n\n private darkenColor(hex: string, amount: number): string {\n // Convert hex to RGB\n let r = parseInt(hex.slice(1, 3), 16);\n let g = parseInt(hex.slice(3, 5), 16);\n let b = parseInt(hex.slice(5, 7), 16);\n\n // Darken\n r = Math.floor(r * (1 - amount));\n g = Math.floor(g * (1 - amount));\n b = Math.floor(b * (1 - amount));\n\n // Convert back to hex\n return `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { NotePaneView } from './note-pane-view';\n\n/**\n * Note options\n */\nexport interface NoteOptions extends DrawingOptions {\n text?: string;\n fontSize?: number;\n backgroundColor?: string;\n iconColor?: string;\n width?: number;\n showIcon?: boolean;\n}\n\n/**\n * Note - A sticky note style annotation.\n *\n * Features:\n * - Single anchor point\n * - Note icon with expandable text\n * - Customizable background and icon color\n * - Fixed or auto-width\n */\nexport class Note extends Drawing {\n readonly type = 'note';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 15;\n\n private _noteOptions: NoteOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<NoteOptions> = {}\n ) {\n const { text, fontSize, backgroundColor, iconColor, width, showIcon, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._noteOptions = {\n ...this._options,\n text: text ?? 'Note',\n fontSize: fontSize ?? 11,\n backgroundColor: backgroundColor ?? '#FFEB3B',\n iconColor: iconColor ?? '#000000',\n width: width ?? 120,\n showIcon: showIcon ?? true,\n };\n }\n\n get noteOptions(): NoteOptions {\n return this._noteOptions;\n }\n\n setNoteOptions(options: Partial<NoteOptions>): void {\n this._noteOptions = { ...this._noteOptions, ...options };\n this.requestUpdate();\n }\n\n setText(text: string): void {\n this._noteOptions.text = text;\n this.requestUpdate();\n }\n\n getText(): string {\n return this._noteOptions.text ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= Note.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new NotePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const width = this._noteOptions.width ?? 120;\n const height = 60; // Approximate height\n\n return (\n point.x >= p.x &&\n point.x <= p.x + width &&\n point.y >= p.y &&\n point.y <= p.y + height\n );\n }\n\n clone(newId: string): IDrawing {\n return new Note(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._noteOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n text: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<NoteOptions>\n ): Note {\n return new Note(id, [position], style, { ...options, text });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { PriceNote } from './price-note';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class PriceNotePaneView implements IPrimitivePaneView {\n private _renderer: PriceNotePaneRenderer;\n\n constructor(drawing: PriceNote) {\n this._renderer = new PriceNotePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PriceNotePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: PriceNote;\n\n constructor(drawing: PriceNote) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.noteOptions;\n const fontSize = (options.fontSize ?? 11) * pixelRatio;\n const backgroundColor = options.backgroundColor ?? 'rgba(30, 34, 45, 0.95)';\n const priceColor = options.priceColor ?? '#26a69a';\n const noteColor = options.noteColor ?? '#d1d4dc';\n const padding = 6 * pixelRatio;\n const markerSize = 6 * pixelRatio;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Build content\n const lines: { text: string; color: string }[] = [];\n\n if (options.showPrice) {\n lines.push({ text: `$${anchor.price.toFixed(2)}`, color: priceColor });\n }\n\n if (options.note) {\n lines.push({ text: options.note, color: noteColor });\n }\n\n if (lines.length === 0) {\n lines.push({ text: `$${anchor.price.toFixed(2)}`, color: priceColor });\n }\n\n // Measure content\n ctx.font = `${fontSize}px sans-serif`;\n let maxWidth = 0;\n for (const line of lines) {\n const metrics = ctx.measureText(line.text);\n maxWidth = Math.max(maxWidth, metrics.width);\n }\n\n const lineHeight = fontSize * 1.3;\n const boxWidth = maxWidth + padding * 2 + markerSize + padding;\n const boxHeight = lines.length * lineHeight + padding * 2;\n\n // Draw marker\n ctx.fillStyle = priceColor;\n ctx.beginPath();\n ctx.arc(x, y, markerSize / 2, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw connector line\n ctx.strokeStyle = priceColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(x + markerSize / 2, y);\n ctx.lineTo(x + markerSize + padding / 2, y);\n ctx.stroke();\n\n // Draw box\n const boxX = x + markerSize + padding;\n const boxY = y - boxHeight / 2;\n\n ctx.fillStyle = backgroundColor;\n ctx.beginPath();\n ctx.roundRect(boxX, boxY, boxWidth, boxHeight, 3 * pixelRatio);\n ctx.fill();\n\n ctx.strokeStyle = priceColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.stroke();\n\n // Draw text\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n\n for (let i = 0; i < lines.length; i++) {\n ctx.fillStyle = lines[i].color;\n ctx.font = i === 0 ? `bold ${fontSize}px sans-serif` : `${fontSize}px sans-serif`;\n ctx.fillText(\n lines[i].text,\n boxX + padding,\n boxY + padding + lineHeight * (i + 0.5)\n );\n }\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { PriceNotePaneView } from './price-note-pane-view';\n\n/**\n * Price Note options\n */\nexport interface PriceNoteOptions extends DrawingOptions {\n note?: string;\n showPrice?: boolean;\n showTime?: boolean;\n fontSize?: number;\n backgroundColor?: string;\n priceColor?: string;\n noteColor?: string;\n}\n\n/**\n * Price Note - Displays price and optional note at a specific point.\n *\n * Features:\n * - Single anchor point\n * - Shows price value\n * - Optional note text\n * - Customizable colors\n */\nexport class PriceNote extends Drawing {\n readonly type = 'price-note';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _noteOptions: PriceNoteOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PriceNoteOptions> = {}\n ) {\n const { note, showPrice, showTime, fontSize, backgroundColor, priceColor, noteColor, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._noteOptions = {\n ...this._options,\n note: note ?? '',\n showPrice: showPrice ?? true,\n showTime: showTime ?? false,\n fontSize: fontSize ?? 11,\n backgroundColor: backgroundColor ?? 'rgba(30, 34, 45, 0.95)',\n priceColor: priceColor ?? '#26a69a',\n noteColor: noteColor ?? '#d1d4dc',\n };\n }\n\n get noteOptions(): PriceNoteOptions {\n return this._noteOptions;\n }\n\n setNoteOptions(options: Partial<PriceNoteOptions>): void {\n this._noteOptions = { ...this._noteOptions, ...options };\n this.requestUpdate();\n }\n\n setNote(note: string): void {\n this._noteOptions.note = note;\n this.requestUpdate();\n }\n\n getNote(): string {\n return this._noteOptions.note ?? '';\n }\n\n getPrice(): number {\n return this._anchors[0]?.price ?? 0;\n }\n\n isValid(): boolean {\n return this._anchors.length >= PriceNote.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PriceNotePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const width = 80;\n const height = 40;\n\n return (\n point.x >= p.x - 10 &&\n point.x <= p.x + width &&\n point.y >= p.y - height / 2 &&\n point.y <= p.y + height / 2\n );\n }\n\n clone(newId: string): IDrawing {\n return new PriceNote(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._noteOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n note?: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<PriceNoteOptions>\n ): PriceNote {\n return new PriceNote(id, [position], style, { ...options, note });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { PriceLabel } from './price-label';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class PriceLabelPaneView implements IPrimitivePaneView {\n private _renderer: PriceLabelPaneRenderer;\n\n constructor(drawing: PriceLabel) {\n this._renderer = new PriceLabelPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PriceLabelPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: PriceLabel;\n\n constructor(drawing: PriceLabel) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio, bitmapSize } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.labelOptions;\n const fontSize = (options.fontSize ?? 11) * pixelRatio;\n const backgroundColor = options.backgroundColor ?? '#2962FF';\n const textColor = options.textColor ?? '#FFFFFF';\n const decimals = options.decimals ?? 2;\n const padding = 4 * pixelRatio;\n const arrowSize = 6 * pixelRatio;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n const chartWidth = bitmapSize.width;\n\n ctx.save();\n\n // Draw horizontal line from anchor to right edge\n ctx.strokeStyle = backgroundColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.setLineDash([4 * pixelRatio, 2 * pixelRatio]);\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(chartWidth, y);\n ctx.stroke();\n ctx.setLineDash([]);\n\n // Draw price label on the right\n const priceText = `$${anchor.price.toFixed(decimals)}`;\n ctx.font = `bold ${fontSize}px sans-serif`;\n const textMetrics = ctx.measureText(priceText);\n const textWidth = textMetrics.width;\n const labelWidth = textWidth + padding * 2;\n const labelHeight = fontSize + padding * 2;\n\n const labelX = chartWidth - labelWidth - 2 * pixelRatio;\n const labelY = y - labelHeight / 2;\n\n // Draw label background with arrow\n ctx.fillStyle = backgroundColor;\n ctx.beginPath();\n\n if (options.showArrow) {\n // Label with arrow pointing left\n ctx.moveTo(labelX, labelY);\n ctx.lineTo(labelX + labelWidth, labelY);\n ctx.lineTo(labelX + labelWidth, labelY + labelHeight);\n ctx.lineTo(labelX, labelY + labelHeight);\n ctx.lineTo(labelX - arrowSize, y);\n ctx.closePath();\n } else {\n ctx.roundRect(labelX, labelY, labelWidth, labelHeight, 2 * pixelRatio);\n }\n ctx.fill();\n\n // Draw text\n ctx.fillStyle = textColor;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n ctx.fillText(priceText, labelX + labelWidth / 2, y);\n\n // Draw anchor marker\n ctx.fillStyle = backgroundColor;\n ctx.beginPath();\n ctx.arc(x, y, 4 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { PriceLabelPaneView } from './price-label-pane-view';\n\n/**\n * Price Label options\n */\nexport interface PriceLabelOptions extends DrawingOptions {\n fontSize?: number;\n backgroundColor?: string;\n textColor?: string;\n showArrow?: boolean;\n arrowDirection?: 'left' | 'right';\n decimals?: number;\n}\n\n/**\n * Price Label - A simple price label with arrow pointer.\n *\n * Features:\n * - Single anchor point\n * - Shows price value in a badge\n * - Arrow pointer to the price level\n * - Extends to the right edge\n */\nexport class PriceLabel extends Drawing {\n readonly type = 'price-label';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 10;\n\n private _labelOptions: PriceLabelOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PriceLabelOptions> = {}\n ) {\n const { fontSize, backgroundColor, textColor, showArrow, arrowDirection, decimals, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._labelOptions = {\n ...this._options,\n fontSize: fontSize ?? 11,\n backgroundColor: backgroundColor ?? '#2962FF',\n textColor: textColor ?? '#FFFFFF',\n showArrow: showArrow ?? true,\n arrowDirection: arrowDirection ?? 'left',\n decimals: decimals ?? 2,\n };\n }\n\n get labelOptions(): PriceLabelOptions {\n return this._labelOptions;\n }\n\n setLabelOptions(options: Partial<PriceLabelOptions>): void {\n this._labelOptions = { ...this._labelOptions, ...options };\n this.requestUpdate();\n }\n\n getPrice(): number {\n return this._anchors[0]?.price ?? 0;\n }\n\n isValid(): boolean {\n return this._anchors.length >= PriceLabel.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PriceLabelPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n // Check if near the label or the horizontal line\n const lineThreshold = 5;\n\n // Check horizontal line hit\n if (Math.abs(point.y - p.y) <= lineThreshold && point.x >= p.x) {\n return true;\n }\n\n // Check label hit (approximate)\n const labelWidth = 70;\n const labelHeight = 20;\n\n return (\n point.x >= viewport.width - labelWidth - 10 &&\n point.x <= viewport.width &&\n point.y >= p.y - labelHeight / 2 &&\n point.y <= p.y + labelHeight / 2\n );\n }\n\n clone(newId: string): IDrawing {\n return new PriceLabel(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._labelOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<PriceLabelOptions>\n ): PriceLabel {\n return new PriceLabel(id, [position], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { FlagMark } from './flag-mark';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class FlagMarkPaneView implements IPrimitivePaneView {\n private _renderer: FlagMarkPaneRenderer;\n\n constructor(drawing: FlagMark) {\n this._renderer = new FlagMarkPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass FlagMarkPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: FlagMark;\n\n constructor(drawing: FlagMark) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.flagOptions;\n const color = this._drawing.getFlagColor();\n const size = (options.size ?? 20) * pixelRatio;\n const poleHeight = size * 1.5;\n const flagWidth = size;\n const flagHeight = size * 0.6;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Draw pole\n ctx.strokeStyle = color;\n ctx.lineWidth = 2 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(x, y - poleHeight);\n ctx.stroke();\n\n // Draw flag\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.moveTo(x, y - poleHeight);\n ctx.lineTo(x + flagWidth, y - poleHeight + flagHeight / 2);\n ctx.lineTo(x, y - poleHeight + flagHeight);\n ctx.closePath();\n ctx.fill();\n\n // Draw base circle\n ctx.beginPath();\n ctx.arc(x, y, 3 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw label if present\n const label = options.label;\n if (label) {\n const fontSize = 10 * pixelRatio;\n ctx.font = `bold ${fontSize}px sans-serif`;\n ctx.fillStyle = '#FFFFFF';\n ctx.textAlign = 'center';\n ctx.textBaseline = 'middle';\n\n // Draw label background\n const textMetrics = ctx.measureText(label);\n const labelPadding = 3 * pixelRatio;\n const labelWidth = textMetrics.width + labelPadding * 2;\n const labelHeight = fontSize + labelPadding * 2;\n const labelX = x + flagWidth / 2;\n const labelY = y - poleHeight - labelHeight / 2 - 2 * pixelRatio;\n\n ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';\n ctx.beginPath();\n ctx.roundRect(\n labelX - labelWidth / 2,\n labelY - labelHeight / 2,\n labelWidth,\n labelHeight,\n 2 * pixelRatio\n );\n ctx.fill();\n\n ctx.fillStyle = '#FFFFFF';\n ctx.fillText(label, labelX, labelY);\n }\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { FlagMarkPaneView } from './flag-mark-pane-view';\n\n/**\n * Flag mark color type\n */\nexport type FlagColor = 'red' | 'green' | 'blue' | 'yellow' | 'purple' | 'custom';\n\n/**\n * Flag Mark options\n */\nexport interface FlagMarkOptions extends DrawingOptions {\n flagColor?: FlagColor;\n customColor?: string;\n label?: string;\n size?: number;\n}\n\n/**\n * Flag Mark - A flag marker placed on the chart.\n *\n * Features:\n * - Single anchor point\n * - Various preset colors\n * - Optional label\n * - Configurable size\n */\nexport class FlagMark extends Drawing {\n readonly type = 'flag-mark';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 15;\n\n private _flagOptions: FlagMarkOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<FlagMarkOptions> = {}\n ) {\n const { flagColor, customColor, label, size, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._flagOptions = {\n ...this._options,\n flagColor: flagColor ?? 'red',\n customColor: customColor ?? '#FF0000',\n label: label ?? '',\n size: size ?? 20,\n };\n }\n\n get flagOptions(): FlagMarkOptions {\n return this._flagOptions;\n }\n\n setFlagOptions(options: Partial<FlagMarkOptions>): void {\n this._flagOptions = { ...this._flagOptions, ...options };\n this.requestUpdate();\n }\n\n getFlagColor(): string {\n const colors: Record<FlagColor, string> = {\n red: '#ef5350',\n green: '#26a69a',\n blue: '#2196F3',\n yellow: '#FFEB3B',\n purple: '#9C27B0',\n custom: this._flagOptions.customColor ?? '#FF0000',\n };\n return colors[this._flagOptions.flagColor ?? 'red'];\n }\n\n setLabel(label: string): void {\n this._flagOptions.label = label;\n this.requestUpdate();\n }\n\n getLabel(): string {\n return this._flagOptions.label ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= FlagMark.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new FlagMarkPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const size = this._flagOptions.size ?? 20;\n\n // Check if near the flag\n return (\n point.x >= p.x - 5 &&\n point.x <= p.x + size + 5 &&\n point.y >= p.y - size * 1.5 &&\n point.y <= p.y + 5\n );\n }\n\n clone(newId: string): IDrawing {\n return new FlagMark(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._flagOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n flagColor?: FlagColor,\n label?: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<FlagMarkOptions>\n ): FlagMark {\n return new FlagMark(id, [position], style, { ...options, flagColor, label });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Pin } from './pin';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class PinPaneView implements IPrimitivePaneView {\n private _renderer: PinPaneRenderer;\n\n constructor(drawing: Pin) {\n this._renderer = new PinPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass PinPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Pin;\n\n constructor(drawing: Pin) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.pinOptions;\n const color = options.color ?? '#E91E63';\n const size = (options.size ?? 24) * pixelRatio;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Draw teardrop pin shape\n const headRadius = size * 0.4;\n const headCenterY = y - size;\n\n // Pin body (teardrop) - path from tip to circle\n ctx.fillStyle = color;\n ctx.beginPath();\n ctx.moveTo(x, y); // tip at anchor\n // Left curve to circle\n ctx.bezierCurveTo(\n x - headRadius * 1.2, y - size * 0.5,\n x - headRadius, headCenterY,\n x, headCenterY - headRadius\n );\n // Right curve back to tip\n ctx.bezierCurveTo(\n x + headRadius, headCenterY,\n x + headRadius * 1.2, y - size * 0.5,\n x, y\n );\n ctx.closePath();\n ctx.fill();\n\n // Draw inner circle (white dot)\n ctx.fillStyle = '#FFFFFF';\n ctx.beginPath();\n ctx.arc(x, headCenterY, headRadius * 0.4, 0, Math.PI * 2);\n ctx.fill();\n\n // Draw label if present\n const label = options.label;\n if (label) {\n const fontSize = 10 * pixelRatio;\n ctx.font = `bold ${fontSize}px sans-serif`;\n ctx.textAlign = 'center';\n ctx.textBaseline = 'bottom';\n\n const textMetrics = ctx.measureText(label);\n const labelPadding = 3 * pixelRatio;\n const labelWidth = textMetrics.width + labelPadding * 2;\n const labelHeight = fontSize + labelPadding * 2;\n const labelX = x;\n const labelY = headCenterY - headRadius - 4 * pixelRatio;\n\n ctx.fillStyle = 'rgba(0, 0, 0, 0.7)';\n ctx.beginPath();\n ctx.roundRect(\n labelX - labelWidth / 2,\n labelY - labelHeight,\n labelWidth,\n labelHeight,\n 2 * pixelRatio\n );\n ctx.fill();\n\n ctx.fillStyle = '#FFFFFF';\n ctx.fillText(label, labelX, labelY - labelPadding);\n }\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { PinPaneView } from './pin-pane-view';\n\n/**\n * Pin options\n */\nexport interface PinOptions extends DrawingOptions {\n color?: string;\n size?: number;\n label?: string;\n}\n\n/**\n * Pin - A simple pin/map marker annotation.\n *\n * Features:\n * - Single anchor point\n * - Teardrop/pin shape\n * - Optional short label\n */\nexport class Pin extends Drawing {\n readonly type = 'pin';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 15;\n\n private _pinOptions: PinOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<PinOptions> = {}\n ) {\n const { color, size, label, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._pinOptions = {\n ...this._options,\n color: color ?? '#E91E63',\n size: size ?? 24,\n label: label ?? '',\n };\n }\n\n get pinOptions(): PinOptions {\n return this._pinOptions;\n }\n\n setPinOptions(options: Partial<PinOptions>): void {\n this._pinOptions = { ...this._pinOptions, ...options };\n this.requestUpdate();\n }\n\n setLabel(label: string): void {\n this._pinOptions.label = label;\n this.requestUpdate();\n }\n\n getLabel(): string {\n return this._pinOptions.label ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= Pin.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new PinPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const size = this._pinOptions.size ?? 24;\n return (\n point.x >= p.x - size / 2 &&\n point.x <= p.x + size / 2 &&\n point.y >= p.y - size * 1.5 &&\n point.y <= p.y\n );\n }\n\n clone(newId: string): IDrawing {\n return new Pin(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._pinOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n style?: Partial<DrawingStyle>,\n options?: Partial<PinOptions>\n ): Pin {\n return new Pin(id, [position], style, options);\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Comment } from './comment';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class CommentPaneView implements IPrimitivePaneView {\n private _renderer: CommentPaneRenderer;\n\n constructor(drawing: Comment) {\n this._renderer = new CommentPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass CommentPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Comment;\n\n constructor(drawing: Comment) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.commentOptions;\n const text = options.text ?? '';\n const fontSize = (options.fontSize ?? 11) * pixelRatio;\n const bgColor = options.backgroundColor ?? '#2962FF';\n const textColor = options.textColor ?? '#FFFFFF';\n const padding = 8 * pixelRatio;\n const borderRadius = 6 * pixelRatio;\n const tailSize = 8 * pixelRatio;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Measure text\n ctx.font = `${fontSize}px sans-serif`;\n const lines = this.wrapText(ctx, text, 120 * pixelRatio);\n const lineHeight = fontSize * 1.3;\n const contentHeight = lines.length * lineHeight;\n const maxLineWidth = Math.max(...lines.map(l => ctx.measureText(l).width));\n const boxWidth = maxLineWidth + padding * 2;\n const boxHeight = contentHeight + padding * 2;\n\n // Position bubble above anchor\n const bubbleX = x;\n const bubbleY = y - tailSize - boxHeight;\n\n // Draw speech bubble\n ctx.fillStyle = bgColor;\n ctx.beginPath();\n ctx.roundRect(bubbleX, bubbleY, boxWidth, boxHeight, borderRadius);\n ctx.fill();\n\n // Draw tail (triangle pointing down to anchor)\n ctx.beginPath();\n ctx.moveTo(bubbleX + 10 * pixelRatio, bubbleY + boxHeight);\n ctx.lineTo(x, y);\n ctx.lineTo(bubbleX + 20 * pixelRatio, bubbleY + boxHeight);\n ctx.closePath();\n ctx.fill();\n\n // Draw text\n ctx.fillStyle = textColor;\n ctx.font = `${fontSize}px sans-serif`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'top';\n\n for (let i = 0; i < lines.length; i++) {\n ctx.fillText(lines[i], bubbleX + padding, bubbleY + padding + i * lineHeight);\n }\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n\n private wrapText(ctx: CanvasRenderingContext2D, text: string, maxWidth: number): string[] {\n const words = text.split(' ');\n const lines: string[] = [];\n let currentLine = '';\n\n for (const word of words) {\n const testLine = currentLine ? `${currentLine} ${word}` : word;\n const metrics = ctx.measureText(testLine);\n\n if (metrics.width > maxWidth && currentLine) {\n lines.push(currentLine);\n currentLine = word;\n } else {\n currentLine = testLine;\n }\n }\n\n if (currentLine) {\n lines.push(currentLine);\n }\n\n return lines.length > 0 ? lines : [''];\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { CommentPaneView } from './comment-pane-view';\n\n/**\n * Comment options\n */\nexport interface CommentOptions extends DrawingOptions {\n text?: string;\n fontSize?: number;\n backgroundColor?: string;\n textColor?: string;\n}\n\n/**\n * Comment - A speech-bubble style comment marker.\n *\n * Features:\n * - Single anchor point\n * - Speech bubble with text\n * - Customizable colors\n */\nexport class Comment extends Drawing {\n readonly type = 'comment';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 15;\n\n private _commentOptions: CommentOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<CommentOptions> = {}\n ) {\n const { text, fontSize, backgroundColor, textColor, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._commentOptions = {\n ...this._options,\n text: text ?? 'Comment',\n fontSize: fontSize ?? 11,\n backgroundColor: backgroundColor ?? '#2962FF',\n textColor: textColor ?? '#FFFFFF',\n };\n }\n\n get commentOptions(): CommentOptions {\n return this._commentOptions;\n }\n\n setCommentOptions(options: Partial<CommentOptions>): void {\n this._commentOptions = { ...this._commentOptions, ...options };\n this.requestUpdate();\n }\n\n setText(text: string): void {\n this._commentOptions.text = text;\n this.requestUpdate();\n }\n\n getText(): string {\n return this._commentOptions.text ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= Comment.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new CommentPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const width = 130;\n const height = 50;\n\n return (\n point.x >= p.x &&\n point.x <= p.x + width &&\n point.y >= p.y - height - 10 &&\n point.y <= p.y\n );\n }\n\n clone(newId: string): IDrawing {\n return new Comment(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._commentOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n text: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<CommentOptions>\n ): Comment {\n return new Comment(id, [position], style, { ...options, text });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Signpost } from './signpost';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class SignpostPaneView implements IPrimitivePaneView {\n private _renderer: SignpostPaneRenderer;\n\n constructor(drawing: Signpost) {\n this._renderer = new SignpostPaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass SignpostPaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Signpost;\n\n constructor(drawing: Signpost) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.signpostOptions;\n const text = options.text ?? '';\n const fontSize = (options.fontSize ?? 11) * pixelRatio;\n const bgColor = options.backgroundColor ?? '#FF9800';\n const textColor = options.textColor ?? '#000000';\n const isRight = options.direction !== 'left';\n const arrowSize = 10 * pixelRatio;\n const padding = 8 * pixelRatio;\n const height = 24 * pixelRatio;\n const poleHeight = 30 * pixelRatio;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Measure text\n ctx.font = `bold ${fontSize}px sans-serif`;\n const textWidth = ctx.measureText(text).width;\n const bodyWidth = textWidth + padding * 2;\n\n // Draw pole\n ctx.strokeStyle = bgColor;\n ctx.lineWidth = 2 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(x, y);\n ctx.lineTo(x, y - poleHeight - height);\n ctx.stroke();\n\n // Draw signpost body with arrow\n const signY = y - poleHeight - height;\n\n ctx.fillStyle = bgColor;\n ctx.beginPath();\n\n if (isRight) {\n ctx.moveTo(x, signY);\n ctx.lineTo(x + bodyWidth, signY);\n ctx.lineTo(x + bodyWidth + arrowSize, signY + height / 2);\n ctx.lineTo(x + bodyWidth, signY + height);\n ctx.lineTo(x, signY + height);\n } else {\n ctx.moveTo(x, signY);\n ctx.lineTo(x - bodyWidth, signY);\n ctx.lineTo(x - bodyWidth - arrowSize, signY + height / 2);\n ctx.lineTo(x - bodyWidth, signY + height);\n ctx.lineTo(x, signY + height);\n }\n\n ctx.closePath();\n ctx.fill();\n\n // Draw text\n ctx.fillStyle = textColor;\n ctx.font = `bold ${fontSize}px sans-serif`;\n ctx.textBaseline = 'middle';\n\n if (isRight) {\n ctx.textAlign = 'left';\n ctx.fillText(text, x + padding, signY + height / 2);\n } else {\n ctx.textAlign = 'right';\n ctx.fillText(text, x - padding, signY + height / 2);\n }\n\n // Draw base circle\n ctx.fillStyle = bgColor;\n ctx.beginPath();\n ctx.arc(x, y, 3 * pixelRatio, 0, Math.PI * 2);\n ctx.fill();\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { SignpostPaneView } from './signpost-pane-view';\n\n/**\n * Signpost options\n */\nexport interface SignpostOptions extends DrawingOptions {\n text?: string;\n fontSize?: number;\n backgroundColor?: string;\n textColor?: string;\n direction?: 'left' | 'right';\n}\n\n/**\n * Signpost - A directional signpost marker.\n *\n * Features:\n * - Single anchor point\n * - Directional arrow-shaped sign (left/right)\n * - Text label on the sign\n */\nexport class Signpost extends Drawing {\n readonly type = 'signpost';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 15;\n\n private _signpostOptions: SignpostOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<SignpostOptions> = {}\n ) {\n const { text, fontSize, backgroundColor, textColor, direction, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._signpostOptions = {\n ...this._options,\n text: text ?? 'Signpost',\n fontSize: fontSize ?? 11,\n backgroundColor: backgroundColor ?? '#FF9800',\n textColor: textColor ?? '#000000',\n direction: direction ?? 'right',\n };\n }\n\n get signpostOptions(): SignpostOptions {\n return this._signpostOptions;\n }\n\n setSignpostOptions(options: Partial<SignpostOptions>): void {\n this._signpostOptions = { ...this._signpostOptions, ...options };\n this.requestUpdate();\n }\n\n setText(text: string): void {\n this._signpostOptions.text = text;\n this.requestUpdate();\n }\n\n getText(): string {\n return this._signpostOptions.text ?? '';\n }\n\n isValid(): boolean {\n return this._anchors.length >= Signpost.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new SignpostPaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const size = 100;\n const height = 28;\n const isRight = this._signpostOptions.direction !== 'left';\n\n if (isRight) {\n return (\n point.x >= p.x &&\n point.x <= p.x + size &&\n point.y >= p.y - height &&\n point.y <= p.y\n );\n } else {\n return (\n point.x >= p.x - size &&\n point.x <= p.x &&\n point.y >= p.y - height &&\n point.y <= p.y\n );\n }\n }\n\n clone(newId: string): IDrawing {\n return new Signpost(\n newId,\n [...this._anchors],\n { ...this._style },\n { ...this._signpostOptions }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n text: string,\n style?: Partial<DrawingStyle>,\n options?: Partial<SignpostOptions>\n ): Signpost {\n return new Signpost(id, [position], style, { ...options, text });\n }\n}\n","import type { IPrimitivePaneView, IPrimitivePaneRenderer } from 'lightweight-charts';\nimport type { CanvasRenderingTarget2D, BitmapCoordinatesRenderingScope } from 'fancy-canvas';\n\nimport type { Table } from './table';\nimport { drawControlPoints } from '../../rendering/canvas-utils';\n\nexport class TablePaneView implements IPrimitivePaneView {\n private _renderer: TablePaneRenderer;\n\n constructor(drawing: Table) {\n this._renderer = new TablePaneRenderer(drawing);\n }\n\n zOrder(): 'bottom' | 'normal' | 'top' {\n return 'top';\n }\n\n renderer(): IPrimitivePaneRenderer {\n return this._renderer;\n }\n}\n\nclass TablePaneRenderer implements IPrimitivePaneRenderer {\n private _drawing: Table;\n\n constructor(drawing: Table) {\n this._drawing = drawing;\n }\n\n draw(target: CanvasRenderingTarget2D): void {\n target.useBitmapCoordinateSpace((scope: BitmapCoordinatesRenderingScope) => {\n this.drawImpl(scope);\n });\n }\n\n private drawImpl(scope: BitmapCoordinatesRenderingScope): void {\n const { context: ctx, horizontalPixelRatio } = scope;\n const pixelRatio = horizontalPixelRatio;\n\n const viewport = this._drawing.getViewport();\n if (!viewport) return;\n if (!this._drawing.options.visible) return;\n if (!this._drawing.isValid()) return;\n\n const anchor = this._drawing.anchors[0];\n const p = this._drawing.anchorToPixel(anchor, viewport);\n if (!p) return;\n\n const options = this._drawing.tableOptions;\n const rows = options.rows ?? [];\n if (rows.length === 0) return;\n\n const fontSize = (options.fontSize ?? 11) * pixelRatio;\n const bgColor = options.backgroundColor ?? '#1e222d';\n const headerColor = options.headerColor ?? '#2a2e39';\n const textColor = options.textColor ?? '#d1d4dc';\n const borderColor = options.borderColor ?? '#363a45';\n const cellPadding = (options.cellPadding ?? 6) * pixelRatio;\n const hasHeader = options.headerRow ?? true;\n\n const x = p.x * pixelRatio;\n const y = p.y * pixelRatio;\n\n ctx.save();\n\n // Measure column widths\n ctx.font = `${fontSize}px sans-serif`;\n const cols = rows[0].length;\n const colWidths: number[] = new Array(cols).fill(0);\n\n for (const row of rows) {\n for (let c = 0; c < row.length && c < cols; c++) {\n const w = ctx.measureText(row[c]).width + cellPadding * 2;\n colWidths[c] = Math.max(colWidths[c], w);\n }\n }\n\n // Ensure minimum column width\n for (let c = 0; c < cols; c++) {\n colWidths[c] = Math.max(colWidths[c], 50 * pixelRatio);\n }\n\n const rowHeight = fontSize + cellPadding * 2;\n const tableWidth = colWidths.reduce((s, w) => s + w, 0);\n const tableHeight = rows.length * rowHeight;\n\n // Draw table background\n ctx.fillStyle = bgColor;\n ctx.fillRect(x, y, tableWidth, tableHeight);\n\n // Draw rows\n for (let r = 0; r < rows.length; r++) {\n const rowY = y + r * rowHeight;\n\n // Header row background\n if (r === 0 && hasHeader) {\n ctx.fillStyle = headerColor;\n ctx.fillRect(x, rowY, tableWidth, rowHeight);\n }\n\n // Draw cells\n let cellX = x;\n for (let c = 0; c < cols; c++) {\n const cellText = (r < rows.length && c < rows[r].length) ? rows[r][c] : '';\n\n // Cell text\n ctx.fillStyle = textColor;\n ctx.font = (r === 0 && hasHeader)\n ? `bold ${fontSize}px sans-serif`\n : `${fontSize}px sans-serif`;\n ctx.textAlign = 'left';\n ctx.textBaseline = 'middle';\n ctx.fillText(cellText, cellX + cellPadding, rowY + rowHeight / 2);\n\n // Vertical border\n if (c > 0) {\n ctx.strokeStyle = borderColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(cellX, rowY);\n ctx.lineTo(cellX, rowY + rowHeight);\n ctx.stroke();\n }\n\n cellX += colWidths[c];\n }\n\n // Horizontal border\n if (r > 0) {\n ctx.strokeStyle = borderColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.beginPath();\n ctx.moveTo(x, rowY);\n ctx.lineTo(x + tableWidth, rowY);\n ctx.stroke();\n }\n }\n\n // Draw outer border\n ctx.strokeStyle = borderColor;\n ctx.lineWidth = 1 * pixelRatio;\n ctx.strokeRect(x, y, tableWidth, tableHeight);\n\n ctx.restore();\n\n // Draw control points if selected\n const state = this._drawing.state;\n if (state === 'selected' || state === 'editing') {\n const controlPoints = this._drawing.getControlPoints(viewport);\n drawControlPoints(ctx, controlPoints, null, pixelRatio);\n }\n }\n}\n","import type { IPrimitivePaneView } from 'lightweight-charts';\n\nimport { Drawing } from '../../core/drawing';\nimport type { Anchor, Point, Viewport, DrawingStyle, DrawingOptions, IDrawing } from '../../core/types';\nimport type { Geometry } from '../../core/geometry';\nimport { TablePaneView } from './table-pane-view';\n\n/**\n * Table options\n */\nexport interface TableOptions extends DrawingOptions {\n rows?: string[][];\n headerRow?: boolean;\n fontSize?: number;\n backgroundColor?: string;\n headerColor?: string;\n textColor?: string;\n borderColor?: string;\n cellPadding?: number;\n}\n\nconst DEFAULT_TABLE_DATA: string[][] = [\n ['Label', 'Value'],\n ['Price', '0.00'],\n ['Change', '0.00%'],\n];\n\n/**\n * Table - A data table annotation.\n *\n * Features:\n * - Single anchor point (top-left corner)\n * - Configurable rows and columns\n * - Optional header row with distinct styling\n */\nexport class Table extends Drawing {\n readonly type = 'table';\n\n protected static readonly REQUIRED_ANCHORS = 1;\n protected static readonly HIT_THRESHOLD = 5;\n\n private _tableOptions: TableOptions;\n\n constructor(\n id: string,\n anchors: Anchor[] = [],\n style: Partial<DrawingStyle> = {},\n options: Partial<TableOptions> = {}\n ) {\n const { rows, headerRow, fontSize, backgroundColor, headerColor, textColor, borderColor, cellPadding, ...baseOptions } = options;\n super(id, anchors, style, baseOptions);\n\n this._tableOptions = {\n ...this._options,\n rows: rows ?? DEFAULT_TABLE_DATA.map(r => [...r]),\n headerRow: headerRow ?? true,\n fontSize: fontSize ?? 11,\n backgroundColor: backgroundColor ?? '#1e222d',\n headerColor: headerColor ?? '#2a2e39',\n textColor: textColor ?? '#d1d4dc',\n borderColor: borderColor ?? '#363a45',\n cellPadding: cellPadding ?? 6,\n };\n }\n\n get tableOptions(): TableOptions {\n return this._tableOptions;\n }\n\n setTableOptions(options: Partial<TableOptions>): void {\n this._tableOptions = { ...this._tableOptions, ...options };\n this.requestUpdate();\n }\n\n setRows(rows: string[][]): void {\n this._tableOptions.rows = rows;\n this.requestUpdate();\n }\n\n getRows(): string[][] {\n return this._tableOptions.rows ?? [];\n }\n\n isValid(): boolean {\n return this._anchors.length >= Table.REQUIRED_ANCHORS;\n }\n\n paneViews(): IPrimitivePaneView[] {\n return [new TablePaneView(this)];\n }\n\n computeGeometry(viewport: Viewport): Geometry[] {\n if (!this.isValid()) return [];\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return [];\n\n return [{\n type: 'polygon',\n points: [p],\n closed: false,\n }];\n }\n\n testHit(point: Point, viewport: Viewport): boolean {\n if (!this.isValid()) return false;\n\n const p = this.anchorToPixel(this._anchors[0], viewport);\n if (!p) return false;\n\n const rows = this._tableOptions.rows ?? [];\n const cols = rows.length > 0 ? rows[0].length : 0;\n const cellPadding = this._tableOptions.cellPadding ?? 6;\n const fontSize = this._tableOptions.fontSize ?? 11;\n const rowHeight = fontSize + cellPadding * 2;\n const colWidth = 80;\n\n const tableWidth = cols * colWidth;\n const tableHeight = rows.length * rowHeight;\n\n return (\n point.x >= p.x &&\n point.x <= p.x + tableWidth &&\n point.y >= p.y &&\n point.y <= p.y + tableHeight\n );\n }\n\n clone(newId: string): IDrawing {\n return new Table(\n newId,\n [...this._anchors],\n { ...this._style },\n {\n ...this._tableOptions,\n rows: (this._tableOptions.rows ?? []).map(r => [...r]),\n }\n );\n }\n\n static create(\n id: string,\n position: Anchor,\n rows?: string[][],\n style?: Partial<DrawingStyle>,\n options?: Partial<TableOptions>\n ): Table {\n return new Table(id, [position], style, { ...options, rows });\n }\n}\n","import type { DrawingToolDefinition, DrawingCategory, Anchor, DrawingStyle, DrawingOptions, IDrawing } from '../core/types';\n\n// Import all drawing tools\nimport { TrendLine } from '../tools/lines/trend-line';\nimport { HorizontalLine } from '../tools/lines/horizontal-line';\nimport { VerticalLine } from '../tools/lines/vertical-line';\nimport { Ray } from '../tools/lines/ray';\nimport { Arrow } from '../tools/lines/arrow';\nimport { ExtendedLine } from '../tools/lines/extended-line';\nimport { CrossLine } from '../tools/lines/cross-line';\nimport { InfoLine } from '../tools/lines/info-line';\nimport { TrendAngle } from '../tools/lines/trend-angle';\nimport { HorizontalRay } from '../tools/lines/horizontal-ray';\n\nimport { Rectangle } from '../tools/shapes/rectangle';\nimport { Circle } from '../tools/shapes/circle';\nimport { Triangle } from '../tools/shapes/triangle';\nimport { PriceRange } from '../tools/shapes/price-range';\n\nimport { ParallelChannel } from '../tools/channels/parallel-channel';\nimport { RegressionTrend } from '../tools/channels/regression-trend';\nimport { FlatTopBottom } from '../tools/channels/flat-top-bottom';\nimport { DisjointChannel } from '../tools/channels/disjoint-channel';\nimport { FibRetracement } from '../tools/channels/fib-retracement';\n\nimport { FibExtension } from '../tools/fibonacci/fib-extension';\nimport { FibChannel } from '../tools/fibonacci/fib-channel';\nimport { FibTimeZone } from '../tools/fibonacci/fib-time-zone';\nimport { FibSpeedFan } from '../tools/fibonacci/fib-speed-fan';\nimport { FibTimeExtension } from '../tools/fibonacci/fib-time-extension';\nimport { FibCircles } from '../tools/fibonacci/fib-circles';\nimport { FibSpiral } from '../tools/fibonacci/fib-spiral';\nimport { FibArcs } from '../tools/fibonacci/fib-arcs';\nimport { FibWedge } from '../tools/fibonacci/fib-wedge';\nimport { Pitchfan } from '../tools/fibonacci/pitchfan';\n\nimport { AndrewsPitchfork } from '../tools/pitchforks/andrews-pitchfork';\nimport { SchiffPitchfork } from '../tools/pitchforks/schiff-pitchfork';\nimport { ModifiedSchiffPitchfork } from '../tools/pitchforks/modified-schiff-pitchfork';\nimport { InsidePitchfork } from '../tools/pitchforks/inside-pitchfork';\n\nimport { GannBox } from '../tools/gann/gann-box';\nimport { GannFan } from '../tools/gann/gann-fan';\nimport { GannSquareFixed } from '../tools/gann/gann-square-fixed';\nimport { GannSquare } from '../tools/gann/gann-square';\n\nimport { LongPosition } from '../tools/forecasting/long-position';\nimport { ShortPosition } from '../tools/forecasting/short-position';\nimport { DateRange } from '../tools/forecasting/date-range';\nimport { DatePriceRange } from '../tools/forecasting/date-price-range';\nimport { Projection } from '../tools/forecasting/projection';\n\nimport { TextAnnotation } from '../tools/annotations/text-annotation';\nimport { Callout } from '../tools/annotations/callout';\nimport { Brush } from '../tools/annotations/brush';\nimport { Highlighter } from '../tools/annotations/highlighter';\nimport { ArrowMarker } from '../tools/annotations/arrow-marker';\nimport { ArrowMarkUp } from '../tools/annotations/arrow-mark-up';\nimport { ArrowMarkDown } from '../tools/annotations/arrow-mark-down';\nimport { AnchoredText } from '../tools/annotations/anchored-text';\nimport { Note } from '../tools/annotations/note';\nimport { PriceNote } from '../tools/annotations/price-note';\nimport { PriceLabel } from '../tools/annotations/price-label';\nimport { FlagMark } from '../tools/annotations/flag-mark';\nimport { Pin } from '../tools/annotations/pin';\nimport { Comment } from '../tools/annotations/comment';\nimport { Signpost } from '../tools/annotations/signpost';\nimport { Table } from '../tools/annotations/table';\n\nimport { Forecast } from '../tools/forecasting/forecast';\nimport { BarsPattern } from '../tools/forecasting/bars-pattern';\n\nimport { Ellipse } from '../tools/shapes/ellipse';\nimport { Arc } from '../tools/shapes/arc';\nimport { RotatedRectangle } from '../tools/shapes/rotated-rectangle';\nimport { Path } from '../tools/shapes/path';\nimport { Polyline } from '../tools/shapes/polyline';\nimport { Curve } from '../tools/shapes/curve';\nimport { DoubleCurve } from '../tools/shapes/double-curve';\n\n/**\n * Tool definition with factory function\n */\ninterface ToolRegistryEntry extends DrawingToolDefinition {\n factory: (id: string, anchors?: Anchor[], style?: Partial<DrawingStyle>, options?: Partial<DrawingOptions>) => IDrawing;\n}\n\n/**\n * All registered drawing tools\n */\nconst TOOL_DEFINITIONS: ToolRegistryEntry[] = [\n // Line Tools\n {\n type: 'trend-line',\n name: 'Trend Line',\n category: 'line',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new TrendLine(id, anchors, style, options),\n },\n {\n type: 'horizontal-line',\n name: 'Horizontal Line',\n category: 'line',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new HorizontalLine(id, anchors, style, options),\n },\n {\n type: 'vertical-line',\n name: 'Vertical Line',\n category: 'line',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new VerticalLine(id, anchors, style, options),\n },\n {\n type: 'ray',\n name: 'Ray',\n category: 'line',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Ray(id, anchors, style, options),\n },\n {\n type: 'arrow',\n name: 'Arrow',\n category: 'line',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Arrow(id, anchors, style, options),\n },\n {\n type: 'extended-line',\n name: 'Extended Line',\n category: 'line',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new ExtendedLine(id, anchors, style, options),\n },\n {\n type: 'cross-line',\n name: 'Cross Line',\n category: 'line',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new CrossLine(id, anchors, style, options),\n },\n {\n type: 'info-line',\n name: 'Info Line',\n category: 'line',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new InfoLine(id, anchors, style, options),\n },\n {\n type: 'trend-angle',\n name: 'Trend Angle',\n category: 'line',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new TrendAngle(id, anchors, style, options),\n },\n {\n type: 'horizontal-ray',\n name: 'Horizontal Ray',\n category: 'line',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new HorizontalRay(id, anchors, style, options),\n },\n\n // Shape Tools\n {\n type: 'rectangle',\n name: 'Rectangle',\n category: 'shape',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Rectangle(id, anchors, style, options),\n },\n {\n type: 'circle',\n name: 'Circle',\n category: 'shape',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Circle(id, anchors, style, options),\n },\n {\n type: 'triangle',\n name: 'Triangle',\n category: 'shape',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new Triangle(id, anchors, style, options),\n },\n {\n type: 'price-range',\n name: 'Price Range',\n category: 'shape',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new PriceRange(id, anchors, style, options),\n },\n\n // Channel Tools\n {\n type: 'parallel-channel',\n name: 'Parallel Channel',\n category: 'channel',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new ParallelChannel(id, anchors, style, options),\n },\n {\n type: 'regression-trend',\n name: 'Regression Trend',\n category: 'channel',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new RegressionTrend(id, anchors, style, options),\n },\n {\n type: 'flat-top-bottom',\n name: 'Flat Top/Bottom',\n category: 'channel',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new FlatTopBottom(id, anchors, style, options),\n },\n {\n type: 'disjoint-channel',\n name: 'Disjoint Channel',\n category: 'channel',\n requiredAnchors: 4,\n factory: (id, anchors, style, options) => new DisjointChannel(id, anchors, style, options),\n },\n {\n type: 'fib-retracement',\n name: 'Fibonacci Retracement',\n category: 'fibonacci',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new FibRetracement(id, anchors, style, options),\n },\n\n // Fibonacci Tools\n {\n type: 'fib-extension',\n name: 'Fibonacci Extension',\n category: 'fibonacci',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new FibExtension(id, anchors, style, options),\n },\n {\n type: 'fib-channel',\n name: 'Fibonacci Channel',\n category: 'fibonacci',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new FibChannel(id, anchors, style, options),\n },\n {\n type: 'fib-time-zone',\n name: 'Fibonacci Time Zone',\n category: 'fibonacci',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new FibTimeZone(id, anchors, style, options),\n },\n {\n type: 'fib-speed-fan',\n name: 'Fibonacci Speed Fan',\n category: 'fibonacci',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new FibSpeedFan(id, anchors, style, options),\n },\n {\n type: 'fib-time-extension',\n name: 'Trend-Based Fib Time',\n category: 'fibonacci',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new FibTimeExtension(id, anchors, style, options),\n },\n {\n type: 'fib-circles',\n name: 'Fibonacci Circles',\n category: 'fibonacci',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new FibCircles(id, anchors, style, options),\n },\n {\n type: 'fib-spiral',\n name: 'Fibonacci Spiral',\n category: 'fibonacci',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new FibSpiral(id, anchors, style, options),\n },\n {\n type: 'fib-arcs',\n name: 'Fibonacci Arcs',\n category: 'fibonacci',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new FibArcs(id, anchors, style, options),\n },\n {\n type: 'fib-wedge',\n name: 'Fibonacci Wedge',\n category: 'fibonacci',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new FibWedge(id, anchors, style, options),\n },\n {\n type: 'pitchfan',\n name: 'Pitchfan',\n category: 'fibonacci',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new Pitchfan(id, anchors, style, options),\n },\n\n // Pitchfork Tools\n {\n type: 'andrews-pitchfork',\n name: \"Andrews' Pitchfork\",\n category: 'pitchfork',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new AndrewsPitchfork(id, anchors, style, options),\n },\n {\n type: 'schiff-pitchfork',\n name: 'Schiff Pitchfork',\n category: 'pitchfork',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new SchiffPitchfork(id, anchors, style, options),\n },\n {\n type: 'modified-schiff-pitchfork',\n name: 'Modified Schiff Pitchfork',\n category: 'pitchfork',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new ModifiedSchiffPitchfork(id, anchors, style, options),\n },\n {\n type: 'inside-pitchfork',\n name: 'Inside Pitchfork',\n category: 'pitchfork',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new InsidePitchfork(id, anchors, style, options),\n },\n\n // Gann Tools\n {\n type: 'gann-box',\n name: 'Gann Box',\n category: 'gann',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new GannBox(id, anchors, style, options),\n },\n {\n type: 'gann-fan',\n name: 'Gann Fan',\n category: 'gann',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new GannFan(id, anchors, style, options),\n },\n {\n type: 'gann-square-fixed',\n name: 'Gann Square Fixed',\n category: 'gann',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new GannSquareFixed(id, anchors, style, options),\n },\n {\n type: 'gann-square',\n name: 'Gann Square',\n category: 'gann',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new GannSquare(id, anchors, style, options),\n },\n\n // Forecasting Tools\n {\n type: 'long-position',\n name: 'Long Position',\n category: 'forecasting',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new LongPosition(id, anchors, style, options),\n },\n {\n type: 'short-position',\n name: 'Short Position',\n category: 'forecasting',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new ShortPosition(id, anchors, style, options),\n },\n {\n type: 'date-range',\n name: 'Date Range',\n category: 'measurement',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new DateRange(id, anchors, style, options),\n },\n {\n type: 'date-price-range',\n name: 'Date and Price Range',\n category: 'measurement',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new DatePriceRange(id, anchors, style, options),\n },\n {\n type: 'projection',\n name: 'Projection',\n category: 'forecasting',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new Projection(id, anchors, style, options),\n },\n\n // Annotation Tools\n {\n type: 'text-annotation',\n name: 'Text',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new TextAnnotation(id, anchors, style, options),\n },\n {\n type: 'callout',\n name: 'Callout',\n category: 'annotation',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Callout(id, anchors, style, options),\n },\n {\n type: 'brush',\n name: 'Brush',\n category: 'annotation',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Brush(id, anchors, style, options),\n },\n {\n type: 'highlighter',\n name: 'Highlighter',\n category: 'annotation',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Highlighter(id, anchors, style, options),\n },\n {\n type: 'arrow-marker',\n name: 'Arrow Marker',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new ArrowMarker(id, anchors, style, options),\n },\n {\n type: 'arrow-mark-up',\n name: 'Arrow Mark Up',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new ArrowMarkUp(id, anchors, style, options),\n },\n {\n type: 'arrow-mark-down',\n name: 'Arrow Mark Down',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new ArrowMarkDown(id, anchors, style, options),\n },\n\n // Additional Shape Tools\n {\n type: 'ellipse',\n name: 'Ellipse',\n category: 'shape',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Ellipse(id, anchors, style, options),\n },\n {\n type: 'arc',\n name: 'Arc',\n category: 'shape',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new Arc(id, anchors, style, options),\n },\n {\n type: 'rotated-rectangle',\n name: 'Rotated Rectangle',\n category: 'shape',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new RotatedRectangle(id, anchors, style, options),\n },\n {\n type: 'path',\n name: 'Path',\n category: 'shape',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Path(id, anchors, style, options),\n },\n {\n type: 'polyline',\n name: 'Polyline',\n category: 'shape',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Polyline(id, anchors, style, options),\n },\n {\n type: 'curve',\n name: 'Curve',\n category: 'shape',\n requiredAnchors: 4,\n factory: (id, anchors, style, options) => new Curve(id, anchors, style, options),\n },\n {\n type: 'double-curve',\n name: 'Double Curve',\n category: 'shape',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new DoubleCurve(id, anchors, style, options),\n },\n\n // Additional Annotation Tools\n {\n type: 'anchored-text',\n name: 'Anchored Text',\n category: 'annotation',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new AnchoredText(id, anchors, style, options),\n },\n {\n type: 'note',\n name: 'Note',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new Note(id, anchors, style, options),\n },\n {\n type: 'price-note',\n name: 'Price Note',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new PriceNote(id, anchors, style, options),\n },\n {\n type: 'price-label',\n name: 'Price Label',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new PriceLabel(id, anchors, style, options),\n },\n {\n type: 'flag-mark',\n name: 'Flag Mark',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new FlagMark(id, anchors, style, options),\n },\n {\n type: 'pin',\n name: 'Pin',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new Pin(id, anchors, style, options),\n },\n {\n type: 'comment',\n name: 'Comment',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new Comment(id, anchors, style, options),\n },\n {\n type: 'signpost',\n name: 'Signpost',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new Signpost(id, anchors, style, options),\n },\n {\n type: 'table',\n name: 'Table',\n category: 'annotation',\n requiredAnchors: 1,\n factory: (id, anchors, style, options) => new Table(id, anchors, style, options),\n },\n {\n type: 'forecast',\n name: 'Forecast',\n category: 'forecasting',\n requiredAnchors: 2,\n factory: (id, anchors, style, options) => new Forecast(id, anchors, style, options),\n },\n {\n type: 'bars-pattern',\n name: 'Bars Pattern',\n category: 'forecasting',\n requiredAnchors: 3,\n factory: (id, anchors, style, options) => new BarsPattern(id, anchors, style, options),\n },\n];\n\n/**\n * Tool Registry - Central registry for all drawing tools.\n */\nexport class ToolRegistry {\n private static _instance: ToolRegistry;\n private _tools: Map<string, ToolRegistryEntry> = new Map();\n\n private constructor() {\n // Register default tools\n for (const tool of TOOL_DEFINITIONS) {\n this._tools.set(tool.type, tool);\n }\n }\n\n static getInstance(): ToolRegistry {\n if (!ToolRegistry._instance) {\n ToolRegistry._instance = new ToolRegistry();\n }\n return ToolRegistry._instance;\n }\n\n /**\n * Register a custom tool\n */\n register(entry: ToolRegistryEntry): void {\n this._tools.set(entry.type, entry);\n }\n\n /**\n * Get tool definition by type\n */\n get(type: string): ToolRegistryEntry | undefined {\n return this._tools.get(type);\n }\n\n /**\n * Get all tool definitions\n */\n getAll(): ToolRegistryEntry[] {\n return Array.from(this._tools.values());\n }\n\n /**\n * Get tools by category\n */\n getByCategory(category: DrawingCategory): ToolRegistryEntry[] {\n return Array.from(this._tools.values()).filter((t) => t.category === category);\n }\n\n /**\n * Get all categories\n */\n getCategories(): DrawingCategory[] {\n const categories = new Set<DrawingCategory>();\n for (const tool of this._tools.values()) {\n categories.add(tool.category);\n }\n return Array.from(categories);\n }\n\n /**\n * Create a drawing instance\n */\n createDrawing(\n type: string,\n id: string,\n anchors?: Anchor[],\n style?: Partial<DrawingStyle>,\n options?: Partial<DrawingOptions>\n ): IDrawing | null {\n const entry = this._tools.get(type);\n if (!entry) return null;\n return entry.factory(id, anchors, style, options);\n }\n\n /**\n * Check if a tool type is registered\n */\n has(type: string): boolean {\n return this._tools.has(type);\n }\n}\n\n// Export singleton getter\nexport function getToolRegistry(): ToolRegistry {\n return ToolRegistry.getInstance();\n}\n\n// Export tool definitions for reference\nexport { TOOL_DEFINITIONS };\n","/**\n * lightweight-charts-drawing\n *\n * Drawing tools plugin for TradingView's lightweight-charts library.\n * Provides professional-grade drawing tools including trend lines,\n * Fibonacci retracements, channels, and more.\n *\n * @packageDocumentation\n */\n\n// ============ Core ============\nexport {\n // Base class\n Drawing,\n // Manager\n DrawingManager,\n // Types\n type Anchor,\n type Point,\n type DrawingStyle,\n type DrawingOptions,\n type DrawingState,\n type SerializedDrawing,\n type Viewport,\n type MouseEventData,\n type PixelToChartFn,\n type ChartToPixelFn,\n type SnapConfig,\n type DrawingToolDefinition,\n type DrawingCategory,\n type DrawingEventType,\n type DrawingEvent,\n type DrawingEventCallback,\n type IDrawing,\n type ControlPoint,\n // Constants\n DEFAULT_DRAWING_STYLE,\n} from './core';\n\n// ============ Geometry ============\nexport {\n // Types\n type Geometry,\n type LineGeometry,\n type ArcGeometry,\n type RectangleGeometry,\n type PolygonGeometry,\n type TextGeometry,\n // Utility functions\n distanceToLineSegment,\n distanceToLine,\n distanceBetweenPoints,\n isPointNear,\n extendLineToViewport,\n getLineAngle,\n getLineAngleDegrees,\n rotatePoint,\n midpoint,\n lerp,\n} from './core/geometry';\n\n// ============ Interaction ============\nexport {\n InteractionHandler,\n TwoPointInteractionHandler,\n ThreePointInteractionHandler,\n SinglePointInteractionHandler,\n type InteractionState,\n type InteractionConfig,\n type IInteractionHandler,\n} from './interaction';\n\n// ============ Rendering ============\nexport {\n // Canvas utilities\n applyStyle,\n drawLine,\n drawDashedLine,\n drawControlPoint,\n drawControlPoints,\n drawArrowHead,\n drawFilledArrowHead,\n drawCircle,\n drawRect,\n drawText,\n drawLabel,\n calculatePriceChange,\n formatPrice,\n formatPercentage,\n // Preview renderers\n PreviewRenderer,\n LinePreviewRenderer,\n HorizontalLinePreviewRenderer,\n VerticalLinePreviewRenderer,\n ThreePointPreviewRenderer,\n type IPreviewRenderer,\n // Pane view\n DrawingPaneView,\n} from './rendering';\n\n// ============ Line Tools ============\nexport {\n BaseLine,\n TrendLine,\n TrendLinePaneView,\n type TrendLineOptions,\n HorizontalLine,\n HorizontalLinePaneView,\n type HorizontalLineOptions,\n VerticalLine,\n VerticalLinePaneView,\n type VerticalLineOptions,\n Ray,\n RayPaneView,\n type RayOptions,\n Arrow,\n ArrowPaneView,\n type ArrowOptions,\n ExtendedLine,\n ExtendedLinePaneView,\n type ExtendedLineOptions,\n CrossLine,\n CrossLinePaneView,\n type CrossLineOptions,\n InfoLine,\n InfoLinePaneView,\n type InfoLineOptions,\n TrendAngle,\n TrendAnglePaneView,\n type TrendAngleOptions,\n HorizontalRay,\n HorizontalRayPaneView,\n type HorizontalRayOptions,\n} from './tools/lines';\n\n// ============ Shape Tools ============\nexport {\n Rectangle,\n RectanglePaneView,\n type RectangleOptions,\n RotatedRectangle,\n RotatedRectanglePaneView,\n type RotatedRectangleOptions,\n Circle,\n CirclePaneView,\n type CircleOptions,\n Triangle,\n TrianglePaneView,\n type TriangleOptions,\n PriceRange,\n PriceRangePaneView,\n type PriceRangeOptions,\n Ellipse,\n EllipsePaneView,\n type EllipseOptions,\n Arc,\n ArcPaneView,\n type ArcOptions,\n Path,\n PathPaneView,\n type PathOptions,\n Polyline,\n PolylinePaneView,\n type PolylineOptions,\n Curve,\n CurvePaneView,\n type CurveOptions,\n DoubleCurve,\n DoubleCurvePaneView,\n type DoubleCurveOptions,\n} from './tools/shapes';\n\n// ============ Channel Tools ============\nexport {\n ParallelChannel,\n ParallelChannelPaneView,\n type ParallelChannelOptions,\n RegressionTrend,\n RegressionTrendPaneView,\n type RegressionTrendOptions,\n FlatTopBottom,\n FlatTopBottomPaneView,\n type FlatTopBottomOptions,\n DisjointChannel,\n DisjointChannelPaneView,\n type DisjointChannelOptions,\n FibRetracement,\n FibRetracementPaneView,\n type FibRetracementOptions,\n FIBONACCI_LEVELS,\n} from './tools/channels';\n\n// ============ Fibonacci Tools ============\nexport {\n FibExtension,\n FibExtensionPaneView,\n type FibExtensionOptions,\n FIB_EXTENSION_LEVELS,\n FibChannel,\n FibChannelPaneView,\n type FibChannelOptions,\n FIB_CHANNEL_LEVELS,\n FibTimeZone,\n FibTimeZonePaneView,\n type FibTimeZoneOptions,\n FIB_TIME_INTERVALS,\n FibSpeedFan,\n FibSpeedFanPaneView,\n type FibSpeedFanOptions,\n FIB_SPEED_RATIOS,\n FibTimeExtension,\n FibTimeExtensionPaneView,\n type FibTimeExtensionOptions,\n FIB_TIME_EXTENSION_LEVELS,\n FibCircles,\n FibCirclesPaneView,\n type FibCirclesOptions,\n FIB_CIRCLE_LEVELS,\n FibSpiral,\n FibSpiralPaneView,\n type FibSpiralOptions,\n GOLDEN_RATIO,\n FibArcs,\n FibArcsPaneView,\n type FibArcsOptions,\n FIB_ARC_LEVELS,\n FibWedge,\n FibWedgePaneView,\n type FibWedgeOptions,\n FIB_WEDGE_LEVELS,\n Pitchfan,\n PitchfanPaneView,\n type PitchfanOptions,\n PITCHFAN_LEVELS,\n} from './tools/fibonacci';\n\n// ============ Pitchfork Tools ============\nexport {\n AndrewsPitchfork,\n AndrewsPitchforkPaneView,\n type AndrewsPitchforkOptions,\n SchiffPitchfork,\n SchiffPitchforkPaneView,\n type SchiffPitchforkOptions,\n ModifiedSchiffPitchfork,\n ModifiedSchiffPitchforkPaneView,\n type ModifiedSchiffPitchforkOptions,\n InsidePitchfork,\n InsidePitchforkPaneView,\n type InsidePitchforkOptions,\n} from './tools/pitchforks';\n\n// ============ Gann Tools ============\nexport {\n GannBox,\n GannBoxPaneView,\n type GannBoxOptions,\n GANN_LEVELS,\n GannFan,\n GannFanPaneView,\n type GannFanOptions,\n GANN_FAN_ANGLES,\n GannSquareFixed,\n GannSquareFixedPaneView,\n type GannSquareFixedOptions,\n GANN_SQUARE_LEVELS,\n GannSquare,\n GannSquarePaneView,\n type GannSquareOptions,\n GANN_SQUARE_DIVISIONS,\n} from './tools/gann';\n\n// ============ Forecasting Tools ============\nexport {\n LongPosition,\n LongPositionPaneView,\n type LongPositionOptions,\n ShortPosition,\n ShortPositionPaneView,\n type ShortPositionOptions,\n DateRange,\n DateRangePaneView,\n type DateRangeOptions,\n DatePriceRange,\n DatePriceRangePaneView,\n type DatePriceRangeOptions,\n Projection,\n ProjectionPaneView,\n type ProjectionOptions,\n Forecast,\n ForecastPaneView,\n type ForecastOptions,\n BarsPattern,\n BarsPatternPaneView,\n type BarsPatternOptions,\n} from './tools/forecasting';\n\n// ============ Annotation Tools ============\nexport {\n TextAnnotation,\n TextAnnotationPaneView,\n type TextAnnotationOptions,\n Callout,\n CalloutPaneView,\n type CalloutOptions,\n Brush,\n BrushPaneView,\n type BrushOptions,\n Highlighter,\n HighlighterPaneView,\n type HighlighterOptions,\n ArrowMarker,\n ArrowMarkerPaneView,\n type ArrowMarkerOptions,\n type ArrowDirection,\n ArrowMarkUp,\n ArrowMarkUpPaneView,\n type ArrowMarkUpOptions,\n ArrowMarkDown,\n ArrowMarkDownPaneView,\n type ArrowMarkDownOptions,\n AnchoredText,\n AnchoredTextPaneView,\n type AnchoredTextOptions,\n Note,\n NotePaneView,\n type NoteOptions,\n PriceNote,\n PriceNotePaneView,\n type PriceNoteOptions,\n PriceLabel,\n PriceLabelPaneView,\n type PriceLabelOptions,\n FlagMark,\n FlagMarkPaneView,\n type FlagMarkOptions,\n type FlagColor,\n Pin,\n PinPaneView,\n type PinOptions,\n Comment,\n CommentPaneView,\n type CommentOptions,\n Signpost,\n SignpostPaneView,\n type SignpostOptions,\n Table,\n TablePaneView,\n type TableOptions,\n} from './tools/annotations';\n\n// ============ Tool Registry ============\nexport {\n ToolRegistry,\n getToolRegistry,\n TOOL_DEFINITIONS,\n} from './registry';\n\n// ============ Version ============\nexport const VERSION = '0.1.0';\n"],"names":["DEFAULT_DRAWING_STYLE","distanceToLineSegment","point","lineStart","lineEnd","dx","dy","lengthSquared","ex","ey","t","projectionX","projectionY","px","py","distanceToLine","numerator","denominator","distanceBetweenPoints","p1","p2","isPointNear","threshold","extendLineToViewport","start","end","viewportWidth","viewportHeight","extendLeft","extendRight","newStart","newEnd","slope","intercept","yAtX0","yAtXMax","getLineAngle","getLineAngleDegrees","rotatePoint","center","angle","cos","sin","midpoint","lerp","Drawing","id","anchors","style","options","__publicField","value","series","chart","container","params","x","y","viewport","prices","a","index","anchor","state","controlPoints","cp","points","pixel","time","price","timeScale","height","_a","logical","data","DrawingManager","drawing","current","toolType","drawings","hitDrawing","event","anchorIndex","_event","rect","d","factory","item","callback","type","listeners","InteractionHandler","config","_data","key","_point","_b","TwoPointInteractionHandler","ThreePointInteractionHandler","SinglePointInteractionHandler","applyStyle","ctx","pixelRatio","drawLine","drawDashedLine","dashPattern","drawControlPoint","isActive","lineColor","radius","ringWidth","drawControlPoints","activeIndex","drawArrowHead","from","to","size","arrowSize","drawFilledArrowHead","drawCircle","fill","drawRect","topLeft","width","w","h","drawText","text","position","font","color","align","baseline","drawLabel","textColor","backgroundColor","padding","borderRadius","textWidth","textHeight","pad","calculatePriceChange","startPrice","endPrice","change","percentage","formatPrice","precision","formatPercentage","PreviewRenderer","LinePreviewRenderer","previewAnchor","startPoint","endPoint","HorizontalLinePreviewRenderer","VerticalLinePreviewRenderer","ThreePointPreviewRenderer","previewPoint","i","DrawingPaneView","DrawingPaneRenderer","target","scope","horizontalPixelRatio","geometries","geometry","line","extended","arc","polygon","_BaseLine","isExtended","distance","dt","absolute","t0","t1","BaseLine","TrendLinePaneView","TrendLinePaneRenderer","drawStart","drawEnd","labelParts","sign","bars","labelPosition","offset","labelY","TrendLine","showAngle","showPriceChange","showPercentChange","showBars","baseOptions","lineGeometry","labelGeometries","labels","newId","startAnchor","endAnchor","HorizontalLinePaneView","HorizontalLinePaneRenderer","priceText","_HorizontalLine","showPrice","showLabel","labelText","HorizontalLine","VerticalLinePaneView","VerticalLinePaneRenderer","timeText","_VerticalLine","showTime","VerticalLine","RayPaneView","RayPaneRenderer","labelPos","Ray","ArrowPaneView","ArrowPaneRenderer","Arrow","showBothEnds","ExtendedLinePaneView","ExtendedLinePaneRenderer","ExtendedLine","CrossLinePaneView","CrossLinePaneRenderer","_CrossLine","CrossLine","InfoLinePaneView","InfoLinePaneRenderer","priceChange","InfoLine","showDistance","TrendAnglePaneView","TrendAnglePaneRenderer","arcRadius","angleDeg","labelRadius","midAngle","labelX","TrendAngle","showArc","showDegrees","arcGeometry","HorizontalRayPaneView","HorizontalRayPaneRenderer","direction","arrowX","_HorizontalRay","HorizontalRay","RectanglePaneView","RectanglePaneRenderer","centerX","centerY","_Rectangle","filled","showDimensions","left","right","top","bottom","nearLeft","nearRight","nearTop","nearBottom","min","max","corner1","corner2","Rectangle","RotatedRectanglePaneView","RotatedRectanglePaneRenderer","corners","_RotatedRectangle","p3","edgeLength","perpX","perpY","v3x","v3y","next","inside","j","xi","yi","xj","yj","RotatedRectangle","CirclePaneView","CirclePaneRenderer","edge","_Circle","distToCenter","Circle","TrianglePaneView","TrianglePaneRenderer","p","_Triangle","b","c","d1","d2","d3","hasNeg","hasPos","Triangle","PriceRangePaneView","PriceRangePaneRenderer","y1","y2","rangeInfo","_PriceRange","showPrices","showRange","showPercentage","rectGeometry","range","price1","price2","PriceRange","EllipsePaneView","EllipsePaneRenderer","radiusX","radiusY","_Ellipse","normalizedDist","innerThreshold","outerThreshold","Ellipse","ArcPaneView","ArcPaneRenderer","startAngle","endAngle","_Arc","dist","innerRadius","outerRadius","normStart","normEnd","normAngle","Arc","PathPaneView","PathPaneRenderer","_Path","closed","segmentCount","Path","PolylinePaneView","PolylinePaneRenderer","vertexRadius","_Polyline","showVertices","totalLength","Polyline","CurvePaneView","CurvePaneRenderer","controlPts","control1","control2","markerRadius","_Curve","showControlLines","resolution","p0","t2","t3","mt","mt2","mt3","curvePoints","lengthSq","projection","Curve","DoubleCurvePaneView","DoubleCurvePaneRenderer","mainPts","ctrlPts","middle","cp1","cp2","cp3","cp4","pt","_DoubleCurve","showControlPoints","curvature","dx1","dx2","halfRes","DoubleCurve","ParallelChannelPaneView","ParallelChannelPaneRenderer","p1Parallel","p2Parallel","drawP1","drawP2","drawP1P","drawP2P","extended1","extended2","p1Middle","p2Middle","drawP1M","drawP2M","extendedM","len","nx","ny","vx","vy","_ParallelChannel","showMiddleLine","extendLines","minX","maxX","minY","maxY","ParallelChannel","RegressionTrendPaneView","RegressionTrendPaneRenderer","stdDev","offsetX","offsetY","p1Upper","p2Upper","p1Lower","p2Lower","drawP1U","drawP2U","drawP1L","drawP2L","extendedMid","extendedUpper","extendedLower","_RegressionTrend","standardDeviations","lineLength","RegressionTrend","FlatTopBottomPaneView","FlatTopBottomPaneRenderer","flatY","flatStart","flatEnd","drawFlatStart","drawFlatEnd","extendedTrend","extendedFlat","_FlatTopBottom","flatPosition","flatLevel","FlatTopBottom","DisjointChannelPaneView","DisjointChannelPaneRenderer","p4","drawP3","drawP4","midStart","midEnd","drawMidStart","drawMidEnd","_DisjointChannel","line1Start","line1End","line2Start","line2End","DisjointChannel","FIB_COLORS","FibRetracementPaneView","FibRetracementPaneRenderer","levels","FIBONACCI_LEVELS","priceRange","sortedLevels","level1","level2","levelPrice1","levelPrice2","level","_FibRetracement","showPercentages","reverseDirection","FibRetracement","FibExtensionPaneView","FibExtensionPaneRenderer","pA","pB","pC","FIB_EXTENSION_LEVELS","priceA","priceB","priceC","startX","_FibExtension","endX","pointA","pointB","pointC","FibExtension","FibChannelPaneView","FibChannelPaneRenderer","FIB_CHANNEL_LEVELS","start1","end1","start2","end2","isMainLevel","_FibChannel","FibChannel","FibTimeZonePaneView","FibTimeZonePaneRenderer","intervals","FIB_TIME_INTERVALS","unitWidth","x1","x2","interval","isFibNumber","_FibTimeZone","showLabels","FibTimeZone","FibSpeedFanPaneView","FibSpeedFanPaneRenderer","ratios","FIB_SPEED_RATIOS","sortedRatios","ratio","isMainRatio","_FibSpeedFan","adjustedDy","extendFactor","FibSpeedFan","FibTimeExtensionPaneView","FibTimeExtensionPaneRenderer","FIB_TIME_EXTENSION_LEVELS","baseTimeWidth","_FibTimeExtension","extension","FibTimeExtension","FibCirclesPaneView","FibCirclesPaneRenderer","FIB_CIRCLE_LEVELS","baseRadius","_FibCircles","distFromCenter","radiusPoint","FibCircles","FibSpiralPaneView","FibSpiralPaneRenderer","startRadius","GOLDEN_RATIO","spiralPoints","startSize","_clockwise","fibSizes","scale","_FibSpiral","rotations","clockwise","showSquares","segments","theta","r","_viewport","segStart","segEnd","projX","projY","sizeRef","FibSpiral","FibArcsPaneView","FibArcsPaneRenderer","FIB_ARC_LEVELS","labelAngle","_FibArcs","fullCircle","pivot","extent","FibArcs","FibWedgePaneView","FibWedgePaneRenderer","apex","FIB_WEDGE_LEVELS","_FibWedge","_apex","boundary1","boundary2","FibWedge","PitchfanPaneView","PitchfanPaneRenderer","PITCHFAN_LEVELS","mid","medianEnd","_Pitchfan","targetPoint","swing1","swing2","Pitchfan","AndrewsPitchforkPaneView","AndrewsPitchforkPaneRenderer","p1End","p2End","drawMedianEnd","drawP1End","drawP2End","extMedian","extP1","extP2","_AndrewsPitchfork","showMedianLine","showOuterLines","AndrewsPitchfork","SchiffPitchforkPaneView","SchiffPitchforkPaneRenderer","schiffPivot","_SchiffPitchfork","SchiffPitchfork","ModifiedSchiffPitchforkPaneView","ModifiedSchiffPitchforkPaneRenderer","modifiedPivot","_ModifiedSchiffPitchfork","verticalPoint","ModifiedSchiffPitchfork","InsidePitchforkPaneView","InsidePitchforkPaneRenderer","convergencePoint","drawConvergence","ext1","ext2","_InsidePitchfork","factor","InsidePitchfork","GannBoxPaneView","GannBoxPaneRenderer","priceLevels","GANN_LEVELS","timeLevels","_GannBox","showDiagonals","GannBox","GANN_COLORS","GannFanPaneView","GannFanPaneRenderer","angles","GANN_FAN_ANGLES","baseLen","unitX","unitY","fanDx","fanDy","_GannFan","origin","GannFan","GannSquareFixedPaneView","GannSquareFixedPaneRenderer","halfSize","GANN_SQUARE_LEVELS","_GannSquareFixed","squareSize","showArcs","topY","bottomY","GannSquareFixed","GannSquarePaneView","GannSquarePaneRenderer","divisions","GANN_SQUARE_DIVISIONS","_divisions","totalRotations","steps","cellSize","fontSize","num","layer","maxLayers","_GannSquare","showCardinalCross","showSpiral","corner","GannSquare","LongPositionPaneView","LongPositionPaneRenderer","entry","stopLoss","takeProfit","info","riskTop","riskHeight","rewardTop","rewardHeight","entryText","slText","tpText","rrText","rrY","_LongPosition","showRiskReward","showPnL","quantity","accountSize","risk","reward","riskRewardRatio","riskPercent","rewardPercent","LongPosition","ShortPositionPaneView","ShortPositionPaneRenderer","_ShortPosition","ShortPosition","DateRangePaneView","DateRangePaneRenderer","bitmapSize","midY","startDate","endDate","_DateRange","showDays","showDates","startTime","endTime","days","DateRange","DatePriceRangePaneView","DatePriceRangePaneRenderer","lineHeight","lines","maxWidth","panelWidth","panelHeight","panelX","panelY","textY","_DatePriceRange","priceChangePercent","isUp","DatePriceRange","ProjectionPaneView","ProjectionPaneRenderer","pD","label","boxWidth","boxHeight","_Projection","moveSize","movePercent","targetPrice","Projection","ForecastPaneView","ForecastPaneRenderer","pH","_Forecast","percentChange","targetAnchor","Forecast","BarsPatternPaneView","BarsPatternPaneRenderer","patternColor","srcLeft","srcTop","srcW","srcH","projLeft","projTop","projW","projH","_BarsPattern","projectedEndPrice","srcRight","srcBottom","projRight","projBottom","BarsPattern","TextAnnotationPaneView","TextAnnotationPaneRenderer","fontFamily","fontWeight","boxX","_TextAnnotation","textAlign","borderColor","estimatedWidth","estimatedHeight","TextAnnotation","CalloutPaneView","CalloutPaneRenderer","boxPos","boxY","targetX","targetY","_Callout","pointerSize","boxPosition","Callout","BrushPaneView","BrushPaneRenderer","brushSize","_Brush","smoothing","Brush","HighlighterPaneView","HighlighterPaneRenderer","highlighterWidth","opacity","_Highlighter","Highlighter","ArrowMarkerPaneView","ArrowMarkerPaneRenderer","vertices","_ArrowMarker","halfBase","v1","v2","v3","ArrowMarker","ArrowMarkUpPaneView","ArrowMarkUpPaneRenderer","_ArrowMarkUp","defaultStyle","ArrowMarkUp","ArrowMarkDownPaneView","ArrowMarkDownPaneRenderer","_ArrowMarkDown","ArrowMarkDown","AnchoredTextPaneView","AnchoredTextPaneRenderer","anchorPos","textPos","_AnchoredText","showConnector","connectorLength","anchorPoint","textPoint","AnchoredText","NotePaneView","NotePaneRenderer","iconColor","iconSize","totalHeight","textX","words","currentLine","word","testLine","hex","amount","g","_Note","showIcon","Note","PriceNotePaneView","PriceNotePaneRenderer","priceColor","noteColor","markerSize","metrics","_PriceNote","note","PriceNote","PriceLabelPaneView","PriceLabelPaneRenderer","decimals","chartWidth","labelWidth","labelHeight","_PriceLabel","showArrow","arrowDirection","PriceLabel","FlagMarkPaneView","FlagMarkPaneRenderer","poleHeight","flagWidth","flagHeight","textMetrics","labelPadding","_FlagMark","flagColor","customColor","FlagMark","PinPaneView","PinPaneRenderer","headRadius","headCenterY","_Pin","Pin","CommentPaneView","CommentPaneRenderer","bgColor","tailSize","contentHeight","l","bubbleX","bubbleY","_Comment","Comment","SignpostPaneView","SignpostPaneRenderer","isRight","bodyWidth","signY","_Signpost","Signpost","TablePaneView","TablePaneRenderer","rows","headerColor","cellPadding","hasHeader","cols","colWidths","row","rowHeight","tableWidth","s","tableHeight","rowY","cellX","cellText","DEFAULT_TABLE_DATA","_Table","headerRow","Table","TOOL_DEFINITIONS","_ToolRegistry","tool","category","categories","ToolRegistry","getToolRegistry","VERSION"],"mappings":"yZA2CO,MAAMA,EAAsC,CACjD,UAAW,UACX,UAAW,EACX,SAAU,CAAA,EACV,UAAW,yBACX,YAAa,GACb,WAAY,GACZ,UAAW,kBACX,WAAY,SACd,ECoBO,SAASC,EACdC,EACAC,EACAC,EACQ,CACR,MAAMC,EAAKD,EAAQ,EAAID,EAAU,EAC3BG,EAAKF,EAAQ,EAAID,EAAU,EAC3BI,EAAgBF,EAAKA,EAAKC,EAAKA,EAErC,GAAIC,IAAkB,EAAG,CAEvB,MAAMC,EAAKN,EAAM,EAAIC,EAAU,EACzBM,EAAKP,EAAM,EAAIC,EAAU,EAC/B,OAAO,KAAK,KAAKK,EAAKA,EAAKC,EAAKA,CAAE,CACpC,CAGA,IAAIC,IAAMR,EAAM,EAAIC,EAAU,GAAKE,GAAMH,EAAM,EAAIC,EAAU,GAAKG,GAAMC,EACxEG,EAAI,KAAK,IAAI,EAAG,KAAK,IAAI,EAAGA,CAAC,CAAC,EAE9B,MAAMC,EAAcR,EAAU,EAAIO,EAAIL,EAChCO,EAAcT,EAAU,EAAIO,EAAIJ,EAChCO,EAAKX,EAAM,EAAIS,EACfG,EAAKZ,EAAM,EAAIU,EAErB,OAAO,KAAK,KAAKC,EAAKA,EAAKC,EAAKA,CAAE,CACpC,CAKO,SAASC,GACdb,EACAC,EACAC,EACQ,CACR,MAAMC,EAAKD,EAAQ,EAAID,EAAU,EAC3BG,EAAKF,EAAQ,EAAID,EAAU,EAC3BI,EAAgBF,EAAKA,EAAKC,EAAKA,EAErC,GAAIC,IAAkB,EAAG,CACvB,MAAMC,EAAKN,EAAM,EAAIC,EAAU,EACzBM,EAAKP,EAAM,EAAIC,EAAU,EAC/B,OAAO,KAAK,KAAKK,EAAKA,EAAKC,EAAKA,CAAE,CACpC,CAGA,MAAMO,EAAY,KAAK,I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