oakscriptjs 0.10.1 → 0.11.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.
Files changed (177) hide show
  1. package/dist/cjs/box/index.d.ts.map +1 -1
  2. package/dist/cjs/box/index.js +7 -1
  3. package/dist/cjs/box/index.js.map +2 -2
  4. package/dist/cjs/callsite/index.d.ts +73 -32
  5. package/dist/cjs/callsite/index.d.ts.map +1 -1
  6. package/dist/cjs/callsite/index.js +69 -65
  7. package/dist/cjs/callsite/index.js.map +2 -2
  8. package/dist/cjs/drawing/registry.d.ts +75 -0
  9. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  10. package/dist/cjs/drawing/registry.js +139 -6
  11. package/dist/cjs/drawing/registry.js.map +2 -2
  12. package/dist/cjs/index.d.ts +6 -1
  13. package/dist/cjs/index.d.ts.map +1 -1
  14. package/dist/cjs/index.js +28 -1
  15. package/dist/cjs/index.js.map +2 -2
  16. package/dist/cjs/label/index.d.ts.map +1 -1
  17. package/dist/cjs/label/index.js +3 -0
  18. package/dist/cjs/label/index.js.map +2 -2
  19. package/dist/cjs/line/index.d.ts.map +1 -1
  20. package/dist/cjs/line/index.js +7 -1
  21. package/dist/cjs/line/index.js.map +2 -2
  22. package/dist/cjs/math/index.d.ts.map +1 -1
  23. package/dist/cjs/math/index.js +2 -0
  24. package/dist/cjs/math/index.js.map +2 -2
  25. package/dist/cjs/polyline/index.d.ts.map +1 -1
  26. package/dist/cjs/polyline/index.js +3 -0
  27. package/dist/cjs/polyline/index.js.map +2 -2
  28. package/dist/cjs/script/index.d.ts +30 -13
  29. package/dist/cjs/script/index.d.ts.map +1 -1
  30. package/dist/cjs/script/index.js +48 -9
  31. package/dist/cjs/script/index.js.map +3 -3
  32. package/dist/cjs/session/bars.d.ts +15 -1
  33. package/dist/cjs/session/bars.d.ts.map +1 -1
  34. package/dist/cjs/session/bars.js +41 -6
  35. package/dist/cjs/session/bars.js.map +3 -3
  36. package/dist/cjs/session/calendar.d.ts +9 -1
  37. package/dist/cjs/session/calendar.d.ts.map +1 -1
  38. package/dist/cjs/session/calendar.js +28 -2
  39. package/dist/cjs/session/calendar.js.map +2 -2
  40. package/dist/cjs/session/context.d.ts +75 -0
  41. package/dist/cjs/session/context.d.ts.map +1 -0
  42. package/dist/cjs/session/context.js +113 -0
  43. package/dist/cjs/session/context.js.map +7 -0
  44. package/dist/cjs/str/index.d.ts +3 -1
  45. package/dist/cjs/str/index.d.ts.map +1 -1
  46. package/dist/cjs/str/index.js +2 -1
  47. package/dist/cjs/str/index.js.map +2 -2
  48. package/dist/cjs/str/numberformat.d.ts +4 -2
  49. package/dist/cjs/str/numberformat.d.ts.map +1 -1
  50. package/dist/cjs/str/numberformat.js +1 -1
  51. package/dist/cjs/str/numberformat.js.map +2 -2
  52. package/dist/cjs/ta/index.d.ts +33 -17
  53. package/dist/cjs/ta/index.d.ts.map +1 -1
  54. package/dist/cjs/ta/index.js +70 -29
  55. package/dist/cjs/ta/index.js.map +2 -2
  56. package/dist/cjs/ta/limits.d.ts +24 -0
  57. package/dist/cjs/ta/limits.d.ts.map +1 -0
  58. package/dist/cjs/ta/limits.js +50 -0
  59. package/dist/cjs/ta/limits.js.map +7 -0
  60. package/dist/cjs/ta/running-sum.d.ts +0 -16
  61. package/dist/cjs/ta/running-sum.d.ts.map +1 -1
  62. package/dist/cjs/ta/running-sum.js +2 -0
  63. package/dist/cjs/ta/running-sum.js.map +2 -2
  64. package/dist/cjs/ta-series.d.ts +7 -7
  65. package/dist/cjs/ta-series.d.ts.map +1 -1
  66. package/dist/cjs/ta-series.js +9 -7
  67. package/dist/cjs/ta-series.js.map +2 -2
  68. package/dist/cjs/time/index.d.ts +5 -2
  69. package/dist/cjs/time/index.d.ts.map +1 -1
  70. package/dist/cjs/time/index.js +2 -2
  71. package/dist/cjs/time/index.js.map +2 -2
  72. package/dist/cjs/time/session.d.ts +17 -1
  73. package/dist/cjs/time/session.d.ts.map +1 -1
  74. package/dist/cjs/time/session.js +61 -7
  75. package/dist/cjs/time/session.js.map +2 -2
  76. package/dist/cjs/types/metadata.d.ts +27 -3
  77. package/dist/cjs/types/metadata.d.ts.map +1 -1
  78. package/dist/cjs/types/metadata.js.map +1 -1
  79. package/dist/esm/box/index.d.ts.map +1 -1
  80. package/dist/esm/box/index.js +8 -2
  81. package/dist/esm/box/index.js.map +1 -1
  82. package/dist/esm/callsite/index.d.ts +73 -32
  83. package/dist/esm/callsite/index.d.ts.map +1 -1
  84. package/dist/esm/callsite/index.js +143 -106
  85. package/dist/esm/callsite/index.js.map +1 -1
  86. package/dist/esm/drawing/registry.d.ts +75 -0
  87. package/dist/esm/drawing/registry.d.ts.map +1 -1
  88. package/dist/esm/drawing/registry.js +237 -6
  89. package/dist/esm/drawing/registry.js.map +1 -1
  90. package/dist/esm/index.d.ts +6 -1
  91. package/dist/esm/index.d.ts.map +1 -1
  92. package/dist/esm/index.js +10 -1
  93. package/dist/esm/index.js.map +1 -1
  94. package/dist/esm/label/index.d.ts.map +1 -1
  95. package/dist/esm/label/index.js +4 -1
  96. package/dist/esm/label/index.js.map +1 -1
  97. package/dist/esm/line/index.d.ts.map +1 -1
  98. package/dist/esm/line/index.js +8 -2
  99. package/dist/esm/line/index.js.map +1 -1
  100. package/dist/esm/math/index.d.ts.map +1 -1
  101. package/dist/esm/math/index.js +3 -0
  102. package/dist/esm/math/index.js.map +1 -1
  103. package/dist/esm/polyline/index.d.ts.map +1 -1
  104. package/dist/esm/polyline/index.js +5 -1
  105. package/dist/esm/polyline/index.js.map +1 -1
  106. package/dist/esm/script/index.d.ts +30 -13
  107. package/dist/esm/script/index.d.ts.map +1 -1
  108. package/dist/esm/script/index.js +54 -11
  109. package/dist/esm/script/index.js.map +1 -1
  110. package/dist/esm/session/bars.d.ts +15 -1
  111. package/dist/esm/session/bars.d.ts.map +1 -1
  112. package/dist/esm/session/bars.js +50 -6
  113. package/dist/esm/session/bars.js.map +1 -1
  114. package/dist/esm/session/calendar.d.ts +9 -1
  115. package/dist/esm/session/calendar.d.ts.map +1 -1
  116. package/dist/esm/session/calendar.js +35 -3
  117. package/dist/esm/session/calendar.js.map +1 -1
  118. package/dist/esm/session/context.d.ts +75 -0
  119. package/dist/esm/session/context.d.ts.map +1 -0
  120. package/dist/esm/session/context.js +122 -0
  121. package/dist/esm/session/context.js.map +1 -0
  122. package/dist/esm/str/index.d.ts +3 -1
  123. package/dist/esm/str/index.d.ts.map +1 -1
  124. package/dist/esm/str/index.js +8 -2
  125. package/dist/esm/str/index.js.map +1 -1
  126. package/dist/esm/str/numberformat.d.ts +4 -2
  127. package/dist/esm/str/numberformat.d.ts.map +1 -1
  128. package/dist/esm/str/numberformat.js +4 -2
  129. package/dist/esm/str/numberformat.js.map +1 -1
  130. package/dist/esm/ta/index.d.ts +33 -17
  131. package/dist/esm/ta/index.d.ts.map +1 -1
  132. package/dist/esm/ta/index.js +130 -56
  133. package/dist/esm/ta/index.js.map +1 -1
  134. package/dist/esm/ta/limits.d.ts +24 -0
  135. package/dist/esm/ta/limits.d.ts.map +1 -0
  136. package/dist/esm/ta/limits.js +42 -0
  137. package/dist/esm/ta/limits.js.map +1 -0
  138. package/dist/esm/ta/running-sum.d.ts +0 -16
  139. package/dist/esm/ta/running-sum.d.ts.map +1 -1
  140. package/dist/esm/ta/running-sum.js +2 -0
  141. package/dist/esm/ta/running-sum.js.map +1 -1
  142. package/dist/esm/ta-series.d.ts +7 -7
  143. package/dist/esm/ta-series.d.ts.map +1 -1
  144. package/dist/esm/ta-series.js +9 -7
  145. package/dist/esm/ta-series.js.map +1 -1
  146. package/dist/esm/time/index.d.ts +5 -2
  147. package/dist/esm/time/index.d.ts.map +1 -1
  148. package/dist/esm/time/index.js +6 -3
  149. package/dist/esm/time/index.js.map +1 -1
  150. package/dist/esm/time/session.d.ts +17 -1
  151. package/dist/esm/time/session.d.ts.map +1 -1
  152. package/dist/esm/time/session.js +97 -10
  153. package/dist/esm/time/session.js.map +1 -1
  154. package/dist/esm/types/metadata.d.ts +27 -3
  155. package/dist/esm/types/metadata.d.ts.map +1 -1
  156. package/package.json +1 -1
  157. package/src/box/index.ts +8 -2
  158. package/src/callsite/index.ts +150 -100
  159. package/src/drawing/registry.ts +255 -5
  160. package/src/index.ts +34 -1
  161. package/src/label/index.ts +4 -1
  162. package/src/line/index.ts +8 -2
  163. package/src/math/index.ts +2 -0
  164. package/src/polyline/index.ts +3 -1
  165. package/src/script/index.ts +77 -18
  166. package/src/session/bars.ts +47 -6
  167. package/src/session/calendar.ts +37 -3
  168. package/src/session/context.ts +160 -0
  169. package/src/str/index.ts +7 -2
  170. package/src/str/numberformat.ts +5 -3
  171. package/src/ta/index.ts +148 -66
  172. package/src/ta/limits.ts +47 -0
  173. package/src/ta/running-sum.ts +2 -0
  174. package/src/ta-series.ts +16 -14
  175. package/src/time/index.ts +6 -3
  176. package/src/time/session.ts +89 -9
  177. package/src/types/metadata.ts +27 -3
package/dist/cjs/index.js CHANGED
@@ -36,9 +36,12 @@ __export(index_exports, {
36
36
  STRATEGY_NUMBER_VARIABLES: () => import_strategy.STRATEGY_NUMBER_VARIABLES,
37
37
  STRATEGY_TEXT_VARIABLES: () => import_strategy.STRATEGY_TEXT_VARIABLES,
38
38
  Series: () => import_series.Series,
39
+ SessionBars: () => import_bars.SessionBars,
39
40
  SimpleInputAdapter: () => import_SimpleInputAdapter.SimpleInputAdapter,
41
+ TradingCalendar: () => import_calendar.TradingCalendar,
40
42
  VERSION: () => VERSION,
41
43
  abs: () => import_math.abs,
44
+ afterCompletion: () => import_resample.afterCompletion,
42
45
  alertcondition: () => alertcondition,
43
46
  array: () => array,
44
47
  at: () => import_utils.at,
@@ -46,12 +49,16 @@ __export(index_exports, {
46
49
  avg: () => import_math.avg,
47
50
  barInterval: () => import_bar_time.barInterval,
48
51
  barTime: () => import_bar_time.barTime,
52
+ barTimeAfter: () => import_context.barTimeAfter,
53
+ barsUntil: () => import_context.barsUntil,
49
54
  bb: () => import_ta_series.bb,
50
55
  box: () => box,
51
56
  callsite: () => callsite,
52
57
  ceil: () => import_math.ceil,
53
58
  change: () => import_ta_series.change,
54
59
  chartPoint: () => chartPoint,
60
+ chartSessionFlags: () => import_context.chartSessionFlags,
61
+ chartSessions: () => import_context.chartSessions,
55
62
  clearContext: () => import_runtime.clearContext,
56
63
  clearPlots: () => import_runtime.clearPlots,
57
64
  color: () => color,
@@ -75,7 +82,9 @@ __export(index_exports, {
75
82
  getOpen: () => import_utils.getOpen,
76
83
  getSource: () => import_utils.getSource,
77
84
  getSourceSeries: () => import_utils.getSourceSeries,
85
+ heikinAshi: () => import_resample.heikinAshi,
78
86
  hline: () => import_runtime.hline,
87
+ holdDrawing: () => import_registry.holdDrawing,
79
88
  indicator: () => import_indicator.indicator,
80
89
  info: () => info,
81
90
  input: () => import_input.input,
@@ -94,6 +103,7 @@ __export(index_exports, {
94
103
  log: () => import_math.log,
95
104
  macd: () => import_ta_series.macd,
96
105
  map: () => map,
106
+ mapToChart: () => import_resample.mapToChart,
97
107
  math: () => math,
98
108
  matrix: () => matrix,
99
109
  max: () => import_math.max,
@@ -102,16 +112,26 @@ __export(index_exports, {
102
112
  new_color: () => import_color.new_color,
103
113
  nz: () => import_utils2.nz,
104
114
  ohlcFromBars: () => import_utils.ohlcFromBars,
115
+ periodClose: () => import_context.periodClose,
116
+ periodTime: () => import_context.periodTime,
117
+ periodsOf: () => import_resample.periodsOf,
105
118
  plot: () => import_runtime.plot,
106
119
  plotHelper: () => import_plot.plot,
107
120
  polyline: () => polyline,
108
121
  pow: () => import_math.pow,
109
122
  recalculate: () => import_runtime.recalculate,
110
123
  registerCalculate: () => import_runtime.registerCalculate,
124
+ releaseDrawing: () => import_registry.releaseDrawing,
125
+ resample: () => import_resample.resample,
126
+ resampleSession: () => import_context.resampleSession,
127
+ resetDrawings: () => import_registry.resetDrawings,
111
128
  rgb: () => import_color.rgb,
112
129
  round: () => import_math.round,
113
130
  rsi: () => import_ta_series.rsi,
131
+ sessionFlags: () => import_bars.sessionFlags,
114
132
  setContext: () => import_runtime.setContext,
133
+ setDrawingBar: () => import_registry.setDrawingBar,
134
+ setDrawingLimits: () => import_registry.setDrawingLimits,
115
135
  sin: () => import_math.sin,
116
136
  sma: () => import_ta_series.sma,
117
137
  sqrt: () => import_math.sqrt,
@@ -126,6 +146,8 @@ __export(index_exports, {
126
146
  time: () => time,
127
147
  timeframe: () => timeframe,
128
148
  tr: () => import_ta_series.tr,
149
+ tradingDayTime: () => import_context.tradingDayTime,
150
+ varDrawing: () => import_registry.varDrawing,
129
151
  vwap: () => import_ta_series.vwap
130
152
  });
131
153
  module.exports = __toCommonJS(index_exports);
@@ -152,6 +174,11 @@ var compare = __toESM(require("./compare/index.js"), 1);
152
174
  var callsite = __toESM(require("./callsite/index.js"), 1);
153
175
  var import_output = require("./drawing/output.js");
154
176
  var import_bar_time = require("./drawing/bar-time.js");
177
+ var import_registry = require("./drawing/registry.js");
178
+ var import_context = require("./session/context.js");
179
+ var import_calendar = require("./session/calendar.js");
180
+ var import_bars = require("./session/bars.js");
181
+ var import_resample = require("./security/resample.js");
155
182
  var import_series = require("./runtime/series.js");
156
183
  var ta = __toESM(require("./ta-series.js"), 1);
157
184
  var import_ta_series = require("./ta-series.js");
@@ -169,7 +196,7 @@ var import_input_active = require("./runtime/input-active.js");
169
196
  var import_strategy = require("./strategy/index.js");
170
197
  var import_LightweightChartsAdapter = require("./runtime/adapters/LightweightChartsAdapter.js");
171
198
  var import_SimpleInputAdapter = require("./runtime/adapters/SimpleInputAdapter.js");
172
- const VERSION = "0.10.1";
199
+ const VERSION = "0.11.0";
173
200
  const info = {
174
201
  name: "OakScriptJS",
175
202
  version: VERSION,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_source,\n input_timeframe,\n input_session,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.10.1';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAY,SAAS,MAAM;AAAA,IACvF,SAAS,CAAC,cAAc,QAAQ,SAAS,SAAS;AAAA,IAClD,WAAW,CAAC,aAAa,SAAS,cAAc,YAAY;AAAA,EAC9D;AACF;AAUO,SAAS,eAAe,YAAqB,QAAiB,UAAyB;AAE9F;",
4
+ "sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count))\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf), time_close(tf), time_tradingday, session.* flags,\n// request.security periods with the session and holidays, and bars after the last bar on the trading calendar\nexport {\n chartSessions,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_source,\n input_timeframe,\n input_session,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.11.0';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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;AAAA,EAC9D;AACF;AAUO,SAAS,eAAe,YAAqB,QAAiB,UAAyB;AAE9F;",
6
6
  "names": ["import_utils"]
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/label/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAElE,KAAK,SAAS,GAAG,WAAW,GAAG,UAAU,CAAC;AAC1C,KAAK,SAAS,GAAG,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;AACnD,KAAK,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,UAAU,EACjB,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,SAAS,EAChB,IAAI,CAAC,EAAE,SAAS,EAChB,UAAU,CAAC,EAAE,KAAK,EAClB,KAAK,CAAC,EAAE,UAAU,EAClB,SAAS,CAAC,EAAE,KAAK,EACjB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EACtB,SAAS,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,EACvC,OAAO,CAAC,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,SAAS,GAAG,WAAW,EAC1C,aAAa,CAAC,EAAE,OAAO,EACvB,eAAe,CAAC,EAAE,MAAM,GACvB,KAAK,CAAC;AACT,wBAAgB,SAAS,CACvB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,SAAS,EAChB,IAAI,CAAC,EAAE,SAAS,EAChB,UAAU,CAAC,EAAE,KAAK,EAClB,KAAK,CAAC,EAAE,UAAU,EAClB,SAAS,CAAC,EAAE,KAAK,EACjB,IAAI,CAAC,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AK,CAIhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,CAIlF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,WAAW,GAAG,KAAK,CAIpF;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,KAAK,GAAG,IAAI,CAE5C;AAQD;;GAEG;AACH,wBAAgB,GAAG,IAAI,KAAK,EAAE,CAE7B;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,GAAG,KAAK,CAK7D;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAIxE;AAGD,OAAO,EAAE,SAAS,IAAI,GAAG,EAAE,CAAC;AAC5B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC"}
@@ -70,6 +70,7 @@ function new_label(...args) {
70
70
  force_overlay,
71
71
  text_formatting
72
72
  ] = rest;
73
+ (0, import_registry.checkBarIndex)("label.new", "x", x, xloc);
73
74
  return (0, import_registry.register)("label", {
74
75
  x,
75
76
  y,
@@ -102,6 +103,7 @@ function copy(id) {
102
103
  }
103
104
  function set_x(id, x) {
104
105
  if ((0, import_registry.isDeleted)(id)) return id;
106
+ (0, import_registry.checkBarIndex)("label.set_x", "x", x, id.xloc);
105
107
  id.x = x;
106
108
  return id;
107
109
  }
@@ -112,6 +114,7 @@ function set_y(id, y) {
112
114
  }
113
115
  function set_xy(id, x, y) {
114
116
  if ((0, import_registry.isDeleted)(id)) return id;
117
+ (0, import_registry.checkBarIndex)("label.set_x", "x", x, id.xloc);
115
118
  id.x = x;
116
119
  id.y = y;
117
120
  return id;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/label/index.ts"],
4
- "sourcesContent": ["/**\n * Label namespace\n * Functions for creating and manipulating label drawing objects.\n *\n * @remarks\n * Labels are primarily used for annotations and marking points on the chart.\n * They have limited computational value compared to lines and boxes, but getters\n * allow retrieving position and text for conditional logic.\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Label, color } from '../types/index.js';\n\ntype LabelXloc = 'bar_index' | 'bar_time';\ntype LabelYloc = 'price' | 'abovebar' | 'belowbar';\ntype LabelStyle = NonNullable<Label['style']>;\n\n/**\n * Creates a new label (PineScript `label.new`), with a chart point or with coordinates:\n *\n * - `label.new(point, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n * - `label.new(x, y, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n *\n * With a chart point, x is `point.index` for `bar_index` labels and `point.time` for `bar_time` labels.\n *\n * @example\n * ```typescript\n * const signal = label.new(10, 105.5, 'BUY');\n * const atPoint = label.new(chartPoint.from_index(10, 105.5), 'BUY');\n * ```\n */\nexport function new_label(\n point: ChartPoint,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(\n x: number,\n y: number,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(...args: unknown[]): Label {\n let x: number, y: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const point = args[0] as ChartPoint;\n rest = args.slice(1);\n x = pointX(point, (rest[1] as LabelXloc | undefined) ?? 'bar_index');\n y = point.price;\n } else {\n [x, y] = args as [number, number];\n rest = args.slice(2);\n }\n const [text, xloc, yloc, labelColor, style, textcolor, size, textalign, tooltip, text_font_family,\n force_overlay, text_formatting] = rest as [\n string?, LabelXloc?, LabelYloc?, color?, LabelStyle?, color?, (string | number)?,\n ('left' | 'center' | 'right')?, string?, ('default' | 'monospace')?, boolean?, number?,\n ];\n return register('label', {\n x,\n y,\n xloc: xloc ?? 'bar_index',\n yloc: yloc ?? 'price',\n // PineScript: a label without text has the text \"\" (label.get_text gives \"\")\n text: text ?? '',\n tooltip,\n color: labelColor,\n style,\n textcolor,\n size,\n textalign,\n text_font_family,\n force_overlay: force_overlay ?? false,\n text_formatting,\n });\n}\n\n/**\n * Returns the x coordinate.\n *\n * @param id - Label object\n * @returns X coordinate (bar index or timestamp)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const x = label.get_x(label); // Returns 50\n * ```\n */\nexport function get_x(id: Label): number {\n return id.x;\n}\n\n/**\n * Returns the y coordinate (price level).\n *\n * @param id - Label object\n * @returns Y coordinate (price)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const y = label.get_y(label); // Returns 155.5\n * ```\n */\nexport function get_y(id: Label): number {\n return id.y;\n}\n\n/**\n * Returns the label text content.\n *\n * @param id - Label object\n * @returns Text content (or undefined if no text)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot High');\n * const text = label.get_text(label); // Returns 'Pivot High'\n * ```\n */\nexport function get_text(id: Label): string | undefined {\n return id.text;\n}\n\n/**\n * Creates a copy of the label object.\n *\n * @param id - Label object to copy\n * @returns New label object with same properties\n *\n * @remarks\n * Creates a shallow copy of the label. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const original = label.new(50, 155.5, 'Pivot');\n * const copied = label.copy(original);\n *\n * // Modify copy without affecting original\n * copied.text = 'New Text';\n * ```\n */\nexport function copy(id: Label): Label {\n return register('label', { ...id });\n}\n\n// =============================================================================\n// POSITION SETTERS\n// =============================================================================\n\n/**\n * Sets the x coordinate.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_x(label, 55); // Move to bar 55\n * ```\n */\nexport function set_x(id: Label, x: number): Label {\n if (isDeleted(id)) return id;\n id.x = x;\n return id;\n}\n\n/**\n * Sets the y coordinate (price level).\n *\n * @param id - Label object to modify\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_y(label, 160); // Move to price 160\n * ```\n */\nexport function set_y(id: Label, y: number): Label {\n if (isDeleted(id)) return id;\n id.y = y;\n return id;\n}\n\n/**\n * Sets both x and y coordinates.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xy(label, 60, 160); // Move to (60, 160)\n * ```\n */\nexport function set_xy(id: Label, x: number, y: number): Label {\n if (isDeleted(id)) return id;\n id.x = x;\n id.y = y;\n return id;\n}\n\n/**\n * Sets the x-axis coordinate system.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param xloc - New coordinate system\n * @returns Modified label object\n *\n * @remarks\n * When changing xloc, you must provide an appropriate x coordinate for the new system.\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xloc(label, 1609459200000, 'bar_time'); // Change to timestamp\n * ```\n */\nexport function set_xloc(id: Label, x: number, xloc: 'bar_index' | 'bar_time'): Label {\n if (isDeleted(id)) return id;\n id.x = x;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the y-location mode of the label (PineScript `label.set_yloc(id, yloc)`): `price` uses the\n * label's y, `abovebar` / `belowbar` place it above / below the bar.\n */\nexport function set_yloc(id: Label, yloc: 'price' | 'abovebar' | 'belowbar'): Label {\n if (isDeleted(id)) return id;\n id.yloc = yloc;\n return id;\n}\n\n// =============================================================================\n// CONTENT SETTERS\n// =============================================================================\n\n/**\n * Sets the text content.\n *\n * @param id - Label object to modify\n * @param text - New text content\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text(label, 'Updated Text');\n * ```\n */\nexport function set_text(id: Label, text: string): Label {\n if (isDeleted(id)) return id;\n id.text = text;\n return id;\n}\n\n/**\n * Sets the tooltip text.\n *\n * @param id - Label object to modify\n * @param tooltip - New tooltip text\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_tooltip(label, 'Resistance level formed at 155.5');\n * ```\n */\nexport function set_tooltip(id: Label, tooltip: string): Label {\n if (isDeleted(id)) return id;\n id.tooltip = tooltip;\n return id;\n}\n\n// =============================================================================\n// STYLING SETTERS\n// =============================================================================\n\n/**\n * Sets the label color (border and arrow).\n *\n * @param id - Label object to modify\n * @param labelColor - New color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_color(label, '#FF0000'); // Red label\n * ```\n */\nexport function set_color(id: Label, labelColor: color): Label {\n if (isDeleted(id)) return id;\n id.color = labelColor;\n return id;\n}\n\n/**\n * Sets the text color.\n *\n * @param id - Label object to modify\n * @param textColor - New text color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textcolor(label, '#FFFFFF'); // White text\n * ```\n */\nexport function set_textcolor(id: Label, textColor: color): Label {\n if (isDeleted(id)) return id;\n id.textcolor = textColor;\n return id;\n}\n\n/**\n * Sets the label style.\n *\n * @param id - Label object to modify\n * @param style - New label style\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_style(label, 'label_down'); // Arrow pointing down\n * ```\n */\nexport function set_style(\n id: Label,\n style: 'none' | 'xcross' | 'cross' | 'triangleup' | 'triangledown' | 'flag' | 'circle' |\n 'arrowup' | 'arrowdown' | 'label_up' | 'label_down' | 'label_left' | 'label_right' |\n 'label_lower_left' | 'label_lower_right' | 'label_upper_left' | 'label_upper_right' |\n 'label_center' | 'square' | 'diamond' | 'text_outline'\n): Label {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the label size.\n *\n * @param id - Label object to modify\n * @param size - New size\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_size(label, 'large'); // Larger label\n * ```\n */\nexport function set_size(id: Label, size: string | number): Label {\n if (isDeleted(id)) return id;\n id.size = size;\n return id;\n}\n\n/**\n * Sets the text alignment.\n *\n * @param id - Label object to modify\n * @param align - New text alignment\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textalign(label, 'center'); // Center-aligned text\n * ```\n */\nexport function set_textalign(id: Label, align: 'left' | 'center' | 'right'): Label {\n if (isDeleted(id)) return id;\n id.textalign = align;\n return id;\n}\n\n/**\n * Sets the text font family.\n *\n * @param id - Label object to modify\n * @param font - New font family\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text_font_family(label, 'monospace');\n * ```\n */\nexport function set_text_font_family(id: Label, font: 'default' | 'monospace'): Label {\n if (isDeleted(id)) return id;\n id.text_font_family = font;\n return id;\n}\n\n/**\n * Deletes the label object.\n *\n * @param id - Label object to delete\n *\n * @remarks\n * Removes the label from `label.all()`. As in PineScript, the deleted label is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.delete(label);\n * // label.all() no longer contains it\n * ```\n */\nexport function delete_label(id: Label): void {\n remove('label', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live labels, in creation order (PineScript `label.all`). A new array.\n */\nexport function all(): Label[] {\n return allDrawings('label');\n}\n\n/**\n * Sets the label position from a chart point: `point.index` for `bar_index` labels, `point.time`\n * for `bar_time` labels, and `point.price`.\n */\nexport function set_point(id: Label, point: ChartPoint): Label {\n if (isDeleted(id)) return id;\n id.x = pointX(point, id.xloc);\n id.y = point.price;\n return id;\n}\n\n/**\n * Sets the text formatting: `text.format_none`, `text.format_bold`, `text.format_italic`,\n * or `text.format_bold + text.format_italic`.\n */\nexport function set_text_formatting(id: Label, formatting: number): Label {\n if (isDeleted(id)) return id;\n id.text_formatting = formatting;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_label as new };\nexport { delete_label as delete };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAgE;AAsDzD,SAAS,aAAa,MAAwB;AACnD,MAAI,GAAW,GAAW;AAC1B,MAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,UAAM,QAAQ,KAAK,CAAC;AACpB,WAAO,KAAK,MAAM,CAAC;AACnB,QAAI,OAAO,OAAQ,KAAK,CAAC,KAA+B,WAAW;AACnE,QAAI,MAAM;AAAA,EACZ,OAAO;AACL,KAAC,GAAG,CAAC,IAAI;AACT,WAAO,KAAK,MAAM,CAAC;AA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AMO,SAAS,oBAAoB,IAAW,YAA2B;AACxE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,kBAAkB;AACrB,SAAO;AACT;",
4
+ "sourcesContent": ["/**\n * Label namespace\n * Functions for creating and manipulating label drawing objects.\n *\n * @remarks\n * Labels are primarily used for annotations and marking points on the chart.\n * They have limited computational value compared to lines and boxes, but getters\n * allow retrieving position and text for conditional logic.\n *\n * @version 6\n */\n\nimport { all as allDrawings, checkBarIndex, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Label, color } from '../types/index.js';\n\ntype LabelXloc = 'bar_index' | 'bar_time';\ntype LabelYloc = 'price' | 'abovebar' | 'belowbar';\ntype LabelStyle = NonNullable<Label['style']>;\n\n/**\n * Creates a new label (PineScript `label.new`), with a chart point or with coordinates:\n *\n * - `label.new(point, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n * - `label.new(x, y, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?,\n * text_font_family?, force_overlay?, text_formatting?)`\n *\n * With a chart point, x is `point.index` for `bar_index` labels and `point.time` for `bar_time` labels.\n *\n * @example\n * ```typescript\n * const signal = label.new(10, 105.5, 'BUY');\n * const atPoint = label.new(chartPoint.from_index(10, 105.5), 'BUY');\n * ```\n */\nexport function new_label(\n point: ChartPoint,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(\n x: number,\n y: number,\n text?: string,\n xloc?: LabelXloc,\n yloc?: LabelYloc,\n labelColor?: color,\n style?: LabelStyle,\n textcolor?: color,\n size?: string | number,\n textalign?: 'left' | 'center' | 'right',\n tooltip?: string,\n text_font_family?: 'default' | 'monospace',\n force_overlay?: boolean,\n text_formatting?: number\n): Label;\nexport function new_label(...args: unknown[]): Label {\n let x: number, y: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const point = args[0] as ChartPoint;\n rest = args.slice(1);\n x = pointX(point, (rest[1] as LabelXloc | undefined) ?? 'bar_index');\n y = point.price;\n } else {\n [x, y] = args as [number, number];\n rest = args.slice(2);\n }\n const [text, xloc, yloc, labelColor, style, textcolor, size, textalign, tooltip, text_font_family,\n force_overlay, text_formatting] = rest as [\n string?, LabelXloc?, LabelYloc?, color?, LabelStyle?, color?, (string | number)?,\n ('left' | 'center' | 'right')?, string?, ('default' | 'monospace')?, boolean?, number?,\n ];\n checkBarIndex('label.new', 'x', x, xloc);\n return register('label', {\n x,\n y,\n xloc: xloc ?? 'bar_index',\n yloc: yloc ?? 'price',\n // PineScript: a label without text has the text \"\" (label.get_text gives \"\")\n text: text ?? '',\n tooltip,\n color: labelColor,\n style,\n textcolor,\n size,\n textalign,\n text_font_family,\n force_overlay: force_overlay ?? false,\n text_formatting,\n });\n}\n\n/**\n * Returns the x coordinate.\n *\n * @param id - Label object\n * @returns X coordinate (bar index or timestamp)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const x = label.get_x(label); // Returns 50\n * ```\n */\nexport function get_x(id: Label): number {\n return id.x;\n}\n\n/**\n * Returns the y coordinate (price level).\n *\n * @param id - Label object\n * @returns Y coordinate (price)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * const y = label.get_y(label); // Returns 155.5\n * ```\n */\nexport function get_y(id: Label): number {\n return id.y;\n}\n\n/**\n * Returns the label text content.\n *\n * @param id - Label object\n * @returns Text content (or undefined if no text)\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot High');\n * const text = label.get_text(label); // Returns 'Pivot High'\n * ```\n */\nexport function get_text(id: Label): string | undefined {\n return id.text;\n}\n\n/**\n * Creates a copy of the label object.\n *\n * @param id - Label object to copy\n * @returns New label object with same properties\n *\n * @remarks\n * Creates a shallow copy of the label. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const original = label.new(50, 155.5, 'Pivot');\n * const copied = label.copy(original);\n *\n * // Modify copy without affecting original\n * copied.text = 'New Text';\n * ```\n */\nexport function copy(id: Label): Label {\n return register('label', { ...id });\n}\n\n// =============================================================================\n// POSITION SETTERS\n// =============================================================================\n\n/**\n * Sets the x coordinate.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_x(label, 55); // Move to bar 55\n * ```\n */\nexport function set_x(id: Label, x: number): Label {\n if (isDeleted(id)) return id;\n checkBarIndex('label.set_x', 'x', x, id.xloc);\n id.x = x;\n return id;\n}\n\n/**\n * Sets the y coordinate (price level).\n *\n * @param id - Label object to modify\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_y(label, 160); // Move to price 160\n * ```\n */\nexport function set_y(id: Label, y: number): Label {\n if (isDeleted(id)) return id;\n id.y = y;\n return id;\n}\n\n/**\n * Sets both x and y coordinates.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xy(label, 60, 160); // Move to (60, 160)\n * ```\n */\nexport function set_xy(id: Label, x: number, y: number): Label {\n if (isDeleted(id)) return id;\n checkBarIndex('label.set_x', 'x', x, id.xloc);\n id.x = x;\n id.y = y;\n return id;\n}\n\n/**\n * Sets the x-axis coordinate system.\n *\n * @param id - Label object to modify\n * @param x - New x coordinate\n * @param xloc - New coordinate system\n * @returns Modified label object\n *\n * @remarks\n * When changing xloc, you must provide an appropriate x coordinate for the new system.\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_xloc(label, 1609459200000, 'bar_time'); // Change to timestamp\n * ```\n */\nexport function set_xloc(id: Label, x: number, xloc: 'bar_index' | 'bar_time'): Label {\n if (isDeleted(id)) return id;\n id.x = x;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the y-location mode of the label (PineScript `label.set_yloc(id, yloc)`): `price` uses the\n * label's y, `abovebar` / `belowbar` place it above / below the bar.\n */\nexport function set_yloc(id: Label, yloc: 'price' | 'abovebar' | 'belowbar'): Label {\n if (isDeleted(id)) return id;\n id.yloc = yloc;\n return id;\n}\n\n// =============================================================================\n// CONTENT SETTERS\n// =============================================================================\n\n/**\n * Sets the text content.\n *\n * @param id - Label object to modify\n * @param text - New text content\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text(label, 'Updated Text');\n * ```\n */\nexport function set_text(id: Label, text: string): Label {\n if (isDeleted(id)) return id;\n id.text = text;\n return id;\n}\n\n/**\n * Sets the tooltip text.\n *\n * @param id - Label object to modify\n * @param tooltip - New tooltip text\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_tooltip(label, 'Resistance level formed at 155.5');\n * ```\n */\nexport function set_tooltip(id: Label, tooltip: string): Label {\n if (isDeleted(id)) return id;\n id.tooltip = tooltip;\n return id;\n}\n\n// =============================================================================\n// STYLING SETTERS\n// =============================================================================\n\n/**\n * Sets the label color (border and arrow).\n *\n * @param id - Label object to modify\n * @param labelColor - New color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_color(label, '#FF0000'); // Red label\n * ```\n */\nexport function set_color(id: Label, labelColor: color): Label {\n if (isDeleted(id)) return id;\n id.color = labelColor;\n return id;\n}\n\n/**\n * Sets the text color.\n *\n * @param id - Label object to modify\n * @param textColor - New text color\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textcolor(label, '#FFFFFF'); // White text\n * ```\n */\nexport function set_textcolor(id: Label, textColor: color): Label {\n if (isDeleted(id)) return id;\n id.textcolor = textColor;\n return id;\n}\n\n/**\n * Sets the label style.\n *\n * @param id - Label object to modify\n * @param style - New label style\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_style(label, 'label_down'); // Arrow pointing down\n * ```\n */\nexport function set_style(\n id: Label,\n style: 'none' | 'xcross' | 'cross' | 'triangleup' | 'triangledown' | 'flag' | 'circle' |\n 'arrowup' | 'arrowdown' | 'label_up' | 'label_down' | 'label_left' | 'label_right' |\n 'label_lower_left' | 'label_lower_right' | 'label_upper_left' | 'label_upper_right' |\n 'label_center' | 'square' | 'diamond' | 'text_outline'\n): Label {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the label size.\n *\n * @param id - Label object to modify\n * @param size - New size\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_size(label, 'large'); // Larger label\n * ```\n */\nexport function set_size(id: Label, size: string | number): Label {\n if (isDeleted(id)) return id;\n id.size = size;\n return id;\n}\n\n/**\n * Sets the text alignment.\n *\n * @param id - Label object to modify\n * @param align - New text alignment\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_textalign(label, 'center'); // Center-aligned text\n * ```\n */\nexport function set_textalign(id: Label, align: 'left' | 'center' | 'right'): Label {\n if (isDeleted(id)) return id;\n id.textalign = align;\n return id;\n}\n\n/**\n * Sets the text font family.\n *\n * @param id - Label object to modify\n * @param font - New font family\n * @returns Modified label object\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.set_text_font_family(label, 'monospace');\n * ```\n */\nexport function set_text_font_family(id: Label, font: 'default' | 'monospace'): Label {\n if (isDeleted(id)) return id;\n id.text_font_family = font;\n return id;\n}\n\n/**\n * Deletes the label object.\n *\n * @param id - Label object to delete\n *\n * @remarks\n * Removes the label from `label.all()`. As in PineScript, the deleted label is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect.\n *\n * @example\n * ```typescript\n * const label = label.new(50, 155.5, 'Pivot');\n * label.delete(label);\n * // label.all() no longer contains it\n * ```\n */\nexport function delete_label(id: Label): void {\n remove('label', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live labels, in creation order (PineScript `label.all`). A new array.\n */\nexport function all(): Label[] {\n return allDrawings('label');\n}\n\n/**\n * Sets the label position from a chart point: `point.index` for `bar_index` labels, `point.time`\n * for `bar_time` labels, and `point.price`.\n */\nexport function set_point(id: Label, point: ChartPoint): Label {\n if (isDeleted(id)) return id;\n id.x = pointX(point, id.xloc);\n id.y = point.price;\n return id;\n}\n\n/**\n * Sets the text formatting: `text.format_none`, `text.format_bold`, `text.format_italic`,\n * or `text.format_bold + text.format_italic`.\n */\nexport function set_text_formatting(id: Label, formatting: number): Label {\n if (isDeleted(id)) return id;\n id.text_formatting = formatting;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_label as new };\nexport { delete_label as delete };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAA+E;AAsDxE,SAAS,aAAa,MAAwB;AACnD,MAAI,GAAW,GAAW;AAC1B,MAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,UAAM,QAAQ,KAAK,CAAC;AACpB,WAAO,KAAK,MAAM,CAAC;AACnB,Q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...args) {
56
56
  rest = args.slice(4);
57
57
  }
58
58
  const [xloc, extend, lineColor, style, width, force_overlay] = rest;
59
+ (0, import_registry.checkBarIndex)("line.new", "x1", x1, xloc);
60
+ (0, import_registry.checkBarIndex)("line.new", "x2", x2, xloc);
59
61
  return (0, import_registry.register)("line", {
60
62
  x1,
61
63
  y1,
@@ -65,7 +67,7 @@ function new_line(...args) {
65
67
  extend: extend ?? "none",
66
68
  color: lineColor,
67
69
  style: style || "solid",
68
- width: width || 1,
70
+ width: width ?? 1,
69
71
  force_overlay: force_overlay ?? false
70
72
  });
71
73
  }
@@ -111,11 +113,13 @@ function copy(id) {
111
113
  }
112
114
  function set_x1(id, x) {
113
115
  if ((0, import_registry.isDeleted)(id)) return id;
116
+ (0, import_registry.checkBarIndex)("line.set_x***", "x1", x, id.xloc);
114
117
  id.x1 = x;
115
118
  return id;
116
119
  }
117
120
  function set_x2(id, x) {
118
121
  if ((0, import_registry.isDeleted)(id)) return id;
122
+ (0, import_registry.checkBarIndex)("line.set_x***", "x2", x, id.xloc);
119
123
  id.x2 = x;
120
124
  return id;
121
125
  }
@@ -131,12 +135,14 @@ function set_y2(id, y) {
131
135
  }
132
136
  function set_xy1(id, x, y) {
133
137
  if ((0, import_registry.isDeleted)(id)) return id;
138
+ (0, import_registry.checkBarIndex)("line.set_x***", "x1", x, id.xloc);
134
139
  id.x1 = x;
135
140
  id.y1 = y;
136
141
  return id;
137
142
  }
138
143
  function set_xy2(id, x, y) {
139
144
  if ((0, import_registry.isDeleted)(id)) return id;
145
+ (0, import_registry.checkBarIndex)("line.set_x***", "x2", x, id.xloc);
140
146
  id.x2 = x;
141
147
  id.y2 = y;
142
148
  return id;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/line/index.ts"],
4
- "sourcesContent": ["/**\n * Line namespace\n * Functions for creating and manipulating line drawing objects.\n *\n * @remarks\n * While lines are primarily visual in PineScript, the line.get_price() function provides\n * computational value for algorithmic trading - calculating trend line breakouts,\n * support/resistance levels, and pattern recognition.\n *\n * @version 6\n */\n\nimport { all as allDrawings, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Line, color } from '../types/index.js';\n\ntype LineXloc = 'bar_index' | 'bar_time';\ntype LineExtend = 'none' | 'left' | 'right' | 'both';\ntype LineStyle = 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';\n\n/**\n * Creates a new line (PineScript `line.new`), with two chart points or with coordinates:\n *\n * - `line.new(first_point, second_point, xloc?, extend?, color?, style?, width?, force_overlay?)`\n * - `line.new(x1, y1, x2, y2, xloc?, extend?, color?, style?, width?, force_overlay?)`\n *\n * With chart points, x is `point.index` for `bar_index` lines and `point.time` for `bar_time` lines.\n *\n * @example\n * ```typescript\n * // Create a trend line from bar 0 (price 100) to bar 50 (price 150)\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n * const fromPoints = line.new(chartPoint.from_index(0, 100), chartPoint.from_index(50, 150));\n *\n * // Calculate price at bar 75 (extrapolated)\n * const price = line.get_price(trendLine, 75); // Returns 175\n * ```\n */\nexport function new_line(\n first_point: ChartPoint,\n second_point: ChartPoint,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(...args: unknown[]): Line {\n let x1: number, y1: number, x2: number, y2: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const [p1, p2, ...others] = args as [ChartPoint, ChartPoint, ...unknown[]];\n const xloc = (others[0] as LineXloc | undefined) ?? 'bar_index';\n [x1, y1, x2, y2, rest] = [pointX(p1, xloc), p1.price, pointX(p2, xloc), p2.price, others];\n } else {\n [x1, y1, x2, y2] = args as [number, number, number, number];\n rest = args.slice(4);\n }\n const [xloc, extend, lineColor, style, width, force_overlay] = rest as [\n LineXloc?, LineExtend?, color?, LineStyle?, number?, boolean?,\n ];\n return register('line', {\n x1,\n y1,\n x2,\n y2,\n xloc: xloc ?? 'bar_index',\n extend: extend ?? 'none',\n color: lineColor,\n style: style || 'solid',\n width: width || 1,\n force_overlay: force_overlay ?? false,\n });\n}\n\n/**\n * Returns the price level of a line at a given bar index.\n *\n * @param id - Line object\n * @param x - Bar index to calculate price at\n * @returns Price level at the given bar index, or NaN if outside bounds and not extended\n *\n * @remarks\n * - **CRITICAL COMPUTATIONAL FUNCTION** - Enables trend line breakout detection\n * - Uses linear interpolation: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n * - Respects extend mode:\n * - 'none': Returns NaN if x is outside [x1, x2]\n * - 'left': Extends infinitely to the left (x < x1)\n * - 'right': Extends infinitely to the right (x > x2)\n * - 'both': Extends infinitely in both directions\n * - Only works with xloc='bar_index' lines (not xloc='bar_time')\n * - In PineScript, this function treats all lines as if extend='both' regardless of actual setting\n * For compatibility, we follow the actual extend setting\n *\n * @example\n * ```typescript\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n *\n * // Within segment\n * line.get_price(trendLine, 25); // Returns 125\n *\n * // Extended right\n * line.get_price(trendLine, 100); // Returns 200\n *\n * // Not extended left (with extend='right')\n * line.get_price(trendLine, -10); // Returns NaN\n *\n * // Use for breakout detection\n * const currentPrice = close[close.length - 1];\n * const linePrice = line.get_price(trendLine, close.length - 1);\n * if (currentPrice > linePrice) {\n * console.log('Breakout above trend line!');\n * }\n * ```\n */\nexport function get_price(id: Line, x: number): number {\n const { x1, y1, x2, y2, extend, xloc } = id;\n\n // Only works with bar_index xloc\n if (xloc === 'bar_time') {\n throw new Error('line.get_price() only works with xloc.bar_index lines, not xloc.bar_time');\n }\n\n // Avoid division by zero\n if (x2 === x1) {\n // Vertical line - return NaN or could return y1/y2\n return NaN;\n }\n\n // Linear interpolation formula: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n const slope = (y2 - y1) / (x2 - x1);\n const price = y1 + slope * (x - x1);\n\n // Check bounds based on extend mode\n if (extend === 'none') {\n // Only valid within the segment\n if (x < Math.min(x1, x2) || x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'left') {\n // Valid to the left and within, but not to the right\n if (x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'right') {\n // Valid to the right and within, but not to the left\n if (x < Math.min(x1, x2)) {\n return NaN;\n }\n }\n // extend === 'both': always valid\n\n return price;\n}\n\n/**\n * Returns the first point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x1 = line.get_x1(line); // Returns 10\n * ```\n */\nexport function get_x1(id: Line): number {\n return id.x1;\n}\n\n/**\n * Returns the second point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x2 = line.get_x2(line); // Returns 50\n * ```\n */\nexport function get_x2(id: Line): number {\n return id.x2;\n}\n\n/**\n * Returns the first point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y1 = line.get_y1(line); // Returns 100\n * ```\n */\nexport function get_y1(id: Line): number {\n return id.y1;\n}\n\n/**\n * Returns the second point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y2 = line.get_y2(line); // Returns 150\n * ```\n */\nexport function get_y2(id: Line): number {\n return id.y2;\n}\n\n/**\n * Creates a copy of the line object.\n *\n * @param id - Line object to copy\n * @returns New line object with same properties\n *\n * @remarks\n * Creates a shallow copy of the line. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const originalLine = line.new(0, 100, 50, 150);\n * const copiedLine = line.copy(originalLine);\n *\n * // Modify copy without affecting original\n * copiedLine.y2 = 200;\n * ```\n */\nexport function copy(id: Line): Line {\n return register('line', { ...id });\n}\n\n/**\n * Sets the first point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x1(line, 10); // Move first point to bar 10\n * ```\n */\nexport function set_x1(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n id.x1 = x;\n return id;\n}\n\n/**\n * Sets the second point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x2(line, 60); // Move second point to bar 60\n * ```\n */\nexport function set_x2(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n id.x2 = x;\n return id;\n}\n\n/**\n * Sets the first point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y1(line, 110); // Move first point to price 110\n * ```\n */\nexport function set_y1(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets the second point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y2(line, 160); // Move second point to price 160\n * ```\n */\nexport function set_y2(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the first point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy1(line, 5, 105); // Move first point to (5, 105)\n * ```\n */\nexport function set_xy1(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n id.x1 = x;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the second point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy2(line, 60, 160); // Move second point to (60, 160)\n * ```\n */\nexport function set_xy2(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n id.x2 = x;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets the coordinate system for the line.\n *\n * @param id - Line object to modify\n * @param x1 - New first point x coordinate\n * @param x2 - New second point x coordinate\n * @param xloc - New coordinate system ('bar_index' or 'bar_time')\n * @returns Modified line object\n *\n * @remarks\n * When changing xloc, you must provide appropriate x coordinates for the new system.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * // Change to timestamp-based coordinates\n * line.set_xloc(line, 1609459200000, 1609545600000, 'bar_time');\n * ```\n */\nexport function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time'): Line {\n if (isDeleted(id)) return id;\n id.x1 = x1;\n id.x2 = x2;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the extension mode of the line.\n *\n * @param id - Line object to modify\n * @param extend - New extension mode\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_extend(line, 'right'); // Extend line to the right\n * ```\n */\nexport function set_extend(id: Line, extend: 'none' | 'left' | 'right' | 'both'): Line {\n if (isDeleted(id)) return id;\n id.extend = extend;\n return id;\n}\n\n/**\n * Sets the line color.\n *\n * @param id - Line object to modify\n * @param color - New line color\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_color(line, '#FF0000'); // Change to red\n * ```\n */\nexport function set_color(id: Line, lineColor: color): Line {\n if (isDeleted(id)) return id;\n id.color = lineColor;\n return id;\n}\n\n/**\n * Sets the line style.\n *\n * @param id - Line object to modify\n * @param style - New line style\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_style(line, 'dashed'); // Change to dashed line\n * ```\n */\nexport function set_style(id: Line, style: 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both'): Line {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the line width.\n *\n * @param id - Line object to modify\n * @param width - New line width in pixels\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_width(line, 3); // Make line thicker\n * ```\n */\nexport function set_width(id: Line, width: number): Line {\n if (isDeleted(id)) return id;\n id.width = width;\n return id;\n}\n\n/**\n * Deletes the line object.\n *\n * @param id - Line object to delete\n *\n * @remarks\n * Removes the line from `line.all()`. As in PineScript, the deleted line is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect. Deleting a line also deletes the linefills that use it.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.delete(line);\n * // line.all() no longer contains it\n * ```\n */\nexport function delete_line(id: Line): void {\n remove('line', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live lines, in creation order (PineScript `line.all`). A new array: later changes do not affect it.\n */\nexport function all(): Line[] {\n return allDrawings('line');\n}\n\n/**\n * Sets the first point of the line from a chart point: `point.index` for `bar_index` lines,\n * `point.time` for `bar_time` lines (`na` when the point does not have it), and `point.price`.\n */\nexport function set_first_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x1 = pointX(point, id.xloc);\n id.y1 = point.price;\n return id;\n}\n\n/**\n * Sets the second point of the line from a chart point (see {@link set_first_point}).\n */\nexport function set_second_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x2 = pointX(point, id.xloc);\n id.y2 = point.price;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_line as new };\nexport { delete_line as delete };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAAgE;AA+CzD,SAAS,YAAY,MAAuB;AACjD,MAAI,IAAY,IAAY,IAAY,IAAY;AACpD,MAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,UAAM,CAAC,IAAI,IAAI,GAAG,MAAM,IAAI;AAC5B,UAAMA,QAAQ,OAAO,CAAC,KAA8B;AACpD,KAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,MAAM;AAAA,EAC1F,OAAO;AACL,KAAC,IAAI,IAAI,IAAI,EAAE,IAAI;AACnB,WAAO,KAAK,MAAM,CAAC;AAAA,EACrB;AACA,QAAM,CAAC,MAAM,QAAQ,WAAW,OAAO,OAAO,aAAa,IAAI;AAG/D,aAAO,0BAAS,QAAQ;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,MAAM,QAAQ;AAAA,IACd,QAAQ,UAAU;AAAA,IAClB,OAAO;AAAA,IACP,OAAO,SAAS;AAAA,IAChB,OAAO,SAAS;AAAA,IAChB,eAAe,iBAAiB;AAAA,EAClC,CAAC;AACH;AA0CO,SAAS,UAAU,IAAU,GAAmB;AACrD,QAAM,EAAE,IAAI,IAAI,IAAI,IAAI,QAAQ,KAAK,IAAI;AAGzC,MAA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AAiB,IAAU,OAAyB;AAClE,UAAI,2BAAU,EAAE,EAAG,QAAO;AAC1B,KAAG,KAAK,OAAO,OAAO,GAAG,IAAI;AAC7B,KAAG,KAAK,MAAM;AACd,SAAO;AACT;",
4
+ "sourcesContent": ["/**\n * Line namespace\n * Functions for creating and manipulating line drawing objects.\n *\n * @remarks\n * While lines are primarily visual in PineScript, the line.get_price() function provides\n * computational value for algorithmic trading - calculating trend line breakouts,\n * support/resistance levels, and pattern recognition.\n *\n * @version 6\n */\n\nimport { all as allDrawings, checkBarIndex, isDeleted, register, remove } from '../drawing/registry.js';\nimport type { ChartPoint, Line, color } from '../types/index.js';\n\ntype LineXloc = 'bar_index' | 'bar_time';\ntype LineExtend = 'none' | 'left' | 'right' | 'both';\ntype LineStyle = 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both';\n\n/**\n * Creates a new line (PineScript `line.new`), with two chart points or with coordinates:\n *\n * - `line.new(first_point, second_point, xloc?, extend?, color?, style?, width?, force_overlay?)`\n * - `line.new(x1, y1, x2, y2, xloc?, extend?, color?, style?, width?, force_overlay?)`\n *\n * With chart points, x is `point.index` for `bar_index` lines and `point.time` for `bar_time` lines.\n *\n * @example\n * ```typescript\n * // Create a trend line from bar 0 (price 100) to bar 50 (price 150)\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n * const fromPoints = line.new(chartPoint.from_index(0, 100), chartPoint.from_index(50, 150));\n *\n * // Calculate price at bar 75 (extrapolated)\n * const price = line.get_price(trendLine, 75); // Returns 175\n * ```\n */\nexport function new_line(\n first_point: ChartPoint,\n second_point: ChartPoint,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(\n x1: number,\n y1: number,\n x2: number,\n y2: number,\n xloc?: LineXloc,\n extend?: LineExtend,\n lineColor?: color,\n style?: LineStyle,\n width?: number,\n force_overlay?: boolean\n): Line;\nexport function new_line(...args: unknown[]): Line {\n let x1: number, y1: number, x2: number, y2: number, rest: unknown[];\n if (typeof args[0] === 'object' && args[0] !== null) {\n const [p1, p2, ...others] = args as [ChartPoint, ChartPoint, ...unknown[]];\n const xloc = (others[0] as LineXloc | undefined) ?? 'bar_index';\n [x1, y1, x2, y2, rest] = [pointX(p1, xloc), p1.price, pointX(p2, xloc), p2.price, others];\n } else {\n [x1, y1, x2, y2] = args as [number, number, number, number];\n rest = args.slice(4);\n }\n const [xloc, extend, lineColor, style, width, force_overlay] = rest as [\n LineXloc?, LineExtend?, color?, LineStyle?, number?, boolean?,\n ];\n checkBarIndex('line.new', 'x1', x1, xloc);\n checkBarIndex('line.new', 'x2', x2, xloc);\n return register('line', {\n x1,\n y1,\n x2,\n y2,\n xloc: xloc ?? 'bar_index',\n extend: extend ?? 'none',\n color: lineColor,\n style: style || 'solid',\n width: width ?? 1,\n force_overlay: force_overlay ?? false,\n });\n}\n\n/**\n * Returns the price level of a line at a given bar index.\n *\n * @param id - Line object\n * @param x - Bar index to calculate price at\n * @returns Price level at the given bar index, or NaN if outside bounds and not extended\n *\n * @remarks\n * - **CRITICAL COMPUTATIONAL FUNCTION** - Enables trend line breakout detection\n * - Uses linear interpolation: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n * - Respects extend mode:\n * - 'none': Returns NaN if x is outside [x1, x2]\n * - 'left': Extends infinitely to the left (x < x1)\n * - 'right': Extends infinitely to the right (x > x2)\n * - 'both': Extends infinitely in both directions\n * - Only works with xloc='bar_index' lines (not xloc='bar_time')\n * - In PineScript, this function treats all lines as if extend='both' regardless of actual setting\n * For compatibility, we follow the actual extend setting\n *\n * @example\n * ```typescript\n * const trendLine = line.new(0, 100, 50, 150, 'bar_index', 'right');\n *\n * // Within segment\n * line.get_price(trendLine, 25); // Returns 125\n *\n * // Extended right\n * line.get_price(trendLine, 100); // Returns 200\n *\n * // Not extended left (with extend='right')\n * line.get_price(trendLine, -10); // Returns NaN\n *\n * // Use for breakout detection\n * const currentPrice = close[close.length - 1];\n * const linePrice = line.get_price(trendLine, close.length - 1);\n * if (currentPrice > linePrice) {\n * console.log('Breakout above trend line!');\n * }\n * ```\n */\nexport function get_price(id: Line, x: number): number {\n const { x1, y1, x2, y2, extend, xloc } = id;\n\n // Only works with bar_index xloc\n if (xloc === 'bar_time') {\n throw new Error('line.get_price() only works with xloc.bar_index lines, not xloc.bar_time');\n }\n\n // Avoid division by zero\n if (x2 === x1) {\n // Vertical line - return NaN or could return y1/y2\n return NaN;\n }\n\n // Linear interpolation formula: y = y1 + (y2 - y1) * (x - x1) / (x2 - x1)\n const slope = (y2 - y1) / (x2 - x1);\n const price = y1 + slope * (x - x1);\n\n // Check bounds based on extend mode\n if (extend === 'none') {\n // Only valid within the segment\n if (x < Math.min(x1, x2) || x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'left') {\n // Valid to the left and within, but not to the right\n if (x > Math.max(x1, x2)) {\n return NaN;\n }\n } else if (extend === 'right') {\n // Valid to the right and within, but not to the left\n if (x < Math.min(x1, x2)) {\n return NaN;\n }\n }\n // extend === 'both': always valid\n\n return price;\n}\n\n/**\n * Returns the first point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x1 = line.get_x1(line); // Returns 10\n * ```\n */\nexport function get_x1(id: Line): number {\n return id.x1;\n}\n\n/**\n * Returns the second point's x coordinate.\n *\n * @param id - Line object\n * @returns X coordinate of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const x2 = line.get_x2(line); // Returns 50\n * ```\n */\nexport function get_x2(id: Line): number {\n return id.x2;\n}\n\n/**\n * Returns the first point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the first point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y1 = line.get_y1(line); // Returns 100\n * ```\n */\nexport function get_y1(id: Line): number {\n return id.y1;\n}\n\n/**\n * Returns the second point's y coordinate (price level).\n *\n * @param id - Line object\n * @returns Y coordinate (price) of the second point\n *\n * @example\n * ```typescript\n * const line = line.new(10, 100, 50, 150);\n * const y2 = line.get_y2(line); // Returns 150\n * ```\n */\nexport function get_y2(id: Line): number {\n return id.y2;\n}\n\n/**\n * Creates a copy of the line object.\n *\n * @param id - Line object to copy\n * @returns New line object with same properties\n *\n * @remarks\n * Creates a shallow copy of the line. Modifications to the copy won't affect the original.\n *\n * @example\n * ```typescript\n * const originalLine = line.new(0, 100, 50, 150);\n * const copiedLine = line.copy(originalLine);\n *\n * // Modify copy without affecting original\n * copiedLine.y2 = 200;\n * ```\n */\nexport function copy(id: Line): Line {\n return register('line', { ...id });\n}\n\n/**\n * Sets the first point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x1(line, 10); // Move first point to bar 10\n * ```\n */\nexport function set_x1(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n checkBarIndex('line.set_x***', 'x1', x, id.xloc);\n id.x1 = x;\n return id;\n}\n\n/**\n * Sets the second point's x coordinate.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate (bar index or timestamp)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_x2(line, 60); // Move second point to bar 60\n * ```\n */\nexport function set_x2(id: Line, x: number): Line {\n if (isDeleted(id)) return id;\n checkBarIndex('line.set_x***', 'x2', x, id.xloc);\n id.x2 = x;\n return id;\n}\n\n/**\n * Sets the first point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y1(line, 110); // Move first point to price 110\n * ```\n */\nexport function set_y1(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets the second point's y coordinate (price level).\n *\n * @param id - Line object to modify\n * @param y - New y coordinate (price)\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_y2(line, 160); // Move second point to price 160\n * ```\n */\nexport function set_y2(id: Line, y: number): Line {\n if (isDeleted(id)) return id;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the first point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy1(line, 5, 105); // Move first point to (5, 105)\n * ```\n */\nexport function set_xy1(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n checkBarIndex('line.set_x***', 'x1', x, id.xloc);\n id.x1 = x;\n id.y1 = y;\n return id;\n}\n\n/**\n * Sets both coordinates of the second point.\n *\n * @param id - Line object to modify\n * @param x - New x coordinate\n * @param y - New y coordinate\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_xy2(line, 60, 160); // Move second point to (60, 160)\n * ```\n */\nexport function set_xy2(id: Line, x: number, y: number): Line {\n if (isDeleted(id)) return id;\n checkBarIndex('line.set_x***', 'x2', x, id.xloc);\n id.x2 = x;\n id.y2 = y;\n return id;\n}\n\n/**\n * Sets the coordinate system for the line.\n *\n * @param id - Line object to modify\n * @param x1 - New first point x coordinate\n * @param x2 - New second point x coordinate\n * @param xloc - New coordinate system ('bar_index' or 'bar_time')\n * @returns Modified line object\n *\n * @remarks\n * When changing xloc, you must provide appropriate x coordinates for the new system.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * // Change to timestamp-based coordinates\n * line.set_xloc(line, 1609459200000, 1609545600000, 'bar_time');\n * ```\n */\nexport function set_xloc(id: Line, x1: number, x2: number, xloc: 'bar_index' | 'bar_time'): Line {\n if (isDeleted(id)) return id;\n id.x1 = x1;\n id.x2 = x2;\n id.xloc = xloc;\n return id;\n}\n\n/**\n * Sets the extension mode of the line.\n *\n * @param id - Line object to modify\n * @param extend - New extension mode\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_extend(line, 'right'); // Extend line to the right\n * ```\n */\nexport function set_extend(id: Line, extend: 'none' | 'left' | 'right' | 'both'): Line {\n if (isDeleted(id)) return id;\n id.extend = extend;\n return id;\n}\n\n/**\n * Sets the line color.\n *\n * @param id - Line object to modify\n * @param color - New line color\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_color(line, '#FF0000'); // Change to red\n * ```\n */\nexport function set_color(id: Line, lineColor: color): Line {\n if (isDeleted(id)) return id;\n id.color = lineColor;\n return id;\n}\n\n/**\n * Sets the line style.\n *\n * @param id - Line object to modify\n * @param style - New line style\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_style(line, 'dashed'); // Change to dashed line\n * ```\n */\nexport function set_style(id: Line, style: 'solid' | 'dotted' | 'dashed' | 'arrow_left' | 'arrow_right' | 'arrow_both'): Line {\n if (isDeleted(id)) return id;\n id.style = style;\n return id;\n}\n\n/**\n * Sets the line width.\n *\n * @param id - Line object to modify\n * @param width - New line width in pixels\n * @returns Modified line object\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.set_width(line, 3); // Make line thicker\n * ```\n */\nexport function set_width(id: Line, width: number): Line {\n if (isDeleted(id)) return id;\n id.width = width;\n return id;\n}\n\n/**\n * Deletes the line object.\n *\n * @param id - Line object to delete\n *\n * @remarks\n * Removes the line from `line.all()`. As in PineScript, the deleted line is `na`: its getters\n * return NaN and its setters do nothing. Deleting it twice has no effect. Deleting a line also deletes the linefills that use it.\n *\n * @example\n * ```typescript\n * const line = line.new(0, 100, 50, 150);\n * line.delete(line);\n * // line.all() no longer contains it\n * ```\n */\nexport function delete_line(id: Line): void {\n remove('line', id);\n}\n\n/** x coordinate of a chart point for an object's xloc (`na` when the point has no such coordinate). */\nfunction pointX(point: ChartPoint, xloc: 'bar_index' | 'bar_time'): number {\n const x = xloc === 'bar_time' ? point.time : point.index;\n return x ?? NaN;\n}\n\n/**\n * All live lines, in creation order (PineScript `line.all`). A new array: later changes do not affect it.\n */\nexport function all(): Line[] {\n return allDrawings('line');\n}\n\n/**\n * Sets the first point of the line from a chart point: `point.index` for `bar_index` lines,\n * `point.time` for `bar_time` lines (`na` when the point does not have it), and `point.price`.\n */\nexport function set_first_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x1 = pointX(point, id.xloc);\n id.y1 = point.price;\n return id;\n}\n\n/**\n * Sets the second point of the line from a chart point (see {@link set_first_point}).\n */\nexport function set_second_point(id: Line, point: ChartPoint): Line {\n if (isDeleted(id)) return id;\n id.x2 = pointX(point, id.xloc);\n id.y2 = point.price;\n return id;\n}\n\n// Alias to match PineScript API\nexport { new_line as new };\nexport { delete_line as delete };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA,sBAA+E;AA+CxE,SAAS,YAAY,MAAuB;AACjD,MAAI,IAAY,IAAY,IAAY,IAAY;AACpD,MAAI,OAAO,KAAK,CAAC,MAAM,YAAY,KAAK,CAAC,MAAM,MAAM;AACnD,UAAM,CAAC,IAAI,IAAI,GAAG,MAAM,IAAI;AAC5B,UAAMA,QAAQ,OAAO,CAAC,KAA8B;AACpD,KAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,OAAO,IAAIA,KAAI,GAAG,GAAG,OAAO,MAAM;AAAA,EAC1F,OAAO;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"}
@@ -53,6 +53,7 @@ __export(math_exports, {
53
53
  module.exports = __toCommonJS(math_exports);
54
54
  var import_series = require("../runtime/series.js");
55
55
  var import_running_sum = require("../ta/running-sum.js");
56
+ var import_limits = require("../ta/limits.js");
56
57
  function abs(value) {
57
58
  if (value instanceof import_series.Series) {
58
59
  const bars = value.bars;
@@ -247,6 +248,7 @@ function avgOf(nums) {
247
248
  }
248
249
  function sum(source, length) {
249
250
  const sourceArray = source instanceof import_series.Series ? source.toArray() : source;
251
+ if (typeof length === "number") (0, import_limits.checkSumLength)("math.sum", length, 0);
250
252
  const result = typeof length === "number" ? (0, import_running_sum.runningSum)(sourceArray, length) : (0, import_running_sum.runningSumSeries)(sourceArray, length instanceof import_series.Series ? length.toArray() : length, "math.sum");
251
253
  if (source instanceof import_series.Series) {
252
254
  return import_series.Series.fromArray(source.bars, result);