oakscriptjs 0.15.1 → 0.15.3
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.
- package/dist/cjs/callsite/index.d.ts.map +1 -1
- package/dist/cjs/callsite/index.js +61 -7
- package/dist/cjs/callsite/index.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +31 -3
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +188 -68
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/linefill/index.d.ts.map +1 -1
- package/dist/cjs/linefill/index.js +14 -5
- package/dist/cjs/linefill/index.js.map +2 -2
- package/dist/cjs/session/bars.d.ts +3 -0
- package/dist/cjs/session/bars.d.ts.map +1 -1
- package/dist/cjs/session/bars.js +10 -3
- package/dist/cjs/session/bars.js.map +2 -2
- package/dist/cjs/session/calendar.d.ts +19 -6
- package/dist/cjs/session/calendar.d.ts.map +1 -1
- package/dist/cjs/session/calendar.js +57 -18
- package/dist/cjs/session/calendar.js.map +2 -2
- package/dist/cjs/session/context.d.ts.map +1 -1
- package/dist/cjs/session/context.js +25 -8
- package/dist/cjs/session/context.js.map +2 -2
- package/dist/cjs/str/floatingdecimal.d.ts +3 -0
- package/dist/cjs/str/floatingdecimal.d.ts.map +1 -1
- package/dist/cjs/str/floatingdecimal.js +25 -12
- package/dist/cjs/str/floatingdecimal.js.map +2 -2
- package/dist/cjs/str/messageformat.d.ts.map +1 -1
- package/dist/cjs/str/messageformat.js +27 -8
- package/dist/cjs/str/messageformat.js.map +2 -2
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +9 -16
- package/dist/cjs/str/numberformat.js.map +3 -3
- package/dist/cjs/ta/index.d.ts.map +1 -1
- package/dist/cjs/ta/index.js +27 -0
- package/dist/cjs/ta/index.js.map +2 -2
- package/dist/cjs/ta/running-sum.d.ts +8 -1
- package/dist/cjs/ta/running-sum.d.ts.map +1 -1
- package/dist/cjs/ta/running-sum.js +13 -1
- package/dist/cjs/ta/running-sum.js.map +2 -2
- package/dist/cjs/time/timezone.d.ts +13 -1
- package/dist/cjs/time/timezone.d.ts.map +1 -1
- package/dist/cjs/time/timezone.js +64 -12
- package/dist/cjs/time/timezone.js.map +2 -2
- package/dist/esm/callsite/index.d.ts.map +1 -1
- package/dist/esm/callsite/index.js +76 -7
- package/dist/esm/callsite/index.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +31 -3
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +237 -80
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/linefill/index.d.ts.map +1 -1
- package/dist/esm/linefill/index.js +17 -7
- package/dist/esm/linefill/index.js.map +1 -1
- package/dist/esm/session/bars.d.ts +3 -0
- package/dist/esm/session/bars.d.ts.map +1 -1
- package/dist/esm/session/bars.js +11 -3
- package/dist/esm/session/bars.js.map +1 -1
- package/dist/esm/session/calendar.d.ts +19 -6
- package/dist/esm/session/calendar.d.ts.map +1 -1
- package/dist/esm/session/calendar.js +74 -21
- package/dist/esm/session/calendar.js.map +1 -1
- package/dist/esm/session/context.d.ts.map +1 -1
- package/dist/esm/session/context.js +34 -9
- package/dist/esm/session/context.js.map +1 -1
- package/dist/esm/str/floatingdecimal.d.ts +3 -0
- package/dist/esm/str/floatingdecimal.d.ts.map +1 -1
- package/dist/esm/str/floatingdecimal.js +27 -11
- package/dist/esm/str/floatingdecimal.js.map +1 -1
- package/dist/esm/str/messageformat.d.ts.map +1 -1
- package/dist/esm/str/messageformat.js +35 -9
- package/dist/esm/str/messageformat.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +12 -18
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/ta/index.d.ts.map +1 -1
- package/dist/esm/ta/index.js +35 -0
- package/dist/esm/ta/index.js.map +1 -1
- package/dist/esm/ta/running-sum.d.ts +8 -1
- package/dist/esm/ta/running-sum.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.js +16 -1
- package/dist/esm/ta/running-sum.js.map +1 -1
- package/dist/esm/time/timezone.d.ts +13 -1
- package/dist/esm/time/timezone.d.ts.map +1 -1
- package/dist/esm/time/timezone.js +97 -16
- package/dist/esm/time/timezone.js.map +1 -1
- package/package.json +1 -1
- package/src/callsite/index.ts +65 -7
- package/src/drawing/registry.ts +249 -79
- package/src/index.ts +1 -1
- package/src/linefill/index.ts +16 -7
- package/src/session/bars.ts +11 -3
- package/src/session/calendar.ts +84 -21
- package/src/session/context.ts +36 -9
- package/src/str/floatingdecimal.ts +27 -11
- package/src/str/messageformat.ts +40 -9
- package/src/str/numberformat.ts +13 -17
- package/src/ta/index.ts +41 -0
- package/src/ta/running-sum.ts +13 -1
- package/src/time/timezone.ts +99 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/callsite/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAMhD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,EACnD,MAAM,EAAE,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,EACnC,EAAE,EAAE,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,EAC3C,GAAG,OAAO,EAAE,MAAM,EAAE,GACnB,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CASnB;AAmBD;;;GAGG;AACH,wBAAgB,SAAS,IAAI,CAAC,CAAC,E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G;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,MAAM,CAE3E"}
|
|
@@ -120,9 +120,21 @@ function cross() {
|
|
|
120
120
|
return result;
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
+
const SCANNED_WINDOW = 32;
|
|
123
124
|
class KeptCalls {
|
|
125
|
+
constructor(isLowest) {
|
|
126
|
+
this.isLowest = isLowest;
|
|
127
|
+
}
|
|
128
|
+
isLowest;
|
|
124
129
|
values = [];
|
|
125
130
|
bars = [];
|
|
131
|
+
/**
|
|
132
|
+
* Segment tree of the best position of each range of kept values (node 1 is the root, leaf `leaves + k` is value
|
|
133
|
+
* `k`, -1 for no value), built on the first long window: a call site whose length grows with the bars (the bars
|
|
134
|
+
* since a session start) would otherwise scan the whole history on every call.
|
|
135
|
+
*/
|
|
136
|
+
tree = null;
|
|
137
|
+
leaves = 0;
|
|
126
138
|
/**
|
|
127
139
|
* Keeps a non-na value (+/-Infinity is skipped like na, #183); a later call on the same bar (a loop) replaces the
|
|
128
140
|
* value of that bar.
|
|
@@ -135,27 +147,68 @@ class KeptCalls {
|
|
|
135
147
|
this.values.push(value);
|
|
136
148
|
this.bars.push(barIndex);
|
|
137
149
|
}
|
|
150
|
+
if (this.tree) this.update(this.values.length - 1);
|
|
138
151
|
}
|
|
139
152
|
/** Position of the best of the last `count` kept values (the newest one on ties), -1 when there is none. */
|
|
140
|
-
best(count
|
|
153
|
+
best(count) {
|
|
141
154
|
const last = this.values.length - 1;
|
|
142
155
|
if (last < 0 || !(count >= 1)) return -1;
|
|
156
|
+
if (count > SCANNED_WINDOW) return this.bestOf(Math.max(0, Math.floor(last - count) + 1), last);
|
|
143
157
|
let best = last;
|
|
144
158
|
for (let k = last - 1; k >= 0 && k > last - count; k--) {
|
|
145
|
-
if (isLowest ? this.values[k] < this.values[best] : this.values[k] > this.values[best]) best = k;
|
|
159
|
+
if (this.isLowest ? this.values[k] < this.values[best] : this.values[k] > this.values[best]) best = k;
|
|
146
160
|
}
|
|
147
161
|
return best;
|
|
148
162
|
}
|
|
163
|
+
/** The better of two positions (-1: none): the lower (higher) value, the newest one on equal values. */
|
|
164
|
+
better(a, b) {
|
|
165
|
+
if (a < 0) return b;
|
|
166
|
+
if (b < 0) return a;
|
|
167
|
+
const va = this.values[a];
|
|
168
|
+
const vb = this.values[b];
|
|
169
|
+
if (this.isLowest ? va < vb : va > vb) return a;
|
|
170
|
+
if (this.isLowest ? vb < va : vb > va) return b;
|
|
171
|
+
return a > b ? a : b;
|
|
172
|
+
}
|
|
173
|
+
/** Best position of the kept values `first` to `last`, from the tree. */
|
|
174
|
+
bestOf(first, last) {
|
|
175
|
+
if (!this.tree) this.build();
|
|
176
|
+
const tree = this.tree;
|
|
177
|
+
let best = -1;
|
|
178
|
+
for (let l = first + this.leaves, r = last + this.leaves + 1; l < r; l >>= 1, r >>= 1) {
|
|
179
|
+
if (l & 1) best = this.better(best, tree[l++]);
|
|
180
|
+
if (r & 1) best = this.better(best, tree[--r]);
|
|
181
|
+
}
|
|
182
|
+
return best;
|
|
183
|
+
}
|
|
184
|
+
/** (Re)builds the tree, with room for as many values again. */
|
|
185
|
+
build() {
|
|
186
|
+
const n = this.values.length;
|
|
187
|
+
let leaves = 1;
|
|
188
|
+
while (leaves < 2 * n) leaves *= 2;
|
|
189
|
+
const tree = new Int32Array(2 * leaves).fill(-1);
|
|
190
|
+
for (let k = 0; k < n; k++) tree[leaves + k] = k;
|
|
191
|
+
for (let i = leaves - 1; i >= 1; i--) tree[i] = this.better(tree[2 * i], tree[2 * i + 1]);
|
|
192
|
+
this.tree = tree;
|
|
193
|
+
this.leaves = leaves;
|
|
194
|
+
}
|
|
195
|
+
/** Value `k` was added or replaced. */
|
|
196
|
+
update(k) {
|
|
197
|
+
if (k >= this.leaves) return this.build();
|
|
198
|
+
const tree = this.tree;
|
|
199
|
+
tree[this.leaves + k] = k;
|
|
200
|
+
for (let i = this.leaves + k >> 1; i >= 1; i >>= 1) tree[i] = this.better(tree[2 * i], tree[2 * i + 1]);
|
|
201
|
+
}
|
|
149
202
|
}
|
|
150
203
|
function extremeByBarSite(isLowest, offsets) {
|
|
151
|
-
const kept = new KeptCalls();
|
|
204
|
+
const kept = new KeptCalls(isLowest);
|
|
152
205
|
const name = (isLowest ? "lowest" : "highest") + (offsets ? "bars" : "");
|
|
153
206
|
return (barIndex, value, length) => {
|
|
154
207
|
(0, import_limits.checkWindowLength)(name, length, barIndex);
|
|
155
208
|
kept.add(barIndex, value);
|
|
156
209
|
const len = Math.trunc(length);
|
|
157
210
|
if (barIndex < len - 1) return NaN;
|
|
158
|
-
const best = kept.best(len
|
|
211
|
+
const best = kept.best(len);
|
|
159
212
|
if (best < 0) return NaN;
|
|
160
213
|
return offsets ? -(barIndex - kept.bars[best]) : kept.values[best];
|
|
161
214
|
};
|
|
@@ -184,13 +237,13 @@ function highestbars() {
|
|
|
184
237
|
return extremeByBarSite(false, true);
|
|
185
238
|
}
|
|
186
239
|
function pivotSite(isLowest) {
|
|
187
|
-
const kept = new KeptCalls();
|
|
240
|
+
const kept = new KeptCalls(isLowest);
|
|
188
241
|
return (barIndex, value, leftbars, rightbars) => {
|
|
189
242
|
kept.add(barIndex, value);
|
|
190
243
|
const left = Math.trunc(leftbars);
|
|
191
244
|
const right = Math.trunc(rightbars);
|
|
192
245
|
if (!(barIndex >= left + right)) return NaN;
|
|
193
|
-
const best = kept.best(left + right + 1
|
|
246
|
+
const best = kept.best(left + right + 1);
|
|
194
247
|
return best >= 0 && kept.bars[best] === barIndex - right ? kept.values[best] : NaN;
|
|
195
248
|
};
|
|
196
249
|
}
|
|
@@ -214,11 +267,12 @@ function linreg() {
|
|
|
214
267
|
function loopSumSite(name, squares) {
|
|
215
268
|
const running = new import_running_sum.RunningSum();
|
|
216
269
|
const runningSq = new import_running_sum.RunningSum();
|
|
270
|
+
const fn = name === "sum" ? "math.sum" : `ta.${name}`;
|
|
217
271
|
let lastBar = NaN;
|
|
218
272
|
let pending = false;
|
|
219
273
|
return (barIndex, value, length) => {
|
|
220
274
|
const len = Math.floor(length);
|
|
221
|
-
(0, import_limits.checkSumLength)(
|
|
275
|
+
(0, import_limits.checkSumLength)(fn, len, barIndex);
|
|
222
276
|
if (!(len >= 1)) throw new Error(`callsite.${name}: length must be at least 1 (got ${length})`);
|
|
223
277
|
if (barIndex !== lastBar) {
|
|
224
278
|
if (pending) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/callsite/index.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Per-call history of ta.* functions called in a conditional block.\n *\n * In PineScript, every ta.* call keeps its own history of the values it receives. A call inside\n * an `if` block receives values only on the bars where the block runs, so its history skips the\n * other bars: `ta.crossover(a, b)` is false on the first bar the block runs, and `ta.sma(x, 3)`\n * averages the last 3 values it received, not the last 3 bars.\n *\n * - {@link whenCalled}: vectorized, when the bars of the calls are known in advance.\n * - {@link crossover} / {@link crossunder} / {@link cross} / {@link barssince}: one stateful call site for bar\n * loops, called only on the bars where the Pine call runs.\n * - {@link crossoverByBar} / {@link crossunderByBar}: `ta.crossover` / `ta.crossunder` called several times on one\n * bar (a `for` loop over zones): every call compares with the last call of the previous bar.\n * - {@link lowestByBar} / {@link highestByBar} / {@link lowestbars} / {@link highestbars} / {@link pivothigh} /\n * {@link pivotlow}: `ta.lowest` / `ta.highest` / `ta.lowestbars` / `ta.highestbars` / `ta.pivothigh` /\n * `ta.pivotlow` in a conditional block or a loop, also with a length that changes on each call. They keep the\n * non-na values of their calls; {@link lowest} / {@link highest} are the same sites called with `(value, length)`.\n * - {@link linreg}: `ta.linreg` in a conditional block, whose history is kept by bar (not by call).\n * - {@link sum} / {@link sma}: `math.sum` / `ta.sma` in a `for` / `while` loop, called several times on one bar.\n *\n * Since PineScript v6, `and` / `or` are lazy: the right operand runs only when the left operand does not decide\n * the result. A ta.* call in the right operand of `a or b` runs on the bars where `a` is false, in `a and b` on the\n * bars where `a` is true, so it needs a call site too:\n *\n * ```typescript\n * // Pine: longCond = longUp or (src > sig and ta.barssince(longUp) <= lookback)\n * const since = callsite.whenCalled(longUp.map((u, i) => !u && src[i] > sig[i]), (c) => taCore.barssince(c.map(Boolean)), longUp);\n * // ta.barssince(longUp) only runs where longUp is false: it never sees true and stays na\n * ```\n *\n * ```typescript\n * // Pine: if inRange\n * // buy = ta.crossover(cumRsi, 60)\n * const buy = callsite.whenCalled(inRange, (a) => taCore.crossover(a, a.map(() => 60)), cumRsi);\n *\n * // Same call in a bar loop\n * const buyCross = callsite.crossover();\n * for (let i = 0; i < n; i++) {\n * if (inRange[i]) {\n * const buy = buyCross(cumRsi[i], 60);\n * }\n * }\n * ```\n *\n * @module callsite\n */\n\nimport type { Source } from '../types/index.js';\nimport { linreg as linregSeries } from '../ta/index.js';\nimport { RunningSum, isNa } from '../ta/running-sum.js';\nimport { checkSumLength, checkWindowLength } from '../ta/limits.js';\nimport { seededRandom } from '../math/index.js';\n\n/**\n * Runs `fn` on the bars where `called` is true only, like a ta.* call inside an `if` block.\n * `fn` receives the values of `sources` on those bars, in order; its results are placed back on\n * the same bars. The other bars get na (NaN).\n *\n * @param called - true (or non-zero) on the bars where the call runs\n * @param fn - the calculation, for example `(x) => taCore.sma(x, 3)`\n * @param sources - the arguments of the call, one value per chart bar\n */\nexport function whenCalled<T extends number | boolean>(\n called: ArrayLike<boolean | number>,\n fn: (...values: number[][]) => ArrayLike<T>,\n ...sources: Source[]\n): Array<T | number> {\n const bars: number[] = [];\n for (let i = 0; i < called.length; i++) if (called[i]) bars.push(i);\n const result = fn(...sources.map(s => bars.map(i => s[i] ?? NaN)));\n const out = new Array<T | number>(called.length).fill(NaN);\n bars.forEach((bar, k) => {\n out[bar] = result[k]!;\n });\n return out;\n}\n\n/**\n * A call site that keeps the arguments of the last call where both were not na (na before such a call), as\n * ta.crossover / ta.crossunder / ta.cross.\n */\nfunction twoSeriesSite(test: (a: number, b: number, prevA: number, prevB: number) => boolean) {\n let prevA = NaN;\n let prevB = NaN;\n return (a: number, b: number): boolean => {\n const result = test(a, b, prevA, prevB);\n if (!Number.isNaN(a) && !Number.isNaN(b)) {\n prevA = a;\n prevB = b;\n }\n return result;\n };\n}\n\n/**\n * One `ta.crossover(a, b)` call site: compared with the last call where both arguments were not na; false before\n * such a call.\n */\nexport function crossover(): (a: number, b: number) => boolean {\n return twoSeriesSite((a, b, pa, pb) => a > b && pa <= pb);\n}\n\n/**\n * One `ta.crossunder(a, b)` call site: compared with the last call where both arguments were not na; false before\n * such a call.\n */\nexport function crossunder(): (a: number, b: number) => boolean {\n return twoSeriesSite((a, b, pa, pb) => a < b && pa >= pb);\n}\n\n/**\n * A call site called several times on one bar (a `for` loop): every call of a bar compares with the arguments of the\n * last call of an earlier bar where both were not na, as PineScript does for a ta.crossover in a loop.\n */\nfunction twoSeriesByBarSite(test: (a: number, b: number, prevA: number, prevB: number) => boolean) {\n let bar = NaN;\n let prevA = NaN;\n let prevB = NaN;\n let lastA = NaN;\n let lastB = NaN;\n return (barIndex: number, a: number, b: number): boolean => {\n if (barIndex !== bar) {\n // a new bar: the last call of the earlier bar becomes the previous value\n if (!Number.isNaN(lastA)) {\n prevA = lastA;\n prevB = lastB;\n }\n lastA = NaN;\n lastB = NaN;\n bar = barIndex;\n }\n const result = test(a, b, prevA, prevB);\n if (!Number.isNaN(a) && !Number.isNaN(b)) {\n lastA = a;\n lastB = b;\n }\n return result;\n };\n}\n\n/**\n * One `ta.crossover(a, b)` call site in a loop, called several times on one bar: each call compares with the last\n * call of the previous bar (where both arguments were not na); false before such a call.\n *\n * ```typescript\n * // Pine: for z in zones\n * // if ta.crossover(close, z.mid)\n * const reclaim = callsite.crossoverByBar();\n * eachBar((c) => { for (const z of zones) if (reclaim(c.i, c.close, z.mid)) { ... } });\n * ```\n */\nexport function crossoverByBar(): (barIndex: number, a: number, b: number) => boolean {\n return twoSeriesByBarSite((a, b, pa, pb) => a > b && pa <= pb);\n}\n\n/**\n * One `ta.crossunder(a, b)` call site in a loop, called several times on one bar: each call compares with the last\n * call of the previous bar (where both arguments were not na); false before such a call.\n */\nexport function crossunderByBar(): (barIndex: number, a: number, b: number) => boolean {\n return twoSeriesByBarSite((a, b, pa, pb) => a < b && pa >= pb);\n}\n\n/**\n * One `ta.barssince(condition)` call site: the number of calls since the condition was true on a call (0 on that\n * call), na before the first true condition. An na condition counts as false.\n */\nexport function barssince(): (condition: boolean | number) => number {\n let count = NaN;\n return (condition) => {\n if (condition && !Number.isNaN(condition)) count = 0;\n else if (!Number.isNaN(count)) count++;\n return count;\n };\n}\n\n/**\n * One `ta.cross(a, b)` call site, rules of `ta.cross`: the site keeps the side of the last call where `a` was\n * strictly above or strictly below `b` (none before such a call; equal values and na arguments do not change it),\n * and is true when the arguments are strictly on the other side. False with an na argument.\n */\nexport function cross(): (a: number, b: number) => boolean {\n let side = 0; // -1: last strictly below, 1: last strictly above, 0: none yet\n return (a, b) => {\n if (Number.isNaN(a) || Number.isNaN(b)) return false;\n const result = (side < 0 && a > b) || (side > 0 && a < b);\n if (a < b) side = -1;\n else if (a > b) side = 1;\n return result;\n };\n}\n\n/** The values a ta.highest / ta.lowest / ta.pivothigh call site keeps: the non-na values of its calls, one per bar. */\nclass KeptCalls {\n readonly values: number[] = [];\n readonly bars: number[] = [];\n\n /**\n * Keeps a non-na value (+/-Infinity is skipped like na, #183); a later call on the same bar (a loop) replaces the\n * value of that bar.\n */\n add(barIndex: number, value: number): void {\n if (!Number.isFinite(value)) return;\n const last = this.values.length - 1;\n if (last >= 0 && this.bars[last] === barIndex) this.values[last] = value;\n else {\n this.values.push(value);\n this.bars.push(barIndex);\n }\n }\n\n /** Position of the best of the last `count` kept values (the newest one on ties), -1 when there is none. */\n best(count: number, isLowest: boolean): number {\n const last = this.values.length - 1;\n if (last < 0 || !(count >= 1)) return -1;\n let best = last;\n for (let k = last - 1; k >= 0 && k > last - count; k--) {\n if (isLowest ? this.values[k]! < this.values[best]! : this.values[k]! > this.values[best]!) best = k;\n }\n return best;\n }\n}\n\n/** One `ta.lowest` / `ta.highest` / `ta.lowestbars` / `ta.highestbars` call site; rules in {@link lowestByBar}. */\nfunction extremeByBarSite(\n isLowest: boolean,\n offsets: boolean\n): (barIndex: number, value: number, length: number) => number {\n const kept = new KeptCalls();\n const name = (isLowest ? 'lowest' : 'highest') + (offsets ? 'bars' : '');\n return (barIndex, value, length) => {\n checkWindowLength(name, length, barIndex);\n kept.add(barIndex, value);\n const len = Math.trunc(length);\n if (barIndex < len - 1) return NaN;\n const best = kept.best(len, isLowest);\n if (best < 0) return NaN;\n return offsets ? -(barIndex - kept.bars[best]!) : kept.values[best]!;\n };\n}\n\n/** {@link extremeByBarSite} called with `(value, length, barIndex?)`: without a bar index, every call is a new bar. */\nfunction extremeSite(isLowest: boolean): (value: number, length: number, barIndex?: number) => number {\n const site = extremeByBarSite(isLowest, false);\n let calls = 0;\n return (value, length, barIndex) => site(barIndex ?? calls++, value, length);\n}\n\n/**\n * One `ta.lowest(source, length)` call site, called with `(value, length, barIndex?)`: the same site as\n * {@link lowestByBar} (same rules). Pass the bar index when the call does not run on every bar; without it every\n * call counts as one bar, which is right for a call on every bar (for example with a length that changes).\n *\n * @example\n * ```typescript\n * // Pine: lowPrice = ta.lowest(close[1], lookback) // lookback changes per bar\n * const lowPrice = callsite.lowest();\n * const out = closes.map((_, i) => lowPrice(i > 0 ? closes[i - 1]! : NaN, lookback[i]!));\n * ```\n */\nexport function lowest(): (value: number, length: number, barIndex?: number) => number {\n return extremeSite(true);\n}\n\n/**\n * One `ta.highest(source, length)` call site, called with `(value, length, barIndex?)`. Same rules as\n * {@link lowest}.\n */\nexport function highest(): (value: number, length: number, barIndex?: number) => number {\n return extremeSite(false);\n}\n\n/**\n * One `ta.lowest(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)` on the bars (and loop turns) where the Pine call runs. The length can change from one\n * call to the next.\n *\n * PineScript rules (measured in `if` blocks, ternaries, user functions and `for` loops, with constant lengths and\n * lengths that change, on sources with and without na):\n * - the call site keeps the non-na values it received, each with its bar; nothing is kept for a bar without a call\n * or for an na value\n * - the result is na while `barIndex < length - 1` (by bar, not by call) and while no value was received\n * - otherwise it is the lowest of the last `length` kept values, or of all of them when there are fewer: the first\n * call after bar `length - 1` gives its own value. A call with an na value also gives this result\n * - in a loop (several calls on one bar), a bar has one kept value: each call replaces the value of the earlier\n * calls of that bar, so a call gives the lowest of its value and the values of the bars before\n *\n * Called on every bar, it equals `ta.lowest`.\n *\n * @example\n * ```typescript\n * // Pine: lo = cond ? ta.lowest(low, 6) : na\n * const site = callsite.lowestByBar();\n * const lo = lows.map((v, i) => (cond[i] ? site(i, v, 6) : NaN));\n * ```\n */\nexport function lowestByBar(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(true, false);\n}\n\n/**\n * One `ta.highest(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)`. Same rules as {@link lowestByBar}.\n */\nexport function highestByBar(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(false, false);\n}\n\n/**\n * One `ta.lowestbars(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)`: the offset (0 or negative) from this bar to the bar of the lowest of the last `length`\n * kept values, the newest one on equal values. The values are kept as in {@link lowestByBar}; the offset counts\n * bars, not calls, so it can be below `-(length - 1)`.\n *\n * @example\n * ```typescript\n * // Pine: off = cond ? ta.lowestbars(low, 10) : na\n * const site = callsite.lowestbars();\n * const off = lows.map((v, i) => (cond[i] ? site(i, v, 10) : NaN));\n * ```\n */\nexport function lowestbars(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(true, true);\n}\n\n/**\n * One `ta.highestbars(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)`. Same rules as {@link lowestbars}.\n */\nexport function highestbars(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(false, true);\n}\n\n/** One `ta.pivothigh` / `ta.pivotlow` call site; rules in {@link pivothigh}. */\nfunction pivotSite(isLowest: boolean): (barIndex: number, value: number, leftbars: number, rightbars: number) => number {\n const kept = new KeptCalls();\n return (barIndex, value, leftbars, rightbars) => {\n kept.add(barIndex, value);\n const left = Math.trunc(leftbars);\n const right = Math.trunc(rightbars);\n if (!(barIndex >= left + right)) return NaN;\n const best = kept.best(left + right + 1, isLowest);\n return best >= 0 && kept.bars[best] === barIndex - right ? kept.values[best]! : NaN;\n };\n}\n\n/**\n * One `ta.pivothigh(source, leftbars, rightbars)` call site in a conditional block, called with\n * `(barIndex, value, leftbars, rightbars)` on the bars where the Pine call runs. The lengths can change from one call\n * to the next (the lengths of the current call are used).\n *\n * PineScript rules (measured in `if` blocks and ternaries, and on sources with na):\n * - the call site keeps the non-na values it received, each with its bar\n * - on a call it takes the last `leftbars + rightbars + 1` kept values (all of them when there are fewer) and finds\n * the highest, the newest one on equal values\n * - there is a pivot only when that value is on the bar `rightbars` BARS back (by bar index, not by call); the\n * result is its value, na otherwise and before bar `leftbars + rightbars`\n *\n * Called on every bar, it equals `ta.pivothigh`.\n *\n * @example\n * ```typescript\n * // Pine: ph = useFilter ? ta.pivothigh(src, 5, 5) : na\n * const site = callsite.pivothigh();\n * const ph = src.map((v, i) => (useFilter[i] ? site(i, v, 5, 5) : NaN));\n * ```\n */\nexport function pivothigh(): (barIndex: number, value: number, leftbars: number, rightbars: number) => number {\n return pivotSite(false);\n}\n\n/**\n * One `ta.pivotlow(source, leftbars, rightbars)` call site in a conditional block, called with\n * `(barIndex, value, leftbars, rightbars)`. Same rules as {@link pivothigh} (the lowest value).\n */\nexport function pivotlow(): (barIndex: number, value: number, leftbars: number, rightbars: number) => number {\n return pivotSite(true);\n}\n\n/**\n * One `ta.linreg(source, length, offset)` call site in a conditional block, called with\n * `(barIndex, value, length, offset)` on the bars where the Pine call runs.\n *\n * PineScript rules (measured): `ta.linreg` keeps the values it receives in a ring of `length + 1` slots indexed by the\n * bar index, filled with 0 at the start and written only on the bars where it is called. The window is read from the\n * ring for the last `length` bars: a bar before the first call counts as 0, and a bar without a call holds the value of\n * the call `length + 1` bars earlier (0 if there was none). The result is na before bar `length - 1`. Called on every\n * bar, it equals `ta.linreg`.\n *\n * @example\n * ```typescript\n * // Pine: if bar_index >= 20\n * // a := ta.linreg(close, 10, 0)\n * const site = callsite.linreg();\n * const a = closes.map((c, i) => (i >= 20 ? site(i, c, 10, 0) : NaN));\n * ```\n */\nexport function linreg(): (barIndex: number, value: number, length: number, offset?: number) => number {\n let ring: number[] = [];\n return (barIndex, value, length, offset = 0) => {\n const len = Math.floor(length);\n if (ring.length !== len + 1) ring = new Array<number>(len + 1).fill(0);\n ring[barIndex % (len + 1)] = value;\n if (barIndex < len - 1) return NaN;\n const window = Array.from({ length: len }, (_, k) => ring[(barIndex - len + 1 + k) % (len + 1)]!);\n return linregSeries(window, len, offset)[len - 1]!;\n };\n}\n\n\n/**\n * One `math.sum` call site in a loop; rules in {@link sum}. With `squares`, it also keeps the running sum of the\n * squared values (for {@link stdev}). Returns `[sum, sumOfSquares]` (NaN when not kept).\n */\nfunction loopSumSite(\n name: string,\n squares: boolean\n): (barIndex: number, value: number, length: number) => [number, number] {\n const running = new RunningSum();\n const runningSq = new RunningSum();\n let lastBar = NaN;\n let pending = false;\n return (barIndex, value, length) => {\n const len = Math.floor(length);\n checkSumLength(name === 'sum' ? 'math.sum' : `ta.${name}`, len, barIndex);\n if (!(len >= 1)) throw new Error(`callsite.${name}: length must be at least 1 (got ${length})`);\n if (barIndex !== lastBar) {\n if (pending) {\n running.commit();\n if (squares) runningSq.commit();\n }\n pending = false;\n lastBar = barIndex;\n }\n if (isNa(value)) {\n pending = false;\n return [running.stepNa(len), squares ? runningSq.stepNa(len) : NaN];\n }\n const x = value;\n const out: [number, number] = [running.step(x, len), squares ? runningSq.step(x * x, len) : NaN];\n pending = true;\n return out;\n };\n}\n\n/**\n * One `math.sum(source, length)` call site inside a `for` / `while` loop, called with `(barIndex, value, length)` on\n * each call.\n *\n * PineScript rules (measured on calls in loops, 1 to 3 calls per bar, and bars without a call):\n * - the call site keeps one history value per bar: the value of its last call on that bar\n * - every call on a bar starts from the state of the earlier bars, so it gives the sum of its value and the last\n * `length - 1` kept values; the last call of the bar is the one kept for the later bars\n * - the length can change from one call to the next (also on the same bar): each call first moves the kept sum to\n * its own length, as `math.sum` with a series length\n * - a bar without a call is not in the history (as a call in an `if` block)\n * - the sum is the correctly rounded window sum, as `math.sum` (bit for bit, #188)\n *\n * An na value is skipped as in `math.sum` (it returns the sum of the last `length` earlier values); when it is the\n * last call of a bar, the bar is not in the history (not measured).\n *\n * @example\n * ```typescript\n * // Pine: for i = 0 to 2\n * // s = math.sum(close * (1 + 0.01 * i), 7)\n * const site = callsite.sum();\n * for (let b = 0; b < closes.length; b++) {\n * for (let i = 0; i <= 2; i++) {\n * const s = site(b, closes[b]! * (1 + 0.01 * i), 7);\n * }\n * }\n * ```\n */\nexport function sum(): (barIndex: number, value: number, length: number) => number {\n const site = loopSumSite('sum', false);\n return (barIndex, value, length) => site(barIndex, value, length)[0];\n}\n\n/**\n * One `ta.sma(source, length)` call site inside a `for` / `while` loop, called with `(barIndex, value, length)` on\n * each call: {@link sum} divided by the length (same rules).\n *\n * @example\n * ```typescript\n * // Pine: evaluate(ratio) => ta.sma(gann(ratio), n) // called once per ratio in a while loop\n * const site = callsite.sma();\n * for (let b = 0; b < closes.length; b++) {\n * for (const ratio of ratios) {\n * const avg = site(b, gann(b, ratio), n);\n * }\n * }\n * ```\n */\nexport function sma(): (barIndex: number, value: number, length: number) => number {\n const site = loopSumSite('sma', false);\n return (barIndex, value, length) => site(barIndex, value, length)[0] / Math.floor(length);\n}\n\n/**\n * One `ta.stdev(source, length, biased)` call site inside a `for` / `while` loop, called with\n * `(barIndex, value, length, biased?)` on each call: the window sums of the values and of their squares follow the\n * rules of {@link sum}; the result is computed from them as `ta.stdev` (bit for bit).\n *\n * @example\n * ```typescript\n * // Pine: for len in lengths\n * // [mid, up, lo] = ta.bb(close, len, 2)\n * const avgSite = callsite.sma();\n * const devSite = callsite.stdev();\n * for (let b = 0; b < closes.length; b++) {\n * for (const len of lengths) {\n * const mid = avgSite(b, closes[b]!, len);\n * const dev = devSite(b, closes[b]!, len);\n * }\n * }\n * ```\n */\nexport function stdev(): (barIndex: number, value: number, length: number, biased?: boolean) => number {\n const site = loopSumSite('stdev', true);\n return (barIndex, value, length, biased = true) => {\n const len = Math.floor(length);\n const [s, sq] = site(barIndex, value, length);\n const mean = s / len;\n const variance = biased ? sq / len - mean * mean : sq / (len - 1) - (mean * s) / (len - 1);\n if (!biased && len <= 1) return NaN;\n return Number.isNaN(variance) ? NaN : variance > 0 ? Math.sqrt(variance) : 0;\n };\n}\n\n/**\n * One `math.random(min, max, seed)` call site: PineScript keeps one generator per call site, so two call sites\n * with the same seed give the same sequence. Called with `(min?, max?)` once per bar.\n *\n * @example\n * ```typescript\n * // Pine: a = math.random(0, 1, 42), b = math.random(0, 1, 42) // a == b on every bar\n * const a = callsite.random(42);\n * const b = callsite.random(42);\n * ```\n */\nexport function random(seed: number): (min?: number, max?: number) => number {\n return seededRandom(seed);\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;AAgDA,gBAAuC;AACvC,yBAAiC;AACjC,oBAAkD;AAClD,kBAA6B;AAWtB,SAAS,WACd,QACA,OACG,SACgB;AACnB,QAAM,OAAiB,CAAC;AACxB,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,IAAK,KAAI,OAAO,CAAC,EAAG,MAAK,KAAK,CAAC;AAClE,QAAM,SAAS,GAAG,GAAG,QAAQ,IAAI,OAAK,KAAK,IAAI,OAAK,EAAE,CAAC,KAAK,GAAG,CAAC,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AAM,EAAE;AAC/D;AAMO,SAAS,kBAAuE;AACrF,SAAO,mBAAmB,CAAC,GAAG,GAAG,IAAI,OAAO,IAAI,KAAK,MAAM,EAAE;AAC/D;AAMO,SAAS,YAAqD;AACnE,MAAI,QAAQ;AACZ,SAAO,CAAC,cAAc;AACpB,QAAI,aAAa,CAAC,OAAO,MAAM,SAAS,EAAG,SAAQ;AAAA,aAC1C,CAAC,OAAO,MAAM,KAAK,EAAG;AAC/B,WAAO;AAAA,EACT;AACF;AAOO,SAAS,QAA2C;AACzD,MAAI,OAAO;AACX,SAAO,CAAC,GAAG,MAAM;AACf,QAAI,OAAO,MAAM,CAAC,KAAK,OAAO,MAAM,CAAC,EAAG,QAAO;AAC/C,UAAM,SAAU,OAAO,KAAK,IAAI,KAAO,OAAO,KAAK,IAAI;AACvD,QAAI,IAAI,EAAG,QAAO;AAAA,aACT,IAAI,EAAG,QAAO;AACvB,WAAO;AAAA,EACT;AACF;AAGA,MAAM,UAAU;AAAA,
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Per-call history of ta.* functions called in a conditional block.\n *\n * In PineScript, every ta.* call keeps its own history of the values it receives. A call inside\n * an `if` block receives values only on the bars where the block runs, so its history skips the\n * other bars: `ta.crossover(a, b)` is false on the first bar the block runs, and `ta.sma(x, 3)`\n * averages the last 3 values it received, not the last 3 bars.\n *\n * - {@link whenCalled}: vectorized, when the bars of the calls are known in advance.\n * - {@link crossover} / {@link crossunder} / {@link cross} / {@link barssince}: one stateful call site for bar\n * loops, called only on the bars where the Pine call runs.\n * - {@link crossoverByBar} / {@link crossunderByBar}: `ta.crossover` / `ta.crossunder` called several times on one\n * bar (a `for` loop over zones): every call compares with the last call of the previous bar.\n * - {@link lowestByBar} / {@link highestByBar} / {@link lowestbars} / {@link highestbars} / {@link pivothigh} /\n * {@link pivotlow}: `ta.lowest` / `ta.highest` / `ta.lowestbars` / `ta.highestbars` / `ta.pivothigh` /\n * `ta.pivotlow` in a conditional block or a loop, also with a length that changes on each call. They keep the\n * non-na values of their calls; {@link lowest} / {@link highest} are the same sites called with `(value, length)`.\n * - {@link linreg}: `ta.linreg` in a conditional block, whose history is kept by bar (not by call).\n * - {@link sum} / {@link sma}: `math.sum` / `ta.sma` in a `for` / `while` loop, called several times on one bar.\n *\n * Since PineScript v6, `and` / `or` are lazy: the right operand runs only when the left operand does not decide\n * the result. A ta.* call in the right operand of `a or b` runs on the bars where `a` is false, in `a and b` on the\n * bars where `a` is true, so it needs a call site too:\n *\n * ```typescript\n * // Pine: longCond = longUp or (src > sig and ta.barssince(longUp) <= lookback)\n * const since = callsite.whenCalled(longUp.map((u, i) => !u && src[i] > sig[i]), (c) => taCore.barssince(c.map(Boolean)), longUp);\n * // ta.barssince(longUp) only runs where longUp is false: it never sees true and stays na\n * ```\n *\n * ```typescript\n * // Pine: if inRange\n * // buy = ta.crossover(cumRsi, 60)\n * const buy = callsite.whenCalled(inRange, (a) => taCore.crossover(a, a.map(() => 60)), cumRsi);\n *\n * // Same call in a bar loop\n * const buyCross = callsite.crossover();\n * for (let i = 0; i < n; i++) {\n * if (inRange[i]) {\n * const buy = buyCross(cumRsi[i], 60);\n * }\n * }\n * ```\n *\n * @module callsite\n */\n\nimport type { Source } from '../types/index.js';\nimport { linreg as linregSeries } from '../ta/index.js';\nimport { RunningSum, isNa } from '../ta/running-sum.js';\nimport { checkSumLength, checkWindowLength } from '../ta/limits.js';\nimport { seededRandom } from '../math/index.js';\n\n/**\n * Runs `fn` on the bars where `called` is true only, like a ta.* call inside an `if` block.\n * `fn` receives the values of `sources` on those bars, in order; its results are placed back on\n * the same bars. The other bars get na (NaN).\n *\n * @param called - true (or non-zero) on the bars where the call runs\n * @param fn - the calculation, for example `(x) => taCore.sma(x, 3)`\n * @param sources - the arguments of the call, one value per chart bar\n */\nexport function whenCalled<T extends number | boolean>(\n called: ArrayLike<boolean | number>,\n fn: (...values: number[][]) => ArrayLike<T>,\n ...sources: Source[]\n): Array<T | number> {\n const bars: number[] = [];\n for (let i = 0; i < called.length; i++) if (called[i]) bars.push(i);\n const result = fn(...sources.map(s => bars.map(i => s[i] ?? NaN)));\n const out = new Array<T | number>(called.length).fill(NaN);\n bars.forEach((bar, k) => {\n out[bar] = result[k]!;\n });\n return out;\n}\n\n/**\n * A call site that keeps the arguments of the last call where both were not na (na before such a call), as\n * ta.crossover / ta.crossunder / ta.cross.\n */\nfunction twoSeriesSite(test: (a: number, b: number, prevA: number, prevB: number) => boolean) {\n let prevA = NaN;\n let prevB = NaN;\n return (a: number, b: number): boolean => {\n const result = test(a, b, prevA, prevB);\n if (!Number.isNaN(a) && !Number.isNaN(b)) {\n prevA = a;\n prevB = b;\n }\n return result;\n };\n}\n\n/**\n * One `ta.crossover(a, b)` call site: compared with the last call where both arguments were not na; false before\n * such a call.\n */\nexport function crossover(): (a: number, b: number) => boolean {\n return twoSeriesSite((a, b, pa, pb) => a > b && pa <= pb);\n}\n\n/**\n * One `ta.crossunder(a, b)` call site: compared with the last call where both arguments were not na; false before\n * such a call.\n */\nexport function crossunder(): (a: number, b: number) => boolean {\n return twoSeriesSite((a, b, pa, pb) => a < b && pa >= pb);\n}\n\n/**\n * A call site called several times on one bar (a `for` loop): every call of a bar compares with the arguments of the\n * last call of an earlier bar where both were not na, as PineScript does for a ta.crossover in a loop.\n */\nfunction twoSeriesByBarSite(test: (a: number, b: number, prevA: number, prevB: number) => boolean) {\n let bar = NaN;\n let prevA = NaN;\n let prevB = NaN;\n let lastA = NaN;\n let lastB = NaN;\n return (barIndex: number, a: number, b: number): boolean => {\n if (barIndex !== bar) {\n // a new bar: the last call of the earlier bar becomes the previous value\n if (!Number.isNaN(lastA)) {\n prevA = lastA;\n prevB = lastB;\n }\n lastA = NaN;\n lastB = NaN;\n bar = barIndex;\n }\n const result = test(a, b, prevA, prevB);\n if (!Number.isNaN(a) && !Number.isNaN(b)) {\n lastA = a;\n lastB = b;\n }\n return result;\n };\n}\n\n/**\n * One `ta.crossover(a, b)` call site in a loop, called several times on one bar: each call compares with the last\n * call of the previous bar (where both arguments were not na); false before such a call.\n *\n * ```typescript\n * // Pine: for z in zones\n * // if ta.crossover(close, z.mid)\n * const reclaim = callsite.crossoverByBar();\n * eachBar((c) => { for (const z of zones) if (reclaim(c.i, c.close, z.mid)) { ... } });\n * ```\n */\nexport function crossoverByBar(): (barIndex: number, a: number, b: number) => boolean {\n return twoSeriesByBarSite((a, b, pa, pb) => a > b && pa <= pb);\n}\n\n/**\n * One `ta.crossunder(a, b)` call site in a loop, called several times on one bar: each call compares with the last\n * call of the previous bar (where both arguments were not na); false before such a call.\n */\nexport function crossunderByBar(): (barIndex: number, a: number, b: number) => boolean {\n return twoSeriesByBarSite((a, b, pa, pb) => a < b && pa >= pb);\n}\n\n/**\n * One `ta.barssince(condition)` call site: the number of calls since the condition was true on a call (0 on that\n * call), na before the first true condition. An na condition counts as false.\n */\nexport function barssince(): (condition: boolean | number) => number {\n let count = NaN;\n return (condition) => {\n if (condition && !Number.isNaN(condition)) count = 0;\n else if (!Number.isNaN(count)) count++;\n return count;\n };\n}\n\n/**\n * One `ta.cross(a, b)` call site, rules of `ta.cross`: the site keeps the side of the last call where `a` was\n * strictly above or strictly below `b` (none before such a call; equal values and na arguments do not change it),\n * and is true when the arguments are strictly on the other side. False with an na argument.\n */\nexport function cross(): (a: number, b: number) => boolean {\n let side = 0; // -1: last strictly below, 1: last strictly above, 0: none yet\n return (a, b) => {\n if (Number.isNaN(a) || Number.isNaN(b)) return false;\n const result = (side < 0 && a > b) || (side > 0 && a < b);\n if (a < b) side = -1;\n else if (a > b) side = 1;\n return result;\n };\n}\n\n/** Windows up to this length are scanned; longer ones are read from the tree of {@link KeptCalls}. */\nconst SCANNED_WINDOW = 32;\n\n/** The values a ta.highest / ta.lowest / ta.pivothigh call site keeps: the non-na values of its calls, one per bar. */\nclass KeptCalls {\n readonly values: number[] = [];\n readonly bars: number[] = [];\n /**\n * Segment tree of the best position of each range of kept values (node 1 is the root, leaf `leaves + k` is value\n * `k`, -1 for no value), built on the first long window: a call site whose length grows with the bars (the bars\n * since a session start) would otherwise scan the whole history on every call.\n */\n private tree: Int32Array | null = null;\n private leaves = 0;\n\n constructor(private readonly isLowest: boolean) {}\n\n /**\n * Keeps a non-na value (+/-Infinity is skipped like na, #183); a later call on the same bar (a loop) replaces the\n * value of that bar.\n */\n add(barIndex: number, value: number): void {\n if (!Number.isFinite(value)) return;\n const last = this.values.length - 1;\n if (last >= 0 && this.bars[last] === barIndex) this.values[last] = value;\n else {\n this.values.push(value);\n this.bars.push(barIndex);\n }\n if (this.tree) this.update(this.values.length - 1);\n }\n\n /** Position of the best of the last `count` kept values (the newest one on ties), -1 when there is none. */\n best(count: number): number {\n const last = this.values.length - 1;\n if (last < 0 || !(count >= 1)) return -1;\n if (count > SCANNED_WINDOW) return this.bestOf(Math.max(0, Math.floor(last - count) + 1), last);\n let best = last;\n for (let k = last - 1; k >= 0 && k > last - count; k--) {\n if (this.isLowest ? this.values[k]! < this.values[best]! : this.values[k]! > this.values[best]!) best = k;\n }\n return best;\n }\n\n /** The better of two positions (-1: none): the lower (higher) value, the newest one on equal values. */\n private better(a: number, b: number): number {\n if (a < 0) return b;\n if (b < 0) return a;\n const va = this.values[a]!;\n const vb = this.values[b]!;\n if (this.isLowest ? va < vb : va > vb) return a;\n if (this.isLowest ? vb < va : vb > va) return b;\n return a > b ? a : b;\n }\n\n /** Best position of the kept values `first` to `last`, from the tree. */\n private bestOf(first: number, last: number): number {\n if (!this.tree) this.build();\n const tree = this.tree!;\n let best = -1;\n for (let l = first + this.leaves, r = last + this.leaves + 1; l < r; l >>= 1, r >>= 1) {\n if (l & 1) best = this.better(best, tree[l++]!);\n if (r & 1) best = this.better(best, tree[--r]!);\n }\n return best;\n }\n\n /** (Re)builds the tree, with room for as many values again. */\n private build(): void {\n const n = this.values.length;\n let leaves = 1;\n while (leaves < 2 * n) leaves *= 2;\n const tree = new Int32Array(2 * leaves).fill(-1);\n for (let k = 0; k < n; k++) tree[leaves + k] = k;\n for (let i = leaves - 1; i >= 1; i--) tree[i] = this.better(tree[2 * i]!, tree[2 * i + 1]!);\n this.tree = tree;\n this.leaves = leaves;\n }\n\n /** Value `k` was added or replaced. */\n private update(k: number): void {\n if (k >= this.leaves) return this.build();\n const tree = this.tree!;\n tree[this.leaves + k] = k;\n for (let i = (this.leaves + k) >> 1; i >= 1; i >>= 1) tree[i] = this.better(tree[2 * i]!, tree[2 * i + 1]!);\n }\n}\n\n/** One `ta.lowest` / `ta.highest` / `ta.lowestbars` / `ta.highestbars` call site; rules in {@link lowestByBar}. */\nfunction extremeByBarSite(\n isLowest: boolean,\n offsets: boolean\n): (barIndex: number, value: number, length: number) => number {\n const kept = new KeptCalls(isLowest);\n const name = (isLowest ? 'lowest' : 'highest') + (offsets ? 'bars' : '');\n return (barIndex, value, length) => {\n checkWindowLength(name, length, barIndex);\n kept.add(barIndex, value);\n const len = Math.trunc(length);\n if (barIndex < len - 1) return NaN;\n const best = kept.best(len);\n if (best < 0) return NaN;\n return offsets ? -(barIndex - kept.bars[best]!) : kept.values[best]!;\n };\n}\n\n/** {@link extremeByBarSite} called with `(value, length, barIndex?)`: without a bar index, every call is a new bar. */\nfunction extremeSite(isLowest: boolean): (value: number, length: number, barIndex?: number) => number {\n const site = extremeByBarSite(isLowest, false);\n let calls = 0;\n return (value, length, barIndex) => site(barIndex ?? calls++, value, length);\n}\n\n/**\n * One `ta.lowest(source, length)` call site, called with `(value, length, barIndex?)`: the same site as\n * {@link lowestByBar} (same rules). Pass the bar index when the call does not run on every bar; without it every\n * call counts as one bar, which is right for a call on every bar (for example with a length that changes).\n *\n * @example\n * ```typescript\n * // Pine: lowPrice = ta.lowest(close[1], lookback) // lookback changes per bar\n * const lowPrice = callsite.lowest();\n * const out = closes.map((_, i) => lowPrice(i > 0 ? closes[i - 1]! : NaN, lookback[i]!));\n * ```\n */\nexport function lowest(): (value: number, length: number, barIndex?: number) => number {\n return extremeSite(true);\n}\n\n/**\n * One `ta.highest(source, length)` call site, called with `(value, length, barIndex?)`. Same rules as\n * {@link lowest}.\n */\nexport function highest(): (value: number, length: number, barIndex?: number) => number {\n return extremeSite(false);\n}\n\n/**\n * One `ta.lowest(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)` on the bars (and loop turns) where the Pine call runs. The length can change from one\n * call to the next.\n *\n * PineScript rules (measured in `if` blocks, ternaries, user functions and `for` loops, with constant lengths and\n * lengths that change, on sources with and without na):\n * - the call site keeps the non-na values it received, each with its bar; nothing is kept for a bar without a call\n * or for an na value\n * - the result is na while `barIndex < length - 1` (by bar, not by call) and while no value was received\n * - otherwise it is the lowest of the last `length` kept values, or of all of them when there are fewer: the first\n * call after bar `length - 1` gives its own value. A call with an na value also gives this result\n * - in a loop (several calls on one bar), a bar has one kept value: each call replaces the value of the earlier\n * calls of that bar, so a call gives the lowest of its value and the values of the bars before\n *\n * Called on every bar, it equals `ta.lowest`.\n *\n * @example\n * ```typescript\n * // Pine: lo = cond ? ta.lowest(low, 6) : na\n * const site = callsite.lowestByBar();\n * const lo = lows.map((v, i) => (cond[i] ? site(i, v, 6) : NaN));\n * ```\n */\nexport function lowestByBar(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(true, false);\n}\n\n/**\n * One `ta.highest(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)`. Same rules as {@link lowestByBar}.\n */\nexport function highestByBar(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(false, false);\n}\n\n/**\n * One `ta.lowestbars(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)`: the offset (0 or negative) from this bar to the bar of the lowest of the last `length`\n * kept values, the newest one on equal values. The values are kept as in {@link lowestByBar}; the offset counts\n * bars, not calls, so it can be below `-(length - 1)`.\n *\n * @example\n * ```typescript\n * // Pine: off = cond ? ta.lowestbars(low, 10) : na\n * const site = callsite.lowestbars();\n * const off = lows.map((v, i) => (cond[i] ? site(i, v, 10) : NaN));\n * ```\n */\nexport function lowestbars(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(true, true);\n}\n\n/**\n * One `ta.highestbars(source, length)` call site in a conditional block or a loop, called with\n * `(barIndex, value, length)`. Same rules as {@link lowestbars}.\n */\nexport function highestbars(): (barIndex: number, value: number, length: number) => number {\n return extremeByBarSite(false, true);\n}\n\n/** One `ta.pivothigh` / `ta.pivotlow` call site; rules in {@link pivothigh}. */\nfunction pivotSite(isLowest: boolean): (barIndex: number, value: number, leftbars: number, rightbars: number) => number {\n const kept = new KeptCalls(isLowest);\n return (barIndex, value, leftbars, rightbars) => {\n kept.add(barIndex, value);\n const left = Math.trunc(leftbars);\n const right = Math.trunc(rightbars);\n if (!(barIndex >= left + right)) return NaN;\n const best = kept.best(left + right + 1);\n return best >= 0 && kept.bars[best] === barIndex - right ? kept.values[best]! : NaN;\n };\n}\n\n/**\n * One `ta.pivothigh(source, leftbars, rightbars)` call site in a conditional block, called with\n * `(barIndex, value, leftbars, rightbars)` on the bars where the Pine call runs. The lengths can change from one call\n * to the next (the lengths of the current call are used).\n *\n * PineScript rules (measured in `if` blocks and ternaries, and on sources with na):\n * - the call site keeps the non-na values it received, each with its bar\n * - on a call it takes the last `leftbars + rightbars + 1` kept values (all of them when there are fewer) and finds\n * the highest, the newest one on equal values\n * - there is a pivot only when that value is on the bar `rightbars` BARS back (by bar index, not by call); the\n * result is its value, na otherwise and before bar `leftbars + rightbars`\n *\n * Called on every bar, it equals `ta.pivothigh`.\n *\n * @example\n * ```typescript\n * // Pine: ph = useFilter ? ta.pivothigh(src, 5, 5) : na\n * const site = callsite.pivothigh();\n * const ph = src.map((v, i) => (useFilter[i] ? site(i, v, 5, 5) : NaN));\n * ```\n */\nexport function pivothigh(): (barIndex: number, value: number, leftbars: number, rightbars: number) => number {\n return pivotSite(false);\n}\n\n/**\n * One `ta.pivotlow(source, leftbars, rightbars)` call site in a conditional block, called with\n * `(barIndex, value, leftbars, rightbars)`. Same rules as {@link pivothigh} (the lowest value).\n */\nexport function pivotlow(): (barIndex: number, value: number, leftbars: number, rightbars: number) => number {\n return pivotSite(true);\n}\n\n/**\n * One `ta.linreg(source, length, offset)` call site in a conditional block, called with\n * `(barIndex, value, length, offset)` on the bars where the Pine call runs.\n *\n * PineScript rules (measured): `ta.linreg` keeps the values it receives in a ring of `length + 1` slots indexed by the\n * bar index, filled with 0 at the start and written only on the bars where it is called. The window is read from the\n * ring for the last `length` bars: a bar before the first call counts as 0, and a bar without a call holds the value of\n * the call `length + 1` bars earlier (0 if there was none). The result is na before bar `length - 1`. Called on every\n * bar, it equals `ta.linreg`.\n *\n * @example\n * ```typescript\n * // Pine: if bar_index >= 20\n * // a := ta.linreg(close, 10, 0)\n * const site = callsite.linreg();\n * const a = closes.map((c, i) => (i >= 20 ? site(i, c, 10, 0) : NaN));\n * ```\n */\nexport function linreg(): (barIndex: number, value: number, length: number, offset?: number) => number {\n let ring: number[] = [];\n return (barIndex, value, length, offset = 0) => {\n const len = Math.floor(length);\n if (ring.length !== len + 1) ring = new Array<number>(len + 1).fill(0);\n ring[barIndex % (len + 1)] = value;\n if (barIndex < len - 1) return NaN;\n const window = Array.from({ length: len }, (_, k) => ring[(barIndex - len + 1 + k) % (len + 1)]!);\n return linregSeries(window, len, offset)[len - 1]!;\n };\n}\n\n\n/**\n * One `math.sum` call site in a loop; rules in {@link sum}. With `squares`, it also keeps the running sum of the\n * squared values (for {@link stdev}). Returns `[sum, sumOfSquares]` (NaN when not kept).\n */\nfunction loopSumSite(\n name: string,\n squares: boolean\n): (barIndex: number, value: number, length: number) => [number, number] {\n const running = new RunningSum();\n const runningSq = new RunningSum();\n const fn = name === 'sum' ? 'math.sum' : `ta.${name}`;\n let lastBar = NaN;\n let pending = false;\n return (barIndex, value, length) => {\n const len = Math.floor(length);\n checkSumLength(fn, len, barIndex);\n if (!(len >= 1)) throw new Error(`callsite.${name}: length must be at least 1 (got ${length})`);\n if (barIndex !== lastBar) {\n if (pending) {\n running.commit();\n if (squares) runningSq.commit();\n }\n pending = false;\n lastBar = barIndex;\n }\n if (isNa(value)) {\n pending = false;\n return [running.stepNa(len), squares ? runningSq.stepNa(len) : NaN];\n }\n const x = value;\n const out: [number, number] = [running.step(x, len), squares ? runningSq.step(x * x, len) : NaN];\n pending = true;\n return out;\n };\n}\n\n/**\n * One `math.sum(source, length)` call site inside a `for` / `while` loop, called with `(barIndex, value, length)` on\n * each call.\n *\n * PineScript rules (measured on calls in loops, 1 to 3 calls per bar, and bars without a call):\n * - the call site keeps one history value per bar: the value of its last call on that bar\n * - every call on a bar starts from the state of the earlier bars, so it gives the sum of its value and the last\n * `length - 1` kept values; the last call of the bar is the one kept for the later bars\n * - the length can change from one call to the next (also on the same bar): each call first moves the kept sum to\n * its own length, as `math.sum` with a series length\n * - a bar without a call is not in the history (as a call in an `if` block)\n * - the sum is the correctly rounded window sum, as `math.sum` (bit for bit, #188)\n *\n * An na value is skipped as in `math.sum` (it returns the sum of the last `length` earlier values); when it is the\n * last call of a bar, the bar is not in the history (not measured).\n *\n * @example\n * ```typescript\n * // Pine: for i = 0 to 2\n * // s = math.sum(close * (1 + 0.01 * i), 7)\n * const site = callsite.sum();\n * for (let b = 0; b < closes.length; b++) {\n * for (let i = 0; i <= 2; i++) {\n * const s = site(b, closes[b]! * (1 + 0.01 * i), 7);\n * }\n * }\n * ```\n */\nexport function sum(): (barIndex: number, value: number, length: number) => number {\n const site = loopSumSite('sum', false);\n return (barIndex, value, length) => site(barIndex, value, length)[0];\n}\n\n/**\n * One `ta.sma(source, length)` call site inside a `for` / `while` loop, called with `(barIndex, value, length)` on\n * each call: {@link sum} divided by the length (same rules).\n *\n * @example\n * ```typescript\n * // Pine: evaluate(ratio) => ta.sma(gann(ratio), n) // called once per ratio in a while loop\n * const site = callsite.sma();\n * for (let b = 0; b < closes.length; b++) {\n * for (const ratio of ratios) {\n * const avg = site(b, gann(b, ratio), n);\n * }\n * }\n * ```\n */\nexport function sma(): (barIndex: number, value: number, length: number) => number {\n const site = loopSumSite('sma', false);\n return (barIndex, value, length) => site(barIndex, value, length)[0] / Math.floor(length);\n}\n\n/**\n * One `ta.stdev(source, length, biased)` call site inside a `for` / `while` loop, called with\n * `(barIndex, value, length, biased?)` on each call: the window sums of the values and of their squares follow the\n * rules of {@link sum}; the result is computed from them as `ta.stdev` (bit for bit).\n *\n * @example\n * ```typescript\n * // Pine: for len in lengths\n * // [mid, up, lo] = ta.bb(close, len, 2)\n * const avgSite = callsite.sma();\n * const devSite = callsite.stdev();\n * for (let b = 0; b < closes.length; b++) {\n * for (const len of lengths) {\n * const mid = avgSite(b, closes[b]!, len);\n * const dev = devSite(b, closes[b]!, len);\n * }\n * }\n * ```\n */\nexport function stdev(): (barIndex: number, value: number, length: number, biased?: boolean) => number {\n const site = loopSumSite('stdev', true);\n return (barIndex, value, length, biased = true) => {\n const len = Math.floor(length);\n const [s, sq] = site(barIndex, value, length);\n const mean = s / len;\n const variance = biased ? sq / len - mean * mean : sq / (len - 1) - (mean * s) / (len - 1);\n if (!biased && len <= 1) return NaN;\n return Number.isNaN(variance) ? NaN : variance > 0 ? Math.sqrt(variance) : 0;\n };\n}\n\n/**\n * One `math.random(min, max, seed)` call site: PineScript keeps one generator per call site, so two call sites\n * with the same seed give the same sequence. Called with `(min?, max?)` once per bar.\n *\n * @example\n * ```typescript\n * // Pine: a = math.random(0, 1, 42), b = math.random(0, 1, 42) // a == b on every bar\n * const a = callsite.random(42);\n * const b = callsite.random(42);\n * ```\n */\nexport function random(seed: number): (min?: number, max?: number) => number {\n return seededRandom(seed);\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;AAgDA,gBAAuC;AACvC,yBAAiC;AACjC,oBAAkD;AAClD,kBAA6B;AAWtB,SAAS,WACd,QACA,OACG,SACgB;AACnB,QAAM,OAAiB,CAAC;A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AAC;AACrE;AAiBO,SAAS,MAAmE;AACjF,QAAM,OAAO,YAAY,OAAO,KAAK;AACrC,SAAO,CAAC,UAAU,OAAO,WAAW,KAAK,UAAU,OAAO,MAAM,EAAE,CAAC,IAAI,KAAK,MAAM,MAAM;AAC1F;AAqBO,SAAS,QAAuF;AACrG,QAAM,OAAO,YAAY,SAAS,IAAI;AACtC,SAAO,CAAC,UAAU,OAAO,QAAQ,SAAS,SAAS;AACjD,UAAM,MAAM,KAAK,MAAM,MAAM;AAC7B,UAAM,CAAC,GAAG,EAAE,IAAI,KAAK,UAAU,OAAO,MAAM;AAC5C,UAAM,OAAO,IAAI;AACjB,UAAM,WAAW,SAAS,KAAK,MAAM,OAAO,OAAO,MAAM,MAAM,KAAM,OAAO,KAAM,MAAM;AACxF,QAAI,CAAC,UAAU,OAAO,EAAG,QAAO;AAChC,WAAO,OAAO,MAAM,QAAQ,IAAI,MAAM,WAAW,IAAI,KAAK,KAAK,QAAQ,IAAI;AAAA,EAC7E;AACF;AAaO,SAAS,OAAO,MAAsD;AAC3E,aAAO,0BAAa,IAAI;AAC1B;",
|
|
6
6
|
"names": ["linregSeries"]
|
|
7
7
|
}
|
|
@@ -63,6 +63,34 @@ interface DrawingTypes {
|
|
|
63
63
|
/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */
|
|
64
64
|
export declare const DEFAULT_MAX_COUNT = 50;
|
|
65
65
|
export type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;
|
|
66
|
+
/**
|
|
67
|
+
* Base of the classes that add a private field to an existing object (their constructor returns the object they are
|
|
68
|
+
* given). Such a field replaces a WeakMap entry: a study that creates hundreds of thousands of objects spends most of
|
|
69
|
+
* its drawing time adding WeakMap keys. The field is invisible (not a key, not copied by a spread) and stays for the
|
|
70
|
+
* life of the object, as the entry did.
|
|
71
|
+
*/
|
|
72
|
+
export declare class Stamped {
|
|
73
|
+
constructor(obj: object);
|
|
74
|
+
}
|
|
75
|
+
/** The `var` records of a run: a reset starts new ones, a nested run saves and puts back those of its run. */
|
|
76
|
+
interface Holds {
|
|
77
|
+
/** The records of the objects whose private record belongs to another run */
|
|
78
|
+
readonly others: WeakMap<object, HoldRecord>;
|
|
79
|
+
/** Records made in the run. None: no object has one, nothing to look up for each object the maximum count may
|
|
80
|
+
* delete */
|
|
81
|
+
records: number;
|
|
82
|
+
}
|
|
83
|
+
/** What the `var` variables of a run did with an object. */
|
|
84
|
+
interface HoldRecord {
|
|
85
|
+
readonly run: Holds;
|
|
86
|
+
/** Number of `var` variables that hold the object (0: not held) */
|
|
87
|
+
count: number;
|
|
88
|
+
/** Bar on which a `var` variable got the object: on that bar the maximum count deletes it only when no other object
|
|
89
|
+
* can go; from the next bar on, never. Undefined outside a bar loop */
|
|
90
|
+
heldAt: number | undefined;
|
|
91
|
+
/** Bar on which the last `var` variable released the object (linefill rule) */
|
|
92
|
+
releasedAt: number | undefined;
|
|
93
|
+
}
|
|
66
94
|
/** Kinds with a maximum count of their own. */
|
|
67
95
|
type CountedKind = 'line' | 'label' | 'box' | 'polyline';
|
|
68
96
|
/**
|
|
@@ -129,6 +157,8 @@ export declare function setDrawingBar(barIndex: number | null, last?: boolean, l
|
|
|
129
157
|
* #176).
|
|
130
158
|
*/
|
|
131
159
|
export declare function checkBarIndex(method: string, variable: string, x: number, xloc: string | undefined): number;
|
|
160
|
+
/** The live linefills that use `line`, in creation order (do not modify). */
|
|
161
|
+
export declare function liveFillsOf(line: Line): readonly Linefill[];
|
|
132
162
|
/** The kinds of drawing objects created since the last {@link resetDrawings}, even when none is alive any more. */
|
|
133
163
|
export declare function createdDrawingKinds(): DrawingKind[];
|
|
134
164
|
/** Records a new object and deletes the oldest objects of its kind when the count is too high. */
|
|
@@ -149,9 +179,7 @@ export interface DrawingState {
|
|
|
149
179
|
[K in DrawingKind]: Array<DrawingTypes[K]>;
|
|
150
180
|
};
|
|
151
181
|
created: DrawingKind[];
|
|
152
|
-
|
|
153
|
-
releasedAt: WeakMap<object, number>;
|
|
154
|
-
heldAt: WeakMap<object, number>;
|
|
182
|
+
holds: Holds;
|
|
155
183
|
pending: Record<CountedKind, number>;
|
|
156
184
|
currentBar: number | null;
|
|
157
185
|
lastBarIndex: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAEvF,UAAU,YAAY;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAErF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