pinets 0.9.20 → 0.9.21
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/pinets.min.browser.es.js +10 -10
- package/dist/pinets.min.browser.es.js.map +1 -1
- package/dist/pinets.min.browser.js +10 -10
- package/dist/pinets.min.browser.js.map +1 -1
- package/dist/pinets.min.cjs +10 -10
- package/dist/pinets.min.cjs.map +1 -1
- package/dist/pinets.min.es.js +10 -10
- package/dist/pinets.min.es.js.map +1 -1
- package/dist/types/namespaces/strategy/utils.d.ts +6 -2
- package/package.json +1 -1
package/dist/pinets.min.es.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import*as Ut from"fs";import*as ci from"path";import{fileURLToPath as Wa}from"url";function Ua(t){return e=>new B(e.array.map(i=>Math.abs(i)),e.type,t)}function qa(t){return e=>{let i=0,r=0;for(const n of e.array){const s=Number(n);isNaN(s)||(r++,i+=(s-i)/r)}return r===0?NaN:t.precision(i)}}function za(t){return(e,i)=>{const r=e.array;let n=0,s=r.length-1;for(;n<=s;){const a=Math.floor((n+s)/2),o=r[a];if(o===i)return a;o<i?n=a+1:s=a-1}return-1}}function Ka(t){return(e,i)=>{const r=e.array;let n=0,s=r.length;for(;n<s;){const a=Math.floor((n+s)/2);r[a]<i?n=a+1:s=a}return n<r.length&&r[n]===i?n:n-1}}function Ha(t){return(e,i)=>{const r=e.array;let n=0,s=r.length;for(;n<s;){const a=Math.floor((n+s)/2);r[a]<=i?n=a+1:s=a}return n>0&&r[n-1]===i?n-1:n}}function Ga(t){return e=>{e.array.length=0}}function Ya(t){return(e,i)=>(e.array.push(...i.array),e)}function Xa(t){return e=>new B([...e.array],e.type,t)}function Za(t){return(e,i,r=!0)=>{const n=e.array,s=i.array;if(n.length!==s.length)return NaN;let a=0,o=0,l=0;const c=[];for(let d=0;d<n.length;d++){const m=Number(n[d]),x=Number(s[d]);!isNaN(m)&&m!==null&&m!==void 0&&!isNaN(x)&&x!==null&&x!==void 0&&(a+=m,o+=x,l++,c.push(d))}if(l===0)return NaN;const u=a/l,p=o/l;let h=0;for(const d of c){const m=Number(n[d]),x=Number(s[d]);h+=(m-u)*(x-p)}const f=r?l:l-1;return f<=0?NaN:t.precision(h/f)}}function Qa(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function Ja(t){return t.every(e=>typeof e=="number")?t.every(e=>Number.isInteger(e))?j.int:j.float:t.every(e=>typeof e=="string")?j.string:t.every(e=>typeof e=="boolean")?j.bool:j.any}function Ge(t){return typeof t=="number"?Number.isInteger(t)?j.int:j.float:typeof t=="string"?j.string:typeof t=="boolean"?j.bool:j.any}function wi(t,e){if(typeof t=="number"&&isNaN(t)||e===j.any)return!0;switch(e){case j.int:return Number.isInteger(t)||isNaN(t);case j.float:return typeof t=="number";case j.string:return typeof t=="string";case j.bool:return typeof t=="boolean";case j.box:case j.label:case j.line:case j.linefill:case j.table:case j.color:return t===null||typeof t=="object"||typeof t=="string"}return!1}function eo(t){return(e,i,r=0,n)=>{const s=e.array.length,a=n!==void 0?Math.min(n,s):s;for(let o=r;o<a;o++){if(!wi(i,e.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array[o]=typeof i=="number"?t.precision(i):i}}}function to(t){return e=>e.array.length>0?e.array[0]:t.NA}function io(t){return(e,i)=>(i<0&&(i=e.array.length+i),i<0||i>=e.array.length?(t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.get"),NaN):e.array[i])}function ro(t){return(e,i)=>e.array.includes(i)}function no(t){return(e,i)=>typeof i=="number"&&i!==i?e.array.findIndex(r=>typeof r=="number"&&r!==r):e.array.indexOf(i)}function so(t){return(e,i,r)=>{if(!wi(r,e.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);if(i<0&&(i=e.array.length+i),i<0||i>e.array.length){t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.insert");return}e.array.splice(i,0,r)}}function ao(t){return(e,i=",")=>e.array.join(i)}function oo(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function lo(t){return(e,i)=>e.array.lastIndexOf(i)}function co(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let s=1;s<r.length;s++)r[s]>n&&(n=r[s]);return n??t.NA}return[...r].sort((n,s)=>s-n)[i]??t.NA}}function uo(t){return e=>{const i=e.array;if(i.length===0)return NaN;const r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=i[s];r.sort((s,a)=>s-a);const n=Math.floor(r.length/2);return r.length%2!==0?r[n]:(r[n-1]+r[n])/2}}function ho(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let s=1;s<r.length;s++)r[s]<n&&(n=r[s]);return n??t.NA}return[...r].sort((n,s)=>n-s)[i]??t.NA}}function po(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const s of e.array){const a=(i.get(s)||0)+1;i.set(s,a),a>r&&(r=a)}const n=[];for(const[s,a]of i)a===r&&n.push(s);return n.sort((s,a)=>typeof s=="number"&&typeof a=="number"?s-a:typeof s=="string"&&typeof a=="string"?s<a?-1:s>a?1:0:0),n[0]}}function fo(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const s=new Array(n);for(let c=0;c<n;c++){const u=Number(r[c]);if(isNaN(u)||u===null||u===void 0)return NaN;s[c]=u}s.sort((c,u)=>c-u),i<0&&(i=0),i>100&&(i=100);const a=i/100*n-.5;if(a<=0)return t.precision(s[0]);if(a>=n-1)return t.precision(s[n-1]);const o=Math.floor(a),l=a-o;return t.precision(s[o]*(1-l)+s[o+1]*l)}}function mo(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const s=new Array;for(let o=0;o<n;o++){const l=Number(r[o]);!isNaN(l)&&l!==null&&l!==void 0&&s.push(l)}if(s.length===0)return NaN;s.sort((o,l)=>o-l),i<0&&(i=0),i>100&&(i=100);const a=Math.ceil(i/100*n);return a<=0?s[0]:a>s.length?NaN:s[a-1]}}function yo(t){return(e,i)=>{if(e.array.length===0)return NaN;const r=Math.floor(i);if(r<0||r>=e.array.length)return NaN;const n=Number(e.array[r]);if(isNaN(n)||n===null||n===void 0)return NaN;let s=0;for(const o of e.array){const l=Number(o);!isNaN(l)&&l!==null&&l!==void 0&&l<n&&s++}const a=e.array.length-1;return a<=0?NaN:s/a*100}}function _o(t){return e=>e.array.pop()}function go(t){return(e,i)=>{if(!wi(i,e.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.push(typeof i=="number"?t.precision(i):i)}}function xo(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function bo(t){return(e,i)=>(i<0&&(i=e.array.length+i),i<0||i>=e.array.length?(t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.remove"),NaN):e.array.splice(i,1)[0])}function vo(t){return e=>{e.array.reverse()}}function wo(t){return(e,i,r)=>{if(!wi(r,e.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);if(i<0&&(i=e.array.length+i),i<0||i>=e.array.length){t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.set");return}e.array[i]=typeof r=="number"?t.precision(r):r}}function So(t){return e=>e.array.shift()}function Eo(t){return e=>e.array.length}function No(t){return(e,i,r)=>{const n=r!==void 0?r:void 0;return new B(e.array.slice(i,n),e.type,t)}}function Co(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var ti=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(ti||{}),rs=(t=>(t.AED="AED",t.ARS="ARS",t.AUD="AUD",t.BDT="BDT",t.BHD="BHD",t.BRL="BRL",t.BTC="BTC",t.CAD="CAD",t.CHF="CHF",t.CLP="CLP",t.CNY="CNY",t.COP="COP",t.CZK="CZK",t.DKK="DKK",t.EGP="EGP",t.ETH="ETH",t.EUR="EUR",t.GBP="GBP",t.HKD="HKD",t.HUF="HUF",t.IDR="IDR",t.ILS="ILS",t.INR="INR",t.ISK="ISK",t.JPY="JPY",t.KES="KES",t.KRW="KRW",t.KWD="KWD",t.LKR="LKR",t.MAD="MAD",t.MXN="MXN",t.MYR="MYR",t.NGN="NGN",t.NOK="NOK",t.NONE="NONE",t.NZD="NZD",t.PEN="PEN",t.PHP="PHP",t.PKR="PKR",t.PLN="PLN",t.QAR="QAR",t.RON="RON",t.RSD="RSD",t.RUB="RUB",t.SAR="SAR",t.SEK="SEK",t.SGD="SGD",t.THB="THB",t.TND="TND",t.TRY="TRY",t.TWD="TWD",t.USD="USD",t.USDT="USDT",t.VES="VES",t.VND="VND",t.ZAR="ZAR",t))(rs||{}),ns=(t=>(t[t.sunday=1]="sunday",t[t.monday=2]="monday",t[t.tuesday=3]="tuesday",t[t.wednesday=4]="wednesday",t[t.thursday=5]="thursday",t[t.friday=6]="friday",t[t.saturday=7]="saturday",t))(ns||{}),ss=(t=>(t.all="all",t.data_window="data_window",t.none="none",t.pane="pane",t.price_scale="price_scale",t.status_line="status_line",t))(ss||{}),as=(t=>(t.flag="shape_flag",t.arrowdown="shape_arrow_down",t.arrowup="shape_arrow_up",t.circle="shape_circle",t.cross="shape_cross",t.diamond="shape_diamond",t.labeldown="shape_label_down",t.labelup="shape_label_up",t.square="shape_square",t.triangledown="shape_triangle_down",t.triangleup="shape_triangle_up",t.xcross="shape_xcross",t))(as||{}),os=(t=>(t.abovebar="AboveBar",t.belowbar="BelowBar",t.absolute="Absolute",t.bottom="Bottom",t.top="Top",t))(os||{}),ls=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(ls||{}),cs=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(cs||{}),Io=(t=>(t.linestyle_dashed="linestyle_dashed",t.linestyle_dotted="linestyle_dotted",t.linestyle_solid="linestyle_solid",t.style_area="style_area",t.style_areabr="style_areabr",t.style_circles="style_circles",t.style_columns="style_columns",t.style_cross="style_cross",t.style_histogram="style_histogram",t.style_line="style_line",t.style_linebr="style_linebr",t.style_stepline="style_stepline",t.style_stepline_diamond="style_stepline_diamond",t.style_steplinebr="style_steplinebr",t))(Io||{}),us=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(us||{}),hs=(t=>(t.bar_index="bi",t.bar_time="bt",t))(hs||{}),ps=(t=>(t.price="pr",t.abovebar="ab",t.belowbar="bl",t))(ps||{}),fs=(t=>(t.left="l",t.right="r",t.both="b",t.none="n",t))(fs||{}),ds=(t=>(t.align_bottom="bottom",t.align_top="top",t.align_left="left",t.align_center="center",t.align_right="right",t.wrap_auto="auto",t.wrap_none="none",t.format_bold="bold",t.format_italic="italic",t.format_none="none",t))(ds||{}),ms=(t=>(t.family_default="default",t.family_monospace="monospace",t))(ms||{}),ys=(t=>(t.none="none",t.splits="splits",t.dividends="dividends",t))(ys||{}),_s=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(_s||{}),gs=(t=>(t.actual="earnings_actual",t.estimate="earnings_estimate",t.standardized="earnings_standardized",t.future_eps="earnings_future_eps",t.future_period_end_time="earnings_future_period_end_time",t.future_revenue="earnings_future_revenue",t.future_time="earnings_future_time",t))(gs||{}),xs=(t=>(t.gross="dividends_gross",t.net="dividends_net",t.future_amount="dividends_future_amount",t.future_ex_date="dividends_future_ex_date",t.future_pay_date="dividends_future_pay_date",t))(xs||{}),bs=(t=>(t.denominator="splits_denominator",t.numerator="splits_numerator",t))(bs||{}),vs=(t=>(t.top_left="top_left",t.top_center="top_center",t.top_right="top_right",t.middle_left="middle_left",t.middle_center="middle_center",t.middle_right="middle_right",t.bottom_left="bottom_left",t.bottom_center="bottom_center",t.bottom_right="bottom_right",t))(vs||{}),ws=(t=>(t.left="left",t.none="none",t.right="right",t))(ws||{}),Ss=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(Ss||{});const ko={order:ti,currency:rs,dayofweek:ns,display:ss,shape:as,location:os,size:ls,format:cs,barmerge:us,xloc:hs,yloc:ps,extend:fs,text:ds,font:ms,adjustment:ys,backadjustment:_s,earnings:gs,dividends:xs,splits:bs,position:vs,scale:ws,settlement_as_close:Ss};function To(t){return(e,i=ti.ascending)=>{e.array.sort((r,n)=>{let s=isNaN(r)?1/0:r,a=isNaN(n)?1/0:n;return i===ti.ascending?s-a:a-s})}}function Ao(t){return(e,i=ti.ascending)=>{const r=e.array.map((n,s)=>s);return r.sort((n,s)=>{const a=isNaN(e.array[n])?1/0:e.array[n],o=isNaN(e.array[s])?1/0:e.array[s];return i===ti.ascending?a-o:o-a}),new B(r,j.int,t)}}function Po(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new B(e.array.map(()=>NaN),j.int,t):r===0?new B(e.array.map(()=>1),j.int,t):new B(e.array.map(n=>(n-i)/r),j.int,t)}}function Do(t){return(e,i=!0)=>{const r=e.array,n=r.length;if(n===0)return NaN;let s=0,a=0,o=0;for(let u=0;u<n;u++){const p=Number(r[u]);!isNaN(p)&&p!==null&&p!==void 0&&(s+=p,a+=p*p,o++)}if(o===0)return NaN;const l=s/o;let c=a/o-l*l;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(c)))}}function Mo(t){return e=>t.precision(e.array.reduce((i,r)=>{const n=Number(r);return isNaN(n)?i:i+n},0))}function Ro(t){return(e,i)=>{if(!wi(i,e.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.unshift(typeof i=="number"?t.precision(i):i)}}function Oo(t){return(e,i=!0)=>{let r=0,n=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,n++)}if(n===0)return NaN;const s=r/n;let a=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(a+=(c-s)*(c-s))}const o=i?n:n-1;return o<=0?NaN:t.precision(a/o)}}var $o=Object.defineProperty,Vo=(t,e,i)=>e in t?$o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,F=(t,e,i)=>Vo(t,typeof e!="symbol"?e+"":e,i),j=(t=>(t.any="",t.box="box",t.bool="bool",t.color="color",t.float="float",t.int="int",t.label="label",t.line="line",t.linefill="linefill",t.string="string",t.table="table",t))(j||{});class B{constructor(e,i,r){this.array=e,this.type=i,this.context=r,F(this,"_abs"),F(this,"_avg"),F(this,"_binary_search"),F(this,"_binary_search_leftmost"),F(this,"_binary_search_rightmost"),F(this,"_clear"),F(this,"_concat"),F(this,"_copy"),F(this,"_covariance"),F(this,"_every"),F(this,"_fill"),F(this,"_first"),F(this,"_get"),F(this,"_includes"),F(this,"_indexof"),F(this,"_insert"),F(this,"_join"),F(this,"_last"),F(this,"_lastindexof"),F(this,"_max"),F(this,"_median"),F(this,"_min"),F(this,"_mode"),F(this,"_percentile_linear_interpolation"),F(this,"_percentile_nearest_rank"),F(this,"_percentrank"),F(this,"_pop"),F(this,"_push"),F(this,"_range"),F(this,"_remove"),F(this,"_reverse"),F(this,"_set"),F(this,"_shift"),F(this,"_size"),F(this,"_slice"),F(this,"_some"),F(this,"_sort"),F(this,"_sort_indices"),F(this,"_standardize"),F(this,"_stdev"),F(this,"_sum"),F(this,"_unshift"),F(this,"_variance"),this._abs=Ua(this.context),this._avg=qa(this.context),this._binary_search=za(this.context),this._binary_search_leftmost=Ka(this.context),this._binary_search_rightmost=Ha(this.context),this._clear=Ga(this.context),this._concat=Ya(this.context),this._copy=Xa(this.context),this._covariance=Za(this.context),this._every=Qa(this.context),this._fill=eo(this.context),this._first=to(this.context),this._get=io(this.context),this._includes=ro(this.context),this._indexof=no(this.context),this._insert=so(this.context),this._join=ao(this.context),this._last=oo(this.context),this._lastindexof=lo(this.context),this._max=co(this.context),this._median=uo(this.context),this._min=ho(this.context),this._mode=po(this.context),this._percentile_linear_interpolation=fo(this.context),this._percentile_nearest_rank=mo(this.context),this._percentrank=yo(this.context),this._pop=_o(this.context),this._push=go(this.context),this._range=xo(this.context),this._remove=bo(this.context),this._reverse=vo(this.context),this._set=wo(this.context),this._shift=So(this.context),this._size=Eo(this.context),this._slice=No(this.context),this._some=Co(this.context),this._sort=To(this.context),this._sort_indices=Ao(this.context),this._standardize=Po(this.context),this._stdev=Do(this.context),this._sum=Mo(this.context),this._unshift=Ro(this.context),this._variance=Oo(this.context)}toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}[Symbol.iterator](){return this.array[Symbol.iterator]()}abs(...e){return this._abs(this,...e)}avg(...e){return this._avg(this,...e)}binary_search(...e){return this._binary_search(this,...e)}binary_search_leftmost(...e){return this._binary_search_leftmost(this,...e)}binary_search_rightmost(...e){return this._binary_search_rightmost(this,...e)}clear(...e){return this._clear(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}covariance(...e){return this._covariance(this,...e)}every(...e){return this._every(this,...e)}fill(...e){return this._fill(this,...e)}first(...e){return this._first(this,...e)}get(...e){return this._get(this,...e)}includes(...e){return this._includes(this,...e)}indexof(...e){return this._indexof(this,...e)}insert(...e){return this._insert(this,...e)}join(...e){return this._join(this,...e)}last(...e){return this._last(this,...e)}lastindexof(...e){return this._lastindexof(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}percentile_linear_interpolation(...e){return this._percentile_linear_interpolation(this,...e)}percentile_nearest_rank(...e){return this._percentile_nearest_rank(this,...e)}percentrank(...e){return this._percentrank(this,...e)}pop(...e){return this._pop(this,...e)}push(...e){return this._push(this,...e)}range(...e){return this._range(this,...e)}remove(...e){return this._remove(this,...e)}reverse(...e){return this._reverse(this,...e)}set(...e){return this._set(this,...e)}shift(...e){return this._shift(this,...e)}size(...e){return this._size(this,...e)}slice(...e){return this._slice(this,...e)}some(...e){return this._some(this,...e)}sort(...e){return this._sort(this,...e)}sort_indices(...e){return this._sort_indices(this,...e)}standardize(...e){return this._standardize(this,...e)}stdev(...e){return this._stdev(this,...e)}sum(...e){return this._sum(this,...e)}unshift(...e){return this._unshift(this,...e)}variance(...e){return this._variance(this,...e)}}function jo(t){return(...e)=>new B([...e],Ja(e),t)}function Lo(t){return(e,i)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;if(i===void 0){const n=r?Array(r).fill(0):[];return new B(n,j.any,t)}return new B(Array(r).fill(t.precision(i||0)),Ge(i||0),t)}}function Bo(t){return(e=0,i=!1)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.bool,t)}}function Fo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.box,t)}}function Wo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.color,t)}}function Uo(t){return(e=0,i=NaN)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(t.precision(i)),j.float,t)}}function qo(t){return(e=0,i=0)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(t.precision(i)),j.int,t)}}function zo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.label,t)}}function Ko(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.line,t)}}function Ho(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.linefill,t)}}function Go(t){return(e=0,i="")=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.string,t)}}function Yo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new B(Array(r).fill(i),j.table,t)}}class y{constructor(e,i=0){this.data=e,this.offset=i}get(e){const i=this.data.length-1-(this.offset+e);return i<0||i>=this.data.length?NaN:this.data[i]}set(e,i){const r=this.data.length-1-(this.offset+e);r>=0&&r<this.data.length&&(this.data[r]=i)}get length(){return this.data.length}toArray(){return this.data}static from(e){return e instanceof y?e:Array.isArray(e)?new y(e):e!=null&&typeof e=="object"&&"__value"in e&&e.__value instanceof y?e.__value:new y([e])}}function Xo(t){return(e,i=0)=>y.from(e).get(i)}class Zo{constructor(e){this.context=e,this.abs=(i,...r)=>i.abs(...r),this.avg=(i,...r)=>i.avg(...r),this.binary_search=(i,...r)=>i.binary_search(...r),this.binary_search_leftmost=(i,...r)=>i.binary_search_leftmost(...r),this.binary_search_rightmost=(i,...r)=>i.binary_search_rightmost(...r),this.clear=(i,...r)=>i.clear(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.covariance=(i,...r)=>i.covariance(...r),this.every=(i,...r)=>i.every(...r),this.fill=(i,...r)=>i.fill(...r),this.first=(i,...r)=>i.first(...r),this.from=jo(e),this.get=(i,...r)=>i.get(...r),this.includes=(i,...r)=>i.includes(...r),this.indexof=(i,...r)=>i.indexof(...r),this.insert=(i,...r)=>i.insert(...r),this.join=(i,...r)=>i.join(...r),this.last=(i,...r)=>i.last(...r),this.lastindexof=(i,...r)=>i.lastindexof(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.new=Lo(e),this.new_bool=Bo(e),this.new_box=Fo(e),this.new_color=Wo(e),this.new_float=Uo(e),this.new_int=qo(e),this.new_label=zo(e),this.new_line=Ko(e),this.new_linefill=Ho(e),this.new_string=Go(e),this.new_table=Yo(e),this.param=Xo(),this.percentile_linear_interpolation=(i,...r)=>i.percentile_linear_interpolation(...r),this.percentile_nearest_rank=(i,...r)=>i.percentile_nearest_rank(...r),this.percentrank=(i,...r)=>i.percentrank(...r),this.pop=(i,...r)=>i.pop(...r),this.push=(i,...r)=>i.push(...r),this.range=(i,...r)=>i.range(...r),this.remove=(i,...r)=>i.remove(...r),this.reverse=(i,...r)=>i.reverse(...r),this.set=(i,...r)=>i.set(...r),this.shift=(i,...r)=>i.shift(...r),this.size=(i,...r)=>i.size(...r),this.slice=(i,...r)=>i.slice(...r),this.some=(i,...r)=>i.some(...r),this.sort=(i,...r)=>i.sort(...r),this.sort_indices=(i,...r)=>i.sort_indices(...r),this.standardize=(i,...r)=>i.standardize(...r),this.stdev=(i,...r)=>i.stdev(...r),this.sum=(i,...r)=>i.sum(...r),this.unshift=(i,...r)=>i.unshift(...r),this.variance=(i,...r)=>i.variance(...r)}}function Qo(t){return e=>{e.map.clear()}}function Jo(t){return(e,i)=>e.map.has(i)}function el(t){return e=>{const i=new Es(t);return i.map=new Map(e.map),i}}function tl(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function il(t){return e=>{const i=Array.from(e.map.keys()),r=Ge(i[0]);return new B(i,r,t)}}function rl(t){return(e,i,r)=>{const n=e.map.get(i);return e.map.set(i,r),n===void 0?NaN:n}}function nl(t){return(e,i)=>{for(const[r,n]of i.map)e.map.set(r,n)}}function sl(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function al(t){return e=>e.map.size}function ol(t){return e=>{const i=Array.from(e.map.values()),r=Ge(i[0]);return new B(i,r,t)}}var ll=Object.defineProperty,cl=(t,e,i)=>e in t?ll(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ze=(t,e,i)=>cl(t,typeof e!="symbol"?e+"":e,i);class Es{constructor(e){this.context=e,Ze(this,"map"),Ze(this,"_clear"),Ze(this,"_contains"),Ze(this,"_copy"),Ze(this,"_get"),Ze(this,"_keys"),Ze(this,"_put"),Ze(this,"_put_all"),Ze(this,"_remove"),Ze(this,"_size"),Ze(this,"_values"),this.map=new Map,this._clear=Qo(this.context),this._contains=Jo(this.context),this._copy=el(this.context),this._get=tl(this.context),this._keys=il(this.context),this._put=rl(this.context),this._put_all=nl(this.context),this._remove=sl(this.context),this._size=al(this.context),this._values=ol(this.context)}toString(){return`PineMapObject(${this.map.size})`}clear(...e){return this._clear(this,...e)}contains(...e){return this._contains(this,...e)}copy(...e){return this._copy(this,...e)}get(...e){return this._get(this,...e)}keys(...e){return this._keys(this,...e)}put(...e){return this._put(this,...e)}put_all(...e){return this._put_all(this,...e)}remove(...e){return this._remove(this,...e)}size(...e){return this._size(this,...e)}values(...e){return this._values(this,...e)}}function ul(t){return()=>new Es(t)}function hl(t){return(e,i=0)=>y.from(e).get(i)}class pl{constructor(e){this.context=e,this.clear=(i,...r)=>i.clear(...r),this.contains=(i,...r)=>i.contains(...r),this.copy=(i,...r)=>i.copy(...r),this.get=(i,...r)=>i.get(...r),this.keys=(i,...r)=>i.keys(...r),this.new=ul(e),this.param=hl(),this.put=(i,...r)=>i.put(...r),this.put_all=(i,...r)=>i.put_all(...r),this.remove=(i,...r)=>i.remove(...r),this.size=(i,...r)=>i.size(...r),this.values=(i,...r)=>i.values(...r)}}function fl(t){return(e,i,r)=>{const n=e.matrix.length;let s=[];if(r&&(r instanceof B?s=r.array:Array.isArray(r)?s=r:s=[r]),n===0){for(let l=0;l<s.length;l++){let c=s[l];c instanceof y&&(c=c.get(0)),e.matrix.push([c])}return}const a=e.matrix[0].length,o=i!==void 0?i:a;for(let l=0;l<n;l++){let c=l<s.length?s[l]:NaN;c instanceof y&&(c=c.get(0)),e.matrix[l].splice(o,0,c)}}}function dl(t){return(e,i,r)=>{const n=e.matrix.length;let s=[];if(r)if(r instanceof B)s=r.array;else if(Array.isArray(r))s=r;else if(r instanceof y){const c=r.get(0);Array.isArray(c)?s=c:s=[c]}else s=[r];const a=n>0?e.matrix[0].length:s.length,o=i!==void 0?i:n,l=[];for(let c=0;c<a;c++)if(c<s.length){let u=s[c];u instanceof y&&(u=u.get(0)),l.push(u)}else l.push(NaN);e.matrix.splice(o,0,l)}}function ml(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;if(r===0)return NaN;let n=0,s=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||(n+=l,s++)}return s===0?NaN:n/s}}function yl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i<0||i>=n){t.warn(`Column index ${i} is out of bounds, matrix has ${n} columns.`,"matrix.col");const o=r>0?Ge(e.matrix[0][0]):"float";return new B([],o,t)}const s=[];for(let o=0;o<r;o++)s.push(e.matrix[o][i]);const a=Ge(s[0]);return new B(s,a,t)}}function _l(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function gl(t){return(e,i)=>{const r=e.matrix.length,n=i.matrix.length;if(r===0){for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]]);return}const s=e.matrix[0].length,a=n>0?i.matrix[0].length:0;if(s!==a&&n>0){console.error(`matrix.concat: Column count mismatch ${s} vs ${a}`);return}for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]])}}function xl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,n=new Z(i,r,NaN,t);return n.matrix=e.matrix.map(s=>[...s]),n}}function bl(t){const e=t.length;if(e===0)return 0;if(e===1)return t[0][0];if(e===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];const i=t.map(n=>[...n]);let r=1;for(let n=0;n<e;n++){let s=n;for(;s<e&&i[s][n]===0;)s++;if(s===e)return 0;s!==n&&([i[n],i[s]]=[i[s],i[n]],r*=-1),r*=i[n][n];for(let a=n+1;a<e;a++){const o=i[a][n]/i[n][n];for(let l=n;l<e;l++)i[a][l]-=o*i[n][l]}}return r}function vl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:bl(e.matrix)}}function wl(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new Z(0,0,NaN,t);const n=e.matrix[0].length,s=new Z(r,n,NaN,t);if(i instanceof Z)for(let a=0;a<r;a++)for(let o=0;o<n;o++){const l=e.matrix[a][o],c=i.matrix[a]&&i.matrix[a][o]!==void 0?i.matrix[a][o]:NaN;s.matrix[a][o]=l-c}else{const a=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]-a}return s}}function Sl(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],n=t[1][0],s=t[1][1],a=i+s,o=i*s-r*n,l=a*a-4*o;if(l<0)return[NaN,NaN];const c=(a+Math.sqrt(l))/2,u=(a-Math.sqrt(l))/2;return[c,u]}function El(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const a=Ge(e.matrix[0][0]);return new B([],a,t)}const n=Sl(e.matrix),s=Ge(n[0]);return new B(n,s,t)}}function Nl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new Z(0,0,NaN,t);const n=new Z(i,r,0,t);for(let s=0;s<i;s++)n.matrix[s][s]=1;return n}}function Cl(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function Il(t){return(e,i,r,n,s,a)=>{const o=e.matrix.length;if(o===0)return;const l=e.matrix[0].length,c=r!==void 0?r:0,u=n!==void 0?n:o,p=s!==void 0?s:0,h=a!==void 0?a:l;for(let f=c;f<u&&!(f>=o);f++)for(let d=p;d<h&&!(d>=l);d++)e.matrix[f][d]=i}}function kl(t){return(e,i,r)=>{const n=e.matrix.length,s=n>0?e.matrix[0].length:0;if(i<0||i>=n)return t.warn(`Row index ${i} is out of bounds, matrix has ${n} rows.`,"matrix.get"),NaN;if(r<0||r>=s)return t.warn(`Column index ${r} is out of bounds, matrix has ${s} columns.`,"matrix.get"),NaN;const a=e.matrix[i][r];return a===void 0?NaN:a}}function Ri(t){const e=t.length;if(e===0)return[];const i=new Array(e);for(let n=0;n<e;n++){i[n]=new Array(2*e);for(let s=0;s<e;s++)i[n][s]=t[n][s];for(let s=0;s<e;s++)i[n][e+s]=n===s?1:0}for(let n=0;n<e;n++){let s=Math.abs(i[n][n]),a=n;for(let l=n+1;l<e;l++){const c=Math.abs(i[l][n]);c>s&&(s=c,a=l)}if(s<1e-14)return t.map(l=>l.map(()=>NaN));if(a!==n){const l=i[n];i[n]=i[a],i[a]=l}const o=i[n][n];for(let l=n;l<2*e;l++)i[n][l]/=o;for(let l=0;l<e;l++){if(l===n)continue;const c=i[l][n];if(c!==0)for(let u=n;u<2*e;u++)i[l][u]-=c*i[n][u]}}const r=new Array(e);for(let n=0;n<e;n++){r[n]=new Array(e);for(let s=0;s<e;s++)r[n][s]=i[n][e+s]}return r}function Tl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new Z(i,r,NaN,t);const n=Ri(e.matrix),s=new Z(i,r,NaN,t);return s.matrix=n,s}}function Al(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(n+s!==i-1&&e.matrix[n][s]!==0)return!1;return!0}}function Pl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(e.matrix[s][n]!==-e.matrix[n][s])return!1;return!0}}function Dl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let s=0;s<r;s++){const a=e.matrix[n][s];if(a!==0&&a!==1)return!1}return!0}}function Ml(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(n!==s&&e.matrix[n][s]!==0)return!1;return!0}}function Rl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(n===s){if(e.matrix[n][s]!==1)return!1}else if(e.matrix[n][s]!==0)return!1;return!0}}function Ol(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function $l(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++){let s=0;for(let a=0;a<r;a++){const o=e.matrix[n][a];if(o<0)return!1;s+=o}if(Math.abs(s-1)>1e-10)return!1}return!0}}function Vl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<n;s++)if(e.matrix[n][s]!==e.matrix[s][n])return!1;return!0}}function jl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;let n=!0,s=!0;for(let a=0;a<i;a++)for(let o=0;o<r;o++)a>o&&e.matrix[a][o]!==0&&(n=!1),a<o&&e.matrix[a][o]!==0&&(s=!1);return n||s}}function Ll(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(e.matrix[n][s]!==0)return!1;return!0}}function Bl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0,s=i.matrix.length,a=s>0?i.matrix[0].length:0,o=r*s,l=n*a,c=new Z(o,l,NaN,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){const h=e.matrix[u][p];for(let f=0;f<s;f++)for(let d=0;d<a;d++){const m=i.matrix[f][d];c.matrix[u*s+f][p*a+d]=h*m}}return c}}function Fl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=-1/0,s=!1;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||(l>n&&(n=l),s=!0)}return s?n:NaN}}function Wl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=[];for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||n.push(l)}if(n.length===0)return NaN;n.sort((a,o)=>a-o);const s=Math.floor(n.length/2);return n.length%2!==0?n[s]:(n[s-1]+n[s])/2}}function Ul(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=1/0,s=!1;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||(l<n&&(n=l),s=!0)}return s?n:NaN}}function ql(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=new Map;let s=0,a=NaN;for(let o=0;o<i;o++)for(let l=0;l<r;l++){const c=e.matrix[o][l];if(!isNaN(c)){const u=(n.get(c)||0)+1;n.set(c,u),u>s?(s=u,a=c):u===s&&c<a&&(a=c)}}return a}}function zl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i instanceof Z){const s=i.matrix.length,a=s>0?i.matrix[0].length:0;if(n!==s)return new Z(0,0,NaN,t);const o=new Z(r,a,0,t);for(let l=0;l<r;l++)for(let c=0;c<a;c++){let u=0;for(let p=0;p<n;p++)u+=e.matrix[l][p]*i.matrix[p][c];o.matrix[l][c]=u}return o}else if(i instanceof B||Array.isArray(i.array||i)){const s=i.array||i;if(n!==s.length)return new B([],"float",t);const a=[];for(let o=0;o<r;o++){let l=0;for(let c=0;c<n;c++)l+=e.matrix[o][c]*s[c];a.push(l)}return new B(a,"float",t)}else{const s=i,a=new Z(r,n,NaN,t);for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]*s;return a}}}function Kl(t){return e=>{const i=e.matrix.length;if(i===0)return new Z(0,0,NaN,t);const r=e.matrix[0].length;if(i===r){const u=Ri(e.matrix),p=new Z(i,r,NaN,t);return p.matrix=u,p}const n=u=>{const p=u.length,h=u[0].length,f=new Array(h);for(let d=0;d<h;d++){f[d]=new Array(p);for(let m=0;m<p;m++)f[d][m]=u[m][d]}return f},s=(u,p)=>{const h=u.length,f=u[0].length,d=p[0].length,m=new Array(h);for(let x=0;x<h;x++){m[x]=new Array(d).fill(0);for(let b=0;b<f;b++){const v=u[x][b];if(v!==0)for(let w=0;w<d;w++)m[x][w]+=v*p[b][w]}}return m},a=e.matrix,o=n(a);let l;if(i>r){const u=s(o,a),p=Ri(u);l=s(p,o)}else{const u=s(a,o),p=Ri(u);l=s(o,p)}const c=new Z(r,i,NaN,t);return c.matrix=l,c}}function Hl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(r!==n)return new Z(0,0,NaN,t);let s=new Z(r,n,0,t);for(let l=0;l<r;l++)s.matrix[l][l]=1;let a=new Z(r,n,NaN,t);for(let l=0;l<r;l++)a.matrix[l]=[...e.matrix[l]];let o=Math.floor(i);if(o<0)return new Z(r,n,NaN,t);for(;o>0;){if(o%2===1){const c=new Z(r,n,0,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){let h=0;for(let f=0;f<r;f++)h+=s.matrix[u][f]*a.matrix[f][p];c.matrix[u][p]=h}s=c}const l=new Z(r,n,0,t);for(let c=0;c<r;c++)for(let u=0;u<n;u++){let p=0;for(let h=0;h<r;h++)p+=a.matrix[c][h]*a.matrix[h][u];l.matrix[c][u]=p}a=l,o=Math.floor(o/2)}return s}}function Gl(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=e.matrix.map(a=>[...a]);let s=0;for(let a=0;a<r&&s<i;a++){let o=s;for(;o<i&&Math.abs(n[o][a])<1e-10;)o++;if(o<i){[n[s],n[o]]=[n[o],n[s]];const l=n[s][a];for(let c=a;c<r;c++)n[s][c]/=l;for(let c=0;c<i;c++)if(c!==s){const u=n[c][a];for(let p=a;p<r;p++)n[c][p]-=u*n[s][p]}s++}}return s}}function Yl(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const a=Ge(e.matrix[0][0]);return new B([],a,t)}const n=[];for(let a=0;a<r;a++){const o=e.matrix[a].splice(i,1);n.push(o[0])}const s=Ge(n[0]);return new B(n,s,t)}}function Xl(t){return(e,i)=>{const r=e.matrix.splice(i,1),n=Ge(r[0][0]);return new B(r[0]||[],n,t)}}function Zl(t){return(e,i,r)=>{const n=e.matrix.length,s=n>0?e.matrix[0].length:0,a=i*r,o=[];for(let u=0;u<n;u++)for(let p=0;p<s;p++)o.push(e.matrix[u][p]);for(;o.length<a;)o.push(NaN);o.length>a&&(o.length=a);const l=[];let c=0;for(let u=0;u<i;u++){const p=[];for(let h=0;h<r;h++)p.push(o[c++]);l.push(p)}e.matrix=l}}function Ql(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function Jl(t){return(e,i)=>{const r=e.matrix.length;if(i<0||i>=r){t.warn(`Row index ${i} is out of bounds, matrix has ${r} rows.`,"matrix.row");const s=r>0?Ge(e.matrix[0][0]):"float";return new B([],s,t)}const n=Ge(e.matrix[i][0]);return new B([...e.matrix[i]],n,t)}}function ec(t){return e=>e.matrix.length}function tc(t){return(e,i,r,n)=>{const s=e.matrix.length,a=s>0?e.matrix[0].length:0;if(i<0||i>=s){t.warn(`Row index ${i} is out of bounds, matrix has ${s} rows.`,"matrix.set");return}if(r<0||r>=a){t.warn(`Column index ${r} is out of bounds, matrix has ${a} columns.`,"matrix.set");return}e.matrix[i][r]=n}}function ic(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((n,s)=>{const a=n[i],o=s[i];return a<o?r==="asc"?-1:1:a>o?r==="asc"?1:-1:0})}}function rc(t){return(e,i,r,n,s)=>{const a=r-i,o=s-n,l=new Z(a,o,NaN,t);for(let c=0;c<a;c++){const u=i+c;if(u>=e.matrix.length)break;for(let p=0;p<o;p++){const h=n+p;if(h>=e.matrix[u].length)break;l.matrix[c][p]=e.matrix[u][h]}}return l}}function nc(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new Z(0,0,NaN,t);const n=e.matrix[0].length,s=new Z(r,n,NaN,t);if(i instanceof Z)for(let a=0;a<r;a++)for(let o=0;o<n;o++){const l=e.matrix[a][o],c=i.matrix[a]&&i.matrix[a][o]!==void 0?i.matrix[a][o]:NaN;s.matrix[a][o]=l+c}else{const a=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]+a}return s}}function sc(t){return(e,i,r)=>{const n=e.matrix.length;for(let s=0;s<n;s++){const a=e.matrix[s][i];e.matrix[s][i]=e.matrix[s][r],e.matrix[s][r]=a}}}function ac(t){return(e,i,r)=>{const n=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=n}}function oc(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=Math.min(i,r);let s=0;for(let a=0;a<n;a++)s+=e.matrix[a][a];return s}}function lc(t){return e=>{const i=e.matrix.length;if(i===0)return new Z(0,0,NaN,t);const r=e.matrix[0].length,n=new Z(r,i,NaN,t);for(let s=0;s<i;s++)for(let a=0;a<r;a++)n.matrix[a][s]=e.matrix[s][a];return n}}var cc=Object.defineProperty,uc=(t,e,i)=>e in t?cc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,V=(t,e,i)=>uc(t,typeof e!="symbol"?e+"":e,i);class Z{constructor(e=0,i=0,r=NaN,n){if(this.context=n,V(this,"matrix"),V(this,"_add_col"),V(this,"_add_row"),V(this,"_avg"),V(this,"_col"),V(this,"_columns"),V(this,"_concat"),V(this,"_copy"),V(this,"_det"),V(this,"_diff"),V(this,"_eigenvalues"),V(this,"_eigenvectors"),V(this,"_elements_count"),V(this,"_fill"),V(this,"_get"),V(this,"_inv"),V(this,"_is_antidiagonal"),V(this,"_is_antisymmetric"),V(this,"_is_binary"),V(this,"_is_diagonal"),V(this,"_is_identity"),V(this,"_is_square"),V(this,"_is_stochastic"),V(this,"_is_symmetric"),V(this,"_is_triangular"),V(this,"_is_zero"),V(this,"_kron"),V(this,"_max"),V(this,"_median"),V(this,"_min"),V(this,"_mode"),V(this,"_mult"),V(this,"_pinv"),V(this,"_pow"),V(this,"_rank"),V(this,"_remove_col"),V(this,"_remove_row"),V(this,"_reshape"),V(this,"_reverse"),V(this,"_row"),V(this,"_rows"),V(this,"_set"),V(this,"_sort"),V(this,"_submatrix"),V(this,"_sum"),V(this,"_swap_columns"),V(this,"_swap_rows"),V(this,"_trace"),V(this,"_transpose"),this.matrix=[],e>0&&i>0)for(let s=0;s<e;s++)this.matrix.push(Array(i).fill(r));this._add_col=fl(this.context),this._add_row=dl(this.context),this._avg=ml(this.context),this._col=yl(this.context),this._columns=_l(this.context),this._concat=gl(this.context),this._copy=xl(this.context),this._det=vl(this.context),this._diff=wl(this.context),this._eigenvalues=El(this.context),this._eigenvectors=Nl(this.context),this._elements_count=Cl(this.context),this._fill=Il(this.context),this._get=kl(this.context),this._inv=Tl(this.context),this._is_antidiagonal=Al(this.context),this._is_antisymmetric=Pl(this.context),this._is_binary=Dl(this.context),this._is_diagonal=Ml(this.context),this._is_identity=Rl(this.context),this._is_square=Ol(this.context),this._is_stochastic=$l(this.context),this._is_symmetric=Vl(this.context),this._is_triangular=jl(this.context),this._is_zero=Ll(this.context),this._kron=Bl(this.context),this._max=Fl(this.context),this._median=Wl(this.context),this._min=Ul(this.context),this._mode=ql(this.context),this._mult=zl(this.context),this._pinv=Kl(this.context),this._pow=Hl(this.context),this._rank=Gl(this.context),this._remove_col=Yl(this.context),this._remove_row=Xl(this.context),this._reshape=Zl(this.context),this._reverse=Ql(this.context),this._row=Jl(this.context),this._rows=ec(this.context),this._set=tc(this.context),this._sort=ic(this.context),this._submatrix=rc(this.context),this._sum=nc(this.context),this._swap_columns=sc(this.context),this._swap_rows=ac(this.context),this._trace=oc(this.context),this._transpose=lc(this.context)}toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
|
|
2
|
-
`,e+="["+this.matrix[i].join(", ")+"]";return e}add_col(...e){return this._add_col(this,...e)}add_row(...e){return this._add_row(this,...e)}avg(...e){return this._avg(this,...e)}col(...e){return this._col(this,...e)}columns(...e){return this._columns(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}det(...e){return this._det(this,...e)}diff(...e){return this._diff(this,...e)}eigenvalues(...e){return this._eigenvalues(this,...e)}eigenvectors(...e){return this._eigenvectors(this,...e)}elements_count(...e){return this._elements_count(this,...e)}fill(...e){return this._fill(this,...e)}get(...e){return this._get(this,...e)}inv(...e){return this._inv(this,...e)}is_antidiagonal(...e){return this._is_antidiagonal(this,...e)}is_antisymmetric(...e){return this._is_antisymmetric(this,...e)}is_binary(...e){return this._is_binary(this,...e)}is_diagonal(...e){return this._is_diagonal(this,...e)}is_identity(...e){return this._is_identity(this,...e)}is_square(...e){return this._is_square(this,...e)}is_stochastic(...e){return this._is_stochastic(this,...e)}is_symmetric(...e){return this._is_symmetric(this,...e)}is_triangular(...e){return this._is_triangular(this,...e)}is_zero(...e){return this._is_zero(this,...e)}kron(...e){return this._kron(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}mult(...e){return this._mult(this,...e)}pinv(...e){return this._pinv(this,...e)}pow(...e){return this._pow(this,...e)}rank(...e){return this._rank(this,...e)}remove_col(...e){return this._remove_col(this,...e)}remove_row(...e){return this._remove_row(this,...e)}reshape(...e){return this._reshape(this,...e)}reverse(...e){return this._reverse(this,...e)}row(...e){return this._row(this,...e)}rows(...e){return this._rows(this,...e)}set(...e){return this._set(this,...e)}sort(...e){return this._sort(this,...e)}submatrix(...e){return this._submatrix(this,...e)}sum(...e){return this._sum(this,...e)}swap_columns(...e){return this._swap_columns(this,...e)}swap_rows(...e){return this._swap_rows(this,...e)}trace(...e){return this._trace(this,...e)}transpose(...e){return this._transpose(this,...e)}}function Qe(t){return(e,i,r)=>new Z(e,i,r,t)}function hc(t){return(e,i=0)=>y.from(e).get(i)}class pc{constructor(e){this.context=e,this.add_col=(i,...r)=>i.add_col(...r),this.add_row=(i,...r)=>i.add_row(...r),this.avg=(i,...r)=>i.avg(...r),this.col=(i,...r)=>i.col(...r),this.columns=(i,...r)=>i.columns(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.det=(i,...r)=>i.det(...r),this.diff=(i,...r)=>i.diff(...r),this.eigenvalues=(i,...r)=>i.eigenvalues(...r),this.eigenvectors=(i,...r)=>i.eigenvectors(...r),this.elements_count=(i,...r)=>i.elements_count(...r),this.fill=(i,...r)=>i.fill(...r),this.get=(i,...r)=>i.get(...r),this.inv=(i,...r)=>i.inv(...r),this.is_antidiagonal=(i,...r)=>i.is_antidiagonal(...r),this.is_antisymmetric=(i,...r)=>i.is_antisymmetric(...r),this.is_binary=(i,...r)=>i.is_binary(...r),this.is_diagonal=(i,...r)=>i.is_diagonal(...r),this.is_identity=(i,...r)=>i.is_identity(...r),this.is_square=(i,...r)=>i.is_square(...r),this.is_stochastic=(i,...r)=>i.is_stochastic(...r),this.is_symmetric=(i,...r)=>i.is_symmetric(...r),this.is_triangular=(i,...r)=>i.is_triangular(...r),this.is_zero=(i,...r)=>i.is_zero(...r),this.kron=(i,...r)=>i.kron(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.mult=(i,...r)=>i.mult(...r),this.new=Qe(e),this.param=hc(),this.pinv=(i,...r)=>i.pinv(...r),this.pow=(i,...r)=>i.pow(...r),this.rank=(i,...r)=>i.rank(...r),this.remove_col=(i,...r)=>i.remove_col(...r),this.remove_row=(i,...r)=>i.remove_row(...r),this.reshape=(i,...r)=>i.reshape(...r),this.reverse=(i,...r)=>i.reverse(...r),this.row=(i,...r)=>i.row(...r),this.rows=(i,...r)=>i.rows(...r),this.set=(i,...r)=>i.set(...r),this.sort=(i,...r)=>i.sort(...r),this.submatrix=(i,...r)=>i.submatrix(...r),this.sum=(i,...r)=>i.sum(...r),this.swap_columns=(i,...r)=>i.swap_columns(...r),this.swap_rows=(i,...r)=>i.swap_rows(...r),this.trace=(i,...r)=>i.trace(...r),this.transpose=(i,...r)=>i.transpose(...r),this.new_float=Qe(e),this.new_int=Qe(e),this.new_string=Qe(e),this.new_bool=Qe(e),this.new_color=Qe(e),this.new_line=Qe(e),this.new_label=Qe(e),this.new_box=Qe(e),this.new_linefill=Qe(e),this.new_table=Qe(e)}}var fc=Object.defineProperty,dc=(t,e,i)=>e in t?fc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,mc=(t,e,i)=>dc(t,typeof e!="symbol"?e+"":e,i);class yc{constructor(e){this.context=e,mc(this,"_live",!1)}setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.length-1}get isfirst(){return this.context.idx===0}get ishistory(){return this.context.idx<this.context.length-1}get isrealtime(){return this.context.idx===this.context.length-1}get isconfirmed(){return this.context.data.closeTime.data[this.context.idx]<=Date.now()}get islastconfirmedhistory(){const e=this.context.idx,i=this.context.length;if(e===i-1)return this.context.data.closeTime.data[e]<=Date.now();if(e===i-2){const r=this.context.marketData?.[i-1]?.closeTime;return r!==void 0?r>Date.now():!1}return!1}}var _c=Object.defineProperty,gc=(t,e,i)=>e in t?_c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xc=(t,e,i)=>gc(t,typeof e!="symbol"?e+"":e,i);class It{constructor(e,i,r){this._definition=e,this.context=i,xc(this,"_udt");for(let n in e)this[n]=e[n];this._udt=r}get __def__(){return this._definition}copy(){return new It(this.__def__,this.context,this._udt)}toString(){const e={};for(let i in this.__def__){const r=this[i];r!=null&&typeof r=="object"&&typeof r.toString=="function"&&!(r instanceof Array)?e[i]=r.toString():e[i]=r}try{return JSON.stringify(e)}catch{return"{"+Object.keys(e).map(i=>`"${i}":${String(e[i])}`).join(",")+"}"}}}var bc=Object.defineProperty,vc=(t,e,i)=>e in t?bc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,cr=(t,e,i)=>vc(t,typeof e!="symbol"?e+"":e,i);class Ie{constructor(e,i,r){cr(this,"time"),cr(this,"index"),cr(this,"price"),this.time=e,this.index=i,this.price=r}copy(){return new Ie(this.time,this.index,this.price)}toString(){return JSON.stringify({time:this.time,index:this.index,price:this.price})}}function wc(t){return typeof t=="object"&&t&&(t.title!==void 0||t._plotKey!==void 0)&&t.data!==void 0&&t.options!==void 0}const on={series:t=>t instanceof y||typeof t=="number"||typeof t=="string"||typeof t=="boolean",string:t=>typeof t=="string",color:t=>typeof t=="string"||t===null||typeof t=="number"&&isNaN(t)||t instanceof y,number:t=>typeof t=="number",boolean:t=>typeof t=="boolean",array:t=>Array.isArray(t),object:t=>typeof t=="object",point:t=>t instanceof Ie,primitive:t=>typeof t===null||typeof t!="object"&&typeof t!="function",function:t=>typeof t=="function",undefined:t=>t===void 0,null:t=>t===null,NaN:t=>isNaN(t),any:()=>!0,remaining_options:t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof y)&&!(t instanceof Ie)&&!wc(t)};function et(t){const e=t[t.length-1];if(e&&typeof e=="object"&&"__callsiteId"in e)return t.pop().__callsiteId}function te(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const n={};let s={};const a=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const l=t[o];if(on.remaining_options(l)){s=l;break}const c=e.map((u,p)=>a[p]?u[o]:void 0);for(let u=0;u<c.length;u++){const p=c[u];if(p===void 0){a[u]=!1;continue}const h=i[p];if(typeof l=="number"&&isNaN(l)&&(h==="number"||h==="series"))n[p]=l;else{const f=on[i[p]];typeof f=="function"&&f(l)?n[p]=l:a[u]=!1}}}return{...n,...s,...r}}function C(t,e,i){const r=i.value;return typeof r!="function"||(i.value=function(...n){return this&&this.context&&this.context.isSecondaryContext?null:r.apply(this,n)}),i}var Ns=Object.defineProperty,Sc=Object.getOwnPropertyDescriptor,Ec=(t,e,i)=>e in t?Ns(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Cs=(t,e,i,r)=>{for(var n=r>1?void 0:r?Sc(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Ns(e,i,n),n},Jt=(t,e,i)=>Ec(t,typeof e!="symbol"?e+"":e,i);const Nc=[["dateString"],["year","month","day","hour","minute","second"],["timezone","year","month","day","hour","minute","second"]],Cc={dateString:"string",timezone:"string",year:"number",month:"number",day:"number",hour:"number",minute:"number",second:"number"},Ic=["title","shorttitle","overlay","format","precision","scale","max_bars_back","timeframe","timeframe_gaps","explicit_plot_zorder","max_lines_count","max_labels_count","max_boxes_count","calc_bars_count","max_polylines_count","dynamic_requests","behind_chart"],kc={title:"string",shorttitle:"string",overlay:"boolean",format:"string",precision:"number",scale:"string",max_bars_back:"number",timeframe:"string",timeframe_gaps:"boolean",explicit_plot_zorder:"boolean",max_lines_count:"number",max_labels_count:"number",max_boxes_count:"number",calc_bars_count:"number",max_polylines_count:"number",dynamic_requests:"boolean",behind_chart:"boolean"};function Tc(t){return te(t,Ic,kc)}class Re{get __value(){return NaN}param(e,i=0){return y.from(e).get(i)}any(e){if(e instanceof Re)return!0;const i=y.from(e).get(0);return i instanceof Re||i==null?!0:typeof i=="number"?i!==i:!1}}const qt={freq_all:"alert.freq_all",freq_once_per_bar:"alert.freq_once_per_bar",freq_once_per_bar_close:"alert.freq_once_per_bar_close"};class Is{constructor(e){this.context=e,Jt(this,"_firedKeys",new Set),Jt(this,"_fallbackCounter",0),Jt(this,"_fallbackLastExecTick",-1)}get freq_all(){return qt.freq_all}get freq_once_per_bar(){return qt.freq_once_per_bar}get freq_once_per_bar_close(){return qt.freq_once_per_bar_close}param(e,i,r){return y.from(e).get(0)}any(e,i,r){const n=y.from(e).get(0),s=i?y.from(i).get(0):qt.freq_once_per_bar;let a;if(r&&typeof r=="object"&&r.__callsiteId)a=r.__callsiteId;else{const u=this.context._execTick||0;u!==this._fallbackLastExecTick&&(this._fallbackCounter=0,this._fallbackLastExecTick=u),a=`alert_${this._fallbackCounter++}`}const o=this.context.idx,l=this.context.pine?.barstate?.isrealtime??o===this.context.length-1;if((this.context._alertMode||"realtime")==="realtime"&&!l)return;const c=`${a}:${o}`;if(s===qt.freq_once_per_bar){if(this._firedKeys.has(c))return;this._firedKeys.add(c)}else if(s===qt.freq_once_per_bar_close){if(!(this.context.pine?.barstate?.isconfirmed??!0)||this._firedKeys.has(c))return;this._firedKeys.add(c)}this.context.alerts.push({type:"alert",id:a,message:n,freq:s,bar_index:o,time:this.context.data.openTime?.data?.[o]??0})}}Cs([C],Is.prototype,"any",1);class ks{constructor(e){this.context=e,Jt(this,"_acCounter",0),Jt(this,"_acLastExecTick",-1),Jt(this,"_acFiredKeys",new Set)}extractPlotOptions(e){const i={};for(let r in e)i[r]=y.from(e[r]).get(0);return i}indicator(...e){const i=e.map(s=>s instanceof y?s.get(0):s),r=Tc(i),n={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"points",max_bars_back:0,timeframe:"",timeframe_gaps:!0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,max_polylines_count:50,dynamic_requests:!1,behind_chart:!0};return this.context.indicator={...n,...r,...this.context._propOverrides??{}},this.context.indicator}get bar_index(){return this.context.idx}na(e){const i=y.from(e).get(0);return i==null||typeof i=="number"&&isNaN(i)}nz(e,i=0){const r=y.from(e).get(0),n=y.from(i).get(0);return r==null||typeof r=="number"&&isNaN(r)?n:r}fixnan(e){const i=y.from(e);for(let r=0;r<i.length;r++){const n=i.get(r);if(!isNaN(n))return n}return NaN}alertcondition(e,i,r){const n=y.from(e).get(0),s=this.context.idx,a=this.context._execTick||0;a!==this._acLastExecTick&&(this._acCounter=0,this._acLastExecTick=a);const o=`alertcondition_${this._acCounter++}`;if(!n)return;const l=this.context.pine?.barstate?.isrealtime??s===this.context.length-1;if((this.context._alertMode||"realtime")==="realtime"&&!l)return;const c=`${o}:${s}`;if(this._acFiredKeys.has(c))return;this._acFiredKeys.add(c);const u=i?y.from(i).get(0):"",p=r?y.from(r).get(0):"";this.context.alerts.push({type:"alertcondition",id:o,title:u,message:p,bar_index:s,time:this.context.data.openTime?.data?.[s]??0})}error(...e){console.error("error called but is currently not implemented",e)}max_bars_back(e,i){}timestamp(...e){const i=e.map(n=>n instanceof y?n.get(0):n),r=te(i,Nc,Cc);if(r.year!==void 0){const n=r.year,s=r.month,a=r.day,o=r.hour||0,l=r.minute||0,c=r.second||0,u=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(u,n,s,a,o,l,c)}if(r.dateString!==void 0){const n=r.dateString.trim();if(/[Zz]$/.test(n)||/[+-]\d{2}:?\d{2}$/.test(n))return new Date(n).getTime();const s=n.includes("T")?n+"Z":n.replace(/\s+/,"T")+"Z",a=new Date(s);if(!isNaN(a.getTime())){const o=this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(o,a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds())}return new Date(n).getTime()}return NaN}_timestampFromComponents(e,i,r,n,s,a,o){const l=new Date(Date.UTC(i,r-1,n,s,a,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=e.trim();if(c==="UTC"||c==="GMT"||c==="Etc/UTC")return l.getTime();const u=c.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(u){const p=u[1]==="+"?1:-1,h=parseInt(u[2],10),f=parseInt(u[3]||"0",10),d=p*(h*60+f)*60*1e3;return l.getTime()-d}try{return this._timestampFromIANA(e,i,r,n,s,a,o)}catch{return l.getTime()}}_timestampFromIANA(e,i,r,n,s,a,o){const l=new Date(Date.UTC(i,r-1,n,s,a,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(l),u=w=>parseInt(c.find(E=>E.type===w)?.value||"0",10),p=u("year"),h=u("month"),f=u("day");let d=u("hour");d===24&&(d=0);const m=u("minute"),x=u("second"),b=new Date(Date.UTC(p,h-1,f,d,m,x));p>=0&&p<100&&b.setUTCFullYear(p);const v=b.getTime()-l.getTime();return l.getTime()-v}bool(e){const i=y.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=y.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "int" with argument "x"="${i}". An argument of "literal string" type was used but a "simple int" is expected.`);return Math.trunc(i)}float(e){const i=y.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "float" with argument "x"="${i}". An argument of "literal string" type was used but a "const float" is expected.`);return i}string(e){return y.from(e).get(0).toString()}Type(e){const i=Object.keys(e),r={};for(const s of i){let a=e[s];a instanceof y&&(a=a.data),Array.isArray(a)&&(a[0],r[s]=a[1])}const n={new:function(...s){const a={};let o=null;if(s.length>0){const l=s[s.length-1];if(l&&typeof l=="object"&&!(l instanceof y)&&!Array.isArray(l)&&!(l instanceof It)){const c=Object.keys(l);c.length>0&&c.some(u=>i.includes(u))&&(o=l,s=s.slice(0,-1))}}for(let l=0;l<i.length;l++){const c=i[l];o&&c in o?a[c]=o[c]:l<s.length?a[c]=s[l]:c in r&&(a[c]=y.from(r[c]).get(0))}return new It(a,this.context,n)},copy:function(s){return new It(s.__def__,this.context,n)},_fieldDefaults:r,_definitionKeys:i};return n}}Cs([C],ks.prototype,"alertcondition",1);function zt(t){if(!t||typeof t!="string")return null;if(t.startsWith("#")){const i=t.slice(1);return i.length===6?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),1]:i.length===8?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),parseInt(i.slice(6,8),16)/255]:null}const e=t.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)/);return e?[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),e[4]?parseFloat(e[4]):1]:null}function Ac(t,e,i,r){const n=Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0"),s=Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0"),a=Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");if(r>=1)return`#${n}${s}${a}`.toUpperCase();const o=Math.round(Math.max(0,Math.min(255,r*255))).toString(16).padStart(2,"0");return`#${n}${s}${a}${o}`.toUpperCase()}const de={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#F23645",silver:"#B2B5BE",teal:"#089981",white:"#FFFFFF",yellow:"#FDD835"};function rt(t){return typeof t=="function"&&(t=t()),t&&typeof t=="object"&&Array.isArray(t.data)&&typeof t.get=="function"&&(t=t.get(0)),t}class Pc{constructor(e){this.context=e}any(e){const i=y.from(e).get(0);return typeof i=="number"&&isNaN(i)?null:i}param(e,i=0){return y.from(e).get(i)}new(e,i){if(e=rt(e),!e||typeof e!="string")return e;if(typeof i=="number"&&isNaN(i)&&(i=void 0),e.startsWith("#")){const r=e.slice(1),n=r.length===8?r.slice(0,6):r;return i!=null?`#${n}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`}else{const r=de[e];if(r)return i!=null?`#${r.slice(1)}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:r;const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(n){const s=n[1],a=n[2],o=n[3];if(i!=null){const l=parseInt(s).toString(16).padStart(2,"0"),c=parseInt(a).toString(16).padStart(2,"0"),u=parseInt(o).toString(16).padStart(2,"0"),p=Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase();return`#${l}${c}${u}${p}`}return e}return i!=null?`rgba(${e}, ${(100-i)/100})`:e}}rgb(e,i,r,n){return typeof n=="number"&&isNaN(n)&&(n=void 0),n!=null?`rgba(${e}, ${i}, ${r}, ${(100-n)/100})`:`rgb(${e}, ${i}, ${r})`}from_gradient(e,i,r,n,s){if(e=rt(e),i=rt(i),r=rt(r),n=rt(n),s=rt(s),e==null||typeof e=="number"&&isNaN(e)||i==null||typeof i=="number"&&isNaN(i)||r==null||typeof r=="number"&&isNaN(r)||n==null||typeof n=="number"&&isNaN(n)||s==null||typeof s=="number"&&isNaN(s))return;let a=0;r!==i&&(a=(e-i)/(r-i)),a=Math.max(0,Math.min(1,a));const o=zt(typeof n=="string"?n:"#000000")||[0,0,0,1],l=zt(typeof s=="string"?s:"#FFFFFF")||[255,255,255,1],c=o[0]+(l[0]-o[0])*a,u=o[1]+(l[1]-o[1])*a,p=o[2]+(l[2]-o[2])*a,h=o[3]+(l[3]-o[3])*a;return Ac(c,u,p,h)}r(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?i[0]:NaN}g(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?i[1]:NaN}b(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?i[2]:NaN}t(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?Math.round(100-i[3]*100):NaN}aqua(){return de.aqua}black(){return de.black}blue(){return de.blue}fuchsia(){return de.fuchsia}gray(){return de.gray}green(){return de.green}lime(){return de.lime}maroon(){return de.maroon}navy(){return de.navy}olive(){return de.olive}orange(){return de.orange}purple(){return de.purple}red(){return de.red}silver(){return de.silver}teal(){return de.teal}white(){return de.white}yellow(){return de.yellow}}var Dc=Object.defineProperty,Mc=(t,e,i)=>e in t?Dc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Fi=(t,e,i)=>Mc(t,typeof e!="symbol"?e+"":e,i);function vr(t){if(!t)return"";const e=t.trim().toUpperCase();return e==="1D"||e==="D"?"D":e==="1W"||e==="W"?"W":e==="1M"||e==="M"?"M":e}function wr(t,e){const i=Rc(e);if(e==="M"){const o=new Date(t);return Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1)}if(e==="W"){const o=new Date(t),l=o.getUTCDay(),c=l===0?6:l-1;return Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()-c)}if(e==="D"||i>=1440)return Math.floor(t/864e5)*864e5;const r=i*6e4,n=Math.floor(t/864e5)*864e5,s=t-n,a=Math.floor(s/r)*r;return n+a}function Rc(t){if(t==="D")return 1440;if(t==="W")return 10080;if(t==="M")return 43200;const e=parseInt(t,10);return isNaN(e)?1440:e}function Rt(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"||i==="Etc/UTC"){const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const n=r[1]==="+"?1:-1,s=parseInt(r[2],10),a=parseInt(r[3]||"0",10),o=n*(s*60+a)*60*1e3,l=new Date(t+o);return{year:l.getUTCFullYear(),month:l.getUTCMonth()+1,day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),dayOfWeek:l.getUTCDay()}}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",weekday:"short",hour12:!1}).formatToParts(new Date(t)),s=c=>parseInt(n.find(u=>u.type===c)?.value||"0",10);let a=s("hour");a===24&&(a=0);const o=n.find(c=>c.type==="weekday")?.value||"Sun",l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:s("year"),month:s("month"),day:s("day"),hour:a,minute:s("minute"),second:s("second"),dayOfWeek:l[o]??0}}catch{const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}}function Oc(t,e,i){const r=new Date(Date.UTC(t,e-1,i)),n=r.getUTCDay()||7;r.setUTCDate(r.getUTCDate()+4-n);const s=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r.getTime()-s.getTime())/864e5+1)/7)}const $c=[["timeframe"],["timeframe","bars_back"],["timeframe","session","bars_back"],["timeframe","session","bars_back","timeframe_bars_back"],["timeframe","session","timezone","bars_back","timeframe_bars_back"]],Vc={timeframe:"string",session:"string",timezone:"string",bars_back:"number",timeframe_bars_back:"number"};class ln{constructor(e,i="openTime"){Fi(this,"context"),Fi(this,"dataField"),this.context=e,this.dataField=i}get __value(){return this.context.data[this.dataField]}param(e,i=0){return y.from(e).get(i)}any(...e){const i=e.map(h=>h instanceof y?h.get(0):h),r=te(i,$c,Vc),n=r.bars_back??0,s=r.timeframe||"",a=this.context.data[this.dataField],o=y.from(a).get(n);if(isNaN(o)||o==null)return NaN;const l=this.context.timeframe||"",c=vr(s),u=vr(l);let p;if(!c||c===u?p=o:p=wr(o,c),r.session!==void 0&&r.session!==""){const h=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._isInSession(p,r.session,h)?p:NaN}return p}_isInSession(e,i,r){const n=i.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);if(!n)return!0;const s=parseInt(n[1],10),a=parseInt(n[2],10),o=parseInt(n[3],10),l=parseInt(n[4],10),c=Rt(e,r),u=c.hour,p=c.minute,h=u*60+p,f=s*60+a,d=o*60+l;return f<=d?h>=f&&h<d:h>=f||h<d}}const jc=[[],["time"],["time","timezone"]],Lc={time:"number",timezone:"string"};class vt{constructor(e,i){Fi(this,"context"),Fi(this,"extractor"),this.context=e,this.extractor=i}get __value(){const e=y.from(this.context.data.openTime).get(0);if(isNaN(e))return NaN;const i=this.context.pine?.syminfo?.timezone||"UTC",r=Rt(e,i);return this.extractor(r)}param(e,i=0){return y.from(e).get(i)}any(...e){const i=e.map(o=>o instanceof y?o.get(0):o);if(i.length===0)return this.__value;const r=te(i,jc,Lc),n=r.time;if(n===void 0||isNaN(n))return NaN;const s=r.timezone||this.context.pine?.syminfo?.timezone||"UTC",a=Rt(n,s);return this.extractor(a)}}const wt={dayofmonth:t=>t.day,dayofweek:t=>t.dayOfWeek===0?1:t.dayOfWeek+1,hour:t=>t.hour,minute:t=>t.minute,month:t=>t.month,second:t=>t.second,weekofyear:t=>Oc(t.year,t.month,t.day),year:t=>t.year},Bc=[["defval","title","tooltip","inline","group","display"],["defval","title","tooltip","group","confirm","display"],["defval","title","tooltip","inline","group","confirm","display"],["defval","title","options","tooltip","inline","group","confirm","display"],["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display"]],Fc={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function $e(t){return te(t,Bc,Fc)}function Be(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function Wc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Uc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function qc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function zc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Kc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Hc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Gc(t){return(e,i=0)=>y.from(e).get(i)}function Yc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Xc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Zc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Qc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Jc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function eu(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function tu(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function iu(t){return(...e)=>$e(e).defval}var ru=Object.defineProperty,nu=(t,e,i)=>e in t?ru(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ne=(t,e,i)=>nu(t,typeof e!="symbol"?e+"":e,i);const su={any:Wc,bool:Uc,color:qc,enum:zc,float:Kc,int:Hc,param:Gc,price:Yc,session:Xc,source:Zc,string:Qc,symbol:Jc,text_area:eu,time:tu,timeframe:iu};class au{constructor(e){this.context=e,Ne(this,"any"),Ne(this,"bool"),Ne(this,"color"),Ne(this,"enum"),Ne(this,"float"),Ne(this,"int"),Ne(this,"param"),Ne(this,"price"),Ne(this,"session"),Ne(this,"source"),Ne(this,"string"),Ne(this,"symbol"),Ne(this,"text_area"),Ne(this,"time"),Ne(this,"timeframe"),Object.entries(su).forEach(([i,r])=>{this[i]=r(e)})}}function ou(t){return e=>Math.abs(y.from(e).get(0))}function lu(t){return e=>Math.acos(y.from(e).get(0))}function cu(t){return e=>Math.asin(y.from(e).get(0))}function uu(t){return e=>Math.atan(y.from(e).get(0))}function hu(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return i.reduce((r,n)=>r+n,0)/i.length}}function pu(t){return e=>Math.ceil(y.from(e).get(0))}function fu(t){return e=>Math.cos(y.from(e).get(0))}function du(t){return()=>Math.E}function mu(t){return e=>Math.exp(y.from(e).get(0))}function yu(t){return e=>Math.floor(y.from(e).get(0))}function _u(t){return e=>Math.log(y.from(e).get(0))}function gu(t){return e=>Math.log(y.from(e).get(0))}function xu(t){return e=>Math.log10(y.from(e).get(0))}function bu(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return Math.max(...i)}}function vu(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return Math.min(...i)}}function wu(t){return(e,i,r)=>typeof e=="string"?e:e instanceof y?i?new y(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new y(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new y(t.params[r],i||0)))}function Su(t){return()=>1.618033988749895}function Eu(t){return()=>Math.PI}function Nu(t){return(e,i)=>Math.pow(y.from(e).get(0),y.from(i).get(0))}function Cu(t){return()=>Math.random()}function ur(t){return t!==t?NaN:Math.sign(t)*Math.round(Math.abs(t))}function Iu(t){return(e,i)=>{const r=y.from(e).get(0);if(i==null)return ur(r);const n=y.from(i).get(0);if(n===0)return ur(r);const s=Math.pow(10,n);return ur(r*s)/s}}function ku(t){return e=>t.precision(Math.round(y.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function Tu(t){return()=>.6180339887498948}function Au(t){return e=>Math.sign(y.from(e).get(0))}function Pu(t){return e=>Math.sin(y.from(e).get(0))}function Du(t){return e=>Math.sqrt(y.from(e).get(0))}function Mu(t){return(e,i)=>{const r=y.from(i).get(0),n=y.from(e);let s=0;for(let a=0;a<r;a++){const o=n.get(a);s+=o}return s}}function Ru(t){return e=>Math.tan(y.from(e).get(0))}function Ou(t){return e=>{const i=y.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function $u(t){return e=>{const i=y.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function Vu(t){return(e,i)=>{const r=y.from(e).get(0),n=y.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)<1e-9:r===n}}function ju(t){return(e,i)=>{const r=y.from(e).get(0),n=y.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)>=1e-9:r!==n}}var Lu=Object.defineProperty,Bu=(t,e,i)=>e in t?Lu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,H=(t,e,i)=>Bu(t,typeof e!="symbol"?e+"":e,i);const Fu={abs:ou,acos:lu,asin:cu,atan:uu,avg:hu,ceil:pu,cos:fu,e:du,exp:mu,floor:yu,ln:_u,log:gu,log10:xu,max:bu,min:vu,param:wu,phi:Su,pi:Eu,pow:Nu,random:Cu,round:Iu,round_to_mintick:ku,rphi:Tu,sign:Au,sin:Pu,sqrt:Du,sum:Mu,tan:Ru,todegrees:Ou,toradians:$u,__eq:Vu,__neq:ju};class Wu{constructor(e){this.context=e,H(this,"_cache",{}),H(this,"abs"),H(this,"acos"),H(this,"asin"),H(this,"atan"),H(this,"avg"),H(this,"ceil"),H(this,"cos"),H(this,"e"),H(this,"exp"),H(this,"floor"),H(this,"ln"),H(this,"log"),H(this,"log10"),H(this,"max"),H(this,"min"),H(this,"param"),H(this,"phi"),H(this,"pi"),H(this,"pow"),H(this,"random"),H(this,"round"),H(this,"round_to_mintick"),H(this,"rphi"),H(this,"sign"),H(this,"sin"),H(this,"sqrt"),H(this,"sum"),H(this,"tan"),H(this,"todegrees"),H(this,"toradians"),H(this,"__eq"),H(this,"__neq"),Object.entries(Fu).forEach(([i,r])=>{this[i]=r(e)})}}function Uu(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let n;if(e instanceof y)n=e.get(i||0);else if(Array.isArray(e)){const s=e.some(o=>o instanceof y),a=e.every(o=>!(o instanceof y)&&!Array.isArray(o));(s||a)&&e.length>=1?n=e.map(o=>o instanceof y?o.get(0):o):n=y.from(e).get(i||0)}else n=e;return t.params[r].length===0?t.params[r].push(n):t.params[r][t.params[r].length-1]=n,t._requestParamSources||(t._requestParamSources={}),t._requestParamSources[r]=e,[n,r]}}const ii=["1","3","5","15","30","45","60","120","180","240","D","W","M"],Ci={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function Wi(t){if(ii.includes(t))return t;if(Ci[t])return Ci[t];const e=t.toLowerCase();if(Ci[e])return Ci[e];const i=t.toUpperCase();return ii.includes(i)?i:t}function cn(t,e,i,r,n=!1,s=!1){for(let a=0;a<i.length;a++)if(i[a]<=t&&t<r[a])return n||s||e>=r[a]?a:a-1;return-1}function un(t,e,i,r,n=!1,s,a=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const l=s&&e>s;if(a&&n)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}if(l&&n&&!a)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}return o}if(r[o]<t)break}return-1}const hn=[["symbol","timeframe","expression"],["symbol","timeframe","expression","gaps"],["symbol","timeframe","expression","gaps","lookahead"],["symbol","timeframe","expression","gaps","lookahead","ignore_invalid_symbol"],["symbol","timeframe","expression","gaps","lookahead","ignore_invalid_symbol","currency"],["symbol","timeframe","expression","gaps","lookahead","ignore_invalid_symbol","currency","calc_bars_count"]],qu={symbol:"series",timeframe:"series",expression:"any",gaps:"series",lookahead:"series",ignore_invalid_symbol:"series",currency:"series",calc_bars_count:"series"};function Lr(t){return Array.isArray(t)&&t.length===2&&typeof t[1]=="string"}function zu(t,e){return t.map(i=>Lr(i)?(e.push(i[1]),i[0]):(e.push(void 0),i))}function Kt(t){return Lr(t)?t[0]:t}function Ku(t,e,i,r){const n=e[e.length-1].indexOf(t);if(n>=0&&n<i.length&&i[n]!==void 0)return i[n];if(Lr(r))return r[1]}function Sr(t){return t==null||typeof t!="object"?t:"__value"in t?t.__value:t instanceof y?t.get(0):Array.isArray(t)?t.map(Sr):t}function Hu(t){return async(...e)=>{const i=[],r=zu(e,i),n=te(r,hn,qu),s=Kt(n.symbol),a=Kt(n.timeframe),o=Kt(n.expression),l=Kt(n.gaps),c=Kt(n.lookahead),u=s instanceof y?s.get(0):s,p=u===""?t.tickerId:u,h=typeof p=="string"&&p.includes(":")?p.split(":")[1]:p,f=a instanceof y?a.get(0):a,d=f===""?t.timeframe:typeof f=="string"?f:String(f??""),m=o,x=Ku("expression",hn,i,n.expression),b=l,v=c,w=b===!0||b==="gaps_on",E=v===!0||v==="lookahead_on",T=(()=>{const _e=Kt(n.calc_bars_count);return typeof _e=="number"&&_e>0?_e:void 0})();if(t.isSecondaryContext){const _e=Sr(m);return Array.isArray(_e)?[_e]:_e}const N=ii.indexOf(Wi(t.timeframe)),A=ii.indexOf(Wi(d));if(N==-1||A==-1)throw new Error("Invalid timeframe");const O=typeof t.tickerId=="string"&&t.tickerId.includes(":")?t.tickerId.split(":")[1]:t.tickerId;if(N===A&&(!h||h===""||h===O)){const _e=Sr(m);return Array.isArray(_e)?[_e]:_e}const k=N>A,U=y.from(t.data.openTime).get(0),R=y.from(t.data.closeTime).get(0),Y=t.idx===t.length-1&&R>Date.now(),$=`${h}_${d}_${x}`,q=`${$}_prevIdx`;if(t.cache[$]){const _e=t.cache[$];t.dataVersion>_e.dataVersion&&(await _e.pineTS.updateTail(_e.context),_e.dataVersion=t.dataVersion);const ai=_e.context,Ni=k?un(U,R,ai.data.openTime.data,ai.data.closeTime.data,E,t.eDate,w):cn(U,R,ai.data.openTime.data,ai.data.closeTime.data,E,Y);if(Ni==-1)return NaN;const Wt=ai.params[x][Ni];if(!k&&w){const an=t.cache[q];return an!==void 0&&an===Ni?NaN:(t.cache[q]=Ni,Array.isArray(Wt)?[Wt]:Wt)}return Array.isArray(Wt)?[Wt]:Wt}const Ae=1e3*60*60*24*30,fe=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),Fe=T?void 0:fe?fe-Ae:void 0,Ee=(t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0)||t.eDate||Date.now(),pt=new nn(t.source,h,d,T,Fe,Ee);pt.markAsSecondary();const Bt=typeof x=="string"?x:"",Fa=Bt.match(/p\d+$/)?.[0]??Bt,sn=t._ltfTruncatedBodies?.[Fa],Ft=sn?await pt.runPretranspiled(sn):await pt.run(t.pineTSCode);t.cache[$]={pineTS:pt,context:Ft,dataVersion:t.dataVersion};const or=k?un(U,R,Ft.data.openTime.data,Ft.data.closeTime.data,E,t.eDate,w):cn(U,R,Ft.data.openTime.data,Ft.data.closeTime.data,E,Y);if(or==-1)return NaN;const lr=Ft.params[x][or];return!k&&w?(t.cache[q]=or,NaN):Array.isArray(lr)?[lr]:lr}}const pn=[["symbol","timeframe","expression"],["symbol","timeframe","expression","ignore_invalid_symbol"],["symbol","timeframe","expression","ignore_invalid_symbol","currency"],["symbol","timeframe","expression","ignore_invalid_symbol","currency","ignore_invalid_timeframe"],["symbol","timeframe","expression","ignore_invalid_symbol","currency","ignore_invalid_timeframe","calc_bars_count"]],Gu={symbol:"series",timeframe:"series",expression:"any",ignore_invalid_symbol:"series",currency:"series",ignore_invalid_timeframe:"series",calc_bars_count:"series"};function Br(t){return Array.isArray(t)&&t.length===2&&typeof t[1]=="string"}function Yu(t,e){return t.map(i=>Br(i)?(e.push(i[1]),i[0]):(e.push(void 0),i))}function Ht(t){return Br(t)?t[0]:t}function Xu(t,e,i,r){const n=e[e.length-1].indexOf(t);if(n>=0&&n<i.length&&i[n]!==void 0)return i[n];if(Br(r))return r[1]}function Gt(t){return typeof t=="number"?j.float:typeof t=="boolean"?j.bool:typeof t=="string"?j.string:j.any}const Ts={open:t=>t.open,high:t=>t.high,low:t=>t.low,close:t=>t.close,volume:t=>t.volume,hl2:t=>(t.high+t.low)/2,hlc3:t=>(t.high+t.low+t.close)/3,ohlc4:t=>(t.high+t.low+t.open+t.close)/4,hlcc4:t=>(t.high+t.low+t.close+t.close)/4,time:t=>t.openTime,openTime:t=>t.openTime,closeTime:t=>t.closeTime};function Er(t,e){if(!(t instanceof y))return null;const i=e?.data;if(!i)return null;for(const r of Object.keys(Ts))if(t===i[r])return r;return null}function Zu(t,e){if(t instanceof y&&(t=t.get(0)),!(t instanceof It))return null;const i=t._udt;if(!i||!i._fieldDefaults||!Array.isArray(i._definitionKeys))return null;const r=i._definitionKeys;if(r.length===0)return null;const n=[];for(const s of r){if(!(s in i._fieldDefaults))return null;const a=i._fieldDefaults[s],o=Er(a,e);if(o===null)return null;n.push(o)}return{kind:"udt",builtinNames:n,fieldNames:r,udt:i}}function Qu(t,e){if(t===void 0)return null;if(Array.isArray(t)){const r=[];for(const n of t){const s=Er(n,e);if(s===null)return null;r.push(s)}return r.length>0?{kind:"tuple",builtinNames:r}:null}const i=Er(t,e);return i!==null?{kind:"series",builtinNames:[i]}:Zu(t,e)}async function fn(t,e,i,r,n,s){const a=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),o=(t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0)||t.eDate||Date.now(),l=new nn(t.source,e,i,r,a,o);l.markAsSecondary(),await l.ready();const c=l.openTime,u=l.closeTime,p=l.data,h=n.builtinNames.map(d=>Ts[d]);let f;if(n.kind==="series")f=p.map(d=>h[0](d));else if(n.kind==="tuple")f=p.map(d=>h.map(m=>m(d)));else{const d=n.fieldNames,m=n.udt;f=p.map(x=>{const b={};for(let v=0;v<d.length;v++)b[d[v]]=h[v](x);return new It(b,t,m)})}return{data:{openTime:{data:c},closeTime:{data:u}},params:{[s]:f}}}function Ju(t){return async(...e)=>{const i=[],r=Yu(e,i),n=te(r,pn,Gu),s=Ht(n.symbol),a=Ht(n.timeframe),o=Ht(n.expression),l=s instanceof y?s.get(0):s,c=l===""?t.tickerId:l,u=typeof c=="string"&&c.includes(":")?c.split(":")[1]:c,p=a instanceof y?a.get(0):a,h=p===""?t.timeframe:typeof p=="string"?p:String(p??""),f=o,d=Xu("expression",pn,i,n.expression);Ht(n.ignore_invalid_symbol);const m=Ht(n.ignore_invalid_timeframe),x=(()=>{const q=Ht(n.calc_bars_count);return typeof q=="number"&&q>0?q:void 0})();if(t.isSecondaryContext)return Array.isArray(f)?[f.map(q=>new B([q],Gt(q),t))]:new B([f],Gt(f),t);const b=ii.indexOf(Wi(t.timeframe)),v=ii.indexOf(Wi(h));if(b===-1||v===-1){if(m)return NaN;throw new Error("Invalid timeframe")}if(v>b){if(m)return NaN;throw new Error(`Timeframe ${h} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(v===b)return Array.isArray(f)?[f.map(q=>new B([q],Gt(q),t))]:new B([f],Gt(f),t);const w=`${u}_${h}_${d}_lower`,E=t._requestParamSources?.[d],T=Qu(E,t);if(!t.cache[w])if(T!==null){const q=await fn(t,u,h,x,T,d);t.cache[w]={pineTS:null,context:q,dataVersion:t.dataVersion,_fastPath:!0,_fastPathArgs:{builtinExpr:T}}}else{const q=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),Ae=(t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0)||t.eDate||Date.now(),fe=new nn(t.source,u,h,x,q,Ae);fe.markAsSecondary();const Fe=typeof d=="string"?d:"",Ee=Fe.match(/p\d+$/)?.[0]??Fe,pt=t._ltfTruncatedBodies?.[Ee];let Bt;pt?Bt=await fe.runPretranspiled(pt):Bt=await fe.run(t.pineTSCode),t.cache[w]={pineTS:fe,context:Bt,dataVersion:t.dataVersion}}const N=t.cache[w];if(t.dataVersion>N.dataVersion)if(N._fastPath){const q=await fn(t,u,h,x,N._fastPathArgs.builtinExpr,d);N.context=q,N.dataVersion=t.dataVersion}else await N.pineTS.updateTail(N.context),N.dataVersion=t.dataVersion;const A=N.context,O=y.from(t.data.openTime).get(0),k=y.from(t.data.closeTime).get(0),U=A.data.openTime.data,R=A.data.closeTime.data,Y=A.params[d];if(!Y)return Array.isArray(f)?[f.map(()=>new B([],j.float,t))]:new B([],j.float,t);const $=[];for(let q=0;q<U.length;q++){const Ae=U[q];if(!(R[q]<=O)){if(Ae>=k)break;Ae>=O&&Ae<k&&$.push(Y[q])}}if($.length>0&&Array.isArray($[0])){const q=$[0].length,Ae=[];for(let fe=0;fe<q;fe++){const Fe=$.map(pt=>pt[fe]),Ee=Fe.length>0?Gt(Fe[0]):j.float;Ae.push(new B(Fe,Ee,t))}return[Ae]}else{const q=$.length>0?Gt($[0]):j.float;return new B($,q,t)}}}var eh=Object.defineProperty,th=(t,e,i)=>e in t?eh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ii=(t,e,i)=>th(t,typeof e!="symbol"?e+"":e,i);const ih={param:Uu,security:Hu,security_lower_tf:Ju};class rh{constructor(e){this.context=e,Ii(this,"_cache",{}),Ii(this,"param"),Ii(this,"security"),Ii(this,"security_lower_tf"),Object.entries(ih).forEach(([i,r])=>{this[i]=r(e)})}}function nh(t){return e=>{t.taState||(t.taState={});const i=e||"accdist";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.high,0),a=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(n)||isNaN(s)||isNaN(a)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const l=s-a;let c=0;l!==0&&(c=(n-a-(s-n))/l*o);const u=r.prevCumulativeSum+c;return r.currentCumulativeSum=u,t.precision(u)}}function sh(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0),l=y.from(n).get(0);t.taState||(t.taState={});const c=s||`alma_${a}_${o}_${l}`;if(!t.taState[c]){const m=o*(a-1),x=a/l,b=[];let v=0;for(let w=0;w<a;w++){const E=Math.exp(-Math.pow(w-m,2)/(2*x*x));b.push(E),v+=E}for(let w=0;w<b.length;w++)b[w]/=v;t.taState[c]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0,weights:b}}const u=t.taState[c];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow],u.prevCallCount=u.currentCallCount),u.lastIdx=t.idx);const p=y.from(e).get(0),h=[...u.prevWindow];for(h.unshift(p);h.length>a;)h.pop();const f=u.prevCallCount+1;if(h.length<a&&(f>=a||t.idx>=a-1)){const m=y.from(e);for(;h.length<a;)h.push(m.get(h.length))}if(u.currentWindow=h,u.currentCallCount=f,h.length<a)return NaN;let d=0;for(let m=0;m<a;m++)d+=u.weights[m]*h[a-1-m];return t.precision(d)}}function ah(t){return(e,i)=>{const r=y.from(e).get(0);t.taState||(t.taState={});const n=i||`atr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,currentAtr:null,currentInitSum:0,currentInitCount:0});const s=t.taState[n];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevAtr=s.currentAtr,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const a=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(a)||isNaN(o)||isNaN(l))return NaN;const c=t.idx>0?t.get(t.data.close,1):null;let u;if(c!==null&&!isNaN(c)){const m=a-o,x=Math.abs(a-c),b=Math.abs(o-c);u=Math.max(m,x,b)}else u=a-o;let p=s.prevInitCount,h=s.prevInitSum,f=s.prevAtr;if(p<r){if(h+=u,p++,s.currentInitSum=h,s.currentInitCount=p,p===r){const m=h/r;return s.currentAtr=m,t.precision(m)}return NaN}const d=(f*(r-1)+u)/r;return s.currentAtr=d,t.precision(d)}}function oh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"barssince";t.taState[r]||(t.taState[r]={lastIdx:-1,prevLastTrueIndex:null,currentLastTrueIndex:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevLastTrueIndex=n.currentLastTrueIndex),n.lastIdx=t.idx);const s=y.from(e).get(0);let a=n.prevLastTrueIndex;return s&&(a=t.idx),n.currentLastTrueIndex=a,a===null?NaN:t.idx-a}}function lh(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`bb_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,[[NaN,NaN,NaN]];const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>s;){const b=u.pop();p-=b}if(u.length<s&&t.idx>=s-1){const b=y.from(e);for(;u.length<s;){const v=b.get(u.length);if(isNaN(v))break;u.push(v),p+=v}}if(l.currentWindow=u,l.currentSum=p,u.length<s)return[[NaN,NaN,NaN]];const h=p/s;let f=0;for(let b=0;b<s;b++)f+=Math.pow(u[b]-h,2);const d=Math.sqrt(f/s),m=h+a*d,x=h-a*d;return[[t.precision(h),t.precision(m),t.precision(x)]]}}function ch(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`bbw_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,NaN;const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>s;){const v=u.pop();p-=v}if(u.length<s&&t.idx>=s-1){const v=y.from(e);for(;u.length<s;){const w=v.get(u.length);if(isNaN(w))break;u.push(w),p+=w}}if(l.currentWindow=u,l.currentSum=p,u.length<s)return NaN;const h=p/s;let f=0;for(let v=0;v<s;v++){const w=u[v]-h;f+=w*w}const d=f/s,m=Math.sqrt(d),x=a*m;if(h===0)return t.precision(0);const b=2*x/h*100;return t.precision(b)}}function uh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`cci_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevSum=a.currentSum,a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0);if(isNaN(o))return NaN;const l=[...a.prevWindow];let c=a.prevSum;for(l.unshift(o),c+=o;l.length>n;){const m=l.pop();c-=m}const u=a.prevCallCount+1;if(l.length<n&&(u>=n||t.idx>=n-1)){const m=y.from(e);for(;l.length<n;){const x=m.get(l.length);if(isNaN(x))break;l.push(x),c+=x}}if(a.currentWindow=l,a.currentSum=c,a.currentCallCount=u,l.length<n)return NaN;const p=c/n;let h=0;for(let m=0;m<n;m++)h+=Math.abs(l[m]-p);const f=h/n;if(f===0)return 0;const d=(o-p)/(.015*f);return t.precision(d)}}function hh(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`change_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=a.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const p=y.from(e);for(;l.length<n+1;)l.push(p.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<=n)return NaN;const u=o-l[n];return t.precision(u)}}function ph(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`cmo_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevGainsWindow=[...a.currentGainsWindow],a.prevLossesWindow=[...a.currentLossesWindow],a.prevGainsSum=a.currentGainsSum,a.prevLossesSum=a.currentLossesSum),a.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(e).get(1);if(isNaN(o)||isNaN(l))return NaN;const c=o-l,u=c>=0?c:0,p=c>=0?0:-c,h=[...a.prevGainsWindow],f=[...a.prevLossesWindow];let d=a.prevGainsSum,m=a.prevLossesSum;if(h.unshift(u),f.unshift(p),d+=u,m+=p,h.length<n)return a.currentGainsWindow=h,a.currentLossesWindow=f,a.currentGainsSum=d,a.currentLossesSum=m,NaN;if(h.length>n){const v=h.pop(),w=f.pop();d-=v,m-=w}a.currentGainsWindow=h,a.currentLossesWindow=f,a.currentGainsSum=d,a.currentLossesSum=m;const x=d+m;if(x===0)return t.precision(0);const b=100*(d-m)/x;return t.precision(b)}}function fh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);let a=0,o=!1;for(let u=0;u<n;u++){const p=s.get(u);if(isNaN(p)){o=!0;break}a+=p}if(o)return NaN;let l=0;for(let u=0;u<n;u++){const p=s.get(u);l+=p*(u+1)}if(a===0)return NaN;const c=-l/a;return t.precision(c)}}function dh(t){return(e,i,r,n)=>{const s=y.from(r).get(0),a=y.from(e),o=y.from(i);if(t.idx<s-1)return NaN;let l=0,c=0,u=0,p=0,h=0,f=0;for(let v=0;v<s;v++){const w=a.get(v),E=o.get(v);isNaN(w)||isNaN(E)||(l+=w,c+=E,u+=w*E,p+=w*w,h+=E*E,f++)}if(f<2)return NaN;const d=f*u-l*c,m=f*p-l*l,x=f*h-c*c;if(m<=0||x<=0)return t.precision(0);const b=d/Math.sqrt(m*x);return t.precision(b)}}function mh(t){return(e,i,r)=>{const n=y.from(e),s=y.from(i),a=n.get(0),o=s.get(0),l=n.get(1),c=s.get(1);if(isNaN(a)||isNaN(o)||isNaN(l)||isNaN(c))return!1;const u=a>o&&l<=c,p=a<o&&l>=c;return u||p}}function yh(t){return(e,i)=>{const r=y.from(e),n=y.from(i),s=r.get(0),a=n.get(0),o=r.get(1),l=n.get(1);return o<=l&&s>a}}function _h(t){return(e,i)=>{const r=y.from(e),n=y.from(i),s=r.get(0),a=n.get(0),o=r.get(1),l=n.get(1);return o>=l&&s<a}}function gh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"cum";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativeSum=n.currentCumulativeSum),n.lastIdx=t.idx);const s=y.from(e).get(0);if(isNaN(s))return n.currentCumulativeSum=n.prevCumulativeSum,t.precision(n.prevCumulativeSum);const a=n.prevCumulativeSum+s;return n.currentCumulativeSum=a,t.precision(a)}}function xh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`dev_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevSum=a.currentSum,a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0)||0,l=[...a.prevWindow];let c=a.prevSum;for(l.unshift(o),c+=o;l.length>n;){const d=l.pop();c-=d}const u=a.prevCallCount+1;if(l.length<n&&(u>=n||t.idx>=n-1)){const d=y.from(e);for(;l.length<n;){const m=d.get(l.length);l.push(m),c+=m}}if(a.currentWindow=l,a.currentSum=c,a.currentCallCount=u,l.length<n)return NaN;const p=c/n;let h=0;for(let d=0;d<n;d++)h+=Math.abs(l[d]-p);const f=h/n;return t.precision(f)}}function bh(t){return(e,i,r)=>{const n=y.from(e).get(0),s=y.from(i).get(0);t.taState||(t.taState={});const a=r||`dmi_${n}_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevTrInitSum:0,prevPlusInitSum:0,prevMinusInitSum:0,prevInitCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,prevDxInitSum:0,prevAdxInitCount:0,prevADX:NaN,currentTrInitSum:0,currentPlusInitSum:0,currentMinusInitSum:0,currentInitCount:0,currentSmoothedTR:NaN,currentSmoothedPlus:NaN,currentSmoothedMinus:NaN,currentDxInitSum:0,currentAdxInitCount:0,currentADX:NaN});const o=t.taState[a];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrInitSum=o.currentTrInitSum,o.prevPlusInitSum=o.currentPlusInitSum,o.prevMinusInitSum=o.currentMinusInitSum,o.prevInitCount=o.currentInitCount,o.prevSmoothedTR=o.currentSmoothedTR,o.prevSmoothedPlus=o.currentSmoothedPlus,o.prevSmoothedMinus=o.currentSmoothedMinus,o.prevDxInitSum=o.currentDxInitSum,o.prevAdxInitCount=o.currentAdxInitCount,o.prevADX=o.currentADX),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(u))return[[NaN,NaN,NaN]];const p=t.idx>0?t.get(t.data.high,1):NaN,h=t.idx>0?t.get(t.data.low,1):NaN,f=t.idx>0?t.get(t.data.close,1):NaN;if(isNaN(p))return[[NaN,NaN,NaN]];const d=Math.max(l-c,Math.abs(l-f),Math.abs(c-f)),m=l-p,x=h-c,b=m>x&&m>0?m:0,v=x>m&&x>0?x:0;let w=o.prevInitCount,E=o.prevTrInitSum,T=o.prevPlusInitSum,N=o.prevMinusInitSum,A=o.prevSmoothedTR,O=o.prevSmoothedPlus,k=o.prevSmoothedMinus;if(w++,w<=n)E+=d,T+=b,N+=v,w===n&&(A=E/n,O=T/n,k=N/n);else{const Ee=1/n;A=Ee*d+(1-Ee)*A,O=Ee*b+(1-Ee)*O,k=Ee*v+(1-Ee)*k}if(o.currentInitCount=w,o.currentTrInitSum=E,o.currentPlusInitSum=T,o.currentMinusInitSum=N,o.currentSmoothedTR=A,o.currentSmoothedPlus=O,o.currentSmoothedMinus=k,w<n)return[[NaN,NaN,NaN]];const U=A===0?0:100*O/A,R=A===0?0:100*k/A,Y=U+R,$=Y===0?0:100*Math.abs(U-R)/Y;let q=o.prevAdxInitCount,Ae=o.prevDxInitSum,fe=o.prevADX,Fe=NaN;if(q++,q<=s)Ae+=$,q===s&&(fe=Ae/s,Fe=fe);else{const Ee=1/s;fe=Ee*$+(1-Ee)*fe,Fe=fe}return o.currentAdxInitCount=q,o.currentDxInitSum=Ae,o.currentADX=fe,[[t.precision(U),t.precision(R),t.precision(Fe)]]}}function vh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`ema_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevEma=a.currentEma,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount),a.lastIdx=t.idx);const o=y.from(e).get(0);if(o==null||isNaN(o))return NaN;let l=a.prevInitCount,c=a.prevInitSum,u=a.prevEma;if(l<n){if(c+=o,l++,a.currentInitSum=c,a.currentInitCount=l,l===n){const f=c/n;return a.currentEma=f,t.precision(f)}return NaN}const p=2/(n+1),h=o*p+u*(1-p);return a.currentEma=h,t.precision(h)}}function wh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);for(let a=0;a<n;a++){const o=s.get(a),l=s.get(a+1);if(isNaN(o)||isNaN(l)||o>=l)return!1}return!0}}function Sh(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`highest_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const h=y.from(e);for(;l.length<n;)l.push(h.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;const u=l.filter(h=>!isNaN(h)&&h!==void 0);if(u.length===0)return NaN;const p=Math.max(...u);return t.precision(p)}}function Eh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n-1)return NaN;let a=-1/0,o=NaN;for(let l=0;l<n;l++){const c=s.get(l);isNaN(c)||(isNaN(o)||c>a)&&(a=c,o=-l)}return o}}function Nh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=Math.floor(n/2),a=Math.floor(Math.sqrt(n)),o=t.pine.ta.wma,l=o(e,s,r?`${r}_wma1`:void 0),c=o(e,n,r?`${r}_wma2`:void 0);if(isNaN(l)||isNaN(c))return NaN;t.taState||(t.taState={});const u=r||`hma_raw_${n}`;t.taState[u]||(t.taState[u]={lastIdx:-1,prevValues:[],currentValues:[]});const p=t.taState[u];t.idx>p.lastIdx&&(p.lastIdx>=0&&(p.prevValues=[...p.currentValues]),p.lastIdx=t.idx);const h=2*l-c,f=[...p.prevValues];f.unshift(h),f.length>a+1&&f.pop(),p.currentValues=f;const d=r?`${r}_hma_final`:`hma_final_${n}`;t.taState[d]||(t.taState[d]={lastIdx:-1,prevWindow:[],currentWindow:[]});const m=t.taState[d];t.idx>m.lastIdx&&(m.lastIdx>=0&&(m.prevWindow=[...m.currentWindow]),m.lastIdx=t.idx);const x=[...m.prevWindow];if(x.unshift(h),x.length<a)return m.currentWindow=x,NaN;for(;x.length>a;)x.pop();m.currentWindow=x;let b=0,v=0;for(let E=0;E<a;E++){const T=a-E;b+=x[E]*T,v+=T}const w=b/v;return t.precision(w)}}function Ch(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),n=t.get(t.data.low,0),s=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(s))return NaN;const a=(r-n)*s;if(a===0)return t.precision(0);const o=(2*i-r-n)/a;return t.precision(o)}}function Ih(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0);let l=!0;typeof n=="string"?s=n:n!==void 0&&(l=y.from(n).get(0));let c;const u=t.get(t.data.high,0),p=t.get(t.data.low,0);if(l){const E=t.get(t.data.close,1);isNaN(E)?c=NaN:c=Math.max(u-p,Math.abs(u-E),Math.abs(p-E))}else c=u-p;const h=y.from(e).get(0);t.taState||(t.taState={});const f=s||`kc_${a}_${o}_${l}`;t.taState[f]||(t.taState[f]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const d=t.taState[f];t.idx>d.lastIdx&&(d.lastIdx>=0&&(d.basisState={...d.currentBasisState},d.rangeState={...d.currentRangeState}),d.lastIdx=t.idx);const m=(E,T,N,A)=>{if(isNaN(N))return Object.assign(T,E),T.prevEma!==null?T.prevEma:NaN;let O=E.initCount,k=E.initSum,U=E.prevEma;if(O<A){if(k+=N,O++,T.initSum=k,T.initCount=O,T.prevEma=U,O===A){const $=k/A;return T.prevEma=$,$}return NaN}const R=2/(A+1),Y=N*R+U*(1-R);return T.prevEma=Y,T.initSum=k,T.initCount=O,Y},x=m(d.basisState,d.currentBasisState,h,a),b=m(d.rangeState,d.currentRangeState,c,a);if(isNaN(x)||isNaN(b))return[[NaN,NaN,NaN]];const v=x+b*o,w=x-b*o;return[[t.precision(x),t.precision(v),t.precision(w)]]}}function kh(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0);let l=!0;typeof n=="string"?s=n:n!==void 0&&(l=y.from(n).get(0)),t.taState||(t.taState={});const c=s||`kcw_${a}_${o}_${l}`;t.taState[c]||(t.taState[c]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const u=t.taState[c];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.basisState={...u.currentBasisState},u.rangeState={...u.currentRangeState}),u.lastIdx=t.idx);const p=(w,E,T,N)=>{if(isNaN(T))return Object.assign(E,w),E.prevEma!==null?E.prevEma:NaN;let A=w.initCount,O=w.initSum,k=w.prevEma;if(A<N){if(O+=T,A++,E.initSum=O,E.initCount=A,E.prevEma=k,A===N){const Y=O/N;return E.prevEma=Y,Y}return NaN}const U=2/(N+1),R=T*U+k*(1-U);return E.prevEma=R,E.initSum=O,E.initCount=A,R};let h;const f=t.get(t.data.high,0),d=t.get(t.data.low,0);if(l){const w=t.get(t.data.close,1);isNaN(w)?h=NaN:h=Math.max(f-d,Math.abs(f-w),Math.abs(d-w))}else h=f-d;const m=y.from(e).get(0),x=p(u.basisState,u.currentBasisState,m,a),b=p(u.rangeState,u.currentRangeState,h,a);if(isNaN(x)||isNaN(b))return NaN;if(x===0)return t.precision(0);const v=2*b*o/x;return t.precision(v)}}function Th(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`linreg_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=y.from(e).get(0),u=[...l.prevWindow];for(u.unshift(c);u.length>s;)u.pop();const p=l.prevCallCount+1;if(u.length<s&&(p>=s||t.idx>=s-1)){const E=y.from(e);for(;u.length<s;)u.push(E.get(u.length))}if(l.currentWindow=u,l.currentCallCount=p,u.length<s)return NaN;let h=0,f=0,d=0,m=0;const x=s;for(let E=0;E<s;E++){const T=s-1-E,N=u[E];h+=T,f+=N,d+=T*N,m+=T*T}const b=x*m-h*h;if(b===0)return NaN;const v=(x*d-h*f)/b,w=(f-v*h)/x+v*(s-1-a);return t.precision(w)}}function Ah(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`lowest_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const h=y.from(e);for(;l.length<n;)l.push(h.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;const u=l.filter(h=>!isNaN(h)&&h!==void 0);if(u.length===0)return NaN;const p=Math.min(...u);return t.precision(p)}}function Ph(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n-1)return NaN;let a=1/0,o=NaN;for(let l=0;l<n;l++){const c=s.get(l);isNaN(c)||(isNaN(o)||c<a)&&(a=c,o=-l)}return o}}function Dh(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0),l=y.from(n).get(0),c=s||`macd_${a}_${o}_${l}`,u=`${c}_fast`,p=`${c}_slow`,h=`${c}_signal`,f=t.pine.ta.ema(e,a,u),d=t.pine.ta.ema(e,o,p);let m=NaN;!isNaN(f)&&!isNaN(d)&&(m=f-d);let x=NaN;isNaN(m)||(x=t.pine.ta.ema(m,l,h));let b=NaN;return!isNaN(m)&&!isNaN(x)&&(b=m-x),[[t.precision(m),t.precision(x),t.precision(b)]]}}function Mh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`median_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=y.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;const u=l.slice().sort((f,d)=>f-d),p=Math.floor(n/2),h=n%2===0?(u[p-1]+u[p])/2:u[p];return t.precision(h)}}function Rh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`mfi_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevUpperWindow=[...a.currentUpperWindow],a.prevLowerWindow=[...a.currentLowerWindow],a.prevUpperSum=a.currentUpperSum,a.prevLowerSum=a.currentLowerSum),a.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(e).get(1),c=t.get(t.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const u=isNaN(l)?NaN:o-l,p=c*(u<=0?0:o),h=c*(u>=0?0:o),f=[...a.prevUpperWindow],d=[...a.prevLowerWindow];let m=a.prevUpperSum,x=a.prevLowerSum;if(f.unshift(p),d.unshift(h),m+=p,x+=h,f.length<n)return a.currentUpperWindow=f,a.currentLowerWindow=d,a.currentUpperSum=m,a.currentLowerSum=x,NaN;if(f.length>n){const v=f.pop(),w=d.pop();m-=v,x-=w}if(a.currentUpperWindow=f,a.currentLowerWindow=d,a.currentUpperSum=m,a.currentLowerSum=x,x===0)return t.precision(100);if(m===0)return t.precision(0);const b=100-100/(1+m/x);return t.precision(b)}}function Oh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n-1)return NaN;const a=new Map;for(let c=0;c<n;c++){const u=s.get(c);isNaN(u)||a.set(u,(a.get(u)||0)+1)}if(a.size===0)return NaN;let o=NaN,l=-1;for(const[c,u]of a.entries())u>l?(l=u,o=c):u===l&&c<o&&(o=c);return o}}function $h(t){return(e,i,r)=>{const n=y.from(i).get(0);return t.pine.ta.change(e,n,r)}}function Vh(t){return e=>{t.taState||(t.taState={});const i=e||"nvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedNVI:1,tentativeNVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedNVI=r.tentativeNVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.close,1),a=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(s)?0:s,u=isNaN(a)?0:a,p=isNaN(o)?0:o;let h=r.committedNVI;if(!(l===0||c===0)&&u<p){const f=(l-c)/c;h=h+f*h}return r.tentativeNVI=h,t.precision(h)}}function jh(t){return()=>{t.taState||(t.taState={});const e="obv";t.taState[e]||(t.taState[e]={lastIdx:-1,committedOBV:0,tentativeOBV:0});const i=t.taState[e];t.idx>i.lastIdx&&(i.lastIdx>=0&&(i.committedOBV=i.tentativeOBV),i.lastIdx=t.idx);const r=t.get(t.data.close,0),n=t.get(t.data.volume,0),s=t.get(t.data.close,1);if(isNaN(s))return i.tentativeOBV=0,t.precision(0);let a=i.committedOBV;return r>s?a+=n:r<s&&(a-=n),i.tentativeOBV=a,t.precision(a)}}function Lh(t){return(e,i,r)=>e instanceof y?i?new y(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new y(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new y(t.params[r],i||0)))}function Bh(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e);if(t.idx<s-1)return NaN;const l=[];for(let d=0;d<s;d++){const m=o.get(d);if(isNaN(m))return NaN;l.push(m)}l.sort((d,m)=>d-m);let c=a/100*s-.5;c<0&&(c=0),c>s-1&&(c=s-1);const u=Math.floor(c),p=Math.ceil(c);if(u===p)return t.precision(l[u]);const h=c-u,f=l[u]+h*(l[p]-l[u]);return t.precision(f)}}function Fh(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e);if(t.idx<s-1)return NaN;const l=[];for(let u=0;u<s;u++){const p=o.get(u);isNaN(p)||l.push(p)}if(l.length===0)return NaN;l.sort((u,p)=>u-p);let c=Math.ceil(a/100*l.length)-1;return c<0&&(c=0),c>=l.length&&(c=l.length-1),t.precision(l[c])}}function Wh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n)return NaN;const a=s.get(0);if(isNaN(a))return NaN;let o=0,l=0;for(let c=1;c<=n;c++){const u=s.get(c);isNaN(u)||(l++,u<=a&&o++)}return l===0?NaN:t.precision(o/l*100)}}function Uh(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const s=t[n-i];let a=!0;for(let o=1;o<=e;o++)if(t[n-i-o]>=s){a=!1;break}if(a){for(let o=1;o<=i;o++)if(t[n-i+o]>=s){a=!1;break}}a&&(r[n]=s)}return r}function qh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e).toArray(),l=Uh(o,s,a),c=t.idx;return t.precision(l[c])}}function zh(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const s=t[n-i];let a=!0;for(let o=1;o<=e;o++)if(t[n-i-o]<=s){a=!1;break}if(a){for(let o=1;o<=i;o++)if(t[n-i+o]<=s){a=!1;break}}a&&(r[n]=s)}return r}function Kh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e).toArray(),l=zh(o,s,a),c=t.idx;return t.precision(l[c])}}function Hh(t){return e=>{t.taState||(t.taState={});const i=e||"pvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedPVI:1,tentativePVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedPVI=r.tentativePVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.close,1),a=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(s)?0:s,u=isNaN(a)?0:a,p=isNaN(o)?0:o;let h=r.committedPVI;if(!(l===0||c===0)&&u>p){const f=(l-c)/c;h=h+f*h}return r.tentativePVI=h,t.precision(h)}}function Gh(t){return e=>{t.taState||(t.taState={});const i=e||"pvt";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.close,1),a=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(n)&&!isNaN(s)&&!isNaN(a)&&s!==0){const l=(n-s)/s*a;o+=l}return r.currentCumulativeSum=o,t.precision(o)}}function Yh(t){return(e,i,r)=>{const n=t.pine.ta.highest(e,i,(r||"range")+"_h"),s=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(n)||isNaN(s)?NaN:t.precision(n-s)}}function Xh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);for(let a=0;a<n;a++){const o=s.get(a),l=s.get(a+1);if(isNaN(o)||isNaN(l)||o<=l)return!1}return!0}}function Zh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`rma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevRma=a.currentRma,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount),a.lastIdx=t.idx);const o=y.from(e).get(0)||0;let l=a.prevInitCount,c=a.prevInitSum,u=a.prevRma;if(l<n){if(c+=o,l++,a.currentInitSum=c,a.currentInitCount=l,l===n){const f=c/n;return a.currentRma=f,t.precision(f)}return NaN}const p=1/n,h=o*p+u*(1-p);return a.currentRma=h,t.precision(h)}}function Qh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`roc_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=a.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const h=y.from(e);for(;l.length<n+1;)l.push(h.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<=n)return NaN;const u=l[n],p=(o-u)/u*100;return t.precision(p)}}function Jh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`rsi_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevPrevValue:null,prevAvgGain:0,prevAvgLoss:0,prevInitGains:[],prevInitLosses:[],currentPrevValue:null,currentAvgGain:0,currentAvgLoss:0,currentInitGains:[],currentInitLosses:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevPrevValue=a.currentPrevValue,a.prevAvgGain=a.currentAvgGain,a.prevAvgLoss=a.currentAvgLoss,a.prevInitGains=[...a.currentInitGains],a.prevInitLosses=[...a.currentInitLosses]),a.lastIdx=t.idx);const o=y.from(e).get(0);if(o==null||isNaN(o))return NaN;const l=a.prevPrevValue;if(l===null||isNaN(l))return a.currentPrevValue=o,a.currentInitGains=[...a.prevInitGains],a.currentInitLosses=[...a.prevInitLosses],a.currentAvgGain=a.prevAvgGain,a.currentAvgLoss=a.prevAvgLoss,NaN;let c=a.prevAvgGain,u=a.prevAvgLoss;const p=[...a.prevInitGains],h=[...a.prevInitLosses],f=o-l,d=f>0?f:0,m=f<0?-f:0;if(p.length<n){if(p.push(d),h.push(m),a.currentInitGains=p,a.currentInitLosses=h,a.currentPrevValue=o,p.length===n){c=p.reduce((v,w)=>v+w,0)/n,u=h.reduce((v,w)=>v+w,0)/n,a.currentAvgGain=c,a.currentAvgLoss=u;const b=u===0?100:100-100/(1+c/u);return t.precision(b)}return NaN}c=(c*(n-1)+d)/n,u=(u*(n-1)+m)/n,a.currentAvgGain=c,a.currentAvgLoss=u,a.currentPrevValue=o;const x=u===0?100:100-100/(1+c/u);return t.precision(x)}}function ep(t){return(e,i,r,n)=>{const s=y.from(e).get(0),a=y.from(i).get(0),o=y.from(r).get(0);t.taState||(t.taState={});const l=n||`sar_${s}_${a}_${o}`;t.taState[l]||(t.taState[l]={lastIdx:-1,prevResult:NaN,prevMaxMin:NaN,prevAcceleration:NaN,prevIsBelow:!1,prevBarIndex:0,currentResult:NaN,currentMaxMin:NaN,currentAcceleration:NaN,currentIsBelow:!1,currentBarIndex:0});const c=t.taState[l];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevResult=c.currentResult,c.prevMaxMin=c.currentMaxMin,c.prevAcceleration=c.currentAcceleration,c.prevIsBelow=c.currentIsBelow,c.prevBarIndex=c.currentBarIndex),c.lastIdx=t.idx);let u=c.prevResult,p=c.prevMaxMin,h=c.prevAcceleration,f=c.prevIsBelow,d=c.prevBarIndex;const m=t.get(t.data.high,0),x=t.get(t.data.low,0),b=t.get(t.data.close,0),v=t.get(t.data.close,1),w=t.get(t.data.high,1),E=t.get(t.data.low,1),T=t.get(t.data.high,2),N=t.get(t.data.low,2);if(isNaN(m)||isNaN(x)||isNaN(b))return c.currentResult=u,c.currentMaxMin=p,c.currentAcceleration=h,c.currentIsBelow=f,c.currentBarIndex=d,NaN;let A=!1;return d===1&&(b>v?(f=!0,p=m,u=E):(f=!1,p=x,u=w),A=!0,h=s),d>=1&&(u=u+h*(p-u),f?u>x&&(A=!0,f=!1,u=Math.max(m,p),p=x,h=s):u<m&&(A=!0,f=!0,u=Math.min(x,p),p=m,h=s),A||(f?m>p&&(p=m,h=Math.min(h+a,o)):x<p&&(p=x,h=Math.min(h+a,o))),f?(u=Math.min(u,E),d>1&&(u=Math.min(u,N))):(u=Math.max(u,w),d>1&&(u=Math.max(u,T)))),d++,c.currentResult=u,c.currentMaxMin=p,c.currentAcceleration=h,c.currentIsBelow=f,c.currentBarIndex=d,d<=1?NaN:t.precision(u)}}function tp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`sma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevSum=a.currentSum,a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;let u=!1;if(l.length<n&&(c>=n||t.idx>=n-1)){const m=y.from(e);for(;l.length<n;)l.push(m.get(l.length));u=!0}let p;const h=o==null||Number.isNaN(o);let f=!Number.isNaN(a.prevSum)&&!h&&!u;if(f){let m=a.prevSum+o;if(a.prevWindow.length>=n){const x=a.prevWindow[a.prevWindow.length-1];x==null||Number.isNaN(x)?f=!1:m-=x}f&&(p=m)}if(!f){p=0;let m=!1;for(const x of l){if(x==null||Number.isNaN(x)){m=!0;break}p+=x}m&&(p=NaN)}if(a.currentWindow=l,a.currentSum=p,a.currentCallCount=c,l.length<n)return NaN;const d=p/n;return t.precision(d)}}function ip(t){return(e,i,r=!0,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`stdev_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum,l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=y.from(e).get(0);if(c==null||isNaN(c))return NaN;const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>s;){const b=u.pop();p-=b}const h=l.prevCallCount+1;if(u.length<s&&(h>=s||t.idx>=s-1)){const b=y.from(e);for(;u.length<s;){const v=b.get(u.length);if(v==null||isNaN(v))break;u.push(v),p+=v}}if(l.currentWindow=u,l.currentSum=p,l.currentCallCount=h,u.length<s)return NaN;const f=p/s;let d=0;for(let b=0;b<s;b++)d+=Math.pow(u[b]-f,2);const m=a?s:s-1,x=Math.sqrt(d/m);return t.precision(x)}}function rp(t){return(e,i,r,n,s)=>{const a=y.from(n).get(0);t.taState||(t.taState={});const o=s||`stoch_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevHighWindow=[...l.currentHighWindow],l.prevLowWindow=[...l.currentLowWindow]),l.lastIdx=t.idx);const c=y.from(e).get(0),u=y.from(i).get(0),p=y.from(r).get(0);if(isNaN(c)||isNaN(u)||isNaN(p))return l.currentHighWindow=[...l.prevHighWindow],l.currentLowWindow=[...l.prevLowWindow],NaN;const h=[...l.prevHighWindow],f=[...l.prevLowWindow];if(h.unshift(u),f.unshift(p),h.length>a&&(h.pop(),f.pop()),l.currentHighWindow=h,l.currentLowWindow=f,h.length<a)return NaN;let d=h[0],m=f[0];for(let v=1;v<a;v++)h[v]>d&&(d=h[v]),f[v]<m&&(m=f[v]);const x=d-m;if(x===0)return NaN;const b=100*(c-m)/x;return t.precision(b)}}function np(t){return(e,i,r)=>{const n=y.from(e).get(0),s=y.from(i).get(0);t.taState||(t.taState={});const a=r||`supertrend_${n}_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevTrSum:0,prevAtrValue:NaN,prevAtrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,currentTrSum:0,currentAtrValue:NaN,currentAtrCount:0,currentLowerBand:NaN,currentUpperBand:NaN,currentSuperTrend:NaN,currentDirection:NaN});const o=t.taState[a];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrSum=o.currentTrSum,o.prevAtrValue=o.currentAtrValue,o.prevAtrCount=o.currentAtrCount,o.prevLowerBand=o.currentLowerBand,o.prevUpperBand=o.currentUpperBand,o.prevSuperTrend=o.currentSuperTrend,o.prevDirection=o.currentDirection),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(u))return[[NaN,NaN]];const p=(l+c)/2,h=t.idx>0?t.get(t.data.close,1):NaN;let f;isNaN(h)?f=l-c:f=Math.max(l-c,Math.abs(l-h),Math.abs(c-h));let d=o.prevAtrCount,m=o.prevTrSum,x=o.prevAtrValue;d++,d<=s?(m+=f,d===s&&(x=m/s)):x=(x*(s-1)+f)/s;const b=x;if(o.currentAtrCount=d,o.currentTrSum=m,o.currentAtrValue=x,isNaN(b))return[[NaN,NaN]];let v=p+n*b,w=p-n*b;const E=isNaN(o.prevLowerBand)?0:o.prevLowerBand,T=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||w>E||h<E||(w=E),isNaN(o.prevUpperBand)||v<T||h>T||(v=T);let N,A;const O=o.prevSuperTrend;return d===s?N=1:O===o.prevUpperBand?N=u>v?-1:1:N=u<w?1:-1,A=N===-1?w:v,o.currentLowerBand=w,o.currentUpperBand=v,o.currentSuperTrend=A,o.currentDirection=N,[[t.precision(A),N]]}}function sp(t){return(e,i)=>{const r=[1,2,2,1],n=6;t.taState||(t.taState={});const s=i||"swma";t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],currentWindow:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow]),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>4;)l.pop();if(l.length<4&&t.idx>=3){const u=y.from(e);for(;l.length<4;)l.push(u.get(l.length))}if(a.currentWindow=l,l.length<4)return NaN;let c=0;for(let u=0;u<4;u++)c+=r[u]*l[3-u];return c/=n,t.precision(c)}}function ap(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=y.from(e).get(0));const n=t.get(t.data.high,0),s=t.get(t.data.low,0),a=t.get(t.data.close,1);if(isNaN(a))return r?t.precision(n-s):NaN;const o=Math.max(n-s,Math.abs(n-a),Math.abs(s-a));return t.precision(o)}}function op(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`tsi_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevSource:NaN,prevEma1PcValue:NaN,prevEma1PcCount:0,prevEma1PcSum:0,prevEma2PcValue:NaN,prevEma2PcCount:0,prevEma2PcSum:0,prevEma1AbsValue:NaN,prevEma1AbsCount:0,prevEma1AbsSum:0,prevEma2AbsValue:NaN,prevEma2AbsCount:0,prevEma2AbsSum:0,currentSource:NaN,currentEma1PcValue:NaN,currentEma1PcCount:0,currentEma1PcSum:0,currentEma2PcValue:NaN,currentEma2PcCount:0,currentEma2PcSum:0,currentEma1AbsValue:NaN,currentEma1AbsCount:0,currentEma1AbsSum:0,currentEma2AbsValue:NaN,currentEma2AbsCount:0,currentEma2AbsSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevSource=l.currentSource,l.prevEma1PcValue=l.currentEma1PcValue,l.prevEma1PcCount=l.currentEma1PcCount,l.prevEma1PcSum=l.currentEma1PcSum,l.prevEma2PcValue=l.currentEma2PcValue,l.prevEma2PcCount=l.currentEma2PcCount,l.prevEma2PcSum=l.currentEma2PcSum,l.prevEma1AbsValue=l.currentEma1AbsValue,l.prevEma1AbsCount=l.currentEma1AbsCount,l.prevEma1AbsSum=l.currentEma1AbsSum,l.prevEma2AbsValue=l.currentEma2AbsValue,l.prevEma2AbsCount=l.currentEma2AbsCount,l.prevEma2AbsSum=l.currentEma2AbsSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return NaN;const u=isNaN(l.prevSource)?NaN:c-l.prevSource;if(l.currentSource=c,isNaN(u))return NaN;const p=Math.abs(u),h=2/(a+1),f=2/(s+1),d=2/(a+1),m=2/(s+1);let x=l.prevEma1PcCount,b=l.prevEma1PcSum,v=l.prevEma1PcValue;x++,x<=a?(b+=u,x===a&&(v=b/a)):v=u*h+v*(1-h);let w=l.prevEma1AbsCount,E=l.prevEma1AbsSum,T=l.prevEma1AbsValue;if(w++,w<=a?(E+=p,w===a&&(T=E/a)):T=p*d+T*(1-d),isNaN(v)||isNaN(T))return l.currentEma1PcCount=x,l.currentEma1PcSum=b,l.currentEma1PcValue=v,l.currentEma1AbsCount=w,l.currentEma1AbsSum=E,l.currentEma1AbsValue=T,NaN;let N=l.prevEma2PcCount,A=l.prevEma2PcSum,O=l.prevEma2PcValue;N++,N<=s?(A+=v,N===s&&(O=A/s)):O=v*f+O*(1-f);let k=l.prevEma2AbsCount,U=l.prevEma2AbsSum,R=l.prevEma2AbsValue;if(k++,k<=s?(U+=T,k===s&&(R=U/s)):R=T*m+R*(1-m),l.currentEma1PcCount=x,l.currentEma1PcSum=b,l.currentEma1PcValue=v,l.currentEma1AbsCount=w,l.currentEma1AbsSum=E,l.currentEma1AbsValue=T,l.currentEma2PcCount=N,l.currentEma2PcSum=A,l.currentEma2PcValue=O,l.currentEma2AbsCount=k,l.currentEma2AbsSum=U,l.currentEma2AbsValue=R,isNaN(O)||isNaN(R))return NaN;if(R===0)return t.precision(0);const Y=O/R;return t.precision(Y)}}function lp(t){return(e,i,r,n)=>{t.taState||(t.taState={});const s=n||"valuewhen";t.taState[s]||(t.taState[s]={lastIdx:-1,prevValues:[],currentValues:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevValues=[...a.currentValues]),a.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(i).get(0),c=y.from(r).get(0),u=[...a.prevValues];if(o&&u.push(l),a.currentValues=u,isNaN(c)||c<0)return NaN;const p=u.length-1-c;if(p<0)return NaN;const h=u[p];return typeof h=="number"?t.precision(h):h}}function cp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`variance_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const d=y.from(e);for(;l.length<n;)l.push(d.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;let u=0,p=0;for(let d=0;d<n;d++)u+=l[d],p+=l[d]*l[d];const h=u/n,f=p/n-h*h;return t.precision(f)}}function up(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"vwap";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativePV:0,prevCumulativeVolume:0,prevLastSessionDate:null,currentCumulativePV:0,currentCumulativeVolume:0,currentLastSessionDate:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativePV=n.currentCumulativePV,n.prevCumulativeVolume=n.currentCumulativeVolume,n.prevLastSessionDate=n.currentLastSessionDate),n.lastIdx=t.idx);const s=y.from(e).get(0),a=y.from(t.data.volume).get(0),o=y.from(t.data.openTime).get(0),l=t.pine?.syminfo?.timezone||"UTC",c=Rt(o,l),u=`${c.year}-${String(c.month).padStart(2,"0")}-${String(c.day).padStart(2,"0")}`;let p=n.prevCumulativePV,h=n.prevCumulativeVolume,f=n.prevLastSessionDate;if(f!==u&&(p=0,h=0,f=u),p+=s*a,h+=a,n.currentCumulativePV=p,n.currentCumulativeVolume=h,n.currentLastSessionDate=f,h===0)return NaN;const d=p/h;return t.precision(d)}}function hp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`vwma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevVolumeWindow=[...a.currentVolumeWindow]),a.lastIdx=t.idx);const o=y.from(e).get(0),l=t.get(t.data.volume,0),c=[...a.prevWindow],u=[...a.prevVolumeWindow];for(c.unshift(o),u.unshift(l);c.length>n;)c.pop(),u.pop();if(c.length<n&&t.idx>=n-1){const d=y.from(e),m=y.from(t.data.volume);for(;c.length<n;)c.push(d.get(c.length)),u.push(m.get(u.length))}if(a.currentWindow=c,a.currentVolumeWindow=u,c.length<n)return NaN;let p=0,h=0;for(let d=0;d<n;d++)p+=c[d]*u[d],h+=u[d];const f=p/h;return t.precision(f)}}function pp(t){return e=>{t.taState||(t.taState={});const i=e||"wad";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.high,0),a=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(n)||isNaN(s)||isNaN(a))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let l=0;if(!isNaN(o)){const u=Math.max(s,o),p=Math.min(a,o),h=n-o;h>0?l=n-p:h<0&&(l=n-u)}const c=r.prevCumulativeSum+l;return r.currentCumulativeSum=c,t.precision(c)}}function fp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`wma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=y.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;let u=0,p=0;for(let f=0;f<n;f++){const d=n-f;u+=l[f]*d,p+=d}const h=u/p;return t.precision(h)}}function dp(t){return(e,i)=>{const r=y.from(e).get(0);t.taState||(t.taState={});const n=i||`wpr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const s=t.taState[n];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevHighWindow=[...s.currentHighWindow],s.prevLowWindow=[...s.currentLowWindow]),s.lastIdx=t.idx);const a=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(a)||isNaN(o)||isNaN(l))return s.currentHighWindow=[...s.prevHighWindow],s.currentLowWindow=[...s.prevLowWindow],NaN;const c=[...s.prevHighWindow],u=[...s.prevLowWindow];if(c.unshift(a),u.unshift(o),c.length>r&&(c.pop(),u.pop()),s.currentHighWindow=c,s.currentLowWindow=u,c.length<r)return NaN;let p=c[0],h=u[0];for(let m=1;m<r;m++)c[m]>p&&(p=c[m]),u[m]<h&&(h=u[m]);const f=p-h;if(f===0)return t.precision(0);const d=(p-l)/f*-100;return t.precision(d)}}function mp(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),n=t.get(t.data.high,0),s=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(s)||isNaN(a))return NaN;const o=n-s;if(o===0)return t.precision(0);const l=(i-r)/o*a;return t.precision(l)}}var yp=Object.defineProperty,_p=(t,e,i)=>e in t?yp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,P=(t,e,i)=>_p(t,typeof e!="symbol"?e+"":e,i);const gp={accdist:nh,alma:sh,atr:ah,barssince:oh,bb:lh,bbw:ch,cci:uh,change:hh,cmo:ph,cog:fh,correlation:dh,cross:mh,crossover:yh,crossunder:_h,cum:gh,dev:xh,dmi:bh,ema:vh,falling:wh,highest:Sh,highestbars:Eh,hma:Nh,iii:Ch,kc:Ih,kcw:kh,linreg:Th,lowest:Ah,lowestbars:Ph,macd:Dh,median:Mh,mfi:Rh,mode:Oh,mom:$h,nvi:Vh,obv:jh,param:Lh,percentile_linear_interpolation:Bh,percentile_nearest_rank:Fh,percentrank:Wh,pivothigh:qh,pivotlow:Kh,pvi:Hh,pvt:Gh,range:Yh,rising:Xh,rma:Zh,roc:Qh,rsi:Jh,sar:ep,sma:tp,stdev:ip,stoch:rp,supertrend:np,swma:sp,tr:ap,tsi:op,valuewhen:lp,variance:cp,vwap:up,vwma:hp,wad:pp,wma:fp,wpr:dp,wvad:mp};class xp{constructor(e){this.context=e,P(this,"accdist"),P(this,"alma"),P(this,"atr"),P(this,"barssince"),P(this,"bb"),P(this,"bbw"),P(this,"cci"),P(this,"change"),P(this,"cmo"),P(this,"cog"),P(this,"correlation"),P(this,"cross"),P(this,"crossover"),P(this,"crossunder"),P(this,"cum"),P(this,"dev"),P(this,"dmi"),P(this,"ema"),P(this,"falling"),P(this,"highest"),P(this,"highestbars"),P(this,"hma"),P(this,"iii"),P(this,"kc"),P(this,"kcw"),P(this,"linreg"),P(this,"lowest"),P(this,"lowestbars"),P(this,"macd"),P(this,"median"),P(this,"mfi"),P(this,"mode"),P(this,"mom"),P(this,"nvi"),P(this,"obv"),P(this,"param"),P(this,"percentile_linear_interpolation"),P(this,"percentile_nearest_rank"),P(this,"percentrank"),P(this,"pivothigh"),P(this,"pivotlow"),P(this,"pvi"),P(this,"pvt"),P(this,"range"),P(this,"rising"),P(this,"rma"),P(this,"roc"),P(this,"rsi"),P(this,"sar"),P(this,"sma"),P(this,"stdev"),P(this,"stoch"),P(this,"supertrend"),P(this,"swma"),P(this,"tr"),P(this,"tsi"),P(this,"valuewhen"),P(this,"variance"),P(this,"vwap"),P(this,"vwma"),P(this,"wad"),P(this,"wma"),P(this,"wpr"),P(this,"wvad"),Object.entries(gp).forEach(([i,r])=>{this[i]=r(e)})}}function bp(t){if(t.length===0)return{};if(typeof t[0]=="string"){const e={title:t[0]};return t.length>1&&typeof t[1]=="object"?{...e,...t[1]}:e}return typeof t[0]=="object"?t[0]:{}}function hi(t,e,i){if(!i||i<=0||!Number.isFinite(t)||t===e)return t;const r=t/i,n=1e-9;return t>e?Math.ceil(r-n)*i:Math.floor(r+n)*i}function Fr(t,e,i,r){return Math.abs(t)*e*r*i/100}function vp(t,e){const i=t.strategy,r=t.pine?.syminfo?.pointvalue??1;let n=0;for(const s of i.opentrades){const a=Math.sign(s.size)===1?e-s.entry_price:s.entry_price-e;n+=a*Math.abs(s.size)*r}return i.initial_capital+i.netprofit+n}function wp(t,e){const i=t.strategy,r=t.pine?.syminfo?.pointvalue??1;let n=0;for(const s of i.opentrades){const a=Math.sign(s.size)===1?i.config.margin_long??100:i.config.margin_short??100;n+=Fr(s.size,e,a,r)}return n}function Wr(t,e,i,r){const n=t.strategy;let s=n.config.default_qty_type||"fixed",a=n.config.default_qty_value||1;typeof s=="function"&&(s=s()),typeof a=="function"&&(a=a());const o=1e6,l=u=>Math.floor(u*o)/o;if(e!=null)return l(Math.abs(e));let c;switch(s){case"fixed":c=a;break;case"cash":c=a/r;break;case"percent_of_equity":{c=n.equity*a/100/r;break}default:c=a}return l(c)}function Sp(t){if(!t.strategy)return;const e=t.strategy,{pending_orders:i}=e,r=y.from(t.data.open).get(0),n=y.from(t.data.high).get(0),s=y.from(t.data.low).get(0),a=y.from(t.data.close).get(0),o=y.from(t.data.openTime).get(0),l=t.pine?.syminfo?.pointvalue??1;for(const c of e.opentrades){const u=Math.abs(c.size),p=c.size>0,h=c.commission??0,f=p?(c.entry_price-s)*u*l:(n-c.entry_price)*u*l,d=p?(n-c.entry_price)*u*l:(c.entry_price-s)*u*l,m=Math.max(0,f)+h,x=Math.max(0,d-h);m>(c.max_drawdown??0)&&(c.max_drawdown=m),x>(c.max_runup??0)&&(c.max_runup=x)}qi(t,r);for(const c of i){if(c.status!=="pending"||(c.category??"entry")==="exit"||c.bar>=t.idx)continue;let u=!1,p=r;switch(c.type){case"market":u=!0,p=r;break;case"limit":if(c.limit!==void 0){const h=ei(c.direction);(h===1&&s<=c.limit||h===-1&&n>=c.limit)&&(u=!0,p=c.limit)}break;case"stop":if(c.stop!==void 0){const h=ei(c.direction);(h===1&&n>=c.stop||h===-1&&s<=c.stop)&&(u=!0,p=c.stop)}break}if(u){if(Np(e,c)){c.status="cancelled";continue}const h=ei(c.direction);p=Cr(t,h,p);const f=h===1?e.config.margin_long??100:e.config.margin_short??100;if(f<100){const d=e.position_size,m=Math.sign(d),x=m!==0&&m!==h?Math.max(0,c.qty-Math.abs(d)):c.qty;if(x>0){const b=t.pine?.syminfo?.pointvalue??1;let v=0;m===h&&(v=wp(t,r));const w=e.equity-v;if(Fr(x,p,f,b)>w){c.status="cancelled";continue}}}Ip(t,c,p,o),c.status="filled",c.fill_price=p,c.fill_bar=t.idx,c.fill_time=o}}e.pending_orders=i.filter(c=>c.status==="pending"),qi(t,a),Dp(t)}function ei(t){return typeof t=="number"?t:t==="long"?1:t==="short"?-1:0}function Nr(t,e,i,r){const n=e.config.commission_type??"percent",s=e.config.commission_value??0;if(!s||s===0)return 0;const a=t.pine?.syminfo?.pointvalue??1;switch(n){case"percent":return Math.abs(i)*r*a*(s/100);case"cash_per_contract":return Math.abs(i)*s;case"cash_per_order":return s;default:return 0}}function Cr(t,e,i){const r=t.strategy.config.slippage??0;if(!r||r===0)return i;const n=t.pine?.syminfo?.mintick??.01,s=r*n;return e===1?i+s:i-s}function As(t){const e=Math.abs(t.position_size);e>t.max_contracts_held_all&&(t.max_contracts_held_all=e),t.position_size>t.max_contracts_held_long&&(t.max_contracts_held_long=t.position_size),-t.position_size>t.max_contracts_held_short&&(t.max_contracts_held_short=-t.position_size)}function Ep(t,e){const i=t.config.pyramiding??1;let r=0;for(const n of t.opentrades)Math.sign(n.size)===e&&r++;return r>=i}function Np(t,e){if(t.risk_halted)return!0;const i=t.risk_rules,r=e.direction;if(i.allow_entry_in&&(i.allow_entry_in==="long"&&r===-1||i.allow_entry_in==="short"&&r===1))return!0;if(i.max_position_size!==void 0){const n=t.position_size+r*e.qty;if(Math.abs(n)>i.max_position_size)return!0}return!1}function Cp(t){if(t.risk_halted)return;const e=t.risk_rules;if(e.max_drawdown){const i=e.max_drawdown.type==="percent_of_equity"?e.max_drawdown.value/100*t.equity_peak:e.max_drawdown.value;if(t.max_drawdown>=i){t.risk_halted=!0;return}}if(e.max_intraday_loss){const i=e.max_intraday_loss.type==="percent_of_equity"?e.max_intraday_loss.value/100*t.initial_capital:e.max_intraday_loss.value;if(t.grossloss>=i){t.risk_halted=!0;return}}if(e.max_cons_loss_days){let i=0;for(let r=t.closedtrades.length-1;r>=0&&(t.closedtrades[r].profit??0)<0;r--)i++;i>=e.max_cons_loss_days.count&&(t.risk_halted=!0)}}function dn(t,e,i,r,n,s,a,o){const l=t.strategy,c=l.opentrades.length+l.closedtrades.length,u=l.config.commission_type??"percent",p=o&&u==="cash_per_order",h=Nr(t,l,r,n),f=p?h/2:h,d={id:`trade_${c}`,entry_id:e,entry_comment:a??e,entry_price:n,entry_bar_index:t.idx,entry_time:s,size:i*r,commission:f,max_drawdown:0,max_runup:0,status:"open"};l.opentrades.push(d),f>0&&(l.netprofit-=f,l.grossloss+=f);const m=y.from(t.data.high).get(0),x=y.from(t.data.low).get(0),b=t.pine?.syminfo?.mintick??.01;let v=i===1?x:m,w=i===1?m:x;for(const k of l.pending_orders){if((k.category??"entry")!=="exit"||k.from_entry&&k.from_entry!==e)continue;let U;k.stop!==void 0?U=k.stop:k.loss!==void 0&&(U=i===1?n-k.loss*b:n+k.loss*b);let R;k.limit!==void 0?R=k.limit:k.profit!==void 0&&(R=i===1?n+k.profit*b:n-k.profit*b),i===1?(U!==void 0&&U>v&&(v=U),R!==void 0&&R<w&&(w=R)):(U!==void 0&&U<v&&(v=U),R!==void 0&&R>w&&(w=R))}const E=t.pine?.syminfo?.pointvalue??1,T=i===1?(n-v)*r*E:(v-n)*r*E,N=i===1?(w-n)*r*E:(n-w)*r*E;d.max_drawdown=Math.max(0,T)+f,d.max_runup=Math.max(0,N-f);const A=l.position_size,O=A+d.size;if(A===0)l.position_size=O,l.position_avg_price=n,l.position_entry_name=e;else if(Math.sign(A)===Math.sign(O)){const k=Math.abs(A)*l.position_avg_price+r*n,U=Math.abs(O);l.position_avg_price=k/U,l.position_size=O}As(l)}function Ip(t,e,i,r){const n=t.strategy,s=ei(e.direction),a=n.position_size,o=Math.sign(a);if(o===1&&s===-1||o===-1&&s===1){const l=Math.min(Math.abs(a),e.qty),c=e.qty-l,u=c>0;Ui(t,l,i,r,{exitId:e.id,exitComment:e.comment,isImplicitReversal:u}),c>0&&dn(t,e.id,s,c,i,r,e.comment,!0)}else dn(t,e.id,s,e.qty,i,r,e.comment)}function Ui(t,e,i,r,n){const s=t.strategy,a=t.pine?.syminfo?.pointvalue??1;let o=e;const l=[...s.opentrades];s.opentrades=[];for(const h of l){if(o<=0){s.opentrades.push(h);continue}const f=Math.abs(h.size),d=Math.min(f,o),m=Math.sign(h.size);if(d>=f){h.status="closed",h.exit_price=i,h.exit_bar_index=t.idx,h.exit_time=r;const x=(m===1?i-h.entry_price:h.entry_price-i)*f*a,b=h.commission??0,v=s.config.commission_type??"percent",w=n?.isImplicitReversal&&v==="cash_per_order",E=Nr(t,s,f,i),T=w?E/2:E;h.commission=b+T,n?.triggerKind==="loss"&&(h.max_runup=0),n?.triggerKind==="profit"&&(h.max_drawdown=b),n?.exitId!==void 0&&(h.exit_id=n.exitId),n?.exitComment!==void 0&&(h.exit_comment=n.exitComment),h.profit=x-h.commission;const N=x-T;s.netprofit+=N,s.grossloss-=b,h.profit>0?(s.grossprofit+=h.profit,s.wintrades++,s.wintrades_total_profit+=h.profit):h.profit<0?(s.grossloss+=Math.abs(h.profit),s.losstrades++,s.losstrades_total_loss+=Math.abs(h.profit)):s.eventrades++,s.closedtrades.push(h),o-=d}else{const x=s.opentrades.length+s.closedtrades.length,b=(m===1?i-h.entry_price:h.entry_price-i)*d*a,v=(h.commission??0)*(d/f),w=s.config.commission_type??"percent",E=n?.isImplicitReversal&&w==="cash_per_order",T=Nr(t,s,d,i),N=E?T/2:T,A=v+N,O={...h,id:`trade_${x}`,size:m*d,status:"closed",exit_price:i,exit_bar_index:t.idx,exit_time:r,commission:A,profit:b-A,exit_id:n?.exitId??h.exit_id,exit_comment:n?.exitComment??h.exit_comment};n?.triggerKind==="loss"&&(O.max_runup=0),n?.triggerKind==="profit"&&(O.max_drawdown=v);const k=b-N;s.netprofit+=k,s.grossloss-=v,O.profit>0?(s.grossprofit+=O.profit,s.wintrades++,s.wintrades_total_profit+=O.profit):O.profit<0?(s.grossloss+=Math.abs(O.profit),s.losstrades++,s.losstrades_total_loss+=Math.abs(O.profit)):s.eventrades++,s.closedtrades.push(O),h.size=m*(f-d),h.commission=(h.commission??0)-v,s.opentrades.push(h),o=0}}Cp(s);const c=s.position_size,u=Math.sign(c)*e,p=c-u;if(s.position_size=p,As(s),p===0)s.position_avg_price=NaN,s.position_entry_name="";else if(s.opentrades.length>0){let h=0,f=0;for(const d of s.opentrades){const m=Math.abs(d.size);h+=m*d.entry_price,f+=m}s.position_avg_price=h/f,s.position_entry_name=s.opentrades[0].entry_id}}function qi(t,e){const i=t.strategy,r=t.pine?.syminfo?.pointvalue??1;let n=0;for(const s of i.opentrades){const a=Math.abs(s.size),o=Math.sign(s.size)===1?e-s.entry_price:s.entry_price-e;n+=o*a*r}i.openprofit=n,i.equity=i.initial_capital+i.netprofit+n}function kp(t,e,i){const r=t.strategy,n=t.pine?.syminfo?.pointvalue??1,s=r.initial_capital+r.netprofit;s>r.equity_peak&&(r.equity_peak=s),s<r.equity_trough&&(r.equity_trough=s);const a=r.position_size,o=r.position_avg_price;let l=0,c=0;if(a!==0&&Number.isFinite(o)){const h=a>0?i:e,f=a>0?e:i;l=a*(o-h)*n,c=a*(f-o)*n}const u=r.equity_peak-s+l;if(u>r.max_drawdown&&(r.max_drawdown=u,r.equity_at_drawdown_peak=r.equity_peak,r.equity_peak>0)){const h=100*u/r.equity_peak;h>r.max_drawdown_percent_value&&(r.max_drawdown_percent_value=h)}const p=s-r.equity_trough+c;if(p>r.max_runup&&(r.max_runup=p,r.equity_at_runup_peak=s+c,r.equity_at_runup_peak>0)){const h=100*p/r.equity_at_runup_peak;h>r.max_runup_percent_value&&(r.max_runup_percent_value=h)}}function mn(t,e,i,r,n,s){const a=t.strategy;if(!e||e===""){Ui(t,i,r,n,s);return}const o=[],l=[];for(const p of a.opentrades)p.entry_id===e?o.push(p):l.push(p);const c=o.reduce((p,h)=>p+Math.abs(h.size),0);if(c===0)return;const u=Math.min(i,c);a.opentrades=[...o,...l],Ui(t,u,r,n,s)}function Tp(t){if(!t.strategy)return;const e=t.strategy;if(e.pending_orders.length===0)return;const i=y.from(t.data.open).get(0),r=y.from(t.data.high).get(0),n=y.from(t.data.low).get(0),s=y.from(t.data.close).get(0),a=y.from(t.data.openTime).get(0),o=t.pine?.syminfo?.mintick??.01;for(const l of e.pending_orders){if(l.status!=="pending"||(l.category??"entry")!=="exit")continue;const c=e.opentrades.filter(R=>!l.from_entry||R.entry_id===l.from_entry);if(c.length===0){l.status="cancelled";continue}const u=c.reduce((R,Y)=>R+Math.abs(Y.size),0),p=Math.sign(c[0].size);if(l.type==="market"&&l.profit===void 0&&l.loss===void 0&&l.limit===void 0&&l.stop===void 0&&l.trail_price===void 0&&l.trail_points===void 0){if(l.bar>=t.idx)continue;let R=l.immediately?s:i;R=Cr(t,-p,R);let Y=u;l.qty&&l.qty>0?Y=Math.min(l.qty,u):l.qty_percent&&l.qty_percent>0&&(Y=u*(l.qty_percent/100)),mn(t,l.from_entry,Y,R,a,{exitId:l.id,exitComment:l.comment}),l.status="filled",l.fill_price=R,l.fill_bar=t.idx,l.fill_time=a;continue}let h=0;for(const R of c)h+=Math.abs(R.size)*R.entry_price;const f=h/u,d=p===1;let m;l.limit!==void 0?m=l.limit:l.profit!==void 0&&(m=d?f+l.profit*o:f-l.profit*o);let x;l.stop!==void 0?x=l.stop:l.loss!==void 0&&(x=d?f-l.loss*o:f+l.loss*o),l._isPersistent||(x!==void 0&&((d?x<f:x>f)||(x=void 0)),m!==void 0&&((d?m>f:m<f)||(m=void 0))),l._attachedAtReversal&&!l._isPersistent&&(l.limit!==void 0&&(m=void 0),l.stop!==void 0&&(x=void 0));let b=!1;if(!l.trail_armed&&(l.trail_price!==void 0||l.trail_points!==void 0)){let R;l.trail_price!==void 0?R=l.trail_price:l.trail_points!==void 0&&(R=d?f+l.trail_points*o:f-l.trail_points*o),R!==void 0&&(d?r>=R:n<=R)&&(l.trail_armed=!0,l.trail_peak=d?r:n,b=!0)}else l.trail_armed&&(d?l.trail_peak=Math.max(l.trail_peak??-1/0,r):l.trail_peak=Math.min(l.trail_peak??1/0,n));let v;l.trail_armed&&l.trail_peak!==void 0&&l.trail_offset!==void 0&&(v=d?l.trail_peak-l.trail_offset*o:l.trail_peak+l.trail_offset*o);const w=Math.abs(r-i)<=Math.abs(i-n),E=d?w:!w;let T=!1,N=NaN,A=null;const O=()=>{T||x===void 0||(d?n<=x:r>=x)&&(T=!0,N=(d?i<=x:i>=x)?i:x,A="loss")},k=()=>{T||v===void 0||b||(d?n<=v:r>=v)&&(T=!0,N=(d?i<=v:i>=v)?i:v,A="trailing")},U=()=>{T||m===void 0||(d?r>=m:n<=m)&&(T=!0,N=(d?i>=m:i<=m)?i:m,A="profit")};if(E?(U(),O(),k()):(O(),k(),U()),T){const R=Cr(t,-p,N);let Y=u;l.qty&&l.qty>0?Y=Math.min(l.qty,u):l.qty_percent&&l.qty_percent>0&&(Y=u*(l.qty_percent/100));const $=A==="profit"?l.comment_profit??l.comment:A==="loss"?l.comment_loss??l.comment:A==="trailing"?l.comment_trailing??l.comment:l.comment;mn(t,l.from_entry,Y,R,a,{triggerKind:A,exitId:l.id,exitComment:$}),l.status="filled",l.fill_price=R,l.fill_bar=t.idx,l.fill_time=a}}e.pending_orders=e.pending_orders.filter(l=>l.status==="pending"),qi(t,s)}function Ap(t){const e=t.strategy;if(!e||e.opentrades.length===0)return;const i=Math.sign(e.position_size);if(i===0)return;const r=i===1?e.config.margin_long??100:e.config.margin_short??100;if(r>=100)return;const n=y.from(t.data.high).get(0),s=y.from(t.data.low).get(0),a=y.from(t.data.openTime).get(0),o=t.pine?.syminfo?.pointvalue??1,l=i===1?s:n,c=Math.abs(e.position_size),u=vp(t,l),p=Fr(c,l,r,o);u<p&&Ui(t,c,l,a,{exitId:"Margin call",exitComment:"Margin call"})}function Pp(t){if(!t.strategy)return;const e=y.from(t.data.high).get(0),i=y.from(t.data.low).get(0),r=y.from(t.data.close).get(0);qi(t,r),kp(t,e,i)}function Dp(t){t.strategy}function Mp(t,e){const i={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"right",pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:"fixed",default_qty_value:1,initial_capital:1e6,currency:"USD",slippage:0,commission_type:"percent",commission_value:0,margin_long:100,margin_short:100,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,max_polylines_count:50,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,...e,...t._propOverrides??{}},r=i.initial_capital;t.strategy={config:i,opentrades:[],closedtrades:[],pending_orders:[],position_size:0,position_avg_price:NaN,position_entry_name:"",initial_capital:r,account_currency:i.currency||"USD",equity:r,netprofit:0,grossprofit:0,grossloss:0,openprofit:0,max_drawdown:0,max_runup:0,equity_peak:r,equity_trough:r,equity_at_runup_peak:r,equity_at_drawdown_peak:r,max_drawdown_percent_value:0,max_runup_percent_value:0,wintrades:0,losstrades:0,eventrades:0,wintrades_total_profit:0,losstrades_total_loss:0,max_contracts_held_all:0,max_contracts_held_long:0,max_contracts_held_short:0,risk_rules:{},risk_halted:!1,_exit_call_history:new Map,_exit_fallback_counter:0,_exit_fallback_last_bar:-1}}function Rp(t){return(...e)=>{const i=bp(e);return t.strategy?t.strategy.config={...t.strategy.config,...i,...t._propOverrides??{}}:Mp(t,i),t.strategy.config}}const Op=[["id","direction","qty","limit","stop","oca_name","oca_type","comment","alert_message","disable_alert"]],$p={id:"string",direction:"series",qty:"series",limit:"series",stop:"series",oca_name:"string",oca_type:"string",comment:"string",alert_message:"string",disable_alert:"boolean"};function Vp(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.order() called before strategy() declaration");const i=te(e,Op,$p),r=v=>v==null||typeof v=="string"||typeof v=="number"||typeof v=="boolean"?v:typeof v=="function"?v():v instanceof y?v.get(0):Array.isArray(v)?v[v.length-1]:typeof v=="object"&&v.get!==void 0?v.get(0):v,n=r(i.id),s=r(i.direction),a=r(i.qty),o=r(i.limit),l=r(i.stop),c=r(i.oca_name),u=r(i.oca_type),p=r(i.comment),h=ei(s),f=y.from(t.data.close).get(0),d=Wr(t,a,h,f);let m="market";o!==void 0&&l!==void 0?m="stop-limit":o!==void 0?m="limit":l!==void 0&&(m="stop");const x=y.from(t.data.openTime).get(0),b={id:n,direction:h,qty:d,type:m,limit:o,stop:l,bar:t.idx,time:x,status:"pending",oca_name:c,oca_type:u,comment:p};return t.strategy.pending_orders.push(b),b}}function jp(t){return(e,i)=>y.from(e).get(i||0)}function Lp(t){return()=>{const e=(t.strategy?.opentrades??[]).slice(),i=h=>e[Number(h)],r=()=>{const h=t.marketData;return Array.isArray(h)&&t.idx>=0&&t.idx<h.length?h[t.idx]?.close??NaN:NaN},n={valueOf(){return e.length},toString(){return String(e.length)},[Symbol.toPrimitive](){return e.length}},s=t.pine?.syminfo?.pointvalue??1,a=(h,f)=>{const d=t.strategy?.config,m=d?.commission_type??"percent",x=d?.commission_value??0;if(!x)return 0;const b=Math.abs(h.size);switch(m){case"percent":return b*f*s*(x/100);case"cash_per_contract":return b*x;case"cash_per_order":return x;default:return 0}},o=h=>Math.abs(h.size)*h.entry_price*s+(h.commission??0);n.profit=h=>{const f=i(h);if(!f)return NaN;const d=r();return Number.isFinite(d)?(Math.sign(f.size)===1?d-f.entry_price:f.entry_price-d)*Math.abs(f.size)*s-(f.commission??0)-a(f,d):NaN},n.profit_percent=h=>{const f=i(h);if(!f)return NaN;const d=n.profit(h);if(!Number.isFinite(d))return NaN;const m=o(f);return m>0?100*d/m:NaN},n.size=h=>i(h)?.size??NaN,n.commission=h=>i(h)?.commission??NaN,n.entry_price=h=>i(h)?.entry_price??NaN,n.entry_bar_index=h=>i(h)?.entry_bar_index??NaN,n.entry_id=h=>i(h)?.entry_id??"",n.entry_comment=h=>i(h)?.entry_comment??i(h)?.entry_id??"",n.entry_time=h=>i(h)?.entry_time??NaN,n.max_drawdown=h=>i(h)?.max_drawdown??0,n.max_drawdown_percent=h=>{const f=i(h);if(!f||!f.max_drawdown)return 0;const d=o(f);return d>0?100*f.max_drawdown/d:0},n.max_runup=h=>i(h)?.max_runup??0,n.max_runup_percent=h=>{const f=i(h);if(!f||!f.max_runup)return 0;const d=o(f);return d>0?100*f.max_runup/d:0};const l=t.strategy,c=l?.config?.margin_long??100,u=l?.config?.margin_short??100,p=c!==100||u!==100;if(!l||l.opentrades.length===0||!p)n.capital_held=NaN;else{let h=0;for(const f of l.opentrades){const d=Math.abs(f.size)*f.entry_price,m=f.size>0?c:u;h+=d*(m/100)}n.capital_held=h}return n}}function Bp(t){return()=>{const e=(t.strategy?.closedtrades??[]).slice(),i=a=>e[Number(a)],r={valueOf(){return e.length},toString(){return String(e.length)},[Symbol.toPrimitive](){return e.length}},n=t.pine?.syminfo?.pointvalue??1,s=a=>{const o=Math.abs(a.size)*a.entry_price*n,l=(a.commission??0)/2;return o+l};return r.profit=a=>i(a)?.profit??NaN,r.profit_percent=a=>{const o=i(a);if(!o||o.profit===void 0)return NaN;const l=s(o);return l>0?100*o.profit/l:NaN},r.size=a=>i(a)?.size??NaN,r.commission=a=>i(a)?.commission??NaN,r.entry_price=a=>i(a)?.entry_price??NaN,r.entry_bar_index=a=>i(a)?.entry_bar_index??NaN,r.entry_id=a=>i(a)?.entry_id??"",r.entry_comment=a=>i(a)?.entry_comment??i(a)?.entry_id??"",r.entry_time=a=>i(a)?.entry_time??NaN,r.exit_price=a=>i(a)?.exit_price??NaN,r.exit_bar_index=a=>i(a)?.exit_bar_index??NaN,r.exit_id=a=>i(a)?.exit_id??"",r.exit_comment=a=>i(a)?.exit_comment??i(a)?.exit_id??"",r.exit_time=a=>i(a)?.exit_time??NaN,r.max_drawdown=a=>i(a)?.max_drawdown??0,r.max_drawdown_percent=a=>{const o=i(a);if(!o||!o.max_drawdown)return 0;const l=s(o);return l>0?100*o.max_drawdown/l:0},r.max_runup=a=>i(a)?.max_runup??0,r.max_runup_percent=a=>{const o=i(a);if(!o||!o.max_runup)return 0;const l=s(o);return l>0?100*o.max_runup/l:0},r.first_index=0,r}}function Fp(t){return()=>t.strategy?.netprofit??0}function Wp(t){return()=>t.strategy?.position_size??0}function Up(t){return()=>{const e=t.strategy;return!e||e.position_size===0?NaN:e.position_avg_price}}function qp(t){return()=>t.strategy?.equity??t.strategy?.config?.initial_capital??1e4}function zp(t){return()=>"long"}function Kp(t){return()=>"short"}function Hp(t){return()=>"cash"}function Gp(t){return()=>"percent_of_equity"}function Yp(t){return()=>"fixed"}function Xp(t){return()=>t.strategy?.openprofit??0}function Zp(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.openprofit/e.initial_capital}}function Qp(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.netprofit/e.initial_capital}}function Jp(t){return()=>t.strategy?.grossprofit??0}function ef(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.grossprofit/e.initial_capital}}function tf(t){return()=>t.strategy?.grossloss??0}function rf(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.grossloss/e.initial_capital}}function nf(t){return()=>t.strategy?.wintrades??0}function sf(t){return()=>t.strategy?.losstrades??0}function af(t){return()=>t.strategy?.eventrades??0}function of(t){return()=>{const e=t.strategy;return!e||!e.closedtrades||e.closedtrades.length===0?NaN:e.netprofit/e.closedtrades.length}}function lf(t){return()=>{const e=t.strategy;if(!e||!e.closedtrades||e.closedtrades.length===0)return NaN;let i=0;for(const r of e.closedtrades){const n=Math.abs(r.size)*r.entry_price;n>0&&(i+=100*(r.profit??0)/n)}return i/e.closedtrades.length}}function cf(t){return()=>{const e=t.strategy;return!e||e.wintrades===0?NaN:e.wintrades_total_profit/e.wintrades}}function uf(t){return()=>{const e=t.strategy;if(!e||e.wintrades===0)return NaN;let i=0;for(const r of e.closedtrades)if((r.profit??0)>0){const n=Math.abs(r.size)*r.entry_price;n>0&&(i+=100*(r.profit??0)/n)}return i/e.wintrades}}function hf(t){return()=>{const e=t.strategy;return!e||e.losstrades===0?NaN:e.losstrades_total_loss/e.losstrades}}function pf(t){return()=>{const e=t.strategy;if(!e||e.losstrades===0)return NaN;let i=0;for(const r of e.closedtrades)if((r.profit??0)<0){const n=Math.abs(r.size)*r.entry_price;n>0&&(i+=100*(r.profit??0)/n)}return i/e.losstrades}}function ff(t){return()=>t.strategy?.max_drawdown??0}function df(t){return()=>{const e=t.strategy;return e?e.max_drawdown_percent_value??0:0}}function mf(t){return()=>t.strategy?.max_runup??0}function yf(t){return()=>{const e=t.strategy;return e?e.max_runup_percent_value??0:0}}function _f(t){return()=>t.strategy?.max_contracts_held_all??0}function gf(t){return()=>t.strategy?.max_contracts_held_long??0}function xf(t){return()=>t.strategy?.max_contracts_held_short??0}function bf(t){return()=>t.strategy?.position_entry_name??""}function vf(t){return()=>t.strategy?.initial_capital??0}function wf(t){return()=>t.strategy?.account_currency??"USD"}function Sf(t){return()=>{const e=t.strategy;if(!e||e.position_size===0)return NaN;const i=e.position_avg_price;if(!Number.isFinite(i))return NaN;const r=Math.sign(e.position_size),n=r===1?e.config.margin_long??100:e.config.margin_short??100;if(n>=100)return NaN;const s=Math.abs(e.position_size),a=t.pine?.syminfo?.pointvalue??1,o=((e.initial_capital??0)+(e.netprofit??0))/(a*s)-r*i,l=n/100-r,c=o/l,u=t.pine?.syminfo?.mintick??.01;return r===1?Math.floor(c/u)*u:Math.ceil(c/u)*u}}const Ef=[["id","direction","qty","limit","stop","oca_name","oca_type","comment","alert_message","disable_alert"]],Nf={id:"string",direction:"series",qty:"series",limit:"series",stop:"series",oca_name:"string",oca_type:"string",comment:"string",alert_message:"string",disable_alert:"boolean"};function Cf(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.entry() called before strategy() declaration");const i=te(e,Ef,Nf),r=k=>k==null||typeof k=="string"||typeof k=="number"||typeof k=="boolean"?k:typeof k=="function"?k():k instanceof y?k.get(0):Array.isArray(k)?k[k.length-1]:typeof k=="object"&&k.get!==void 0?k.get(0):k,n=r(i.id),s=r(i.direction),a=r(i.qty),o=r(i.limit),l=r(i.stop),c=r(i.oca_name),u=r(i.oca_type),p=r(i.comment),h=ei(s),f=t.strategy,d=f.position_size;if(Math.sign(d)===h&&d!==0&&Ep(f,h))return;const m=y.from(t.data.close).get(0),x=Wr(t,a,h,m),b=d!==0&&Math.sign(d)!==h,v=b?Math.abs(d)+x:x;let w="market";o!==void 0&&l!==void 0?w="stop-limit":o!==void 0?w="limit":l!==void 0&&(w="stop");const E=t.pine?.syminfo?.mintick??0,T=o!==void 0?hi(o,m,E):void 0,N=l!==void 0?hi(l,m,E):void 0,A=y.from(t.data.openTime).get(0),O={id:n,direction:h,qty:v,type:w,limit:T,stop:N,bar:t.idx,time:A,status:"pending",category:"entry",oca_name:c,oca_type:u,comment:p,_isReversalEntry:b};f.pending_orders.push(O)}}const If=[["id","from_entry","qty","qty_percent","profit","limit","loss","stop","trail_price","trail_points","trail_offset","oca_name","comment","comment_profit","comment_loss","comment_trailing","alert_message","alert_profit","alert_loss","alert_trailing","disable_alert"]],kf={id:"string",from_entry:"string",qty:"series",qty_percent:"series",profit:"series",limit:"series",loss:"series",stop:"series",trail_price:"series",trail_points:"series",trail_offset:"series",oca_name:"string",comment:"string",comment_profit:"string",comment_loss:"string",comment_trailing:"string",alert_message:"string",alert_profit:"string",alert_loss:"string",alert_trailing:"string",disable_alert:"boolean"};function Tf(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.exit() called before strategy() declaration");let i=et(e);if(i===void 0){const $=t.strategy;$._exit_fallback_last_bar!==t.idx&&($._exit_fallback_counter=0,$._exit_fallback_last_bar=t.idx),i=`exit_raw_${$._exit_fallback_counter++}`}const r=te(e,If,kf),n=$=>$==null||typeof $=="string"||typeof $=="number"||typeof $=="boolean"?$:typeof $=="function"?$():$ instanceof y?$.get(0):Array.isArray($)?$[$.length-1]:typeof $=="object"&&$.get!==void 0?$.get(0):$,s=n(r.id),a=n(r.from_entry),o=n(r.qty),l=n(r.qty_percent),c=n(r.profit),u=n(r.limit),p=n(r.loss),h=n(r.stop),f=n(r.trail_price),d=n(r.trail_points),m=n(r.trail_offset),x=t.pine?.syminfo?.mintick??0,b=y.from(t.data.close).get(0),v=u!==void 0?hi(u,b,x):void 0,w=h!==void 0?hi(h,b,x):void 0,E=f!==void 0?hi(f,b,x):void 0,T=a??"",N=!!(T?t.strategy.pending_orders.find($=>$.category==="entry"&&$.id===T&&$.status==="pending"):t.strategy.pending_orders.find($=>$.category==="entry"&&$.status==="pending"))?._isReversalEntry,A=t.strategy._exit_call_history,O=A.get(i),k=O!==void 0&&O===t.idx-1;A.set(i,t.idx);const U={id:s??"exit",direction:0,qty:o!==void 0?Math.abs(Number(o)):0,qty_percent:l,type:"market",bar:t.idx,time:y.from(t.data.openTime).get(0),status:"pending",category:"exit",from_entry:T,profit:c,loss:p,limit:v,stop:w,trail_price:E,trail_points:d,trail_offset:m,oca_name:n(r.oca_name),comment:n(r.comment),comment_profit:n(r.comment_profit),comment_loss:n(r.comment_loss),comment_trailing:n(r.comment_trailing),alert_message:n(r.alert_message),alert_profit:n(r.alert_profit),alert_loss:n(r.alert_loss),alert_trailing:n(r.alert_trailing),disable_alert:n(r.disable_alert),trail_armed:!1,trail_peak:NaN,_attachedAtReversal:N,_isPersistent:k,_callsiteId:i},R=U.id,Y=t.strategy.pending_orders;for(let $=Y.length-1;$>=0;$--){const q=Y[$];q.category==="exit"&&q.id===R&&(q.from_entry??"")===(U.from_entry??"")&&q.status==="pending"&&Y.splice($,1)}Y.push(U)}}const Af=[["id","comment","qty","qty_percent","alert_message","immediately","disable_alert"]],Pf={id:"string",comment:"string",qty:"series",qty_percent:"series",alert_message:"string",immediately:"boolean",disable_alert:"boolean"};function Df(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.close() called before strategy() declaration");const i=te(e,Af,Pf),r=i.id;if(r==null)return;const n=o=>(o.category??"entry")==="exit"&&(o.profit!==void 0||o.loss!==void 0||o.limit!==void 0||o.stop!==void 0||o.trail_price!==void 0||o.trail_points!==void 0),s=t.strategy.pending_orders;for(const o of s)n(o)&&(o.from_entry??"")===r&&o.status==="pending"&&(o.status="cancelled");t.strategy.pending_orders=s.filter(o=>o.status==="pending");const a={id:`close_${r}`,direction:0,qty:0,type:"market",bar:t.idx,time:y.from(t.data.openTime).get(0),status:"pending",category:"exit",from_entry:r,qty_percent:i.qty_percent,comment:i.comment,alert_message:i.alert_message,immediately:i.immediately===!0,disable_alert:i.disable_alert};i.qty!==void 0&&(a.qty=Math.abs(Number(i.qty))),t.strategy.pending_orders.push(a)}}const Mf=[["comment","alert_message","immediately","disable_alert"]],Rf={comment:"string",alert_message:"string",immediately:"boolean",disable_alert:"boolean"};function Of(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.close_all() called before strategy() declaration");const i=te(e,Mf,Rf),r=a=>(a.category??"entry")==="exit"&&(a.profit!==void 0||a.loss!==void 0||a.limit!==void 0||a.stop!==void 0||a.trail_price!==void 0||a.trail_points!==void 0),n=t.strategy.pending_orders;for(const a of n)r(a)&&a.status==="pending"&&(a.status="cancelled");t.strategy.pending_orders=n.filter(a=>a.status==="pending");const s={id:"close_all",direction:0,qty:0,type:"market",bar:t.idx,time:y.from(t.data.openTime).get(0),status:"pending",category:"exit",from_entry:"",comment:i.comment,alert_message:i.alert_message,immediately:i.immediately===!0,disable_alert:i.disable_alert};t.strategy.pending_orders.push(s)}}const $f=[["id","immediately"]],Vf={id:"string",immediately:"boolean"};function jf(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.cancel() called before strategy() declaration");const i=te(e,$f,Vf).id;i!=null&&(t.strategy.pending_orders=t.strategy.pending_orders.filter(r=>!(r.status==="pending"&&r.id===i)))}}function Lf(t){return()=>{if(!t.strategy)throw new Error("strategy.cancel_all() called before strategy() declaration");t.strategy.pending_orders=t.strategy.pending_orders.filter(e=>!(e.status==="pending"&&(e.category??"entry")==="entry"))}}function Bf(t){return{allow_entry_in:e=>{t.strategy&&(t.strategy.risk_rules.allow_entry_in=e)},max_cons_loss_days:(e,i)=>{t.strategy&&(t.strategy.risk_rules.max_cons_loss_days={count:e,alert_message:i})},max_drawdown:(e,i,r)=>{t.strategy&&(t.strategy.risk_rules.max_drawdown={value:e,type:i})},max_intraday_filled_orders:(e,i)=>{t.strategy&&(t.strategy.risk_rules.max_intraday_filled_orders={count:e,alert_message:i})},max_intraday_loss:(e,i,r)=>{t.strategy&&(t.strategy.risk_rules.max_intraday_loss={value:e,type:i})},max_position_size:e=>{t.strategy&&(t.strategy.risk_rules.max_position_size=e)}}}function Ff(t){return e=>{const i=t.strategy,r=t.pine?.syminfo?.currency,n=i?.account_currency??"USD";return r&&r!==n?NaN:e}}function Wf(t){return e=>{const i=t.strategy,r=t.pine?.syminfo?.currency,n=i?.account_currency??"USD";return r&&r!==n?NaN:e}}function Uf(t){return e=>t.strategy?Wr(t,void 0,1,e):0}const qf={any:Rp,order:Vp,param:jp,opentrades:Lp,closedtrades:Bp,netprofit:Fp,position_size:Wp,position_avg_price:Up,equity:qp,long:zp,short:Kp,cash:Hp,percent_of_equity:Gp,fixed:Yp,openprofit:Xp,openprofit_percent:Zp,netprofit_percent:Qp,grossprofit:Jp,grossprofit_percent:ef,grossloss:tf,grossloss_percent:rf,wintrades:nf,losstrades:sf,eventrades:af,avg_trade:of,avg_trade_percent:lf,avg_winning_trade:cf,avg_winning_trade_percent:uf,avg_losing_trade:hf,avg_losing_trade_percent:pf,max_drawdown:ff,max_drawdown_percent:df,max_runup:mf,max_runup_percent:yf,max_contracts_held_all:_f,max_contracts_held_long:gf,max_contracts_held_short:xf,position_entry_name:bf,initial_capital:vf,account_currency:wf,margin_liquidation_price:Sf,entry:Cf,exit:Tf,close:Df,close_all:Of,cancel:jf,cancel_all:Lf,convert_to_account:Ff,convert_to_symbol:Wf,default_entry_qty:Uf},zf={long:"long",short:"short",all:"all"},Kf={none:"none",cancel:"cancel",reduce:"reduce"},Hf={percent:"percent",cash_per_order:"cash_per_order",cash_per_contract:"cash_per_contract"};class Gf{constructor(e){this.context=e,Object.entries(qf).forEach(([r,n])=>{this[r]=n(e)}),this.direction=()=>zf,this.oca=()=>Kf,this.commission=()=>Hf;const i=Bf(e);this.risk=()=>i}}function Yf(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"||i==="Etc/UTC")return 0;const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const a=r[1]==="+"?1:-1,o=parseInt(r[2],10),l=parseInt(r[3]||"0",10);return a*(o*60+l)}const n=Rt(t,e),s=new Date(Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second));return Math.round((s.getTime()-t)/6e4)}function Xf(t,e){const i=e>=0?"+":"-",r=s=>String(Math.floor(Math.abs(s))).padStart(2,"0"),n=i+r(e/60)+":"+r(e%60);return`[${new Date(t+e*6e4).toISOString().slice(0,-1)}${n}]`}class Zf{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,n)=>i[n])}param(e,i=0,r){return y.from(e).get(i)}_formatTimestamp(){const e=this.context.data.openTime.data[this.context.idx],i=this.context.chartTimezone||this.context.pine?.syminfo?.timezone||"UTC",r=Yf(e,i);return Xf(e,r)}warning(e,...i){this.context.isSecondaryContext||console.warn(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}error(e,...i){this.context.isSecondaryContext||console.error(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}info(e,...i){this.context.isSecondaryContext||console.log(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}}const Qf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Jf=["January","February","March","April","May","June","July","August","September","October","November","December"],ed=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],td=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ve=(t,e)=>String(t).padStart(e,"0");class id{constructor(e){this.context=e}param(e,i=0,r){return y.from(e).get(i)}tostring(e,i){if(typeof e!="number"||isNaN(e)||!i)return String(e);if(i==="mintick"){const n=this.context.pine?.syminfo?.mintick||.01,s=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(s)}if(i==="integer")return String(Math.round(e));if(i==="percent")return(e*100).toFixed(2)+"%";if(i==="price"){const n=this.context.pine?.syminfo?.mintick||.01,s=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(s)}if(i==="volume")return String(Math.round(e));const r=i.indexOf(".");if(r>=0){const n=i.substring(r+1).length;return e.toFixed(n)}return i.includes("#")||i.includes("0")?String(Math.round(e)):String(e)}tonumber(e){return Number(e)}lower(e){return String(e).toLowerCase()}upper(e){return String(e).toUpperCase()}trim(e){return String(e).trim()}repeat(e,i,r=""){return Array(i).fill(e).join(r||"")}replace_all(e,i,r){return String(e).replaceAll(i,r)}replace(e,i,r,n=0){const s=String(e),a=String(i),o=String(r),l=Math.floor(Number(n))||0;if(a==="")return s;let c=0,u=0;for(;;){const p=s.indexOf(a,c);if(p===-1)return s;if(u===l)return s.substring(0,p)+o+s.substring(p+a.length);u++,c=p+a.length}}contains(e,i){return String(e).includes(i)}endswith(e,i){return String(e).endsWith(i)}startswith(e,i){return String(e).startsWith(i)}pos(e,i){const r=String(e).indexOf(i);return r===-1?NaN:r}length(e){return String(e).length}match(e,i){return String(e).match(new RegExp(i))}split(e,i){return new B(String(e).split(i),j.string,this.context)}substring(e,i,r){return String(e).substring(i,r)}format_time(e,i="yyyy-MM-dd'T'HH:mm:ssZ",r){if(e==null||typeof e=="number"&&isNaN(e))return"NaN";const n=Number(e),s=r||this.context.pine?.syminfo?.timezone||"UTC",a=Rt(n,s),o=Date.UTC(a.year,a.month-1,a.day,a.hour,a.minute,a.second),l=Math.round((o-n)/6e4),c=Date.UTC(a.year,0,1),u=Math.floor((o-c)/864e5)+1,p=a.hour%12===0?12:a.hour%12;let h="",f=0;for(;f<i.length;){const d=i[f];if(d==="'"){if(i[f+1]==="'"){h+="'",f+=2;continue}const m=i.indexOf("'",f+1);if(m===-1){h+=i.substring(f+1);break}h+=i.substring(f+1,m),f=m+1;continue}if(d>="a"&&d<="z"||d>="A"&&d<="Z"){let m=1;for(;i[f+m]===d;)m++;switch(f+=m,d){case"y":h+=m===2?Ve(a.year%100,2):m>=4?Ve(a.year,4):String(a.year);break;case"M":m>=4?h+=Jf[a.month-1]:m===3?h+=Qf[a.month-1]:m===2?h+=Ve(a.month,2):h+=String(a.month);break;case"d":h+=m===2?Ve(a.day,2):String(a.day);break;case"D":h+=m>=3?Ve(u,3):m===2?Ve(u,2):String(u);break;case"E":h+=m>=4?td[a.dayOfWeek]:ed[a.dayOfWeek];break;case"a":h+=a.hour<12?"AM":"PM";break;case"h":h+=m===2?Ve(p,2):String(p);break;case"H":h+=m===2?Ve(a.hour,2):String(a.hour);break;case"m":h+=m===2?Ve(a.minute,2):String(a.minute);break;case"s":h+=m===2?Ve(a.second,2):String(a.second);break;case"S":{const x=n-Math.floor(n/1e3)*1e3;h+=Ve(x,3).substring(0,m);break}case"Z":{const x=l>=0?"+":"-",b=Math.abs(l);h+=`${x}${Ve(Math.floor(b/60),2)}${Ve(b%60,2)}`;break}default:h+=d.repeat(m)}continue}h+=d,f++}return h}format(e,...i){return e.replace(/\{(\d+)(?:,number,([^}]+))?\}/g,(r,n,s)=>{const a=i[n];return s&&typeof a=="number"&&!isNaN(a)?this.tostring(a,s):String(a)})}}var rd=Object.defineProperty,nd=(t,e,i)=>e in t?rd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,sd=(t,e,i)=>nd(t,typeof e!="symbol"?e+"":e,i);const ki={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function yn(t){if(!t||/^\d+$/.test(t))return t;if(ki[t])return ki[t];const e=t.toLowerCase();if(ki[e])return ki[e];if(t.length===1){const r=t.toUpperCase();if(["D","W","M","S"].includes(r))return r}const i=t.slice(-1).toUpperCase();if(["D","W","M","S"].includes(i)){const r=parseInt(t);if(!isNaN(r))return r+i}return t}class ad{constructor(e){this.context=e,sd(this,"_normalized",null)}param(e,i=0,r){return y.from(e).get(i)}get normalized(){return this._normalized===null&&(this._normalized=yn(this.context.timeframe)),this._normalized}get unit(){return this.normalized.slice(-1).toUpperCase()}get main_period(){return this.normalized}get period(){return this.normalized}get multiplier(){const e=parseInt(this.normalized);return isNaN(e)?1:e}get isdwm(){return["D","W","M"].includes(this.unit)}get isdaily(){return this.unit==="D"}get isweekly(){return this.unit==="W"}get ismonthly(){return this.unit==="M"}get isseconds(){return this.unit==="S"}get isminutes(){return/^\d+$/.test(this.normalized)}get isintraday(){return!this.isdwm}change(e){const i=typeof e=="function"?e():e,r=i instanceof y?i.get(0):i,n=vr(r||"");if(!n)return!1;const s=y.from(this.context.data.openTime).get(0),a=y.from(this.context.data.openTime).get(1);if(isNaN(s)||isNaN(a))return!1;const o=wr(s,n),l=wr(a,n);return o!==l}from_seconds(e){return e<60?Math.ceil(e/5)*5+"S":e<3600*24?Math.ceil(e/60):e<=3600*24*7*52?e%(3600*24*7)===0?Math.ceil(e/604800)+"W":Math.ceil(e/(3600*24))+"D":"12M"}in_seconds(e){e==null?e=this.normalized:e=yn(e);const i=e.slice(-1).toUpperCase(),r=parseInt(e);return i==="S"?isNaN(r)?1:r:i==="D"?(isNaN(r)?1:r)*60*60*24:i==="W"?(isNaN(r)?1:r)*60*60*24*7:i==="M"?(isNaN(r)?1:r)*60*60*24*30:isNaN(r)?0:r*60}}var od=Object.defineProperty,ld=Object.getOwnPropertyDescriptor,at=(t,e,i,r)=>{for(var n=r>1?void 0:r?ld(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&od(e,i,n),n};const cd=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],ud=["series","title","char","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],hd={series:"series",title:"string",char:"string",location:"string",color:"color",offset:"number",text:"string",textcolor:"color",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},pd=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],fd=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],dd=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],md=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],_n=["color","offset","editable","show_last","title","display","force_overlay"],yd=["price","title","color","linestyle","linewidth","editable","display"],_d=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],gd={series:"series",title:"string",color:"color",linewidth:"number",style:"string",trackprice:"boolean",histbase:"number",offset:"number",join:"bool",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},xd={series:"series",title:"string",style:"string",location:"string",color:"color",offset:"number",text:"string",textcolor:"color",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},bd={series:"series",title:"string",colorup:"color",colordown:"color",offset:"number",minheight:"number",maxheight:"number",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},vd={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},wd={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",wickcolor:"color",bordercolor:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},gn={color:"color",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},Sd={price:"series",title:"string",color:"color",linestyle:"string",linewidth:"number",editable:"boolean",display:"string"},Ed={plot1:"object",plot2:"object",color:"color",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class yt{constructor(e){this.context=e}_resolvePlotKey(e,i){if(e){const r=this.context.plots[e];return!r||!i||r._callsiteId===i?e:e+i}return i||"plot"}extractPlotOptions(e){const i={};for(let r in e)i[r]=y.from(e[r]).get(0);return i}get linestyle_dashed(){return"linestyle_dashed"}get linestyle_dotted(){return"linestyle_dotted"}get linestyle_solid(){return"linestyle_solid"}get style_area(){return"style_area"}get style_areabr(){return"style_areabr"}get style_circles(){return"style_circles"}get style_columns(){return"style_columns"}get style_cross(){return"style_cross"}get style_histogram(){return"style_histogram"}get style_line(){return"style_line"}get style_linebr(){return"style_linebr"}get style_stepline(){return"style_stepline"}get style_stepline_diamond(){return"style_stepline_diamond"}get style_steplinebr(){return"style_steplinebr"}param(e,i=0,r){return y.from(e).get(i)}plotchar(...e){const i=et(e),r=te(e,ud,hd),{series:n,title:s,...a}=r,o=this.extractPlotOptions(a),l=this._resolvePlotKey(s,i);this.context.plots[l]||(this.context.plots[l]={data:[],options:{...o,style:"char"},title:s,_plotKey:l,_callsiteId:i});const c=y.from(n).get(0);return this.context.plots[l].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:c,options:{char:o.char,color:o.color,textcolor:o.textcolor,location:o.location,size:o.size,offset:o.offset}}),this.context.plots[l]}any(...e){const i=et(e),r=te(e,cd,gd),{series:n,title:s,...a}=r,o=this.extractPlotOptions(a),l=this._resolvePlotKey(s,i),c="color"in a;if(!this.context.plots[l]){const f=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,overlay:f},title:s,_plotKey:l,_callsiteId:i}}const u=y.from(n).get(0);let p=o.color;typeof p=="function"&&(p=p());const h={color:c?typeof p=="string"?p:void 0:p||"#2962ff"};return"offset"in a&&(h.offset=o.offset),this.context.plots[l].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:u,options:h}),this.context.plots[l]}plotshape(...e){const i=et(e),r=te(e,pd,xd),{series:n,title:s,...a}=r,o=this.extractPlotOptions(a),l=this._resolvePlotKey(s,i);if(!this.context.plots[l]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,style:"shape",shape:o.style,overlay:u},title:s,_plotKey:l,_callsiteId:i}}const c=y.from(n).get(0);return this.context.plots[l].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:c,options:o?.location==="absolute"||c?{text:o.text,textcolor:o.textcolor,color:o.color,offset:o.offset,shape:o.style,location:o.location,size:o.size}:void 0}),this.context.plots[l]}plotarrow(...e){const i=et(e),r=te(e,fd,bd),{series:n,title:s,...a}=r,o=y.from(n).get(0),l=this.extractPlotOptions(a),c=this._resolvePlotKey(s,i);if(!this.context.plots[c]){const u=l.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...l,style:"shape",overlay:u},title:s,_plotKey:c,_callsiteId:i}}return this.context.plots[c].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:o,options:typeof o=="number"&&!isNaN(o)&&o!==0?{text:void 0,textcolor:void 0,color:o>0?l.colorup:l.colordown,offset:l.offset,shape:o>0?"shape_arrow_up":"shape_arrow_down",location:o>0?"BelowBar":"AboveBar",height:l.maxheight}:void 0}),this.context.plots[c]}plotbar(...e){const i=et(e),r=te(e,dd,vd),{open:n,high:s,low:a,close:o,title:l,...c}=r,u=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"bar",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const h=[y.from(n).get(0),y.from(s).get(0),y.from(a).get(0),y.from(o).get(0)];this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color}})}plotcandle(...e){const i=et(e),r=te(e,md,wd),{open:n,high:s,low:a,close:o,title:l,...c}=r,u=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"candle",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const h=[y.from(n).get(0),y.from(s).get(0),y.from(a).get(0),y.from(o).get(0)];return this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color,wickcolor:u.wickcolor,bordercolor:u.bordercolor}}),this.context.plots[p]}bgcolor(...e){const i=et(e),r=te(e,_n,gn),{title:n,...s}=r,a=this.extractPlotOptions(s),o=this._resolvePlotKey(n,i);if(!this.context.plots[o]){const l=a.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...a,style:"background",overlay:l},title:n,_plotKey:o,_callsiteId:i}}this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:a.color&&a.color!=="na"&&a?.color.toString()!=="NaN",options:{color:a.color}})}barcolor(...e){const i=et(e),r=te(e,_n,gn),{title:n,...s}=r,a=this.extractPlotOptions(s),o=this._resolvePlotKey(n,i);return this.context.plots[o]||(this.context.plots[o]={data:[],options:{...a,style:"barcolor"},title:n,_plotKey:o,_callsiteId:i}),this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:a.color&&a.color!=="na"&&a?.color.toString()!=="NaN",options:{color:a.color}}),this.context.plots[o]}}at([C],yt.prototype,"plotchar",1),at([C],yt.prototype,"any",1),at([C],yt.prototype,"plotshape",1),at([C],yt.prototype,"plotarrow",1),at([C],yt.prototype,"plotbar",1),at([C],yt.prototype,"plotcandle",1),at([C],yt.prototype,"bgcolor",1),at([C],yt.prototype,"barcolor",1);class Ps{constructor(e){this.context=e}get style_dashed(){return"dashed"}get style_solid(){return"solid"}get style_dotted(){return"dotted"}param(e,i=0,r){return y.from(e).get(i)}any(...e){const i=et(e),r=te(e,yd,Sd),{price:n,title:s,color:a,linestyle:o,linewidth:l,editable:c,display:u}=r,p=[n,{title:s,color:a,linestyle:o,linewidth:l,editable:c,display:u,style:"hline"}];return i&&p.push({__callsiteId:i}),this.context.pine.plot.any(...p)}}at([C],Ps.prototype,"any",1);class Ds{constructor(e){this.context=e}param(e,i=0,r){return y.from(e).get(i)}any(...e){const i=et(e),r=e.length>=6&&typeof e[2]=="number",n=!r&&e.length>=3&&e[2]!==null&&typeof e[2]=="object"&&"top_value"in e[2]?e[2]:null;if(r||n!==null){const s=e[0],a=e[1],o=n?y.from(n.top_value).get(0):e[2],l=n?y.from(n.bottom_value).get(0):e[3],c=n?y.from(n.top_color).get(0):e[4],u=n?y.from(n.bottom_color).get(0):e[5],p=n?n.title||void 0:e.length>6&&typeof e[6]=="string"?e[6]:void 0,h=s?._plotKey||s?.title,f=a?._plotKey||a?.title;let d=p||"fill";const m=this.context.plots[d];m&&i&&m._callsiteId!==i&&(d=i),this.context.plots[d]||(this.context.plots[d]={title:p||"Fill",plot1:h,plot2:f,data:[],options:{plot1:h,plot2:f,style:"fill",gradient:!0},_plotKey:d,_callsiteId:i}),this.context.plots[d].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{top_value:o,bottom_value:l,top_color:c,bottom_color:u}})}else{const s=te(e,_d,Ed),{plot1:a,plot2:o,color:l,title:c,editable:u,show_last:p,fillgaps:h,display:f}=s;let d=c||"fill";const m=this.context.plots[d];m&&i&&m._callsiteId!==i&&(d=i);const x=y.from(l).get(0);if(!this.context.plots[d]){const b=a?._plotKey||a?.title,v=o?._plotKey||o?.title;this.context.plots[d]={title:c||"Fill",plot1:b,plot2:v,data:[],options:{plot1:b,plot2:v,color:x,editable:u,show_last:p,fillgaps:h,display:f,style:"fill"},_plotKey:d,_callsiteId:i}}this.context.plots[d].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{color:x}})}}}at([C],Ds.prototype,"any",1);var Nd=Object.defineProperty,Cd=(t,e,i)=>e in t?Nd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Id=(t,e,i)=>Cd(t,typeof e!="symbol"?e+"":e,i);class kd{constructor(e){this.context=e,Id(this,"point");const i=this.context;this.point={new(r,n,s){return new Ie(r,n,s??NaN)},from_index(r,n){return new Ie(void 0,r,n)},from_time(r,n){return new Ie(r,void 0,n)},copy(r){return r.copy()},now(r){const n=i.idx,s=i.marketData[n]?.openTime;return new Ie(s,n,r)}}}param(e,i=0,r){return y.from(e).get(i)}bg_color(){return"#1e293b"}fg_color(){return"#d1d4dc"}is_standard(){return!0}is_heikinashi(){return!1}is_kagi(){return!1}is_linebreak(){return!1}is_pnf(){return!1}is_range(){return!1}is_renko(){return!1}}var Td=Object.defineProperty,Ad=(t,e,i)=>e in t?Td(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ge=(t,e,i)=>Ad(t,typeof e!="symbol"?e+"":e,i);let Pd=0;class pi{constructor(e,i,r="",n="bi",s="pr",a="",o="style_label_down",l="",c="normal",u="center",p="",h="default",f=!1){ge(this,"id"),ge(this,"x"),ge(this,"y"),ge(this,"text"),ge(this,"xloc"),ge(this,"yloc"),ge(this,"color"),ge(this,"style"),ge(this,"textcolor"),ge(this,"size"),ge(this,"textalign"),ge(this,"tooltip"),ge(this,"text_font_family"),ge(this,"force_overlay"),ge(this,"_deleted"),ge(this,"_helper"),ge(this,"_createdAtBar",-1),this.id=Pd++,this.x=e,this.y=i,this.text=r,this.xloc=n,this.yloc=s,this.color=a,this.style=o,this.textcolor=l,this.size=c,this.textalign=u,this.tooltip=p,this.text_font_family=h,this.force_overlay=f,this._deleted=!1,this._helper=null}set_x(e){this._helper?this._helper.set_x(this,e):this._deleted||(this.x=e)}set_y(e){this._helper?this._helper.set_y(this,e):this._deleted||(this.y=e)}set_xy(e,i){this._helper?this._helper.set_xy(this,e,i):this._deleted||(this.x=e,this.y=i)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_textcolor(e){this._helper?this._helper.set_textcolor(this,e):this._deleted||(this.textcolor=e)}set_size(e){this._helper?this._helper.set_size(this,e):this._deleted||(this.size=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_textalign(e){this._helper?this._helper.set_textalign(this,e):this._deleted||(this.textalign=e)}set_tooltip(e){this._helper?this._helper.set_tooltip(this,e):this._deleted||(this.tooltip=e)}set_xloc(e){this._helper?this._helper.set_xloc(this,e):this._deleted||(this.xloc=e)}set_yloc(e){this._helper?this._helper.set_yloc(this,e):this._deleted||(this.yloc=e)}set_point(e){this._helper&&this._helper.set_point(this,e)}set_text_font_family(e){this._deleted||(this.text_font_family=e)}get_x(){return this.x}get_y(){return this.y}get_text(){return this.text}delete(){this._deleted=!0}copy(){return new pi(this.x,this.y,this.text,this.xloc,this.yloc,this.color,this.style,this.textcolor,this.size,this.textalign,this.tooltip,this.text_font_family,this.force_overlay)}toPlotData(){return{id:this.id,x:this.x,y:this.y,text:this.text,xloc:this.xloc,yloc:this.yloc,color:this.color,style:this.style,textcolor:this.textcolor,size:this.size,textalign:this.textalign,tooltip:this.tooltip,text_font_family:this.text_font_family,force_overlay:this.force_overlay,_deleted:this._deleted}}}var Ms=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Md=(t,e,i)=>e in t?Ms(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ve=(t,e,i,r)=>{for(var n=r>1?void 0:r?Dd(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Ms(e,i,n),n},Rd=(t,e,i)=>Md(t,typeof e!="symbol"?e+"":e,i);const Od=[["x","y","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"],["point","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"]],$d={x:"number",y:"number",text:"string",xloc:"string",yloc:"string",color:"color",style:"string",textcolor:"color",size:"string",textalign:"string",tooltip:"string",text_font_family:"string",force_overlay:"boolean",point:"point"};class xe{constructor(e){this.context=e,Rd(this,"_labels",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__labels__||(this.context.plots.__labels__={title:"__labels__",data:[],options:{style:"label",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._labels.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__labels__.data=[{time:e,value:r,options:{style:"label"}}],n.length>0?this.context.plots.__labels_overlay__={title:"__labels_overlay__",data:[{time:e,value:n,options:{style:"label"}}],options:{style:"label",overlay:!0}}:delete this.context.plots.__labels_overlay__}_resolve(e){if(e==null)return e;if(e instanceof Re)return null;if(typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"){const i=e.get(0);return typeof i=="number"&&isNaN(i)?null:i}return typeof e=="function"?e():typeof e=="number"&&isNaN(e)?null:e}_createLabel(e,i,r="",n="bi",s="pr",a="",o="style_label_down",l="",c="normal",u="center",p="",h="default",f=!1){const d=new pi(e,i,this._resolve(r),this._resolve(n),this._resolve(s),this._resolve(a),this._resolve(o),this._resolve(l),this._resolve(c),this._resolve(u),this._resolve(p),this._resolve(h),f);return d._helper=this,d._createdAtBar=this.context.idx,this._labels.push(d),this._enforceMaxCount(),this.syncToPlot(),d}_enforceMaxCount(){const e=this.context.indicator?.max_labels_count??50,i=this._labels.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._labels){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}new(...e){const i=te(e,Od,$d);let r,n,s=i.xloc;if(i.point instanceof Ie){const a=i.point,o=a.index!==void 0&&!(typeof a.index=="number"&&isNaN(a.index)),l=a.time!==void 0&&!(typeof a.time=="number"&&isNaN(a.time));o?(r=a.index,s=s||"bi"):l?(r=a.time,s=s||"bt"):(r=0,s=s||"bi"),n=a.price}else r=i.x,n=i.y;return this._createLabel(r,n,i.text,s,i.yloc,i.color,i.style,i.textcolor,i.size,i.textalign,i.tooltip,i.text_font_family,i.force_overlay)}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof pi)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof pi)return r}return null}return this.new(...e)}set_x(e,i){e&&!e._deleted&&(e.x=i)}set_y(e,i){e&&!e._deleted&&(e.y=i)}set_xy(e,i,r){e&&!e._deleted&&(e.x=i,e.y=r)}set_text(e,i){e&&!e._deleted&&(e.text=i)}set_color(e,i){e&&!e._deleted&&(e.color=i)}set_textcolor(e,i){e&&!e._deleted&&(e.textcolor=i)}set_size(e,i){e&&!e._deleted&&(e.size=i)}set_style(e,i){e&&!e._deleted&&(e.style=i)}set_textalign(e,i){e&&!e._deleted&&(e.textalign=i)}set_tooltip(e,i){e&&!e._deleted&&(e.tooltip=i)}set_xloc(e,i){e&&!e._deleted&&(e.xloc=i)}set_yloc(e,i){e&&!e._deleted&&(e.yloc=i)}set_point(e,i){if(e&&!e._deleted&&i){const r=i.index!==void 0&&!(typeof i.index=="number"&&isNaN(i.index)),n=i.time!==void 0&&!(typeof i.time=="number"&&isNaN(i.time));r?(e.x=i.index,e.xloc="bi"):n&&(e.x=i.time,e.xloc="bt"),e.y=i.price}}get_x(e){return e?e.x:NaN}get_y(e){return e?e.y:NaN}get_text(e){return e?e.text:""}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._labels.push(i),this._enforceMaxCount(),this.syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._labels.filter(e=>!e._deleted)}rollbackFromBar(e){this._labels=this._labels.filter(i=>i._createdAtBar<e),this.syncToPlot()}get style_label_down(){return"style_label_down"}get style_label_up(){return"style_label_up"}get style_label_left(){return"style_label_left"}get style_label_right(){return"style_label_right"}get style_label_lower_left(){return"style_label_lower_left"}get style_label_lower_right(){return"style_label_lower_right"}get style_label_upper_left(){return"style_label_upper_left"}get style_label_upper_right(){return"style_label_upper_right"}get style_label_center(){return"style_label_center"}get style_circle(){return"style_circle"}get style_square(){return"style_square"}get style_diamond(){return"style_diamond"}get style_flag(){return"style_flag"}get style_arrowup(){return"style_arrowup"}get style_arrowdown(){return"style_arrowdown"}get style_cross(){return"style_cross"}get style_xcross(){return"style_xcross"}get style_triangleup(){return"style_triangleup"}get style_triangledown(){return"style_triangledown"}get style_none(){return"style_none"}get style_text_outline(){return"style_text_outline"}}ve([C],xe.prototype,"new",1),ve([C],xe.prototype,"set_x",1),ve([C],xe.prototype,"set_y",1),ve([C],xe.prototype,"set_xy",1),ve([C],xe.prototype,"set_text",1),ve([C],xe.prototype,"set_color",1),ve([C],xe.prototype,"set_textcolor",1),ve([C],xe.prototype,"set_size",1),ve([C],xe.prototype,"set_style",1),ve([C],xe.prototype,"set_textalign",1),ve([C],xe.prototype,"set_tooltip",1),ve([C],xe.prototype,"set_xloc",1),ve([C],xe.prototype,"set_yloc",1),ve([C],xe.prototype,"set_point",1),ve([C],xe.prototype,"copy",1),ve([C],xe.prototype,"delete",1);var Vd=Object.defineProperty,jd=(t,e,i)=>e in t?Vd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pe=(t,e,i)=>jd(t,typeof e!="symbol"?e+"":e,i);let Ld=0;class fi{constructor(e,i,r,n,s="bi",a="none",o="",l="style_solid",c=1,u=!1){Pe(this,"id"),Pe(this,"x1"),Pe(this,"y1"),Pe(this,"x2"),Pe(this,"y2"),Pe(this,"xloc"),Pe(this,"extend"),Pe(this,"color"),Pe(this,"style"),Pe(this,"width"),Pe(this,"force_overlay"),Pe(this,"_deleted"),Pe(this,"_helper"),Pe(this,"_createdAtBar",-1),this.id=Ld++,this.x1=e,this.y1=i,this.x2=r,this.y2=n,this.xloc=s,this.extend=a,this.color=o,this.style=l,this.width=c,this.force_overlay=u,this._deleted=!1,this._helper=null}set_x1(e){this._helper?this._helper.set_x1(this,e):this._deleted||(this.x1=e)}set_y1(e){this._helper?this._helper.set_y1(this,e):this._deleted||(this.y1=e)}set_x2(e){this._helper?this._helper.set_x2(this,e):this._deleted||(this.x2=e)}set_y2(e){this._helper?this._helper.set_y2(this,e):this._deleted||(this.y2=e)}set_xy1(e,i){this._helper?this._helper.set_xy1(this,e,i):this._deleted||(this.x1=e,this.y1=i)}set_xy2(e,i){this._helper?this._helper.set_xy2(this,e,i):this._deleted||(this.x2=e,this.y2=i)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_width(e){this._helper?this._helper.set_width(this,e):this._deleted||(this.width=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.x1=e,this.x2=i,this.xloc=r)}set_first_point(e){this._helper&&this._helper.set_first_point(this,e)}set_second_point(e){this._helper&&this._helper.set_second_point(this,e)}get_x1(){return this.x1}get_y1(){return this.y1}get_x2(){return this.x2}get_y2(){return this.y2}get_price(e){return this._helper?this._helper.get_price(this,e):NaN}delete(){this._deleted=!0}copy(){return new fi(this.x1,this.y1,this.x2,this.y2,this.xloc,this.extend,this.color,this.style,this.width,this.force_overlay)}toPlotData(){return{id:this.id,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,xloc:this.xloc,extend:this.extend,color:this.color,style:this.style,width:this.width,force_overlay:this.force_overlay,_deleted:this._deleted}}}var Rs=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Fd=(t,e,i)=>e in t?Rs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,we=(t,e,i,r)=>{for(var n=r>1?void 0:r?Bd(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Rs(e,i,n),n},Wd=(t,e,i)=>Fd(t,typeof e!="symbol"?e+"":e,i);const Ud=[["x1","y1","x2","y2","xloc","extend","color","style","width","force_overlay"],["first_point","second_point","xloc","extend","color","style","width","force_overlay"]],qd={x1:"number",y1:"number",x2:"number",y2:"number",xloc:"string",extend:"string",color:"color",style:"string",width:"number",force_overlay:"boolean",first_point:"point",second_point:"point"};class be{constructor(e){this.context=e,Wd(this,"_lines",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__lines__||(this.context.plots.__lines__={title:"__lines__",data:[],options:{style:"drawing_line",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._lines.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__lines__.data=[{time:e,value:r,options:{style:"drawing_line"}}],n.length>0?this.context.plots.__lines_overlay__={title:"__lines_overlay__",data:[{time:e,value:n,options:{style:"drawing_line"}}],options:{style:"drawing_line",overlay:!0}}:delete this.context.plots.__lines_overlay__}_resolvePoint(e){const i=e.index!==void 0&&!(typeof e.index=="number"&&isNaN(e.index)),r=e.time!==void 0&&!(typeof e.time=="number"&&isNaN(e.time));return i?{x:e.index,xloc:"bi"}:r?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e){const i=this._resolve(e);return i==null?i:typeof i=="number"&&isNaN(i)?NaN:i}_createLine(e,i,r,n,s="bi",a="none",o="",l="style_solid",c=1,u=!1){const p=new fi(e,i,r,n,s,this._resolve(a),this._resolveColor(o),this._resolve(l),this._resolve(c)||1,u);return p._helper=this,p._createdAtBar=this.context.idx,this._lines.push(p),this._enforceMaxCount(),this.syncToPlot(),p}_enforceMaxCount(){const e=this.context.indicator?.max_lines_count??50,i=this._lines.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._lines){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}new(...e){const i=te(e,Ud,qd);let r,n,s,a,o=i.xloc;if(i.first_point instanceof Ie){const l=i.first_point,c=i.second_point,u=this._resolvePoint(l);r=u.x,n=l.price,o=o||u.xloc,c instanceof Ie?(s=this._resolvePoint(c).x,a=c.price):(s=0,a=NaN)}else r=i.x1,n=i.y1,s=i.x2,a=i.y2;return this._createLine(r,n,s,a,o,i.extend,i.color,i.style,i.width,i.force_overlay)}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof fi)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof fi)return r}return null}return this.new(...e)}set_x1(e,i){e&&!e._deleted&&(e.x1=this._resolve(i))}set_y1(e,i){e&&!e._deleted&&(e.y1=this._resolve(i))}set_x2(e,i){e&&!e._deleted&&(e.x2=this._resolve(i))}set_y2(e,i){e&&!e._deleted&&(e.y2=this._resolve(i))}set_xy1(e,i,r){e&&!e._deleted&&(e.x1=this._resolve(i),e.y1=this._resolve(r))}set_xy2(e,i,r){e&&!e._deleted&&(e.x2=this._resolve(i),e.y2=this._resolve(r))}set_color(e,i){e&&!e._deleted&&(e.color=this._resolveColor(i))}set_width(e,i){e&&!e._deleted&&(e.width=this._resolve(i)||1)}set_style(e,i){e&&!e._deleted&&(e.style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_xloc(e,i,r,n){e&&!e._deleted&&(e.x1=i,e.x2=r,e.xloc=n)}set_first_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x1=r.x,e.y1=i.price,e.xloc=r.xloc}}set_second_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x2=r.x,e.y2=i.price,e.xloc=r.xloc}}get_x1(e){return e?e.x1:NaN}get_y1(e){return e?e.y1:NaN}get_x2(e){return e?e.x2:NaN}get_y2(e){return e?e.y2:NaN}get_price(e,i){if(!e||e._deleted)return NaN;if(e.xloc!=="bi")return NaN;const r=e.x2-e.x1;return r===0?e.y1:e.y1+(i-e.x1)/r*(e.y2-e.y1)}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._lines.push(i),this._enforceMaxCount(),this.syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._lines.filter(e=>!e._deleted)}rollbackFromBar(e){this._lines=this._lines.filter(i=>i._createdAtBar<e),this.syncToPlot()}get style_solid(){return"style_solid"}get style_dotted(){return"style_dotted"}get style_dashed(){return"style_dashed"}get style_arrow_left(){return"style_arrow_left"}get style_arrow_right(){return"style_arrow_right"}get style_arrow_both(){return"style_arrow_both"}}we([C],be.prototype,"new",1),we([C],be.prototype,"set_x1",1),we([C],be.prototype,"set_y1",1),we([C],be.prototype,"set_x2",1),we([C],be.prototype,"set_y2",1),we([C],be.prototype,"set_xy1",1),we([C],be.prototype,"set_xy2",1),we([C],be.prototype,"set_color",1),we([C],be.prototype,"set_width",1),we([C],be.prototype,"set_style",1),we([C],be.prototype,"set_extend",1),we([C],be.prototype,"set_xloc",1),we([C],be.prototype,"set_first_point",1),we([C],be.prototype,"set_second_point",1),we([C],be.prototype,"copy",1),we([C],be.prototype,"delete",1);var zd=Object.defineProperty,Kd=(t,e,i)=>e in t?zd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ne=(t,e,i)=>Kd(t,typeof e!="symbol"?e+"":e,i);let Hd=0;class di{constructor(e,i,r,n,s="bi",a="none",o="#2962ff",l="style_solid",c=1,u="#2962ff",p="",h="#000000",f="auto",d="center",m="center",x="wrap_none",b="default",v="format_none",w=!1){ne(this,"id"),ne(this,"left"),ne(this,"top"),ne(this,"right"),ne(this,"bottom"),ne(this,"xloc"),ne(this,"extend"),ne(this,"border_color"),ne(this,"border_style"),ne(this,"border_width"),ne(this,"bgcolor"),ne(this,"text"),ne(this,"text_color"),ne(this,"text_size"),ne(this,"text_halign"),ne(this,"text_valign"),ne(this,"text_wrap"),ne(this,"text_font_family"),ne(this,"text_formatting"),ne(this,"force_overlay"),ne(this,"_deleted"),ne(this,"_helper"),ne(this,"_createdAtBar",-1),this.id=Hd++,this.left=e,this.top=i,this.right=r,this.bottom=n,this.xloc=s,this.extend=a,this.border_color=o,this.border_style=l,this.border_width=c,this.bgcolor=u,this.text=p,this.text_color=h,this.text_size=f,this.text_halign=d,this.text_valign=m,this.text_wrap=x,this.text_font_family=b,this.text_formatting=v,this.force_overlay=w,this._deleted=!1,this._helper=null}set_left(e){this._helper?this._helper.set_left(this,e):this._deleted||(this.left=e)}set_right(e){this._helper?this._helper.set_right(this,e):this._deleted||(this.right=e)}set_top(e){this._helper?this._helper.set_top(this,e):this._deleted||(this.top=e)}set_bottom(e){this._helper?this._helper.set_bottom(this,e):this._deleted||(this.bottom=e)}set_lefttop(e,i){this._helper?this._helper.set_lefttop(this,e,i):this._deleted||(this.left=e,this.top=i)}set_rightbottom(e,i){this._helper?this._helper.set_rightbottom(this,e,i):this._deleted||(this.right=e,this.bottom=i)}set_top_left_point(e){this._helper&&this._helper.set_top_left_point(this,e)}set_bottom_right_point(e){this._helper&&this._helper.set_bottom_right_point(this,e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.left=e,this.right=i,this.xloc=r)}set_bgcolor(e){this._helper?this._helper.set_bgcolor(this,e):this._deleted||(this.bgcolor=e)}set_border_color(e){this._helper?this._helper.set_border_color(this,e):this._deleted||(this.border_color=e)}set_border_width(e){this._helper?this._helper.set_border_width(this,e):this._deleted||(this.border_width=e)}set_border_style(e){this._helper?this._helper.set_border_style(this,e):this._deleted||(this.border_style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_text_color(e){this._helper?this._helper.set_text_color(this,e):this._deleted||(this.text_color=e)}set_text_size(e){this._helper?this._helper.set_text_size(this,e):this._deleted||(this.text_size=e)}set_text_halign(e){this._helper?this._helper.set_text_halign(this,e):this._deleted||(this.text_halign=e)}set_text_valign(e){this._helper?this._helper.set_text_valign(this,e):this._deleted||(this.text_valign=e)}set_text_wrap(e){this._helper?this._helper.set_text_wrap(this,e):this._deleted||(this.text_wrap=e)}set_text_font_family(e){this._helper?this._helper.set_text_font_family(this,e):this._deleted||(this.text_font_family=e)}set_text_formatting(e){this._helper?this._helper.set_text_formatting(this,e):this._deleted||(this.text_formatting=e)}get_left(){return this.left}get_right(){return this.right}get_top(){return this.top}get_bottom(){return this.bottom}delete(){this._deleted=!0}toPlotData(){return{id:this.id,left:this.left,top:this.top,right:this.right,bottom:this.bottom,xloc:this.xloc,extend:this.extend,border_color:this.border_color,border_style:this.border_style,border_width:this.border_width,bgcolor:this.bgcolor,text:this.text,text_color:this.text_color,text_size:this.text_size,text_halign:this.text_halign,text_valign:this.text_valign,text_wrap:this.text_wrap,text_font_family:this.text_font_family,text_formatting:this.text_formatting,force_overlay:this.force_overlay,_deleted:this._deleted}}copy(){return new di(this.left,this.top,this.right,this.bottom,this.xloc,this.extend,this.border_color,this.border_style,this.border_width,this.bgcolor,this.text,this.text_color,this.text_size,this.text_halign,this.text_valign,this.text_wrap,this.text_font_family,this.text_formatting,this.force_overlay)}}var Os=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,Yd=(t,e,i)=>e in t?Os(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ie=(t,e,i,r)=>{for(var n=r>1?void 0:r?Gd(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Os(e,i,n),n},Xd=(t,e,i)=>Yd(t,typeof e!="symbol"?e+"":e,i);const Zd=[["left","top","right","bottom","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"],["top_left","bottom_right","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"]],Qd={left:"number",top:"number",right:"number",bottom:"number",top_left:"point",bottom_right:"point",border_color:"color",border_width:"number",border_style:"string",extend:"string",xloc:"string",bgcolor:"color",text:"string",text_size:"string",text_color:"color",text_halign:"string",text_valign:"string",text_wrap:"string",text_font_family:"string",force_overlay:"boolean"};class ee{constructor(e){this.context=e,Xd(this,"_boxes",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__boxes__||(this.context.plots.__boxes__={title:"__boxes__",data:[],options:{style:"drawing_box",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._boxes.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__boxes__.data=[{time:e,value:r,options:{style:"drawing_box"}}],n.length>0?this.context.plots.__boxes_overlay__={title:"__boxes_overlay__",data:[{time:e,value:n,options:{style:"drawing_box"}}],options:{style:"drawing_box",overlay:!0}}:delete this.context.plots.__boxes_overlay__}_resolvePoint(e){const i=e.index!==void 0&&!(typeof e.index=="number"&&isNaN(e.index)),r=e.time!==void 0&&!(typeof e.time=="number"&&isNaN(e.time));return i?{x:e.index,xloc:"bi"}:r?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return r==null?r:typeof r=="number"&&isNaN(r)?NaN:r||i}_createBox(e,i,r,n,s="bi",a="none",o="#2962ff",l="style_solid",c=1,u="#2962ff",p="",h="#000000",f="auto",d="center",m="center",x="wrap_none",b="default",v="format_none",w=!1){const E=new di(e,i,r,n,s,this._resolve(a),this._resolveColor(o,"#2962ff"),this._resolve(l)||"style_solid",this._resolve(c)??1,this._resolveColor(u,"#2962ff"),this._resolve(p)||"",this._resolveColor(h,"#000000"),this._resolve(f)||"auto",this._resolve(d)||"center",this._resolve(m)||"center",this._resolve(x)||"wrap_none",this._resolve(b)||"default",this._resolve(v)||"format_none",w);return E._helper=this,E._createdAtBar=this.context.idx,this._boxes.push(E),this._enforceMaxCount(),this.syncToPlot(),E}_enforceMaxCount(){const e=this.context.indicator?.max_boxes_count??50,i=this._boxes.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._boxes){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}new(...e){const i=te(e,Zd,Qd);let r,n,s,a,o=i.xloc;if(i.top_left instanceof Ie){const l=i.top_left,c=i.bottom_right,u=this._resolvePoint(l);r=u.x,n=l.price,o=o||u.xloc,c instanceof Ie?(s=this._resolvePoint(c).x,a=c.price):(s=0,a=NaN)}else r=this._resolve(i.left),n=this._resolve(i.top),s=this._resolve(i.right),a=this._resolve(i.bottom);return this._createBox(r,n,s,a,o,i.extend,i.border_color,i.border_style,i.border_width,i.bgcolor,i.text,i.text_color,i.text_size,i.text_halign,i.text_valign,i.text_wrap,i.text_font_family,void 0,i.force_overlay)}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof di)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof di)return r}return null}return this.new(...e)}set_left(e,i){e&&!e._deleted&&(e.left=this._resolve(i))}set_right(e,i){e&&!e._deleted&&(e.right=this._resolve(i))}set_top(e,i){e&&!e._deleted&&(e.top=this._resolve(i))}set_bottom(e,i){e&&!e._deleted&&(e.bottom=this._resolve(i))}set_lefttop(e,i,r){e&&!e._deleted&&(e.left=this._resolve(i),e.top=this._resolve(r))}set_rightbottom(e,i,r){e&&!e._deleted&&(e.right=this._resolve(i),e.bottom=this._resolve(r))}set_top_left_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.left=r.x,e.top=i.price,e.xloc=r.xloc}}set_bottom_right_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.right=r.x,e.bottom=i.price,e.xloc=r.xloc}}set_xloc(e,i,r,n){e&&!e._deleted&&(e.left=this._resolve(i),e.right=this._resolve(r),e.xloc=this._resolve(n))}set_bgcolor(e,i){e&&!e._deleted&&(e.bgcolor=this._resolve(i))}set_border_color(e,i){e&&!e._deleted&&(e.border_color=this._resolve(i))}set_border_width(e,i){e&&!e._deleted&&(e.border_width=this._resolve(i)??1)}set_border_style(e,i){e&&!e._deleted&&(e.border_style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_text(e,i){e&&!e._deleted&&(e.text=this._resolve(i)||"")}set_text_color(e,i){e&&!e._deleted&&(e.text_color=this._resolve(i))}set_text_size(e,i){e&&!e._deleted&&(e.text_size=this._resolve(i))}set_text_halign(e,i){e&&!e._deleted&&(e.text_halign=this._resolve(i))}set_text_valign(e,i){e&&!e._deleted&&(e.text_valign=this._resolve(i))}set_text_wrap(e,i){e&&!e._deleted&&(e.text_wrap=this._resolve(i))}set_text_font_family(e,i){e&&!e._deleted&&(e.text_font_family=this._resolve(i))}set_text_formatting(e,i){e&&!e._deleted&&(e.text_formatting=this._resolve(i))}get_left(e){return e?e.left:NaN}get_right(e){return e?e.right:NaN}get_top(e){return e?e.top:NaN}get_bottom(e){return e?e.bottom:NaN}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._boxes.push(i),this._enforceMaxCount(),this.syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._boxes.filter(e=>!e._deleted)}rollbackFromBar(e){this._boxes=this._boxes.filter(i=>i._createdAtBar<e),this.syncToPlot()}}ie([C],ee.prototype,"new",1),ie([C],ee.prototype,"set_left",1),ie([C],ee.prototype,"set_right",1),ie([C],ee.prototype,"set_top",1),ie([C],ee.prototype,"set_bottom",1),ie([C],ee.prototype,"set_lefttop",1),ie([C],ee.prototype,"set_rightbottom",1),ie([C],ee.prototype,"set_top_left_point",1),ie([C],ee.prototype,"set_bottom_right_point",1),ie([C],ee.prototype,"set_xloc",1),ie([C],ee.prototype,"set_bgcolor",1),ie([C],ee.prototype,"set_border_color",1),ie([C],ee.prototype,"set_border_width",1),ie([C],ee.prototype,"set_border_style",1),ie([C],ee.prototype,"set_extend",1),ie([C],ee.prototype,"set_text",1),ie([C],ee.prototype,"set_text_color",1),ie([C],ee.prototype,"set_text_size",1),ie([C],ee.prototype,"set_text_halign",1),ie([C],ee.prototype,"set_text_valign",1),ie([C],ee.prototype,"set_text_wrap",1),ie([C],ee.prototype,"set_text_font_family",1),ie([C],ee.prototype,"set_text_formatting",1),ie([C],ee.prototype,"copy",1),ie([C],ee.prototype,"delete",1);var Jd=Object.defineProperty,em=(t,e,i)=>e in t?Jd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Yt=(t,e,i)=>em(t,typeof e!="symbol"?e+"":e,i);let tm=0;class xn{constructor(e,i,r){Yt(this,"id"),Yt(this,"line1"),Yt(this,"line2"),Yt(this,"color"),Yt(this,"_deleted"),Yt(this,"_createdAtBar",-1),this.id=tm++,this.line1=e,this.line2=i,this.color=r,this._deleted=!1}get_line1(){return this.line1}get_line2(){return this.line2}set_color(e){this._deleted||(typeof e=="function"&&(e=e()),e&&typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"&&(e=e.get(0)),this.color=e||"")}delete(){this._deleted=!0}toPlotData(){const e=r=>r?{id:r.id,x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,xloc:r.xloc,extend:r.extend,color:r.color,style:r.style,width:r.width,_deleted:r._deleted}:null,i=!!(this.line1?.force_overlay||this.line2?.force_overlay);return{id:this.id,line1:e(this.line1),line2:e(this.line2),color:this.color,force_overlay:i,_deleted:this._deleted}}}var $s=Object.defineProperty,im=Object.getOwnPropertyDescriptor,rm=(t,e,i)=>e in t?$s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,hr=(t,e,i,r)=>{for(var n=r>1?void 0:r?im(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&$s(e,i,n),n},nm=(t,e,i)=>rm(t,typeof e!="symbol"?e+"":e,i);class Oi{constructor(e){this.context=e,nm(this,"_linefills",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__linefills__||(this.context.plots.__linefills__={title:"__linefills__",data:[],options:{style:"linefill",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._linefills.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__linefills__.data=[{time:e,value:r,options:{style:"linefill"}}],n.length>0?this.context.plots.__linefills_overlay__={title:"__linefills_overlay__",data:[{time:e,value:n,options:{style:"linefill"}}],options:{style:"linefill",overlay:!0}}:delete this.context.plots.__linefills_overlay__}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e){const i=this._resolve(e);return i==null?i:typeof i=="number"&&isNaN(i)?NaN:i}new(e,i,r){const n=this._resolve(e),s=this._resolve(i),a=r&&typeof r=="object"&&!Array.isArray(r)&&"color"in r?r.color:r,o=this._resolveColor(a);if(n&&s){const c=n.id,u=s.id;for(const p of this._linefills){if(p._deleted)continue;const h=p.line1?.id,f=p.line2?.id;if(h===c&&f===u||h===u&&f===c)return p.color=o,p._createdAtBar=this.context.idx,this.syncToPlot(),p}}const l=new xn(n,s,o);return l._createdAtBar=this.context.idx,this._linefills.push(l),this.syncToPlot(),l}any(...e){if(e.length===1){const i=e[0];return i==null||i instanceof Re||typeof i=="number"&&isNaN(i)?null:i instanceof xn?i:null}return this.new(e[0],e[1],e[2])}set_color(e,i){e&&!e._deleted&&(e.color=this._resolveColor(i))}get_line1(e){return e?e.line1:void 0}get_line2(e){return e?e.line2:void 0}delete(e){e&&(e._deleted=!0)}get all(){return this._linefills.filter(e=>!e._deleted)}rollbackFromBar(e){this._linefills=this._linefills.filter(i=>i._createdAtBar<e),this.syncToPlot()}}hr([C],Oi.prototype,"new",1),hr([C],Oi.prototype,"set_color",1),hr([C],Oi.prototype,"delete",1);var sm=Object.defineProperty,am=(t,e,i)=>e in t?sm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,We=(t,e,i)=>am(t,typeof e!="symbol"?e+"":e,i);let om=0;class pr{constructor(e,i=!1,r=!1,n="bi",s="#2962ff",a="",o="style_solid",l=1,c=!1){We(this,"id"),We(this,"points"),We(this,"curved"),We(this,"closed"),We(this,"xloc"),We(this,"line_color"),We(this,"fill_color"),We(this,"line_style"),We(this,"line_width"),We(this,"force_overlay"),We(this,"_deleted"),We(this,"_createdAtBar",-1),this.id=om++,this.points=e,this.curved=i,this.closed=r,this.xloc=n,this.line_color=s,this.fill_color=a,this.line_style=o,this.line_width=l,this.force_overlay=c,this._deleted=!1}delete(){this._deleted=!0}toPlotData(){return{id:this.id,points:this.points.map(e=>({time:e.time,index:e.index,price:e.price})),curved:this.curved,closed:this.closed,xloc:this.xloc,line_color:this.line_color,fill_color:this.fill_color,line_style:this.line_style,line_width:this.line_width,force_overlay:this.force_overlay,_deleted:this._deleted}}}var Vs=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,cm=(t,e,i)=>e in t?Vs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,bn=(t,e,i,r)=>{for(var n=r>1?void 0:r?lm(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Vs(e,i,n),n},um=(t,e,i)=>cm(t,typeof e!="symbol"?e+"":e,i);class Ir{constructor(e){this.context=e,um(this,"_polylines",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__polylines__||(this.context.plots.__polylines__={title:"__polylines__",data:[],options:{style:"drawing_polyline",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__polylines__.data=[{time:e,value:this._polylines.filter(i=>!i._deleted).map(i=>i.toPlotData()),options:{style:"drawing_polyline"}}]}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return r==null?r:typeof r=="number"&&isNaN(r)?NaN:r||i}_extractPoints(e){let i=this._resolve(e);const r=i&&i.array?i.array:i;return Array.isArray(r)?r.filter(n=>n instanceof Ie):[]}new(...e){let i,r=!1,n=!1,s="bi",a="#2962ff",o="",l="style_solid",c=1,u=!1;const p=(b,v)=>Object.prototype.hasOwnProperty.call(b,v),h=b=>{p(b,"curved")&&(r=b.curved),p(b,"closed")&&(n=b.closed),p(b,"xloc")&&(s=b.xloc),p(b,"line_color")&&(a=b.line_color),p(b,"fill_color")&&(o=b.fill_color),p(b,"line_style")&&(l=b.line_style),p(b,"line_width")&&(c=b.line_width),p(b,"force_overlay")&&(u=b.force_overlay)},f=e.length>=1?e[e.length-1]:null,d=e.length>=2&&f&&typeof f=="object"&&!Array.isArray(f)&&!(f instanceof y)&&!(f instanceof Ie);if(e.length===1&&f&&typeof f=="object"&&!Array.isArray(f)&&"points"in f)i=f.points,h(f);else{const b=d?e.slice(0,-1):e;i=b[0],b.length>1&&(r=b[1]),b.length>2&&(n=b[2]),b.length>3&&(s=b[3]),b.length>4&&(a=b[4]),b.length>5&&(o=b[5]),b.length>6&&(l=b[6]),b.length>7&&(c=b[7]),b.length>8&&(u=b[8]),d&&h(f)}const m=this._extractPoints(i),x=new pr(m,this._resolve(r)??!1,this._resolve(n)??!1,this._resolve(s)||"bi",this._resolveColor(a,"#2962ff"),this._resolveColor(o,""),this._resolve(l)||"style_solid",this._resolve(c)||1,this._resolve(u)??!1);return x._createdAtBar=this.context.idx,this._polylines.push(x),this._enforceMaxCount(),this.syncToPlot(),x}_enforceMaxCount(){const e=this.context.indicator?.max_polylines_count??50,i=this._polylines.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._polylines){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof pr)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof pr)return r}return null}return this.new(...e)}delete(e){e&&(e._deleted=!0)}get all(){return this._polylines.filter(e=>!e._deleted)}rollbackFromBar(e){this._polylines=this._polylines.filter(i=>i._createdAtBar<e),this.syncToPlot()}}bn([C],Ir.prototype,"new",1),bn([C],Ir.prototype,"delete",1);var hm=Object.defineProperty,pm=(t,e,i)=>e in t?hm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,De=(t,e,i)=>pm(t,typeof e!="symbol"?e+"":e,i);let fm=0;class vn{constructor(e="top_right",i=1,r=1,n="",s="",a=0,o="",l=0,c=!1){De(this,"id"),De(this,"position"),De(this,"columns"),De(this,"rows"),De(this,"bgcolor"),De(this,"frame_color"),De(this,"frame_width"),De(this,"border_color"),De(this,"border_width"),De(this,"force_overlay"),De(this,"_deleted"),De(this,"cells"),De(this,"merges"),De(this,"_helper"),this.id=fm++,this.position=e,this.columns=i,this.rows=r,this.bgcolor=n,this.frame_color=s,this.frame_width=a,this.border_color=o,this.border_width=l,this.force_overlay=c,this._deleted=!1,this.merges=[],this.cells=[];for(let u=0;u<r;u++){this.cells[u]=[];for(let p=0;p<i;p++)this.cells[u][p]=null}}delete(){this._deleted=!0}toPlotData(){const e=this.cells.map(i=>i.map(r=>r?{...r}:null));return{id:this.id,position:this.position,columns:this.columns,rows:this.rows,bgcolor:this.bgcolor,frame_color:this.frame_color,frame_width:this.frame_width,border_color:this.border_color,border_width:this.border_width,force_overlay:this.force_overlay,_deleted:this._deleted,cells:e,merges:this.merges.map(i=>({...i}))}}setCell(e,i,r){if(i<0||i>=this.rows||e<0||e>=this.columns)return;const n=this.cells[i][e];if(n&&n._merged&&n._merge_parent){const[a,o]=n._merge_parent;if(a===e&&o===i)n._merged=!1,n._merge_parent=void 0;else{this.setCell(a,o,r);return}}const s=n||this._defaultCell();Object.assign(s,r),this.cells[i][e]=s}getCell(e,i){return i<0||i>=this.rows||e<0||e>=this.columns?null:this.cells[i][e]}clearCell(e,i){i<0||i>=this.rows||e<0||e>=this.columns||(this.cells[i][e]=null)}_setHelper(e){this._helper=e}cell(...e){return this._helper.cell(this,...e)}clear(...e){return this._helper.clear(this,...e)}merge_cells(...e){return this._helper.merge_cells(this,...e)}cell_set_text(...e){return this._helper.cell_set_text(this,...e)}cell_set_bgcolor(...e){return this._helper.cell_set_bgcolor(this,...e)}cell_set_text_color(...e){return this._helper.cell_set_text_color(this,...e)}cell_set_text_size(...e){return this._helper.cell_set_text_size(this,...e)}cell_set_height(...e){return this._helper.cell_set_height(this,...e)}cell_set_width(...e){return this._helper.cell_set_width(this,...e)}cell_set_tooltip(...e){return this._helper.cell_set_tooltip(this,...e)}cell_set_text_halign(...e){return this._helper.cell_set_text_halign(this,...e)}cell_set_text_valign(...e){return this._helper.cell_set_text_valign(this,...e)}cell_set_text_font_family(...e){return this._helper.cell_set_text_font_family(this,...e)}set_position(...e){return this._helper.set_position(this,...e)}set_bgcolor(...e){return this._helper.set_bgcolor(this,...e)}set_border_color(...e){return this._helper.set_border_color(this,...e)}set_border_width(...e){return this._helper.set_border_width(this,...e)}set_frame_color(...e){return this._helper.set_frame_color(this,...e)}set_frame_width(...e){return this._helper.set_frame_width(this,...e)}_defaultCell(){return{text:"",width:0,height:0,text_color:"#000000",text_halign:"center",text_valign:"center",text_size:"normal",bgcolor:"",tooltip:"",text_font_family:"default",_merged:!1,_merge_parent:null}}}var js=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,mm=(t,e,i)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,oe=(t,e,i,r)=>{for(var n=r>1?void 0:r?dm(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&js(e,i,n),n},ym=(t,e,i)=>mm(t,typeof e!="symbol"?e+"":e,i);class ae{constructor(e){this.context=e,ym(this,"_tables",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__tables__||(this.context.plots.__tables__={title:"__tables__",data:[],options:{style:"table",overlay:!0}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__tables__.data=[{time:e,value:this._tables.filter(i=>!i._deleted).map(i=>i.toPlotData()),options:{style:"table"}}]}_resolve(e){return e==null?e:typeof e=="object"&&"__value"in e?e.__value:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(...e){let i="top_right",r=1,n=1,s="",a="",o=0,l="",c=0,u=!1;const p=e[e.length-1];if(p&&typeof p=="object"&&!Array.isArray(p)&&("bgcolor"in p||"frame_color"in p||"border_color"in p||"position"in p||"columns"in p||"rows"in p)){const f=p,d=e.slice(0,-1);i=d[0]??f.position??i,r=d[1]??f.columns??r,n=d[2]??f.rows??n,s=f.bgcolor??s,a=f.frame_color??a,o=f.frame_width??o,l=f.border_color??l,c=f.border_width??c,u=f.force_overlay??u}else i=e[0]??i,r=e[1]??r,n=e[2]??n,s=e[3]??s,a=e[4]??a,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u;const h=new vn(this._resolve(i)||"top_right",this._resolve(r)||1,this._resolve(n)||1,this._resolve(s)||"",this._resolve(a)||"",this._resolve(o)||0,this._resolve(l)||"",this._resolve(c)||0,this._resolve(u)??!1);return h._setHelper(this),this._tables.push(h),this.syncToPlot(),h}any(...e){if(e.length===1){const i=e[0];return i==null||typeof i=="object"&&"__value"in i||typeof i=="number"&&isNaN(i)?null:i instanceof vn?i:null}return this.new(...e)}cell(...e){let i,r,n,s="",a=0,o=0,l="#000000",c="center",u="center",p="normal",h="",f="",d="default";const m=e[e.length-1];if(m&&typeof m=="object"&&!Array.isArray(m)&&("text"in m||"bgcolor"in m||"text_color"in m||"text_size"in m||"text_halign"in m||"tooltip"in m||"column"in m||"row"in m||"height"in m||"width"in m||"text_valign"in m||"text_font_family"in m)){const w=m,E=e.slice(0,-1);i=E[0],r=E.length>1?E[1]:w.column??0,n=E.length>2?E[2]:w.row??0,s=E[3]??w.text??s,a=E[4]??w.width??a,o=E[5]??w.height??o,l=E[6]??w.text_color??l,c=E[7]??w.text_halign??c,u=E[8]??w.text_valign??u,p=E[9]??w.text_size??p,h=E[10]??w.bgcolor??h,f=E[11]??w.tooltip??f,d=E[12]??w.text_font_family??d}else i=e[0],r=e[1]??0,n=e[2]??0,s=e[3]??s,a=e[4]??a,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u,p=e[9]??p,h=e[10]??h,f=e[11]??f,d=e[12]??d;const x=this._resolve(i);if(!x||x._deleted)return;const b=this._resolve(r)??0,v=this._resolve(n)??0;x.setCell(b,v,{text:this._resolveText(this._resolve(s)),width:this._resolve(a)||0,height:this._resolve(o)||0,text_color:this._resolve(l)||"#000000",text_halign:this._resolve(c)||"center",text_valign:this._resolve(u)||"center",text_size:this._resolve(p)||"normal",bgcolor:this._resolve(h)||"",tooltip:this._resolveText(this._resolve(f)),text_font_family:this._resolve(d)||"default"}),this.syncToPlot()}delete(e){e&&(e._deleted=!0)}clear(...e){let i,r,n,s,a;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,s=f.end_column??(e.length>4?e[3]:r),a=f.end_row??(e.length>5?e[4]:n)}else i=e[0],r=e[1]??0,n=e[2]??0,s=e[3]??r,a=e[4]??n;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,u=this._resolve(n)??0,p=this._resolve(s)??c,h=this._resolve(a)??u;for(let f=u;f<=h;f++)for(let d=c;d<=p;d++)l.clearCell(d,f);this.syncToPlot()}merge_cells(...e){let i,r,n,s,a;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,s=f.end_column??(e.length>4?e[3]:0),a=f.end_row??(e.length>5?e[4]:0)}else i=e[0],r=e[1]??0,n=e[2]??0,s=e[3]??0,a=e[4]??0;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,u=this._resolve(n)??0,p=this._resolve(s)??0,h=this._resolve(a)??0;for(let f=u;f<=h;f++)for(let d=c;d<=p;d++)f===u&&d===c||l.setCell(d,f,{_merged:!0,_merge_parent:[c,u]});l.merges.push({startCol:c,startRow:u,endCol:p,endRow:h}),this.syncToPlot()}cell_set_text(e,i,r,n){this._setCellProp(e,i,r,"text",n,!0)}cell_set_bgcolor(e,i,r,n){this._setCellProp(e,i,r,"bgcolor",n)}cell_set_text_color(e,i,r,n){this._setCellProp(e,i,r,"text_color",n)}cell_set_text_size(e,i,r,n){this._setCellProp(e,i,r,"text_size",n)}cell_set_height(e,i,r,n){this._setCellProp(e,i,r,"height",n)}cell_set_width(e,i,r,n){this._setCellProp(e,i,r,"width",n)}cell_set_tooltip(e,i,r,n){this._setCellProp(e,i,r,"tooltip",n,!0)}cell_set_text_halign(e,i,r,n){this._setCellProp(e,i,r,"text_halign",n)}cell_set_text_valign(e,i,r,n){this._setCellProp(e,i,r,"text_valign",n)}cell_set_text_font_family(e,i,r,n){this._setCellProp(e,i,r,"text_font_family",n)}set_position(e,i){const r=this._resolve(e);!r||r._deleted||(r.position=this._resolve(i)||r.position,this.syncToPlot())}set_bgcolor(e,i){const r=this._resolve(e);!r||r._deleted||(r.bgcolor=this._resolve(i)||"",this.syncToPlot())}set_border_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_color=this._resolve(i)||"",this.syncToPlot())}set_border_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_width=this._resolve(i)||0,this.syncToPlot())}set_frame_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_color=this._resolve(i)||"",this.syncToPlot())}set_frame_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_width=this._resolve(i)||0,this.syncToPlot())}get all(){return this._tables.filter(e=>!e._deleted)}rollbackFromBar(e){this.syncToPlot()}_setCellProp(e,i,r,n,s,a=!1){const o=this._resolve(e);if(!o||o._deleted)return;const l=this._resolve(i)??0,c=this._resolve(r)??0,u=this._resolve(s);o.setCell(l,c,{[n]:a?this._resolveText(u):u}),this.syncToPlot()}_resolveText(e){return e==null||e!==e?"":String(e)}}oe([C],ae.prototype,"new",1),oe([C],ae.prototype,"cell",1),oe([C],ae.prototype,"delete",1),oe([C],ae.prototype,"clear",1),oe([C],ae.prototype,"merge_cells",1),oe([C],ae.prototype,"cell_set_text",1),oe([C],ae.prototype,"cell_set_bgcolor",1),oe([C],ae.prototype,"cell_set_text_color",1),oe([C],ae.prototype,"cell_set_text_size",1),oe([C],ae.prototype,"cell_set_height",1),oe([C],ae.prototype,"cell_set_width",1),oe([C],ae.prototype,"cell_set_tooltip",1),oe([C],ae.prototype,"cell_set_text_halign",1),oe([C],ae.prototype,"cell_set_text_valign",1),oe([C],ae.prototype,"cell_set_text_font_family",1),oe([C],ae.prototype,"set_position",1),oe([C],ae.prototype,"set_bgcolor",1),oe([C],ae.prototype,"set_border_color",1),oe([C],ae.prototype,"set_border_width",1),oe([C],ae.prototype,"set_frame_color",1),oe([C],ae.prototype,"set_frame_width",1);class _m{constructor(e){this.context=e}param(e,i=0,r){return typeof e=="string"?e:y.from(e).get(i)}inherit(e,i){return this._coerce(i)}new(e,i,r,n,s,a){const o=this._coerce(e),l=this._coerce(i);return o?l?`${o}:${l}`:o:l}modify(e,i,r,n,s){return this._coerce(e)}standard(e){return e==null?this.context?.pine?.syminfo?.tickerid||this.context?.tickerId||"":this._coerce(e)}heikinashi(e){return this._coerce(e)}renko(e,i,r,n,s){return this._coerce(e)}kagi(e,i){return this._coerce(e)}linebreak(e,i){return this._coerce(e)}pointfigure(e,i,r,n,s){return this._coerce(e)}_coerce(e){if(e==null)return"";if(e instanceof y){const i=e.get(0);return i==null?"":String(i)}return typeof e=="number"&&isNaN(e)?"":String(e)}}var gm=Object.defineProperty,xm=(t,e,i)=>e in t?gm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,W=(t,e,i)=>xm(t,typeof e!="symbol"?e+"":e,i);const kr=class $i{constructor({marketData:e,source:i,tickerId:r,timeframe:n,limit:s,sDate:a,eDate:o,fullContext:l,inputs:c}){W(this,"data",{open:new y([]),high:new y([]),low:new y([]),close:new y([]),volume:new y([]),hl2:new y([]),hlc3:new y([]),ohlc4:new y([]),hlcc4:new y([]),bar_index:new y([])}),W(this,"indicator"),W(this,"cache",{}),W(this,"taState",{}),W(this,"strategy"),W(this,"isSecondaryContext",!1),W(this,"chartTimezone",null),W(this,"dataVersion",0),W(this,"__maxLoops",5e5),W(this,"NA",NaN),W(this,"warnings",[]),W(this,"alerts",[]),W(this,"_alertMode","realtime"),W(this,"_propOverrides",{}),W(this,"_execTick",0),W(this,"lang"),W(this,"length",0),W(this,"_drawingHelpers",[]),W(this,"pine"),W(this,"idx",0),W(this,"params",{}),W(this,"const",{}),W(this,"var",{}),W(this,"let",{}),W(this,"lctx",new Map),W(this,"result"),W(this,"plots",{}),W(this,"marketData"),W(this,"source"),W(this,"tickerId"),W(this,"timeframe",""),W(this,"limit"),W(this,"sDate"),W(this,"eDate"),W(this,"fullContext"),W(this,"viewportLeft"),W(this,"viewportRight"),W(this,"pineTSCode"),W(this,"inputs",{}),W(this,"_callStack",[]),W(this,"_pathStack",[]),this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=n,this.limit=s,this.sDate=a,this.eDate=o,this.fullContext=l||this,this.inputs=c||{};const u=new ks(this),p={Type:u.Type.bind(u),na:new Re,nz:u.nz.bind(u),indicator:u.indicator.bind(u),fixnan:u.fixnan.bind(u),alertcondition:u.alertcondition.bind(u),alert:new Is(this),error:u.error.bind(u),max_bars_back:u.max_bars_back.bind(u),timestamp:u.timestamp.bind(u),time:new ln(this,"openTime"),time_close:new ln(this,"closeTime"),dayofmonth:new vt(this,wt.dayofmonth),dayofweek:new vt(this,wt.dayofweek),hour:new vt(this,wt.hour),minute:new vt(this,wt.minute),month:new vt(this,wt.month),second:new vt(this,wt.second),weekofyear:new vt(this,wt.weekofyear),year:new vt(this,wt.year),bool:u.bool.bind(u),int:u.int.bind(u),float:u.float.bind(u),string:u.string.bind(u)},h=this;this.pine={input:new au(this),ta:new xp(this),math:new Wu(this),request:new rh(this),array:new Zo(this),map:new pl(this),matrix:new pc(this),ticker:new _m(this),strategy:new Gf(this),syminfo:null,timeframe:new ad(this),barstate:new yc(this),get bar_index(){return h.data.bar_index},get last_bar_index(){return h.data.close.length-1},get last_bar_time(){const k=h.marketData;return Array.isArray(k)&&k.length>0?k[k.length-1].openTime:h.data.openTime.get(0)},get timenow(){return new Date().getTime()},get time_tradingday(){const k=y.from(h.data.closeTime).get(0);if(isNaN(k))return NaN;const U=h.pine?.syminfo?.timezone||"UTC",R=Rt(k,U);return Date.UTC(R.year,R.month-1,R.day,0,0,0)},get inputs(){return h.inputs},log:new Zf(this),str:new id(this),...p,...ko};const f=p.dayofweek;Object.assign(f,{sunday:1,monday:2,tuesday:3,wednesday:4,thursday:5,friday:6,saturday:7}),this.pine.dayofweek=f;const d=new yt(this),m=new Ps(this),x=new Ds(this);this.bindContextObject(d,["plotchar","plotshape","plotarrow","plotbar","plotcandle","bgcolor","barcolor"]),this.bindContextObject(d,["any","param","linestyle_dashed","linestyle_dotted","linestyle_solid","style_area","style_areabr","style_circles","style_columns","style_cross","style_histogram","style_line","style_linebr","style_stepline","style_stepline_diamond","style_steplinebr"],"plot"),this.bindContextObject(m,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(x,["any","param"],"fill");const b=new kd(this);this.pine.chart={param:b.param.bind(b),bg_color:b.bg_color.bind(b),fg_color:b.fg_color.bind(b),is_standard:b.is_standard.bind(b),is_heikinashi:b.is_heikinashi.bind(b),is_kagi:b.is_kagi.bind(b),is_linebreak:b.is_linebreak.bind(b),is_pnf:b.is_pnf.bind(b),is_range:b.is_range.bind(b),is_renko:b.is_renko.bind(b),point:b.point,get left_visible_bar_time(){if(h.viewportLeft!==void 0)return h.viewportLeft;const k=h.marketData;return Array.isArray(k)&&k.length>0?k[0].openTime:NaN},get right_visible_bar_time(){if(h.viewportRight!==void 0)return h.viewportRight;const k=h.marketData;return Array.isArray(k)&&k.length>0?k[k.length-1].openTime:NaN}};const v=new xe(this);this.bindContextObject(v,["any","new","param","set_x","set_y","set_xy","set_text","set_color","set_textcolor","set_size","set_style","set_textalign","set_tooltip","set_point","set_xloc","set_yloc","get_x","get_y","get_text","copy","delete","style_label_down","style_label_up","style_label_left","style_label_right","style_label_lower_left","style_label_lower_right","style_label_upper_left","style_label_upper_right","style_label_center","style_circle","style_square","style_diamond","style_flag","style_arrowup","style_arrowdown","style_cross","style_xcross","style_triangleup","style_triangledown","style_none","style_text_outline"],"label"),Object.defineProperty(this.pine.label,"all",{get:()=>v.all});const w=new be(this);this.bindContextObject(w,["any","new","param","set_x1","set_y1","set_x2","set_y2","set_xy1","set_xy2","set_color","set_width","set_style","set_extend","set_xloc","set_first_point","set_second_point","get_x1","get_y1","get_x2","get_y2","get_price","copy","delete","style_solid","style_dotted","style_dashed","style_arrow_left","style_arrow_right","style_arrow_both"],"line"),Object.defineProperty(this.pine.line,"all",{get:()=>w.all});const E=new ee(this);this.bindContextObject(E,["any","new","param","copy","delete","set_left","set_right","set_top","set_bottom","set_lefttop","set_rightbottom","set_top_left_point","set_bottom_right_point","set_bgcolor","set_border_color","set_border_width","set_border_style","set_extend","set_xloc","set_text","set_text_color","set_text_size","set_text_halign","set_text_valign","set_text_wrap","set_text_font_family","set_text_formatting","get_left","get_right","get_top","get_bottom"],"box"),Object.defineProperty(this.pine.box,"all",{get:()=>E.all});const T=new Oi(this);this.bindContextObject(T,["any","new","param","set_color","get_line1","get_line2","delete"],"linefill"),Object.defineProperty(this.pine.linefill,"all",{get:()=>T.all});const N=new Ir(this);this.bindContextObject(N,["any","new","param","delete"],"polyline"),Object.defineProperty(this.pine.polyline,"all",{get:()=>N.all});const A=new ae(this);this.bindContextObject(A,["any","new","param","cell","delete","clear","merge_cells","cell_set_text","cell_set_bgcolor","cell_set_text_color","cell_set_text_size","cell_set_height","cell_set_width","cell_set_tooltip","cell_set_text_halign","cell_set_text_valign","cell_set_text_font_family","set_position","set_bgcolor","set_border_color","set_border_width","set_frame_color","set_frame_width"],"table"),Object.defineProperty(this.pine.table,"all",{get:()=>A.all}),this._drawingHelpers=[v,w,E,T,N,A];const O=new Pc(this);this.bindContextObject(O,["any","param","new","rgb","from_gradient","r","g","b","t","aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"],"color")}warn(e,i){this.warnings.push({message:e,method:i,bar:this.idx})}rollbackDrawings(e){for(const i of this._drawingHelpers)i.rollbackFromBar(e)}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const n=r?this.pine[r]:this.pine;for(const s of i)typeof e[s]=="function"?n[s]=e[s].bind(e):n[s]=e[s]}init(e,i,r=0){let n;return i instanceof y?n=i.get(0):Array.isArray(i)?Array.isArray(i[0])?n=i[0]:n=i[i.length-1+r]:n=i,e?e instanceof y?(e.data[e.data.length-1]=n,e):Array.isArray(e)?(e[e.length-1]=n,new y(e)):new y([n]):new y([n])}initVar(e,i){if(e)return e;if(typeof i=="function"&&(i=i()),i instanceof It){const n=i.__def__;for(const s in n)typeof i[s]=="function"&&(i[s]=i[s]())}let r;return i instanceof y?r=i.get(0):Array.isArray(i)?Array.isArray(i[0])?r=i[0]:r=this.precision(i[i.length-1]):r=this.precision(i),new y([r])}precision(e,i=10){const r=i===10?$i.PRECISION_EPSILON:10**i;return typeof e=="number"?Math.round(e*r)/r:e}param(e,i,r){return typeof e=="string"?e:e instanceof y?i?new y(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new y(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new y(this.params[r],i||0)))}get(e,i){if(e instanceof y)return e.get(i);if(Array.isArray(e)){const r=e.length-1-i;return r<0||r>=e.length?NaN:e[r]}return e}set(e,i){if(e instanceof y){e.set(0,typeof i=="number"?this.precision(i):i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}iter(e){return e==null?[]:Array.isArray(e.array)?e.array:e.map instanceof Map?e.map:e}entries(e){return e==null?[].entries():Array.isArray(e.array)?e.array.entries():e.map instanceof Map?e.map.entries():Array.isArray(e)||typeof e.entries=="function"?e.entries():[].entries()}pushId(e){const i=this._pathStack.length>0?this._pathStack[this._pathStack.length-1]:"",r=i?i+"|"+e:e;this._callStack.push(e),this._pathStack.push(r)}popId(){this._callStack.pop(),this._pathStack.pop()}peekId(){return this._pathStack.length>0?this._pathStack[this._pathStack.length-1]:""}peekCtx(){const e=this.peekId();if(!e)return this;let i=this.lctx.get(e);return i||(i={id:e,let:{},const:{},var:{}},this.lctx.set(e,i)),i}call(e,i,...r){this.pushId(i);try{return e(...r)}finally{this.popId()}}get math(){return this._showDeprecationWarning("const math = context.math","const { math, ta, input } = context.pine"),this.pine.math}get ta(){return this._showDeprecationWarning("const ta = context.ta","const { ta, math, input } = context.pine"),this.pine.ta}get input(){return this._showDeprecationWarning("const input = context.input","const { input, math, ta } = context.pine"),this.pine.input}get request(){return this._showDeprecationWarning("const request = context.request","const { request, math, ta } = context.pine"),this.pine.request}get array(){return this._showDeprecationWarning("const array = context.array","const { array, math, ta } = context.pine"),this.pine.array}get core(){return this._showDeprecationWarning("context.core.*","context.pine (e.g., const { na, plotchar, color, plot, nz } = context.pine)"),{na:this.pine.na,fill:this.pine.fill,plotchar:this.pine.plotchar,plotshape:this.pine.plotshape,plotarrow:this.pine.plotarrow,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(e,i){const r=`${e}->${i}`;$i._deprecationWarningsShown.has(r)||($i._deprecationWarningsShown.add(r),typeof window<"u"?console.warn("%c[WARNING]%c %s syntax is deprecated. Use %s instead. This will be removed in a future version.","color: #FFA500; font-weight: bold;","color: #FFA500;",e,i):console.warn(`\x1B[33m[WARNING] ${e} syntax is deprecated. Use ${i} instead. This will be removed in a future version.\x1B[0m`))}};W(kr,"_deprecationWarningsShown",new Set),W(kr,"PRECISION_EPSILON",10**10);let wn=kr;var bm=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Ls=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],vm="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",Bs="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",fr={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},dr="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",wm={5:dr,"5module":dr+" export import",6:dr+" const class extends export import super"},Fs=/^in(stanceof)?$/,Sm=new RegExp("["+Bs+"]"),Em=new RegExp("["+Bs+vm+"]");function Tr(t,e){for(var i=65536,r=0;r<e.length;r+=2){if(i+=e[r],i>t)return!1;if(i+=e[r+1],i>=t)return!0}return!1}function ut(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Sm.test(String.fromCharCode(t)):e===!1?!1:Tr(t,Ls)}function kt(t,e){return t<48?t===36:t<58?!0:t<65?!1:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Em.test(String.fromCharCode(t)):e===!1?!1:Tr(t,Ls)||Tr(t,bm)}var G=function(e,i){i===void 0&&(i={}),this.label=e,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function Ue(t,e){return new G(t,{beforeExpr:!0,binop:e})}var qe={beforeExpr:!0},Me={startsExpr:!0},Ur={};function K(t,e){return e===void 0&&(e={}),e.keyword=t,Ur[t]=new G(t,e)}var _={num:new G("num",Me),regexp:new G("regexp",Me),string:new G("string",Me),name:new G("name",Me),privateId:new G("privateId",Me),eof:new G("eof"),bracketL:new G("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new G("]"),braceL:new G("{",{beforeExpr:!0,startsExpr:!0}),braceR:new G("}"),parenL:new G("(",{beforeExpr:!0,startsExpr:!0}),parenR:new G(")"),comma:new G(",",qe),semi:new G(";",qe),colon:new G(":",qe),dot:new G("."),question:new G("?",qe),questionDot:new G("?."),arrow:new G("=>",qe),template:new G("template"),invalidTemplate:new G("invalidTemplate"),ellipsis:new G("...",qe),backQuote:new G("`",Me),dollarBraceL:new G("${",{beforeExpr:!0,startsExpr:!0}),eq:new G("=",{beforeExpr:!0,isAssign:!0}),assign:new G("_=",{beforeExpr:!0,isAssign:!0}),incDec:new G("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new G("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Ue("||",1),logicalAND:Ue("&&",2),bitwiseOR:Ue("|",3),bitwiseXOR:Ue("^",4),bitwiseAND:Ue("&",5),equality:Ue("==/!=/===/!==",6),relational:Ue("</>/<=/>=",7),bitShift:Ue("<</>>/>>>",8),plusMin:new G("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Ue("%",10),star:Ue("*",10),slash:Ue("/",10),starstar:new G("**",{beforeExpr:!0}),coalesce:Ue("??",1),_break:K("break"),_case:K("case",qe),_catch:K("catch"),_continue:K("continue"),_debugger:K("debugger"),_default:K("default",qe),_do:K("do",{isLoop:!0,beforeExpr:!0}),_else:K("else",qe),_finally:K("finally"),_for:K("for",{isLoop:!0}),_function:K("function",Me),_if:K("if"),_return:K("return",qe),_switch:K("switch"),_throw:K("throw",qe),_try:K("try"),_var:K("var"),_const:K("const"),_while:K("while",{isLoop:!0}),_with:K("with"),_new:K("new",{beforeExpr:!0,startsExpr:!0}),_this:K("this",Me),_super:K("super",Me),_class:K("class",Me),_extends:K("extends",qe),_export:K("export"),_import:K("import",Me),_null:K("null",Me),_true:K("true",Me),_false:K("false",Me),_in:K("in",{beforeExpr:!0,binop:7}),_instanceof:K("instanceof",{beforeExpr:!0,binop:7}),_typeof:K("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:K("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:K("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Oe=/\r\n?|\n|\u2028|\u2029/,Nm=new RegExp(Oe.source,"g");function ri(t){return t===10||t===13||t===8232||t===8233}function Ws(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var n=t.charCodeAt(r);if(ri(n))return r<i-1&&n===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var Us=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Se=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,qs=Object.prototype,Cm=qs.hasOwnProperty,Im=qs.toString,ni=Object.hasOwn||(function(t,e){return Cm.call(t,e)}),Sn=Array.isArray||(function(t){return Im.call(t)==="[object Array]"}),En=Object.create(null);function Ct(t){return En[t]||(En[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function gt(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var km=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,bi=function(e,i){this.line=e,this.column=i};bi.prototype.offset=function(e){return new bi(this.line,this.column+e)};var er=function(e,i,r){this.start=i,this.end=r,e.sourceFile!==null&&(this.source=e.sourceFile)};function zs(t,e){for(var i=1,r=0;;){var n=Ws(t,r,e);if(n<0)return new bi(i,e-r);++i,r=n}}var Ar={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Nn=!1;function Tm(t){var e={};for(var i in Ar)e[i]=t&&ni(t,i)?t[i]:Ar[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!Nn&&typeof console=="object"&&console.warn&&(Nn=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
1
|
+
import*as Ut from"fs";import*as ci from"path";import{fileURLToPath as Wa}from"url";function Ua(t){return e=>new F(e.array.map(i=>Math.abs(i)),e.type,t)}function qa(t){return e=>{let i=0,r=0;for(const n of e.array){const s=Number(n);isNaN(s)||(r++,i+=(s-i)/r)}return r===0?NaN:t.precision(i)}}function za(t){return(e,i)=>{const r=e.array;let n=0,s=r.length-1;for(;n<=s;){const a=Math.floor((n+s)/2),o=r[a];if(o===i)return a;o<i?n=a+1:s=a-1}return-1}}function Ka(t){return(e,i)=>{const r=e.array;let n=0,s=r.length;for(;n<s;){const a=Math.floor((n+s)/2);r[a]<i?n=a+1:s=a}return n<r.length&&r[n]===i?n:n-1}}function Ha(t){return(e,i)=>{const r=e.array;let n=0,s=r.length;for(;n<s;){const a=Math.floor((n+s)/2);r[a]<=i?n=a+1:s=a}return n>0&&r[n-1]===i?n-1:n}}function Ga(t){return e=>{e.array.length=0}}function Ya(t){return(e,i)=>(e.array.push(...i.array),e)}function Xa(t){return e=>new F([...e.array],e.type,t)}function Za(t){return(e,i,r=!0)=>{const n=e.array,s=i.array;if(n.length!==s.length)return NaN;let a=0,o=0,l=0;const c=[];for(let d=0;d<n.length;d++){const m=Number(n[d]),x=Number(s[d]);!isNaN(m)&&m!==null&&m!==void 0&&!isNaN(x)&&x!==null&&x!==void 0&&(a+=m,o+=x,l++,c.push(d))}if(l===0)return NaN;const u=a/l,p=o/l;let h=0;for(const d of c){const m=Number(n[d]),x=Number(s[d]);h+=(m-u)*(x-p)}const f=r?l:l-1;return f<=0?NaN:t.precision(h/f)}}function Qa(t){return e=>e.array.every(i=>!isNaN(i)&&i)}function Ja(t){return t.every(e=>typeof e=="number")?t.every(e=>Number.isInteger(e))?L.int:L.float:t.every(e=>typeof e=="string")?L.string:t.every(e=>typeof e=="boolean")?L.bool:L.any}function Ge(t){return typeof t=="number"?Number.isInteger(t)?L.int:L.float:typeof t=="string"?L.string:typeof t=="boolean"?L.bool:L.any}function wi(t,e){if(typeof t=="number"&&isNaN(t)||e===L.any)return!0;switch(e){case L.int:return Number.isInteger(t)||isNaN(t);case L.float:return typeof t=="number";case L.string:return typeof t=="string";case L.bool:return typeof t=="boolean";case L.box:case L.label:case L.line:case L.linefill:case L.table:case L.color:return t===null||typeof t=="object"||typeof t=="string"}return!1}function eo(t){return(e,i,r=0,n)=>{const s=e.array.length,a=n!==void 0?Math.min(n,s):s;for(let o=r;o<a;o++){if(!wi(i,e.type))throw new Error(`Cannot call 'array.fill' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array[o]=typeof i=="number"?t.precision(i):i}}}function to(t){return e=>e.array.length>0?e.array[0]:t.NA}function io(t){return(e,i)=>(i<0&&(i=e.array.length+i),i<0||i>=e.array.length?(t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.get"),NaN):e.array[i])}function ro(t){return(e,i)=>e.array.includes(i)}function no(t){return(e,i)=>typeof i=="number"&&i!==i?e.array.findIndex(r=>typeof r=="number"&&r!==r):e.array.indexOf(i)}function so(t){return(e,i,r)=>{if(!wi(r,e.type))throw new Error(`Cannot call 'array.insert' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);if(i<0&&(i=e.array.length+i),i<0||i>e.array.length){t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.insert");return}e.array.splice(i,0,r)}}function ao(t){return(e,i=",")=>e.array.join(i)}function oo(t){return e=>e.array.length>0?e.array[e.array.length-1]:t.NA}function lo(t){return(e,i)=>e.array.lastIndexOf(i)}function co(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let s=1;s<r.length;s++)r[s]>n&&(n=r[s]);return n??t.NA}return[...r].sort((n,s)=>s-n)[i]??t.NA}}function uo(t){return e=>{const i=e.array;if(i.length===0)return NaN;const r=new Array(i.length);for(let s=0;s<i.length;s++)r[s]=i[s];r.sort((s,a)=>s-a);const n=Math.floor(r.length/2);return r.length%2!==0?r[n]:(r[n-1]+r[n])/2}}function ho(t){return(e,i=0)=>{const r=e.array;if(r.length===0)return t.NA;if(i===0){let n=r[0];for(let s=1;s<r.length;s++)r[s]<n&&(n=r[s]);return n??t.NA}return[...r].sort((n,s)=>n-s)[i]??t.NA}}function po(t){return e=>{if(e.array.length===0)return NaN;const i=new Map;let r=0;for(const s of e.array){const a=(i.get(s)||0)+1;i.set(s,a),a>r&&(r=a)}const n=[];for(const[s,a]of i)a===r&&n.push(s);return n.sort((s,a)=>typeof s=="number"&&typeof a=="number"?s-a:typeof s=="string"&&typeof a=="string"?s<a?-1:s>a?1:0:0),n[0]}}function fo(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const s=new Array(n);for(let c=0;c<n;c++){const u=Number(r[c]);if(isNaN(u)||u===null||u===void 0)return NaN;s[c]=u}s.sort((c,u)=>c-u),i<0&&(i=0),i>100&&(i=100);const a=i/100*n-.5;if(a<=0)return t.precision(s[0]);if(a>=n-1)return t.precision(s[n-1]);const o=Math.floor(a),l=a-o;return t.precision(s[o]*(1-l)+s[o+1]*l)}}function mo(t){return(e,i)=>{const r=e.array,n=r.length;if(n===0)return NaN;const s=new Array;for(let o=0;o<n;o++){const l=Number(r[o]);!isNaN(l)&&l!==null&&l!==void 0&&s.push(l)}if(s.length===0)return NaN;s.sort((o,l)=>o-l),i<0&&(i=0),i>100&&(i=100);const a=Math.ceil(i/100*n);return a<=0?s[0]:a>s.length?NaN:s[a-1]}}function yo(t){return(e,i)=>{if(e.array.length===0)return NaN;const r=Math.floor(i);if(r<0||r>=e.array.length)return NaN;const n=Number(e.array[r]);if(isNaN(n)||n===null||n===void 0)return NaN;let s=0;for(const o of e.array){const l=Number(o);!isNaN(l)&&l!==null&&l!==void 0&&l<n&&s++}const a=e.array.length-1;return a<=0?NaN:s/a*100}}function _o(t){return e=>e.array.pop()}function go(t){return(e,i)=>{if(!wi(i,e.type))throw new Error(`Cannot call 'array.push' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.push(typeof i=="number"?t.precision(i):i)}}function xo(t){return e=>t.precision(t.pine.array.max(e)-t.pine.array.min(e))}function bo(t){return(e,i)=>(i<0&&(i=e.array.length+i),i<0||i>=e.array.length?(t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.remove"),NaN):e.array.splice(i,1)[0])}function vo(t){return e=>{e.array.reverse()}}function wo(t){return(e,i,r)=>{if(!wi(r,e.type))throw new Error(`Cannot call 'array.set' with argument 'value'='${r}'. An argument of 'literal ${typeof r}' type was used but a '${e.type}' is expected.`);if(i<0&&(i=e.array.length+i),i<0||i>=e.array.length){t.warn(`Index ${i} is out of bounds, array size is ${e.array.length}.`,"array.set");return}e.array[i]=typeof r=="number"?t.precision(r):r}}function So(t){return e=>e.array.shift()}function Eo(t){return e=>e.array.length}function No(t){return(e,i,r)=>{const n=r!==void 0?r:void 0;return new F(e.array.slice(i,n),e.type,t)}}function Co(t){return e=>e.array.some(i=>!isNaN(i)&&i)}var ti=(t=>(t[t.ascending=1]="ascending",t[t.descending=0]="descending",t))(ti||{}),rs=(t=>(t.AED="AED",t.ARS="ARS",t.AUD="AUD",t.BDT="BDT",t.BHD="BHD",t.BRL="BRL",t.BTC="BTC",t.CAD="CAD",t.CHF="CHF",t.CLP="CLP",t.CNY="CNY",t.COP="COP",t.CZK="CZK",t.DKK="DKK",t.EGP="EGP",t.ETH="ETH",t.EUR="EUR",t.GBP="GBP",t.HKD="HKD",t.HUF="HUF",t.IDR="IDR",t.ILS="ILS",t.INR="INR",t.ISK="ISK",t.JPY="JPY",t.KES="KES",t.KRW="KRW",t.KWD="KWD",t.LKR="LKR",t.MAD="MAD",t.MXN="MXN",t.MYR="MYR",t.NGN="NGN",t.NOK="NOK",t.NONE="NONE",t.NZD="NZD",t.PEN="PEN",t.PHP="PHP",t.PKR="PKR",t.PLN="PLN",t.QAR="QAR",t.RON="RON",t.RSD="RSD",t.RUB="RUB",t.SAR="SAR",t.SEK="SEK",t.SGD="SGD",t.THB="THB",t.TND="TND",t.TRY="TRY",t.TWD="TWD",t.USD="USD",t.USDT="USDT",t.VES="VES",t.VND="VND",t.ZAR="ZAR",t))(rs||{}),ns=(t=>(t[t.sunday=1]="sunday",t[t.monday=2]="monday",t[t.tuesday=3]="tuesday",t[t.wednesday=4]="wednesday",t[t.thursday=5]="thursday",t[t.friday=6]="friday",t[t.saturday=7]="saturday",t))(ns||{}),ss=(t=>(t.all="all",t.data_window="data_window",t.none="none",t.pane="pane",t.price_scale="price_scale",t.status_line="status_line",t))(ss||{}),as=(t=>(t.flag="shape_flag",t.arrowdown="shape_arrow_down",t.arrowup="shape_arrow_up",t.circle="shape_circle",t.cross="shape_cross",t.diamond="shape_diamond",t.labeldown="shape_label_down",t.labelup="shape_label_up",t.square="shape_square",t.triangledown="shape_triangle_down",t.triangleup="shape_triangle_up",t.xcross="shape_xcross",t))(as||{}),os=(t=>(t.abovebar="AboveBar",t.belowbar="BelowBar",t.absolute="Absolute",t.bottom="Bottom",t.top="Top",t))(os||{}),ls=(t=>(t.auto="auto",t.tiny="tiny",t.small="small",t.normal="normal",t.large="large",t.huge="huge",t))(ls||{}),cs=(t=>(t.inherit="inherit",t.mintick="mintick",t.percent="percent",t.price="price",t.volume="volume",t))(cs||{}),Io=(t=>(t.linestyle_dashed="linestyle_dashed",t.linestyle_dotted="linestyle_dotted",t.linestyle_solid="linestyle_solid",t.style_area="style_area",t.style_areabr="style_areabr",t.style_circles="style_circles",t.style_columns="style_columns",t.style_cross="style_cross",t.style_histogram="style_histogram",t.style_line="style_line",t.style_linebr="style_linebr",t.style_stepline="style_stepline",t.style_stepline_diamond="style_stepline_diamond",t.style_steplinebr="style_steplinebr",t))(Io||{}),us=(t=>(t.gaps_on="gaps_on",t.gaps_off="gaps_off",t.lookahead_on="lookahead_on",t.lookahead_off="lookahead_off",t))(us||{}),hs=(t=>(t.bar_index="bi",t.bar_time="bt",t))(hs||{}),ps=(t=>(t.price="pr",t.abovebar="ab",t.belowbar="bl",t))(ps||{}),fs=(t=>(t.left="l",t.right="r",t.both="b",t.none="n",t))(fs||{}),ds=(t=>(t.align_bottom="bottom",t.align_top="top",t.align_left="left",t.align_center="center",t.align_right="right",t.wrap_auto="auto",t.wrap_none="none",t.format_bold="bold",t.format_italic="italic",t.format_none="none",t))(ds||{}),ms=(t=>(t.family_default="default",t.family_monospace="monospace",t))(ms||{}),ys=(t=>(t.none="none",t.splits="splits",t.dividends="dividends",t))(ys||{}),_s=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(_s||{}),gs=(t=>(t.actual="earnings_actual",t.estimate="earnings_estimate",t.standardized="earnings_standardized",t.future_eps="earnings_future_eps",t.future_period_end_time="earnings_future_period_end_time",t.future_revenue="earnings_future_revenue",t.future_time="earnings_future_time",t))(gs||{}),xs=(t=>(t.gross="dividends_gross",t.net="dividends_net",t.future_amount="dividends_future_amount",t.future_ex_date="dividends_future_ex_date",t.future_pay_date="dividends_future_pay_date",t))(xs||{}),bs=(t=>(t.denominator="splits_denominator",t.numerator="splits_numerator",t))(bs||{}),vs=(t=>(t.top_left="top_left",t.top_center="top_center",t.top_right="top_right",t.middle_left="middle_left",t.middle_center="middle_center",t.middle_right="middle_right",t.bottom_left="bottom_left",t.bottom_center="bottom_center",t.bottom_right="bottom_right",t))(vs||{}),ws=(t=>(t.left="left",t.none="none",t.right="right",t))(ws||{}),Ss=(t=>(t.inherit="inherit",t.off="off",t.on="on",t))(Ss||{});const ko={order:ti,currency:rs,dayofweek:ns,display:ss,shape:as,location:os,size:ls,format:cs,barmerge:us,xloc:hs,yloc:ps,extend:fs,text:ds,font:ms,adjustment:ys,backadjustment:_s,earnings:gs,dividends:xs,splits:bs,position:vs,scale:ws,settlement_as_close:Ss};function To(t){return(e,i=ti.ascending)=>{e.array.sort((r,n)=>{let s=isNaN(r)?1/0:r,a=isNaN(n)?1/0:n;return i===ti.ascending?s-a:a-s})}}function Ao(t){return(e,i=ti.ascending)=>{const r=e.array.map((n,s)=>s);return r.sort((n,s)=>{const a=isNaN(e.array[n])?1/0:e.array[n],o=isNaN(e.array[s])?1/0:e.array[s];return i===ti.ascending?a-o:o-a}),new F(r,L.int,t)}}function Po(t){return e=>{const i=t.array.avg(e),r=t.array.stdev(e);return isNaN(r)?new F(e.array.map(()=>NaN),L.int,t):r===0?new F(e.array.map(()=>1),L.int,t):new F(e.array.map(n=>(n-i)/r),L.int,t)}}function Do(t){return(e,i=!0)=>{const r=e.array,n=r.length;if(n===0)return NaN;let s=0,a=0,o=0;for(let u=0;u<n;u++){const p=Number(r[u]);!isNaN(p)&&p!==null&&p!==void 0&&(s+=p,a+=p*p,o++)}if(o===0)return NaN;const l=s/o;let c=a/o-l*l;return c<0?NaN:(!i&&o>1&&(c=c*o/(o-1)),!i&&o===1?0:t.precision(Math.sqrt(c)))}}function Mo(t){return e=>t.precision(e.array.reduce((i,r)=>{const n=Number(r);return isNaN(n)?i:i+n},0))}function Ro(t){return(e,i)=>{if(!wi(i,e.type))throw new Error(`Cannot call 'array.unshift' with argument 'value'='${i}'. An argument of 'literal ${typeof i}' type was used but a '${e.type}' is expected.`);e.array.unshift(typeof i=="number"?t.precision(i):i)}}function Oo(t){return(e,i=!0)=>{let r=0,n=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(r+=c,n++)}if(n===0)return NaN;const s=r/n;let a=0;for(const l of e.array){const c=Number(l);!isNaN(c)&&c!==null&&c!==void 0&&(a+=(c-s)*(c-s))}const o=i?n:n-1;return o<=0?NaN:t.precision(a/o)}}var $o=Object.defineProperty,Vo=(t,e,i)=>e in t?$o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,W=(t,e,i)=>Vo(t,typeof e!="symbol"?e+"":e,i),L=(t=>(t.any="",t.box="box",t.bool="bool",t.color="color",t.float="float",t.int="int",t.label="label",t.line="line",t.linefill="linefill",t.string="string",t.table="table",t))(L||{});class F{constructor(e,i,r){this.array=e,this.type=i,this.context=r,W(this,"_abs"),W(this,"_avg"),W(this,"_binary_search"),W(this,"_binary_search_leftmost"),W(this,"_binary_search_rightmost"),W(this,"_clear"),W(this,"_concat"),W(this,"_copy"),W(this,"_covariance"),W(this,"_every"),W(this,"_fill"),W(this,"_first"),W(this,"_get"),W(this,"_includes"),W(this,"_indexof"),W(this,"_insert"),W(this,"_join"),W(this,"_last"),W(this,"_lastindexof"),W(this,"_max"),W(this,"_median"),W(this,"_min"),W(this,"_mode"),W(this,"_percentile_linear_interpolation"),W(this,"_percentile_nearest_rank"),W(this,"_percentrank"),W(this,"_pop"),W(this,"_push"),W(this,"_range"),W(this,"_remove"),W(this,"_reverse"),W(this,"_set"),W(this,"_shift"),W(this,"_size"),W(this,"_slice"),W(this,"_some"),W(this,"_sort"),W(this,"_sort_indices"),W(this,"_standardize"),W(this,"_stdev"),W(this,"_sum"),W(this,"_unshift"),W(this,"_variance"),this._abs=Ua(this.context),this._avg=qa(this.context),this._binary_search=za(this.context),this._binary_search_leftmost=Ka(this.context),this._binary_search_rightmost=Ha(this.context),this._clear=Ga(this.context),this._concat=Ya(this.context),this._copy=Xa(this.context),this._covariance=Za(this.context),this._every=Qa(this.context),this._fill=eo(this.context),this._first=to(this.context),this._get=io(this.context),this._includes=ro(this.context),this._indexof=no(this.context),this._insert=so(this.context),this._join=ao(this.context),this._last=oo(this.context),this._lastindexof=lo(this.context),this._max=co(this.context),this._median=uo(this.context),this._min=ho(this.context),this._mode=po(this.context),this._percentile_linear_interpolation=fo(this.context),this._percentile_nearest_rank=mo(this.context),this._percentrank=yo(this.context),this._pop=_o(this.context),this._push=go(this.context),this._range=xo(this.context),this._remove=bo(this.context),this._reverse=vo(this.context),this._set=wo(this.context),this._shift=So(this.context),this._size=Eo(this.context),this._slice=No(this.context),this._some=Co(this.context),this._sort=To(this.context),this._sort_indices=Ao(this.context),this._standardize=Po(this.context),this._stdev=Do(this.context),this._sum=Mo(this.context),this._unshift=Ro(this.context),this._variance=Oo(this.context)}toString(){return"["+this.array.toString().replace(/,/g,", ")+"]"}[Symbol.iterator](){return this.array[Symbol.iterator]()}abs(...e){return this._abs(this,...e)}avg(...e){return this._avg(this,...e)}binary_search(...e){return this._binary_search(this,...e)}binary_search_leftmost(...e){return this._binary_search_leftmost(this,...e)}binary_search_rightmost(...e){return this._binary_search_rightmost(this,...e)}clear(...e){return this._clear(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}covariance(...e){return this._covariance(this,...e)}every(...e){return this._every(this,...e)}fill(...e){return this._fill(this,...e)}first(...e){return this._first(this,...e)}get(...e){return this._get(this,...e)}includes(...e){return this._includes(this,...e)}indexof(...e){return this._indexof(this,...e)}insert(...e){return this._insert(this,...e)}join(...e){return this._join(this,...e)}last(...e){return this._last(this,...e)}lastindexof(...e){return this._lastindexof(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}percentile_linear_interpolation(...e){return this._percentile_linear_interpolation(this,...e)}percentile_nearest_rank(...e){return this._percentile_nearest_rank(this,...e)}percentrank(...e){return this._percentrank(this,...e)}pop(...e){return this._pop(this,...e)}push(...e){return this._push(this,...e)}range(...e){return this._range(this,...e)}remove(...e){return this._remove(this,...e)}reverse(...e){return this._reverse(this,...e)}set(...e){return this._set(this,...e)}shift(...e){return this._shift(this,...e)}size(...e){return this._size(this,...e)}slice(...e){return this._slice(this,...e)}some(...e){return this._some(this,...e)}sort(...e){return this._sort(this,...e)}sort_indices(...e){return this._sort_indices(this,...e)}standardize(...e){return this._standardize(this,...e)}stdev(...e){return this._stdev(this,...e)}sum(...e){return this._sum(this,...e)}unshift(...e){return this._unshift(this,...e)}variance(...e){return this._variance(this,...e)}}function jo(t){return(...e)=>new F([...e],Ja(e),t)}function Lo(t){return(e,i)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;if(i===void 0){const n=r?Array(r).fill(0):[];return new F(n,L.any,t)}return new F(Array(r).fill(t.precision(i||0)),Ge(i||0),t)}}function Bo(t){return(e=0,i=!1)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.bool,t)}}function Fo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.box,t)}}function Wo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.color,t)}}function Uo(t){return(e=0,i=NaN)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(t.precision(i)),L.float,t)}}function qo(t){return(e=0,i=0)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(t.precision(i)),L.int,t)}}function zo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.label,t)}}function Ko(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.line,t)}}function Ho(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.linefill,t)}}function Go(t){return(e=0,i="")=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.string,t)}}function Yo(t){return(e=0,i=null)=>{const r=typeof e=="number"&&e>0&&!isNaN(e)?Math.floor(e):0;return new F(Array(r).fill(i),L.table,t)}}class y{constructor(e,i=0){this.data=e,this.offset=i}get(e){const i=this.data.length-1-(this.offset+e);return i<0||i>=this.data.length?NaN:this.data[i]}set(e,i){const r=this.data.length-1-(this.offset+e);r>=0&&r<this.data.length&&(this.data[r]=i)}get length(){return this.data.length}toArray(){return this.data}static from(e){return e instanceof y?e:Array.isArray(e)?new y(e):e!=null&&typeof e=="object"&&"__value"in e&&e.__value instanceof y?e.__value:new y([e])}}function Xo(t){return(e,i=0)=>y.from(e).get(i)}class Zo{constructor(e){this.context=e,this.abs=(i,...r)=>i.abs(...r),this.avg=(i,...r)=>i.avg(...r),this.binary_search=(i,...r)=>i.binary_search(...r),this.binary_search_leftmost=(i,...r)=>i.binary_search_leftmost(...r),this.binary_search_rightmost=(i,...r)=>i.binary_search_rightmost(...r),this.clear=(i,...r)=>i.clear(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.covariance=(i,...r)=>i.covariance(...r),this.every=(i,...r)=>i.every(...r),this.fill=(i,...r)=>i.fill(...r),this.first=(i,...r)=>i.first(...r),this.from=jo(e),this.get=(i,...r)=>i.get(...r),this.includes=(i,...r)=>i.includes(...r),this.indexof=(i,...r)=>i.indexof(...r),this.insert=(i,...r)=>i.insert(...r),this.join=(i,...r)=>i.join(...r),this.last=(i,...r)=>i.last(...r),this.lastindexof=(i,...r)=>i.lastindexof(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.new=Lo(e),this.new_bool=Bo(e),this.new_box=Fo(e),this.new_color=Wo(e),this.new_float=Uo(e),this.new_int=qo(e),this.new_label=zo(e),this.new_line=Ko(e),this.new_linefill=Ho(e),this.new_string=Go(e),this.new_table=Yo(e),this.param=Xo(),this.percentile_linear_interpolation=(i,...r)=>i.percentile_linear_interpolation(...r),this.percentile_nearest_rank=(i,...r)=>i.percentile_nearest_rank(...r),this.percentrank=(i,...r)=>i.percentrank(...r),this.pop=(i,...r)=>i.pop(...r),this.push=(i,...r)=>i.push(...r),this.range=(i,...r)=>i.range(...r),this.remove=(i,...r)=>i.remove(...r),this.reverse=(i,...r)=>i.reverse(...r),this.set=(i,...r)=>i.set(...r),this.shift=(i,...r)=>i.shift(...r),this.size=(i,...r)=>i.size(...r),this.slice=(i,...r)=>i.slice(...r),this.some=(i,...r)=>i.some(...r),this.sort=(i,...r)=>i.sort(...r),this.sort_indices=(i,...r)=>i.sort_indices(...r),this.standardize=(i,...r)=>i.standardize(...r),this.stdev=(i,...r)=>i.stdev(...r),this.sum=(i,...r)=>i.sum(...r),this.unshift=(i,...r)=>i.unshift(...r),this.variance=(i,...r)=>i.variance(...r)}}function Qo(t){return e=>{e.map.clear()}}function Jo(t){return(e,i)=>e.map.has(i)}function el(t){return e=>{const i=new Es(t);return i.map=new Map(e.map),i}}function tl(t){return(e,i)=>{const r=e.map.get(i);return r===void 0?NaN:r}}function il(t){return e=>{const i=Array.from(e.map.keys()),r=Ge(i[0]);return new F(i,r,t)}}function rl(t){return(e,i,r)=>{const n=e.map.get(i);return e.map.set(i,r),n===void 0?NaN:n}}function nl(t){return(e,i)=>{for(const[r,n]of i.map)e.map.set(r,n)}}function sl(t){return(e,i)=>{const r=e.map.get(i);return e.map.delete(i)?r:NaN}}function al(t){return e=>e.map.size}function ol(t){return e=>{const i=Array.from(e.map.values()),r=Ge(i[0]);return new F(i,r,t)}}var ll=Object.defineProperty,cl=(t,e,i)=>e in t?ll(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ze=(t,e,i)=>cl(t,typeof e!="symbol"?e+"":e,i);class Es{constructor(e){this.context=e,Ze(this,"map"),Ze(this,"_clear"),Ze(this,"_contains"),Ze(this,"_copy"),Ze(this,"_get"),Ze(this,"_keys"),Ze(this,"_put"),Ze(this,"_put_all"),Ze(this,"_remove"),Ze(this,"_size"),Ze(this,"_values"),this.map=new Map,this._clear=Qo(this.context),this._contains=Jo(this.context),this._copy=el(this.context),this._get=tl(this.context),this._keys=il(this.context),this._put=rl(this.context),this._put_all=nl(this.context),this._remove=sl(this.context),this._size=al(this.context),this._values=ol(this.context)}toString(){return`PineMapObject(${this.map.size})`}clear(...e){return this._clear(this,...e)}contains(...e){return this._contains(this,...e)}copy(...e){return this._copy(this,...e)}get(...e){return this._get(this,...e)}keys(...e){return this._keys(this,...e)}put(...e){return this._put(this,...e)}put_all(...e){return this._put_all(this,...e)}remove(...e){return this._remove(this,...e)}size(...e){return this._size(this,...e)}values(...e){return this._values(this,...e)}}function ul(t){return()=>new Es(t)}function hl(t){return(e,i=0)=>y.from(e).get(i)}class pl{constructor(e){this.context=e,this.clear=(i,...r)=>i.clear(...r),this.contains=(i,...r)=>i.contains(...r),this.copy=(i,...r)=>i.copy(...r),this.get=(i,...r)=>i.get(...r),this.keys=(i,...r)=>i.keys(...r),this.new=ul(e),this.param=hl(),this.put=(i,...r)=>i.put(...r),this.put_all=(i,...r)=>i.put_all(...r),this.remove=(i,...r)=>i.remove(...r),this.size=(i,...r)=>i.size(...r),this.values=(i,...r)=>i.values(...r)}}function fl(t){return(e,i,r)=>{const n=e.matrix.length;let s=[];if(r&&(r instanceof F?s=r.array:Array.isArray(r)?s=r:s=[r]),n===0){for(let l=0;l<s.length;l++){let c=s[l];c instanceof y&&(c=c.get(0)),e.matrix.push([c])}return}const a=e.matrix[0].length,o=i!==void 0?i:a;for(let l=0;l<n;l++){let c=l<s.length?s[l]:NaN;c instanceof y&&(c=c.get(0)),e.matrix[l].splice(o,0,c)}}}function dl(t){return(e,i,r)=>{const n=e.matrix.length;let s=[];if(r)if(r instanceof F)s=r.array;else if(Array.isArray(r))s=r;else if(r instanceof y){const c=r.get(0);Array.isArray(c)?s=c:s=[c]}else s=[r];const a=n>0?e.matrix[0].length:s.length,o=i!==void 0?i:n,l=[];for(let c=0;c<a;c++)if(c<s.length){let u=s[c];u instanceof y&&(u=u.get(0)),l.push(u)}else l.push(NaN);e.matrix.splice(o,0,l)}}function ml(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;if(r===0)return NaN;let n=0,s=0;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||(n+=l,s++)}return s===0?NaN:n/s}}function yl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i<0||i>=n){t.warn(`Column index ${i} is out of bounds, matrix has ${n} columns.`,"matrix.col");const o=r>0?Ge(e.matrix[0][0]):"float";return new F([],o,t)}const s=[];for(let o=0;o<r;o++)s.push(e.matrix[o][i]);const a=Ge(s[0]);return new F(s,a,t)}}function _l(t){return e=>e.matrix.length===0?0:e.matrix[0].length}function gl(t){return(e,i)=>{const r=e.matrix.length,n=i.matrix.length;if(r===0){for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]]);return}const s=e.matrix[0].length,a=n>0?i.matrix[0].length:0;if(s!==a&&n>0){console.error(`matrix.concat: Column count mismatch ${s} vs ${a}`);return}for(let o=0;o<n;o++)e.matrix.push([...i.matrix[o]])}}function xl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0,n=new Z(i,r,NaN,t);return n.matrix=e.matrix.map(s=>[...s]),n}}function bl(t){const e=t.length;if(e===0)return 0;if(e===1)return t[0][0];if(e===2)return t[0][0]*t[1][1]-t[0][1]*t[1][0];const i=t.map(n=>[...n]);let r=1;for(let n=0;n<e;n++){let s=n;for(;s<e&&i[s][n]===0;)s++;if(s===e)return 0;s!==n&&([i[n],i[s]]=[i[s],i[n]],r*=-1),r*=i[n][n];for(let a=n+1;a<e;a++){const o=i[a][n]/i[n][n];for(let l=n;l<e;l++)i[a][l]-=o*i[n][l]}}return r}function vl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;return i!==r?NaN:bl(e.matrix)}}function wl(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new Z(0,0,NaN,t);const n=e.matrix[0].length,s=new Z(r,n,NaN,t);if(i instanceof Z)for(let a=0;a<r;a++)for(let o=0;o<n;o++){const l=e.matrix[a][o],c=i.matrix[a]&&i.matrix[a][o]!==void 0?i.matrix[a][o]:NaN;s.matrix[a][o]=l-c}else{const a=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]-a}return s}}function Sl(t){const e=t.length;if(e!==2)return Array(e).fill(NaN);const i=t[0][0],r=t[0][1],n=t[1][0],s=t[1][1],a=i+s,o=i*s-r*n,l=a*a-4*o;if(l<0)return[NaN,NaN];const c=(a+Math.sqrt(l))/2,u=(a-Math.sqrt(l))/2;return[c,u]}function El(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r){const a=Ge(e.matrix[0][0]);return new F([],a,t)}const n=Sl(e.matrix),s=Ge(n[0]);return new F(n,s,t)}}function Nl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new Z(0,0,NaN,t);const n=new Z(i,r,0,t);for(let s=0;s<i;s++)n.matrix[s][s]=1;return n}}function Cl(t){return e=>{const i=e.matrix.length;return i===0?0:i*e.matrix[0].length}}function Il(t){return(e,i,r,n,s,a)=>{const o=e.matrix.length;if(o===0)return;const l=e.matrix[0].length,c=r!==void 0?r:0,u=n!==void 0?n:o,p=s!==void 0?s:0,h=a!==void 0?a:l;for(let f=c;f<u&&!(f>=o);f++)for(let d=p;d<h&&!(d>=l);d++)e.matrix[f][d]=i}}function kl(t){return(e,i,r)=>{const n=e.matrix.length,s=n>0?e.matrix[0].length:0;if(i<0||i>=n)return t.warn(`Row index ${i} is out of bounds, matrix has ${n} rows.`,"matrix.get"),NaN;if(r<0||r>=s)return t.warn(`Column index ${r} is out of bounds, matrix has ${s} columns.`,"matrix.get"),NaN;const a=e.matrix[i][r];return a===void 0?NaN:a}}function Ri(t){const e=t.length;if(e===0)return[];const i=new Array(e);for(let n=0;n<e;n++){i[n]=new Array(2*e);for(let s=0;s<e;s++)i[n][s]=t[n][s];for(let s=0;s<e;s++)i[n][e+s]=n===s?1:0}for(let n=0;n<e;n++){let s=Math.abs(i[n][n]),a=n;for(let l=n+1;l<e;l++){const c=Math.abs(i[l][n]);c>s&&(s=c,a=l)}if(s<1e-14)return t.map(l=>l.map(()=>NaN));if(a!==n){const l=i[n];i[n]=i[a],i[a]=l}const o=i[n][n];for(let l=n;l<2*e;l++)i[n][l]/=o;for(let l=0;l<e;l++){if(l===n)continue;const c=i[l][n];if(c!==0)for(let u=n;u<2*e;u++)i[l][u]-=c*i[n][u]}}const r=new Array(e);for(let n=0;n<e;n++){r[n]=new Array(e);for(let s=0;s<e;s++)r[n][s]=i[n][e+s]}return r}function Tl(t){return e=>{const i=e.matrix.length,r=i>0?e.matrix[0].length:0;if(i!==r)return new Z(i,r,NaN,t);const n=Ri(e.matrix),s=new Z(i,r,NaN,t);return s.matrix=n,s}}function Al(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(n+s!==i-1&&e.matrix[n][s]!==0)return!1;return!0}}function Pl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(e.matrix[s][n]!==-e.matrix[n][s])return!1;return!0}}function Dl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let s=0;s<r;s++){const a=e.matrix[n][s];if(a!==0&&a!==1)return!1}return!0}}function Ml(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(n!==s&&e.matrix[n][s]!==0)return!1;return!0}}function Rl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(n===s){if(e.matrix[n][s]!==1)return!1}else if(e.matrix[n][s]!==0)return!1;return!0}}function Ol(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;return i===r}}function $l(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;for(let n=0;n<i;n++){let s=0;for(let a=0;a<r;a++){const o=e.matrix[n][a];if(o<0)return!1;s+=o}if(Math.abs(s-1)>1e-10)return!1}return!0}}function Vl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;for(let n=0;n<i;n++)for(let s=0;s<n;s++)if(e.matrix[n][s]!==e.matrix[s][n])return!1;return!0}}function jl(t){return e=>{const i=e.matrix.length;if(i===0)return!1;const r=e.matrix[0].length;if(i!==r)return!1;let n=!0,s=!0;for(let a=0;a<i;a++)for(let o=0;o<r;o++)a>o&&e.matrix[a][o]!==0&&(n=!1),a<o&&e.matrix[a][o]!==0&&(s=!1);return n||s}}function Ll(t){return e=>{const i=e.matrix.length;if(i===0)return!0;const r=e.matrix[0].length;for(let n=0;n<i;n++)for(let s=0;s<r;s++)if(e.matrix[n][s]!==0)return!1;return!0}}function Bl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0,s=i.matrix.length,a=s>0?i.matrix[0].length:0,o=r*s,l=n*a,c=new Z(o,l,NaN,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){const h=e.matrix[u][p];for(let f=0;f<s;f++)for(let d=0;d<a;d++){const m=i.matrix[f][d];c.matrix[u*s+f][p*a+d]=h*m}}return c}}function Fl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=-1/0,s=!1;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||(l>n&&(n=l),s=!0)}return s?n:NaN}}function Wl(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=[];for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||n.push(l)}if(n.length===0)return NaN;n.sort((a,o)=>a-o);const s=Math.floor(n.length/2);return n.length%2!==0?n[s]:(n[s-1]+n[s])/2}}function Ul(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length;let n=1/0,s=!1;for(let a=0;a<i;a++)for(let o=0;o<r;o++){const l=e.matrix[a][o];isNaN(l)||(l<n&&(n=l),s=!0)}return s?n:NaN}}function ql(t){return e=>{const i=e.matrix.length;if(i===0)return NaN;const r=e.matrix[0].length,n=new Map;let s=0,a=NaN;for(let o=0;o<i;o++)for(let l=0;l<r;l++){const c=e.matrix[o][l];if(!isNaN(c)){const u=(n.get(c)||0)+1;n.set(c,u),u>s?(s=u,a=c):u===s&&c<a&&(a=c)}}return a}}function zl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(i instanceof Z){const s=i.matrix.length,a=s>0?i.matrix[0].length:0;if(n!==s)return new Z(0,0,NaN,t);const o=new Z(r,a,0,t);for(let l=0;l<r;l++)for(let c=0;c<a;c++){let u=0;for(let p=0;p<n;p++)u+=e.matrix[l][p]*i.matrix[p][c];o.matrix[l][c]=u}return o}else if(i instanceof F||Array.isArray(i.array||i)){const s=i.array||i;if(n!==s.length)return new F([],"float",t);const a=[];for(let o=0;o<r;o++){let l=0;for(let c=0;c<n;c++)l+=e.matrix[o][c]*s[c];a.push(l)}return new F(a,"float",t)}else{const s=i,a=new Z(r,n,NaN,t);for(let o=0;o<r;o++)for(let l=0;l<n;l++)a.matrix[o][l]=e.matrix[o][l]*s;return a}}}function Kl(t){return e=>{const i=e.matrix.length;if(i===0)return new Z(0,0,NaN,t);const r=e.matrix[0].length;if(i===r){const u=Ri(e.matrix),p=new Z(i,r,NaN,t);return p.matrix=u,p}const n=u=>{const p=u.length,h=u[0].length,f=new Array(h);for(let d=0;d<h;d++){f[d]=new Array(p);for(let m=0;m<p;m++)f[d][m]=u[m][d]}return f},s=(u,p)=>{const h=u.length,f=u[0].length,d=p[0].length,m=new Array(h);for(let x=0;x<h;x++){m[x]=new Array(d).fill(0);for(let b=0;b<f;b++){const v=u[x][b];if(v!==0)for(let w=0;w<d;w++)m[x][w]+=v*p[b][w]}}return m},a=e.matrix,o=n(a);let l;if(i>r){const u=s(o,a),p=Ri(u);l=s(p,o)}else{const u=s(a,o),p=Ri(u);l=s(o,p)}const c=new Z(r,i,NaN,t);return c.matrix=l,c}}function Hl(t){return(e,i)=>{const r=e.matrix.length,n=r>0?e.matrix[0].length:0;if(r!==n)return new Z(0,0,NaN,t);let s=new Z(r,n,0,t);for(let l=0;l<r;l++)s.matrix[l][l]=1;let a=new Z(r,n,NaN,t);for(let l=0;l<r;l++)a.matrix[l]=[...e.matrix[l]];let o=Math.floor(i);if(o<0)return new Z(r,n,NaN,t);for(;o>0;){if(o%2===1){const c=new Z(r,n,0,t);for(let u=0;u<r;u++)for(let p=0;p<n;p++){let h=0;for(let f=0;f<r;f++)h+=s.matrix[u][f]*a.matrix[f][p];c.matrix[u][p]=h}s=c}const l=new Z(r,n,0,t);for(let c=0;c<r;c++)for(let u=0;u<n;u++){let p=0;for(let h=0;h<r;h++)p+=a.matrix[c][h]*a.matrix[h][u];l.matrix[c][u]=p}a=l,o=Math.floor(o/2)}return s}}function Gl(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=e.matrix.map(a=>[...a]);let s=0;for(let a=0;a<r&&s<i;a++){let o=s;for(;o<i&&Math.abs(n[o][a])<1e-10;)o++;if(o<i){[n[s],n[o]]=[n[o],n[s]];const l=n[s][a];for(let c=a;c<r;c++)n[s][c]/=l;for(let c=0;c<i;c++)if(c!==s){const u=n[c][a];for(let p=a;p<r;p++)n[c][p]-=u*n[s][p]}s++}}return s}}function Yl(t){return(e,i)=>{const r=e.matrix.length;if(r===0){const a=Ge(e.matrix[0][0]);return new F([],a,t)}const n=[];for(let a=0;a<r;a++){const o=e.matrix[a].splice(i,1);n.push(o[0])}const s=Ge(n[0]);return new F(n,s,t)}}function Xl(t){return(e,i)=>{const r=e.matrix.splice(i,1),n=Ge(r[0][0]);return new F(r[0]||[],n,t)}}function Zl(t){return(e,i,r)=>{const n=e.matrix.length,s=n>0?e.matrix[0].length:0,a=i*r,o=[];for(let u=0;u<n;u++)for(let p=0;p<s;p++)o.push(e.matrix[u][p]);for(;o.length<a;)o.push(NaN);o.length>a&&(o.length=a);const l=[];let c=0;for(let u=0;u<i;u++){const p=[];for(let h=0;h<r;h++)p.push(o[c++]);l.push(p)}e.matrix=l}}function Ql(t){return e=>{e.matrix.reverse();for(const i of e.matrix)i.reverse()}}function Jl(t){return(e,i)=>{const r=e.matrix.length;if(i<0||i>=r){t.warn(`Row index ${i} is out of bounds, matrix has ${r} rows.`,"matrix.row");const s=r>0?Ge(e.matrix[0][0]):"float";return new F([],s,t)}const n=Ge(e.matrix[i][0]);return new F([...e.matrix[i]],n,t)}}function ec(t){return e=>e.matrix.length}function tc(t){return(e,i,r,n)=>{const s=e.matrix.length,a=s>0?e.matrix[0].length:0;if(i<0||i>=s){t.warn(`Row index ${i} is out of bounds, matrix has ${s} rows.`,"matrix.set");return}if(r<0||r>=a){t.warn(`Column index ${r} is out of bounds, matrix has ${a} columns.`,"matrix.set");return}e.matrix[i][r]=n}}function ic(t){return(e,i=0,r="asc")=>{e.matrix.length!==0&&e.matrix.sort((n,s)=>{const a=n[i],o=s[i];return a<o?r==="asc"?-1:1:a>o?r==="asc"?1:-1:0})}}function rc(t){return(e,i,r,n,s)=>{const a=r-i,o=s-n,l=new Z(a,o,NaN,t);for(let c=0;c<a;c++){const u=i+c;if(u>=e.matrix.length)break;for(let p=0;p<o;p++){const h=n+p;if(h>=e.matrix[u].length)break;l.matrix[c][p]=e.matrix[u][h]}}return l}}function nc(t){return(e,i)=>{const r=e.matrix.length;if(r===0)return new Z(0,0,NaN,t);const n=e.matrix[0].length,s=new Z(r,n,NaN,t);if(i instanceof Z)for(let a=0;a<r;a++)for(let o=0;o<n;o++){const l=e.matrix[a][o],c=i.matrix[a]&&i.matrix[a][o]!==void 0?i.matrix[a][o]:NaN;s.matrix[a][o]=l+c}else{const a=i;for(let o=0;o<r;o++)for(let l=0;l<n;l++)s.matrix[o][l]=e.matrix[o][l]+a}return s}}function sc(t){return(e,i,r)=>{const n=e.matrix.length;for(let s=0;s<n;s++){const a=e.matrix[s][i];e.matrix[s][i]=e.matrix[s][r],e.matrix[s][r]=a}}}function ac(t){return(e,i,r)=>{const n=e.matrix[i];e.matrix[i]=e.matrix[r],e.matrix[r]=n}}function oc(t){return e=>{const i=e.matrix.length;if(i===0)return 0;const r=e.matrix[0].length,n=Math.min(i,r);let s=0;for(let a=0;a<n;a++)s+=e.matrix[a][a];return s}}function lc(t){return e=>{const i=e.matrix.length;if(i===0)return new Z(0,0,NaN,t);const r=e.matrix[0].length,n=new Z(r,i,NaN,t);for(let s=0;s<i;s++)for(let a=0;a<r;a++)n.matrix[a][s]=e.matrix[s][a];return n}}var cc=Object.defineProperty,uc=(t,e,i)=>e in t?cc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,j=(t,e,i)=>uc(t,typeof e!="symbol"?e+"":e,i);class Z{constructor(e=0,i=0,r=NaN,n){if(this.context=n,j(this,"matrix"),j(this,"_add_col"),j(this,"_add_row"),j(this,"_avg"),j(this,"_col"),j(this,"_columns"),j(this,"_concat"),j(this,"_copy"),j(this,"_det"),j(this,"_diff"),j(this,"_eigenvalues"),j(this,"_eigenvectors"),j(this,"_elements_count"),j(this,"_fill"),j(this,"_get"),j(this,"_inv"),j(this,"_is_antidiagonal"),j(this,"_is_antisymmetric"),j(this,"_is_binary"),j(this,"_is_diagonal"),j(this,"_is_identity"),j(this,"_is_square"),j(this,"_is_stochastic"),j(this,"_is_symmetric"),j(this,"_is_triangular"),j(this,"_is_zero"),j(this,"_kron"),j(this,"_max"),j(this,"_median"),j(this,"_min"),j(this,"_mode"),j(this,"_mult"),j(this,"_pinv"),j(this,"_pow"),j(this,"_rank"),j(this,"_remove_col"),j(this,"_remove_row"),j(this,"_reshape"),j(this,"_reverse"),j(this,"_row"),j(this,"_rows"),j(this,"_set"),j(this,"_sort"),j(this,"_submatrix"),j(this,"_sum"),j(this,"_swap_columns"),j(this,"_swap_rows"),j(this,"_trace"),j(this,"_transpose"),this.matrix=[],e>0&&i>0)for(let s=0;s<e;s++)this.matrix.push(Array(i).fill(r));this._add_col=fl(this.context),this._add_row=dl(this.context),this._avg=ml(this.context),this._col=yl(this.context),this._columns=_l(this.context),this._concat=gl(this.context),this._copy=xl(this.context),this._det=vl(this.context),this._diff=wl(this.context),this._eigenvalues=El(this.context),this._eigenvectors=Nl(this.context),this._elements_count=Cl(this.context),this._fill=Il(this.context),this._get=kl(this.context),this._inv=Tl(this.context),this._is_antidiagonal=Al(this.context),this._is_antisymmetric=Pl(this.context),this._is_binary=Dl(this.context),this._is_diagonal=Ml(this.context),this._is_identity=Rl(this.context),this._is_square=Ol(this.context),this._is_stochastic=$l(this.context),this._is_symmetric=Vl(this.context),this._is_triangular=jl(this.context),this._is_zero=Ll(this.context),this._kron=Bl(this.context),this._max=Fl(this.context),this._median=Wl(this.context),this._min=Ul(this.context),this._mode=ql(this.context),this._mult=zl(this.context),this._pinv=Kl(this.context),this._pow=Hl(this.context),this._rank=Gl(this.context),this._remove_col=Yl(this.context),this._remove_row=Xl(this.context),this._reshape=Zl(this.context),this._reverse=Ql(this.context),this._row=Jl(this.context),this._rows=ec(this.context),this._set=tc(this.context),this._sort=ic(this.context),this._submatrix=rc(this.context),this._sum=nc(this.context),this._swap_columns=sc(this.context),this._swap_rows=ac(this.context),this._trace=oc(this.context),this._transpose=lc(this.context)}toString(){let e="";for(let i=0;i<this.matrix.length;i++)e+=e===""?"":`
|
|
2
|
+
`,e+="["+this.matrix[i].join(", ")+"]";return e}add_col(...e){return this._add_col(this,...e)}add_row(...e){return this._add_row(this,...e)}avg(...e){return this._avg(this,...e)}col(...e){return this._col(this,...e)}columns(...e){return this._columns(this,...e)}concat(...e){return this._concat(this,...e)}copy(...e){return this._copy(this,...e)}det(...e){return this._det(this,...e)}diff(...e){return this._diff(this,...e)}eigenvalues(...e){return this._eigenvalues(this,...e)}eigenvectors(...e){return this._eigenvectors(this,...e)}elements_count(...e){return this._elements_count(this,...e)}fill(...e){return this._fill(this,...e)}get(...e){return this._get(this,...e)}inv(...e){return this._inv(this,...e)}is_antidiagonal(...e){return this._is_antidiagonal(this,...e)}is_antisymmetric(...e){return this._is_antisymmetric(this,...e)}is_binary(...e){return this._is_binary(this,...e)}is_diagonal(...e){return this._is_diagonal(this,...e)}is_identity(...e){return this._is_identity(this,...e)}is_square(...e){return this._is_square(this,...e)}is_stochastic(...e){return this._is_stochastic(this,...e)}is_symmetric(...e){return this._is_symmetric(this,...e)}is_triangular(...e){return this._is_triangular(this,...e)}is_zero(...e){return this._is_zero(this,...e)}kron(...e){return this._kron(this,...e)}max(...e){return this._max(this,...e)}median(...e){return this._median(this,...e)}min(...e){return this._min(this,...e)}mode(...e){return this._mode(this,...e)}mult(...e){return this._mult(this,...e)}pinv(...e){return this._pinv(this,...e)}pow(...e){return this._pow(this,...e)}rank(...e){return this._rank(this,...e)}remove_col(...e){return this._remove_col(this,...e)}remove_row(...e){return this._remove_row(this,...e)}reshape(...e){return this._reshape(this,...e)}reverse(...e){return this._reverse(this,...e)}row(...e){return this._row(this,...e)}rows(...e){return this._rows(this,...e)}set(...e){return this._set(this,...e)}sort(...e){return this._sort(this,...e)}submatrix(...e){return this._submatrix(this,...e)}sum(...e){return this._sum(this,...e)}swap_columns(...e){return this._swap_columns(this,...e)}swap_rows(...e){return this._swap_rows(this,...e)}trace(...e){return this._trace(this,...e)}transpose(...e){return this._transpose(this,...e)}}function Qe(t){return(e,i,r)=>new Z(e,i,r,t)}function hc(t){return(e,i=0)=>y.from(e).get(i)}class pc{constructor(e){this.context=e,this.add_col=(i,...r)=>i.add_col(...r),this.add_row=(i,...r)=>i.add_row(...r),this.avg=(i,...r)=>i.avg(...r),this.col=(i,...r)=>i.col(...r),this.columns=(i,...r)=>i.columns(...r),this.concat=(i,...r)=>i.concat(...r),this.copy=(i,...r)=>i.copy(...r),this.det=(i,...r)=>i.det(...r),this.diff=(i,...r)=>i.diff(...r),this.eigenvalues=(i,...r)=>i.eigenvalues(...r),this.eigenvectors=(i,...r)=>i.eigenvectors(...r),this.elements_count=(i,...r)=>i.elements_count(...r),this.fill=(i,...r)=>i.fill(...r),this.get=(i,...r)=>i.get(...r),this.inv=(i,...r)=>i.inv(...r),this.is_antidiagonal=(i,...r)=>i.is_antidiagonal(...r),this.is_antisymmetric=(i,...r)=>i.is_antisymmetric(...r),this.is_binary=(i,...r)=>i.is_binary(...r),this.is_diagonal=(i,...r)=>i.is_diagonal(...r),this.is_identity=(i,...r)=>i.is_identity(...r),this.is_square=(i,...r)=>i.is_square(...r),this.is_stochastic=(i,...r)=>i.is_stochastic(...r),this.is_symmetric=(i,...r)=>i.is_symmetric(...r),this.is_triangular=(i,...r)=>i.is_triangular(...r),this.is_zero=(i,...r)=>i.is_zero(...r),this.kron=(i,...r)=>i.kron(...r),this.max=(i,...r)=>i.max(...r),this.median=(i,...r)=>i.median(...r),this.min=(i,...r)=>i.min(...r),this.mode=(i,...r)=>i.mode(...r),this.mult=(i,...r)=>i.mult(...r),this.new=Qe(e),this.param=hc(),this.pinv=(i,...r)=>i.pinv(...r),this.pow=(i,...r)=>i.pow(...r),this.rank=(i,...r)=>i.rank(...r),this.remove_col=(i,...r)=>i.remove_col(...r),this.remove_row=(i,...r)=>i.remove_row(...r),this.reshape=(i,...r)=>i.reshape(...r),this.reverse=(i,...r)=>i.reverse(...r),this.row=(i,...r)=>i.row(...r),this.rows=(i,...r)=>i.rows(...r),this.set=(i,...r)=>i.set(...r),this.sort=(i,...r)=>i.sort(...r),this.submatrix=(i,...r)=>i.submatrix(...r),this.sum=(i,...r)=>i.sum(...r),this.swap_columns=(i,...r)=>i.swap_columns(...r),this.swap_rows=(i,...r)=>i.swap_rows(...r),this.trace=(i,...r)=>i.trace(...r),this.transpose=(i,...r)=>i.transpose(...r),this.new_float=Qe(e),this.new_int=Qe(e),this.new_string=Qe(e),this.new_bool=Qe(e),this.new_color=Qe(e),this.new_line=Qe(e),this.new_label=Qe(e),this.new_box=Qe(e),this.new_linefill=Qe(e),this.new_table=Qe(e)}}var fc=Object.defineProperty,dc=(t,e,i)=>e in t?fc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,mc=(t,e,i)=>dc(t,typeof e!="symbol"?e+"":e,i);class yc{constructor(e){this.context=e,mc(this,"_live",!1)}setLive(){this._live=!0}get isnew(){return!this._live}get islast(){return this.context.idx===this.context.length-1}get isfirst(){return this.context.idx===0}get ishistory(){return this.context.idx<this.context.length-1}get isrealtime(){return this.context.idx===this.context.length-1}get isconfirmed(){return this.context.data.closeTime.data[this.context.idx]<=Date.now()}get islastconfirmedhistory(){const e=this.context.idx,i=this.context.length;if(e===i-1)return this.context.data.closeTime.data[e]<=Date.now();if(e===i-2){const r=this.context.marketData?.[i-1]?.closeTime;return r!==void 0?r>Date.now():!1}return!1}}var _c=Object.defineProperty,gc=(t,e,i)=>e in t?_c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,xc=(t,e,i)=>gc(t,typeof e!="symbol"?e+"":e,i);class It{constructor(e,i,r){this._definition=e,this.context=i,xc(this,"_udt");for(let n in e)this[n]=e[n];this._udt=r}get __def__(){return this._definition}copy(){return new It(this.__def__,this.context,this._udt)}toString(){const e={};for(let i in this.__def__){const r=this[i];r!=null&&typeof r=="object"&&typeof r.toString=="function"&&!(r instanceof Array)?e[i]=r.toString():e[i]=r}try{return JSON.stringify(e)}catch{return"{"+Object.keys(e).map(i=>`"${i}":${String(e[i])}`).join(",")+"}"}}}var bc=Object.defineProperty,vc=(t,e,i)=>e in t?bc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,cr=(t,e,i)=>vc(t,typeof e!="symbol"?e+"":e,i);class Ie{constructor(e,i,r){cr(this,"time"),cr(this,"index"),cr(this,"price"),this.time=e,this.index=i,this.price=r}copy(){return new Ie(this.time,this.index,this.price)}toString(){return JSON.stringify({time:this.time,index:this.index,price:this.price})}}function wc(t){return typeof t=="object"&&t&&(t.title!==void 0||t._plotKey!==void 0)&&t.data!==void 0&&t.options!==void 0}const on={series:t=>t instanceof y||typeof t=="number"||typeof t=="string"||typeof t=="boolean",string:t=>typeof t=="string",color:t=>typeof t=="string"||t===null||typeof t=="number"&&isNaN(t)||t instanceof y,number:t=>typeof t=="number",boolean:t=>typeof t=="boolean",array:t=>Array.isArray(t),object:t=>typeof t=="object",point:t=>t instanceof Ie,primitive:t=>typeof t===null||typeof t!="object"&&typeof t!="function",function:t=>typeof t=="function",undefined:t=>t===void 0,null:t=>t===null,NaN:t=>isNaN(t),any:()=>!0,remaining_options:t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof y)&&!(t instanceof Ie)&&!wc(t)};function et(t){const e=t[t.length-1];if(e&&typeof e=="object"&&"__callsiteId"in e)return t.pop().__callsiteId}function te(t,e,i,r){Array.isArray(e)&&typeof e[0]=="string"&&(e=[e]);const n={};let s={};const a=new Array(e.length).fill(!0);for(let o=0;o<t.length;o++){const l=t[o];if(on.remaining_options(l)){s=l;break}const c=e.map((u,p)=>a[p]?u[o]:void 0);for(let u=0;u<c.length;u++){const p=c[u];if(p===void 0){a[u]=!1;continue}const h=i[p];if(typeof l=="number"&&isNaN(l)&&(h==="number"||h==="series"))n[p]=l;else{const f=on[i[p]];typeof f=="function"&&f(l)?n[p]=l:a[u]=!1}}}return{...n,...s,...r}}function C(t,e,i){const r=i.value;return typeof r!="function"||(i.value=function(...n){return this&&this.context&&this.context.isSecondaryContext?null:r.apply(this,n)}),i}var Ns=Object.defineProperty,Sc=Object.getOwnPropertyDescriptor,Ec=(t,e,i)=>e in t?Ns(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Cs=(t,e,i,r)=>{for(var n=r>1?void 0:r?Sc(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Ns(e,i,n),n},Jt=(t,e,i)=>Ec(t,typeof e!="symbol"?e+"":e,i);const Nc=[["dateString"],["year","month","day","hour","minute","second"],["timezone","year","month","day","hour","minute","second"]],Cc={dateString:"string",timezone:"string",year:"number",month:"number",day:"number",hour:"number",minute:"number",second:"number"},Ic=["title","shorttitle","overlay","format","precision","scale","max_bars_back","timeframe","timeframe_gaps","explicit_plot_zorder","max_lines_count","max_labels_count","max_boxes_count","calc_bars_count","max_polylines_count","dynamic_requests","behind_chart"],kc={title:"string",shorttitle:"string",overlay:"boolean",format:"string",precision:"number",scale:"string",max_bars_back:"number",timeframe:"string",timeframe_gaps:"boolean",explicit_plot_zorder:"boolean",max_lines_count:"number",max_labels_count:"number",max_boxes_count:"number",calc_bars_count:"number",max_polylines_count:"number",dynamic_requests:"boolean",behind_chart:"boolean"};function Tc(t){return te(t,Ic,kc)}class Re{get __value(){return NaN}param(e,i=0){return y.from(e).get(i)}any(e){if(e instanceof Re)return!0;const i=y.from(e).get(0);return i instanceof Re||i==null?!0:typeof i=="number"?i!==i:!1}}const qt={freq_all:"alert.freq_all",freq_once_per_bar:"alert.freq_once_per_bar",freq_once_per_bar_close:"alert.freq_once_per_bar_close"};class Is{constructor(e){this.context=e,Jt(this,"_firedKeys",new Set),Jt(this,"_fallbackCounter",0),Jt(this,"_fallbackLastExecTick",-1)}get freq_all(){return qt.freq_all}get freq_once_per_bar(){return qt.freq_once_per_bar}get freq_once_per_bar_close(){return qt.freq_once_per_bar_close}param(e,i,r){return y.from(e).get(0)}any(e,i,r){const n=y.from(e).get(0),s=i?y.from(i).get(0):qt.freq_once_per_bar;let a;if(r&&typeof r=="object"&&r.__callsiteId)a=r.__callsiteId;else{const u=this.context._execTick||0;u!==this._fallbackLastExecTick&&(this._fallbackCounter=0,this._fallbackLastExecTick=u),a=`alert_${this._fallbackCounter++}`}const o=this.context.idx,l=this.context.pine?.barstate?.isrealtime??o===this.context.length-1;if((this.context._alertMode||"realtime")==="realtime"&&!l)return;const c=`${a}:${o}`;if(s===qt.freq_once_per_bar){if(this._firedKeys.has(c))return;this._firedKeys.add(c)}else if(s===qt.freq_once_per_bar_close){if(!(this.context.pine?.barstate?.isconfirmed??!0)||this._firedKeys.has(c))return;this._firedKeys.add(c)}this.context.alerts.push({type:"alert",id:a,message:n,freq:s,bar_index:o,time:this.context.data.openTime?.data?.[o]??0})}}Cs([C],Is.prototype,"any",1);class ks{constructor(e){this.context=e,Jt(this,"_acCounter",0),Jt(this,"_acLastExecTick",-1),Jt(this,"_acFiredKeys",new Set)}extractPlotOptions(e){const i={};for(let r in e)i[r]=y.from(e[r]).get(0);return i}indicator(...e){const i=e.map(s=>s instanceof y?s.get(0):s),r=Tc(i),n={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"points",max_bars_back:0,timeframe:"",timeframe_gaps:!0,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,calc_bars_count:0,max_polylines_count:50,dynamic_requests:!1,behind_chart:!0};return this.context.indicator={...n,...r,...this.context._propOverrides??{}},this.context.indicator}get bar_index(){return this.context.idx}na(e){const i=y.from(e).get(0);return i==null||typeof i=="number"&&isNaN(i)}nz(e,i=0){const r=y.from(e).get(0),n=y.from(i).get(0);return r==null||typeof r=="number"&&isNaN(r)?n:r}fixnan(e){const i=y.from(e);for(let r=0;r<i.length;r++){const n=i.get(r);if(!isNaN(n))return n}return NaN}alertcondition(e,i,r){const n=y.from(e).get(0),s=this.context.idx,a=this.context._execTick||0;a!==this._acLastExecTick&&(this._acCounter=0,this._acLastExecTick=a);const o=`alertcondition_${this._acCounter++}`;if(!n)return;const l=this.context.pine?.barstate?.isrealtime??s===this.context.length-1;if((this.context._alertMode||"realtime")==="realtime"&&!l)return;const c=`${o}:${s}`;if(this._acFiredKeys.has(c))return;this._acFiredKeys.add(c);const u=i?y.from(i).get(0):"",p=r?y.from(r).get(0):"";this.context.alerts.push({type:"alertcondition",id:o,title:u,message:p,bar_index:s,time:this.context.data.openTime?.data?.[s]??0})}error(...e){console.error("error called but is currently not implemented",e)}max_bars_back(e,i){}timestamp(...e){const i=e.map(n=>n instanceof y?n.get(0):n),r=te(i,Nc,Cc);if(r.year!==void 0){const n=r.year,s=r.month,a=r.day,o=r.hour||0,l=r.minute||0,c=r.second||0,u=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(u,n,s,a,o,l,c)}if(r.dateString!==void 0){const n=r.dateString.trim();if(/[Zz]$/.test(n)||/[+-]\d{2}:?\d{2}$/.test(n))return new Date(n).getTime();const s=n.includes("T")?n+"Z":n.replace(/\s+/,"T")+"Z",a=new Date(s);if(!isNaN(a.getTime())){const o=this.context.pine?.syminfo?.timezone||"UTC";return this._timestampFromComponents(o,a.getUTCFullYear(),a.getUTCMonth()+1,a.getUTCDate(),a.getUTCHours(),a.getUTCMinutes(),a.getUTCSeconds())}return new Date(n).getTime()}return NaN}_timestampFromComponents(e,i,r,n,s,a,o){const l=new Date(Date.UTC(i,r-1,n,s,a,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=e.trim();if(c==="UTC"||c==="GMT"||c==="Etc/UTC")return l.getTime();const u=c.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(u){const p=u[1]==="+"?1:-1,h=parseInt(u[2],10),f=parseInt(u[3]||"0",10),d=p*(h*60+f)*60*1e3;return l.getTime()-d}try{return this._timestampFromIANA(e,i,r,n,s,a,o)}catch{return l.getTime()}}_timestampFromIANA(e,i,r,n,s,a,o){const l=new Date(Date.UTC(i,r-1,n,s,a,o));i>=0&&i<100&&l.setUTCFullYear(i);const c=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(l),u=w=>parseInt(c.find(S=>S.type===w)?.value||"0",10),p=u("year"),h=u("month"),f=u("day");let d=u("hour");d===24&&(d=0);const m=u("minute"),x=u("second"),b=new Date(Date.UTC(p,h-1,f,d,m,x));p>=0&&p<100&&b.setUTCFullYear(p);const v=b.getTime()-l.getTime();return l.getTime()-v}bool(e){const i=y.from(e).get(0);return!isNaN(i)&&i!==0}int(e){const i=y.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "int" with argument "x"="${i}". An argument of "literal string" type was used but a "simple int" is expected.`);return Math.trunc(i)}float(e){const i=y.from(e).get(0);if(typeof i!="number")throw new Error(`Cannot call "float" with argument "x"="${i}". An argument of "literal string" type was used but a "const float" is expected.`);return i}string(e){return y.from(e).get(0).toString()}Type(e){const i=Object.keys(e),r={};for(const s of i){let a=e[s];a instanceof y&&(a=a.data),Array.isArray(a)&&(a[0],r[s]=a[1])}const n={new:function(...s){const a={};let o=null;if(s.length>0){const l=s[s.length-1];if(l&&typeof l=="object"&&!(l instanceof y)&&!Array.isArray(l)&&!(l instanceof It)){const c=Object.keys(l);c.length>0&&c.some(u=>i.includes(u))&&(o=l,s=s.slice(0,-1))}}for(let l=0;l<i.length;l++){const c=i[l];o&&c in o?a[c]=o[c]:l<s.length?a[c]=s[l]:c in r&&(a[c]=y.from(r[c]).get(0))}return new It(a,this.context,n)},copy:function(s){return new It(s.__def__,this.context,n)},_fieldDefaults:r,_definitionKeys:i};return n}}Cs([C],ks.prototype,"alertcondition",1);function zt(t){if(!t||typeof t!="string")return null;if(t.startsWith("#")){const i=t.slice(1);return i.length===6?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),1]:i.length===8?[parseInt(i.slice(0,2),16),parseInt(i.slice(2,4),16),parseInt(i.slice(4,6),16),parseInt(i.slice(6,8),16)/255]:null}const e=t.match(/rgba?\(\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\s*\)/);return e?[parseInt(e[1]),parseInt(e[2]),parseInt(e[3]),e[4]?parseFloat(e[4]):1]:null}function Ac(t,e,i,r){const n=Math.round(Math.max(0,Math.min(255,t))).toString(16).padStart(2,"0"),s=Math.round(Math.max(0,Math.min(255,e))).toString(16).padStart(2,"0"),a=Math.round(Math.max(0,Math.min(255,i))).toString(16).padStart(2,"0");if(r>=1)return`#${n}${s}${a}`.toUpperCase();const o=Math.round(Math.max(0,Math.min(255,r*255))).toString(16).padStart(2,"0");return`#${n}${s}${a}${o}`.toUpperCase()}const de={aqua:"#00BCD4",black:"#363A45",blue:"#2196F3",fuchsia:"#E040FB",gray:"#787B86",green:"#4CAF50",lime:"#00E676",maroon:"#880E4F",navy:"#311B92",olive:"#808000",orange:"#FF9800",purple:"#9C27B0",red:"#F23645",silver:"#B2B5BE",teal:"#089981",white:"#FFFFFF",yellow:"#FDD835"};function rt(t){return typeof t=="function"&&(t=t()),t&&typeof t=="object"&&Array.isArray(t.data)&&typeof t.get=="function"&&(t=t.get(0)),t}class Pc{constructor(e){this.context=e}any(e){const i=y.from(e).get(0);return typeof i=="number"&&isNaN(i)?null:i}param(e,i=0){return y.from(e).get(i)}new(e,i){if(e=rt(e),!e||typeof e!="string")return e;if(typeof i=="number"&&isNaN(i)&&(i=void 0),e.startsWith("#")){const r=e.slice(1),n=r.length===8?r.slice(0,6):r;return i!=null?`#${n}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:`#${r}`}else{const r=de[e];if(r)return i!=null?`#${r.slice(1)}${Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase()}`:r;const n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(n){const s=n[1],a=n[2],o=n[3];if(i!=null){const l=parseInt(s).toString(16).padStart(2,"0"),c=parseInt(a).toString(16).padStart(2,"0"),u=parseInt(o).toString(16).padStart(2,"0"),p=Math.round(255/100*(100-i)).toString(16).padStart(2,"0").toUpperCase();return`#${l}${c}${u}${p}`}return e}return i!=null?`rgba(${e}, ${(100-i)/100})`:e}}rgb(e,i,r,n){return typeof n=="number"&&isNaN(n)&&(n=void 0),n!=null?`rgba(${e}, ${i}, ${r}, ${(100-n)/100})`:`rgb(${e}, ${i}, ${r})`}from_gradient(e,i,r,n,s){if(e=rt(e),i=rt(i),r=rt(r),n=rt(n),s=rt(s),e==null||typeof e=="number"&&isNaN(e)||i==null||typeof i=="number"&&isNaN(i)||r==null||typeof r=="number"&&isNaN(r)||n==null||typeof n=="number"&&isNaN(n)||s==null||typeof s=="number"&&isNaN(s))return;let a=0;r!==i&&(a=(e-i)/(r-i)),a=Math.max(0,Math.min(1,a));const o=zt(typeof n=="string"?n:"#000000")||[0,0,0,1],l=zt(typeof s=="string"?s:"#FFFFFF")||[255,255,255,1],c=o[0]+(l[0]-o[0])*a,u=o[1]+(l[1]-o[1])*a,p=o[2]+(l[2]-o[2])*a,h=o[3]+(l[3]-o[3])*a;return Ac(c,u,p,h)}r(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?i[0]:NaN}g(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?i[1]:NaN}b(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?i[2]:NaN}t(e){if(e=rt(e),!e||typeof e!="string")return NaN;const i=zt(e);return i?Math.round(100-i[3]*100):NaN}aqua(){return de.aqua}black(){return de.black}blue(){return de.blue}fuchsia(){return de.fuchsia}gray(){return de.gray}green(){return de.green}lime(){return de.lime}maroon(){return de.maroon}navy(){return de.navy}olive(){return de.olive}orange(){return de.orange}purple(){return de.purple}red(){return de.red}silver(){return de.silver}teal(){return de.teal}white(){return de.white}yellow(){return de.yellow}}var Dc=Object.defineProperty,Mc=(t,e,i)=>e in t?Dc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Fi=(t,e,i)=>Mc(t,typeof e!="symbol"?e+"":e,i);function vr(t){if(!t)return"";const e=t.trim().toUpperCase();return e==="1D"||e==="D"?"D":e==="1W"||e==="W"?"W":e==="1M"||e==="M"?"M":e}function wr(t,e){const i=Rc(e);if(e==="M"){const o=new Date(t);return Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),1)}if(e==="W"){const o=new Date(t),l=o.getUTCDay(),c=l===0?6:l-1;return Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()-c)}if(e==="D"||i>=1440)return Math.floor(t/864e5)*864e5;const r=i*6e4,n=Math.floor(t/864e5)*864e5,s=t-n,a=Math.floor(s/r)*r;return n+a}function Rc(t){if(t==="D")return 1440;if(t==="W")return 10080;if(t==="M")return 43200;const e=parseInt(t,10);return isNaN(e)?1440:e}function Rt(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"||i==="Etc/UTC"){const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const n=r[1]==="+"?1:-1,s=parseInt(r[2],10),a=parseInt(r[3]||"0",10),o=n*(s*60+a)*60*1e3,l=new Date(t+o);return{year:l.getUTCFullYear(),month:l.getUTCMonth()+1,day:l.getUTCDate(),hour:l.getUTCHours(),minute:l.getUTCMinutes(),second:l.getUTCSeconds(),dayOfWeek:l.getUTCDay()}}try{const n=new Intl.DateTimeFormat("en-US",{timeZone:e,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",weekday:"short",hour12:!1}).formatToParts(new Date(t)),s=c=>parseInt(n.find(u=>u.type===c)?.value||"0",10);let a=s("hour");a===24&&(a=0);const o=n.find(c=>c.type==="weekday")?.value||"Sun",l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return{year:s("year"),month:s("month"),day:s("day"),hour:a,minute:s("minute"),second:s("second"),dayOfWeek:l[o]??0}}catch{const n=new Date(t);return{year:n.getUTCFullYear(),month:n.getUTCMonth()+1,day:n.getUTCDate(),hour:n.getUTCHours(),minute:n.getUTCMinutes(),second:n.getUTCSeconds(),dayOfWeek:n.getUTCDay()}}}function Oc(t,e,i){const r=new Date(Date.UTC(t,e-1,i)),n=r.getUTCDay()||7;r.setUTCDate(r.getUTCDate()+4-n);const s=new Date(Date.UTC(r.getUTCFullYear(),0,1));return Math.ceil(((r.getTime()-s.getTime())/864e5+1)/7)}const $c=[["timeframe"],["timeframe","bars_back"],["timeframe","session","bars_back"],["timeframe","session","bars_back","timeframe_bars_back"],["timeframe","session","timezone","bars_back","timeframe_bars_back"]],Vc={timeframe:"string",session:"string",timezone:"string",bars_back:"number",timeframe_bars_back:"number"};class ln{constructor(e,i="openTime"){Fi(this,"context"),Fi(this,"dataField"),this.context=e,this.dataField=i}get __value(){return this.context.data[this.dataField]}param(e,i=0){return y.from(e).get(i)}any(...e){const i=e.map(h=>h instanceof y?h.get(0):h),r=te(i,$c,Vc),n=r.bars_back??0,s=r.timeframe||"",a=this.context.data[this.dataField],o=y.from(a).get(n);if(isNaN(o)||o==null)return NaN;const l=this.context.timeframe||"",c=vr(s),u=vr(l);let p;if(!c||c===u?p=o:p=wr(o,c),r.session!==void 0&&r.session!==""){const h=r.timezone||this.context.pine?.syminfo?.timezone||"UTC";return this._isInSession(p,r.session,h)?p:NaN}return p}_isInSession(e,i,r){const n=i.match(/^(\d{2})(\d{2})-(\d{2})(\d{2})$/);if(!n)return!0;const s=parseInt(n[1],10),a=parseInt(n[2],10),o=parseInt(n[3],10),l=parseInt(n[4],10),c=Rt(e,r),u=c.hour,p=c.minute,h=u*60+p,f=s*60+a,d=o*60+l;return f<=d?h>=f&&h<d:h>=f||h<d}}const jc=[[],["time"],["time","timezone"]],Lc={time:"number",timezone:"string"};class vt{constructor(e,i){Fi(this,"context"),Fi(this,"extractor"),this.context=e,this.extractor=i}get __value(){const e=y.from(this.context.data.openTime).get(0);if(isNaN(e))return NaN;const i=this.context.pine?.syminfo?.timezone||"UTC",r=Rt(e,i);return this.extractor(r)}param(e,i=0){return y.from(e).get(i)}any(...e){const i=e.map(o=>o instanceof y?o.get(0):o);if(i.length===0)return this.__value;const r=te(i,jc,Lc),n=r.time;if(n===void 0||isNaN(n))return NaN;const s=r.timezone||this.context.pine?.syminfo?.timezone||"UTC",a=Rt(n,s);return this.extractor(a)}}const wt={dayofmonth:t=>t.day,dayofweek:t=>t.dayOfWeek===0?1:t.dayOfWeek+1,hour:t=>t.hour,minute:t=>t.minute,month:t=>t.month,second:t=>t.second,weekofyear:t=>Oc(t.year,t.month,t.day),year:t=>t.year},Bc=[["defval","title","tooltip","inline","group","display"],["defval","title","tooltip","group","confirm","display"],["defval","title","tooltip","inline","group","confirm","display"],["defval","title","options","tooltip","inline","group","confirm","display"],["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display"]],Fc={defval:"primitive",title:"string",tooltip:"string",inline:"string",group:"string",display:"string",confirm:"boolean",options:"array",minval:"number",maxval:"number",step:"number"};function $e(t){return te(t,Bc,Fc)}function Be(t,e){return e.title&&t.inputs&&t.inputs[e.title]!==void 0?t.inputs[e.title]:e.defval}function Wc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Uc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function qc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function zc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Kc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Hc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Gc(t){return(e,i=0)=>y.from(e).get(i)}function Yc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Xc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Zc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Qc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function Jc(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function eu(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function tu(t){return(...e)=>{const i=$e(e);return Be(t,i)}}function iu(t){return(...e)=>$e(e).defval}var ru=Object.defineProperty,nu=(t,e,i)=>e in t?ru(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ne=(t,e,i)=>nu(t,typeof e!="symbol"?e+"":e,i);const su={any:Wc,bool:Uc,color:qc,enum:zc,float:Kc,int:Hc,param:Gc,price:Yc,session:Xc,source:Zc,string:Qc,symbol:Jc,text_area:eu,time:tu,timeframe:iu};class au{constructor(e){this.context=e,Ne(this,"any"),Ne(this,"bool"),Ne(this,"color"),Ne(this,"enum"),Ne(this,"float"),Ne(this,"int"),Ne(this,"param"),Ne(this,"price"),Ne(this,"session"),Ne(this,"source"),Ne(this,"string"),Ne(this,"symbol"),Ne(this,"text_area"),Ne(this,"time"),Ne(this,"timeframe"),Object.entries(su).forEach(([i,r])=>{this[i]=r(e)})}}function ou(t){return e=>Math.abs(y.from(e).get(0))}function lu(t){return e=>Math.acos(y.from(e).get(0))}function cu(t){return e=>Math.asin(y.from(e).get(0))}function uu(t){return e=>Math.atan(y.from(e).get(0))}function hu(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return i.reduce((r,n)=>r+n,0)/i.length}}function pu(t){return e=>Math.ceil(y.from(e).get(0))}function fu(t){return e=>Math.cos(y.from(e).get(0))}function du(t){return()=>Math.E}function mu(t){return e=>Math.exp(y.from(e).get(0))}function yu(t){return e=>Math.floor(y.from(e).get(0))}function _u(t){return e=>Math.log(y.from(e).get(0))}function gu(t){return e=>Math.log(y.from(e).get(0))}function xu(t){return e=>Math.log10(y.from(e).get(0))}function bu(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return Math.max(...i)}}function vu(t){return(...e)=>{const i=e.map(r=>y.from(r).get(0));return Math.min(...i)}}function wu(t){return(e,i,r)=>typeof e=="string"?e:e instanceof y?i?new y(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new y(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new y(t.params[r],i||0)))}function Su(t){return()=>1.618033988749895}function Eu(t){return()=>Math.PI}function Nu(t){return(e,i)=>Math.pow(y.from(e).get(0),y.from(i).get(0))}function Cu(t){return()=>Math.random()}function ur(t){return t!==t?NaN:Math.sign(t)*Math.round(Math.abs(t))}function Iu(t){return(e,i)=>{const r=y.from(e).get(0);if(i==null)return ur(r);const n=y.from(i).get(0);if(n===0)return ur(r);const s=Math.pow(10,n);return ur(r*s)/s}}function ku(t){return e=>t.precision(Math.round(y.from(e).get(0)/t.pine.syminfo.mintick)*t.pine.syminfo.mintick)}function Tu(t){return()=>.6180339887498948}function Au(t){return e=>Math.sign(y.from(e).get(0))}function Pu(t){return e=>Math.sin(y.from(e).get(0))}function Du(t){return e=>Math.sqrt(y.from(e).get(0))}function Mu(t){return(e,i)=>{const r=y.from(i).get(0),n=y.from(e);let s=0;for(let a=0;a<r;a++){const o=n.get(a);s+=o}return s}}function Ru(t){return e=>Math.tan(y.from(e).get(0))}function Ou(t){return e=>{const i=y.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(180/Math.PI)}}function $u(t){return e=>{const i=y.from(e).get(0);return i==null||Number.isNaN(i)?NaN:i*(Math.PI/180)}}function Vu(t){return(e,i)=>{const r=y.from(e).get(0),n=y.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)<1e-9:r===n}}function ju(t){return(e,i)=>{const r=y.from(e).get(0),n=y.from(i).get(0);return typeof r=="number"&&typeof n=="number"?isNaN(r)||isNaN(n)?!1:Math.abs(r-n)>=1e-9:r!==n}}var Lu=Object.defineProperty,Bu=(t,e,i)=>e in t?Lu(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,G=(t,e,i)=>Bu(t,typeof e!="symbol"?e+"":e,i);const Fu={abs:ou,acos:lu,asin:cu,atan:uu,avg:hu,ceil:pu,cos:fu,e:du,exp:mu,floor:yu,ln:_u,log:gu,log10:xu,max:bu,min:vu,param:wu,phi:Su,pi:Eu,pow:Nu,random:Cu,round:Iu,round_to_mintick:ku,rphi:Tu,sign:Au,sin:Pu,sqrt:Du,sum:Mu,tan:Ru,todegrees:Ou,toradians:$u,__eq:Vu,__neq:ju};class Wu{constructor(e){this.context=e,G(this,"_cache",{}),G(this,"abs"),G(this,"acos"),G(this,"asin"),G(this,"atan"),G(this,"avg"),G(this,"ceil"),G(this,"cos"),G(this,"e"),G(this,"exp"),G(this,"floor"),G(this,"ln"),G(this,"log"),G(this,"log10"),G(this,"max"),G(this,"min"),G(this,"param"),G(this,"phi"),G(this,"pi"),G(this,"pow"),G(this,"random"),G(this,"round"),G(this,"round_to_mintick"),G(this,"rphi"),G(this,"sign"),G(this,"sin"),G(this,"sqrt"),G(this,"sum"),G(this,"tan"),G(this,"todegrees"),G(this,"toradians"),G(this,"__eq"),G(this,"__neq"),Object.entries(Fu).forEach(([i,r])=>{this[i]=r(e)})}}function Uu(t){return(e,i,r)=>{t.params[r]||(t.params[r]=[]);let n;if(e instanceof y)n=e.get(i||0);else if(Array.isArray(e)){const s=e.some(o=>o instanceof y),a=e.every(o=>!(o instanceof y)&&!Array.isArray(o));(s||a)&&e.length>=1?n=e.map(o=>o instanceof y?o.get(0):o):n=y.from(e).get(i||0)}else n=e;return t.params[r].length===0?t.params[r].push(n):t.params[r][t.params[r].length-1]=n,t._requestParamSources||(t._requestParamSources={}),t._requestParamSources[r]=e,[n,r]}}const ii=["1","3","5","15","30","45","60","120","180","240","D","W","M"],Ci={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function Wi(t){if(ii.includes(t))return t;if(Ci[t])return Ci[t];const e=t.toLowerCase();if(Ci[e])return Ci[e];const i=t.toUpperCase();return ii.includes(i)?i:t}function cn(t,e,i,r,n=!1,s=!1){for(let a=0;a<i.length;a++)if(i[a]<=t&&t<r[a])return n||s||e>=r[a]?a:a-1;return-1}function un(t,e,i,r,n=!1,s,a=!1){for(let o=i.length-1;o>=0;o--){if(r[o]<=e&&i[o]>=t){const l=s&&e>s;if(a&&n)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}if(l&&n&&!a)for(let c=0;c<i.length;c++){if(i[c]>=t&&i[c]<e)return c;if(i[c]>=e)break}return o}if(r[o]<t)break}return-1}const hn=[["symbol","timeframe","expression"],["symbol","timeframe","expression","gaps"],["symbol","timeframe","expression","gaps","lookahead"],["symbol","timeframe","expression","gaps","lookahead","ignore_invalid_symbol"],["symbol","timeframe","expression","gaps","lookahead","ignore_invalid_symbol","currency"],["symbol","timeframe","expression","gaps","lookahead","ignore_invalid_symbol","currency","calc_bars_count"]],qu={symbol:"series",timeframe:"series",expression:"any",gaps:"series",lookahead:"series",ignore_invalid_symbol:"series",currency:"series",calc_bars_count:"series"};function Lr(t){return Array.isArray(t)&&t.length===2&&typeof t[1]=="string"}function zu(t,e){return t.map(i=>Lr(i)?(e.push(i[1]),i[0]):(e.push(void 0),i))}function Kt(t){return Lr(t)?t[0]:t}function Ku(t,e,i,r){const n=e[e.length-1].indexOf(t);if(n>=0&&n<i.length&&i[n]!==void 0)return i[n];if(Lr(r))return r[1]}function Sr(t){return t==null||typeof t!="object"?t:"__value"in t?t.__value:t instanceof y?t.get(0):Array.isArray(t)?t.map(Sr):t}function Hu(t){return async(...e)=>{const i=[],r=zu(e,i),n=te(r,hn,qu),s=Kt(n.symbol),a=Kt(n.timeframe),o=Kt(n.expression),l=Kt(n.gaps),c=Kt(n.lookahead),u=s instanceof y?s.get(0):s,p=u===""?t.tickerId:u,h=typeof p=="string"&&p.includes(":")?p.split(":")[1]:p,f=a instanceof y?a.get(0):a,d=f===""?t.timeframe:typeof f=="string"?f:String(f??""),m=o,x=Ku("expression",hn,i,n.expression),b=l,v=c,w=b===!0||b==="gaps_on",S=v===!0||v==="lookahead_on",T=(()=>{const _e=Kt(n.calc_bars_count);return typeof _e=="number"&&_e>0?_e:void 0})();if(t.isSecondaryContext){const _e=Sr(m);return Array.isArray(_e)?[_e]:_e}const N=ii.indexOf(Wi(t.timeframe)),R=ii.indexOf(Wi(d));if(N==-1||R==-1)throw new Error("Invalid timeframe");const $=typeof t.tickerId=="string"&&t.tickerId.includes(":")?t.tickerId.split(":")[1]:t.tickerId;if(N===R&&(!h||h===""||h===$)){const _e=Sr(m);return Array.isArray(_e)?[_e]:_e}const k=N>R,A=y.from(t.data.openTime).get(0),V=y.from(t.data.closeTime).get(0),z=t.idx===t.length-1&&V>Date.now(),O=`${h}_${d}_${x}`,q=`${O}_prevIdx`;if(t.cache[O]){const _e=t.cache[O];t.dataVersion>_e.dataVersion&&(await _e.pineTS.updateTail(_e.context),_e.dataVersion=t.dataVersion);const ai=_e.context,Ni=k?un(A,V,ai.data.openTime.data,ai.data.closeTime.data,S,t.eDate,w):cn(A,V,ai.data.openTime.data,ai.data.closeTime.data,S,z);if(Ni==-1)return NaN;const Wt=ai.params[x][Ni];if(!k&&w){const an=t.cache[q];return an!==void 0&&an===Ni?NaN:(t.cache[q]=Ni,Array.isArray(Wt)?[Wt]:Wt)}return Array.isArray(Wt)?[Wt]:Wt}const Ae=1e3*60*60*24*30,fe=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),Fe=T?void 0:fe?fe-Ae:void 0,Ee=(t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0)||t.eDate||Date.now(),pt=new nn(t.source,h,d,T,Fe,Ee);pt.markAsSecondary();const Bt=typeof x=="string"?x:"",Fa=Bt.match(/p\d+$/)?.[0]??Bt,sn=t._ltfTruncatedBodies?.[Fa],Ft=sn?await pt.runPretranspiled(sn):await pt.run(t.pineTSCode);t.cache[O]={pineTS:pt,context:Ft,dataVersion:t.dataVersion};const or=k?un(A,V,Ft.data.openTime.data,Ft.data.closeTime.data,S,t.eDate,w):cn(A,V,Ft.data.openTime.data,Ft.data.closeTime.data,S,z);if(or==-1)return NaN;const lr=Ft.params[x][or];return!k&&w?(t.cache[q]=or,NaN):Array.isArray(lr)?[lr]:lr}}const pn=[["symbol","timeframe","expression"],["symbol","timeframe","expression","ignore_invalid_symbol"],["symbol","timeframe","expression","ignore_invalid_symbol","currency"],["symbol","timeframe","expression","ignore_invalid_symbol","currency","ignore_invalid_timeframe"],["symbol","timeframe","expression","ignore_invalid_symbol","currency","ignore_invalid_timeframe","calc_bars_count"]],Gu={symbol:"series",timeframe:"series",expression:"any",ignore_invalid_symbol:"series",currency:"series",ignore_invalid_timeframe:"series",calc_bars_count:"series"};function Br(t){return Array.isArray(t)&&t.length===2&&typeof t[1]=="string"}function Yu(t,e){return t.map(i=>Br(i)?(e.push(i[1]),i[0]):(e.push(void 0),i))}function Ht(t){return Br(t)?t[0]:t}function Xu(t,e,i,r){const n=e[e.length-1].indexOf(t);if(n>=0&&n<i.length&&i[n]!==void 0)return i[n];if(Br(r))return r[1]}function Gt(t){return typeof t=="number"?L.float:typeof t=="boolean"?L.bool:typeof t=="string"?L.string:L.any}const Ts={open:t=>t.open,high:t=>t.high,low:t=>t.low,close:t=>t.close,volume:t=>t.volume,hl2:t=>(t.high+t.low)/2,hlc3:t=>(t.high+t.low+t.close)/3,ohlc4:t=>(t.high+t.low+t.open+t.close)/4,hlcc4:t=>(t.high+t.low+t.close+t.close)/4,time:t=>t.openTime,openTime:t=>t.openTime,closeTime:t=>t.closeTime};function Er(t,e){if(!(t instanceof y))return null;const i=e?.data;if(!i)return null;for(const r of Object.keys(Ts))if(t===i[r])return r;return null}function Zu(t,e){if(t instanceof y&&(t=t.get(0)),!(t instanceof It))return null;const i=t._udt;if(!i||!i._fieldDefaults||!Array.isArray(i._definitionKeys))return null;const r=i._definitionKeys;if(r.length===0)return null;const n=[];for(const s of r){if(!(s in i._fieldDefaults))return null;const a=i._fieldDefaults[s],o=Er(a,e);if(o===null)return null;n.push(o)}return{kind:"udt",builtinNames:n,fieldNames:r,udt:i}}function Qu(t,e){if(t===void 0)return null;if(Array.isArray(t)){const r=[];for(const n of t){const s=Er(n,e);if(s===null)return null;r.push(s)}return r.length>0?{kind:"tuple",builtinNames:r}:null}const i=Er(t,e);return i!==null?{kind:"series",builtinNames:[i]}:Zu(t,e)}async function fn(t,e,i,r,n,s){const a=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),o=(t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0)||t.eDate||Date.now(),l=new nn(t.source,e,i,r,a,o);l.markAsSecondary(),await l.ready();const c=l.openTime,u=l.closeTime,p=l.data,h=n.builtinNames.map(d=>Ts[d]);let f;if(n.kind==="series")f=p.map(d=>h[0](d));else if(n.kind==="tuple")f=p.map(d=>h.map(m=>m(d)));else{const d=n.fieldNames,m=n.udt;f=p.map(x=>{const b={};for(let v=0;v<d.length;v++)b[d[v]]=h[v](x);return new It(b,t,m)})}return{data:{openTime:{data:c},closeTime:{data:u}},params:{[s]:f}}}function Ju(t){return async(...e)=>{const i=[],r=Yu(e,i),n=te(r,pn,Gu),s=Ht(n.symbol),a=Ht(n.timeframe),o=Ht(n.expression),l=s instanceof y?s.get(0):s,c=l===""?t.tickerId:l,u=typeof c=="string"&&c.includes(":")?c.split(":")[1]:c,p=a instanceof y?a.get(0):a,h=p===""?t.timeframe:typeof p=="string"?p:String(p??""),f=o,d=Xu("expression",pn,i,n.expression);Ht(n.ignore_invalid_symbol);const m=Ht(n.ignore_invalid_timeframe),x=(()=>{const q=Ht(n.calc_bars_count);return typeof q=="number"&&q>0?q:void 0})();if(t.isSecondaryContext)return Array.isArray(f)?[f.map(q=>new F([q],Gt(q),t))]:new F([f],Gt(f),t);const b=ii.indexOf(Wi(t.timeframe)),v=ii.indexOf(Wi(h));if(b===-1||v===-1){if(m)return NaN;throw new Error("Invalid timeframe")}if(v>b){if(m)return NaN;throw new Error(`Timeframe ${h} is not lower than or equal to chart timeframe ${t.timeframe}`)}if(v===b)return Array.isArray(f)?[f.map(q=>new F([q],Gt(q),t))]:new F([f],Gt(f),t);const w=`${u}_${h}_${d}_lower`,S=t._requestParamSources?.[d],T=Qu(S,t);if(!t.cache[w])if(T!==null){const q=await fn(t,u,h,x,T,d);t.cache[w]={pineTS:null,context:q,dataVersion:t.dataVersion,_fastPath:!0,_fastPathArgs:{builtinExpr:T}}}else{const q=t.sDate||(t.marketData?.length>0?t.marketData[0].openTime:void 0),Ae=(t.marketData?.length>0?t.marketData[t.marketData.length-1].closeTime:0)||t.eDate||Date.now(),fe=new nn(t.source,u,h,x,q,Ae);fe.markAsSecondary();const Fe=typeof d=="string"?d:"",Ee=Fe.match(/p\d+$/)?.[0]??Fe,pt=t._ltfTruncatedBodies?.[Ee];let Bt;pt?Bt=await fe.runPretranspiled(pt):Bt=await fe.run(t.pineTSCode),t.cache[w]={pineTS:fe,context:Bt,dataVersion:t.dataVersion}}const N=t.cache[w];if(t.dataVersion>N.dataVersion)if(N._fastPath){const q=await fn(t,u,h,x,N._fastPathArgs.builtinExpr,d);N.context=q,N.dataVersion=t.dataVersion}else await N.pineTS.updateTail(N.context),N.dataVersion=t.dataVersion;const R=N.context,$=y.from(t.data.openTime).get(0),k=y.from(t.data.closeTime).get(0),A=R.data.openTime.data,V=R.data.closeTime.data,z=R.params[d];if(!z)return Array.isArray(f)?[f.map(()=>new F([],L.float,t))]:new F([],L.float,t);const O=[];for(let q=0;q<A.length;q++){const Ae=A[q];if(!(V[q]<=$)){if(Ae>=k)break;Ae>=$&&Ae<k&&O.push(z[q])}}if(O.length>0&&Array.isArray(O[0])){const q=O[0].length,Ae=[];for(let fe=0;fe<q;fe++){const Fe=O.map(pt=>pt[fe]),Ee=Fe.length>0?Gt(Fe[0]):L.float;Ae.push(new F(Fe,Ee,t))}return[Ae]}else{const q=O.length>0?Gt(O[0]):L.float;return new F(O,q,t)}}}var eh=Object.defineProperty,th=(t,e,i)=>e in t?eh(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Ii=(t,e,i)=>th(t,typeof e!="symbol"?e+"":e,i);const ih={param:Uu,security:Hu,security_lower_tf:Ju};class rh{constructor(e){this.context=e,Ii(this,"_cache",{}),Ii(this,"param"),Ii(this,"security"),Ii(this,"security_lower_tf"),Object.entries(ih).forEach(([i,r])=>{this[i]=r(e)})}}function nh(t){return e=>{t.taState||(t.taState={});const i=e||"accdist";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.high,0),a=t.get(t.data.low,0),o=t.get(t.data.volume,0);if(isNaN(n)||isNaN(s)||isNaN(a)||isNaN(o))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);const l=s-a;let c=0;l!==0&&(c=(n-a-(s-n))/l*o);const u=r.prevCumulativeSum+c;return r.currentCumulativeSum=u,t.precision(u)}}function sh(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0),l=y.from(n).get(0);t.taState||(t.taState={});const c=s||`alma_${a}_${o}_${l}`;if(!t.taState[c]){const m=o*(a-1),x=a/l,b=[];let v=0;for(let w=0;w<a;w++){const S=Math.exp(-Math.pow(w-m,2)/(2*x*x));b.push(S),v+=S}for(let w=0;w<b.length;w++)b[w]/=v;t.taState[c]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0,weights:b}}const u=t.taState[c];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.prevWindow=[...u.currentWindow],u.prevCallCount=u.currentCallCount),u.lastIdx=t.idx);const p=y.from(e).get(0),h=[...u.prevWindow];for(h.unshift(p);h.length>a;)h.pop();const f=u.prevCallCount+1;if(h.length<a&&(f>=a||t.idx>=a-1)){const m=y.from(e);for(;h.length<a;)h.push(m.get(h.length))}if(u.currentWindow=h,u.currentCallCount=f,h.length<a)return NaN;let d=0;for(let m=0;m<a;m++)d+=u.weights[m]*h[a-1-m];return t.precision(d)}}function ah(t){return(e,i)=>{const r=y.from(e).get(0);t.taState||(t.taState={});const n=i||`atr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevAtr:null,prevInitSum:0,prevInitCount:0,currentAtr:null,currentInitSum:0,currentInitCount:0});const s=t.taState[n];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevAtr=s.currentAtr,s.prevInitSum=s.currentInitSum,s.prevInitCount=s.currentInitCount),s.lastIdx=t.idx);const a=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(a)||isNaN(o)||isNaN(l))return NaN;const c=t.idx>0?t.get(t.data.close,1):null;let u;if(c!==null&&!isNaN(c)){const m=a-o,x=Math.abs(a-c),b=Math.abs(o-c);u=Math.max(m,x,b)}else u=a-o;let p=s.prevInitCount,h=s.prevInitSum,f=s.prevAtr;if(p<r){if(h+=u,p++,s.currentInitSum=h,s.currentInitCount=p,p===r){const m=h/r;return s.currentAtr=m,t.precision(m)}return NaN}const d=(f*(r-1)+u)/r;return s.currentAtr=d,t.precision(d)}}function oh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"barssince";t.taState[r]||(t.taState[r]={lastIdx:-1,prevLastTrueIndex:null,currentLastTrueIndex:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevLastTrueIndex=n.currentLastTrueIndex),n.lastIdx=t.idx);const s=y.from(e).get(0);let a=n.prevLastTrueIndex;return s&&(a=t.idx),n.currentLastTrueIndex=a,a===null?NaN:t.idx-a}}function lh(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`bb_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,[[NaN,NaN,NaN]];const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>s;){const b=u.pop();p-=b}if(u.length<s&&t.idx>=s-1){const b=y.from(e);for(;u.length<s;){const v=b.get(u.length);if(isNaN(v))break;u.push(v),p+=v}}if(l.currentWindow=u,l.currentSum=p,u.length<s)return[[NaN,NaN,NaN]];const h=p/s;let f=0;for(let b=0;b<s;b++)f+=Math.pow(u[b]-h,2);const d=Math.sqrt(f/s),m=h+a*d,x=h-a*d;return[[t.precision(h),t.precision(m),t.precision(x)]]}}function ch(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`bbw_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,currentWindow:[],currentSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return l.currentWindow=[...l.prevWindow],l.currentSum=l.prevSum,NaN;const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>s;){const v=u.pop();p-=v}if(u.length<s&&t.idx>=s-1){const v=y.from(e);for(;u.length<s;){const w=v.get(u.length);if(isNaN(w))break;u.push(w),p+=w}}if(l.currentWindow=u,l.currentSum=p,u.length<s)return NaN;const h=p/s;let f=0;for(let v=0;v<s;v++){const w=u[v]-h;f+=w*w}const d=f/s,m=Math.sqrt(d),x=a*m;if(h===0)return t.precision(0);const b=2*x/h*100;return t.precision(b)}}function uh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`cci_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevSum=a.currentSum,a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0);if(isNaN(o))return NaN;const l=[...a.prevWindow];let c=a.prevSum;for(l.unshift(o),c+=o;l.length>n;){const m=l.pop();c-=m}const u=a.prevCallCount+1;if(l.length<n&&(u>=n||t.idx>=n-1)){const m=y.from(e);for(;l.length<n;){const x=m.get(l.length);if(isNaN(x))break;l.push(x),c+=x}}if(a.currentWindow=l,a.currentSum=c,a.currentCallCount=u,l.length<n)return NaN;const p=c/n;let h=0;for(let m=0;m<n;m++)h+=Math.abs(l[m]-p);const f=h/n;if(f===0)return 0;const d=(o-p)/(.015*f);return t.precision(d)}}function hh(t){return(e,i=1,r)=>{typeof i=="string"&&(r=i,i=1);const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`change_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=a.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const p=y.from(e);for(;l.length<n+1;)l.push(p.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<=n)return NaN;const u=o-l[n];return t.precision(u)}}function ph(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`cmo_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevGainsWindow:[],prevLossesWindow:[],prevGainsSum:0,prevLossesSum:0,currentGainsWindow:[],currentLossesWindow:[],currentGainsSum:0,currentLossesSum:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevGainsWindow=[...a.currentGainsWindow],a.prevLossesWindow=[...a.currentLossesWindow],a.prevGainsSum=a.currentGainsSum,a.prevLossesSum=a.currentLossesSum),a.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(e).get(1);if(isNaN(o)||isNaN(l))return NaN;const c=o-l,u=c>=0?c:0,p=c>=0?0:-c,h=[...a.prevGainsWindow],f=[...a.prevLossesWindow];let d=a.prevGainsSum,m=a.prevLossesSum;if(h.unshift(u),f.unshift(p),d+=u,m+=p,h.length<n)return a.currentGainsWindow=h,a.currentLossesWindow=f,a.currentGainsSum=d,a.currentLossesSum=m,NaN;if(h.length>n){const v=h.pop(),w=f.pop();d-=v,m-=w}a.currentGainsWindow=h,a.currentLossesWindow=f,a.currentGainsSum=d,a.currentLossesSum=m;const x=d+m;if(x===0)return t.precision(0);const b=100*(d-m)/x;return t.precision(b)}}function fh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);let a=0,o=!1;for(let u=0;u<n;u++){const p=s.get(u);if(isNaN(p)){o=!0;break}a+=p}if(o)return NaN;let l=0;for(let u=0;u<n;u++){const p=s.get(u);l+=p*(u+1)}if(a===0)return NaN;const c=-l/a;return t.precision(c)}}function dh(t){return(e,i,r,n)=>{const s=y.from(r).get(0),a=y.from(e),o=y.from(i);if(t.idx<s-1)return NaN;let l=0,c=0,u=0,p=0,h=0,f=0;for(let v=0;v<s;v++){const w=a.get(v),S=o.get(v);isNaN(w)||isNaN(S)||(l+=w,c+=S,u+=w*S,p+=w*w,h+=S*S,f++)}if(f<2)return NaN;const d=f*u-l*c,m=f*p-l*l,x=f*h-c*c;if(m<=0||x<=0)return t.precision(0);const b=d/Math.sqrt(m*x);return t.precision(b)}}function mh(t){return(e,i,r)=>{const n=y.from(e),s=y.from(i),a=n.get(0),o=s.get(0),l=n.get(1),c=s.get(1);if(isNaN(a)||isNaN(o)||isNaN(l)||isNaN(c))return!1;const u=a>o&&l<=c,p=a<o&&l>=c;return u||p}}function yh(t){return(e,i)=>{const r=y.from(e),n=y.from(i),s=r.get(0),a=n.get(0),o=r.get(1),l=n.get(1);return o<=l&&s>a}}function _h(t){return(e,i)=>{const r=y.from(e),n=y.from(i),s=r.get(0),a=n.get(0),o=r.get(1),l=n.get(1);return o>=l&&s<a}}function gh(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"cum";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativeSum=n.currentCumulativeSum),n.lastIdx=t.idx);const s=y.from(e).get(0);if(isNaN(s))return n.currentCumulativeSum=n.prevCumulativeSum,t.precision(n.prevCumulativeSum);const a=n.prevCumulativeSum+s;return n.currentCumulativeSum=a,t.precision(a)}}function xh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`dev_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevSum=a.currentSum,a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0)||0,l=[...a.prevWindow];let c=a.prevSum;for(l.unshift(o),c+=o;l.length>n;){const d=l.pop();c-=d}const u=a.prevCallCount+1;if(l.length<n&&(u>=n||t.idx>=n-1)){const d=y.from(e);for(;l.length<n;){const m=d.get(l.length);l.push(m),c+=m}}if(a.currentWindow=l,a.currentSum=c,a.currentCallCount=u,l.length<n)return NaN;const p=c/n;let h=0;for(let d=0;d<n;d++)h+=Math.abs(l[d]-p);const f=h/n;return t.precision(f)}}function bh(t){return(e,i,r)=>{const n=y.from(e).get(0),s=y.from(i).get(0);t.taState||(t.taState={});const a=r||`dmi_${n}_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevTrInitSum:0,prevPlusInitSum:0,prevMinusInitSum:0,prevInitCount:0,prevSmoothedTR:NaN,prevSmoothedPlus:NaN,prevSmoothedMinus:NaN,prevDxInitSum:0,prevAdxInitCount:0,prevADX:NaN,currentTrInitSum:0,currentPlusInitSum:0,currentMinusInitSum:0,currentInitCount:0,currentSmoothedTR:NaN,currentSmoothedPlus:NaN,currentSmoothedMinus:NaN,currentDxInitSum:0,currentAdxInitCount:0,currentADX:NaN});const o=t.taState[a];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrInitSum=o.currentTrInitSum,o.prevPlusInitSum=o.currentPlusInitSum,o.prevMinusInitSum=o.currentMinusInitSum,o.prevInitCount=o.currentInitCount,o.prevSmoothedTR=o.currentSmoothedTR,o.prevSmoothedPlus=o.currentSmoothedPlus,o.prevSmoothedMinus=o.currentSmoothedMinus,o.prevDxInitSum=o.currentDxInitSum,o.prevAdxInitCount=o.currentAdxInitCount,o.prevADX=o.currentADX),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(u))return[[NaN,NaN,NaN]];const p=t.idx>0?t.get(t.data.high,1):NaN,h=t.idx>0?t.get(t.data.low,1):NaN,f=t.idx>0?t.get(t.data.close,1):NaN;if(isNaN(p))return[[NaN,NaN,NaN]];const d=Math.max(l-c,Math.abs(l-f),Math.abs(c-f)),m=l-p,x=h-c,b=m>x&&m>0?m:0,v=x>m&&x>0?x:0;let w=o.prevInitCount,S=o.prevTrInitSum,T=o.prevPlusInitSum,N=o.prevMinusInitSum,R=o.prevSmoothedTR,$=o.prevSmoothedPlus,k=o.prevSmoothedMinus;if(w++,w<=n)S+=d,T+=b,N+=v,w===n&&(R=S/n,$=T/n,k=N/n);else{const Ee=1/n;R=Ee*d+(1-Ee)*R,$=Ee*b+(1-Ee)*$,k=Ee*v+(1-Ee)*k}if(o.currentInitCount=w,o.currentTrInitSum=S,o.currentPlusInitSum=T,o.currentMinusInitSum=N,o.currentSmoothedTR=R,o.currentSmoothedPlus=$,o.currentSmoothedMinus=k,w<n)return[[NaN,NaN,NaN]];const A=R===0?0:100*$/R,V=R===0?0:100*k/R,z=A+V,O=z===0?0:100*Math.abs(A-V)/z;let q=o.prevAdxInitCount,Ae=o.prevDxInitSum,fe=o.prevADX,Fe=NaN;if(q++,q<=s)Ae+=O,q===s&&(fe=Ae/s,Fe=fe);else{const Ee=1/s;fe=Ee*O+(1-Ee)*fe,Fe=fe}return o.currentAdxInitCount=q,o.currentDxInitSum=Ae,o.currentADX=fe,[[t.precision(A),t.precision(V),t.precision(Fe)]]}}function vh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`ema_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevEma:null,prevInitSum:0,prevInitCount:0,currentEma:null,currentInitSum:0,currentInitCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevEma=a.currentEma,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount),a.lastIdx=t.idx);const o=y.from(e).get(0);if(o==null||isNaN(o))return NaN;let l=a.prevInitCount,c=a.prevInitSum,u=a.prevEma;if(l<n){if(c+=o,l++,a.currentInitSum=c,a.currentInitCount=l,l===n){const f=c/n;return a.currentEma=f,t.precision(f)}return NaN}const p=2/(n+1),h=o*p+u*(1-p);return a.currentEma=h,t.precision(h)}}function wh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);for(let a=0;a<n;a++){const o=s.get(a),l=s.get(a+1);if(isNaN(o)||isNaN(l)||o>=l)return!1}return!0}}function Sh(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.high);const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`highest_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const h=y.from(e);for(;l.length<n;)l.push(h.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;const u=l.filter(h=>!isNaN(h)&&h!==void 0);if(u.length===0)return NaN;const p=Math.max(...u);return t.precision(p)}}function Eh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n-1)return NaN;let a=-1/0,o=NaN;for(let l=0;l<n;l++){const c=s.get(l);isNaN(c)||(isNaN(o)||c>a)&&(a=c,o=-l)}return o}}function Nh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=Math.floor(n/2),a=Math.floor(Math.sqrt(n)),o=t.pine.ta.wma,l=o(e,s,r?`${r}_wma1`:void 0),c=o(e,n,r?`${r}_wma2`:void 0);if(isNaN(l)||isNaN(c))return NaN;t.taState||(t.taState={});const u=r||`hma_raw_${n}`;t.taState[u]||(t.taState[u]={lastIdx:-1,prevValues:[],currentValues:[]});const p=t.taState[u];t.idx>p.lastIdx&&(p.lastIdx>=0&&(p.prevValues=[...p.currentValues]),p.lastIdx=t.idx);const h=2*l-c,f=[...p.prevValues];f.unshift(h),f.length>a+1&&f.pop(),p.currentValues=f;const d=r?`${r}_hma_final`:`hma_final_${n}`;t.taState[d]||(t.taState[d]={lastIdx:-1,prevWindow:[],currentWindow:[]});const m=t.taState[d];t.idx>m.lastIdx&&(m.lastIdx>=0&&(m.prevWindow=[...m.currentWindow]),m.lastIdx=t.idx);const x=[...m.prevWindow];if(x.unshift(h),x.length<a)return m.currentWindow=x,NaN;for(;x.length>a;)x.pop();m.currentWindow=x;let b=0,v=0;for(let S=0;S<a;S++){const T=a-S;b+=x[S]*T,v+=T}const w=b/v;return t.precision(w)}}function Ch(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.high,0),n=t.get(t.data.low,0),s=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(s))return NaN;const a=(r-n)*s;if(a===0)return t.precision(0);const o=(2*i-r-n)/a;return t.precision(o)}}function Ih(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0);let l=!0;typeof n=="string"?s=n:n!==void 0&&(l=y.from(n).get(0));let c;const u=t.get(t.data.high,0),p=t.get(t.data.low,0);if(l){const S=t.get(t.data.close,1);isNaN(S)?c=NaN:c=Math.max(u-p,Math.abs(u-S),Math.abs(p-S))}else c=u-p;const h=y.from(e).get(0);t.taState||(t.taState={});const f=s||`kc_${a}_${o}_${l}`;t.taState[f]||(t.taState[f]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const d=t.taState[f];t.idx>d.lastIdx&&(d.lastIdx>=0&&(d.basisState={...d.currentBasisState},d.rangeState={...d.currentRangeState}),d.lastIdx=t.idx);const m=(S,T,N,R)=>{if(isNaN(N))return Object.assign(T,S),T.prevEma!==null?T.prevEma:NaN;let $=S.initCount,k=S.initSum,A=S.prevEma;if($<R){if(k+=N,$++,T.initSum=k,T.initCount=$,T.prevEma=A,$===R){const O=k/R;return T.prevEma=O,O}return NaN}const V=2/(R+1),z=N*V+A*(1-V);return T.prevEma=z,T.initSum=k,T.initCount=$,z},x=m(d.basisState,d.currentBasisState,h,a),b=m(d.rangeState,d.currentRangeState,c,a);if(isNaN(x)||isNaN(b))return[[NaN,NaN,NaN]];const v=x+b*o,w=x-b*o;return[[t.precision(x),t.precision(v),t.precision(w)]]}}function kh(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0);let l=!0;typeof n=="string"?s=n:n!==void 0&&(l=y.from(n).get(0)),t.taState||(t.taState={});const c=s||`kcw_${a}_${o}_${l}`;t.taState[c]||(t.taState[c]={lastIdx:-1,basisState:{prevEma:null,initSum:0,initCount:0},rangeState:{prevEma:null,initSum:0,initCount:0},currentBasisState:{prevEma:null,initSum:0,initCount:0},currentRangeState:{prevEma:null,initSum:0,initCount:0}});const u=t.taState[c];t.idx>u.lastIdx&&(u.lastIdx>=0&&(u.basisState={...u.currentBasisState},u.rangeState={...u.currentRangeState}),u.lastIdx=t.idx);const p=(w,S,T,N)=>{if(isNaN(T))return Object.assign(S,w),S.prevEma!==null?S.prevEma:NaN;let R=w.initCount,$=w.initSum,k=w.prevEma;if(R<N){if($+=T,R++,S.initSum=$,S.initCount=R,S.prevEma=k,R===N){const z=$/N;return S.prevEma=z,z}return NaN}const A=2/(N+1),V=T*A+k*(1-A);return S.prevEma=V,S.initSum=$,S.initCount=R,V};let h;const f=t.get(t.data.high,0),d=t.get(t.data.low,0);if(l){const w=t.get(t.data.close,1);isNaN(w)?h=NaN:h=Math.max(f-d,Math.abs(f-w),Math.abs(d-w))}else h=f-d;const m=y.from(e).get(0),x=p(u.basisState,u.currentBasisState,m,a),b=p(u.rangeState,u.currentRangeState,h,a);if(isNaN(x)||isNaN(b))return NaN;if(x===0)return t.precision(0);const v=2*b*o/x;return t.precision(v)}}function Th(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`linreg_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=y.from(e).get(0),u=[...l.prevWindow];for(u.unshift(c);u.length>s;)u.pop();const p=l.prevCallCount+1;if(u.length<s&&(p>=s||t.idx>=s-1)){const S=y.from(e);for(;u.length<s;)u.push(S.get(u.length))}if(l.currentWindow=u,l.currentCallCount=p,u.length<s)return NaN;let h=0,f=0,d=0,m=0;const x=s;for(let S=0;S<s;S++){const T=s-1-S,N=u[S];h+=T,f+=N,d+=T*N,m+=T*T}const b=x*m-h*h;if(b===0)return NaN;const v=(x*d-h*f)/b,w=(f-v*h)/x+v*(s-1-a);return t.precision(w)}}function Ah(t){return(e,i,r)=>{typeof i=="string"&&r===void 0&&(r=i,i=e,e=t.data.low);const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`lowest_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const h=y.from(e);for(;l.length<n;)l.push(h.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;const u=l.filter(h=>!isNaN(h)&&h!==void 0);if(u.length===0)return NaN;const p=Math.min(...u);return t.precision(p)}}function Ph(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n-1)return NaN;let a=1/0,o=NaN;for(let l=0;l<n;l++){const c=s.get(l);isNaN(c)||(isNaN(o)||c<a)&&(a=c,o=-l)}return o}}function Dh(t){return(e,i,r,n,s)=>{const a=y.from(i).get(0),o=y.from(r).get(0),l=y.from(n).get(0),c=s||`macd_${a}_${o}_${l}`,u=`${c}_fast`,p=`${c}_slow`,h=`${c}_signal`,f=t.pine.ta.ema(e,a,u),d=t.pine.ta.ema(e,o,p);let m=NaN;!isNaN(f)&&!isNaN(d)&&(m=f-d);let x=NaN;isNaN(m)||(x=t.pine.ta.ema(m,l,h));let b=NaN;return!isNaN(m)&&!isNaN(x)&&(b=m-x),[[t.precision(m),t.precision(x),t.precision(b)]]}}function Mh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`median_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=y.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;const u=l.slice().sort((f,d)=>f-d),p=Math.floor(n/2),h=n%2===0?(u[p-1]+u[p])/2:u[p];return t.precision(h)}}function Rh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`mfi_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevUpperWindow:[],prevLowerWindow:[],prevUpperSum:0,prevLowerSum:0,currentUpperWindow:[],currentLowerWindow:[],currentUpperSum:0,currentLowerSum:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevUpperWindow=[...a.currentUpperWindow],a.prevLowerWindow=[...a.currentLowerWindow],a.prevUpperSum=a.currentUpperSum,a.prevLowerSum=a.currentLowerSum),a.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(e).get(1),c=t.get(t.data.volume,0);if(isNaN(o)||isNaN(c))return NaN;const u=isNaN(l)?NaN:o-l,p=c*(u<=0?0:o),h=c*(u>=0?0:o),f=[...a.prevUpperWindow],d=[...a.prevLowerWindow];let m=a.prevUpperSum,x=a.prevLowerSum;if(f.unshift(p),d.unshift(h),m+=p,x+=h,f.length<n)return a.currentUpperWindow=f,a.currentLowerWindow=d,a.currentUpperSum=m,a.currentLowerSum=x,NaN;if(f.length>n){const v=f.pop(),w=d.pop();m-=v,x-=w}if(a.currentUpperWindow=f,a.currentLowerWindow=d,a.currentUpperSum=m,a.currentLowerSum=x,x===0)return t.precision(100);if(m===0)return t.precision(0);const b=100-100/(1+m/x);return t.precision(b)}}function Oh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n-1)return NaN;const a=new Map;for(let c=0;c<n;c++){const u=s.get(c);isNaN(u)||a.set(u,(a.get(u)||0)+1)}if(a.size===0)return NaN;let o=NaN,l=-1;for(const[c,u]of a.entries())u>l?(l=u,o=c):u===l&&c<o&&(o=c);return o}}function $h(t){return(e,i,r)=>{const n=y.from(i).get(0);return t.pine.ta.change(e,n,r)}}function Vh(t){return e=>{t.taState||(t.taState={});const i=e||"nvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedNVI:1,tentativeNVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedNVI=r.tentativeNVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.close,1),a=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(s)?0:s,u=isNaN(a)?0:a,p=isNaN(o)?0:o;let h=r.committedNVI;if(!(l===0||c===0)&&u<p){const f=(l-c)/c;h=h+f*h}return r.tentativeNVI=h,t.precision(h)}}function jh(t){return()=>{t.taState||(t.taState={});const e="obv";t.taState[e]||(t.taState[e]={lastIdx:-1,committedOBV:0,tentativeOBV:0});const i=t.taState[e];t.idx>i.lastIdx&&(i.lastIdx>=0&&(i.committedOBV=i.tentativeOBV),i.lastIdx=t.idx);const r=t.get(t.data.close,0),n=t.get(t.data.volume,0),s=t.get(t.data.close,1);if(isNaN(s))return i.tentativeOBV=0,t.precision(0);let a=i.committedOBV;return r>s?a+=n:r<s&&(a-=n),i.tentativeOBV=a,t.precision(a)}}function Lh(t){return(e,i,r)=>e instanceof y?i?new y(e.data,e.offset+i):e:(t.params[r]||(t.params[r]=[]),Array.isArray(e)?new y(e,i||0):(t.params[r].length===0?t.params[r].push(e):t.params[r][t.params[r].length-1]=e,new y(t.params[r],i||0)))}function Bh(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e);if(t.idx<s-1)return NaN;const l=[];for(let d=0;d<s;d++){const m=o.get(d);if(isNaN(m))return NaN;l.push(m)}l.sort((d,m)=>d-m);let c=a/100*s-.5;c<0&&(c=0),c>s-1&&(c=s-1);const u=Math.floor(c),p=Math.ceil(c);if(u===p)return t.precision(l[u]);const h=c-u,f=l[u]+h*(l[p]-l[u]);return t.precision(f)}}function Fh(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e);if(t.idx<s-1)return NaN;const l=[];for(let u=0;u<s;u++){const p=o.get(u);isNaN(p)||l.push(p)}if(l.length===0)return NaN;l.sort((u,p)=>u-p);let c=Math.ceil(a/100*l.length)-1;return c<0&&(c=0),c>=l.length&&(c=l.length-1),t.precision(l[c])}}function Wh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);if(t.idx<n)return NaN;const a=s.get(0);if(isNaN(a))return NaN;let o=0,l=0;for(let c=1;c<=n;c++){const u=s.get(c);isNaN(u)||(l++,u<=a&&o++)}return l===0?NaN:t.precision(o/l*100)}}function Uh(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const s=t[n-i];let a=!0;for(let o=1;o<=e;o++)if(t[n-i-o]>=s){a=!1;break}if(a){for(let o=1;o<=i;o++)if(t[n-i+o]>=s){a=!1;break}}a&&(r[n]=s)}return r}function qh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.high);const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e).toArray(),l=Uh(o,s,a),c=t.idx;return t.precision(l[c])}}function zh(t,e,i){const r=new Array(t.length).fill(NaN);for(let n=e+i;n<t.length;n++){const s=t[n-i];let a=!0;for(let o=1;o<=e;o++)if(t[n-i-o]<=s){a=!1;break}if(a){for(let o=1;o<=i;o++)if(t[n-i+o]<=s){a=!1;break}}a&&(r[n]=s)}return r}function Kh(t){return(e,i,r,n)=>{typeof r=="string"&&(r=i,i=e,e=t.data.low);const s=y.from(i).get(0),a=y.from(r).get(0),o=y.from(e).toArray(),l=zh(o,s,a),c=t.idx;return t.precision(l[c])}}function Hh(t){return e=>{t.taState||(t.taState={});const i=e||"pvi";t.taState[i]||(t.taState[i]={lastIdx:-1,committedPVI:1,tentativePVI:1});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.committedPVI=r.tentativePVI),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.close,1),a=t.get(t.data.volume,0),o=t.get(t.data.volume,1),l=isNaN(n)?0:n,c=isNaN(s)?0:s,u=isNaN(a)?0:a,p=isNaN(o)?0:o;let h=r.committedPVI;if(!(l===0||c===0)&&u>p){const f=(l-c)/c;h=h+f*h}return r.tentativePVI=h,t.precision(h)}}function Gh(t){return e=>{t.taState||(t.taState={});const i=e||"pvt";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.close,1),a=t.get(t.data.volume,0);let o=r.prevCumulativeSum;if(!isNaN(n)&&!isNaN(s)&&!isNaN(a)&&s!==0){const l=(n-s)/s*a;o+=l}return r.currentCumulativeSum=o,t.precision(o)}}function Yh(t){return(e,i,r)=>{const n=t.pine.ta.highest(e,i,(r||"range")+"_h"),s=t.pine.ta.lowest(e,i,(r||"range")+"_l");return isNaN(n)||isNaN(s)?NaN:t.precision(n-s)}}function Xh(t){return(e,i,r)=>{const n=y.from(i).get(0),s=y.from(e);for(let a=0;a<n;a++){const o=s.get(a),l=s.get(a+1);if(isNaN(o)||isNaN(l)||o<=l)return!1}return!0}}function Zh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`rma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevRma:null,prevInitSum:0,prevInitCount:0,currentRma:null,currentInitSum:0,currentInitCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevRma=a.currentRma,a.prevInitSum=a.currentInitSum,a.prevInitCount=a.currentInitCount),a.lastIdx=t.idx);const o=y.from(e).get(0)||0;let l=a.prevInitCount,c=a.prevInitSum,u=a.prevRma;if(l<n){if(c+=o,l++,a.currentInitSum=c,a.currentInitCount=l,l===n){const f=c/n;return a.currentRma=f,t.precision(f)}return NaN}const p=1/n,h=o*p+u*(1-p);return a.currentRma=h,t.precision(h)}}function Qh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`roc_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n+1;)l.pop();const c=a.prevCallCount+1;if(l.length<n+1&&(c>=n+1||t.idx>=n)){const h=y.from(e);for(;l.length<n+1;)l.push(h.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<=n)return NaN;const u=l[n],p=(o-u)/u*100;return t.precision(p)}}function Jh(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`rsi_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevPrevValue:null,prevAvgGain:0,prevAvgLoss:0,prevInitGains:[],prevInitLosses:[],currentPrevValue:null,currentAvgGain:0,currentAvgLoss:0,currentInitGains:[],currentInitLosses:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevPrevValue=a.currentPrevValue,a.prevAvgGain=a.currentAvgGain,a.prevAvgLoss=a.currentAvgLoss,a.prevInitGains=[...a.currentInitGains],a.prevInitLosses=[...a.currentInitLosses]),a.lastIdx=t.idx);const o=y.from(e).get(0);if(o==null||isNaN(o))return NaN;const l=a.prevPrevValue;if(l===null||isNaN(l))return a.currentPrevValue=o,a.currentInitGains=[...a.prevInitGains],a.currentInitLosses=[...a.prevInitLosses],a.currentAvgGain=a.prevAvgGain,a.currentAvgLoss=a.prevAvgLoss,NaN;let c=a.prevAvgGain,u=a.prevAvgLoss;const p=[...a.prevInitGains],h=[...a.prevInitLosses],f=o-l,d=f>0?f:0,m=f<0?-f:0;if(p.length<n){if(p.push(d),h.push(m),a.currentInitGains=p,a.currentInitLosses=h,a.currentPrevValue=o,p.length===n){c=p.reduce((v,w)=>v+w,0)/n,u=h.reduce((v,w)=>v+w,0)/n,a.currentAvgGain=c,a.currentAvgLoss=u;const b=u===0?100:100-100/(1+c/u);return t.precision(b)}return NaN}c=(c*(n-1)+d)/n,u=(u*(n-1)+m)/n,a.currentAvgGain=c,a.currentAvgLoss=u,a.currentPrevValue=o;const x=u===0?100:100-100/(1+c/u);return t.precision(x)}}function ep(t){return(e,i,r,n)=>{const s=y.from(e).get(0),a=y.from(i).get(0),o=y.from(r).get(0);t.taState||(t.taState={});const l=n||`sar_${s}_${a}_${o}`;t.taState[l]||(t.taState[l]={lastIdx:-1,prevResult:NaN,prevMaxMin:NaN,prevAcceleration:NaN,prevIsBelow:!1,prevBarIndex:0,currentResult:NaN,currentMaxMin:NaN,currentAcceleration:NaN,currentIsBelow:!1,currentBarIndex:0});const c=t.taState[l];t.idx>c.lastIdx&&(c.lastIdx>=0&&(c.prevResult=c.currentResult,c.prevMaxMin=c.currentMaxMin,c.prevAcceleration=c.currentAcceleration,c.prevIsBelow=c.currentIsBelow,c.prevBarIndex=c.currentBarIndex),c.lastIdx=t.idx);let u=c.prevResult,p=c.prevMaxMin,h=c.prevAcceleration,f=c.prevIsBelow,d=c.prevBarIndex;const m=t.get(t.data.high,0),x=t.get(t.data.low,0),b=t.get(t.data.close,0),v=t.get(t.data.close,1),w=t.get(t.data.high,1),S=t.get(t.data.low,1),T=t.get(t.data.high,2),N=t.get(t.data.low,2);if(isNaN(m)||isNaN(x)||isNaN(b))return c.currentResult=u,c.currentMaxMin=p,c.currentAcceleration=h,c.currentIsBelow=f,c.currentBarIndex=d,NaN;let R=!1;return d===1&&(b>v?(f=!0,p=m,u=S):(f=!1,p=x,u=w),R=!0,h=s),d>=1&&(u=u+h*(p-u),f?u>x&&(R=!0,f=!1,u=Math.max(m,p),p=x,h=s):u<m&&(R=!0,f=!0,u=Math.min(x,p),p=m,h=s),R||(f?m>p&&(p=m,h=Math.min(h+a,o)):x<p&&(p=x,h=Math.min(h+a,o))),f?(u=Math.min(u,S),d>1&&(u=Math.min(u,N))):(u=Math.max(u,w),d>1&&(u=Math.max(u,T)))),d++,c.currentResult=u,c.currentMaxMin=p,c.currentAcceleration=h,c.currentIsBelow=f,c.currentBarIndex=d,d<=1?NaN:t.precision(u)}}function tp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`sma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevSum=a.currentSum,a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;let u=!1;if(l.length<n&&(c>=n||t.idx>=n-1)){const m=y.from(e);for(;l.length<n;)l.push(m.get(l.length));u=!0}let p;const h=o==null||Number.isNaN(o);let f=!Number.isNaN(a.prevSum)&&!h&&!u;if(f){let m=a.prevSum+o;if(a.prevWindow.length>=n){const x=a.prevWindow[a.prevWindow.length-1];x==null||Number.isNaN(x)?f=!1:m-=x}f&&(p=m)}if(!f){p=0;let m=!1;for(const x of l){if(x==null||Number.isNaN(x)){m=!0;break}p+=x}m&&(p=NaN)}if(a.currentWindow=l,a.currentSum=p,a.currentCallCount=c,l.length<n)return NaN;const d=p/n;return t.precision(d)}}function ip(t){return(e,i,r=!0,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`stdev_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevWindow:[],prevSum:0,prevCallCount:0,currentWindow:[],currentSum:0,currentCallCount:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevWindow=[...l.currentWindow],l.prevSum=l.currentSum,l.prevCallCount=l.currentCallCount),l.lastIdx=t.idx);const c=y.from(e).get(0);if(c==null||isNaN(c))return NaN;const u=[...l.prevWindow];let p=l.prevSum;for(u.unshift(c),p+=c;u.length>s;){const b=u.pop();p-=b}const h=l.prevCallCount+1;if(u.length<s&&(h>=s||t.idx>=s-1)){const b=y.from(e);for(;u.length<s;){const v=b.get(u.length);if(v==null||isNaN(v))break;u.push(v),p+=v}}if(l.currentWindow=u,l.currentSum=p,l.currentCallCount=h,u.length<s)return NaN;const f=p/s;let d=0;for(let b=0;b<s;b++)d+=Math.pow(u[b]-f,2);const m=a?s:s-1,x=Math.sqrt(d/m);return t.precision(x)}}function rp(t){return(e,i,r,n,s)=>{const a=y.from(n).get(0);t.taState||(t.taState={});const o=s||`stoch_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevHighWindow=[...l.currentHighWindow],l.prevLowWindow=[...l.currentLowWindow]),l.lastIdx=t.idx);const c=y.from(e).get(0),u=y.from(i).get(0),p=y.from(r).get(0);if(isNaN(c)||isNaN(u)||isNaN(p))return l.currentHighWindow=[...l.prevHighWindow],l.currentLowWindow=[...l.prevLowWindow],NaN;const h=[...l.prevHighWindow],f=[...l.prevLowWindow];if(h.unshift(u),f.unshift(p),h.length>a&&(h.pop(),f.pop()),l.currentHighWindow=h,l.currentLowWindow=f,h.length<a)return NaN;let d=h[0],m=f[0];for(let v=1;v<a;v++)h[v]>d&&(d=h[v]),f[v]<m&&(m=f[v]);const x=d-m;if(x===0)return NaN;const b=100*(c-m)/x;return t.precision(b)}}function np(t){return(e,i,r)=>{const n=y.from(e).get(0),s=y.from(i).get(0);t.taState||(t.taState={});const a=r||`supertrend_${n}_${s}`;t.taState[a]||(t.taState[a]={lastIdx:-1,prevTrSum:0,prevAtrValue:NaN,prevAtrCount:0,prevLowerBand:NaN,prevUpperBand:NaN,prevSuperTrend:NaN,prevDirection:NaN,currentTrSum:0,currentAtrValue:NaN,currentAtrCount:0,currentLowerBand:NaN,currentUpperBand:NaN,currentSuperTrend:NaN,currentDirection:NaN});const o=t.taState[a];t.idx>o.lastIdx&&(o.lastIdx>=0&&(o.prevTrSum=o.currentTrSum,o.prevAtrValue=o.currentAtrValue,o.prevAtrCount=o.currentAtrCount,o.prevLowerBand=o.currentLowerBand,o.prevUpperBand=o.currentUpperBand,o.prevSuperTrend=o.currentSuperTrend,o.prevDirection=o.currentDirection),o.lastIdx=t.idx);const l=t.get(t.data.high,0),c=t.get(t.data.low,0),u=t.get(t.data.close,0);if(isNaN(l)||isNaN(c)||isNaN(u))return[[NaN,NaN]];const p=(l+c)/2,h=t.idx>0?t.get(t.data.close,1):NaN;let f;isNaN(h)?f=l-c:f=Math.max(l-c,Math.abs(l-h),Math.abs(c-h));let d=o.prevAtrCount,m=o.prevTrSum,x=o.prevAtrValue;d++,d<=s?(m+=f,d===s&&(x=m/s)):x=(x*(s-1)+f)/s;const b=x;if(o.currentAtrCount=d,o.currentTrSum=m,o.currentAtrValue=x,isNaN(b))return[[NaN,NaN]];let v=p+n*b,w=p-n*b;const S=isNaN(o.prevLowerBand)?0:o.prevLowerBand,T=isNaN(o.prevUpperBand)?0:o.prevUpperBand;isNaN(o.prevLowerBand)||w>S||h<S||(w=S),isNaN(o.prevUpperBand)||v<T||h>T||(v=T);let N,R;const $=o.prevSuperTrend;return d===s?N=1:$===o.prevUpperBand?N=u>v?-1:1:N=u<w?1:-1,R=N===-1?w:v,o.currentLowerBand=w,o.currentUpperBand=v,o.currentSuperTrend=R,o.currentDirection=N,[[t.precision(R),N]]}}function sp(t){return(e,i)=>{const r=[1,2,2,1],n=6;t.taState||(t.taState={});const s=i||"swma";t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],currentWindow:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow]),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>4;)l.pop();if(l.length<4&&t.idx>=3){const u=y.from(e);for(;l.length<4;)l.push(u.get(l.length))}if(a.currentWindow=l,l.length<4)return NaN;let c=0;for(let u=0;u<4;u++)c+=r[u]*l[3-u];return c/=n,t.precision(c)}}function ap(t){return(e,i)=>{let r=!0;typeof e=="string"||e!==void 0&&(r=y.from(e).get(0));const n=t.get(t.data.high,0),s=t.get(t.data.low,0),a=t.get(t.data.close,1);if(isNaN(a))return r?t.precision(n-s):NaN;const o=Math.max(n-s,Math.abs(n-a),Math.abs(s-a));return t.precision(o)}}function op(t){return(e,i,r,n)=>{const s=y.from(i).get(0),a=y.from(r).get(0);t.taState||(t.taState={});const o=n||`tsi_${s}_${a}`;t.taState[o]||(t.taState[o]={lastIdx:-1,prevSource:NaN,prevEma1PcValue:NaN,prevEma1PcCount:0,prevEma1PcSum:0,prevEma2PcValue:NaN,prevEma2PcCount:0,prevEma2PcSum:0,prevEma1AbsValue:NaN,prevEma1AbsCount:0,prevEma1AbsSum:0,prevEma2AbsValue:NaN,prevEma2AbsCount:0,prevEma2AbsSum:0,currentSource:NaN,currentEma1PcValue:NaN,currentEma1PcCount:0,currentEma1PcSum:0,currentEma2PcValue:NaN,currentEma2PcCount:0,currentEma2PcSum:0,currentEma1AbsValue:NaN,currentEma1AbsCount:0,currentEma1AbsSum:0,currentEma2AbsValue:NaN,currentEma2AbsCount:0,currentEma2AbsSum:0});const l=t.taState[o];t.idx>l.lastIdx&&(l.lastIdx>=0&&(l.prevSource=l.currentSource,l.prevEma1PcValue=l.currentEma1PcValue,l.prevEma1PcCount=l.currentEma1PcCount,l.prevEma1PcSum=l.currentEma1PcSum,l.prevEma2PcValue=l.currentEma2PcValue,l.prevEma2PcCount=l.currentEma2PcCount,l.prevEma2PcSum=l.currentEma2PcSum,l.prevEma1AbsValue=l.currentEma1AbsValue,l.prevEma1AbsCount=l.currentEma1AbsCount,l.prevEma1AbsSum=l.currentEma1AbsSum,l.prevEma2AbsValue=l.currentEma2AbsValue,l.prevEma2AbsCount=l.currentEma2AbsCount,l.prevEma2AbsSum=l.currentEma2AbsSum),l.lastIdx=t.idx);const c=y.from(e).get(0);if(isNaN(c))return NaN;const u=isNaN(l.prevSource)?NaN:c-l.prevSource;if(l.currentSource=c,isNaN(u))return NaN;const p=Math.abs(u),h=2/(a+1),f=2/(s+1),d=2/(a+1),m=2/(s+1);let x=l.prevEma1PcCount,b=l.prevEma1PcSum,v=l.prevEma1PcValue;x++,x<=a?(b+=u,x===a&&(v=b/a)):v=u*h+v*(1-h);let w=l.prevEma1AbsCount,S=l.prevEma1AbsSum,T=l.prevEma1AbsValue;if(w++,w<=a?(S+=p,w===a&&(T=S/a)):T=p*d+T*(1-d),isNaN(v)||isNaN(T))return l.currentEma1PcCount=x,l.currentEma1PcSum=b,l.currentEma1PcValue=v,l.currentEma1AbsCount=w,l.currentEma1AbsSum=S,l.currentEma1AbsValue=T,NaN;let N=l.prevEma2PcCount,R=l.prevEma2PcSum,$=l.prevEma2PcValue;N++,N<=s?(R+=v,N===s&&($=R/s)):$=v*f+$*(1-f);let k=l.prevEma2AbsCount,A=l.prevEma2AbsSum,V=l.prevEma2AbsValue;if(k++,k<=s?(A+=T,k===s&&(V=A/s)):V=T*m+V*(1-m),l.currentEma1PcCount=x,l.currentEma1PcSum=b,l.currentEma1PcValue=v,l.currentEma1AbsCount=w,l.currentEma1AbsSum=S,l.currentEma1AbsValue=T,l.currentEma2PcCount=N,l.currentEma2PcSum=R,l.currentEma2PcValue=$,l.currentEma2AbsCount=k,l.currentEma2AbsSum=A,l.currentEma2AbsValue=V,isNaN($)||isNaN(V))return NaN;if(V===0)return t.precision(0);const z=$/V;return t.precision(z)}}function lp(t){return(e,i,r,n)=>{t.taState||(t.taState={});const s=n||"valuewhen";t.taState[s]||(t.taState[s]={lastIdx:-1,prevValues:[],currentValues:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevValues=[...a.currentValues]),a.lastIdx=t.idx);const o=y.from(e).get(0),l=y.from(i).get(0),c=y.from(r).get(0),u=[...a.prevValues];if(o&&u.push(l),a.currentValues=u,isNaN(c)||c<0)return NaN;const p=u.length-1-c;if(p<0)return NaN;const h=u[p];return typeof h=="number"?t.precision(h):h}}function cp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`variance_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const d=y.from(e);for(;l.length<n;)l.push(d.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;let u=0,p=0;for(let d=0;d<n;d++)u+=l[d],p+=l[d]*l[d];const h=u/n,f=p/n-h*h;return t.precision(f)}}function up(t){return(e,i)=>{t.taState||(t.taState={});const r=i||"vwap";t.taState[r]||(t.taState[r]={lastIdx:-1,prevCumulativePV:0,prevCumulativeVolume:0,prevLastSessionDate:null,currentCumulativePV:0,currentCumulativeVolume:0,currentLastSessionDate:null});const n=t.taState[r];t.idx>n.lastIdx&&(n.lastIdx>=0&&(n.prevCumulativePV=n.currentCumulativePV,n.prevCumulativeVolume=n.currentCumulativeVolume,n.prevLastSessionDate=n.currentLastSessionDate),n.lastIdx=t.idx);const s=y.from(e).get(0),a=y.from(t.data.volume).get(0),o=y.from(t.data.openTime).get(0),l=t.pine?.syminfo?.timezone||"UTC",c=Rt(o,l),u=`${c.year}-${String(c.month).padStart(2,"0")}-${String(c.day).padStart(2,"0")}`;let p=n.prevCumulativePV,h=n.prevCumulativeVolume,f=n.prevLastSessionDate;if(f!==u&&(p=0,h=0,f=u),p+=s*a,h+=a,n.currentCumulativePV=p,n.currentCumulativeVolume=h,n.currentLastSessionDate=f,h===0)return NaN;const d=p/h;return t.precision(d)}}function hp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`vwma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevVolumeWindow:[],currentWindow:[],currentVolumeWindow:[]});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevVolumeWindow=[...a.currentVolumeWindow]),a.lastIdx=t.idx);const o=y.from(e).get(0),l=t.get(t.data.volume,0),c=[...a.prevWindow],u=[...a.prevVolumeWindow];for(c.unshift(o),u.unshift(l);c.length>n;)c.pop(),u.pop();if(c.length<n&&t.idx>=n-1){const d=y.from(e),m=y.from(t.data.volume);for(;c.length<n;)c.push(d.get(c.length)),u.push(m.get(u.length))}if(a.currentWindow=c,a.currentVolumeWindow=u,c.length<n)return NaN;let p=0,h=0;for(let d=0;d<n;d++)p+=c[d]*u[d],h+=u[d];const f=p/h;return t.precision(f)}}function pp(t){return e=>{t.taState||(t.taState={});const i=e||"wad";t.taState[i]||(t.taState[i]={lastIdx:-1,prevCumulativeSum:0,currentCumulativeSum:0});const r=t.taState[i];t.idx>r.lastIdx&&(r.lastIdx>=0&&(r.prevCumulativeSum=r.currentCumulativeSum),r.lastIdx=t.idx);const n=t.get(t.data.close,0),s=t.get(t.data.high,0),a=t.get(t.data.low,0),o=t.get(t.data.close,1);if(isNaN(n)||isNaN(s)||isNaN(a))return r.currentCumulativeSum=r.prevCumulativeSum,t.precision(r.prevCumulativeSum);let l=0;if(!isNaN(o)){const u=Math.max(s,o),p=Math.min(a,o),h=n-o;h>0?l=n-p:h<0&&(l=n-u)}const c=r.prevCumulativeSum+l;return r.currentCumulativeSum=c,t.precision(c)}}function fp(t){return(e,i,r)=>{const n=y.from(i).get(0);t.taState||(t.taState={});const s=r||`wma_${n}`;t.taState[s]||(t.taState[s]={lastIdx:-1,prevWindow:[],prevCallCount:0,currentWindow:[],currentCallCount:0});const a=t.taState[s];t.idx>a.lastIdx&&(a.lastIdx>=0&&(a.prevWindow=[...a.currentWindow],a.prevCallCount=a.currentCallCount),a.lastIdx=t.idx);const o=y.from(e).get(0),l=[...a.prevWindow];for(l.unshift(o);l.length>n;)l.pop();const c=a.prevCallCount+1;if(l.length<n&&(c>=n||t.idx>=n-1)){const f=y.from(e);for(;l.length<n;)l.push(f.get(l.length))}if(a.currentWindow=l,a.currentCallCount=c,l.length<n)return NaN;let u=0,p=0;for(let f=0;f<n;f++){const d=n-f;u+=l[f]*d,p+=d}const h=u/p;return t.precision(h)}}function dp(t){return(e,i)=>{const r=y.from(e).get(0);t.taState||(t.taState={});const n=i||`wpr_${r}`;t.taState[n]||(t.taState[n]={lastIdx:-1,prevHighWindow:[],prevLowWindow:[],currentHighWindow:[],currentLowWindow:[]});const s=t.taState[n];t.idx>s.lastIdx&&(s.lastIdx>=0&&(s.prevHighWindow=[...s.currentHighWindow],s.prevLowWindow=[...s.currentLowWindow]),s.lastIdx=t.idx);const a=t.get(t.data.high,0),o=t.get(t.data.low,0),l=t.get(t.data.close,0);if(isNaN(a)||isNaN(o)||isNaN(l))return s.currentHighWindow=[...s.prevHighWindow],s.currentLowWindow=[...s.prevLowWindow],NaN;const c=[...s.prevHighWindow],u=[...s.prevLowWindow];if(c.unshift(a),u.unshift(o),c.length>r&&(c.pop(),u.pop()),s.currentHighWindow=c,s.currentLowWindow=u,c.length<r)return NaN;let p=c[0],h=u[0];for(let m=1;m<r;m++)c[m]>p&&(p=c[m]),u[m]<h&&(h=u[m]);const f=p-h;if(f===0)return t.precision(0);const d=(p-l)/f*-100;return t.precision(d)}}function mp(t){return e=>{const i=t.get(t.data.close,0),r=t.get(t.data.open,0),n=t.get(t.data.high,0),s=t.get(t.data.low,0),a=t.get(t.data.volume,0);if(isNaN(i)||isNaN(r)||isNaN(n)||isNaN(s)||isNaN(a))return NaN;const o=n-s;if(o===0)return t.precision(0);const l=(i-r)/o*a;return t.precision(l)}}var yp=Object.defineProperty,_p=(t,e,i)=>e in t?yp(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,P=(t,e,i)=>_p(t,typeof e!="symbol"?e+"":e,i);const gp={accdist:nh,alma:sh,atr:ah,barssince:oh,bb:lh,bbw:ch,cci:uh,change:hh,cmo:ph,cog:fh,correlation:dh,cross:mh,crossover:yh,crossunder:_h,cum:gh,dev:xh,dmi:bh,ema:vh,falling:wh,highest:Sh,highestbars:Eh,hma:Nh,iii:Ch,kc:Ih,kcw:kh,linreg:Th,lowest:Ah,lowestbars:Ph,macd:Dh,median:Mh,mfi:Rh,mode:Oh,mom:$h,nvi:Vh,obv:jh,param:Lh,percentile_linear_interpolation:Bh,percentile_nearest_rank:Fh,percentrank:Wh,pivothigh:qh,pivotlow:Kh,pvi:Hh,pvt:Gh,range:Yh,rising:Xh,rma:Zh,roc:Qh,rsi:Jh,sar:ep,sma:tp,stdev:ip,stoch:rp,supertrend:np,swma:sp,tr:ap,tsi:op,valuewhen:lp,variance:cp,vwap:up,vwma:hp,wad:pp,wma:fp,wpr:dp,wvad:mp};class xp{constructor(e){this.context=e,P(this,"accdist"),P(this,"alma"),P(this,"atr"),P(this,"barssince"),P(this,"bb"),P(this,"bbw"),P(this,"cci"),P(this,"change"),P(this,"cmo"),P(this,"cog"),P(this,"correlation"),P(this,"cross"),P(this,"crossover"),P(this,"crossunder"),P(this,"cum"),P(this,"dev"),P(this,"dmi"),P(this,"ema"),P(this,"falling"),P(this,"highest"),P(this,"highestbars"),P(this,"hma"),P(this,"iii"),P(this,"kc"),P(this,"kcw"),P(this,"linreg"),P(this,"lowest"),P(this,"lowestbars"),P(this,"macd"),P(this,"median"),P(this,"mfi"),P(this,"mode"),P(this,"mom"),P(this,"nvi"),P(this,"obv"),P(this,"param"),P(this,"percentile_linear_interpolation"),P(this,"percentile_nearest_rank"),P(this,"percentrank"),P(this,"pivothigh"),P(this,"pivotlow"),P(this,"pvi"),P(this,"pvt"),P(this,"range"),P(this,"rising"),P(this,"rma"),P(this,"roc"),P(this,"rsi"),P(this,"sar"),P(this,"sma"),P(this,"stdev"),P(this,"stoch"),P(this,"supertrend"),P(this,"swma"),P(this,"tr"),P(this,"tsi"),P(this,"valuewhen"),P(this,"variance"),P(this,"vwap"),P(this,"vwma"),P(this,"wad"),P(this,"wma"),P(this,"wpr"),P(this,"wvad"),Object.entries(gp).forEach(([i,r])=>{this[i]=r(e)})}}function bp(t){if(t.length===0)return{};if(typeof t[0]=="object"&&t[0]!==null)return t[0];const e={};typeof t[0]=="string"&&(e.title=t[0]);let i=null;for(let r=1;r<t.length;r++){const n=t[r];typeof n=="string"?e.shorttitle===void 0&&(e.shorttitle=n):typeof n=="object"&&n!==null&&(i=n)}return i&&Object.assign(e,i),e}function hi(t,e,i){if(!i||i<=0||!Number.isFinite(t)||t===e)return t;const r=t/i,n=1e-9;return t>e?Math.ceil(r-n)*i:Math.floor(r+n)*i}function Fr(t,e,i,r){return Math.abs(t)*e*r*i/100}function vp(t,e){const i=t.strategy,r=t.pine?.syminfo?.pointvalue??1;let n=0;for(const s of i.opentrades){const a=Math.sign(s.size)===1?e-s.entry_price:s.entry_price-e;n+=a*Math.abs(s.size)*r}return i.initial_capital+i.netprofit+n}function wp(t,e){const i=t.strategy,r=t.pine?.syminfo?.pointvalue??1;let n=0;for(const s of i.opentrades){const a=Math.sign(s.size)===1?i.config.margin_long??100:i.config.margin_short??100;n+=Fr(s.size,e,a,r)}return n}function Wr(t,e,i,r){const n=t.strategy;let s=n.config.default_qty_type||"fixed",a=n.config.default_qty_value||1;typeof s=="function"&&(s=s()),typeof a=="function"&&(a=a());const o=1e6,l=u=>Math.floor(u*o)/o;if(e!=null)return l(Math.abs(e));let c;switch(s){case"fixed":c=a;break;case"cash":c=a/r;break;case"percent_of_equity":{c=n.equity*a/100/r;break}default:c=a}return l(c)}function Sp(t){if(!t.strategy)return;const e=t.strategy,{pending_orders:i}=e,r=y.from(t.data.open).get(0),n=y.from(t.data.high).get(0),s=y.from(t.data.low).get(0),a=y.from(t.data.close).get(0),o=y.from(t.data.openTime).get(0),l=t.pine?.syminfo?.pointvalue??1;for(const c of e.opentrades){const u=Math.abs(c.size),p=c.size>0,h=c.commission??0,f=p?(c.entry_price-s)*u*l:(n-c.entry_price)*u*l,d=p?(n-c.entry_price)*u*l:(c.entry_price-s)*u*l,m=Math.max(0,f)+h,x=Math.max(0,d-h);m>(c.max_drawdown??0)&&(c.max_drawdown=m),x>(c.max_runup??0)&&(c.max_runup=x)}qi(t,r);for(const c of i){if(c.status!=="pending"||(c.category??"entry")==="exit"||c.bar>=t.idx)continue;let u=!1,p=r;switch(c.type){case"market":u=!0,p=r;break;case"limit":if(c.limit!==void 0){const h=ei(c.direction);(h===1&&s<=c.limit||h===-1&&n>=c.limit)&&(u=!0,p=c.limit)}break;case"stop":if(c.stop!==void 0){const h=ei(c.direction);(h===1&&n>=c.stop||h===-1&&s<=c.stop)&&(u=!0,p=c.stop)}break}if(u){if(Np(e,c)){c.status="cancelled";continue}const h=ei(c.direction);p=Cr(t,h,p);const f=h===1?e.config.margin_long??100:e.config.margin_short??100;{const d=e.position_size,m=Math.sign(d),x=m!==0&&m!==h?Math.max(0,c.qty-Math.abs(d)):c.qty;if(x>0){const b=t.pine?.syminfo?.pointvalue??1;let v=0;m===h&&(v=wp(t,r));const w=e.equity-v;if(Fr(x,p,f,b)>w){c.status="cancelled";continue}}}Ip(t,c,p,o),c.status="filled",c.fill_price=p,c.fill_bar=t.idx,c.fill_time=o}}e.pending_orders=i.filter(c=>c.status==="pending"),qi(t,a),Dp(t)}function ei(t){return typeof t=="number"?t:t==="long"?1:t==="short"?-1:0}function Nr(t,e,i,r){const n=e.config.commission_type??"percent",s=e.config.commission_value??0;if(!s||s===0)return 0;const a=t.pine?.syminfo?.pointvalue??1;switch(n){case"percent":return Math.abs(i)*r*a*(s/100);case"cash_per_contract":return Math.abs(i)*s;case"cash_per_order":return s;default:return 0}}function Cr(t,e,i){const r=t.strategy.config.slippage??0;if(!r||r===0)return i;const n=t.pine?.syminfo?.mintick??.01,s=r*n;return e===1?i+s:i-s}function As(t){const e=Math.abs(t.position_size);e>t.max_contracts_held_all&&(t.max_contracts_held_all=e),t.position_size>t.max_contracts_held_long&&(t.max_contracts_held_long=t.position_size),-t.position_size>t.max_contracts_held_short&&(t.max_contracts_held_short=-t.position_size)}function Ep(t,e){const i=t.config.pyramiding??1;let r=0;for(const n of t.opentrades)Math.sign(n.size)===e&&r++;return r>=i}function Np(t,e){if(t.risk_halted)return!0;const i=t.risk_rules,r=e.direction;if(i.allow_entry_in&&(i.allow_entry_in==="long"&&r===-1||i.allow_entry_in==="short"&&r===1))return!0;if(i.max_position_size!==void 0){const n=t.position_size+r*e.qty;if(Math.abs(n)>i.max_position_size)return!0}return!1}function Cp(t){if(t.risk_halted)return;const e=t.risk_rules;if(e.max_drawdown){const i=e.max_drawdown.type==="percent_of_equity"?e.max_drawdown.value/100*t.equity_peak:e.max_drawdown.value;if(t.max_drawdown>=i){t.risk_halted=!0;return}}if(e.max_intraday_loss){const i=e.max_intraday_loss.type==="percent_of_equity"?e.max_intraday_loss.value/100*t.initial_capital:e.max_intraday_loss.value;if(t.grossloss>=i){t.risk_halted=!0;return}}if(e.max_cons_loss_days){let i=0;for(let r=t.closedtrades.length-1;r>=0&&(t.closedtrades[r].profit??0)<0;r--)i++;i>=e.max_cons_loss_days.count&&(t.risk_halted=!0)}}function dn(t,e,i,r,n,s,a,o){const l=t.strategy,c=l.opentrades.length+l.closedtrades.length,u=l.config.commission_type??"percent",p=o&&u==="cash_per_order",h=Nr(t,l,r,n),f=p?h/2:h,d={id:`trade_${c}`,entry_id:e,entry_comment:a??e,entry_price:n,entry_bar_index:t.idx,entry_time:s,size:i*r,commission:f,max_drawdown:0,max_runup:0,status:"open"};l.opentrades.push(d),f>0&&(l.netprofit-=f,l.grossloss+=f);const m=y.from(t.data.high).get(0),x=y.from(t.data.low).get(0),b=t.pine?.syminfo?.mintick??.01;let v=i===1?x:m,w=i===1?m:x;for(const k of l.pending_orders){if((k.category??"entry")!=="exit"||k.from_entry&&k.from_entry!==e)continue;let A;k.stop!==void 0?A=k.stop:k.loss!==void 0&&(A=i===1?n-k.loss*b:n+k.loss*b);let V;k.limit!==void 0?V=k.limit:k.profit!==void 0&&(V=i===1?n+k.profit*b:n-k.profit*b),i===1?(A!==void 0&&A>v&&(v=A),V!==void 0&&V<w&&(w=V)):(A!==void 0&&A<v&&(v=A),V!==void 0&&V>w&&(w=V))}const S=t.pine?.syminfo?.pointvalue??1,T=i===1?(n-v)*r*S:(v-n)*r*S,N=i===1?(w-n)*r*S:(n-w)*r*S;d.max_drawdown=Math.max(0,T)+f,d.max_runup=Math.max(0,N-f);const R=l.position_size,$=R+d.size;if(R===0)l.position_size=$,l.position_avg_price=n,l.position_entry_name=e;else if(Math.sign(R)===Math.sign($)){const k=Math.abs(R)*l.position_avg_price+r*n,A=Math.abs($);l.position_avg_price=k/A,l.position_size=$}As(l)}function Ip(t,e,i,r){const n=t.strategy,s=ei(e.direction),a=n.position_size,o=Math.sign(a);if(o===1&&s===-1||o===-1&&s===1){const l=Math.min(Math.abs(a),e.qty),c=e.qty-l,u=c>0;Ui(t,l,i,r,{exitId:e.id,exitComment:e.comment,isImplicitReversal:u}),c>0&&dn(t,e.id,s,c,i,r,e.comment,!0)}else dn(t,e.id,s,e.qty,i,r,e.comment)}function Ui(t,e,i,r,n){const s=t.strategy,a=t.pine?.syminfo?.pointvalue??1;let o=e;const l=[...s.opentrades];s.opentrades=[];for(const h of l){if(o<=0){s.opentrades.push(h);continue}const f=Math.abs(h.size),d=Math.min(f,o),m=Math.sign(h.size);if(d>=f){h.status="closed",h.exit_price=i,h.exit_bar_index=t.idx,h.exit_time=r;const x=(m===1?i-h.entry_price:h.entry_price-i)*f*a,b=h.commission??0,v=s.config.commission_type??"percent",w=n?.isImplicitReversal&&v==="cash_per_order",S=Nr(t,s,f,i),T=w?S/2:S;h.commission=b+T,n?.triggerKind==="loss"&&(h.max_runup=0),n?.triggerKind==="profit"&&(h.max_drawdown=b),n?.exitId!==void 0&&(h.exit_id=n.exitId),n?.exitComment!==void 0&&(h.exit_comment=n.exitComment),h.profit=x-h.commission;const N=x-T;s.netprofit+=N,s.grossloss-=b,h.profit>0?(s.grossprofit+=h.profit,s.wintrades++,s.wintrades_total_profit+=h.profit):h.profit<0?(s.grossloss+=Math.abs(h.profit),s.losstrades++,s.losstrades_total_loss+=Math.abs(h.profit)):s.eventrades++,s.closedtrades.push(h),o-=d}else{const x=s.opentrades.length+s.closedtrades.length,b=(m===1?i-h.entry_price:h.entry_price-i)*d*a,v=(h.commission??0)*(d/f),w=s.config.commission_type??"percent",S=n?.isImplicitReversal&&w==="cash_per_order",T=Nr(t,s,d,i),N=S?T/2:T,R=v+N,$={...h,id:`trade_${x}`,size:m*d,status:"closed",exit_price:i,exit_bar_index:t.idx,exit_time:r,commission:R,profit:b-R,exit_id:n?.exitId??h.exit_id,exit_comment:n?.exitComment??h.exit_comment};n?.triggerKind==="loss"&&($.max_runup=0),n?.triggerKind==="profit"&&($.max_drawdown=v);const k=b-N;s.netprofit+=k,s.grossloss-=v,$.profit>0?(s.grossprofit+=$.profit,s.wintrades++,s.wintrades_total_profit+=$.profit):$.profit<0?(s.grossloss+=Math.abs($.profit),s.losstrades++,s.losstrades_total_loss+=Math.abs($.profit)):s.eventrades++,s.closedtrades.push($),h.size=m*(f-d),h.commission=(h.commission??0)-v,s.opentrades.push(h),o=0}}Cp(s);const c=s.position_size,u=Math.sign(c)*e,p=c-u;if(s.position_size=p,As(s),p===0)s.position_avg_price=NaN,s.position_entry_name="";else if(s.opentrades.length>0){let h=0,f=0;for(const d of s.opentrades){const m=Math.abs(d.size);h+=m*d.entry_price,f+=m}s.position_avg_price=h/f,s.position_entry_name=s.opentrades[0].entry_id}}function qi(t,e){const i=t.strategy,r=t.pine?.syminfo?.pointvalue??1;let n=0;for(const s of i.opentrades){const a=Math.abs(s.size),o=Math.sign(s.size)===1?e-s.entry_price:s.entry_price-e;n+=o*a*r}i.openprofit=n,i.equity=i.initial_capital+i.netprofit+n}function kp(t,e,i){const r=t.strategy,n=t.pine?.syminfo?.pointvalue??1,s=r.initial_capital+r.netprofit;s>r.equity_peak&&(r.equity_peak=s),s<r.equity_trough&&(r.equity_trough=s);const a=r.position_size,o=r.position_avg_price;let l=0,c=0;if(a!==0&&Number.isFinite(o)){const h=a>0?i:e,f=a>0?e:i;l=a*(o-h)*n,c=a*(f-o)*n}const u=r.equity_peak-s+l;if(u>r.max_drawdown&&(r.max_drawdown=u,r.equity_at_drawdown_peak=r.equity_peak,r.equity_peak>0)){const h=100*u/r.equity_peak;h>r.max_drawdown_percent_value&&(r.max_drawdown_percent_value=h)}const p=s-r.equity_trough+c;if(p>r.max_runup&&(r.max_runup=p,r.equity_at_runup_peak=s+c,r.equity_at_runup_peak>0)){const h=100*p/r.equity_at_runup_peak;h>r.max_runup_percent_value&&(r.max_runup_percent_value=h)}}function mn(t,e,i,r,n,s){const a=t.strategy;if(!e||e===""){Ui(t,i,r,n,s);return}const o=[],l=[];for(const p of a.opentrades)p.entry_id===e?o.push(p):l.push(p);const c=o.reduce((p,h)=>p+Math.abs(h.size),0);if(c===0)return;const u=Math.min(i,c);a.opentrades=[...o,...l],Ui(t,u,r,n,s)}function Tp(t){if(!t.strategy)return;const e=t.strategy;if(e.pending_orders.length===0)return;const i=y.from(t.data.open).get(0),r=y.from(t.data.high).get(0),n=y.from(t.data.low).get(0),s=y.from(t.data.close).get(0),a=y.from(t.data.openTime).get(0),o=t.pine?.syminfo?.mintick??.01;for(const l of e.pending_orders){if(l.status!=="pending"||(l.category??"entry")!=="exit")continue;const c=e.opentrades.filter(A=>!l.from_entry||A.entry_id===l.from_entry);if(c.length===0){l.status="cancelled";continue}const u=c.reduce((A,V)=>A+Math.abs(V.size),0),p=Math.sign(c[0].size);if(l.type==="market"&&l.profit===void 0&&l.loss===void 0&&l.limit===void 0&&l.stop===void 0&&l.trail_price===void 0&&l.trail_points===void 0){if(l.bar>=t.idx)continue;let A=l.immediately?s:i;A=Cr(t,-p,A);let V=u;l.qty&&l.qty>0?V=Math.min(l.qty,u):l.qty_percent&&l.qty_percent>0&&(V=u*(l.qty_percent/100)),mn(t,l.from_entry,V,A,a,{exitId:l.id,exitComment:l.comment}),l.status="filled",l.fill_price=A,l.fill_bar=t.idx,l.fill_time=a;continue}let h=0;for(const A of c)h+=Math.abs(A.size)*A.entry_price;const f=h/u,d=p===1;let m;l.limit!==void 0?m=l.limit:l.profit!==void 0&&(m=d?f+l.profit*o:f-l.profit*o);let x;l.stop!==void 0?x=l.stop:l.loss!==void 0&&(x=d?f-l.loss*o:f+l.loss*o),l._isPersistent||(x!==void 0&&((d?x<f:x>f)||(x=void 0)),m!==void 0&&((d?m>f:m<f)||(m=void 0))),l._attachedAtReversal&&!l._isPersistent&&(l.limit!==void 0&&(m=void 0),l.stop!==void 0&&(x=void 0));let b=!1;if(!l.trail_armed&&(l.trail_price!==void 0||l.trail_points!==void 0)){let A;l.trail_price!==void 0?A=l.trail_price:l.trail_points!==void 0&&(A=d?f+l.trail_points*o:f-l.trail_points*o),A!==void 0&&(d?r>=A:n<=A)&&(l.trail_armed=!0,l.trail_peak=d?r:n,b=!0)}const v=Math.abs(r-i)<=Math.abs(i-n),w=d?v:!v;let S=!1,T=NaN,N=null;const R=()=>{S||x===void 0||(d?n<=x:r>=x)&&(S=!0,T=(d?i<=x:i>=x)?i:x,N="loss")},$=()=>{if(S||!l.trail_armed||l.trail_offset===void 0)return;const A=()=>{d?l.trail_peak=Math.max(l.trail_peak??-1/0,r):l.trail_peak=Math.min(l.trail_peak??1/0,n)},V=()=>d?l.trail_peak-l.trail_offset*o:l.trail_peak+l.trail_offset*o;if(b){const z=V();w?(d?n<=z:r>=z)&&(S=!0,T=z,N="trailing"):(d?s<z:s>z)&&(S=!0,T=z,N="trailing");return}if(w){A();const z=V();(d?n<=z:r>=z)&&(S=!0,T=z,N="trailing")}else{const z=V();if(d?n<=z:r>=z){S=!0,T=z,N="trailing";return}A();const O=V();(d?s<O:s>O)&&(S=!0,T=O,N="trailing")}},k=()=>{S||m===void 0||(d?r>=m:n<=m)&&(S=!0,T=(d?i>=m:i<=m)?i:m,N="profit")};if(w?(k(),R(),$()):(R(),$(),k()),S){const A=Cr(t,-p,T);let V=u;l.qty&&l.qty>0?V=Math.min(l.qty,u):l.qty_percent&&l.qty_percent>0&&(V=u*(l.qty_percent/100));const z=N==="profit"?l.comment_profit??l.comment:N==="loss"?l.comment_loss??l.comment:N==="trailing"?l.comment_trailing??l.comment:l.comment;mn(t,l.from_entry,V,A,a,{triggerKind:N,exitId:l.id,exitComment:z}),l.status="filled",l.fill_price=A,l.fill_bar=t.idx,l.fill_time=a}}e.pending_orders=e.pending_orders.filter(l=>l.status==="pending"),qi(t,s)}function Ap(t){const e=t.strategy;if(!e||e.opentrades.length===0)return;const i=Math.sign(e.position_size);if(i===0)return;const r=i===1?e.config.margin_long??100:e.config.margin_short??100,n=y.from(t.data.high).get(0),s=y.from(t.data.low).get(0),a=y.from(t.data.openTime).get(0),o=t.pine?.syminfo?.pointvalue??1,l=i===1?s:n,c=Math.abs(e.position_size),u=vp(t,l),p=Fr(c,l,r,o);u<p&&Ui(t,c,l,a,{exitId:"Margin call",exitComment:"Margin call"})}function Pp(t){if(!t.strategy)return;const e=y.from(t.data.high).get(0),i=y.from(t.data.low).get(0),r=y.from(t.data.close).get(0);qi(t,r),kp(t,e,i)}function Dp(t){t.strategy}function Mp(t,e){const i={title:"",shorttitle:"",overlay:!1,format:"inherit",precision:10,scale:"right",pyramiding:1,calc_on_order_fills:!1,calc_on_every_tick:!1,max_bars_back:0,backtest_fill_limits_assumption:0,default_qty_type:"fixed",default_qty_value:1,initial_capital:1e6,currency:"USD",slippage:0,commission_type:"percent",commission_value:0,margin_long:100,margin_short:100,explicit_plot_zorder:!1,max_lines_count:50,max_labels_count:50,max_boxes_count:50,max_polylines_count:50,risk_free_rate:2,use_bar_magnifier:!1,fill_orders_on_standard_ohlc:!1,...e,...t._propOverrides??{}},r=i.initial_capital;t.strategy={config:i,opentrades:[],closedtrades:[],pending_orders:[],position_size:0,position_avg_price:NaN,position_entry_name:"",initial_capital:r,account_currency:i.currency||"USD",equity:r,netprofit:0,grossprofit:0,grossloss:0,openprofit:0,max_drawdown:0,max_runup:0,equity_peak:r,equity_trough:r,equity_at_runup_peak:r,equity_at_drawdown_peak:r,max_drawdown_percent_value:0,max_runup_percent_value:0,wintrades:0,losstrades:0,eventrades:0,wintrades_total_profit:0,losstrades_total_loss:0,max_contracts_held_all:0,max_contracts_held_long:0,max_contracts_held_short:0,risk_rules:{},risk_halted:!1,_exit_call_history:new Map,_exit_fallback_counter:0,_exit_fallback_last_bar:-1}}function Rp(t){return(...e)=>{const i=bp(e);return t.strategy?t.strategy.config={...t.strategy.config,...i,...t._propOverrides??{}}:Mp(t,i),t.strategy.config}}const Op=[["id","direction","qty","limit","stop","oca_name","oca_type","comment","alert_message","disable_alert"]],$p={id:"string",direction:"series",qty:"series",limit:"series",stop:"series",oca_name:"string",oca_type:"string",comment:"string",alert_message:"string",disable_alert:"boolean"};function Vp(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.order() called before strategy() declaration");const i=te(e,Op,$p),r=v=>v==null||typeof v=="string"||typeof v=="number"||typeof v=="boolean"?v:typeof v=="function"?v():v instanceof y?v.get(0):Array.isArray(v)?v[v.length-1]:typeof v=="object"&&v.get!==void 0?v.get(0):v,n=r(i.id),s=r(i.direction),a=r(i.qty),o=r(i.limit),l=r(i.stop),c=r(i.oca_name),u=r(i.oca_type),p=r(i.comment),h=ei(s),f=y.from(t.data.close).get(0),d=Wr(t,a,h,f);let m="market";o!==void 0&&l!==void 0?m="stop-limit":o!==void 0?m="limit":l!==void 0&&(m="stop");const x=y.from(t.data.openTime).get(0),b={id:n,direction:h,qty:d,type:m,limit:o,stop:l,bar:t.idx,time:x,status:"pending",oca_name:c,oca_type:u,comment:p};return t.strategy.pending_orders.push(b),b}}function jp(t){return(e,i)=>y.from(e).get(i||0)}function Lp(t){return()=>{const e=(t.strategy?.opentrades??[]).slice(),i=h=>e[Number(h)],r=()=>{const h=t.marketData;return Array.isArray(h)&&t.idx>=0&&t.idx<h.length?h[t.idx]?.close??NaN:NaN},n={valueOf(){return e.length},toString(){return String(e.length)},[Symbol.toPrimitive](){return e.length}},s=t.pine?.syminfo?.pointvalue??1,a=(h,f)=>{const d=t.strategy?.config,m=d?.commission_type??"percent",x=d?.commission_value??0;if(!x)return 0;const b=Math.abs(h.size);switch(m){case"percent":return b*f*s*(x/100);case"cash_per_contract":return b*x;case"cash_per_order":return x;default:return 0}},o=h=>Math.abs(h.size)*h.entry_price*s+(h.commission??0);n.profit=h=>{const f=i(h);if(!f)return NaN;const d=r();return Number.isFinite(d)?(Math.sign(f.size)===1?d-f.entry_price:f.entry_price-d)*Math.abs(f.size)*s-(f.commission??0)-a(f,d):NaN},n.profit_percent=h=>{const f=i(h);if(!f)return NaN;const d=n.profit(h);if(!Number.isFinite(d))return NaN;const m=o(f);return m>0?100*d/m:NaN},n.size=h=>i(h)?.size??NaN,n.commission=h=>i(h)?.commission??NaN,n.entry_price=h=>i(h)?.entry_price??NaN,n.entry_bar_index=h=>i(h)?.entry_bar_index??NaN,n.entry_id=h=>i(h)?.entry_id??"",n.entry_comment=h=>i(h)?.entry_comment??i(h)?.entry_id??"",n.entry_time=h=>i(h)?.entry_time??NaN,n.max_drawdown=h=>i(h)?.max_drawdown??0,n.max_drawdown_percent=h=>{const f=i(h);if(!f||!f.max_drawdown)return 0;const d=o(f);return d>0?100*f.max_drawdown/d:0},n.max_runup=h=>i(h)?.max_runup??0,n.max_runup_percent=h=>{const f=i(h);if(!f||!f.max_runup)return 0;const d=o(f);return d>0?100*f.max_runup/d:0};const l=t.strategy,c=l?.config?.margin_long??100,u=l?.config?.margin_short??100,p=c!==100||u!==100;if(!l||l.opentrades.length===0||!p)n.capital_held=NaN;else{let h=0;for(const f of l.opentrades){const d=Math.abs(f.size)*f.entry_price,m=f.size>0?c:u;h+=d*(m/100)}n.capital_held=h}return n}}function Bp(t){return()=>{const e=(t.strategy?.closedtrades??[]).slice(),i=a=>e[Number(a)],r={valueOf(){return e.length},toString(){return String(e.length)},[Symbol.toPrimitive](){return e.length}},n=t.pine?.syminfo?.pointvalue??1,s=a=>{const o=Math.abs(a.size)*a.entry_price*n,l=(a.commission??0)/2;return o+l};return r.profit=a=>i(a)?.profit??NaN,r.profit_percent=a=>{const o=i(a);if(!o||o.profit===void 0)return NaN;const l=s(o);return l>0?100*o.profit/l:NaN},r.size=a=>i(a)?.size??NaN,r.commission=a=>i(a)?.commission??NaN,r.entry_price=a=>i(a)?.entry_price??NaN,r.entry_bar_index=a=>i(a)?.entry_bar_index??NaN,r.entry_id=a=>i(a)?.entry_id??"",r.entry_comment=a=>i(a)?.entry_comment??i(a)?.entry_id??"",r.entry_time=a=>i(a)?.entry_time??NaN,r.exit_price=a=>i(a)?.exit_price??NaN,r.exit_bar_index=a=>i(a)?.exit_bar_index??NaN,r.exit_id=a=>i(a)?.exit_id??"",r.exit_comment=a=>i(a)?.exit_comment??i(a)?.exit_id??"",r.exit_time=a=>i(a)?.exit_time??NaN,r.max_drawdown=a=>i(a)?.max_drawdown??0,r.max_drawdown_percent=a=>{const o=i(a);if(!o||!o.max_drawdown)return 0;const l=s(o);return l>0?100*o.max_drawdown/l:0},r.max_runup=a=>i(a)?.max_runup??0,r.max_runup_percent=a=>{const o=i(a);if(!o||!o.max_runup)return 0;const l=s(o);return l>0?100*o.max_runup/l:0},r.first_index=0,r}}function Fp(t){return()=>t.strategy?.netprofit??0}function Wp(t){return()=>t.strategy?.position_size??0}function Up(t){return()=>{const e=t.strategy;return!e||e.position_size===0?NaN:e.position_avg_price}}function qp(t){return()=>t.strategy?.equity??t.strategy?.config?.initial_capital??1e4}function zp(t){return()=>"long"}function Kp(t){return()=>"short"}function Hp(t){return()=>"cash"}function Gp(t){return()=>"percent_of_equity"}function Yp(t){return()=>"fixed"}function Xp(t){return()=>t.strategy?.openprofit??0}function Zp(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.openprofit/e.initial_capital}}function Qp(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.netprofit/e.initial_capital}}function Jp(t){return()=>t.strategy?.grossprofit??0}function ef(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.grossprofit/e.initial_capital}}function tf(t){return()=>t.strategy?.grossloss??0}function rf(t){return()=>{const e=t.strategy;return!e||!e.initial_capital?0:100*e.grossloss/e.initial_capital}}function nf(t){return()=>t.strategy?.wintrades??0}function sf(t){return()=>t.strategy?.losstrades??0}function af(t){return()=>t.strategy?.eventrades??0}function of(t){return()=>{const e=t.strategy;return!e||!e.closedtrades||e.closedtrades.length===0?NaN:e.netprofit/e.closedtrades.length}}function lf(t){return()=>{const e=t.strategy;if(!e||!e.closedtrades||e.closedtrades.length===0)return NaN;let i=0;for(const r of e.closedtrades){const n=Math.abs(r.size)*r.entry_price;n>0&&(i+=100*(r.profit??0)/n)}return i/e.closedtrades.length}}function cf(t){return()=>{const e=t.strategy;return!e||e.wintrades===0?NaN:e.wintrades_total_profit/e.wintrades}}function uf(t){return()=>{const e=t.strategy;if(!e||e.wintrades===0)return NaN;let i=0;for(const r of e.closedtrades)if((r.profit??0)>0){const n=Math.abs(r.size)*r.entry_price;n>0&&(i+=100*(r.profit??0)/n)}return i/e.wintrades}}function hf(t){return()=>{const e=t.strategy;return!e||e.losstrades===0?NaN:e.losstrades_total_loss/e.losstrades}}function pf(t){return()=>{const e=t.strategy;if(!e||e.losstrades===0)return NaN;let i=0;for(const r of e.closedtrades)if((r.profit??0)<0){const n=Math.abs(r.size)*r.entry_price;n>0&&(i+=100*(r.profit??0)/n)}return i/e.losstrades}}function ff(t){return()=>t.strategy?.max_drawdown??0}function df(t){return()=>{const e=t.strategy;return e?e.max_drawdown_percent_value??0:0}}function mf(t){return()=>t.strategy?.max_runup??0}function yf(t){return()=>{const e=t.strategy;return e?e.max_runup_percent_value??0:0}}function _f(t){return()=>t.strategy?.max_contracts_held_all??0}function gf(t){return()=>t.strategy?.max_contracts_held_long??0}function xf(t){return()=>t.strategy?.max_contracts_held_short??0}function bf(t){return()=>t.strategy?.position_entry_name??""}function vf(t){return()=>t.strategy?.initial_capital??0}function wf(t){return()=>t.strategy?.account_currency??"USD"}function Sf(t){return()=>{const e=t.strategy;if(!e||e.position_size===0)return NaN;const i=e.position_avg_price;if(!Number.isFinite(i))return NaN;const r=Math.sign(e.position_size),n=r===1?e.config.margin_long??100:e.config.margin_short??100;if(n>=100)return NaN;const s=Math.abs(e.position_size),a=t.pine?.syminfo?.pointvalue??1,o=((e.initial_capital??0)+(e.netprofit??0))/(a*s)-r*i,l=n/100-r,c=o/l,u=t.pine?.syminfo?.mintick??.01;return r===1?Math.floor(c/u)*u:Math.ceil(c/u)*u}}const Ef=[["id","direction","qty","limit","stop","oca_name","oca_type","comment","alert_message","disable_alert"]],Nf={id:"string",direction:"series",qty:"series",limit:"series",stop:"series",oca_name:"string",oca_type:"string",comment:"string",alert_message:"string",disable_alert:"boolean"};function Cf(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.entry() called before strategy() declaration");const i=te(e,Ef,Nf),r=k=>k==null||typeof k=="string"||typeof k=="number"||typeof k=="boolean"?k:typeof k=="function"?k():k instanceof y?k.get(0):Array.isArray(k)?k[k.length-1]:typeof k=="object"&&k.get!==void 0?k.get(0):k,n=r(i.id),s=r(i.direction),a=r(i.qty),o=r(i.limit),l=r(i.stop),c=r(i.oca_name),u=r(i.oca_type),p=r(i.comment),h=ei(s),f=t.strategy,d=f.position_size;if(Math.sign(d)===h&&d!==0&&Ep(f,h))return;const m=y.from(t.data.close).get(0),x=Wr(t,a,h,m),b=d!==0&&Math.sign(d)!==h,v=b?Math.abs(d)+x:x;let w="market";o!==void 0&&l!==void 0?w="stop-limit":o!==void 0?w="limit":l!==void 0&&(w="stop");const S=t.pine?.syminfo?.mintick??0,T=o!==void 0?hi(o,m,S):void 0,N=l!==void 0?hi(l,m,S):void 0,R=y.from(t.data.openTime).get(0),$={id:n,direction:h,qty:v,type:w,limit:T,stop:N,bar:t.idx,time:R,status:"pending",category:"entry",oca_name:c,oca_type:u,comment:p,_isReversalEntry:b};f.pending_orders.push($)}}const If=[["id","from_entry","qty","qty_percent","profit","limit","loss","stop","trail_price","trail_points","trail_offset","oca_name","comment","comment_profit","comment_loss","comment_trailing","alert_message","alert_profit","alert_loss","alert_trailing","disable_alert"]],kf={id:"string",from_entry:"string",qty:"series",qty_percent:"series",profit:"series",limit:"series",loss:"series",stop:"series",trail_price:"series",trail_points:"series",trail_offset:"series",oca_name:"string",comment:"string",comment_profit:"string",comment_loss:"string",comment_trailing:"string",alert_message:"string",alert_profit:"string",alert_loss:"string",alert_trailing:"string",disable_alert:"boolean"};function Tf(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.exit() called before strategy() declaration");let i=et(e);if(i===void 0){const O=t.strategy;O._exit_fallback_last_bar!==t.idx&&(O._exit_fallback_counter=0,O._exit_fallback_last_bar=t.idx),i=`exit_raw_${O._exit_fallback_counter++}`}const r=te(e,If,kf),n=O=>O==null||typeof O=="string"||typeof O=="number"||typeof O=="boolean"?O:typeof O=="function"?O():O instanceof y?O.get(0):Array.isArray(O)?O[O.length-1]:typeof O=="object"&&O.get!==void 0?O.get(0):O,s=n(r.id),a=n(r.from_entry),o=n(r.qty),l=n(r.qty_percent),c=n(r.profit),u=n(r.limit),p=n(r.loss),h=n(r.stop),f=n(r.trail_price),d=n(r.trail_points),m=n(r.trail_offset),x=t.pine?.syminfo?.mintick??0,b=y.from(t.data.close).get(0),v=u!==void 0?hi(u,b,x):void 0,w=h!==void 0?hi(h,b,x):void 0,S=f!==void 0?hi(f,b,x):void 0,T=a??"",N=!!(T?t.strategy.pending_orders.find(O=>O.category==="entry"&&O.id===T&&O.status==="pending"):t.strategy.pending_orders.find(O=>O.category==="entry"&&O.status==="pending"))?._isReversalEntry,R=t.strategy._exit_call_history,$=R.get(i),k=$!==void 0&&$===t.idx-1;R.set(i,t.idx);const A={id:s??"exit",direction:0,qty:o!==void 0?Math.abs(Number(o)):0,qty_percent:l,type:"market",bar:t.idx,time:y.from(t.data.openTime).get(0),status:"pending",category:"exit",from_entry:T,profit:c,loss:p,limit:v,stop:w,trail_price:S,trail_points:d,trail_offset:m,oca_name:n(r.oca_name),comment:n(r.comment),comment_profit:n(r.comment_profit),comment_loss:n(r.comment_loss),comment_trailing:n(r.comment_trailing),alert_message:n(r.alert_message),alert_profit:n(r.alert_profit),alert_loss:n(r.alert_loss),alert_trailing:n(r.alert_trailing),disable_alert:n(r.disable_alert),trail_armed:!1,trail_peak:NaN,_attachedAtReversal:N,_isPersistent:k,_callsiteId:i},V=A.id,z=t.strategy.pending_orders;for(let O=z.length-1;O>=0;O--){const q=z[O];q.category==="exit"&&q.id===V&&(q.from_entry??"")===(A.from_entry??"")&&q.status==="pending"&&(q.trail_armed&&(A.trail_armed=!0,A.trail_peak=q.trail_peak),z.splice(O,1))}z.push(A)}}const Af=[["id","comment","qty","qty_percent","alert_message","immediately","disable_alert"]],Pf={id:"string",comment:"string",qty:"series",qty_percent:"series",alert_message:"string",immediately:"boolean",disable_alert:"boolean"};function Df(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.close() called before strategy() declaration");const i=te(e,Af,Pf),r=i.id;if(r==null||!t.strategy.opentrades.some(o=>o.entry_id===r))return;const n=o=>(o.category??"entry")==="exit"&&(o.profit!==void 0||o.loss!==void 0||o.limit!==void 0||o.stop!==void 0||o.trail_price!==void 0||o.trail_points!==void 0),s=t.strategy.pending_orders;for(const o of s)n(o)&&(o.from_entry??"")===r&&o.status==="pending"&&(o.status="cancelled");t.strategy.pending_orders=s.filter(o=>o.status==="pending");const a={id:`close_${r}`,direction:0,qty:0,type:"market",bar:t.idx,time:y.from(t.data.openTime).get(0),status:"pending",category:"exit",from_entry:r,qty_percent:i.qty_percent,comment:i.comment,alert_message:i.alert_message,immediately:i.immediately===!0,disable_alert:i.disable_alert};i.qty!==void 0&&(a.qty=Math.abs(Number(i.qty))),t.strategy.pending_orders.push(a)}}const Mf=[["comment","alert_message","immediately","disable_alert"]],Rf={comment:"string",alert_message:"string",immediately:"boolean",disable_alert:"boolean"};function Of(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.close_all() called before strategy() declaration");const i=te(e,Mf,Rf);if(t.strategy.opentrades.length===0)return;const r=a=>(a.category??"entry")==="exit"&&(a.profit!==void 0||a.loss!==void 0||a.limit!==void 0||a.stop!==void 0||a.trail_price!==void 0||a.trail_points!==void 0),n=t.strategy.pending_orders;for(const a of n)r(a)&&a.status==="pending"&&(a.status="cancelled");t.strategy.pending_orders=n.filter(a=>a.status==="pending");const s={id:"close_all",direction:0,qty:0,type:"market",bar:t.idx,time:y.from(t.data.openTime).get(0),status:"pending",category:"exit",from_entry:"",comment:i.comment,alert_message:i.alert_message,immediately:i.immediately===!0,disable_alert:i.disable_alert};t.strategy.pending_orders.push(s)}}const $f=[["id","immediately"]],Vf={id:"string",immediately:"boolean"};function jf(t){return(...e)=>{if(!t.strategy)throw new Error("strategy.cancel() called before strategy() declaration");const i=te(e,$f,Vf).id;i!=null&&(t.strategy.pending_orders=t.strategy.pending_orders.filter(r=>!(r.status==="pending"&&r.id===i)))}}function Lf(t){return()=>{if(!t.strategy)throw new Error("strategy.cancel_all() called before strategy() declaration");t.strategy.pending_orders=t.strategy.pending_orders.filter(e=>!(e.status==="pending"&&(e.category??"entry")==="entry"))}}function Bf(t){return{allow_entry_in:e=>{t.strategy&&(t.strategy.risk_rules.allow_entry_in=e)},max_cons_loss_days:(e,i)=>{t.strategy&&(t.strategy.risk_rules.max_cons_loss_days={count:e,alert_message:i})},max_drawdown:(e,i,r)=>{t.strategy&&(t.strategy.risk_rules.max_drawdown={value:e,type:i})},max_intraday_filled_orders:(e,i)=>{t.strategy&&(t.strategy.risk_rules.max_intraday_filled_orders={count:e,alert_message:i})},max_intraday_loss:(e,i,r)=>{t.strategy&&(t.strategy.risk_rules.max_intraday_loss={value:e,type:i})},max_position_size:e=>{t.strategy&&(t.strategy.risk_rules.max_position_size=e)}}}function Ff(t){return e=>{const i=t.strategy,r=t.pine?.syminfo?.currency,n=i?.account_currency??"USD";return r&&r!==n?NaN:e}}function Wf(t){return e=>{const i=t.strategy,r=t.pine?.syminfo?.currency,n=i?.account_currency??"USD";return r&&r!==n?NaN:e}}function Uf(t){return e=>t.strategy?Wr(t,void 0,1,e):0}const qf={any:Rp,order:Vp,param:jp,opentrades:Lp,closedtrades:Bp,netprofit:Fp,position_size:Wp,position_avg_price:Up,equity:qp,long:zp,short:Kp,cash:Hp,percent_of_equity:Gp,fixed:Yp,openprofit:Xp,openprofit_percent:Zp,netprofit_percent:Qp,grossprofit:Jp,grossprofit_percent:ef,grossloss:tf,grossloss_percent:rf,wintrades:nf,losstrades:sf,eventrades:af,avg_trade:of,avg_trade_percent:lf,avg_winning_trade:cf,avg_winning_trade_percent:uf,avg_losing_trade:hf,avg_losing_trade_percent:pf,max_drawdown:ff,max_drawdown_percent:df,max_runup:mf,max_runup_percent:yf,max_contracts_held_all:_f,max_contracts_held_long:gf,max_contracts_held_short:xf,position_entry_name:bf,initial_capital:vf,account_currency:wf,margin_liquidation_price:Sf,entry:Cf,exit:Tf,close:Df,close_all:Of,cancel:jf,cancel_all:Lf,convert_to_account:Ff,convert_to_symbol:Wf,default_entry_qty:Uf},zf={long:"long",short:"short",all:"all"},Kf={none:"none",cancel:"cancel",reduce:"reduce"},Hf={percent:"percent",cash_per_order:"cash_per_order",cash_per_contract:"cash_per_contract"};class Gf{constructor(e){this.context=e,Object.entries(qf).forEach(([r,n])=>{this[r]=n(e)}),this.direction=()=>zf,this.oca=()=>Kf,this.commission=()=>Hf;const i=Bf(e);this.risk=()=>i}}function Yf(t,e){const i=e.trim();if(i==="UTC"||i==="GMT"||i==="Etc/UTC")return 0;const r=i.match(/^(?:UTC|GMT)([+-])(\d{1,2})(?::(\d{2}))?$/i);if(r){const a=r[1]==="+"?1:-1,o=parseInt(r[2],10),l=parseInt(r[3]||"0",10);return a*(o*60+l)}const n=Rt(t,e),s=new Date(Date.UTC(n.year,n.month-1,n.day,n.hour,n.minute,n.second));return Math.round((s.getTime()-t)/6e4)}function Xf(t,e){const i=e>=0?"+":"-",r=s=>String(Math.floor(Math.abs(s))).padStart(2,"0"),n=i+r(e/60)+":"+r(e%60);return`[${new Date(t+e*6e4).toISOString().slice(0,-1)}${n}]`}class Zf{constructor(e){this.context=e}logFormat(e,...i){return e.replace(/{(\d+)}/g,(r,n)=>i[n])}param(e,i=0,r){return y.from(e).get(i)}_formatTimestamp(){const e=this.context.data.openTime.data[this.context.idx],i=this.context.chartTimezone||this.context.pine?.syminfo?.timezone||"UTC",r=Yf(e,i);return Xf(e,r)}warning(e,...i){this.context.isSecondaryContext||console.warn(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}error(e,...i){this.context.isSecondaryContext||console.error(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}info(e,...i){this.context.isSecondaryContext||console.log(`${this._formatTimestamp()} ${this.logFormat(e,...i)}`)}}const Qf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Jf=["January","February","March","April","May","June","July","August","September","October","November","December"],ed=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],td=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Ve=(t,e)=>String(t).padStart(e,"0");class id{constructor(e){this.context=e}param(e,i=0,r){return y.from(e).get(i)}tostring(e,i){if(typeof e!="number"||isNaN(e)||!i)return String(e);if(i==="mintick"){const n=this.context.pine?.syminfo?.mintick||.01,s=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(s)}if(i==="integer")return String(Math.round(e));if(i==="percent")return(e*100).toFixed(2)+"%";if(i==="price"){const n=this.context.pine?.syminfo?.mintick||.01,s=Math.max(0,-Math.floor(Math.log10(n)));return e.toFixed(s)}if(i==="volume")return String(Math.round(e));const r=i.indexOf(".");if(r>=0){const n=i.substring(r+1).length;return e.toFixed(n)}return i.includes("#")||i.includes("0")?String(Math.round(e)):String(e)}tonumber(e){return Number(e)}lower(e){return String(e).toLowerCase()}upper(e){return String(e).toUpperCase()}trim(e){return String(e).trim()}repeat(e,i,r=""){return Array(i).fill(e).join(r||"")}replace_all(e,i,r){return String(e).replaceAll(i,r)}replace(e,i,r,n=0){const s=String(e),a=String(i),o=String(r),l=Math.floor(Number(n))||0;if(a==="")return s;let c=0,u=0;for(;;){const p=s.indexOf(a,c);if(p===-1)return s;if(u===l)return s.substring(0,p)+o+s.substring(p+a.length);u++,c=p+a.length}}contains(e,i){return String(e).includes(i)}endswith(e,i){return String(e).endsWith(i)}startswith(e,i){return String(e).startsWith(i)}pos(e,i){const r=String(e).indexOf(i);return r===-1?NaN:r}length(e){return String(e).length}match(e,i){return String(e).match(new RegExp(i))}split(e,i){return new F(String(e).split(i),L.string,this.context)}substring(e,i,r){return String(e).substring(i,r)}format_time(e,i="yyyy-MM-dd'T'HH:mm:ssZ",r){if(e==null||typeof e=="number"&&isNaN(e))return"NaN";const n=Number(e),s=r||this.context.pine?.syminfo?.timezone||"UTC",a=Rt(n,s),o=Date.UTC(a.year,a.month-1,a.day,a.hour,a.minute,a.second),l=Math.round((o-n)/6e4),c=Date.UTC(a.year,0,1),u=Math.floor((o-c)/864e5)+1,p=a.hour%12===0?12:a.hour%12;let h="",f=0;for(;f<i.length;){const d=i[f];if(d==="'"){if(i[f+1]==="'"){h+="'",f+=2;continue}const m=i.indexOf("'",f+1);if(m===-1){h+=i.substring(f+1);break}h+=i.substring(f+1,m),f=m+1;continue}if(d>="a"&&d<="z"||d>="A"&&d<="Z"){let m=1;for(;i[f+m]===d;)m++;switch(f+=m,d){case"y":h+=m===2?Ve(a.year%100,2):m>=4?Ve(a.year,4):String(a.year);break;case"M":m>=4?h+=Jf[a.month-1]:m===3?h+=Qf[a.month-1]:m===2?h+=Ve(a.month,2):h+=String(a.month);break;case"d":h+=m===2?Ve(a.day,2):String(a.day);break;case"D":h+=m>=3?Ve(u,3):m===2?Ve(u,2):String(u);break;case"E":h+=m>=4?td[a.dayOfWeek]:ed[a.dayOfWeek];break;case"a":h+=a.hour<12?"AM":"PM";break;case"h":h+=m===2?Ve(p,2):String(p);break;case"H":h+=m===2?Ve(a.hour,2):String(a.hour);break;case"m":h+=m===2?Ve(a.minute,2):String(a.minute);break;case"s":h+=m===2?Ve(a.second,2):String(a.second);break;case"S":{const x=n-Math.floor(n/1e3)*1e3;h+=Ve(x,3).substring(0,m);break}case"Z":{const x=l>=0?"+":"-",b=Math.abs(l);h+=`${x}${Ve(Math.floor(b/60),2)}${Ve(b%60,2)}`;break}default:h+=d.repeat(m)}continue}h+=d,f++}return h}format(e,...i){return e.replace(/\{(\d+)(?:,number,([^}]+))?\}/g,(r,n,s)=>{const a=i[n];return s&&typeof a=="number"&&!isNaN(a)?this.tostring(a,s):String(a)})}}var rd=Object.defineProperty,nd=(t,e,i)=>e in t?rd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,sd=(t,e,i)=>nd(t,typeof e!="symbol"?e+"":e,i);const ki={"1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1M":"M"};function yn(t){if(!t||/^\d+$/.test(t))return t;if(ki[t])return ki[t];const e=t.toLowerCase();if(ki[e])return ki[e];if(t.length===1){const r=t.toUpperCase();if(["D","W","M","S"].includes(r))return r}const i=t.slice(-1).toUpperCase();if(["D","W","M","S"].includes(i)){const r=parseInt(t);if(!isNaN(r))return r+i}return t}class ad{constructor(e){this.context=e,sd(this,"_normalized",null)}param(e,i=0,r){return y.from(e).get(i)}get normalized(){return this._normalized===null&&(this._normalized=yn(this.context.timeframe)),this._normalized}get unit(){return this.normalized.slice(-1).toUpperCase()}get main_period(){return this.normalized}get period(){return this.normalized}get multiplier(){const e=parseInt(this.normalized);return isNaN(e)?1:e}get isdwm(){return["D","W","M"].includes(this.unit)}get isdaily(){return this.unit==="D"}get isweekly(){return this.unit==="W"}get ismonthly(){return this.unit==="M"}get isseconds(){return this.unit==="S"}get isminutes(){return/^\d+$/.test(this.normalized)}get isintraday(){return!this.isdwm}change(e){const i=typeof e=="function"?e():e,r=i instanceof y?i.get(0):i,n=vr(r||"");if(!n)return!1;const s=y.from(this.context.data.openTime).get(0),a=y.from(this.context.data.openTime).get(1);if(isNaN(s)||isNaN(a))return!1;const o=wr(s,n),l=wr(a,n);return o!==l}from_seconds(e){return e<60?Math.ceil(e/5)*5+"S":e<3600*24?Math.ceil(e/60):e<=3600*24*7*52?e%(3600*24*7)===0?Math.ceil(e/604800)+"W":Math.ceil(e/(3600*24))+"D":"12M"}in_seconds(e){e==null?e=this.normalized:e=yn(e);const i=e.slice(-1).toUpperCase(),r=parseInt(e);return i==="S"?isNaN(r)?1:r:i==="D"?(isNaN(r)?1:r)*60*60*24:i==="W"?(isNaN(r)?1:r)*60*60*24*7:i==="M"?(isNaN(r)?1:r)*60*60*24*30:isNaN(r)?0:r*60}}var od=Object.defineProperty,ld=Object.getOwnPropertyDescriptor,at=(t,e,i,r)=>{for(var n=r>1?void 0:r?ld(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&od(e,i,n),n};const cd=["series","title","color","linewidth","style","trackprice","histbase","offset","join","editable","show_last","display","format","precision","force_overlay"],ud=["series","title","char","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],hd={series:"series",title:"string",char:"string",location:"string",color:"color",offset:"number",text:"string",textcolor:"color",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},pd=["series","title","style","location","color","offset","text","textcolor","editable","size","show_last","display","format","precision","force_overlay"],fd=["series","title","colorup","colordown","offset","minheight","maxheight","editable","show_last","display","format","precision","force_overlay"],dd=["open","high","low","close","title","color","editable","show_last","display","format","precision","force_overlay"],md=["open","high","low","close","title","color","wickcolor","editable","show_last","bordercolor","display","format","precision","force_overlay"],_n=["color","offset","editable","show_last","title","display","force_overlay"],yd=["price","title","color","linestyle","linewidth","editable","display"],_d=["plot1","plot2","color","title","editable","show_last","fillgaps","display"],gd={series:"series",title:"string",color:"color",linewidth:"number",style:"string",trackprice:"boolean",histbase:"number",offset:"number",join:"bool",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},xd={series:"series",title:"string",style:"string",location:"string",color:"color",offset:"number",text:"string",textcolor:"color",editable:"boolean",size:"string",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},bd={series:"series",title:"string",colorup:"color",colordown:"color",offset:"number",minheight:"number",maxheight:"number",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},vd={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},wd={open:"series",high:"series",low:"series",close:"series",title:"string",color:"color",wickcolor:"color",bordercolor:"color",editable:"boolean",show_last:"number",display:"string",format:"string",precision:"number",force_overlay:"boolean"},gn={color:"color",offset:"number",editable:"boolean",show_last:"number",title:"string",display:"string",force_overlay:"boolean"},Sd={price:"series",title:"string",color:"color",linestyle:"string",linewidth:"number",editable:"boolean",display:"string"},Ed={plot1:"object",plot2:"object",color:"color",title:"string",editable:"boolean",show_last:"number",fillgaps:"boolean",display:"string"};class yt{constructor(e){this.context=e}_resolvePlotKey(e,i){if(e){const r=this.context.plots[e];return!r||!i||r._callsiteId===i?e:e+i}return i||"plot"}extractPlotOptions(e){const i={};for(let r in e)i[r]=y.from(e[r]).get(0);return i}get linestyle_dashed(){return"linestyle_dashed"}get linestyle_dotted(){return"linestyle_dotted"}get linestyle_solid(){return"linestyle_solid"}get style_area(){return"style_area"}get style_areabr(){return"style_areabr"}get style_circles(){return"style_circles"}get style_columns(){return"style_columns"}get style_cross(){return"style_cross"}get style_histogram(){return"style_histogram"}get style_line(){return"style_line"}get style_linebr(){return"style_linebr"}get style_stepline(){return"style_stepline"}get style_stepline_diamond(){return"style_stepline_diamond"}get style_steplinebr(){return"style_steplinebr"}param(e,i=0,r){return y.from(e).get(i)}plotchar(...e){const i=et(e),r=te(e,ud,hd),{series:n,title:s,...a}=r,o=this.extractPlotOptions(a),l=this._resolvePlotKey(s,i);this.context.plots[l]||(this.context.plots[l]={data:[],options:{...o,style:"char"},title:s,_plotKey:l,_callsiteId:i});const c=y.from(n).get(0);return this.context.plots[l].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:c,options:{char:o.char,color:o.color,textcolor:o.textcolor,location:o.location,size:o.size,offset:o.offset}}),this.context.plots[l]}any(...e){const i=et(e),r=te(e,cd,gd),{series:n,title:s,...a}=r,o=this.extractPlotOptions(a),l=this._resolvePlotKey(s,i),c="color"in a;if(!this.context.plots[l]){const f=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,overlay:f},title:s,_plotKey:l,_callsiteId:i}}const u=y.from(n).get(0);let p=o.color;typeof p=="function"&&(p=p());const h={color:c?typeof p=="string"?p:void 0:p||"#2962ff"};return"offset"in a&&(h.offset=o.offset),this.context.plots[l].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:u,options:h}),this.context.plots[l]}plotshape(...e){const i=et(e),r=te(e,pd,xd),{series:n,title:s,...a}=r,o=this.extractPlotOptions(a),l=this._resolvePlotKey(s,i);if(!this.context.plots[l]){const u=o.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[l]={data:[],options:{...o,style:"shape",shape:o.style,overlay:u},title:s,_plotKey:l,_callsiteId:i}}const c=y.from(n).get(0);return this.context.plots[l].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:c,options:o?.location==="absolute"||c?{text:o.text,textcolor:o.textcolor,color:o.color,offset:o.offset,shape:o.style,location:o.location,size:o.size}:void 0}),this.context.plots[l]}plotarrow(...e){const i=et(e),r=te(e,fd,bd),{series:n,title:s,...a}=r,o=y.from(n).get(0),l=this.extractPlotOptions(a),c=this._resolvePlotKey(s,i);if(!this.context.plots[c]){const u=l.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[c]={data:[],options:{...l,style:"shape",overlay:u},title:s,_plotKey:c,_callsiteId:i}}return this.context.plots[c].data.push({title:s,time:this.context.marketData[this.context.idx].openTime,value:o,options:typeof o=="number"&&!isNaN(o)&&o!==0?{text:void 0,textcolor:void 0,color:o>0?l.colorup:l.colordown,offset:l.offset,shape:o>0?"shape_arrow_up":"shape_arrow_down",location:o>0?"BelowBar":"AboveBar",height:l.maxheight}:void 0}),this.context.plots[c]}plotbar(...e){const i=et(e),r=te(e,dd,vd),{open:n,high:s,low:a,close:o,title:l,...c}=r,u=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"bar",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const h=[y.from(n).get(0),y.from(s).get(0),y.from(a).get(0),y.from(o).get(0)];this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color}})}plotcandle(...e){const i=et(e),r=te(e,md,wd),{open:n,high:s,low:a,close:o,title:l,...c}=r,u=this.extractPlotOptions(c),p=this._resolvePlotKey(l,i);if(!this.context.plots[p]){const f=u.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[p]={data:[],options:{...u,style:"candle",overlay:f},title:l,_plotKey:p,_callsiteId:i}}const h=[y.from(n).get(0),y.from(s).get(0),y.from(a).get(0),y.from(o).get(0)];return this.context.plots[p].data.push({title:l,time:this.context.marketData[this.context.idx].openTime,value:h,options:{color:u.color,wickcolor:u.wickcolor,bordercolor:u.bordercolor}}),this.context.plots[p]}bgcolor(...e){const i=et(e),r=te(e,_n,gn),{title:n,...s}=r,a=this.extractPlotOptions(s),o=this._resolvePlotKey(n,i);if(!this.context.plots[o]){const l=a.force_overlay??(this.context?.indicator?.overlay||!1);this.context.plots[o]={data:[],options:{...a,style:"background",overlay:l},title:n,_plotKey:o,_callsiteId:i}}this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:a.color&&a.color!=="na"&&a?.color.toString()!=="NaN",options:{color:a.color}})}barcolor(...e){const i=et(e),r=te(e,_n,gn),{title:n,...s}=r,a=this.extractPlotOptions(s),o=this._resolvePlotKey(n,i);return this.context.plots[o]||(this.context.plots[o]={data:[],options:{...a,style:"barcolor"},title:n,_plotKey:o,_callsiteId:i}),this.context.plots[o].data.push({title:n,time:this.context.marketData[this.context.idx].openTime,value:a.color&&a.color!=="na"&&a?.color.toString()!=="NaN",options:{color:a.color}}),this.context.plots[o]}}at([C],yt.prototype,"plotchar",1),at([C],yt.prototype,"any",1),at([C],yt.prototype,"plotshape",1),at([C],yt.prototype,"plotarrow",1),at([C],yt.prototype,"plotbar",1),at([C],yt.prototype,"plotcandle",1),at([C],yt.prototype,"bgcolor",1),at([C],yt.prototype,"barcolor",1);class Ps{constructor(e){this.context=e}get style_dashed(){return"dashed"}get style_solid(){return"solid"}get style_dotted(){return"dotted"}param(e,i=0,r){return y.from(e).get(i)}any(...e){const i=et(e),r=te(e,yd,Sd),{price:n,title:s,color:a,linestyle:o,linewidth:l,editable:c,display:u}=r,p=[n,{title:s,color:a,linestyle:o,linewidth:l,editable:c,display:u,style:"hline"}];return i&&p.push({__callsiteId:i}),this.context.pine.plot.any(...p)}}at([C],Ps.prototype,"any",1);class Ds{constructor(e){this.context=e}param(e,i=0,r){return y.from(e).get(i)}any(...e){const i=et(e),r=e.length>=6&&typeof e[2]=="number",n=!r&&e.length>=3&&e[2]!==null&&typeof e[2]=="object"&&"top_value"in e[2]?e[2]:null;if(r||n!==null){const s=e[0],a=e[1],o=n?y.from(n.top_value).get(0):e[2],l=n?y.from(n.bottom_value).get(0):e[3],c=n?y.from(n.top_color).get(0):e[4],u=n?y.from(n.bottom_color).get(0):e[5],p=n?n.title||void 0:e.length>6&&typeof e[6]=="string"?e[6]:void 0,h=s?._plotKey||s?.title,f=a?._plotKey||a?.title;let d=p||"fill";const m=this.context.plots[d];m&&i&&m._callsiteId!==i&&(d=i),this.context.plots[d]||(this.context.plots[d]={title:p||"Fill",plot1:h,plot2:f,data:[],options:{plot1:h,plot2:f,style:"fill",gradient:!0},_plotKey:d,_callsiteId:i}),this.context.plots[d].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{top_value:o,bottom_value:l,top_color:c,bottom_color:u}})}else{const s=te(e,_d,Ed),{plot1:a,plot2:o,color:l,title:c,editable:u,show_last:p,fillgaps:h,display:f}=s;let d=c||"fill";const m=this.context.plots[d];m&&i&&m._callsiteId!==i&&(d=i);const x=y.from(l).get(0);if(!this.context.plots[d]){const b=a?._plotKey||a?.title,v=o?._plotKey||o?.title;this.context.plots[d]={title:c||"Fill",plot1:b,plot2:v,data:[],options:{plot1:b,plot2:v,color:x,editable:u,show_last:p,fillgaps:h,display:f,style:"fill"},_plotKey:d,_callsiteId:i}}this.context.plots[d].data.push({time:this.context.marketData[this.context.idx].openTime,value:null,options:{color:x}})}}}at([C],Ds.prototype,"any",1);var Nd=Object.defineProperty,Cd=(t,e,i)=>e in t?Nd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Id=(t,e,i)=>Cd(t,typeof e!="symbol"?e+"":e,i);class kd{constructor(e){this.context=e,Id(this,"point");const i=this.context;this.point={new(r,n,s){return new Ie(r,n,s??NaN)},from_index(r,n){return new Ie(void 0,r,n)},from_time(r,n){return new Ie(r,void 0,n)},copy(r){return r.copy()},now(r){const n=i.idx,s=i.marketData[n]?.openTime;return new Ie(s,n,r)}}}param(e,i=0,r){return y.from(e).get(i)}bg_color(){return"#1e293b"}fg_color(){return"#d1d4dc"}is_standard(){return!0}is_heikinashi(){return!1}is_kagi(){return!1}is_linebreak(){return!1}is_pnf(){return!1}is_range(){return!1}is_renko(){return!1}}var Td=Object.defineProperty,Ad=(t,e,i)=>e in t?Td(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ge=(t,e,i)=>Ad(t,typeof e!="symbol"?e+"":e,i);let Pd=0;class pi{constructor(e,i,r="",n="bi",s="pr",a="",o="style_label_down",l="",c="normal",u="center",p="",h="default",f=!1){ge(this,"id"),ge(this,"x"),ge(this,"y"),ge(this,"text"),ge(this,"xloc"),ge(this,"yloc"),ge(this,"color"),ge(this,"style"),ge(this,"textcolor"),ge(this,"size"),ge(this,"textalign"),ge(this,"tooltip"),ge(this,"text_font_family"),ge(this,"force_overlay"),ge(this,"_deleted"),ge(this,"_helper"),ge(this,"_createdAtBar",-1),this.id=Pd++,this.x=e,this.y=i,this.text=r,this.xloc=n,this.yloc=s,this.color=a,this.style=o,this.textcolor=l,this.size=c,this.textalign=u,this.tooltip=p,this.text_font_family=h,this.force_overlay=f,this._deleted=!1,this._helper=null}set_x(e){this._helper?this._helper.set_x(this,e):this._deleted||(this.x=e)}set_y(e){this._helper?this._helper.set_y(this,e):this._deleted||(this.y=e)}set_xy(e,i){this._helper?this._helper.set_xy(this,e,i):this._deleted||(this.x=e,this.y=i)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_textcolor(e){this._helper?this._helper.set_textcolor(this,e):this._deleted||(this.textcolor=e)}set_size(e){this._helper?this._helper.set_size(this,e):this._deleted||(this.size=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_textalign(e){this._helper?this._helper.set_textalign(this,e):this._deleted||(this.textalign=e)}set_tooltip(e){this._helper?this._helper.set_tooltip(this,e):this._deleted||(this.tooltip=e)}set_xloc(e){this._helper?this._helper.set_xloc(this,e):this._deleted||(this.xloc=e)}set_yloc(e){this._helper?this._helper.set_yloc(this,e):this._deleted||(this.yloc=e)}set_point(e){this._helper&&this._helper.set_point(this,e)}set_text_font_family(e){this._deleted||(this.text_font_family=e)}get_x(){return this.x}get_y(){return this.y}get_text(){return this.text}delete(){this._deleted=!0}copy(){return new pi(this.x,this.y,this.text,this.xloc,this.yloc,this.color,this.style,this.textcolor,this.size,this.textalign,this.tooltip,this.text_font_family,this.force_overlay)}toPlotData(){return{id:this.id,x:this.x,y:this.y,text:this.text,xloc:this.xloc,yloc:this.yloc,color:this.color,style:this.style,textcolor:this.textcolor,size:this.size,textalign:this.textalign,tooltip:this.tooltip,text_font_family:this.text_font_family,force_overlay:this.force_overlay,_deleted:this._deleted}}}var Ms=Object.defineProperty,Dd=Object.getOwnPropertyDescriptor,Md=(t,e,i)=>e in t?Ms(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ve=(t,e,i,r)=>{for(var n=r>1?void 0:r?Dd(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Ms(e,i,n),n},Rd=(t,e,i)=>Md(t,typeof e!="symbol"?e+"":e,i);const Od=[["x","y","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"],["point","text","xloc","yloc","color","style","textcolor","size","textalign","tooltip","text_font_family","force_overlay"]],$d={x:"number",y:"number",text:"string",xloc:"string",yloc:"string",color:"color",style:"string",textcolor:"color",size:"string",textalign:"string",tooltip:"string",text_font_family:"string",force_overlay:"boolean",point:"point"};class xe{constructor(e){this.context=e,Rd(this,"_labels",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__labels__||(this.context.plots.__labels__={title:"__labels__",data:[],options:{style:"label",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._labels.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__labels__.data=[{time:e,value:r,options:{style:"label"}}],n.length>0?this.context.plots.__labels_overlay__={title:"__labels_overlay__",data:[{time:e,value:n,options:{style:"label"}}],options:{style:"label",overlay:!0}}:delete this.context.plots.__labels_overlay__}_resolve(e){if(e==null)return e;if(e instanceof Re)return null;if(typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"){const i=e.get(0);return typeof i=="number"&&isNaN(i)?null:i}return typeof e=="function"?e():typeof e=="number"&&isNaN(e)?null:e}_createLabel(e,i,r="",n="bi",s="pr",a="",o="style_label_down",l="",c="normal",u="center",p="",h="default",f=!1){const d=new pi(e,i,this._resolve(r),this._resolve(n),this._resolve(s),this._resolve(a),this._resolve(o),this._resolve(l),this._resolve(c),this._resolve(u),this._resolve(p),this._resolve(h),f);return d._helper=this,d._createdAtBar=this.context.idx,this._labels.push(d),this._enforceMaxCount(),this.syncToPlot(),d}_enforceMaxCount(){const e=this.context.indicator?.max_labels_count??50,i=this._labels.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._labels){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}new(...e){const i=te(e,Od,$d);let r,n,s=i.xloc;if(i.point instanceof Ie){const a=i.point,o=a.index!==void 0&&!(typeof a.index=="number"&&isNaN(a.index)),l=a.time!==void 0&&!(typeof a.time=="number"&&isNaN(a.time));o?(r=a.index,s=s||"bi"):l?(r=a.time,s=s||"bt"):(r=0,s=s||"bi"),n=a.price}else r=i.x,n=i.y;return this._createLabel(r,n,i.text,s,i.yloc,i.color,i.style,i.textcolor,i.size,i.textalign,i.tooltip,i.text_font_family,i.force_overlay)}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof pi)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof pi)return r}return null}return this.new(...e)}set_x(e,i){e&&!e._deleted&&(e.x=i)}set_y(e,i){e&&!e._deleted&&(e.y=i)}set_xy(e,i,r){e&&!e._deleted&&(e.x=i,e.y=r)}set_text(e,i){e&&!e._deleted&&(e.text=i)}set_color(e,i){e&&!e._deleted&&(e.color=i)}set_textcolor(e,i){e&&!e._deleted&&(e.textcolor=i)}set_size(e,i){e&&!e._deleted&&(e.size=i)}set_style(e,i){e&&!e._deleted&&(e.style=i)}set_textalign(e,i){e&&!e._deleted&&(e.textalign=i)}set_tooltip(e,i){e&&!e._deleted&&(e.tooltip=i)}set_xloc(e,i){e&&!e._deleted&&(e.xloc=i)}set_yloc(e,i){e&&!e._deleted&&(e.yloc=i)}set_point(e,i){if(e&&!e._deleted&&i){const r=i.index!==void 0&&!(typeof i.index=="number"&&isNaN(i.index)),n=i.time!==void 0&&!(typeof i.time=="number"&&isNaN(i.time));r?(e.x=i.index,e.xloc="bi"):n&&(e.x=i.time,e.xloc="bt"),e.y=i.price}}get_x(e){return e?e.x:NaN}get_y(e){return e?e.y:NaN}get_text(e){return e?e.text:""}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._labels.push(i),this._enforceMaxCount(),this.syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._labels.filter(e=>!e._deleted)}rollbackFromBar(e){this._labels=this._labels.filter(i=>i._createdAtBar<e),this.syncToPlot()}get style_label_down(){return"style_label_down"}get style_label_up(){return"style_label_up"}get style_label_left(){return"style_label_left"}get style_label_right(){return"style_label_right"}get style_label_lower_left(){return"style_label_lower_left"}get style_label_lower_right(){return"style_label_lower_right"}get style_label_upper_left(){return"style_label_upper_left"}get style_label_upper_right(){return"style_label_upper_right"}get style_label_center(){return"style_label_center"}get style_circle(){return"style_circle"}get style_square(){return"style_square"}get style_diamond(){return"style_diamond"}get style_flag(){return"style_flag"}get style_arrowup(){return"style_arrowup"}get style_arrowdown(){return"style_arrowdown"}get style_cross(){return"style_cross"}get style_xcross(){return"style_xcross"}get style_triangleup(){return"style_triangleup"}get style_triangledown(){return"style_triangledown"}get style_none(){return"style_none"}get style_text_outline(){return"style_text_outline"}}ve([C],xe.prototype,"new",1),ve([C],xe.prototype,"set_x",1),ve([C],xe.prototype,"set_y",1),ve([C],xe.prototype,"set_xy",1),ve([C],xe.prototype,"set_text",1),ve([C],xe.prototype,"set_color",1),ve([C],xe.prototype,"set_textcolor",1),ve([C],xe.prototype,"set_size",1),ve([C],xe.prototype,"set_style",1),ve([C],xe.prototype,"set_textalign",1),ve([C],xe.prototype,"set_tooltip",1),ve([C],xe.prototype,"set_xloc",1),ve([C],xe.prototype,"set_yloc",1),ve([C],xe.prototype,"set_point",1),ve([C],xe.prototype,"copy",1),ve([C],xe.prototype,"delete",1);var Vd=Object.defineProperty,jd=(t,e,i)=>e in t?Vd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pe=(t,e,i)=>jd(t,typeof e!="symbol"?e+"":e,i);let Ld=0;class fi{constructor(e,i,r,n,s="bi",a="none",o="",l="style_solid",c=1,u=!1){Pe(this,"id"),Pe(this,"x1"),Pe(this,"y1"),Pe(this,"x2"),Pe(this,"y2"),Pe(this,"xloc"),Pe(this,"extend"),Pe(this,"color"),Pe(this,"style"),Pe(this,"width"),Pe(this,"force_overlay"),Pe(this,"_deleted"),Pe(this,"_helper"),Pe(this,"_createdAtBar",-1),this.id=Ld++,this.x1=e,this.y1=i,this.x2=r,this.y2=n,this.xloc=s,this.extend=a,this.color=o,this.style=l,this.width=c,this.force_overlay=u,this._deleted=!1,this._helper=null}set_x1(e){this._helper?this._helper.set_x1(this,e):this._deleted||(this.x1=e)}set_y1(e){this._helper?this._helper.set_y1(this,e):this._deleted||(this.y1=e)}set_x2(e){this._helper?this._helper.set_x2(this,e):this._deleted||(this.x2=e)}set_y2(e){this._helper?this._helper.set_y2(this,e):this._deleted||(this.y2=e)}set_xy1(e,i){this._helper?this._helper.set_xy1(this,e,i):this._deleted||(this.x1=e,this.y1=i)}set_xy2(e,i){this._helper?this._helper.set_xy2(this,e,i):this._deleted||(this.x2=e,this.y2=i)}set_color(e){this._helper?this._helper.set_color(this,e):this._deleted||(this.color=e)}set_width(e){this._helper?this._helper.set_width(this,e):this._deleted||(this.width=e)}set_style(e){this._helper?this._helper.set_style(this,e):this._deleted||(this.style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.x1=e,this.x2=i,this.xloc=r)}set_first_point(e){this._helper&&this._helper.set_first_point(this,e)}set_second_point(e){this._helper&&this._helper.set_second_point(this,e)}get_x1(){return this.x1}get_y1(){return this.y1}get_x2(){return this.x2}get_y2(){return this.y2}get_price(e){return this._helper?this._helper.get_price(this,e):NaN}delete(){this._deleted=!0}copy(){return new fi(this.x1,this.y1,this.x2,this.y2,this.xloc,this.extend,this.color,this.style,this.width,this.force_overlay)}toPlotData(){return{id:this.id,x1:this.x1,y1:this.y1,x2:this.x2,y2:this.y2,xloc:this.xloc,extend:this.extend,color:this.color,style:this.style,width:this.width,force_overlay:this.force_overlay,_deleted:this._deleted}}}var Rs=Object.defineProperty,Bd=Object.getOwnPropertyDescriptor,Fd=(t,e,i)=>e in t?Rs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,we=(t,e,i,r)=>{for(var n=r>1?void 0:r?Bd(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Rs(e,i,n),n},Wd=(t,e,i)=>Fd(t,typeof e!="symbol"?e+"":e,i);const Ud=[["x1","y1","x2","y2","xloc","extend","color","style","width","force_overlay"],["first_point","second_point","xloc","extend","color","style","width","force_overlay"]],qd={x1:"number",y1:"number",x2:"number",y2:"number",xloc:"string",extend:"string",color:"color",style:"string",width:"number",force_overlay:"boolean",first_point:"point",second_point:"point"};class be{constructor(e){this.context=e,Wd(this,"_lines",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__lines__||(this.context.plots.__lines__={title:"__lines__",data:[],options:{style:"drawing_line",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._lines.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__lines__.data=[{time:e,value:r,options:{style:"drawing_line"}}],n.length>0?this.context.plots.__lines_overlay__={title:"__lines_overlay__",data:[{time:e,value:n,options:{style:"drawing_line"}}],options:{style:"drawing_line",overlay:!0}}:delete this.context.plots.__lines_overlay__}_resolvePoint(e){const i=e.index!==void 0&&!(typeof e.index=="number"&&isNaN(e.index)),r=e.time!==void 0&&!(typeof e.time=="number"&&isNaN(e.time));return i?{x:e.index,xloc:"bi"}:r?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e){const i=this._resolve(e);return i==null?i:typeof i=="number"&&isNaN(i)?NaN:i}_createLine(e,i,r,n,s="bi",a="none",o="",l="style_solid",c=1,u=!1){const p=new fi(e,i,r,n,s,this._resolve(a),this._resolveColor(o),this._resolve(l),this._resolve(c)||1,u);return p._helper=this,p._createdAtBar=this.context.idx,this._lines.push(p),this._enforceMaxCount(),this.syncToPlot(),p}_enforceMaxCount(){const e=this.context.indicator?.max_lines_count??50,i=this._lines.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._lines){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}new(...e){const i=te(e,Ud,qd);let r,n,s,a,o=i.xloc;if(i.first_point instanceof Ie){const l=i.first_point,c=i.second_point,u=this._resolvePoint(l);r=u.x,n=l.price,o=o||u.xloc,c instanceof Ie?(s=this._resolvePoint(c).x,a=c.price):(s=0,a=NaN)}else r=i.x1,n=i.y1,s=i.x2,a=i.y2;return this._createLine(r,n,s,a,o,i.extend,i.color,i.style,i.width,i.force_overlay)}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof fi)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof fi)return r}return null}return this.new(...e)}set_x1(e,i){e&&!e._deleted&&(e.x1=this._resolve(i))}set_y1(e,i){e&&!e._deleted&&(e.y1=this._resolve(i))}set_x2(e,i){e&&!e._deleted&&(e.x2=this._resolve(i))}set_y2(e,i){e&&!e._deleted&&(e.y2=this._resolve(i))}set_xy1(e,i,r){e&&!e._deleted&&(e.x1=this._resolve(i),e.y1=this._resolve(r))}set_xy2(e,i,r){e&&!e._deleted&&(e.x2=this._resolve(i),e.y2=this._resolve(r))}set_color(e,i){e&&!e._deleted&&(e.color=this._resolveColor(i))}set_width(e,i){e&&!e._deleted&&(e.width=this._resolve(i)||1)}set_style(e,i){e&&!e._deleted&&(e.style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_xloc(e,i,r,n){e&&!e._deleted&&(e.x1=i,e.x2=r,e.xloc=n)}set_first_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x1=r.x,e.y1=i.price,e.xloc=r.xloc}}set_second_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.x2=r.x,e.y2=i.price,e.xloc=r.xloc}}get_x1(e){return e?e.x1:NaN}get_y1(e){return e?e.y1:NaN}get_x2(e){return e?e.x2:NaN}get_y2(e){return e?e.y2:NaN}get_price(e,i){if(!e||e._deleted)return NaN;if(e.xloc!=="bi")return NaN;const r=e.x2-e.x1;return r===0?e.y1:e.y1+(i-e.x1)/r*(e.y2-e.y1)}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._lines.push(i),this._enforceMaxCount(),this.syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._lines.filter(e=>!e._deleted)}rollbackFromBar(e){this._lines=this._lines.filter(i=>i._createdAtBar<e),this.syncToPlot()}get style_solid(){return"style_solid"}get style_dotted(){return"style_dotted"}get style_dashed(){return"style_dashed"}get style_arrow_left(){return"style_arrow_left"}get style_arrow_right(){return"style_arrow_right"}get style_arrow_both(){return"style_arrow_both"}}we([C],be.prototype,"new",1),we([C],be.prototype,"set_x1",1),we([C],be.prototype,"set_y1",1),we([C],be.prototype,"set_x2",1),we([C],be.prototype,"set_y2",1),we([C],be.prototype,"set_xy1",1),we([C],be.prototype,"set_xy2",1),we([C],be.prototype,"set_color",1),we([C],be.prototype,"set_width",1),we([C],be.prototype,"set_style",1),we([C],be.prototype,"set_extend",1),we([C],be.prototype,"set_xloc",1),we([C],be.prototype,"set_first_point",1),we([C],be.prototype,"set_second_point",1),we([C],be.prototype,"copy",1),we([C],be.prototype,"delete",1);var zd=Object.defineProperty,Kd=(t,e,i)=>e in t?zd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ne=(t,e,i)=>Kd(t,typeof e!="symbol"?e+"":e,i);let Hd=0;class di{constructor(e,i,r,n,s="bi",a="none",o="#2962ff",l="style_solid",c=1,u="#2962ff",p="",h="#000000",f="auto",d="center",m="center",x="wrap_none",b="default",v="format_none",w=!1){ne(this,"id"),ne(this,"left"),ne(this,"top"),ne(this,"right"),ne(this,"bottom"),ne(this,"xloc"),ne(this,"extend"),ne(this,"border_color"),ne(this,"border_style"),ne(this,"border_width"),ne(this,"bgcolor"),ne(this,"text"),ne(this,"text_color"),ne(this,"text_size"),ne(this,"text_halign"),ne(this,"text_valign"),ne(this,"text_wrap"),ne(this,"text_font_family"),ne(this,"text_formatting"),ne(this,"force_overlay"),ne(this,"_deleted"),ne(this,"_helper"),ne(this,"_createdAtBar",-1),this.id=Hd++,this.left=e,this.top=i,this.right=r,this.bottom=n,this.xloc=s,this.extend=a,this.border_color=o,this.border_style=l,this.border_width=c,this.bgcolor=u,this.text=p,this.text_color=h,this.text_size=f,this.text_halign=d,this.text_valign=m,this.text_wrap=x,this.text_font_family=b,this.text_formatting=v,this.force_overlay=w,this._deleted=!1,this._helper=null}set_left(e){this._helper?this._helper.set_left(this,e):this._deleted||(this.left=e)}set_right(e){this._helper?this._helper.set_right(this,e):this._deleted||(this.right=e)}set_top(e){this._helper?this._helper.set_top(this,e):this._deleted||(this.top=e)}set_bottom(e){this._helper?this._helper.set_bottom(this,e):this._deleted||(this.bottom=e)}set_lefttop(e,i){this._helper?this._helper.set_lefttop(this,e,i):this._deleted||(this.left=e,this.top=i)}set_rightbottom(e,i){this._helper?this._helper.set_rightbottom(this,e,i):this._deleted||(this.right=e,this.bottom=i)}set_top_left_point(e){this._helper&&this._helper.set_top_left_point(this,e)}set_bottom_right_point(e){this._helper&&this._helper.set_bottom_right_point(this,e)}set_xloc(e,i,r){this._helper?this._helper.set_xloc(this,e,i,r):this._deleted||(this.left=e,this.right=i,this.xloc=r)}set_bgcolor(e){this._helper?this._helper.set_bgcolor(this,e):this._deleted||(this.bgcolor=e)}set_border_color(e){this._helper?this._helper.set_border_color(this,e):this._deleted||(this.border_color=e)}set_border_width(e){this._helper?this._helper.set_border_width(this,e):this._deleted||(this.border_width=e)}set_border_style(e){this._helper?this._helper.set_border_style(this,e):this._deleted||(this.border_style=e)}set_extend(e){this._helper?this._helper.set_extend(this,e):this._deleted||(this.extend=e)}set_text(e){this._helper?this._helper.set_text(this,e):this._deleted||(this.text=e)}set_text_color(e){this._helper?this._helper.set_text_color(this,e):this._deleted||(this.text_color=e)}set_text_size(e){this._helper?this._helper.set_text_size(this,e):this._deleted||(this.text_size=e)}set_text_halign(e){this._helper?this._helper.set_text_halign(this,e):this._deleted||(this.text_halign=e)}set_text_valign(e){this._helper?this._helper.set_text_valign(this,e):this._deleted||(this.text_valign=e)}set_text_wrap(e){this._helper?this._helper.set_text_wrap(this,e):this._deleted||(this.text_wrap=e)}set_text_font_family(e){this._helper?this._helper.set_text_font_family(this,e):this._deleted||(this.text_font_family=e)}set_text_formatting(e){this._helper?this._helper.set_text_formatting(this,e):this._deleted||(this.text_formatting=e)}get_left(){return this.left}get_right(){return this.right}get_top(){return this.top}get_bottom(){return this.bottom}delete(){this._deleted=!0}toPlotData(){return{id:this.id,left:this.left,top:this.top,right:this.right,bottom:this.bottom,xloc:this.xloc,extend:this.extend,border_color:this.border_color,border_style:this.border_style,border_width:this.border_width,bgcolor:this.bgcolor,text:this.text,text_color:this.text_color,text_size:this.text_size,text_halign:this.text_halign,text_valign:this.text_valign,text_wrap:this.text_wrap,text_font_family:this.text_font_family,text_formatting:this.text_formatting,force_overlay:this.force_overlay,_deleted:this._deleted}}copy(){return new di(this.left,this.top,this.right,this.bottom,this.xloc,this.extend,this.border_color,this.border_style,this.border_width,this.bgcolor,this.text,this.text_color,this.text_size,this.text_halign,this.text_valign,this.text_wrap,this.text_font_family,this.text_formatting,this.force_overlay)}}var Os=Object.defineProperty,Gd=Object.getOwnPropertyDescriptor,Yd=(t,e,i)=>e in t?Os(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,ie=(t,e,i,r)=>{for(var n=r>1?void 0:r?Gd(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Os(e,i,n),n},Xd=(t,e,i)=>Yd(t,typeof e!="symbol"?e+"":e,i);const Zd=[["left","top","right","bottom","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"],["top_left","bottom_right","border_color","border_width","border_style","extend","xloc","bgcolor","text","text_size","text_color","text_halign","text_valign","text_wrap","text_font_family","force_overlay"]],Qd={left:"number",top:"number",right:"number",bottom:"number",top_left:"point",bottom_right:"point",border_color:"color",border_width:"number",border_style:"string",extend:"string",xloc:"string",bgcolor:"color",text:"string",text_size:"string",text_color:"color",text_halign:"string",text_valign:"string",text_wrap:"string",text_font_family:"string",force_overlay:"boolean"};class ee{constructor(e){this.context=e,Xd(this,"_boxes",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__boxes__||(this.context.plots.__boxes__={title:"__boxes__",data:[],options:{style:"drawing_box",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._boxes.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__boxes__.data=[{time:e,value:r,options:{style:"drawing_box"}}],n.length>0?this.context.plots.__boxes_overlay__={title:"__boxes_overlay__",data:[{time:e,value:n,options:{style:"drawing_box"}}],options:{style:"drawing_box",overlay:!0}}:delete this.context.plots.__boxes_overlay__}_resolvePoint(e){const i=e.index!==void 0&&!(typeof e.index=="number"&&isNaN(e.index)),r=e.time!==void 0&&!(typeof e.time=="number"&&isNaN(e.time));return i?{x:e.index,xloc:"bi"}:r?{x:e.time,xloc:"bt"}:{x:0,xloc:"bi"}}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return r==null?r:typeof r=="number"&&isNaN(r)?NaN:r||i}_createBox(e,i,r,n,s="bi",a="none",o="#2962ff",l="style_solid",c=1,u="#2962ff",p="",h="#000000",f="auto",d="center",m="center",x="wrap_none",b="default",v="format_none",w=!1){const S=new di(e,i,r,n,s,this._resolve(a),this._resolveColor(o,"#2962ff"),this._resolve(l)||"style_solid",this._resolve(c)??1,this._resolveColor(u,"#2962ff"),this._resolve(p)||"",this._resolveColor(h,"#000000"),this._resolve(f)||"auto",this._resolve(d)||"center",this._resolve(m)||"center",this._resolve(x)||"wrap_none",this._resolve(b)||"default",this._resolve(v)||"format_none",w);return S._helper=this,S._createdAtBar=this.context.idx,this._boxes.push(S),this._enforceMaxCount(),this.syncToPlot(),S}_enforceMaxCount(){const e=this.context.indicator?.max_boxes_count??50,i=this._boxes.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._boxes){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}new(...e){const i=te(e,Zd,Qd);let r,n,s,a,o=i.xloc;if(i.top_left instanceof Ie){const l=i.top_left,c=i.bottom_right,u=this._resolvePoint(l);r=u.x,n=l.price,o=o||u.xloc,c instanceof Ie?(s=this._resolvePoint(c).x,a=c.price):(s=0,a=NaN)}else r=this._resolve(i.left),n=this._resolve(i.top),s=this._resolve(i.right),a=this._resolve(i.bottom);return this._createBox(r,n,s,a,o,i.extend,i.border_color,i.border_style,i.border_width,i.bgcolor,i.text,i.text_color,i.text_size,i.text_halign,i.text_valign,i.text_wrap,i.text_font_family,void 0,i.force_overlay)}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof di)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof di)return r}return null}return this.new(...e)}set_left(e,i){e&&!e._deleted&&(e.left=this._resolve(i))}set_right(e,i){e&&!e._deleted&&(e.right=this._resolve(i))}set_top(e,i){e&&!e._deleted&&(e.top=this._resolve(i))}set_bottom(e,i){e&&!e._deleted&&(e.bottom=this._resolve(i))}set_lefttop(e,i,r){e&&!e._deleted&&(e.left=this._resolve(i),e.top=this._resolve(r))}set_rightbottom(e,i,r){e&&!e._deleted&&(e.right=this._resolve(i),e.bottom=this._resolve(r))}set_top_left_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.left=r.x,e.top=i.price,e.xloc=r.xloc}}set_bottom_right_point(e,i){if(e&&!e._deleted&&i){const r=this._resolvePoint(i);e.right=r.x,e.bottom=i.price,e.xloc=r.xloc}}set_xloc(e,i,r,n){e&&!e._deleted&&(e.left=this._resolve(i),e.right=this._resolve(r),e.xloc=this._resolve(n))}set_bgcolor(e,i){e&&!e._deleted&&(e.bgcolor=this._resolve(i))}set_border_color(e,i){e&&!e._deleted&&(e.border_color=this._resolve(i))}set_border_width(e,i){e&&!e._deleted&&(e.border_width=this._resolve(i)??1)}set_border_style(e,i){e&&!e._deleted&&(e.border_style=this._resolve(i))}set_extend(e,i){e&&!e._deleted&&(e.extend=this._resolve(i))}set_text(e,i){e&&!e._deleted&&(e.text=this._resolve(i)||"")}set_text_color(e,i){e&&!e._deleted&&(e.text_color=this._resolve(i))}set_text_size(e,i){e&&!e._deleted&&(e.text_size=this._resolve(i))}set_text_halign(e,i){e&&!e._deleted&&(e.text_halign=this._resolve(i))}set_text_valign(e,i){e&&!e._deleted&&(e.text_valign=this._resolve(i))}set_text_wrap(e,i){e&&!e._deleted&&(e.text_wrap=this._resolve(i))}set_text_font_family(e,i){e&&!e._deleted&&(e.text_font_family=this._resolve(i))}set_text_formatting(e,i){e&&!e._deleted&&(e.text_formatting=this._resolve(i))}get_left(e){return e?e.left:NaN}get_right(e){return e?e.right:NaN}get_top(e){return e?e.top:NaN}get_bottom(e){return e?e.bottom:NaN}copy(e){if(!e)return;const i=e.copy();return i._helper=this,i._createdAtBar=this.context.idx,this._boxes.push(i),this._enforceMaxCount(),this.syncToPlot(),i}delete(e){e&&(e._deleted=!0)}get all(){return this._boxes.filter(e=>!e._deleted)}rollbackFromBar(e){this._boxes=this._boxes.filter(i=>i._createdAtBar<e),this.syncToPlot()}}ie([C],ee.prototype,"new",1),ie([C],ee.prototype,"set_left",1),ie([C],ee.prototype,"set_right",1),ie([C],ee.prototype,"set_top",1),ie([C],ee.prototype,"set_bottom",1),ie([C],ee.prototype,"set_lefttop",1),ie([C],ee.prototype,"set_rightbottom",1),ie([C],ee.prototype,"set_top_left_point",1),ie([C],ee.prototype,"set_bottom_right_point",1),ie([C],ee.prototype,"set_xloc",1),ie([C],ee.prototype,"set_bgcolor",1),ie([C],ee.prototype,"set_border_color",1),ie([C],ee.prototype,"set_border_width",1),ie([C],ee.prototype,"set_border_style",1),ie([C],ee.prototype,"set_extend",1),ie([C],ee.prototype,"set_text",1),ie([C],ee.prototype,"set_text_color",1),ie([C],ee.prototype,"set_text_size",1),ie([C],ee.prototype,"set_text_halign",1),ie([C],ee.prototype,"set_text_valign",1),ie([C],ee.prototype,"set_text_wrap",1),ie([C],ee.prototype,"set_text_font_family",1),ie([C],ee.prototype,"set_text_formatting",1),ie([C],ee.prototype,"copy",1),ie([C],ee.prototype,"delete",1);var Jd=Object.defineProperty,em=(t,e,i)=>e in t?Jd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Yt=(t,e,i)=>em(t,typeof e!="symbol"?e+"":e,i);let tm=0;class xn{constructor(e,i,r){Yt(this,"id"),Yt(this,"line1"),Yt(this,"line2"),Yt(this,"color"),Yt(this,"_deleted"),Yt(this,"_createdAtBar",-1),this.id=tm++,this.line1=e,this.line2=i,this.color=r,this._deleted=!1}get_line1(){return this.line1}get_line2(){return this.line2}set_color(e){this._deleted||(typeof e=="function"&&(e=e()),e&&typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"&&(e=e.get(0)),this.color=e||"")}delete(){this._deleted=!0}toPlotData(){const e=r=>r?{id:r.id,x1:r.x1,y1:r.y1,x2:r.x2,y2:r.y2,xloc:r.xloc,extend:r.extend,color:r.color,style:r.style,width:r.width,_deleted:r._deleted}:null,i=!!(this.line1?.force_overlay||this.line2?.force_overlay);return{id:this.id,line1:e(this.line1),line2:e(this.line2),color:this.color,force_overlay:i,_deleted:this._deleted}}}var $s=Object.defineProperty,im=Object.getOwnPropertyDescriptor,rm=(t,e,i)=>e in t?$s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,hr=(t,e,i,r)=>{for(var n=r>1?void 0:r?im(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&$s(e,i,n),n},nm=(t,e,i)=>rm(t,typeof e!="symbol"?e+"":e,i);class Oi{constructor(e){this.context=e,nm(this,"_linefills",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__linefills__||(this.context.plots.__linefills__={title:"__linefills__",data:[],options:{style:"linefill",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0,i=this._linefills.filter(s=>!s._deleted).map(s=>s.toPlotData()),r=i.filter(s=>!s.force_overlay),n=i.filter(s=>s.force_overlay);this.context.plots.__linefills__.data=[{time:e,value:r,options:{style:"linefill"}}],n.length>0?this.context.plots.__linefills_overlay__={title:"__linefills_overlay__",data:[{time:e,value:n,options:{style:"linefill"}}],options:{style:"linefill",overlay:!0}}:delete this.context.plots.__linefills_overlay__}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e){const i=this._resolve(e);return i==null?i:typeof i=="number"&&isNaN(i)?NaN:i}new(e,i,r){const n=this._resolve(e),s=this._resolve(i),a=r&&typeof r=="object"&&!Array.isArray(r)&&"color"in r?r.color:r,o=this._resolveColor(a);if(n&&s){const c=n.id,u=s.id;for(const p of this._linefills){if(p._deleted)continue;const h=p.line1?.id,f=p.line2?.id;if(h===c&&f===u||h===u&&f===c)return p.color=o,p._createdAtBar=this.context.idx,this.syncToPlot(),p}}const l=new xn(n,s,o);return l._createdAtBar=this.context.idx,this._linefills.push(l),this.syncToPlot(),l}any(...e){if(e.length===1){const i=e[0];return i==null||i instanceof Re||typeof i=="number"&&isNaN(i)?null:i instanceof xn?i:null}return this.new(e[0],e[1],e[2])}set_color(e,i){e&&!e._deleted&&(e.color=this._resolveColor(i))}get_line1(e){return e?e.line1:void 0}get_line2(e){return e?e.line2:void 0}delete(e){e&&(e._deleted=!0)}get all(){return this._linefills.filter(e=>!e._deleted)}rollbackFromBar(e){this._linefills=this._linefills.filter(i=>i._createdAtBar<e),this.syncToPlot()}}hr([C],Oi.prototype,"new",1),hr([C],Oi.prototype,"set_color",1),hr([C],Oi.prototype,"delete",1);var sm=Object.defineProperty,am=(t,e,i)=>e in t?sm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,We=(t,e,i)=>am(t,typeof e!="symbol"?e+"":e,i);let om=0;class pr{constructor(e,i=!1,r=!1,n="bi",s="#2962ff",a="",o="style_solid",l=1,c=!1){We(this,"id"),We(this,"points"),We(this,"curved"),We(this,"closed"),We(this,"xloc"),We(this,"line_color"),We(this,"fill_color"),We(this,"line_style"),We(this,"line_width"),We(this,"force_overlay"),We(this,"_deleted"),We(this,"_createdAtBar",-1),this.id=om++,this.points=e,this.curved=i,this.closed=r,this.xloc=n,this.line_color=s,this.fill_color=a,this.line_style=o,this.line_width=l,this.force_overlay=c,this._deleted=!1}delete(){this._deleted=!0}toPlotData(){return{id:this.id,points:this.points.map(e=>({time:e.time,index:e.index,price:e.price})),curved:this.curved,closed:this.closed,xloc:this.xloc,line_color:this.line_color,fill_color:this.fill_color,line_style:this.line_style,line_width:this.line_width,force_overlay:this.force_overlay,_deleted:this._deleted}}}var Vs=Object.defineProperty,lm=Object.getOwnPropertyDescriptor,cm=(t,e,i)=>e in t?Vs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,bn=(t,e,i,r)=>{for(var n=r>1?void 0:r?lm(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&Vs(e,i,n),n},um=(t,e,i)=>cm(t,typeof e!="symbol"?e+"":e,i);class Ir{constructor(e){this.context=e,um(this,"_polylines",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__polylines__||(this.context.plots.__polylines__={title:"__polylines__",data:[],options:{style:"drawing_polyline",overlay:this.context.indicator?.overlay||!1}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__polylines__.data=[{time:e,value:this._polylines.filter(i=>!i._deleted).map(i=>i.toPlotData()),options:{style:"drawing_polyline"}}]}_resolve(e){return e==null?e:e instanceof Re?NaN:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}_resolveColor(e,i){const r=this._resolve(e);return r==null?r:typeof r=="number"&&isNaN(r)?NaN:r||i}_extractPoints(e){let i=this._resolve(e);const r=i&&i.array?i.array:i;return Array.isArray(r)?r.filter(n=>n instanceof Ie):[]}new(...e){let i,r=!1,n=!1,s="bi",a="#2962ff",o="",l="style_solid",c=1,u=!1;const p=(b,v)=>Object.prototype.hasOwnProperty.call(b,v),h=b=>{p(b,"curved")&&(r=b.curved),p(b,"closed")&&(n=b.closed),p(b,"xloc")&&(s=b.xloc),p(b,"line_color")&&(a=b.line_color),p(b,"fill_color")&&(o=b.fill_color),p(b,"line_style")&&(l=b.line_style),p(b,"line_width")&&(c=b.line_width),p(b,"force_overlay")&&(u=b.force_overlay)},f=e.length>=1?e[e.length-1]:null,d=e.length>=2&&f&&typeof f=="object"&&!Array.isArray(f)&&!(f instanceof y)&&!(f instanceof Ie);if(e.length===1&&f&&typeof f=="object"&&!Array.isArray(f)&&"points"in f)i=f.points,h(f);else{const b=d?e.slice(0,-1):e;i=b[0],b.length>1&&(r=b[1]),b.length>2&&(n=b[2]),b.length>3&&(s=b[3]),b.length>4&&(a=b[4]),b.length>5&&(o=b[5]),b.length>6&&(l=b[6]),b.length>7&&(c=b[7]),b.length>8&&(u=b[8]),d&&h(f)}const m=this._extractPoints(i),x=new pr(m,this._resolve(r)??!1,this._resolve(n)??!1,this._resolve(s)||"bi",this._resolveColor(a,"#2962ff"),this._resolveColor(o,""),this._resolve(l)||"style_solid",this._resolve(c)||1,this._resolve(u)??!1);return x._createdAtBar=this.context.idx,this._polylines.push(x),this._enforceMaxCount(),this.syncToPlot(),x}_enforceMaxCount(){const e=this.context.indicator?.max_polylines_count??50,i=this._polylines.filter(r=>!r._deleted);if(i.length>e){const r=i.length-e;let n=0;for(const s of this._polylines){if(n>=r)break;s._deleted||(s._deleted=!0,n++)}}}any(...e){if(e.length===1){const i=e[0];if(i==null||i instanceof Re||typeof i=="number"&&isNaN(i))return null;if(i instanceof pr)return i;if(i instanceof y){const r=i.get(0);if(r==null||typeof r=="number"&&isNaN(r))return null;if(r instanceof pr)return r}return null}return this.new(...e)}delete(e){e&&(e._deleted=!0)}get all(){return this._polylines.filter(e=>!e._deleted)}rollbackFromBar(e){this._polylines=this._polylines.filter(i=>i._createdAtBar<e),this.syncToPlot()}}bn([C],Ir.prototype,"new",1),bn([C],Ir.prototype,"delete",1);var hm=Object.defineProperty,pm=(t,e,i)=>e in t?hm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,De=(t,e,i)=>pm(t,typeof e!="symbol"?e+"":e,i);let fm=0;class vn{constructor(e="top_right",i=1,r=1,n="",s="",a=0,o="",l=0,c=!1){De(this,"id"),De(this,"position"),De(this,"columns"),De(this,"rows"),De(this,"bgcolor"),De(this,"frame_color"),De(this,"frame_width"),De(this,"border_color"),De(this,"border_width"),De(this,"force_overlay"),De(this,"_deleted"),De(this,"cells"),De(this,"merges"),De(this,"_helper"),this.id=fm++,this.position=e,this.columns=i,this.rows=r,this.bgcolor=n,this.frame_color=s,this.frame_width=a,this.border_color=o,this.border_width=l,this.force_overlay=c,this._deleted=!1,this.merges=[],this.cells=[];for(let u=0;u<r;u++){this.cells[u]=[];for(let p=0;p<i;p++)this.cells[u][p]=null}}delete(){this._deleted=!0}toPlotData(){const e=this.cells.map(i=>i.map(r=>r?{...r}:null));return{id:this.id,position:this.position,columns:this.columns,rows:this.rows,bgcolor:this.bgcolor,frame_color:this.frame_color,frame_width:this.frame_width,border_color:this.border_color,border_width:this.border_width,force_overlay:this.force_overlay,_deleted:this._deleted,cells:e,merges:this.merges.map(i=>({...i}))}}setCell(e,i,r){if(i<0||i>=this.rows||e<0||e>=this.columns)return;const n=this.cells[i][e];if(n&&n._merged&&n._merge_parent){const[a,o]=n._merge_parent;if(a===e&&o===i)n._merged=!1,n._merge_parent=void 0;else{this.setCell(a,o,r);return}}const s=n||this._defaultCell();Object.assign(s,r),this.cells[i][e]=s}getCell(e,i){return i<0||i>=this.rows||e<0||e>=this.columns?null:this.cells[i][e]}clearCell(e,i){i<0||i>=this.rows||e<0||e>=this.columns||(this.cells[i][e]=null)}_setHelper(e){this._helper=e}cell(...e){return this._helper.cell(this,...e)}clear(...e){return this._helper.clear(this,...e)}merge_cells(...e){return this._helper.merge_cells(this,...e)}cell_set_text(...e){return this._helper.cell_set_text(this,...e)}cell_set_bgcolor(...e){return this._helper.cell_set_bgcolor(this,...e)}cell_set_text_color(...e){return this._helper.cell_set_text_color(this,...e)}cell_set_text_size(...e){return this._helper.cell_set_text_size(this,...e)}cell_set_height(...e){return this._helper.cell_set_height(this,...e)}cell_set_width(...e){return this._helper.cell_set_width(this,...e)}cell_set_tooltip(...e){return this._helper.cell_set_tooltip(this,...e)}cell_set_text_halign(...e){return this._helper.cell_set_text_halign(this,...e)}cell_set_text_valign(...e){return this._helper.cell_set_text_valign(this,...e)}cell_set_text_font_family(...e){return this._helper.cell_set_text_font_family(this,...e)}set_position(...e){return this._helper.set_position(this,...e)}set_bgcolor(...e){return this._helper.set_bgcolor(this,...e)}set_border_color(...e){return this._helper.set_border_color(this,...e)}set_border_width(...e){return this._helper.set_border_width(this,...e)}set_frame_color(...e){return this._helper.set_frame_color(this,...e)}set_frame_width(...e){return this._helper.set_frame_width(this,...e)}_defaultCell(){return{text:"",width:0,height:0,text_color:"#000000",text_halign:"center",text_valign:"center",text_size:"normal",bgcolor:"",tooltip:"",text_font_family:"default",_merged:!1,_merge_parent:null}}}var js=Object.defineProperty,dm=Object.getOwnPropertyDescriptor,mm=(t,e,i)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,oe=(t,e,i,r)=>{for(var n=r>1?void 0:r?dm(e,i):e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(n=(r?a(e,i,n):a(n))||n);return r&&n&&js(e,i,n),n},ym=(t,e,i)=>mm(t,typeof e!="symbol"?e+"":e,i);class ae{constructor(e){this.context=e,ym(this,"_tables",[])}param(e,i=0,r){return y.from(e).get(i)}_ensurePlotsEntry(){this.context.plots.__tables__||(this.context.plots.__tables__={title:"__tables__",data:[],options:{style:"table",overlay:!0}})}syncToPlot(){this._ensurePlotsEntry();const e=this.context.marketData[0]?.openTime||0;this.context.plots.__tables__.data=[{time:e,value:this._tables.filter(i=>!i._deleted).map(i=>i.toPlotData()),options:{style:"table"}}]}_resolve(e){return e==null?e:typeof e=="object"&&"__value"in e?e.__value:typeof e=="object"&&Array.isArray(e.data)&&typeof e.get=="function"?e.get(0):typeof e=="function"?e():e}new(...e){let i="top_right",r=1,n=1,s="",a="",o=0,l="",c=0,u=!1;const p=e[e.length-1];if(p&&typeof p=="object"&&!Array.isArray(p)&&("bgcolor"in p||"frame_color"in p||"border_color"in p||"position"in p||"columns"in p||"rows"in p)){const f=p,d=e.slice(0,-1);i=d[0]??f.position??i,r=d[1]??f.columns??r,n=d[2]??f.rows??n,s=f.bgcolor??s,a=f.frame_color??a,o=f.frame_width??o,l=f.border_color??l,c=f.border_width??c,u=f.force_overlay??u}else i=e[0]??i,r=e[1]??r,n=e[2]??n,s=e[3]??s,a=e[4]??a,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u;const h=new vn(this._resolve(i)||"top_right",this._resolve(r)||1,this._resolve(n)||1,this._resolve(s)||"",this._resolve(a)||"",this._resolve(o)||0,this._resolve(l)||"",this._resolve(c)||0,this._resolve(u)??!1);return h._setHelper(this),this._tables.push(h),this.syncToPlot(),h}any(...e){if(e.length===1){const i=e[0];return i==null||typeof i=="object"&&"__value"in i||typeof i=="number"&&isNaN(i)?null:i instanceof vn?i:null}return this.new(...e)}cell(...e){let i,r,n,s="",a=0,o=0,l="#000000",c="center",u="center",p="normal",h="",f="",d="default";const m=e[e.length-1];if(m&&typeof m=="object"&&!Array.isArray(m)&&("text"in m||"bgcolor"in m||"text_color"in m||"text_size"in m||"text_halign"in m||"tooltip"in m||"column"in m||"row"in m||"height"in m||"width"in m||"text_valign"in m||"text_font_family"in m)){const w=m,S=e.slice(0,-1);i=S[0],r=S.length>1?S[1]:w.column??0,n=S.length>2?S[2]:w.row??0,s=S[3]??w.text??s,a=S[4]??w.width??a,o=S[5]??w.height??o,l=S[6]??w.text_color??l,c=S[7]??w.text_halign??c,u=S[8]??w.text_valign??u,p=S[9]??w.text_size??p,h=S[10]??w.bgcolor??h,f=S[11]??w.tooltip??f,d=S[12]??w.text_font_family??d}else i=e[0],r=e[1]??0,n=e[2]??0,s=e[3]??s,a=e[4]??a,o=e[5]??o,l=e[6]??l,c=e[7]??c,u=e[8]??u,p=e[9]??p,h=e[10]??h,f=e[11]??f,d=e[12]??d;const x=this._resolve(i);if(!x||x._deleted)return;const b=this._resolve(r)??0,v=this._resolve(n)??0;x.setCell(b,v,{text:this._resolveText(this._resolve(s)),width:this._resolve(a)||0,height:this._resolve(o)||0,text_color:this._resolve(l)||"#000000",text_halign:this._resolve(c)||"center",text_valign:this._resolve(u)||"center",text_size:this._resolve(p)||"normal",bgcolor:this._resolve(h)||"",tooltip:this._resolveText(this._resolve(f)),text_font_family:this._resolve(d)||"default"}),this.syncToPlot()}delete(e){e&&(e._deleted=!0)}clear(...e){let i,r,n,s,a;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,s=f.end_column??(e.length>4?e[3]:r),a=f.end_row??(e.length>5?e[4]:n)}else i=e[0],r=e[1]??0,n=e[2]??0,s=e[3]??r,a=e[4]??n;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,u=this._resolve(n)??0,p=this._resolve(s)??c,h=this._resolve(a)??u;for(let f=u;f<=h;f++)for(let d=c;d<=p;d++)l.clearCell(d,f);this.syncToPlot()}merge_cells(...e){let i,r,n,s,a;const o=e[e.length-1];if(o&&typeof o=="object"&&!Array.isArray(o)&&("start_column"in o||"start_row"in o||"end_column"in o)){const f=o;i=e[0],r=e.length>2?e[1]:f.start_column??0,n=e.length>3?e[2]:f.start_row??0,s=f.end_column??(e.length>4?e[3]:0),a=f.end_row??(e.length>5?e[4]:0)}else i=e[0],r=e[1]??0,n=e[2]??0,s=e[3]??0,a=e[4]??0;const l=this._resolve(i);if(!l||l._deleted)return;const c=this._resolve(r)??0,u=this._resolve(n)??0,p=this._resolve(s)??0,h=this._resolve(a)??0;for(let f=u;f<=h;f++)for(let d=c;d<=p;d++)f===u&&d===c||l.setCell(d,f,{_merged:!0,_merge_parent:[c,u]});l.merges.push({startCol:c,startRow:u,endCol:p,endRow:h}),this.syncToPlot()}cell_set_text(e,i,r,n){this._setCellProp(e,i,r,"text",n,!0)}cell_set_bgcolor(e,i,r,n){this._setCellProp(e,i,r,"bgcolor",n)}cell_set_text_color(e,i,r,n){this._setCellProp(e,i,r,"text_color",n)}cell_set_text_size(e,i,r,n){this._setCellProp(e,i,r,"text_size",n)}cell_set_height(e,i,r,n){this._setCellProp(e,i,r,"height",n)}cell_set_width(e,i,r,n){this._setCellProp(e,i,r,"width",n)}cell_set_tooltip(e,i,r,n){this._setCellProp(e,i,r,"tooltip",n,!0)}cell_set_text_halign(e,i,r,n){this._setCellProp(e,i,r,"text_halign",n)}cell_set_text_valign(e,i,r,n){this._setCellProp(e,i,r,"text_valign",n)}cell_set_text_font_family(e,i,r,n){this._setCellProp(e,i,r,"text_font_family",n)}set_position(e,i){const r=this._resolve(e);!r||r._deleted||(r.position=this._resolve(i)||r.position,this.syncToPlot())}set_bgcolor(e,i){const r=this._resolve(e);!r||r._deleted||(r.bgcolor=this._resolve(i)||"",this.syncToPlot())}set_border_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_color=this._resolve(i)||"",this.syncToPlot())}set_border_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.border_width=this._resolve(i)||0,this.syncToPlot())}set_frame_color(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_color=this._resolve(i)||"",this.syncToPlot())}set_frame_width(e,i){const r=this._resolve(e);!r||r._deleted||(r.frame_width=this._resolve(i)||0,this.syncToPlot())}get all(){return this._tables.filter(e=>!e._deleted)}rollbackFromBar(e){this.syncToPlot()}_setCellProp(e,i,r,n,s,a=!1){const o=this._resolve(e);if(!o||o._deleted)return;const l=this._resolve(i)??0,c=this._resolve(r)??0,u=this._resolve(s);o.setCell(l,c,{[n]:a?this._resolveText(u):u}),this.syncToPlot()}_resolveText(e){return e==null||e!==e?"":String(e)}}oe([C],ae.prototype,"new",1),oe([C],ae.prototype,"cell",1),oe([C],ae.prototype,"delete",1),oe([C],ae.prototype,"clear",1),oe([C],ae.prototype,"merge_cells",1),oe([C],ae.prototype,"cell_set_text",1),oe([C],ae.prototype,"cell_set_bgcolor",1),oe([C],ae.prototype,"cell_set_text_color",1),oe([C],ae.prototype,"cell_set_text_size",1),oe([C],ae.prototype,"cell_set_height",1),oe([C],ae.prototype,"cell_set_width",1),oe([C],ae.prototype,"cell_set_tooltip",1),oe([C],ae.prototype,"cell_set_text_halign",1),oe([C],ae.prototype,"cell_set_text_valign",1),oe([C],ae.prototype,"cell_set_text_font_family",1),oe([C],ae.prototype,"set_position",1),oe([C],ae.prototype,"set_bgcolor",1),oe([C],ae.prototype,"set_border_color",1),oe([C],ae.prototype,"set_border_width",1),oe([C],ae.prototype,"set_frame_color",1),oe([C],ae.prototype,"set_frame_width",1);class _m{constructor(e){this.context=e}param(e,i=0,r){return typeof e=="string"?e:y.from(e).get(i)}inherit(e,i){return this._coerce(i)}new(e,i,r,n,s,a){const o=this._coerce(e),l=this._coerce(i);return o?l?`${o}:${l}`:o:l}modify(e,i,r,n,s){return this._coerce(e)}standard(e){return e==null?this.context?.pine?.syminfo?.tickerid||this.context?.tickerId||"":this._coerce(e)}heikinashi(e){return this._coerce(e)}renko(e,i,r,n,s){return this._coerce(e)}kagi(e,i){return this._coerce(e)}linebreak(e,i){return this._coerce(e)}pointfigure(e,i,r,n,s){return this._coerce(e)}_coerce(e){if(e==null)return"";if(e instanceof y){const i=e.get(0);return i==null?"":String(i)}return typeof e=="number"&&isNaN(e)?"":String(e)}}var gm=Object.defineProperty,xm=(t,e,i)=>e in t?gm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,U=(t,e,i)=>xm(t,typeof e!="symbol"?e+"":e,i);const kr=class $i{constructor({marketData:e,source:i,tickerId:r,timeframe:n,limit:s,sDate:a,eDate:o,fullContext:l,inputs:c}){U(this,"data",{open:new y([]),high:new y([]),low:new y([]),close:new y([]),volume:new y([]),hl2:new y([]),hlc3:new y([]),ohlc4:new y([]),hlcc4:new y([]),bar_index:new y([])}),U(this,"indicator"),U(this,"cache",{}),U(this,"taState",{}),U(this,"strategy"),U(this,"isSecondaryContext",!1),U(this,"chartTimezone",null),U(this,"dataVersion",0),U(this,"__maxLoops",5e5),U(this,"NA",NaN),U(this,"warnings",[]),U(this,"alerts",[]),U(this,"_alertMode","realtime"),U(this,"_propOverrides",{}),U(this,"_execTick",0),U(this,"lang"),U(this,"length",0),U(this,"_drawingHelpers",[]),U(this,"pine"),U(this,"idx",0),U(this,"params",{}),U(this,"const",{}),U(this,"var",{}),U(this,"let",{}),U(this,"lctx",new Map),U(this,"result"),U(this,"plots",{}),U(this,"marketData"),U(this,"source"),U(this,"tickerId"),U(this,"timeframe",""),U(this,"limit"),U(this,"sDate"),U(this,"eDate"),U(this,"fullContext"),U(this,"viewportLeft"),U(this,"viewportRight"),U(this,"pineTSCode"),U(this,"inputs",{}),U(this,"_callStack",[]),U(this,"_pathStack",[]),this.marketData=e,this.source=i,this.tickerId=r,this.timeframe=n,this.limit=s,this.sDate=a,this.eDate=o,this.fullContext=l||this,this.inputs=c||{};const u=new ks(this),p={Type:u.Type.bind(u),na:new Re,nz:u.nz.bind(u),indicator:u.indicator.bind(u),fixnan:u.fixnan.bind(u),alertcondition:u.alertcondition.bind(u),alert:new Is(this),error:u.error.bind(u),max_bars_back:u.max_bars_back.bind(u),timestamp:u.timestamp.bind(u),time:new ln(this,"openTime"),time_close:new ln(this,"closeTime"),dayofmonth:new vt(this,wt.dayofmonth),dayofweek:new vt(this,wt.dayofweek),hour:new vt(this,wt.hour),minute:new vt(this,wt.minute),month:new vt(this,wt.month),second:new vt(this,wt.second),weekofyear:new vt(this,wt.weekofyear),year:new vt(this,wt.year),bool:u.bool.bind(u),int:u.int.bind(u),float:u.float.bind(u),string:u.string.bind(u)},h=this;this.pine={input:new au(this),ta:new xp(this),math:new Wu(this),request:new rh(this),array:new Zo(this),map:new pl(this),matrix:new pc(this),ticker:new _m(this),strategy:new Gf(this),syminfo:null,timeframe:new ad(this),barstate:new yc(this),get bar_index(){return h.data.bar_index},get last_bar_index(){return h.data.close.length-1},get last_bar_time(){const k=h.marketData;return Array.isArray(k)&&k.length>0?k[k.length-1].openTime:h.data.openTime.get(0)},get timenow(){return new Date().getTime()},get time_tradingday(){const k=y.from(h.data.closeTime).get(0);if(isNaN(k))return NaN;const A=h.pine?.syminfo?.timezone||"UTC",V=Rt(k,A);return Date.UTC(V.year,V.month-1,V.day,0,0,0)},get inputs(){return h.inputs},log:new Zf(this),str:new id(this),...p,...ko};const f=p.dayofweek;Object.assign(f,{sunday:1,monday:2,tuesday:3,wednesday:4,thursday:5,friday:6,saturday:7}),this.pine.dayofweek=f;const d=new yt(this),m=new Ps(this),x=new Ds(this);this.bindContextObject(d,["plotchar","plotshape","plotarrow","plotbar","plotcandle","bgcolor","barcolor"]),this.bindContextObject(d,["any","param","linestyle_dashed","linestyle_dotted","linestyle_solid","style_area","style_areabr","style_circles","style_columns","style_cross","style_histogram","style_line","style_linebr","style_stepline","style_stepline_diamond","style_steplinebr"],"plot"),this.bindContextObject(m,["any","style_dashed","style_solid","style_dotted","param"],"hline"),this.bindContextObject(x,["any","param"],"fill");const b=new kd(this);this.pine.chart={param:b.param.bind(b),bg_color:b.bg_color.bind(b),fg_color:b.fg_color.bind(b),is_standard:b.is_standard.bind(b),is_heikinashi:b.is_heikinashi.bind(b),is_kagi:b.is_kagi.bind(b),is_linebreak:b.is_linebreak.bind(b),is_pnf:b.is_pnf.bind(b),is_range:b.is_range.bind(b),is_renko:b.is_renko.bind(b),point:b.point,get left_visible_bar_time(){if(h.viewportLeft!==void 0)return h.viewportLeft;const k=h.marketData;return Array.isArray(k)&&k.length>0?k[0].openTime:NaN},get right_visible_bar_time(){if(h.viewportRight!==void 0)return h.viewportRight;const k=h.marketData;return Array.isArray(k)&&k.length>0?k[k.length-1].openTime:NaN}};const v=new xe(this);this.bindContextObject(v,["any","new","param","set_x","set_y","set_xy","set_text","set_color","set_textcolor","set_size","set_style","set_textalign","set_tooltip","set_point","set_xloc","set_yloc","get_x","get_y","get_text","copy","delete","style_label_down","style_label_up","style_label_left","style_label_right","style_label_lower_left","style_label_lower_right","style_label_upper_left","style_label_upper_right","style_label_center","style_circle","style_square","style_diamond","style_flag","style_arrowup","style_arrowdown","style_cross","style_xcross","style_triangleup","style_triangledown","style_none","style_text_outline"],"label"),Object.defineProperty(this.pine.label,"all",{get:()=>v.all});const w=new be(this);this.bindContextObject(w,["any","new","param","set_x1","set_y1","set_x2","set_y2","set_xy1","set_xy2","set_color","set_width","set_style","set_extend","set_xloc","set_first_point","set_second_point","get_x1","get_y1","get_x2","get_y2","get_price","copy","delete","style_solid","style_dotted","style_dashed","style_arrow_left","style_arrow_right","style_arrow_both"],"line"),Object.defineProperty(this.pine.line,"all",{get:()=>w.all});const S=new ee(this);this.bindContextObject(S,["any","new","param","copy","delete","set_left","set_right","set_top","set_bottom","set_lefttop","set_rightbottom","set_top_left_point","set_bottom_right_point","set_bgcolor","set_border_color","set_border_width","set_border_style","set_extend","set_xloc","set_text","set_text_color","set_text_size","set_text_halign","set_text_valign","set_text_wrap","set_text_font_family","set_text_formatting","get_left","get_right","get_top","get_bottom"],"box"),Object.defineProperty(this.pine.box,"all",{get:()=>S.all});const T=new Oi(this);this.bindContextObject(T,["any","new","param","set_color","get_line1","get_line2","delete"],"linefill"),Object.defineProperty(this.pine.linefill,"all",{get:()=>T.all});const N=new Ir(this);this.bindContextObject(N,["any","new","param","delete"],"polyline"),Object.defineProperty(this.pine.polyline,"all",{get:()=>N.all});const R=new ae(this);this.bindContextObject(R,["any","new","param","cell","delete","clear","merge_cells","cell_set_text","cell_set_bgcolor","cell_set_text_color","cell_set_text_size","cell_set_height","cell_set_width","cell_set_tooltip","cell_set_text_halign","cell_set_text_valign","cell_set_text_font_family","set_position","set_bgcolor","set_border_color","set_border_width","set_frame_color","set_frame_width"],"table"),Object.defineProperty(this.pine.table,"all",{get:()=>R.all}),this._drawingHelpers=[v,w,S,T,N,R];const $=new Pc(this);this.bindContextObject($,["any","param","new","rgb","from_gradient","r","g","b","t","aqua","black","blue","fuchsia","gray","green","lime","maroon","navy","olive","orange","purple","red","silver","teal","white","yellow"],"color")}warn(e,i){this.warnings.push({message:e,method:i,bar:this.idx})}rollbackDrawings(e){for(const i of this._drawingHelpers)i.rollbackFromBar(e)}bindContextObject(e,i,r=""){r&&!this.pine[r]&&(this.pine[r]={});const n=r?this.pine[r]:this.pine;for(const s of i)typeof e[s]=="function"?n[s]=e[s].bind(e):n[s]=e[s]}init(e,i,r=0){let n;return i instanceof y?n=i.get(0):Array.isArray(i)?Array.isArray(i[0])?n=i[0]:n=i[i.length-1+r]:n=i,e?e instanceof y?(e.data[e.data.length-1]=n,e):Array.isArray(e)?(e[e.length-1]=n,new y(e)):new y([n]):new y([n])}initVar(e,i){if(e)return e;if(typeof i=="function"&&(i=i()),i instanceof It){const n=i.__def__;for(const s in n)typeof i[s]=="function"&&(i[s]=i[s]())}let r;return i instanceof y?r=i.get(0):Array.isArray(i)?Array.isArray(i[0])?r=i[0]:r=this.precision(i[i.length-1]):r=this.precision(i),new y([r])}precision(e,i=10){const r=i===10?$i.PRECISION_EPSILON:10**i;return typeof e=="number"?Math.round(e*r)/r:e}param(e,i,r){return typeof e=="string"?e:e instanceof y?i?new y(e.data,e.offset+i):e:!Array.isArray(e)&&typeof e=="object"?e:(this.params[r]||(this.params[r]=[]),Array.isArray(e)?new y(e,i||0):(this.params[r].length===0?this.params[r].push(e):this.params[r][this.params[r].length-1]=e,new y(this.params[r],i||0)))}get(e,i){if(e instanceof y)return e.get(i);if(Array.isArray(e)){const r=e.length-1-i;return r<0||r>=e.length?NaN:e[r]}return e}set(e,i){if(e instanceof y){e.set(0,typeof i=="number"?this.precision(i):i);return}if(Array.isArray(e)){e.length>0?e[e.length-1]=i:e.push(i);return}}iter(e){return e==null?[]:Array.isArray(e.array)?e.array:e.map instanceof Map?e.map:e}entries(e){return e==null?[].entries():Array.isArray(e.array)?e.array.entries():e.map instanceof Map?e.map.entries():Array.isArray(e)||typeof e.entries=="function"?e.entries():[].entries()}pushId(e){const i=this._pathStack.length>0?this._pathStack[this._pathStack.length-1]:"",r=i?i+"|"+e:e;this._callStack.push(e),this._pathStack.push(r)}popId(){this._callStack.pop(),this._pathStack.pop()}peekId(){return this._pathStack.length>0?this._pathStack[this._pathStack.length-1]:""}peekCtx(){const e=this.peekId();if(!e)return this;let i=this.lctx.get(e);return i||(i={id:e,let:{},const:{},var:{}},this.lctx.set(e,i)),i}call(e,i,...r){this.pushId(i);try{return e(...r)}finally{this.popId()}}get math(){return this._showDeprecationWarning("const math = context.math","const { math, ta, input } = context.pine"),this.pine.math}get ta(){return this._showDeprecationWarning("const ta = context.ta","const { ta, math, input } = context.pine"),this.pine.ta}get input(){return this._showDeprecationWarning("const input = context.input","const { input, math, ta } = context.pine"),this.pine.input}get request(){return this._showDeprecationWarning("const request = context.request","const { request, math, ta } = context.pine"),this.pine.request}get array(){return this._showDeprecationWarning("const array = context.array","const { array, math, ta } = context.pine"),this.pine.array}get core(){return this._showDeprecationWarning("context.core.*","context.pine (e.g., const { na, plotchar, color, plot, nz } = context.pine)"),{na:this.pine.na,fill:this.pine.fill,plotchar:this.pine.plotchar,plotshape:this.pine.plotshape,plotarrow:this.pine.plotarrow,color:this.pine.color,plot:this.pine.plot,nz:this.pine.nz}}_showDeprecationWarning(e,i){const r=`${e}->${i}`;$i._deprecationWarningsShown.has(r)||($i._deprecationWarningsShown.add(r),typeof window<"u"?console.warn("%c[WARNING]%c %s syntax is deprecated. Use %s instead. This will be removed in a future version.","color: #FFA500; font-weight: bold;","color: #FFA500;",e,i):console.warn(`\x1B[33m[WARNING] ${e} syntax is deprecated. Use ${i} instead. This will be removed in a future version.\x1B[0m`))}};U(kr,"_deprecationWarningsShown",new Set),U(kr,"PRECISION_EPSILON",10**10);let wn=kr;var bm=[509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,7,9,32,4,318,1,78,5,71,10,50,3,123,2,54,14,32,10,3,1,11,3,46,10,8,0,46,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,3,0,158,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,68,8,2,0,3,0,2,3,2,4,2,0,15,1,83,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,7,19,58,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,199,7,137,9,54,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,55,9,266,3,10,1,2,0,49,6,4,4,14,10,5350,0,7,14,11465,27,2343,9,87,9,39,4,60,6,26,9,535,9,470,0,2,54,8,3,82,0,12,1,19628,1,4178,9,519,45,3,22,543,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,101,0,161,6,10,9,357,0,62,13,499,13,245,1,2,9,233,0,3,0,8,1,6,0,475,6,110,6,6,9,4759,9,787719,239],Ls=[0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,13,10,2,14,2,6,2,1,2,10,2,14,2,6,2,1,4,51,13,310,10,21,11,7,25,5,2,41,2,8,70,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,7,25,39,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,39,27,10,22,251,41,7,1,17,5,57,28,11,0,9,21,43,17,47,20,28,22,13,52,58,1,3,0,14,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,20,1,64,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,31,9,2,0,3,0,2,37,2,0,26,0,2,0,45,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,38,6,186,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,19,72,200,32,32,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,24,43,261,18,16,0,2,12,2,33,125,0,80,921,103,110,18,195,2637,96,16,1071,18,5,26,3994,6,582,6842,29,1763,568,8,30,18,78,18,29,19,47,17,3,32,20,6,18,433,44,212,63,33,24,3,24,45,74,6,0,67,12,65,1,2,0,15,4,10,7381,42,31,98,114,8702,3,2,6,2,1,2,290,16,0,30,2,3,0,15,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,1845,30,7,5,262,61,147,44,11,6,17,0,322,29,19,43,485,27,229,29,3,0,208,30,2,2,2,1,2,6,3,4,10,1,225,6,2,3,2,1,2,14,2,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42719,33,4381,3,5773,3,7472,16,621,2467,541,1507,4938,6,8489],vm="\u200C\u200D\xB7\u0300-\u036F\u0387\u0483-\u0487\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u0669\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u06F0-\u06F9\u0711\u0730-\u074A\u07A6-\u07B0\u07C0-\u07C9\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0897-\u089F\u08CA-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0966-\u096F\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09E6-\u09EF\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A66-\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AE6-\u0AEF\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B66-\u0B6F\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0BE6-\u0BEF\u0C00-\u0C04\u0C3C\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0CE6-\u0CEF\u0CF3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D66-\u0D6F\u0D81-\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0E50-\u0E59\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0ED0-\u0ED9\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1040-\u1049\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F-\u109D\u135D-\u135F\u1369-\u1371\u1712-\u1715\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u17E0-\u17E9\u180B-\u180D\u180F-\u1819\u18A9\u1920-\u192B\u1930-\u193B\u1946-\u194F\u19D0-\u19DA\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AB0-\u1ABD\u1ABF-\u1ADD\u1AE0-\u1AEB\u1B00-\u1B04\u1B34-\u1B44\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BB0-\u1BB9\u1BE6-\u1BF3\u1C24-\u1C37\u1C40-\u1C49\u1C50-\u1C59\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DFF\u200C\u200D\u203F\u2040\u2054\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\u30FB\uA620-\uA629\uA66F\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA82C\uA880\uA881\uA8B4-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F1\uA8FF-\uA909\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9D0-\uA9D9\uA9E5\uA9F0-\uA9F9\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA50-\uAA59\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uABF0-\uABF9\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFF10-\uFF19\uFF3F\uFF65",Bs="\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088F\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5C\u0C5D\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDC-\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C8A\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7DC\uA7F1-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC",fr={3:"abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile",5:"class enum extends super const export import",6:"enum",strict:"implements interface let package private protected public static yield",strictBind:"eval arguments"},dr="break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this",wm={5:dr,"5module":dr+" export import",6:dr+" const class extends export import super"},Fs=/^in(stanceof)?$/,Sm=new RegExp("["+Bs+"]"),Em=new RegExp("["+Bs+vm+"]");function Tr(t,e){for(var i=65536,r=0;r<e.length;r+=2){if(i+=e[r],i>t)return!1;if(i+=e[r+1],i>=t)return!0}return!1}function ut(t,e){return t<65?t===36:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Sm.test(String.fromCharCode(t)):e===!1?!1:Tr(t,Ls)}function kt(t,e){return t<48?t===36:t<58?!0:t<65?!1:t<91?!0:t<97?t===95:t<123?!0:t<=65535?t>=170&&Em.test(String.fromCharCode(t)):e===!1?!1:Tr(t,Ls)||Tr(t,bm)}var Y=function(e,i){i===void 0&&(i={}),this.label=e,this.keyword=i.keyword,this.beforeExpr=!!i.beforeExpr,this.startsExpr=!!i.startsExpr,this.isLoop=!!i.isLoop,this.isAssign=!!i.isAssign,this.prefix=!!i.prefix,this.postfix=!!i.postfix,this.binop=i.binop||null,this.updateContext=null};function Ue(t,e){return new Y(t,{beforeExpr:!0,binop:e})}var qe={beforeExpr:!0},Me={startsExpr:!0},Ur={};function H(t,e){return e===void 0&&(e={}),e.keyword=t,Ur[t]=new Y(t,e)}var _={num:new Y("num",Me),regexp:new Y("regexp",Me),string:new Y("string",Me),name:new Y("name",Me),privateId:new Y("privateId",Me),eof:new Y("eof"),bracketL:new Y("[",{beforeExpr:!0,startsExpr:!0}),bracketR:new Y("]"),braceL:new Y("{",{beforeExpr:!0,startsExpr:!0}),braceR:new Y("}"),parenL:new Y("(",{beforeExpr:!0,startsExpr:!0}),parenR:new Y(")"),comma:new Y(",",qe),semi:new Y(";",qe),colon:new Y(":",qe),dot:new Y("."),question:new Y("?",qe),questionDot:new Y("?."),arrow:new Y("=>",qe),template:new Y("template"),invalidTemplate:new Y("invalidTemplate"),ellipsis:new Y("...",qe),backQuote:new Y("`",Me),dollarBraceL:new Y("${",{beforeExpr:!0,startsExpr:!0}),eq:new Y("=",{beforeExpr:!0,isAssign:!0}),assign:new Y("_=",{beforeExpr:!0,isAssign:!0}),incDec:new Y("++/--",{prefix:!0,postfix:!0,startsExpr:!0}),prefix:new Y("!/~",{beforeExpr:!0,prefix:!0,startsExpr:!0}),logicalOR:Ue("||",1),logicalAND:Ue("&&",2),bitwiseOR:Ue("|",3),bitwiseXOR:Ue("^",4),bitwiseAND:Ue("&",5),equality:Ue("==/!=/===/!==",6),relational:Ue("</>/<=/>=",7),bitShift:Ue("<</>>/>>>",8),plusMin:new Y("+/-",{beforeExpr:!0,binop:9,prefix:!0,startsExpr:!0}),modulo:Ue("%",10),star:Ue("*",10),slash:Ue("/",10),starstar:new Y("**",{beforeExpr:!0}),coalesce:Ue("??",1),_break:H("break"),_case:H("case",qe),_catch:H("catch"),_continue:H("continue"),_debugger:H("debugger"),_default:H("default",qe),_do:H("do",{isLoop:!0,beforeExpr:!0}),_else:H("else",qe),_finally:H("finally"),_for:H("for",{isLoop:!0}),_function:H("function",Me),_if:H("if"),_return:H("return",qe),_switch:H("switch"),_throw:H("throw",qe),_try:H("try"),_var:H("var"),_const:H("const"),_while:H("while",{isLoop:!0}),_with:H("with"),_new:H("new",{beforeExpr:!0,startsExpr:!0}),_this:H("this",Me),_super:H("super",Me),_class:H("class",Me),_extends:H("extends",qe),_export:H("export"),_import:H("import",Me),_null:H("null",Me),_true:H("true",Me),_false:H("false",Me),_in:H("in",{beforeExpr:!0,binop:7}),_instanceof:H("instanceof",{beforeExpr:!0,binop:7}),_typeof:H("typeof",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_void:H("void",{beforeExpr:!0,prefix:!0,startsExpr:!0}),_delete:H("delete",{beforeExpr:!0,prefix:!0,startsExpr:!0})},Oe=/\r\n?|\n|\u2028|\u2029/,Nm=new RegExp(Oe.source,"g");function ri(t){return t===10||t===13||t===8232||t===8233}function Ws(t,e,i){i===void 0&&(i=t.length);for(var r=e;r<i;r++){var n=t.charCodeAt(r);if(ri(n))return r<i-1&&n===13&&t.charCodeAt(r+1)===10?r+2:r+1}return-1}var Us=/[\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff]/,Se=/(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g,qs=Object.prototype,Cm=qs.hasOwnProperty,Im=qs.toString,ni=Object.hasOwn||(function(t,e){return Cm.call(t,e)}),Sn=Array.isArray||(function(t){return Im.call(t)==="[object Array]"}),En=Object.create(null);function Ct(t){return En[t]||(En[t]=new RegExp("^(?:"+t.replace(/ /g,"|")+")$"))}function gt(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}var km=/(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/,bi=function(e,i){this.line=e,this.column=i};bi.prototype.offset=function(e){return new bi(this.line,this.column+e)};var er=function(e,i,r){this.start=i,this.end=r,e.sourceFile!==null&&(this.source=e.sourceFile)};function zs(t,e){for(var i=1,r=0;;){var n=Ws(t,r,e);if(n<0)return new bi(i,e-r);++i,r=n}}var Ar={ecmaVersion:null,sourceType:"script",onInsertedSemicolon:null,onTrailingComma:null,allowReserved:null,allowReturnOutsideFunction:!1,allowImportExportEverywhere:!1,allowAwaitOutsideFunction:null,allowSuperOutsideMethod:null,allowHashBang:!1,checkPrivateFields:!0,locations:!1,onToken:null,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null,preserveParens:!1},Nn=!1;function Tm(t){var e={};for(var i in Ar)e[i]=t&&ni(t,i)?t[i]:Ar[i];if(e.ecmaVersion==="latest"?e.ecmaVersion=1e8:e.ecmaVersion==null?(!Nn&&typeof console=="object"&&console.warn&&(Nn=!0,console.warn(`Since Acorn 8.0.0, options.ecmaVersion is required.
|
|
3
3
|
Defaulting to 2020, but this will stop working in the future.`)),e.ecmaVersion=11):e.ecmaVersion>=2015&&(e.ecmaVersion-=2009),e.allowReserved==null&&(e.allowReserved=e.ecmaVersion<5),(!t||t.allowHashBang==null)&&(e.allowHashBang=e.ecmaVersion>=14),Sn(e.onToken)){var r=e.onToken;e.onToken=function(n){return r.push(n)}}if(Sn(e.onComment)&&(e.onComment=Am(e,e.onComment)),e.sourceType==="commonjs"&&e.allowAwaitOutsideFunction)throw new Error("Cannot use allowAwaitOutsideFunction with sourceType: commonjs");return e}function Am(t,e){return function(i,r,n,s,a,o){var l={type:i?"Block":"Line",value:r,start:n,end:s};t.locations&&(l.loc=new er(this,a,o)),t.ranges&&(l.range=[n,s]),e.push(l)}}var Ot=1,$t=2,qr=4,Ks=8,zr=16,Hs=32,tr=64,Gs=128,Vt=256,Si=512,Ys=1024,ir=Ot|$t|Vt;function Kr(t,e){return $t|(t?qr:0)|(e?Ks:0)}var zi=0,Hr=1,bt=2,Xs=3,Zs=4,Qs=5,pe=function(e,i,r){this.options=e=Tm(e),this.sourceFile=e.sourceFile,this.keywords=Ct(wm[e.ecmaVersion>=6?6:e.sourceType==="module"?"5module":5]);var n="";e.allowReserved!==!0&&(n=fr[e.ecmaVersion>=6?6:e.ecmaVersion===5?5:3],e.sourceType==="module"&&(n+=" await")),this.reservedWords=Ct(n);var s=(n?n+" ":"")+fr.strict;this.reservedWordsStrict=Ct(s),this.reservedWordsStrictBind=Ct(s+" "+fr.strictBind),this.input=String(i),this.containsEsc=!1,r?(this.pos=r,this.lineStart=this.input.lastIndexOf(`
|
|
4
|
-
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(Oe).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=_.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?$t:Ot),this.regexpState=null,this.privateNameStack=[]},Ye={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};pe.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};Ye.inFunction.get=function(){return(this.currentVarScope().flags&$t)>0};Ye.inGenerator.get=function(){return(this.currentVarScope().flags&Ks)>0};Ye.inAsync.get=function(){return(this.currentVarScope().flags&qr)>0};Ye.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Vt|Si))return!1;if(i&$t)return(i&qr)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ye.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Ot)};Ye.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&tr)>0||this.options.allowSuperOutsideMethod};Ye.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Gs)>0};Ye.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ye.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Vt|Si)||i&$t&&!(i&zr))return!0}return!1};Ye.allowUsing.get=function(){var t=this.currentScope(),e=t.flags;return!(e&Ys||!this.inModule&&e&Ot)};Ye.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Vt)>0};pe.extend=function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r};pe.parse=function(e,i){return new this(i,e).parse()};pe.parseExpressionAt=function(e,i,r){var n=new this(r,e,i);return n.nextToken(),n.parseExpression()};pe.tokenizer=function(e,i){return new this(i,e)};Object.defineProperties(pe.prototype,Ye);var Te=pe.prototype,Pm=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Te.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){Se.lastIndex=t,t+=Se.exec(this.input)[0].length;var e=Pm.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){Se.lastIndex=t+e[0].length;var i=Se.exec(this.input),r=i.index+i[0].length,n=this.input.charAt(r);return n===";"||n==="}"||Oe.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,Se.lastIndex=t,t+=Se.exec(this.input)[0].length,this.input[t]===";"&&t++}};Te.eat=function(t){return this.type===t?(this.next(),!0):!1};Te.isContextual=function(t){return this.type===_.name&&this.value===t&&!this.containsEsc};Te.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};Te.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};Te.canInsertSemicolon=function(){return this.type===_.eof||this.type===_.braceR||Oe.test(this.input.slice(this.lastTokEnd,this.start))};Te.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};Te.semicolon=function(){!this.eat(_.semi)&&!this.insertSemicolon()&&this.unexpected()};Te.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};Te.expect=function(t){this.eat(t)||this.unexpected()};Te.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var rr=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Te.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var i=e?t.parenthesizedAssign:t.parenthesizedBind;i>-1&&this.raiseRecoverable(i,e?"Assigning to rvalue":"Parenthesized pattern")}};Te.checkExpressionErrors=function(t,e){if(!t)return!1;var i=t.shorthandAssign,r=t.doubleProto;if(!e)return i>=0||r>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};Te.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};Te.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var M=pe.prototype;M.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==_.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var s=n[r];this.raiseRecoverable(this.undefinedExports[s].start,"Export '"+s+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(t,"Program")};var Gr={kind:"loop"},Dm={kind:"switch"};M.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;Se.lastIndex=this.pos;var e=Se.exec(this.input),i=this.pos+e[0].length,r=this.fullCharCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123)return!0;if(ut(r)){var n=i;do i+=r<=65535?1:2;while(kt(r=this.fullCharCodeAt(i)));if(r===92)return!0;var s=this.input.slice(n,i);if(!Fs.test(s))return!0}return!1};M.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Se.lastIndex=this.pos;var t=Se.exec(this.input),e=this.pos+t[0].length,i;return!Oe.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(kt(i=this.fullCharCodeAt(e+8))||i===92))};M.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;Se.lastIndex=this.pos;var i=Se.exec(this.input),r=this.pos+i[0].length;if(Oe.test(this.input.slice(this.pos,r)))return!1;if(t){var n=r+5,s;if(this.input.slice(r,n)!=="using"||n===this.input.length||kt(s=this.fullCharCodeAt(n))||s===92)return!1;Se.lastIndex=n;var a=Se.exec(this.input);if(r=n+a[0].length,a&&Oe.test(this.input.slice(n,r)))return!1}var o=this.fullCharCodeAt(r);if(!ut(o)&&o!==92)return!1;var l=r;do r+=o<=65535?1:2;while(kt(o=this.fullCharCodeAt(r)));if(o===92)return!0;var c=this.input.slice(l,r);return!(Fs.test(c)||e&&c==="of")};M.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};M.isUsing=function(t){return this.isUsingKeyword(!1,t)};M.parseStatement=function(t,e,i){var r=this.type,n=this.startNode(),s;switch(this.isLet(t)&&(r=_._var,s="let"),r){case _._break:case _._continue:return this.parseBreakContinueStatement(n,r.keyword);case _._debugger:return this.parseDebuggerStatement(n);case _._do:return this.parseDoStatement(n);case _._for:return this.parseForStatement(n);case _._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case _._class:return t&&this.unexpected(),this.parseClass(n,!0);case _._if:return this.parseIfStatement(n);case _._return:return this.parseReturnStatement(n);case _._switch:return this.parseSwitchStatement(n);case _._throw:return this.parseThrowStatement(n);case _._try:return this.parseTryStatement(n);case _._const:case _._var:return s=s||this.value,t&&s!=="var"&&this.unexpected(),this.parseVarStatement(n,s);case _._while:return this.parseWhileStatement(n);case _._with:return this.parseWithStatement(n);case _.braceL:return this.parseBlock(!0,n);case _.semi:return this.parseEmptyStatement(n);case _._export:case _._import:if(this.options.ecmaVersion>10&&r===_._import){Se.lastIndex=this.pos;var a=Se.exec(this.input),o=this.pos+a[0].length,l=this.input.charCodeAt(o);if(l===40||l===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===_._import?this.parseImport(n):this.parseExport(n,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,c),this.semicolon(),this.finishNode(n,"VariableDeclaration");var u=this.value,p=this.parseExpression();return r===_.name&&p.type==="Identifier"&&this.eat(_.colon)?this.parseLabeledStatement(n,u,p,t):this.parseExpressionStatement(n,p)}};M.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(_.semi)||this.insertSemicolon()?t.label=null:this.type!==_.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(i||n.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};M.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};M.parseDoStatement=function(t){return this.next(),this.labels.push(Gr),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(_._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(_.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};M.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Gr),this.enterScope(0),this.expect(_.parenL),this.type===_.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===_._var||this.type===_._const||i){var r=this.startNode(),n=i?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(t,r,e)}var s=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(t,l,e)}var c=this.containsEsc,u=new rr,p=this.start,h=e>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===_._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===_._in&&this.unexpected(e),t.await=!0):a&&this.options.ecmaVersion>=8&&(h.start===p&&!c&&h.type==="Identifier"&&h.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),s&&a&&this.raise(h.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(h,!1,u),this.checkLValPattern(h),this.parseForIn(t,h)):(this.checkExpressionErrors(u,!0),e>-1&&this.unexpected(e),this.parseFor(t,h))};M.parseForAfterInit=function(t,e,i){return(this.type===_._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===_._in?i>-1&&this.unexpected(i):t.await=i>-1),this.parseForIn(t,e)):(i>-1&&this.unexpected(i),this.parseFor(t,e))};M.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,mi|(i?0:Pr),!1,e)};M.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(_._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};M.parseReturnStatement=function(t){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(_.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};M.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(_.braceL),this.labels.push(Dm),this.enterScope(Ys);for(var e,i=!1;this.type!==_.braceR;)if(this.type===_._case||this.type===_._default){var r=this.type===_._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),r?e.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,e.test=null),this.expect(_.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")};M.parseThrowStatement=function(t){return this.next(),Oe.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var Mm=[];M.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?Hs:0),this.checkLValPattern(t,e?Zs:bt),this.expect(_.parenR),t};M.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===_._catch){var e=this.startNode();this.next(),this.eat(_.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(_._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};M.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};M.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(Gr),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};M.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")};M.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};M.parseLabeledStatement=function(t,e,i,r){for(var n=0,s=this.labels;n<s.length;n+=1){var a=s[n];a.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===_._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var c=this.labels[l];if(c.statementStart===t.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")};M.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};M.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(_.braceL),t&&this.enterScope(0);this.type!==_.braceR;){var r=this.parseStatement(null);e.body.push(r)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};M.parseFor=function(t,e){return t.init=e,this.expect(_.semi),t.test=this.type===_.semi?null:this.parseExpression(),this.expect(_.semi),t.update=this.type===_.parenR?null:this.parseExpression(),this.expect(_.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};M.parseForIn=function(t,e){var i=this.type===_._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(_.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};M.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var n=this.startNode();if(this.parseVarId(n,i),this.eat(_.eq)?n.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===_._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==_._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!r&&n.id.type!=="Identifier"&&!(e&&(this.type===_._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(_.comma))break}return t};M.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?Hr:bt,!1)};var mi=1,Pr=2,Js=4;M.parseFunction=function(t,e,i,r,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===_.star&&e&Pr&&this.unexpected(),t.generator=this.eat(_.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&mi&&(t.id=e&Js&&this.type!==_.name?null:this.parseIdent(),t.id&&!(e&Pr)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Hr:bt:Xs));var s=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kr(t.async,t.generator)),e&mi||(t.id=this.type===_.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,n),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(t,e&mi?"FunctionDeclaration":"FunctionExpression")};M.parseFunctionParams=function(t){this.expect(_.parenL),t.params=this.parseBindingList(_.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};M.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),n=this.startNode(),s=!1;for(n.body=[],this.expect(_.braceL);this.type!==_.braceR;){var a=this.parseClassElement(t.superClass!==null);a&&(n.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(s&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),s=!0):a.key&&a.key.type==="PrivateIdentifier"&&Rm(r,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};M.parseClassElement=function(t){if(this.eat(_.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",n=!1,s=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(_.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===_.star?o=!0:r="static"}if(i.static=o,!r&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===_.star)&&!this.canInsertSemicolon()?s=!0:r="async"),!r&&(e>=9||!s)&&this.eat(_.star)&&(n=!0),!r&&!s&&!n){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=l:r=l)}if(r?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=r,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),e<13||this.type===_.parenL||a!=="method"||n||s){var c=!i.static&&Ki(i,"constructor"),u=c&&t;c&&a!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":a,this.parseClassMethod(i,n,s,u)}else this.parseClassField(i);return i};M.isClassElementNameStart=function(){return this.type===_.name||this.type===_.privateId||this.type===_.num||this.type===_.string||this.type===_.bracketL||this.type.keyword};M.parseClassElementName=function(t){this.type===_.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)};M.parseClassMethod=function(t,e,i,r){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),i&&this.raise(n.start,"Constructor can't be an async method")):t.static&&Ki(t,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var s=t.value=this.parseMethod(e,i,r);return t.kind==="get"&&s.params.length!==0&&this.raiseRecoverable(s.start,"getter should have no params"),t.kind==="set"&&s.params.length!==1&&this.raiseRecoverable(s.start,"setter should have exactly one param"),t.kind==="set"&&s.params[0].type==="RestElement"&&this.raiseRecoverable(s.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")};M.parseClassField=function(t){return Ki(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&Ki(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(_.eq)?(this.enterScope(Si|tr),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};M.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(Vt|tr);this.type!==_.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};M.parseClassId=function(t,e){this.type===_.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,bt,!1)):(e===!0&&this.unexpected(),t.id=null)};M.parseClassSuper=function(t){t.superClass=this.eat(_._extends)?this.parseExprSubscripts(null,!1):null};M.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};M.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=r===0?null:this.privateNameStack[r-1],s=0;s<i.length;++s){var a=i[s];ni(e,a.name)||(n?n.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function Rm(t,e){var i=e.key.name,r=t[i],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),r==="iget"&&n==="iset"||r==="iset"&&n==="iget"||r==="sget"&&n==="sset"||r==="sset"&&n==="sget"?(t[i]="true",!1):r?!0:(t[i]=n,!1)}function Ki(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}M.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==_.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};M.parseExport=function(t,e){if(this.next(),this.eat(_.star))return this.parseExportAllDeclaration(t,e);if(this.eat(_._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==_.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var i=0,r=t.specifiers;i<r.length;i+=1){var n=r[i];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};M.parseExportDeclaration=function(t){return this.parseStatement(null)};M.parseExportDefaultDeclaration=function(){var t;if(this.type===_._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,mi|Js,!1,t)}else if(this.type===_._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};M.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),ni(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};M.checkPatternExport=function(t,e){var i=e.type;if(i==="Identifier")this.checkExport(t,e,e.start);else if(i==="ObjectPattern")for(var r=0,n=e.properties;r<n.length;r+=1){var s=n[r];this.checkPatternExport(t,s)}else if(i==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var l=o[a];l&&this.checkPatternExport(t,l)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};M.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var n=r[i];this.checkPatternExport(t,n.id)}};M.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};M.parseExportSpecifier=function(t){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(t,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};M.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(_.braceL);!this.eat(_.braceR);){if(i)i=!1;else if(this.expect(_.comma),this.afterTrailingComma(_.braceR))break;e.push(this.parseExportSpecifier(t))}return e};M.parseImport=function(t){return this.next(),this.type===_.string?(t.specifiers=Mm,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===_.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};M.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual("as")?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,bt),this.finishNode(t,"ImportSpecifier")};M.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,bt),this.finishNode(t,"ImportDefaultSpecifier")};M.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,bt),this.finishNode(t,"ImportNamespaceSpecifier")};M.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===_.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(_.comma)))return t;if(this.type===_.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(_.braceL);!this.eat(_.braceR);){if(e)e=!1;else if(this.expect(_.comma),this.afterTrailingComma(_.braceR))break;t.push(this.parseImportSpecifier())}return t};M.parseWithClause=function(){var t=[];if(!this.eat(_._with))return t;this.expect(_.braceL);for(var e={},i=!0;!this.eat(_.braceR);){if(i)i=!1;else if(this.expect(_.comma),this.afterTrailingComma(_.braceR))break;var r=this.parseImportAttribute(),n=r.key.type==="Identifier"?r.key.name:r.key.value;ni(e,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(r)}return t};M.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===_.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(_.colon),this.type!==_.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};M.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===_.string){var t=this.parseLiteral(this.value);return km.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};M.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)};M.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type==="ExpressionStatement"&&t.expression.type==="Literal"&&typeof t.expression.value=="string"&&(this.input[t.start]==='"'||this.input[t.start]==="'")};var Xe=pe.prototype;Xe.toAssignable=function(t,e,i){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&t.name==="await"&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];this.toAssignable(s,e),s.type==="RestElement"&&(s.argument.type==="ArrayPattern"||s.argument.type==="ObjectPattern")&&this.raise(s.argument.start,"Unexpected token")}break;case"Property":t.kind!=="init"&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,e);break;case"ArrayExpression":t.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(t.elements,e);break;case"SpreadElement":t.type="RestElement",this.toAssignable(t.argument,e),t.argument.type==="AssignmentPattern"&&this.raise(t.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":t.operator!=="="&&this.raise(t.left.end,"Only '=' operator can be used for specifying default value."),t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);break;case"ParenthesizedExpression":this.toAssignable(t.expression,e,i);break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return t};Xe.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var n=t[r];n&&this.toAssignable(n,e)}if(i){var s=t[i-1];this.options.ecmaVersion===6&&e&&s&&s.type==="RestElement"&&s.argument.type!=="Identifier"&&this.unexpected(s.argument.start)}return t};Xe.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};Xe.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==_.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};Xe.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case _.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(_.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case _.braceL:return this.parseObj(!0)}return this.parseIdent()};Xe.parseBindingList=function(t,e,i,r){for(var n=[],s=!0;!this.eat(t);)if(s?s=!1:this.expect(_.comma),e&&this.type===_.comma)n.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===_.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),n.push(a),this.type===_.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(r))}return n};Xe.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};Xe.parseBindingListItem=function(t){return t};Xe.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(_.eq))return i;var r=this.startNodeAt(t,e);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};Xe.checkLValSimple=function(t,e,i){e===void 0&&(e=zi);var r=e!==zi;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(r?"Binding ":"Assigning to ")+t.name+" in strict mode"),r&&(e===bt&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(ni(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==Qs&&this.declareName(t.name,e,t.start));break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,i);default:this.raise(t.start,(r?"Binding":"Assigning to")+" rvalue")}};Xe.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=zi),t.type){case"ObjectPattern":for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];this.checkLValInnerPattern(s,e,i)}break;case"ArrayPattern":for(var a=0,o=t.elements;a<o.length;a+=1){var l=o[a];l&&this.checkLValInnerPattern(l,e,i)}break;default:this.checkLValSimple(t,e,i)}};Xe.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=zi),t.type){case"Property":this.checkLValInnerPattern(t.value,e,i);break;case"AssignmentPattern":this.checkLValPattern(t.left,e,i);break;case"RestElement":this.checkLValPattern(t.argument,e,i);break;default:this.checkLValPattern(t,e,i)}};var Je=function(e,i,r,n,s){this.token=e,this.isExpr=!!i,this.preserveSpace=!!r,this.override=n,this.generator=!!s},re={b_stat:new Je("{",!1),b_expr:new Je("{",!0),b_tmpl:new Je("${",!1),p_stat:new Je("(",!1),p_expr:new Je("(",!0),q_tmpl:new Je("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new Je("function",!1),f_expr:new Je("function",!0),f_expr_gen:new Je("function",!0,!1,null,!0),f_gen:new Je("function",!1,!1,null,!0)},si=pe.prototype;si.initialContext=function(){return[re.b_stat]};si.curContext=function(){return this.context[this.context.length-1]};si.braceIsBlock=function(t){var e=this.curContext();return e===re.f_expr||e===re.f_stat?!0:t===_.colon&&(e===re.b_stat||e===re.b_expr)?!e.isExpr:t===_._return||t===_.name&&this.exprAllowed?Oe.test(this.input.slice(this.lastTokEnd,this.start)):t===_._else||t===_.semi||t===_.eof||t===_.parenR||t===_.arrow?!0:t===_.braceL?e===re.b_stat:t===_._var||t===_._const||t===_.name?!1:!this.exprAllowed};si.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var e=this.context[t];if(e.token==="function")return e.generator}return!1};si.updateContext=function(t){var e,i=this.type;i.keyword&&t===_.dot?this.exprAllowed=!1:(e=i.updateContext)?e.call(this,t):this.exprAllowed=i.beforeExpr};si.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};_.parenR.updateContext=_.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===re.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};_.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?re.b_stat:re.b_expr),this.exprAllowed=!0};_.dollarBraceL.updateContext=function(){this.context.push(re.b_tmpl),this.exprAllowed=!0};_.parenL.updateContext=function(t){var e=t===_._if||t===_._for||t===_._with||t===_._while;this.context.push(e?re.p_stat:re.p_expr),this.exprAllowed=!0};_.incDec.updateContext=function(){};_._function.updateContext=_._class.updateContext=function(t){t.beforeExpr&&t!==_._else&&!(t===_.semi&&this.curContext()!==re.p_stat)&&!(t===_._return&&Oe.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===_.colon||t===_.braceL)&&this.curContext()===re.b_stat)?this.context.push(re.f_expr):this.context.push(re.f_stat),this.exprAllowed=!1};_.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};_.backQuote.updateContext=function(){this.curContext()===re.q_tmpl?this.context.pop():this.context.push(re.q_tmpl),this.exprAllowed=!1};_.star.updateContext=function(t){if(t===_._function){var e=this.context.length-1;this.context[e]===re.f_expr?this.context[e]=re.f_expr_gen:this.context[e]=re.f_gen}this.exprAllowed=!0};_.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==_.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var L=pe.prototype;L.checkPropClash=function(t,e,i){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r=t.key,n;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var s=t.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&s==="init"&&(e.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0);return}n="$"+n;var a=e[n];if(a){var o;s==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[s],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=e[n]={init:!1,get:!1,set:!1};a[s]=!0}};L.parseExpression=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===_.comma){var s=this.startNodeAt(i,r);for(s.expressions=[n];this.eat(_.comma);)s.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(s,"SequenceExpression")}return n};L.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,n=-1,s=-1,a=-1;e?(n=e.parenthesizedAssign,s=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new rr,r=!0);var o=this.start,l=this.startLoc;(this.type===_.parenL||this.type===_.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var c=this.parseMaybeConditional(t,e);if(i&&(c=i.call(this,c,o,l)),this.type.isAssign){var u=this.startNodeAt(o,l);return u.operator=this.value,this.type===_.eq&&(c=this.toAssignable(c,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===_.eq?this.checkLValPattern(c):this.checkLValSimple(c),u.left=c,this.next(),u.right=this.parseMaybeAssign(t),a>-1&&(e.doubleProto=a),this.finishNode(u,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),s>-1&&(e.trailingComma=s),c};L.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(_.question)){var s=this.startNodeAt(i,r);return s.test=n,s.consequent=this.parseMaybeAssign(),this.expect(_.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return n};L.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===i&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,i,r,-1,t)};L.parseExprOp=function(t,e,i,r,n){var s=this.type.binop;if(s!=null&&(!n||this.type!==_._in)&&s>r){var a=this.type===_.logicalOR||this.type===_.logicalAND,o=this.type===_.coalesce;o&&(s=_.logicalAND.binop);var l=this.value;this.next();var c=this.start,u=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),c,u,s,n),h=this.buildBinary(e,i,t,p,l,a||o);return(a&&this.type===_.coalesce||o&&(this.type===_.logicalOR||this.type===_.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(h,e,i,r,n)}return t};L.buildBinary=function(t,e,i,r,n,s){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(t,e);return a.left=i,a.operator=n,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")};L.parseMaybeUnary=function(t,e,i,r){var n=this.start,s=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===_.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(t,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&ea(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Dr(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===_.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==_._in&&this.unexpected();else{if(a=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(n,s);c.operator=this.value,c.prefix=!1,c.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(_.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,s,a,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return a};function ea(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&ea(t.expression)}function Dr(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&Dr(t.expression)||t.type==="ParenthesizedExpression"&&Dr(t.expression)}L.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var s=this.parseSubscripts(n,i,r,!1,e);return t&&s.type==="MemberExpression"&&(t.parenthesizedAssign>=s.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=s.start&&(t.parenthesizedBind=-1),t.trailingComma>=s.start&&(t.trailingComma=-1)),s};L.parseSubscripts=function(t,e,i,r,n){for(var s=this.options.ecmaVersion>=8&&t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,a=!1;;){var o=this.parseSubscript(t,e,i,r,s,a,n);if(o.optional&&(a=!0),o===t||o.type==="ArrowFunctionExpression"){if(a){var l=this.startNodeAt(e,i);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}t=o}};L.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(_.arrow)};L.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};L.parseSubscript=function(t,e,i,r,n,s,a){var o=this.options.ecmaVersion>=11,l=o&&this.eat(_.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(_.bracketL);if(c||l&&this.type!==_.parenL&&this.type!==_.backQuote||this.eat(_.dot)){var u=this.startNodeAt(e,i);u.object=t,c?(u.property=this.parseExpression(),this.expect(_.bracketR)):this.type===_.privateId&&t.type!=="Super"?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!=="never"),u.computed=!!c,o&&(u.optional=l),t=this.finishNode(u,"MemberExpression")}else if(!r&&this.eat(_.parenL)){var p=new rr,h=this.yieldPos,f=this.awaitPos,d=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var m=this.parseExprList(_.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!l&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=h,this.awaitPos=f,this.awaitIdentPos=d,this.parseSubscriptAsyncArrow(e,i,m,a);this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=f||this.awaitPos,this.awaitIdentPos=d||this.awaitIdentPos;var x=this.startNodeAt(e,i);x.callee=t,x.arguments=m,o&&(x.optional=l),t=this.finishNode(x,"CallExpression")}else if(this.type===_.backQuote){(l||s)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var b=this.startNodeAt(e,i);b.tag=t,b.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(b,"TaggedTemplateExpression")}return t};L.parseExprAtom=function(t,e,i){this.type===_.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case _._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===_.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==_.dot&&this.type!==_.bracketL&&this.type!==_.parenL&&this.unexpected(),this.finishNode(r,"Super");case _._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case _.name:var s=this.start,a=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(_._function))return this.overrideContext(re.f_expr),this.parseFunction(this.startNodeAt(s,a),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(_.arrow))return this.parseArrowExpression(this.startNodeAt(s,a),[l],!1,e);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===_.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(_.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(s,a),[l],!0,e)}return l;case _.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case _.num:case _.string:return this.parseLiteral(this.value);case _._null:case _._true:case _._false:return r=this.startNode(),r.value=this.type===_._null?null:this.type===_._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case _.parenL:var u=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),p;case _.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(_.bracketR,!0,!0,t),this.finishNode(r,"ArrayExpression");case _.braceL:return this.overrideContext(re.b_expr),this.parseObj(!1,t);case _._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case _._class:return this.parseClass(this.startNode(),!1);case _._new:return this.parseNew();case _.backQuote:return this.parseTemplate();case _._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};L.parseExprAtomDefault=function(){this.unexpected()};L.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===_.parenL&&!t)return this.parseDynamicImport(e);if(this.type===_.dot){var i=this.startNodeAt(e.start,e.loc&&e.loc.start);return i.name="import",e.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};L.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(_.parenR)?t.options=null:(this.expect(_.comma),this.afterTrailingComma(_.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(_.parenR)||(this.expect(_.comma),this.afterTrailingComma(_.parenR)||this.unexpected())));else if(!this.eat(_.parenR)){var e=this.start;this.eat(_.comma)&&this.eat(_.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};L.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="meta"&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")};L.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};L.parseParenExpression=function(){this.expect(_.parenL);var t=this.parseExpression();return this.expect(_.parenR),t};L.shouldParseArrow=function(t){return!this.canInsertSemicolon()};L.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,n,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,l=[],c=!0,u=!1,p=new rr,h=this.yieldPos,f=this.awaitPos,d;for(this.yieldPos=0,this.awaitPos=0;this.type!==_.parenR;)if(c?c=!1:this.expect(_.comma),s&&this.afterTrailingComma(_.parenR,!0)){u=!0;break}else if(this.type===_.ellipsis){d=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===_.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var m=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(_.parenR),t&&this.shouldParseArrow(l)&&this.eat(_.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=h,this.awaitPos=f,this.parseParenArrowList(i,r,l,e);(!l.length||u)&&this.unexpected(this.lastTokStart),d&&this.unexpected(d),this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?(n=this.startNodeAt(a,o),n.expressions=l,this.finishNodeAt(n,"SequenceExpression",m,x)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var b=this.startNodeAt(i,r);return b.expression=n,this.finishNode(b,"ParenthesizedExpression")}else return n};L.parseParenItem=function(t){return t};L.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var Om=[];L.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===_.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var i=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="target"&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var r=this.start,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),this.eat(_.parenL)?t.arguments=this.parseExprList(_.parenR,this.options.ecmaVersion>=8,!1):t.arguments=Om,this.finishNode(t,"NewExpression")};L.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===_.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
4
|
+
`,r-1)+1,this.curLine=this.input.slice(0,this.lineStart).split(Oe).length):(this.pos=this.lineStart=0,this.curLine=1),this.type=_.eof,this.value=null,this.start=this.end=this.pos,this.startLoc=this.endLoc=this.curPosition(),this.lastTokEndLoc=this.lastTokStartLoc=null,this.lastTokStart=this.lastTokEnd=this.pos,this.context=this.initialContext(),this.exprAllowed=!0,this.inModule=e.sourceType==="module",this.strict=this.inModule||this.strictDirective(this.pos),this.potentialArrowAt=-1,this.potentialArrowInForAwait=!1,this.yieldPos=this.awaitPos=this.awaitIdentPos=0,this.labels=[],this.undefinedExports=Object.create(null),this.pos===0&&e.allowHashBang&&this.input.slice(0,2)==="#!"&&this.skipLineComment(2),this.scopeStack=[],this.enterScope(this.options.sourceType==="commonjs"?$t:Ot),this.regexpState=null,this.privateNameStack=[]},Ye={inFunction:{configurable:!0},inGenerator:{configurable:!0},inAsync:{configurable:!0},canAwait:{configurable:!0},allowReturn:{configurable:!0},allowSuper:{configurable:!0},allowDirectSuper:{configurable:!0},treatFunctionsAsVar:{configurable:!0},allowNewDotTarget:{configurable:!0},allowUsing:{configurable:!0},inClassStaticBlock:{configurable:!0}};pe.prototype.parse=function(){var e=this.options.program||this.startNode();return this.nextToken(),this.parseTopLevel(e)};Ye.inFunction.get=function(){return(this.currentVarScope().flags&$t)>0};Ye.inGenerator.get=function(){return(this.currentVarScope().flags&Ks)>0};Ye.inAsync.get=function(){return(this.currentVarScope().flags&qr)>0};Ye.canAwait.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Vt|Si))return!1;if(i&$t)return(i&qr)>0}return this.inModule&&this.options.ecmaVersion>=13||this.options.allowAwaitOutsideFunction};Ye.allowReturn.get=function(){return!!(this.inFunction||this.options.allowReturnOutsideFunction&&this.currentVarScope().flags&Ot)};Ye.allowSuper.get=function(){var t=this.currentThisScope(),e=t.flags;return(e&tr)>0||this.options.allowSuperOutsideMethod};Ye.allowDirectSuper.get=function(){return(this.currentThisScope().flags&Gs)>0};Ye.treatFunctionsAsVar.get=function(){return this.treatFunctionsAsVarInScope(this.currentScope())};Ye.allowNewDotTarget.get=function(){for(var t=this.scopeStack.length-1;t>=0;t--){var e=this.scopeStack[t],i=e.flags;if(i&(Vt|Si)||i&$t&&!(i&zr))return!0}return!1};Ye.allowUsing.get=function(){var t=this.currentScope(),e=t.flags;return!(e&Ys||!this.inModule&&e&Ot)};Ye.inClassStaticBlock.get=function(){return(this.currentVarScope().flags&Vt)>0};pe.extend=function(){for(var e=[],i=arguments.length;i--;)e[i]=arguments[i];for(var r=this,n=0;n<e.length;n++)r=e[n](r);return r};pe.parse=function(e,i){return new this(i,e).parse()};pe.parseExpressionAt=function(e,i,r){var n=new this(r,e,i);return n.nextToken(),n.parseExpression()};pe.tokenizer=function(e,i){return new this(i,e)};Object.defineProperties(pe.prototype,Ye);var Te=pe.prototype,Pm=/^(?:'((?:\\[^]|[^'\\])*?)'|"((?:\\[^]|[^"\\])*?)")/;Te.strictDirective=function(t){if(this.options.ecmaVersion<5)return!1;for(;;){Se.lastIndex=t,t+=Se.exec(this.input)[0].length;var e=Pm.exec(this.input.slice(t));if(!e)return!1;if((e[1]||e[2])==="use strict"){Se.lastIndex=t+e[0].length;var i=Se.exec(this.input),r=i.index+i[0].length,n=this.input.charAt(r);return n===";"||n==="}"||Oe.test(i[0])&&!(/[(`.[+\-/*%<>=,?^&]/.test(n)||n==="!"&&this.input.charAt(r+1)==="=")}t+=e[0].length,Se.lastIndex=t,t+=Se.exec(this.input)[0].length,this.input[t]===";"&&t++}};Te.eat=function(t){return this.type===t?(this.next(),!0):!1};Te.isContextual=function(t){return this.type===_.name&&this.value===t&&!this.containsEsc};Te.eatContextual=function(t){return this.isContextual(t)?(this.next(),!0):!1};Te.expectContextual=function(t){this.eatContextual(t)||this.unexpected()};Te.canInsertSemicolon=function(){return this.type===_.eof||this.type===_.braceR||Oe.test(this.input.slice(this.lastTokEnd,this.start))};Te.insertSemicolon=function(){if(this.canInsertSemicolon())return this.options.onInsertedSemicolon&&this.options.onInsertedSemicolon(this.lastTokEnd,this.lastTokEndLoc),!0};Te.semicolon=function(){!this.eat(_.semi)&&!this.insertSemicolon()&&this.unexpected()};Te.afterTrailingComma=function(t,e){if(this.type===t)return this.options.onTrailingComma&&this.options.onTrailingComma(this.lastTokStart,this.lastTokStartLoc),e||this.next(),!0};Te.expect=function(t){this.eat(t)||this.unexpected()};Te.unexpected=function(t){this.raise(t??this.start,"Unexpected token")};var rr=function(){this.shorthandAssign=this.trailingComma=this.parenthesizedAssign=this.parenthesizedBind=this.doubleProto=-1};Te.checkPatternErrors=function(t,e){if(t){t.trailingComma>-1&&this.raiseRecoverable(t.trailingComma,"Comma is not permitted after the rest element");var i=e?t.parenthesizedAssign:t.parenthesizedBind;i>-1&&this.raiseRecoverable(i,e?"Assigning to rvalue":"Parenthesized pattern")}};Te.checkExpressionErrors=function(t,e){if(!t)return!1;var i=t.shorthandAssign,r=t.doubleProto;if(!e)return i>=0||r>=0;i>=0&&this.raise(i,"Shorthand property assignments are valid only in destructuring patterns"),r>=0&&this.raiseRecoverable(r,"Redefinition of __proto__ property")};Te.checkYieldAwaitInDefaultParams=function(){this.yieldPos&&(!this.awaitPos||this.yieldPos<this.awaitPos)&&this.raise(this.yieldPos,"Yield expression cannot be a default value"),this.awaitPos&&this.raise(this.awaitPos,"Await expression cannot be a default value")};Te.isSimpleAssignTarget=function(t){return t.type==="ParenthesizedExpression"?this.isSimpleAssignTarget(t.expression):t.type==="Identifier"||t.type==="MemberExpression"};var M=pe.prototype;M.parseTopLevel=function(t){var e=Object.create(null);for(t.body||(t.body=[]);this.type!==_.eof;){var i=this.parseStatement(null,!0,e);t.body.push(i)}if(this.inModule)for(var r=0,n=Object.keys(this.undefinedExports);r<n.length;r+=1){var s=n[r];this.raiseRecoverable(this.undefinedExports[s].start,"Export '"+s+"' is not defined")}return this.adaptDirectivePrologue(t.body),this.next(),t.sourceType=this.options.sourceType==="commonjs"?"script":this.options.sourceType,this.finishNode(t,"Program")};var Gr={kind:"loop"},Dm={kind:"switch"};M.isLet=function(t){if(this.options.ecmaVersion<6||!this.isContextual("let"))return!1;Se.lastIndex=this.pos;var e=Se.exec(this.input),i=this.pos+e[0].length,r=this.fullCharCodeAt(i);if(r===91||r===92)return!0;if(t)return!1;if(r===123)return!0;if(ut(r)){var n=i;do i+=r<=65535?1:2;while(kt(r=this.fullCharCodeAt(i)));if(r===92)return!0;var s=this.input.slice(n,i);if(!Fs.test(s))return!0}return!1};M.isAsyncFunction=function(){if(this.options.ecmaVersion<8||!this.isContextual("async"))return!1;Se.lastIndex=this.pos;var t=Se.exec(this.input),e=this.pos+t[0].length,i;return!Oe.test(this.input.slice(this.pos,e))&&this.input.slice(e,e+8)==="function"&&(e+8===this.input.length||!(kt(i=this.fullCharCodeAt(e+8))||i===92))};M.isUsingKeyword=function(t,e){if(this.options.ecmaVersion<17||!this.isContextual(t?"await":"using"))return!1;Se.lastIndex=this.pos;var i=Se.exec(this.input),r=this.pos+i[0].length;if(Oe.test(this.input.slice(this.pos,r)))return!1;if(t){var n=r+5,s;if(this.input.slice(r,n)!=="using"||n===this.input.length||kt(s=this.fullCharCodeAt(n))||s===92)return!1;Se.lastIndex=n;var a=Se.exec(this.input);if(r=n+a[0].length,a&&Oe.test(this.input.slice(n,r)))return!1}var o=this.fullCharCodeAt(r);if(!ut(o)&&o!==92)return!1;var l=r;do r+=o<=65535?1:2;while(kt(o=this.fullCharCodeAt(r)));if(o===92)return!0;var c=this.input.slice(l,r);return!(Fs.test(c)||e&&c==="of")};M.isAwaitUsing=function(t){return this.isUsingKeyword(!0,t)};M.isUsing=function(t){return this.isUsingKeyword(!1,t)};M.parseStatement=function(t,e,i){var r=this.type,n=this.startNode(),s;switch(this.isLet(t)&&(r=_._var,s="let"),r){case _._break:case _._continue:return this.parseBreakContinueStatement(n,r.keyword);case _._debugger:return this.parseDebuggerStatement(n);case _._do:return this.parseDoStatement(n);case _._for:return this.parseForStatement(n);case _._function:return t&&(this.strict||t!=="if"&&t!=="label")&&this.options.ecmaVersion>=6&&this.unexpected(),this.parseFunctionStatement(n,!1,!t);case _._class:return t&&this.unexpected(),this.parseClass(n,!0);case _._if:return this.parseIfStatement(n);case _._return:return this.parseReturnStatement(n);case _._switch:return this.parseSwitchStatement(n);case _._throw:return this.parseThrowStatement(n);case _._try:return this.parseTryStatement(n);case _._const:case _._var:return s=s||this.value,t&&s!=="var"&&this.unexpected(),this.parseVarStatement(n,s);case _._while:return this.parseWhileStatement(n);case _._with:return this.parseWithStatement(n);case _.braceL:return this.parseBlock(!0,n);case _.semi:return this.parseEmptyStatement(n);case _._export:case _._import:if(this.options.ecmaVersion>10&&r===_._import){Se.lastIndex=this.pos;var a=Se.exec(this.input),o=this.pos+a[0].length,l=this.input.charCodeAt(o);if(l===40||l===46)return this.parseExpressionStatement(n,this.parseExpression())}return this.options.allowImportExportEverywhere||(e||this.raise(this.start,"'import' and 'export' may only appear at the top level"),this.inModule||this.raise(this.start,"'import' and 'export' may appear only with 'sourceType: module'")),r===_._import?this.parseImport(n):this.parseExport(n,i);default:if(this.isAsyncFunction())return t&&this.unexpected(),this.next(),this.parseFunctionStatement(n,!0,!t);var c=this.isAwaitUsing(!1)?"await using":this.isUsing(!1)?"using":null;if(c)return this.allowUsing||this.raise(this.start,"Using declaration cannot appear in the top level when source type is `script` or in the bare case statement"),c==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.next(),this.parseVar(n,!1,c),this.semicolon(),this.finishNode(n,"VariableDeclaration");var u=this.value,p=this.parseExpression();return r===_.name&&p.type==="Identifier"&&this.eat(_.colon)?this.parseLabeledStatement(n,u,p,t):this.parseExpressionStatement(n,p)}};M.parseBreakContinueStatement=function(t,e){var i=e==="break";this.next(),this.eat(_.semi)||this.insertSemicolon()?t.label=null:this.type!==_.name?this.unexpected():(t.label=this.parseIdent(),this.semicolon());for(var r=0;r<this.labels.length;++r){var n=this.labels[r];if((t.label==null||n.name===t.label.name)&&(n.kind!=null&&(i||n.kind==="loop")||t.label&&i))break}return r===this.labels.length&&this.raise(t.start,"Unsyntactic "+e),this.finishNode(t,i?"BreakStatement":"ContinueStatement")};M.parseDebuggerStatement=function(t){return this.next(),this.semicolon(),this.finishNode(t,"DebuggerStatement")};M.parseDoStatement=function(t){return this.next(),this.labels.push(Gr),t.body=this.parseStatement("do"),this.labels.pop(),this.expect(_._while),t.test=this.parseParenExpression(),this.options.ecmaVersion>=6?this.eat(_.semi):this.semicolon(),this.finishNode(t,"DoWhileStatement")};M.parseForStatement=function(t){this.next();var e=this.options.ecmaVersion>=9&&this.canAwait&&this.eatContextual("await")?this.lastTokStart:-1;if(this.labels.push(Gr),this.enterScope(0),this.expect(_.parenL),this.type===_.semi)return e>-1&&this.unexpected(e),this.parseFor(t,null);var i=this.isLet();if(this.type===_._var||this.type===_._const||i){var r=this.startNode(),n=i?"let":this.value;return this.next(),this.parseVar(r,!0,n),this.finishNode(r,"VariableDeclaration"),this.parseForAfterInit(t,r,e)}var s=this.isContextual("let"),a=!1,o=this.isUsing(!0)?"using":this.isAwaitUsing(!0)?"await using":null;if(o){var l=this.startNode();return this.next(),o==="await using"&&(this.canAwait||this.raise(this.start,"Await using cannot appear outside of async function"),this.next()),this.parseVar(l,!0,o),this.finishNode(l,"VariableDeclaration"),this.parseForAfterInit(t,l,e)}var c=this.containsEsc,u=new rr,p=this.start,h=e>-1?this.parseExprSubscripts(u,"await"):this.parseExpression(!0,u);return this.type===_._in||(a=this.options.ecmaVersion>=6&&this.isContextual("of"))?(e>-1?(this.type===_._in&&this.unexpected(e),t.await=!0):a&&this.options.ecmaVersion>=8&&(h.start===p&&!c&&h.type==="Identifier"&&h.name==="async"?this.unexpected():this.options.ecmaVersion>=9&&(t.await=!1)),s&&a&&this.raise(h.start,"The left-hand side of a for-of loop may not start with 'let'."),this.toAssignable(h,!1,u),this.checkLValPattern(h),this.parseForIn(t,h)):(this.checkExpressionErrors(u,!0),e>-1&&this.unexpected(e),this.parseFor(t,h))};M.parseForAfterInit=function(t,e,i){return(this.type===_._in||this.options.ecmaVersion>=6&&this.isContextual("of"))&&e.declarations.length===1?(this.options.ecmaVersion>=9&&(this.type===_._in?i>-1&&this.unexpected(i):t.await=i>-1),this.parseForIn(t,e)):(i>-1&&this.unexpected(i),this.parseFor(t,e))};M.parseFunctionStatement=function(t,e,i){return this.next(),this.parseFunction(t,mi|(i?0:Pr),!1,e)};M.parseIfStatement=function(t){return this.next(),t.test=this.parseParenExpression(),t.consequent=this.parseStatement("if"),t.alternate=this.eat(_._else)?this.parseStatement("if"):null,this.finishNode(t,"IfStatement")};M.parseReturnStatement=function(t){return this.allowReturn||this.raise(this.start,"'return' outside of function"),this.next(),this.eat(_.semi)||this.insertSemicolon()?t.argument=null:(t.argument=this.parseExpression(),this.semicolon()),this.finishNode(t,"ReturnStatement")};M.parseSwitchStatement=function(t){this.next(),t.discriminant=this.parseParenExpression(),t.cases=[],this.expect(_.braceL),this.labels.push(Dm),this.enterScope(Ys);for(var e,i=!1;this.type!==_.braceR;)if(this.type===_._case||this.type===_._default){var r=this.type===_._case;e&&this.finishNode(e,"SwitchCase"),t.cases.push(e=this.startNode()),e.consequent=[],this.next(),r?e.test=this.parseExpression():(i&&this.raiseRecoverable(this.lastTokStart,"Multiple default clauses"),i=!0,e.test=null),this.expect(_.colon)}else e||this.unexpected(),e.consequent.push(this.parseStatement(null));return this.exitScope(),e&&this.finishNode(e,"SwitchCase"),this.next(),this.labels.pop(),this.finishNode(t,"SwitchStatement")};M.parseThrowStatement=function(t){return this.next(),Oe.test(this.input.slice(this.lastTokEnd,this.start))&&this.raise(this.lastTokEnd,"Illegal newline after throw"),t.argument=this.parseExpression(),this.semicolon(),this.finishNode(t,"ThrowStatement")};var Mm=[];M.parseCatchClauseParam=function(){var t=this.parseBindingAtom(),e=t.type==="Identifier";return this.enterScope(e?Hs:0),this.checkLValPattern(t,e?Zs:bt),this.expect(_.parenR),t};M.parseTryStatement=function(t){if(this.next(),t.block=this.parseBlock(),t.handler=null,this.type===_._catch){var e=this.startNode();this.next(),this.eat(_.parenL)?e.param=this.parseCatchClauseParam():(this.options.ecmaVersion<10&&this.unexpected(),e.param=null,this.enterScope(0)),e.body=this.parseBlock(!1),this.exitScope(),t.handler=this.finishNode(e,"CatchClause")}return t.finalizer=this.eat(_._finally)?this.parseBlock():null,!t.handler&&!t.finalizer&&this.raise(t.start,"Missing catch or finally clause"),this.finishNode(t,"TryStatement")};M.parseVarStatement=function(t,e,i){return this.next(),this.parseVar(t,!1,e,i),this.semicolon(),this.finishNode(t,"VariableDeclaration")};M.parseWhileStatement=function(t){return this.next(),t.test=this.parseParenExpression(),this.labels.push(Gr),t.body=this.parseStatement("while"),this.labels.pop(),this.finishNode(t,"WhileStatement")};M.parseWithStatement=function(t){return this.strict&&this.raise(this.start,"'with' in strict mode"),this.next(),t.object=this.parseParenExpression(),t.body=this.parseStatement("with"),this.finishNode(t,"WithStatement")};M.parseEmptyStatement=function(t){return this.next(),this.finishNode(t,"EmptyStatement")};M.parseLabeledStatement=function(t,e,i,r){for(var n=0,s=this.labels;n<s.length;n+=1){var a=s[n];a.name===e&&this.raise(i.start,"Label '"+e+"' is already declared")}for(var o=this.type.isLoop?"loop":this.type===_._switch?"switch":null,l=this.labels.length-1;l>=0;l--){var c=this.labels[l];if(c.statementStart===t.start)c.statementStart=this.start,c.kind=o;else break}return this.labels.push({name:e,kind:o,statementStart:this.start}),t.body=this.parseStatement(r?r.indexOf("label")===-1?r+"label":r:"label"),this.labels.pop(),t.label=i,this.finishNode(t,"LabeledStatement")};M.parseExpressionStatement=function(t,e){return t.expression=e,this.semicolon(),this.finishNode(t,"ExpressionStatement")};M.parseBlock=function(t,e,i){for(t===void 0&&(t=!0),e===void 0&&(e=this.startNode()),e.body=[],this.expect(_.braceL),t&&this.enterScope(0);this.type!==_.braceR;){var r=this.parseStatement(null);e.body.push(r)}return i&&(this.strict=!1),this.next(),t&&this.exitScope(),this.finishNode(e,"BlockStatement")};M.parseFor=function(t,e){return t.init=e,this.expect(_.semi),t.test=this.type===_.semi?null:this.parseExpression(),this.expect(_.semi),t.update=this.type===_.parenR?null:this.parseExpression(),this.expect(_.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,"ForStatement")};M.parseForIn=function(t,e){var i=this.type===_._in;return this.next(),e.type==="VariableDeclaration"&&e.declarations[0].init!=null&&(!i||this.options.ecmaVersion<8||this.strict||e.kind!=="var"||e.declarations[0].id.type!=="Identifier")&&this.raise(e.start,(i?"for-in":"for-of")+" loop variable declaration may not have an initializer"),t.left=e,t.right=i?this.parseExpression():this.parseMaybeAssign(),this.expect(_.parenR),t.body=this.parseStatement("for"),this.exitScope(),this.labels.pop(),this.finishNode(t,i?"ForInStatement":"ForOfStatement")};M.parseVar=function(t,e,i,r){for(t.declarations=[],t.kind=i;;){var n=this.startNode();if(this.parseVarId(n,i),this.eat(_.eq)?n.init=this.parseMaybeAssign(e):!r&&i==="const"&&!(this.type===_._in||this.options.ecmaVersion>=6&&this.isContextual("of"))?this.unexpected():!r&&(i==="using"||i==="await using")&&this.options.ecmaVersion>=17&&this.type!==_._in&&!this.isContextual("of")?this.raise(this.lastTokEnd,"Missing initializer in "+i+" declaration"):!r&&n.id.type!=="Identifier"&&!(e&&(this.type===_._in||this.isContextual("of")))?this.raise(this.lastTokEnd,"Complex binding patterns require an initialization value"):n.init=null,t.declarations.push(this.finishNode(n,"VariableDeclarator")),!this.eat(_.comma))break}return t};M.parseVarId=function(t,e){t.id=e==="using"||e==="await using"?this.parseIdent():this.parseBindingAtom(),this.checkLValPattern(t.id,e==="var"?Hr:bt,!1)};var mi=1,Pr=2,Js=4;M.parseFunction=function(t,e,i,r,n){this.initFunction(t),(this.options.ecmaVersion>=9||this.options.ecmaVersion>=6&&!r)&&(this.type===_.star&&e&Pr&&this.unexpected(),t.generator=this.eat(_.star)),this.options.ecmaVersion>=8&&(t.async=!!r),e&mi&&(t.id=e&Js&&this.type!==_.name?null:this.parseIdent(),t.id&&!(e&Pr)&&this.checkLValSimple(t.id,this.strict||t.generator||t.async?this.treatFunctionsAsVar?Hr:bt:Xs));var s=this.yieldPos,a=this.awaitPos,o=this.awaitIdentPos;return this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kr(t.async,t.generator)),e&mi||(t.id=this.type===_.name?this.parseIdent():null),this.parseFunctionParams(t),this.parseFunctionBody(t,i,!1,n),this.yieldPos=s,this.awaitPos=a,this.awaitIdentPos=o,this.finishNode(t,e&mi?"FunctionDeclaration":"FunctionExpression")};M.parseFunctionParams=function(t){this.expect(_.parenL),t.params=this.parseBindingList(_.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams()};M.parseClass=function(t,e){this.next();var i=this.strict;this.strict=!0,this.parseClassId(t,e),this.parseClassSuper(t);var r=this.enterClassBody(),n=this.startNode(),s=!1;for(n.body=[],this.expect(_.braceL);this.type!==_.braceR;){var a=this.parseClassElement(t.superClass!==null);a&&(n.body.push(a),a.type==="MethodDefinition"&&a.kind==="constructor"?(s&&this.raiseRecoverable(a.start,"Duplicate constructor in the same class"),s=!0):a.key&&a.key.type==="PrivateIdentifier"&&Rm(r,a)&&this.raiseRecoverable(a.key.start,"Identifier '#"+a.key.name+"' has already been declared"))}return this.strict=i,this.next(),t.body=this.finishNode(n,"ClassBody"),this.exitClassBody(),this.finishNode(t,e?"ClassDeclaration":"ClassExpression")};M.parseClassElement=function(t){if(this.eat(_.semi))return null;var e=this.options.ecmaVersion,i=this.startNode(),r="",n=!1,s=!1,a="method",o=!1;if(this.eatContextual("static")){if(e>=13&&this.eat(_.braceL))return this.parseClassStaticBlock(i),i;this.isClassElementNameStart()||this.type===_.star?o=!0:r="static"}if(i.static=o,!r&&e>=8&&this.eatContextual("async")&&((this.isClassElementNameStart()||this.type===_.star)&&!this.canInsertSemicolon()?s=!0:r="async"),!r&&(e>=9||!s)&&this.eat(_.star)&&(n=!0),!r&&!s&&!n){var l=this.value;(this.eatContextual("get")||this.eatContextual("set"))&&(this.isClassElementNameStart()?a=l:r=l)}if(r?(i.computed=!1,i.key=this.startNodeAt(this.lastTokStart,this.lastTokStartLoc),i.key.name=r,this.finishNode(i.key,"Identifier")):this.parseClassElementName(i),e<13||this.type===_.parenL||a!=="method"||n||s){var c=!i.static&&Ki(i,"constructor"),u=c&&t;c&&a!=="method"&&this.raise(i.key.start,"Constructor can't have get/set modifier"),i.kind=c?"constructor":a,this.parseClassMethod(i,n,s,u)}else this.parseClassField(i);return i};M.isClassElementNameStart=function(){return this.type===_.name||this.type===_.privateId||this.type===_.num||this.type===_.string||this.type===_.bracketL||this.type.keyword};M.parseClassElementName=function(t){this.type===_.privateId?(this.value==="constructor"&&this.raise(this.start,"Classes can't have an element named '#constructor'"),t.computed=!1,t.key=this.parsePrivateIdent()):this.parsePropertyName(t)};M.parseClassMethod=function(t,e,i,r){var n=t.key;t.kind==="constructor"?(e&&this.raise(n.start,"Constructor can't be a generator"),i&&this.raise(n.start,"Constructor can't be an async method")):t.static&&Ki(t,"prototype")&&this.raise(n.start,"Classes may not have a static property named prototype");var s=t.value=this.parseMethod(e,i,r);return t.kind==="get"&&s.params.length!==0&&this.raiseRecoverable(s.start,"getter should have no params"),t.kind==="set"&&s.params.length!==1&&this.raiseRecoverable(s.start,"setter should have exactly one param"),t.kind==="set"&&s.params[0].type==="RestElement"&&this.raiseRecoverable(s.params[0].start,"Setter cannot use rest params"),this.finishNode(t,"MethodDefinition")};M.parseClassField=function(t){return Ki(t,"constructor")?this.raise(t.key.start,"Classes can't have a field named 'constructor'"):t.static&&Ki(t,"prototype")&&this.raise(t.key.start,"Classes can't have a static field named 'prototype'"),this.eat(_.eq)?(this.enterScope(Si|tr),t.value=this.parseMaybeAssign(),this.exitScope()):t.value=null,this.semicolon(),this.finishNode(t,"PropertyDefinition")};M.parseClassStaticBlock=function(t){t.body=[];var e=this.labels;for(this.labels=[],this.enterScope(Vt|tr);this.type!==_.braceR;){var i=this.parseStatement(null);t.body.push(i)}return this.next(),this.exitScope(),this.labels=e,this.finishNode(t,"StaticBlock")};M.parseClassId=function(t,e){this.type===_.name?(t.id=this.parseIdent(),e&&this.checkLValSimple(t.id,bt,!1)):(e===!0&&this.unexpected(),t.id=null)};M.parseClassSuper=function(t){t.superClass=this.eat(_._extends)?this.parseExprSubscripts(null,!1):null};M.enterClassBody=function(){var t={declared:Object.create(null),used:[]};return this.privateNameStack.push(t),t.declared};M.exitClassBody=function(){var t=this.privateNameStack.pop(),e=t.declared,i=t.used;if(this.options.checkPrivateFields)for(var r=this.privateNameStack.length,n=r===0?null:this.privateNameStack[r-1],s=0;s<i.length;++s){var a=i[s];ni(e,a.name)||(n?n.used.push(a):this.raiseRecoverable(a.start,"Private field '#"+a.name+"' must be declared in an enclosing class"))}};function Rm(t,e){var i=e.key.name,r=t[i],n="true";return e.type==="MethodDefinition"&&(e.kind==="get"||e.kind==="set")&&(n=(e.static?"s":"i")+e.kind),r==="iget"&&n==="iset"||r==="iset"&&n==="iget"||r==="sget"&&n==="sset"||r==="sset"&&n==="sget"?(t[i]="true",!1):r?!0:(t[i]=n,!1)}function Ki(t,e){var i=t.computed,r=t.key;return!i&&(r.type==="Identifier"&&r.name===e||r.type==="Literal"&&r.value===e)}M.parseExportAllDeclaration=function(t,e){return this.options.ecmaVersion>=11&&(this.eatContextual("as")?(t.exported=this.parseModuleExportName(),this.checkExport(e,t.exported,this.lastTokStart)):t.exported=null),this.expectContextual("from"),this.type!==_.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ExportAllDeclaration")};M.parseExport=function(t,e){if(this.next(),this.eat(_.star))return this.parseExportAllDeclaration(t,e);if(this.eat(_._default))return this.checkExport(e,"default",this.lastTokStart),t.declaration=this.parseExportDefaultDeclaration(),this.finishNode(t,"ExportDefaultDeclaration");if(this.shouldParseExportStatement())t.declaration=this.parseExportDeclaration(t),t.declaration.type==="VariableDeclaration"?this.checkVariableExport(e,t.declaration.declarations):this.checkExport(e,t.declaration.id,t.declaration.id.start),t.specifiers=[],t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[]);else{if(t.declaration=null,t.specifiers=this.parseExportSpecifiers(e),this.eatContextual("from"))this.type!==_.string&&this.unexpected(),t.source=this.parseExprAtom(),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause());else{for(var i=0,r=t.specifiers;i<r.length;i+=1){var n=r[i];this.checkUnreserved(n.local),this.checkLocalExport(n.local),n.local.type==="Literal"&&this.raise(n.local.start,"A string literal cannot be used as an exported binding without `from`.")}t.source=null,this.options.ecmaVersion>=16&&(t.attributes=[])}this.semicolon()}return this.finishNode(t,"ExportNamedDeclaration")};M.parseExportDeclaration=function(t){return this.parseStatement(null)};M.parseExportDefaultDeclaration=function(){var t;if(this.type===_._function||(t=this.isAsyncFunction())){var e=this.startNode();return this.next(),t&&this.next(),this.parseFunction(e,mi|Js,!1,t)}else if(this.type===_._class){var i=this.startNode();return this.parseClass(i,"nullableID")}else{var r=this.parseMaybeAssign();return this.semicolon(),r}};M.checkExport=function(t,e,i){t&&(typeof e!="string"&&(e=e.type==="Identifier"?e.name:e.value),ni(t,e)&&this.raiseRecoverable(i,"Duplicate export '"+e+"'"),t[e]=!0)};M.checkPatternExport=function(t,e){var i=e.type;if(i==="Identifier")this.checkExport(t,e,e.start);else if(i==="ObjectPattern")for(var r=0,n=e.properties;r<n.length;r+=1){var s=n[r];this.checkPatternExport(t,s)}else if(i==="ArrayPattern")for(var a=0,o=e.elements;a<o.length;a+=1){var l=o[a];l&&this.checkPatternExport(t,l)}else i==="Property"?this.checkPatternExport(t,e.value):i==="AssignmentPattern"?this.checkPatternExport(t,e.left):i==="RestElement"&&this.checkPatternExport(t,e.argument)};M.checkVariableExport=function(t,e){if(t)for(var i=0,r=e;i<r.length;i+=1){var n=r[i];this.checkPatternExport(t,n.id)}};M.shouldParseExportStatement=function(){return this.type.keyword==="var"||this.type.keyword==="const"||this.type.keyword==="class"||this.type.keyword==="function"||this.isLet()||this.isAsyncFunction()};M.parseExportSpecifier=function(t){var e=this.startNode();return e.local=this.parseModuleExportName(),e.exported=this.eatContextual("as")?this.parseModuleExportName():e.local,this.checkExport(t,e.exported,e.exported.start),this.finishNode(e,"ExportSpecifier")};M.parseExportSpecifiers=function(t){var e=[],i=!0;for(this.expect(_.braceL);!this.eat(_.braceR);){if(i)i=!1;else if(this.expect(_.comma),this.afterTrailingComma(_.braceR))break;e.push(this.parseExportSpecifier(t))}return e};M.parseImport=function(t){return this.next(),this.type===_.string?(t.specifiers=Mm,t.source=this.parseExprAtom()):(t.specifiers=this.parseImportSpecifiers(),this.expectContextual("from"),t.source=this.type===_.string?this.parseExprAtom():this.unexpected()),this.options.ecmaVersion>=16&&(t.attributes=this.parseWithClause()),this.semicolon(),this.finishNode(t,"ImportDeclaration")};M.parseImportSpecifier=function(){var t=this.startNode();return t.imported=this.parseModuleExportName(),this.eatContextual("as")?t.local=this.parseIdent():(this.checkUnreserved(t.imported),t.local=t.imported),this.checkLValSimple(t.local,bt),this.finishNode(t,"ImportSpecifier")};M.parseImportDefaultSpecifier=function(){var t=this.startNode();return t.local=this.parseIdent(),this.checkLValSimple(t.local,bt),this.finishNode(t,"ImportDefaultSpecifier")};M.parseImportNamespaceSpecifier=function(){var t=this.startNode();return this.next(),this.expectContextual("as"),t.local=this.parseIdent(),this.checkLValSimple(t.local,bt),this.finishNode(t,"ImportNamespaceSpecifier")};M.parseImportSpecifiers=function(){var t=[],e=!0;if(this.type===_.name&&(t.push(this.parseImportDefaultSpecifier()),!this.eat(_.comma)))return t;if(this.type===_.star)return t.push(this.parseImportNamespaceSpecifier()),t;for(this.expect(_.braceL);!this.eat(_.braceR);){if(e)e=!1;else if(this.expect(_.comma),this.afterTrailingComma(_.braceR))break;t.push(this.parseImportSpecifier())}return t};M.parseWithClause=function(){var t=[];if(!this.eat(_._with))return t;this.expect(_.braceL);for(var e={},i=!0;!this.eat(_.braceR);){if(i)i=!1;else if(this.expect(_.comma),this.afterTrailingComma(_.braceR))break;var r=this.parseImportAttribute(),n=r.key.type==="Identifier"?r.key.name:r.key.value;ni(e,n)&&this.raiseRecoverable(r.key.start,"Duplicate attribute key '"+n+"'"),e[n]=!0,t.push(r)}return t};M.parseImportAttribute=function(){var t=this.startNode();return t.key=this.type===_.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never"),this.expect(_.colon),this.type!==_.string&&this.unexpected(),t.value=this.parseExprAtom(),this.finishNode(t,"ImportAttribute")};M.parseModuleExportName=function(){if(this.options.ecmaVersion>=13&&this.type===_.string){var t=this.parseLiteral(this.value);return km.test(t.value)&&this.raise(t.start,"An export name cannot include a lone surrogate."),t}return this.parseIdent(!0)};M.adaptDirectivePrologue=function(t){for(var e=0;e<t.length&&this.isDirectiveCandidate(t[e]);++e)t[e].directive=t[e].expression.raw.slice(1,-1)};M.isDirectiveCandidate=function(t){return this.options.ecmaVersion>=5&&t.type==="ExpressionStatement"&&t.expression.type==="Literal"&&typeof t.expression.value=="string"&&(this.input[t.start]==='"'||this.input[t.start]==="'")};var Xe=pe.prototype;Xe.toAssignable=function(t,e,i){if(this.options.ecmaVersion>=6&&t)switch(t.type){case"Identifier":this.inAsync&&t.name==="await"&&this.raise(t.start,"Cannot use 'await' as identifier inside an async function");break;case"ObjectPattern":case"ArrayPattern":case"AssignmentPattern":case"RestElement":break;case"ObjectExpression":t.type="ObjectPattern",i&&this.checkPatternErrors(i,!0);for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];this.toAssignable(s,e),s.type==="RestElement"&&(s.argument.type==="ArrayPattern"||s.argument.type==="ObjectPattern")&&this.raise(s.argument.start,"Unexpected token")}break;case"Property":t.kind!=="init"&&this.raise(t.key.start,"Object pattern can't contain getter or setter"),this.toAssignable(t.value,e);break;case"ArrayExpression":t.type="ArrayPattern",i&&this.checkPatternErrors(i,!0),this.toAssignableList(t.elements,e);break;case"SpreadElement":t.type="RestElement",this.toAssignable(t.argument,e),t.argument.type==="AssignmentPattern"&&this.raise(t.argument.start,"Rest elements cannot have a default value");break;case"AssignmentExpression":t.operator!=="="&&this.raise(t.left.end,"Only '=' operator can be used for specifying default value."),t.type="AssignmentPattern",delete t.operator,this.toAssignable(t.left,e);break;case"ParenthesizedExpression":this.toAssignable(t.expression,e,i);break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":if(!e)break;default:this.raise(t.start,"Assigning to rvalue")}else i&&this.checkPatternErrors(i,!0);return t};Xe.toAssignableList=function(t,e){for(var i=t.length,r=0;r<i;r++){var n=t[r];n&&this.toAssignable(n,e)}if(i){var s=t[i-1];this.options.ecmaVersion===6&&e&&s&&s.type==="RestElement"&&s.argument.type!=="Identifier"&&this.unexpected(s.argument.start)}return t};Xe.parseSpread=function(t){var e=this.startNode();return this.next(),e.argument=this.parseMaybeAssign(!1,t),this.finishNode(e,"SpreadElement")};Xe.parseRestBinding=function(){var t=this.startNode();return this.next(),this.options.ecmaVersion===6&&this.type!==_.name&&this.unexpected(),t.argument=this.parseBindingAtom(),this.finishNode(t,"RestElement")};Xe.parseBindingAtom=function(){if(this.options.ecmaVersion>=6)switch(this.type){case _.bracketL:var t=this.startNode();return this.next(),t.elements=this.parseBindingList(_.bracketR,!0,!0),this.finishNode(t,"ArrayPattern");case _.braceL:return this.parseObj(!0)}return this.parseIdent()};Xe.parseBindingList=function(t,e,i,r){for(var n=[],s=!0;!this.eat(t);)if(s?s=!1:this.expect(_.comma),e&&this.type===_.comma)n.push(null);else{if(i&&this.afterTrailingComma(t))break;if(this.type===_.ellipsis){var a=this.parseRestBinding();this.parseBindingListItem(a),n.push(a),this.type===_.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.expect(t);break}else n.push(this.parseAssignableListItem(r))}return n};Xe.parseAssignableListItem=function(t){var e=this.parseMaybeDefault(this.start,this.startLoc);return this.parseBindingListItem(e),e};Xe.parseBindingListItem=function(t){return t};Xe.parseMaybeDefault=function(t,e,i){if(i=i||this.parseBindingAtom(),this.options.ecmaVersion<6||!this.eat(_.eq))return i;var r=this.startNodeAt(t,e);return r.left=i,r.right=this.parseMaybeAssign(),this.finishNode(r,"AssignmentPattern")};Xe.checkLValSimple=function(t,e,i){e===void 0&&(e=zi);var r=e!==zi;switch(t.type){case"Identifier":this.strict&&this.reservedWordsStrictBind.test(t.name)&&this.raiseRecoverable(t.start,(r?"Binding ":"Assigning to ")+t.name+" in strict mode"),r&&(e===bt&&t.name==="let"&&this.raiseRecoverable(t.start,"let is disallowed as a lexically bound name"),i&&(ni(i,t.name)&&this.raiseRecoverable(t.start,"Argument name clash"),i[t.name]=!0),e!==Qs&&this.declareName(t.name,e,t.start));break;case"ChainExpression":this.raiseRecoverable(t.start,"Optional chaining cannot appear in left-hand side");break;case"MemberExpression":r&&this.raiseRecoverable(t.start,"Binding member expression");break;case"ParenthesizedExpression":return r&&this.raiseRecoverable(t.start,"Binding parenthesized expression"),this.checkLValSimple(t.expression,e,i);default:this.raise(t.start,(r?"Binding":"Assigning to")+" rvalue")}};Xe.checkLValPattern=function(t,e,i){switch(e===void 0&&(e=zi),t.type){case"ObjectPattern":for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];this.checkLValInnerPattern(s,e,i)}break;case"ArrayPattern":for(var a=0,o=t.elements;a<o.length;a+=1){var l=o[a];l&&this.checkLValInnerPattern(l,e,i)}break;default:this.checkLValSimple(t,e,i)}};Xe.checkLValInnerPattern=function(t,e,i){switch(e===void 0&&(e=zi),t.type){case"Property":this.checkLValInnerPattern(t.value,e,i);break;case"AssignmentPattern":this.checkLValPattern(t.left,e,i);break;case"RestElement":this.checkLValPattern(t.argument,e,i);break;default:this.checkLValPattern(t,e,i)}};var Je=function(e,i,r,n,s){this.token=e,this.isExpr=!!i,this.preserveSpace=!!r,this.override=n,this.generator=!!s},re={b_stat:new Je("{",!1),b_expr:new Je("{",!0),b_tmpl:new Je("${",!1),p_stat:new Je("(",!1),p_expr:new Je("(",!0),q_tmpl:new Je("`",!0,!0,function(t){return t.tryReadTemplateToken()}),f_stat:new Je("function",!1),f_expr:new Je("function",!0),f_expr_gen:new Je("function",!0,!1,null,!0),f_gen:new Je("function",!1,!1,null,!0)},si=pe.prototype;si.initialContext=function(){return[re.b_stat]};si.curContext=function(){return this.context[this.context.length-1]};si.braceIsBlock=function(t){var e=this.curContext();return e===re.f_expr||e===re.f_stat?!0:t===_.colon&&(e===re.b_stat||e===re.b_expr)?!e.isExpr:t===_._return||t===_.name&&this.exprAllowed?Oe.test(this.input.slice(this.lastTokEnd,this.start)):t===_._else||t===_.semi||t===_.eof||t===_.parenR||t===_.arrow?!0:t===_.braceL?e===re.b_stat:t===_._var||t===_._const||t===_.name?!1:!this.exprAllowed};si.inGeneratorContext=function(){for(var t=this.context.length-1;t>=1;t--){var e=this.context[t];if(e.token==="function")return e.generator}return!1};si.updateContext=function(t){var e,i=this.type;i.keyword&&t===_.dot?this.exprAllowed=!1:(e=i.updateContext)?e.call(this,t):this.exprAllowed=i.beforeExpr};si.overrideContext=function(t){this.curContext()!==t&&(this.context[this.context.length-1]=t)};_.parenR.updateContext=_.braceR.updateContext=function(){if(this.context.length===1){this.exprAllowed=!0;return}var t=this.context.pop();t===re.b_stat&&this.curContext().token==="function"&&(t=this.context.pop()),this.exprAllowed=!t.isExpr};_.braceL.updateContext=function(t){this.context.push(this.braceIsBlock(t)?re.b_stat:re.b_expr),this.exprAllowed=!0};_.dollarBraceL.updateContext=function(){this.context.push(re.b_tmpl),this.exprAllowed=!0};_.parenL.updateContext=function(t){var e=t===_._if||t===_._for||t===_._with||t===_._while;this.context.push(e?re.p_stat:re.p_expr),this.exprAllowed=!0};_.incDec.updateContext=function(){};_._function.updateContext=_._class.updateContext=function(t){t.beforeExpr&&t!==_._else&&!(t===_.semi&&this.curContext()!==re.p_stat)&&!(t===_._return&&Oe.test(this.input.slice(this.lastTokEnd,this.start)))&&!((t===_.colon||t===_.braceL)&&this.curContext()===re.b_stat)?this.context.push(re.f_expr):this.context.push(re.f_stat),this.exprAllowed=!1};_.colon.updateContext=function(){this.curContext().token==="function"&&this.context.pop(),this.exprAllowed=!0};_.backQuote.updateContext=function(){this.curContext()===re.q_tmpl?this.context.pop():this.context.push(re.q_tmpl),this.exprAllowed=!1};_.star.updateContext=function(t){if(t===_._function){var e=this.context.length-1;this.context[e]===re.f_expr?this.context[e]=re.f_expr_gen:this.context[e]=re.f_gen}this.exprAllowed=!0};_.name.updateContext=function(t){var e=!1;this.options.ecmaVersion>=6&&t!==_.dot&&(this.value==="of"&&!this.exprAllowed||this.value==="yield"&&this.inGeneratorContext())&&(e=!0),this.exprAllowed=e};var B=pe.prototype;B.checkPropClash=function(t,e,i){if(!(this.options.ecmaVersion>=9&&t.type==="SpreadElement")&&!(this.options.ecmaVersion>=6&&(t.computed||t.method||t.shorthand))){var r=t.key,n;switch(r.type){case"Identifier":n=r.name;break;case"Literal":n=String(r.value);break;default:return}var s=t.kind;if(this.options.ecmaVersion>=6){n==="__proto__"&&s==="init"&&(e.proto&&(i?i.doubleProto<0&&(i.doubleProto=r.start):this.raiseRecoverable(r.start,"Redefinition of __proto__ property")),e.proto=!0);return}n="$"+n;var a=e[n];if(a){var o;s==="init"?o=this.strict&&a.init||a.get||a.set:o=a.init||a[s],o&&this.raiseRecoverable(r.start,"Redefinition of property")}else a=e[n]={init:!1,get:!1,set:!1};a[s]=!0}};B.parseExpression=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeAssign(t,e);if(this.type===_.comma){var s=this.startNodeAt(i,r);for(s.expressions=[n];this.eat(_.comma);)s.expressions.push(this.parseMaybeAssign(t,e));return this.finishNode(s,"SequenceExpression")}return n};B.parseMaybeAssign=function(t,e,i){if(this.isContextual("yield")){if(this.inGenerator)return this.parseYield(t);this.exprAllowed=!1}var r=!1,n=-1,s=-1,a=-1;e?(n=e.parenthesizedAssign,s=e.trailingComma,a=e.doubleProto,e.parenthesizedAssign=e.trailingComma=-1):(e=new rr,r=!0);var o=this.start,l=this.startLoc;(this.type===_.parenL||this.type===_.name)&&(this.potentialArrowAt=this.start,this.potentialArrowInForAwait=t==="await");var c=this.parseMaybeConditional(t,e);if(i&&(c=i.call(this,c,o,l)),this.type.isAssign){var u=this.startNodeAt(o,l);return u.operator=this.value,this.type===_.eq&&(c=this.toAssignable(c,!1,e)),r||(e.parenthesizedAssign=e.trailingComma=e.doubleProto=-1),e.shorthandAssign>=c.start&&(e.shorthandAssign=-1),this.type===_.eq?this.checkLValPattern(c):this.checkLValSimple(c),u.left=c,this.next(),u.right=this.parseMaybeAssign(t),a>-1&&(e.doubleProto=a),this.finishNode(u,"AssignmentExpression")}else r&&this.checkExpressionErrors(e,!0);return n>-1&&(e.parenthesizedAssign=n),s>-1&&(e.trailingComma=s),c};B.parseMaybeConditional=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprOps(t,e);if(this.checkExpressionErrors(e))return n;if(this.eat(_.question)){var s=this.startNodeAt(i,r);return s.test=n,s.consequent=this.parseMaybeAssign(),this.expect(_.colon),s.alternate=this.parseMaybeAssign(t),this.finishNode(s,"ConditionalExpression")}return n};B.parseExprOps=function(t,e){var i=this.start,r=this.startLoc,n=this.parseMaybeUnary(e,!1,!1,t);return this.checkExpressionErrors(e)||n.start===i&&n.type==="ArrowFunctionExpression"?n:this.parseExprOp(n,i,r,-1,t)};B.parseExprOp=function(t,e,i,r,n){var s=this.type.binop;if(s!=null&&(!n||this.type!==_._in)&&s>r){var a=this.type===_.logicalOR||this.type===_.logicalAND,o=this.type===_.coalesce;o&&(s=_.logicalAND.binop);var l=this.value;this.next();var c=this.start,u=this.startLoc,p=this.parseExprOp(this.parseMaybeUnary(null,!1,!1,n),c,u,s,n),h=this.buildBinary(e,i,t,p,l,a||o);return(a&&this.type===_.coalesce||o&&(this.type===_.logicalOR||this.type===_.logicalAND))&&this.raiseRecoverable(this.start,"Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses"),this.parseExprOp(h,e,i,r,n)}return t};B.buildBinary=function(t,e,i,r,n,s){r.type==="PrivateIdentifier"&&this.raise(r.start,"Private identifier can only be left side of binary expression");var a=this.startNodeAt(t,e);return a.left=i,a.operator=n,a.right=r,this.finishNode(a,s?"LogicalExpression":"BinaryExpression")};B.parseMaybeUnary=function(t,e,i,r){var n=this.start,s=this.startLoc,a;if(this.isContextual("await")&&this.canAwait)a=this.parseAwait(r),e=!0;else if(this.type.prefix){var o=this.startNode(),l=this.type===_.incDec;o.operator=this.value,o.prefix=!0,this.next(),o.argument=this.parseMaybeUnary(null,!0,l,r),this.checkExpressionErrors(t,!0),l?this.checkLValSimple(o.argument):this.strict&&o.operator==="delete"&&ea(o.argument)?this.raiseRecoverable(o.start,"Deleting local variable in strict mode"):o.operator==="delete"&&Dr(o.argument)?this.raiseRecoverable(o.start,"Private fields can not be deleted"):e=!0,a=this.finishNode(o,l?"UpdateExpression":"UnaryExpression")}else if(!e&&this.type===_.privateId)(r||this.privateNameStack.length===0)&&this.options.checkPrivateFields&&this.unexpected(),a=this.parsePrivateIdent(),this.type!==_._in&&this.unexpected();else{if(a=this.parseExprSubscripts(t,r),this.checkExpressionErrors(t))return a;for(;this.type.postfix&&!this.canInsertSemicolon();){var c=this.startNodeAt(n,s);c.operator=this.value,c.prefix=!1,c.argument=a,this.checkLValSimple(a),this.next(),a=this.finishNode(c,"UpdateExpression")}}if(!i&&this.eat(_.starstar))if(e)this.unexpected(this.lastTokStart);else return this.buildBinary(n,s,a,this.parseMaybeUnary(null,!1,!1,r),"**",!1);else return a};function ea(t){return t.type==="Identifier"||t.type==="ParenthesizedExpression"&&ea(t.expression)}function Dr(t){return t.type==="MemberExpression"&&t.property.type==="PrivateIdentifier"||t.type==="ChainExpression"&&Dr(t.expression)||t.type==="ParenthesizedExpression"&&Dr(t.expression)}B.parseExprSubscripts=function(t,e){var i=this.start,r=this.startLoc,n=this.parseExprAtom(t,e);if(n.type==="ArrowFunctionExpression"&&this.input.slice(this.lastTokStart,this.lastTokEnd)!==")")return n;var s=this.parseSubscripts(n,i,r,!1,e);return t&&s.type==="MemberExpression"&&(t.parenthesizedAssign>=s.start&&(t.parenthesizedAssign=-1),t.parenthesizedBind>=s.start&&(t.parenthesizedBind=-1),t.trailingComma>=s.start&&(t.trailingComma=-1)),s};B.parseSubscripts=function(t,e,i,r,n){for(var s=this.options.ecmaVersion>=8&&t.type==="Identifier"&&t.name==="async"&&this.lastTokEnd===t.end&&!this.canInsertSemicolon()&&t.end-t.start===5&&this.potentialArrowAt===t.start,a=!1;;){var o=this.parseSubscript(t,e,i,r,s,a,n);if(o.optional&&(a=!0),o===t||o.type==="ArrowFunctionExpression"){if(a){var l=this.startNodeAt(e,i);l.expression=o,o=this.finishNode(l,"ChainExpression")}return o}t=o}};B.shouldParseAsyncArrow=function(){return!this.canInsertSemicolon()&&this.eat(_.arrow)};B.parseSubscriptAsyncArrow=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!0,r)};B.parseSubscript=function(t,e,i,r,n,s,a){var o=this.options.ecmaVersion>=11,l=o&&this.eat(_.questionDot);r&&l&&this.raise(this.lastTokStart,"Optional chaining cannot appear in the callee of new expressions");var c=this.eat(_.bracketL);if(c||l&&this.type!==_.parenL&&this.type!==_.backQuote||this.eat(_.dot)){var u=this.startNodeAt(e,i);u.object=t,c?(u.property=this.parseExpression(),this.expect(_.bracketR)):this.type===_.privateId&&t.type!=="Super"?u.property=this.parsePrivateIdent():u.property=this.parseIdent(this.options.allowReserved!=="never"),u.computed=!!c,o&&(u.optional=l),t=this.finishNode(u,"MemberExpression")}else if(!r&&this.eat(_.parenL)){var p=new rr,h=this.yieldPos,f=this.awaitPos,d=this.awaitIdentPos;this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0;var m=this.parseExprList(_.parenR,this.options.ecmaVersion>=8,!1,p);if(n&&!l&&this.shouldParseAsyncArrow())return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.awaitIdentPos>0&&this.raise(this.awaitIdentPos,"Cannot use 'await' as identifier inside an async function"),this.yieldPos=h,this.awaitPos=f,this.awaitIdentPos=d,this.parseSubscriptAsyncArrow(e,i,m,a);this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=f||this.awaitPos,this.awaitIdentPos=d||this.awaitIdentPos;var x=this.startNodeAt(e,i);x.callee=t,x.arguments=m,o&&(x.optional=l),t=this.finishNode(x,"CallExpression")}else if(this.type===_.backQuote){(l||s)&&this.raise(this.start,"Optional chaining cannot appear in the tag of tagged template expressions");var b=this.startNodeAt(e,i);b.tag=t,b.quasi=this.parseTemplate({isTagged:!0}),t=this.finishNode(b,"TaggedTemplateExpression")}return t};B.parseExprAtom=function(t,e,i){this.type===_.slash&&this.readRegexp();var r,n=this.potentialArrowAt===this.start;switch(this.type){case _._super:return this.allowSuper||this.raise(this.start,"'super' keyword outside a method"),r=this.startNode(),this.next(),this.type===_.parenL&&!this.allowDirectSuper&&this.raise(r.start,"super() call outside constructor of a subclass"),this.type!==_.dot&&this.type!==_.bracketL&&this.type!==_.parenL&&this.unexpected(),this.finishNode(r,"Super");case _._this:return r=this.startNode(),this.next(),this.finishNode(r,"ThisExpression");case _.name:var s=this.start,a=this.startLoc,o=this.containsEsc,l=this.parseIdent(!1);if(this.options.ecmaVersion>=8&&!o&&l.name==="async"&&!this.canInsertSemicolon()&&this.eat(_._function))return this.overrideContext(re.f_expr),this.parseFunction(this.startNodeAt(s,a),0,!1,!0,e);if(n&&!this.canInsertSemicolon()){if(this.eat(_.arrow))return this.parseArrowExpression(this.startNodeAt(s,a),[l],!1,e);if(this.options.ecmaVersion>=8&&l.name==="async"&&this.type===_.name&&!o&&(!this.potentialArrowInForAwait||this.value!=="of"||this.containsEsc))return l=this.parseIdent(!1),(this.canInsertSemicolon()||!this.eat(_.arrow))&&this.unexpected(),this.parseArrowExpression(this.startNodeAt(s,a),[l],!0,e)}return l;case _.regexp:var c=this.value;return r=this.parseLiteral(c.value),r.regex={pattern:c.pattern,flags:c.flags},r;case _.num:case _.string:return this.parseLiteral(this.value);case _._null:case _._true:case _._false:return r=this.startNode(),r.value=this.type===_._null?null:this.type===_._true,r.raw=this.type.keyword,this.next(),this.finishNode(r,"Literal");case _.parenL:var u=this.start,p=this.parseParenAndDistinguishExpression(n,e);return t&&(t.parenthesizedAssign<0&&!this.isSimpleAssignTarget(p)&&(t.parenthesizedAssign=u),t.parenthesizedBind<0&&(t.parenthesizedBind=u)),p;case _.bracketL:return r=this.startNode(),this.next(),r.elements=this.parseExprList(_.bracketR,!0,!0,t),this.finishNode(r,"ArrayExpression");case _.braceL:return this.overrideContext(re.b_expr),this.parseObj(!1,t);case _._function:return r=this.startNode(),this.next(),this.parseFunction(r,0);case _._class:return this.parseClass(this.startNode(),!1);case _._new:return this.parseNew();case _.backQuote:return this.parseTemplate();case _._import:return this.options.ecmaVersion>=11?this.parseExprImport(i):this.unexpected();default:return this.parseExprAtomDefault()}};B.parseExprAtomDefault=function(){this.unexpected()};B.parseExprImport=function(t){var e=this.startNode();if(this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword import"),this.next(),this.type===_.parenL&&!t)return this.parseDynamicImport(e);if(this.type===_.dot){var i=this.startNodeAt(e.start,e.loc&&e.loc.start);return i.name="import",e.meta=this.finishNode(i,"Identifier"),this.parseImportMeta(e)}else this.unexpected()};B.parseDynamicImport=function(t){if(this.next(),t.source=this.parseMaybeAssign(),this.options.ecmaVersion>=16)this.eat(_.parenR)?t.options=null:(this.expect(_.comma),this.afterTrailingComma(_.parenR)?t.options=null:(t.options=this.parseMaybeAssign(),this.eat(_.parenR)||(this.expect(_.comma),this.afterTrailingComma(_.parenR)||this.unexpected())));else if(!this.eat(_.parenR)){var e=this.start;this.eat(_.comma)&&this.eat(_.parenR)?this.raiseRecoverable(e,"Trailing comma is not allowed in import()"):this.unexpected(e)}return this.finishNode(t,"ImportExpression")};B.parseImportMeta=function(t){this.next();var e=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="meta"&&this.raiseRecoverable(t.property.start,"The only valid meta property for import is 'import.meta'"),e&&this.raiseRecoverable(t.start,"'import.meta' must not contain escaped characters"),this.options.sourceType!=="module"&&!this.options.allowImportExportEverywhere&&this.raiseRecoverable(t.start,"Cannot use 'import.meta' outside a module"),this.finishNode(t,"MetaProperty")};B.parseLiteral=function(t){var e=this.startNode();return e.value=t,e.raw=this.input.slice(this.start,this.end),e.raw.charCodeAt(e.raw.length-1)===110&&(e.bigint=e.value!=null?e.value.toString():e.raw.slice(0,-1).replace(/_/g,"")),this.next(),this.finishNode(e,"Literal")};B.parseParenExpression=function(){this.expect(_.parenL);var t=this.parseExpression();return this.expect(_.parenR),t};B.shouldParseArrow=function(t){return!this.canInsertSemicolon()};B.parseParenAndDistinguishExpression=function(t,e){var i=this.start,r=this.startLoc,n,s=this.options.ecmaVersion>=8;if(this.options.ecmaVersion>=6){this.next();var a=this.start,o=this.startLoc,l=[],c=!0,u=!1,p=new rr,h=this.yieldPos,f=this.awaitPos,d;for(this.yieldPos=0,this.awaitPos=0;this.type!==_.parenR;)if(c?c=!1:this.expect(_.comma),s&&this.afterTrailingComma(_.parenR,!0)){u=!0;break}else if(this.type===_.ellipsis){d=this.start,l.push(this.parseParenItem(this.parseRestBinding())),this.type===_.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element");break}else l.push(this.parseMaybeAssign(!1,p,this.parseParenItem));var m=this.lastTokEnd,x=this.lastTokEndLoc;if(this.expect(_.parenR),t&&this.shouldParseArrow(l)&&this.eat(_.arrow))return this.checkPatternErrors(p,!1),this.checkYieldAwaitInDefaultParams(),this.yieldPos=h,this.awaitPos=f,this.parseParenArrowList(i,r,l,e);(!l.length||u)&&this.unexpected(this.lastTokStart),d&&this.unexpected(d),this.checkExpressionErrors(p,!0),this.yieldPos=h||this.yieldPos,this.awaitPos=f||this.awaitPos,l.length>1?(n=this.startNodeAt(a,o),n.expressions=l,this.finishNodeAt(n,"SequenceExpression",m,x)):n=l[0]}else n=this.parseParenExpression();if(this.options.preserveParens){var b=this.startNodeAt(i,r);return b.expression=n,this.finishNode(b,"ParenthesizedExpression")}else return n};B.parseParenItem=function(t){return t};B.parseParenArrowList=function(t,e,i,r){return this.parseArrowExpression(this.startNodeAt(t,e),i,!1,r)};var Om=[];B.parseNew=function(){this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword new");var t=this.startNode();if(this.next(),this.options.ecmaVersion>=6&&this.type===_.dot){var e=this.startNodeAt(t.start,t.loc&&t.loc.start);e.name="new",t.meta=this.finishNode(e,"Identifier"),this.next();var i=this.containsEsc;return t.property=this.parseIdent(!0),t.property.name!=="target"&&this.raiseRecoverable(t.property.start,"The only valid meta property for new is 'new.target'"),i&&this.raiseRecoverable(t.start,"'new.target' must not contain escaped characters"),this.allowNewDotTarget||this.raiseRecoverable(t.start,"'new.target' can only be used in functions and class static block"),this.finishNode(t,"MetaProperty")}var r=this.start,n=this.startLoc;return t.callee=this.parseSubscripts(this.parseExprAtom(null,!1,!0),r,n,!0,!1),this.eat(_.parenL)?t.arguments=this.parseExprList(_.parenR,this.options.ecmaVersion>=8,!1):t.arguments=Om,this.finishNode(t,"NewExpression")};B.parseTemplateElement=function(t){var e=t.isTagged,i=this.startNode();return this.type===_.invalidTemplate?(e||this.raiseRecoverable(this.start,"Bad escape sequence in untagged template literal"),i.value={raw:this.value.replace(/\r\n?/g,`
|
|
5
5
|
`),cooked:null}):i.value={raw:this.input.slice(this.start,this.end).replace(/\r\n?/g,`
|
|
6
|
-
`),cooked:this.value},this.next(),i.tail=this.type===_.backQuote,this.finishNode(i,"TemplateElement")};L.parseTemplate=function(t){t===void 0&&(t={});var e=t.isTagged;e===void 0&&(e=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:e});for(i.quasis=[r];!r.tail;)this.type===_.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(_.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(_.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};L.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===_.name||this.type===_.num||this.type===_.string||this.type===_.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===_.star)&&!Oe.test(this.input.slice(this.lastTokEnd,this.start))};L.parseObj=function(t,e){var i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(_.braceR);){if(r)r=!1;else if(this.expect(_.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(_.braceR))break;var s=this.parseProperty(t,e);t||this.checkPropClash(s,n,e),i.properties.push(s)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};L.parseProperty=function(t,e){var i=this.startNode(),r,n,s,a;if(this.options.ecmaVersion>=9&&this.eat(_.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===_.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,e),this.type===_.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(t||e)&&(s=this.start,a=this.startLoc),t||(r=this.eat(_.star)));var o=this.containsEsc;return this.parsePropertyName(i),!t&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(_.star),this.parsePropertyName(i)):n=!1,this.parsePropertyValue(i,t,r,n,s,a,e,o),this.finishNode(i,"Property")};L.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var i=t.kind==="get"?0:1;if(t.value.params.length!==i){var r=t.value.start;t.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};L.parsePropertyValue=function(t,e,i,r,n,s,a,o){(i||r)&&this.type===_.colon&&this.unexpected(),this.eat(_.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init"):this.options.ecmaVersion>=6&&this.type===_.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(i,r),t.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==_.comma&&this.type!==_.braceR&&this.type!==_.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),e?t.value=this.parseMaybeDefault(n,s,this.copyNode(t.key)):this.type===_.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,s,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};L.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(_.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(_.bracketR),t.key;t.computed=!1}return t.key=this.type===_.num||this.type===_.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};L.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};L.parseMethod=function(t,e,i){var r=this.startNode(),n=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=t),this.options.ecmaVersion>=8&&(r.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kr(e,r.generator)|tr|(i?Gs:0)),this.expect(_.parenL),r.params=this.parseBindingList(_.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(r,"FunctionExpression")};L.parseArrowExpression=function(t,e,i,r){var n=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(Kr(i,!1)|zr),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,r),this.yieldPos=n,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(t,"ArrowFunctionExpression")};L.parseFunctionBody=function(t,e,i,r){var n=e&&this.type!==_.braceL,s=this.strict,a=!1;if(n)t.body=this.parseMaybeAssign(r),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!s||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(t,!s&&!a&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,Qs),t.body=this.parseBlock(!1,void 0,a&&!s),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=l}this.exitScope()};L.isSimpleParamList=function(t){for(var e=0,i=t;e<i.length;e+=1){var r=i[e];if(r.type!=="Identifier")return!1}return!0};L.checkParams=function(t,e){for(var i=Object.create(null),r=0,n=t.params;r<n.length;r+=1){var s=n[r];this.checkLValInnerPattern(s,Hr,e?null:i)}};L.parseExprList=function(t,e,i,r){for(var n=[],s=!0;!this.eat(t);){if(s)s=!1;else if(this.expect(_.comma),e&&this.afterTrailingComma(t))break;var a=void 0;i&&this.type===_.comma?a=null:this.type===_.ellipsis?(a=this.parseSpread(r),r&&this.type===_.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):a=this.parseMaybeAssign(!1,r),n.push(a)}return n};L.checkUnreserved=function(t){var e=t.start,i=t.end,r=t.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&ir)&&r==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(e,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(e,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,i).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+r+"' is reserved"))}};L.parseIdent=function(t){var e=this.parseIdentNode();return this.next(!!t),this.finishNode(e,"Identifier"),t||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};L.parseIdentNode=function(){var t=this.startNode();return this.type===_.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name==="class"||t.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=_.name):this.unexpected(),t};L.parsePrivateIdent=function(){var t=this.startNode();return this.type===_.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,"Private field '#"+t.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t};L.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===_.semi||this.canInsertSemicolon()||this.type!==_.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(_.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};L.parseAwait=function(t){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(e,"AwaitExpression")};var Hi=pe.prototype;Hi.raise=function(t,e){var i=zs(this.input,t);e+=" ("+i.line+":"+i.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};Hi.raiseRecoverable=Hi.raise;Hi.curPosition=function(){if(this.options.locations)return new bi(this.curLine,this.pos-this.lineStart)};var At=pe.prototype,$m=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};At.enterScope=function(t){this.scopeStack.push(new $m(t))};At.exitScope=function(){this.scopeStack.pop()};At.treatFunctionsAsVarInScope=function(t){return t.flags&$t||!this.inModule&&t.flags&Ot};At.declareName=function(t,e,i){var r=!1;if(e===bt){var n=this.currentScope();r=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&Ot&&delete this.undefinedExports[t]}else if(e===Zs){var s=this.currentScope();s.lexical.push(t)}else if(e===Xs){var a=this.currentScope();this.treatFunctionsAsVar?r=a.lexical.indexOf(t)>-1:r=a.lexical.indexOf(t)>-1||a.var.indexOf(t)>-1,a.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(t)>-1&&!(l.flags&Hs&&l.lexical[0]===t)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(t)>-1){r=!0;break}if(l.var.push(t),this.inModule&&l.flags&Ot&&delete this.undefinedExports[t],l.flags&ir)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};At.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};At.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};At.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(ir|Si|Vt))return e}};At.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(ir|Si|Vt)&&!(e.flags&zr))return e}};var nr=function(e,i,r){this.type="",this.start=i,this.end=0,e.options.locations&&(this.loc=new er(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[i,0])},Ei=pe.prototype;Ei.startNode=function(){return new nr(this,this.start,this.startLoc)};Ei.startNodeAt=function(t,e){return new nr(this,t,e)};function ta(t,e,i,r){return t.type=e,t.end=i,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=i),t}Ei.finishNode=function(t,e){return ta.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};Ei.finishNodeAt=function(t,e,i,r){return ta.call(this,t,e,i,r)};Ei.copyNode=function(t){var e=new nr(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var Vm="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",ia="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",ra=ia+" Extended_Pictographic",na=ra,sa=na+" EBase EComp EMod EPres ExtPict",aa=sa,jm=aa,Lm={9:ia,10:ra,11:na,12:sa,13:aa,14:jm},Bm="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Fm={9:"",10:"",11:"",12:"",13:"",14:Bm},Cn="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",oa="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",la=oa+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",ca=la+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",ua=ca+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",ha=ua+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Wm=ha+" "+Vm,Um={9:oa,10:la,11:ca,12:ua,13:ha,14:Wm},pa={};function qm(t){var e=pa[t]={binary:Ct(Lm[t]+" "+Cn),binaryOfStrings:Ct(Fm[t]),nonBinary:{General_Category:Ct(Cn),Script:Ct(Um[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var mr=0,In=[9,10,11,12,13,14];mr<In.length;mr+=1){var zm=In[mr];qm(zm)}var D=pe.prototype,Gi=function(e,i){this.parent=e,this.base=i||this};Gi.prototype.separatedFrom=function(e){for(var i=this;i;i=i.parent)for(var r=e;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};Gi.prototype.sibling=function(){return new Gi(this.parent,this.base)};var ht=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=pa[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ht.prototype.reset=function(e,i,r){var n=r.indexOf("v")!==-1,s=r.indexOf("u")!==-1;this.start=e|0,this.source=i+"",this.flags=r,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=s&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=s&&this.parser.options.ecmaVersion>=9)};ht.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};ht.prototype.at=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return-1;var s=r.charCodeAt(e);if(!(i||this.switchU)||s<=55295||s>=57344||e+1>=n)return s;var a=r.charCodeAt(e+1);return a>=56320&&a<=57343?(s<<10)+a-56613888:s};ht.prototype.nextIndex=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return n;var s=r.charCodeAt(e),a;return!(i||this.switchU)||s<=55295||s>=57344||e+1>=n||(a=r.charCodeAt(e+1))<56320||a>57343?e+1:e+2};ht.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};ht.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};ht.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};ht.prototype.eat=function(e,i){return i===void 0&&(i=!1),this.current(i)===e?(this.advance(i),!0):!1};ht.prototype.eatChars=function(e,i){i===void 0&&(i=!1);for(var r=this.pos,n=0,s=e;n<s.length;n+=1){var a=s[n],o=this.at(r,i);if(o===-1||o!==a)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};D.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,n=!1,s=0;s<i.length;s++){var a=i.charAt(s);e.indexOf(a)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(a,s+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),a==="u"&&(r=!0),a==="v"&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(t.start,"Invalid regular expression flag")};function Km(t){for(var e in t)return!0;return!1}D.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&Km(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};D.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,i=t.backReferenceNames;e<i.length;e+=1){var r=i[e];t.groupNames[r]||t.raise("Invalid named capture referenced")}};D.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new Gi(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)e&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);e&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise("Nothing to repeat"),t.eat(123)&&t.raise("Lone quantifier brackets")};D.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};D.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise("Invalid quantifier"),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1};D.regexp_eatAssertion=function(t){var e=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=e}if(t.eat(40)&&t.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!i,!0}return t.pos=e,!1};D.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};D.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};D.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};D.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)};D.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};D.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(t),r=t.eat(45);if(i||r){for(var n=0;n<i.length;n++){var s=i.charAt(n);i.indexOf(s,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var a=this.regexp_eatModifiers(t);!i&&!a&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var l=a.charAt(o);(a.indexOf(l,o+1)>-1||i.indexOf(l)>-1)&&t.raise("Duplicate regular expression modifiers")}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}}t.pos=e}return!1};D.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1};D.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&Hm(i);)e+=gt(i),t.advance();return e};function Hm(t){return t===105||t===109||t===115}D.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)};D.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};D.regexp_eatSyntaxCharacter=function(t){var e=t.current();return fa(e)?(t.lastIntValue=e,t.advance(),!0):!1};function fa(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}D.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!fa(i);)t.advance();return t.pos!==e};D.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(t.advance(),!0):!1};D.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise("Invalid group");var e=this.options.ecmaVersion>=16,i=t.groupNames[t.lastStringValue];if(i)if(e)for(var r=0,n=i;r<n.length;r+=1){var s=n[r];s.separatedFrom(t.branchID)||t.raise("Duplicate capture group name")}else t.raise("Duplicate capture group name");e?(i||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}};D.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1};D.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=gt(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=gt(t.lastIntValue);return!0}return!1};D.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),Gm(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Gm(t){return ut(t,!0)||t===36||t===95}D.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),Ym(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Ym(t){return kt(t,!0)||t===36||t===95||t===8204||t===8205}D.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)};D.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var i=t.lastIntValue;if(t.switchU)return i>t.maxBackReference&&(t.maxBackReference=i),!0;if(i<=t.numCapturingParens)return!0;t.pos=e}return!1};D.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1};D.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)};D.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};D.regexp_eatZero=function(t){return t.current()===48&&!sr(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};D.regexp_eatControlEscape=function(t){var e=t.current();return e===116?(t.lastIntValue=9,t.advance(),!0):e===110?(t.lastIntValue=10,t.advance(),!0):e===118?(t.lastIntValue=11,t.advance(),!0):e===102?(t.lastIntValue=12,t.advance(),!0):e===114?(t.lastIntValue=13,t.advance(),!0):!1};D.regexp_eatControlLetter=function(t){var e=t.current();return da(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function da(t){return t>=65&&t<=90||t>=97&&t<=122}D.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(r&&n>=55296&&n<=56319){var s=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var a=t.lastIntValue;if(a>=56320&&a<=57343)return t.lastIntValue=(n-55296)*1024+(a-56320)+65536,!0}t.pos=s,t.lastIntValue=n}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&Xm(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function Xm(t){return t>=0&&t<=1114111}D.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var e=t.current();return e!==99&&(!t.switchN||e!==107)?(t.lastIntValue=e,t.advance(),!0):!1};D.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1};var ma=0,xt=1,Ke=2;D.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(Zm(e))return t.lastIntValue=-1,t.advance(),xt;var i=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((i=e===80)||e===112)){t.lastIntValue=-1,t.advance();var r;if(t.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return i&&r===Ke&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return ma};function Zm(t){return t===100||t===68||t===115||t===83||t===119||t===87}D.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var i=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,r),xt}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return ma};D.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){ni(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};D.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return xt;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return Ke;t.raise("Invalid property name")};D.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";ya(e=t.current());)t.lastStringValue+=gt(e),t.advance();return t.lastStringValue!==""};function ya(t){return da(t)||t===95}D.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";Qm(e=t.current());)t.lastStringValue+=gt(e),t.advance();return t.lastStringValue!==""};function Qm(t){return ya(t)||sr(t)}D.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};D.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),i=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&i===Ke&&t.raise("Negated character class may contain strings"),!0}return!1};D.regexp_classContents=function(t){return t.current()===93?xt:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),xt)};D.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var i=t.lastIntValue;t.switchU&&(e===-1||i===-1)&&t.raise("Invalid character class"),e!==-1&&i!==-1&&e>i&&t.raise("Range out of order in character class")}}};D.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var i=t.current();(i===99||xa(i))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return r!==93?(t.lastIntValue=r,t.advance(),!0):!1};D.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)};D.regexp_classSetExpression=function(t){var e=xt,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===Ke&&(e=Ke);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==Ke&&(e=xt);continue}t.raise("Invalid character in character class")}if(r!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(r!==t.pos)return e}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(i=this.regexp_eatClassSetOperand(t),!i)return e;i===Ke&&(e=Ke)}};D.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var r=t.lastIntValue;return i!==-1&&r!==-1&&i>r&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};D.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?xt:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};D.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var i=t.eat(94),r=this.regexp_classContents(t);if(t.eat(93))return i&&r===Ke&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};D.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var i=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return i}else t.raise("Invalid escape");t.pos=e}return null};D.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===Ke&&(e=Ke);return e};D.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?xt:Ke};D.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1);var i=t.current();return i<0||i===t.lookahead()&&Jm(i)||ey(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function Jm(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function ey(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}D.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return ty(e)?(t.lastIntValue=e,t.advance(),!0):!1};function ty(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}D.regexp_eatClassControlLetter=function(t){var e=t.current();return sr(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};D.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1};D.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;sr(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function sr(t){return t>=48&&t<=57}D.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;_a(i=t.current());)t.lastIntValue=16*t.lastIntValue+ga(i),t.advance();return t.pos!==e};function _a(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function ga(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}D.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var i=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=e*64+i*8+t.lastIntValue:t.lastIntValue=e*8+i}else t.lastIntValue=e;return!0}return!1};D.regexp_eatOctalDigit=function(t){var e=t.current();return xa(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function xa(t){return t>=48&&t<=55}D.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var n=t.current();if(!_a(n))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+ga(n),t.advance()}return!0};var Yr=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new er(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},z=pe.prototype;z.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Yr(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};z.getToken=function(){return this.next(),new Yr(this)};typeof Symbol<"u"&&(z[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===_.eof,value:e}}}});z.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(_.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};z.readToken=function(t){return ut(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};z.fullCharCodeAt=function(t){var e=this.input.charCodeAt(t);if(e<=55295||e>=56320)return e;var i=this.input.charCodeAt(t+1);return i<=56319||i>=57344?e:(e<<10)+i-56613888};z.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};z.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations)for(var r=void 0,n=e;(r=Ws(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};z.skipLineComment=function(t){for(var e=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!ri(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,i,this.curPosition())};z.skipSpace=function(){e:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(t>8&&t<14||t>=5760&&Us.test(String.fromCharCode(t)))++this.pos;else break e}}};z.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=t,this.value=e,this.updateContext(i)};z.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&e===46?(this.pos+=3,this.finishToken(_.ellipsis)):(++this.pos,this.finishToken(_.dot))};z.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(_.assign,2):this.finishOp(_.slash,1)};z.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,r=t===42?_.star:_.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,r=_.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(_.assign,i+1):this.finishOp(r,i)};z.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(_.assign,3)}return this.finishOp(t===124?_.logicalOR:_.logicalAND,2)}return e===61?this.finishOp(_.assign,2):this.finishOp(t===124?_.bitwiseOR:_.bitwiseAND,1)};z.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(_.assign,2):this.finishOp(_.bitwiseXOR,1)};z.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Oe.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(_.incDec,2):e===61?this.finishOp(_.assign,2):this.finishOp(_.plusMin,1)};z.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),i=1;return e===t?(i=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(_.assign,i+1):this.finishOp(_.bitShift,i)):e===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(i=2),this.finishOp(_.relational,i))};z.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(_.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(_.arrow)):this.finishOp(t===61?_.eq:_.prefix,1)};z.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(_.questionDot,2)}if(e===63){if(t>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(_.assign,3)}return this.finishOp(_.coalesce,2)}}return this.finishOp(_.question,1)};z.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),ut(e,!0)||e===92))return this.finishToken(_.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+gt(e)+"'")};z.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(_.parenL);case 41:return++this.pos,this.finishToken(_.parenR);case 59:return++this.pos,this.finishToken(_.semi);case 44:return++this.pos,this.finishToken(_.comma);case 91:return++this.pos,this.finishToken(_.bracketL);case 93:return++this.pos,this.finishToken(_.bracketR);case 123:return++this.pos,this.finishToken(_.braceL);case 125:return++this.pos,this.finishToken(_.braceR);case 58:return++this.pos,this.finishToken(_.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(_.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(_.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+gt(t)+"'")};z.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};z.readRegexp=function(){for(var t,e,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(Oe.test(r)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if(r==="[")e=!0;else if(r==="]"&&e)e=!1;else if(r==="/"&&!e)break;t=r==="\\"}++this.pos}var n=this.input.slice(i,this.pos);++this.pos;var s=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(s);var o=this.regexpState||(this.regexpState=new ht(this));o.reset(i,n,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(n,a)}catch{}return this.finishToken(_.regexp,{pattern:n,flags:a,value:l})};z.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,n=i&&this.input.charCodeAt(this.pos)===48,s=this.pos,a=0,o=0,l=0,c=e??1/0;l<c;++l,++this.pos){var u=this.input.charCodeAt(this.pos),p=void 0;if(r&&u===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),l===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=u;continue}if(u>=97?p=u-97+10:u>=65?p=u-65+10:u>=48&&u<=57?p=u-48:p=1/0,p>=t)break;o=u,a=a*t+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===s||e!=null&&this.pos-s!==e?null:a};function iy(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function ba(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}z.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var i=this.readInt(t);return i==null&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=ba(this.input.slice(e,this.pos)),++this.pos):ut(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(_.num,i)};z.readNumber=function(t){var e=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var i=this.pos-e>=2&&this.input.charCodeAt(e)===48;i&&this.strict&&this.raise(e,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!t&&this.options.ecmaVersion>=11&&r===110){var n=ba(this.input.slice(e,this.pos));return++this.pos,ut(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(_.num,n)}i&&/[89]/.test(this.input.slice(e,this.pos))&&(i=!1),r===46&&!i&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!i&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),ut(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=iy(this.input.slice(e,this.pos),i);return this.finishToken(_.num,s)};z.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),e;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else e=this.readHexChar(4);return e};z.readString=function(t){for(var e="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===t)break;r===92?(e+=this.input.slice(i,this.pos),e+=this.readEscapedChar(!1),i=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ri(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(_.string,e)};var va={};z.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===va)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};z.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw va;this.raise(t,e)};z.readTmplToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(i===96||i===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===_.template||this.type===_.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(_.dollarBraceL)):(++this.pos,this.finishToken(_.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(_.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(ri(i)){switch(t+=this.input.slice(e,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
|
|
7
|
-
`;break;default:t+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};
|
|
6
|
+
`),cooked:this.value},this.next(),i.tail=this.type===_.backQuote,this.finishNode(i,"TemplateElement")};B.parseTemplate=function(t){t===void 0&&(t={});var e=t.isTagged;e===void 0&&(e=!1);var i=this.startNode();this.next(),i.expressions=[];var r=this.parseTemplateElement({isTagged:e});for(i.quasis=[r];!r.tail;)this.type===_.eof&&this.raise(this.pos,"Unterminated template literal"),this.expect(_.dollarBraceL),i.expressions.push(this.parseExpression()),this.expect(_.braceR),i.quasis.push(r=this.parseTemplateElement({isTagged:e}));return this.next(),this.finishNode(i,"TemplateLiteral")};B.isAsyncProp=function(t){return!t.computed&&t.key.type==="Identifier"&&t.key.name==="async"&&(this.type===_.name||this.type===_.num||this.type===_.string||this.type===_.bracketL||this.type.keyword||this.options.ecmaVersion>=9&&this.type===_.star)&&!Oe.test(this.input.slice(this.lastTokEnd,this.start))};B.parseObj=function(t,e){var i=this.startNode(),r=!0,n={};for(i.properties=[],this.next();!this.eat(_.braceR);){if(r)r=!1;else if(this.expect(_.comma),this.options.ecmaVersion>=5&&this.afterTrailingComma(_.braceR))break;var s=this.parseProperty(t,e);t||this.checkPropClash(s,n,e),i.properties.push(s)}return this.finishNode(i,t?"ObjectPattern":"ObjectExpression")};B.parseProperty=function(t,e){var i=this.startNode(),r,n,s,a;if(this.options.ecmaVersion>=9&&this.eat(_.ellipsis))return t?(i.argument=this.parseIdent(!1),this.type===_.comma&&this.raiseRecoverable(this.start,"Comma is not permitted after the rest element"),this.finishNode(i,"RestElement")):(i.argument=this.parseMaybeAssign(!1,e),this.type===_.comma&&e&&e.trailingComma<0&&(e.trailingComma=this.start),this.finishNode(i,"SpreadElement"));this.options.ecmaVersion>=6&&(i.method=!1,i.shorthand=!1,(t||e)&&(s=this.start,a=this.startLoc),t||(r=this.eat(_.star)));var o=this.containsEsc;return this.parsePropertyName(i),!t&&!o&&this.options.ecmaVersion>=8&&!r&&this.isAsyncProp(i)?(n=!0,r=this.options.ecmaVersion>=9&&this.eat(_.star),this.parsePropertyName(i)):n=!1,this.parsePropertyValue(i,t,r,n,s,a,e,o),this.finishNode(i,"Property")};B.parseGetterSetter=function(t){var e=t.key.name;this.parsePropertyName(t),t.value=this.parseMethod(!1),t.kind=e;var i=t.kind==="get"?0:1;if(t.value.params.length!==i){var r=t.value.start;t.kind==="get"?this.raiseRecoverable(r,"getter should have no params"):this.raiseRecoverable(r,"setter should have exactly one param")}else t.kind==="set"&&t.value.params[0].type==="RestElement"&&this.raiseRecoverable(t.value.params[0].start,"Setter cannot use rest params")};B.parsePropertyValue=function(t,e,i,r,n,s,a,o){(i||r)&&this.type===_.colon&&this.unexpected(),this.eat(_.colon)?(t.value=e?this.parseMaybeDefault(this.start,this.startLoc):this.parseMaybeAssign(!1,a),t.kind="init"):this.options.ecmaVersion>=6&&this.type===_.parenL?(e&&this.unexpected(),t.method=!0,t.value=this.parseMethod(i,r),t.kind="init"):!e&&!o&&this.options.ecmaVersion>=5&&!t.computed&&t.key.type==="Identifier"&&(t.key.name==="get"||t.key.name==="set")&&this.type!==_.comma&&this.type!==_.braceR&&this.type!==_.eq?((i||r)&&this.unexpected(),this.parseGetterSetter(t)):this.options.ecmaVersion>=6&&!t.computed&&t.key.type==="Identifier"?((i||r)&&this.unexpected(),this.checkUnreserved(t.key),t.key.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=n),e?t.value=this.parseMaybeDefault(n,s,this.copyNode(t.key)):this.type===_.eq&&a?(a.shorthandAssign<0&&(a.shorthandAssign=this.start),t.value=this.parseMaybeDefault(n,s,this.copyNode(t.key))):t.value=this.copyNode(t.key),t.kind="init",t.shorthand=!0):this.unexpected()};B.parsePropertyName=function(t){if(this.options.ecmaVersion>=6){if(this.eat(_.bracketL))return t.computed=!0,t.key=this.parseMaybeAssign(),this.expect(_.bracketR),t.key;t.computed=!1}return t.key=this.type===_.num||this.type===_.string?this.parseExprAtom():this.parseIdent(this.options.allowReserved!=="never")};B.initFunction=function(t){t.id=null,this.options.ecmaVersion>=6&&(t.generator=t.expression=!1),this.options.ecmaVersion>=8&&(t.async=!1)};B.parseMethod=function(t,e,i){var r=this.startNode(),n=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.initFunction(r),this.options.ecmaVersion>=6&&(r.generator=t),this.options.ecmaVersion>=8&&(r.async=!!e),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,this.enterScope(Kr(e,r.generator)|tr|(i?Gs:0)),this.expect(_.parenL),r.params=this.parseBindingList(_.parenR,!1,this.options.ecmaVersion>=8),this.checkYieldAwaitInDefaultParams(),this.parseFunctionBody(r,!1,!0,!1),this.yieldPos=n,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(r,"FunctionExpression")};B.parseArrowExpression=function(t,e,i,r){var n=this.yieldPos,s=this.awaitPos,a=this.awaitIdentPos;return this.enterScope(Kr(i,!1)|zr),this.initFunction(t),this.options.ecmaVersion>=8&&(t.async=!!i),this.yieldPos=0,this.awaitPos=0,this.awaitIdentPos=0,t.params=this.toAssignableList(e,!0),this.parseFunctionBody(t,!0,!1,r),this.yieldPos=n,this.awaitPos=s,this.awaitIdentPos=a,this.finishNode(t,"ArrowFunctionExpression")};B.parseFunctionBody=function(t,e,i,r){var n=e&&this.type!==_.braceL,s=this.strict,a=!1;if(n)t.body=this.parseMaybeAssign(r),t.expression=!0,this.checkParams(t,!1);else{var o=this.options.ecmaVersion>=7&&!this.isSimpleParamList(t.params);(!s||o)&&(a=this.strictDirective(this.end),a&&o&&this.raiseRecoverable(t.start,"Illegal 'use strict' directive in function with non-simple parameter list"));var l=this.labels;this.labels=[],a&&(this.strict=!0),this.checkParams(t,!s&&!a&&!e&&!i&&this.isSimpleParamList(t.params)),this.strict&&t.id&&this.checkLValSimple(t.id,Qs),t.body=this.parseBlock(!1,void 0,a&&!s),t.expression=!1,this.adaptDirectivePrologue(t.body.body),this.labels=l}this.exitScope()};B.isSimpleParamList=function(t){for(var e=0,i=t;e<i.length;e+=1){var r=i[e];if(r.type!=="Identifier")return!1}return!0};B.checkParams=function(t,e){for(var i=Object.create(null),r=0,n=t.params;r<n.length;r+=1){var s=n[r];this.checkLValInnerPattern(s,Hr,e?null:i)}};B.parseExprList=function(t,e,i,r){for(var n=[],s=!0;!this.eat(t);){if(s)s=!1;else if(this.expect(_.comma),e&&this.afterTrailingComma(t))break;var a=void 0;i&&this.type===_.comma?a=null:this.type===_.ellipsis?(a=this.parseSpread(r),r&&this.type===_.comma&&r.trailingComma<0&&(r.trailingComma=this.start)):a=this.parseMaybeAssign(!1,r),n.push(a)}return n};B.checkUnreserved=function(t){var e=t.start,i=t.end,r=t.name;if(this.inGenerator&&r==="yield"&&this.raiseRecoverable(e,"Cannot use 'yield' as identifier inside a generator"),this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use 'await' as identifier inside an async function"),!(this.currentThisScope().flags&ir)&&r==="arguments"&&this.raiseRecoverable(e,"Cannot use 'arguments' in class field initializer"),this.inClassStaticBlock&&(r==="arguments"||r==="await")&&this.raise(e,"Cannot use "+r+" in class static initialization block"),this.keywords.test(r)&&this.raise(e,"Unexpected keyword '"+r+"'"),!(this.options.ecmaVersion<6&&this.input.slice(e,i).indexOf("\\")!==-1)){var n=this.strict?this.reservedWordsStrict:this.reservedWords;n.test(r)&&(!this.inAsync&&r==="await"&&this.raiseRecoverable(e,"Cannot use keyword 'await' outside an async function"),this.raiseRecoverable(e,"The keyword '"+r+"' is reserved"))}};B.parseIdent=function(t){var e=this.parseIdentNode();return this.next(!!t),this.finishNode(e,"Identifier"),t||(this.checkUnreserved(e),e.name==="await"&&!this.awaitIdentPos&&(this.awaitIdentPos=e.start)),e};B.parseIdentNode=function(){var t=this.startNode();return this.type===_.name?t.name=this.value:this.type.keyword?(t.name=this.type.keyword,(t.name==="class"||t.name==="function")&&(this.lastTokEnd!==this.lastTokStart+1||this.input.charCodeAt(this.lastTokStart)!==46)&&this.context.pop(),this.type=_.name):this.unexpected(),t};B.parsePrivateIdent=function(){var t=this.startNode();return this.type===_.privateId?t.name=this.value:this.unexpected(),this.next(),this.finishNode(t,"PrivateIdentifier"),this.options.checkPrivateFields&&(this.privateNameStack.length===0?this.raise(t.start,"Private field '#"+t.name+"' must be declared in an enclosing class"):this.privateNameStack[this.privateNameStack.length-1].used.push(t)),t};B.parseYield=function(t){this.yieldPos||(this.yieldPos=this.start);var e=this.startNode();return this.next(),this.type===_.semi||this.canInsertSemicolon()||this.type!==_.star&&!this.type.startsExpr?(e.delegate=!1,e.argument=null):(e.delegate=this.eat(_.star),e.argument=this.parseMaybeAssign(t)),this.finishNode(e,"YieldExpression")};B.parseAwait=function(t){this.awaitPos||(this.awaitPos=this.start);var e=this.startNode();return this.next(),e.argument=this.parseMaybeUnary(null,!0,!1,t),this.finishNode(e,"AwaitExpression")};var Hi=pe.prototype;Hi.raise=function(t,e){var i=zs(this.input,t);e+=" ("+i.line+":"+i.column+")",this.sourceFile&&(e+=" in "+this.sourceFile);var r=new SyntaxError(e);throw r.pos=t,r.loc=i,r.raisedAt=this.pos,r};Hi.raiseRecoverable=Hi.raise;Hi.curPosition=function(){if(this.options.locations)return new bi(this.curLine,this.pos-this.lineStart)};var At=pe.prototype,$m=function(e){this.flags=e,this.var=[],this.lexical=[],this.functions=[]};At.enterScope=function(t){this.scopeStack.push(new $m(t))};At.exitScope=function(){this.scopeStack.pop()};At.treatFunctionsAsVarInScope=function(t){return t.flags&$t||!this.inModule&&t.flags&Ot};At.declareName=function(t,e,i){var r=!1;if(e===bt){var n=this.currentScope();r=n.lexical.indexOf(t)>-1||n.functions.indexOf(t)>-1||n.var.indexOf(t)>-1,n.lexical.push(t),this.inModule&&n.flags&Ot&&delete this.undefinedExports[t]}else if(e===Zs){var s=this.currentScope();s.lexical.push(t)}else if(e===Xs){var a=this.currentScope();this.treatFunctionsAsVar?r=a.lexical.indexOf(t)>-1:r=a.lexical.indexOf(t)>-1||a.var.indexOf(t)>-1,a.functions.push(t)}else for(var o=this.scopeStack.length-1;o>=0;--o){var l=this.scopeStack[o];if(l.lexical.indexOf(t)>-1&&!(l.flags&Hs&&l.lexical[0]===t)||!this.treatFunctionsAsVarInScope(l)&&l.functions.indexOf(t)>-1){r=!0;break}if(l.var.push(t),this.inModule&&l.flags&Ot&&delete this.undefinedExports[t],l.flags&ir)break}r&&this.raiseRecoverable(i,"Identifier '"+t+"' has already been declared")};At.checkLocalExport=function(t){this.scopeStack[0].lexical.indexOf(t.name)===-1&&this.scopeStack[0].var.indexOf(t.name)===-1&&(this.undefinedExports[t.name]=t)};At.currentScope=function(){return this.scopeStack[this.scopeStack.length-1]};At.currentVarScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(ir|Si|Vt))return e}};At.currentThisScope=function(){for(var t=this.scopeStack.length-1;;t--){var e=this.scopeStack[t];if(e.flags&(ir|Si|Vt)&&!(e.flags&zr))return e}};var nr=function(e,i,r){this.type="",this.start=i,this.end=0,e.options.locations&&(this.loc=new er(e,r)),e.options.directSourceFile&&(this.sourceFile=e.options.directSourceFile),e.options.ranges&&(this.range=[i,0])},Ei=pe.prototype;Ei.startNode=function(){return new nr(this,this.start,this.startLoc)};Ei.startNodeAt=function(t,e){return new nr(this,t,e)};function ta(t,e,i,r){return t.type=e,t.end=i,this.options.locations&&(t.loc.end=r),this.options.ranges&&(t.range[1]=i),t}Ei.finishNode=function(t,e){return ta.call(this,t,e,this.lastTokEnd,this.lastTokEndLoc)};Ei.finishNodeAt=function(t,e,i,r){return ta.call(this,t,e,i,r)};Ei.copyNode=function(t){var e=new nr(this,t.start,this.startLoc);for(var i in t)e[i]=t[i];return e};var Vm="Berf Beria_Erfe Gara Garay Gukh Gurung_Khema Hrkt Katakana_Or_Hiragana Kawi Kirat_Rai Krai Nag_Mundari Nagm Ol_Onal Onao Sidetic Sidt Sunu Sunuwar Tai_Yo Tayo Todhri Todr Tolong_Siki Tols Tulu_Tigalari Tutg Unknown Zzzz",ia="ASCII ASCII_Hex_Digit AHex Alphabetic Alpha Any Assigned Bidi_Control Bidi_C Bidi_Mirrored Bidi_M Case_Ignorable CI Cased Changes_When_Casefolded CWCF Changes_When_Casemapped CWCM Changes_When_Lowercased CWL Changes_When_NFKC_Casefolded CWKCF Changes_When_Titlecased CWT Changes_When_Uppercased CWU Dash Default_Ignorable_Code_Point DI Deprecated Dep Diacritic Dia Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Extender Ext Grapheme_Base Gr_Base Grapheme_Extend Gr_Ext Hex_Digit Hex IDS_Binary_Operator IDSB IDS_Trinary_Operator IDST ID_Continue IDC ID_Start IDS Ideographic Ideo Join_Control Join_C Logical_Order_Exception LOE Lowercase Lower Math Noncharacter_Code_Point NChar Pattern_Syntax Pat_Syn Pattern_White_Space Pat_WS Quotation_Mark QMark Radical Regional_Indicator RI Sentence_Terminal STerm Soft_Dotted SD Terminal_Punctuation Term Unified_Ideograph UIdeo Uppercase Upper Variation_Selector VS White_Space space XID_Continue XIDC XID_Start XIDS",ra=ia+" Extended_Pictographic",na=ra,sa=na+" EBase EComp EMod EPres ExtPict",aa=sa,jm=aa,Lm={9:ia,10:ra,11:na,12:sa,13:aa,14:jm},Bm="Basic_Emoji Emoji_Keycap_Sequence RGI_Emoji_Modifier_Sequence RGI_Emoji_Flag_Sequence RGI_Emoji_Tag_Sequence RGI_Emoji_ZWJ_Sequence RGI_Emoji",Fm={9:"",10:"",11:"",12:"",13:"",14:Bm},Cn="Cased_Letter LC Close_Punctuation Pe Connector_Punctuation Pc Control Cc cntrl Currency_Symbol Sc Dash_Punctuation Pd Decimal_Number Nd digit Enclosing_Mark Me Final_Punctuation Pf Format Cf Initial_Punctuation Pi Letter L Letter_Number Nl Line_Separator Zl Lowercase_Letter Ll Mark M Combining_Mark Math_Symbol Sm Modifier_Letter Lm Modifier_Symbol Sk Nonspacing_Mark Mn Number N Open_Punctuation Ps Other C Other_Letter Lo Other_Number No Other_Punctuation Po Other_Symbol So Paragraph_Separator Zp Private_Use Co Punctuation P punct Separator Z Space_Separator Zs Spacing_Mark Mc Surrogate Cs Symbol S Titlecase_Letter Lt Unassigned Cn Uppercase_Letter Lu",oa="Adlam Adlm Ahom Anatolian_Hieroglyphs Hluw Arabic Arab Armenian Armn Avestan Avst Balinese Bali Bamum Bamu Bassa_Vah Bass Batak Batk Bengali Beng Bhaiksuki Bhks Bopomofo Bopo Brahmi Brah Braille Brai Buginese Bugi Buhid Buhd Canadian_Aboriginal Cans Carian Cari Caucasian_Albanian Aghb Chakma Cakm Cham Cham Cherokee Cher Common Zyyy Coptic Copt Qaac Cuneiform Xsux Cypriot Cprt Cyrillic Cyrl Deseret Dsrt Devanagari Deva Duployan Dupl Egyptian_Hieroglyphs Egyp Elbasan Elba Ethiopic Ethi Georgian Geor Glagolitic Glag Gothic Goth Grantha Gran Greek Grek Gujarati Gujr Gurmukhi Guru Han Hani Hangul Hang Hanunoo Hano Hatran Hatr Hebrew Hebr Hiragana Hira Imperial_Aramaic Armi Inherited Zinh Qaai Inscriptional_Pahlavi Phli Inscriptional_Parthian Prti Javanese Java Kaithi Kthi Kannada Knda Katakana Kana Kayah_Li Kali Kharoshthi Khar Khmer Khmr Khojki Khoj Khudawadi Sind Lao Laoo Latin Latn Lepcha Lepc Limbu Limb Linear_A Lina Linear_B Linb Lisu Lisu Lycian Lyci Lydian Lydi Mahajani Mahj Malayalam Mlym Mandaic Mand Manichaean Mani Marchen Marc Masaram_Gondi Gonm Meetei_Mayek Mtei Mende_Kikakui Mend Meroitic_Cursive Merc Meroitic_Hieroglyphs Mero Miao Plrd Modi Mongolian Mong Mro Mroo Multani Mult Myanmar Mymr Nabataean Nbat New_Tai_Lue Talu Newa Newa Nko Nkoo Nushu Nshu Ogham Ogam Ol_Chiki Olck Old_Hungarian Hung Old_Italic Ital Old_North_Arabian Narb Old_Permic Perm Old_Persian Xpeo Old_South_Arabian Sarb Old_Turkic Orkh Oriya Orya Osage Osge Osmanya Osma Pahawh_Hmong Hmng Palmyrene Palm Pau_Cin_Hau Pauc Phags_Pa Phag Phoenician Phnx Psalter_Pahlavi Phlp Rejang Rjng Runic Runr Samaritan Samr Saurashtra Saur Sharada Shrd Shavian Shaw Siddham Sidd SignWriting Sgnw Sinhala Sinh Sora_Sompeng Sora Soyombo Soyo Sundanese Sund Syloti_Nagri Sylo Syriac Syrc Tagalog Tglg Tagbanwa Tagb Tai_Le Tale Tai_Tham Lana Tai_Viet Tavt Takri Takr Tamil Taml Tangut Tang Telugu Telu Thaana Thaa Thai Thai Tibetan Tibt Tifinagh Tfng Tirhuta Tirh Ugaritic Ugar Vai Vaii Warang_Citi Wara Yi Yiii Zanabazar_Square Zanb",la=oa+" Dogra Dogr Gunjala_Gondi Gong Hanifi_Rohingya Rohg Makasar Maka Medefaidrin Medf Old_Sogdian Sogo Sogdian Sogd",ca=la+" Elymaic Elym Nandinagari Nand Nyiakeng_Puachue_Hmong Hmnp Wancho Wcho",ua=ca+" Chorasmian Chrs Diak Dives_Akuru Khitan_Small_Script Kits Yezi Yezidi",ha=ua+" Cypro_Minoan Cpmn Old_Uyghur Ougr Tangsa Tnsa Toto Vithkuqi Vith",Wm=ha+" "+Vm,Um={9:oa,10:la,11:ca,12:ua,13:ha,14:Wm},pa={};function qm(t){var e=pa[t]={binary:Ct(Lm[t]+" "+Cn),binaryOfStrings:Ct(Fm[t]),nonBinary:{General_Category:Ct(Cn),Script:Ct(Um[t])}};e.nonBinary.Script_Extensions=e.nonBinary.Script,e.nonBinary.gc=e.nonBinary.General_Category,e.nonBinary.sc=e.nonBinary.Script,e.nonBinary.scx=e.nonBinary.Script_Extensions}for(var mr=0,In=[9,10,11,12,13,14];mr<In.length;mr+=1){var zm=In[mr];qm(zm)}var D=pe.prototype,Gi=function(e,i){this.parent=e,this.base=i||this};Gi.prototype.separatedFrom=function(e){for(var i=this;i;i=i.parent)for(var r=e;r;r=r.parent)if(i.base===r.base&&i!==r)return!0;return!1};Gi.prototype.sibling=function(){return new Gi(this.parent,this.base)};var ht=function(e){this.parser=e,this.validFlags="gim"+(e.options.ecmaVersion>=6?"uy":"")+(e.options.ecmaVersion>=9?"s":"")+(e.options.ecmaVersion>=13?"d":"")+(e.options.ecmaVersion>=15?"v":""),this.unicodeProperties=pa[e.options.ecmaVersion>=14?14:e.options.ecmaVersion],this.source="",this.flags="",this.start=0,this.switchU=!1,this.switchV=!1,this.switchN=!1,this.pos=0,this.lastIntValue=0,this.lastStringValue="",this.lastAssertionIsQuantifiable=!1,this.numCapturingParens=0,this.maxBackReference=0,this.groupNames=Object.create(null),this.backReferenceNames=[],this.branchID=null};ht.prototype.reset=function(e,i,r){var n=r.indexOf("v")!==-1,s=r.indexOf("u")!==-1;this.start=e|0,this.source=i+"",this.flags=r,n&&this.parser.options.ecmaVersion>=15?(this.switchU=!0,this.switchV=!0,this.switchN=!0):(this.switchU=s&&this.parser.options.ecmaVersion>=6,this.switchV=!1,this.switchN=s&&this.parser.options.ecmaVersion>=9)};ht.prototype.raise=function(e){this.parser.raiseRecoverable(this.start,"Invalid regular expression: /"+this.source+"/: "+e)};ht.prototype.at=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return-1;var s=r.charCodeAt(e);if(!(i||this.switchU)||s<=55295||s>=57344||e+1>=n)return s;var a=r.charCodeAt(e+1);return a>=56320&&a<=57343?(s<<10)+a-56613888:s};ht.prototype.nextIndex=function(e,i){i===void 0&&(i=!1);var r=this.source,n=r.length;if(e>=n)return n;var s=r.charCodeAt(e),a;return!(i||this.switchU)||s<=55295||s>=57344||e+1>=n||(a=r.charCodeAt(e+1))<56320||a>57343?e+1:e+2};ht.prototype.current=function(e){return e===void 0&&(e=!1),this.at(this.pos,e)};ht.prototype.lookahead=function(e){return e===void 0&&(e=!1),this.at(this.nextIndex(this.pos,e),e)};ht.prototype.advance=function(e){e===void 0&&(e=!1),this.pos=this.nextIndex(this.pos,e)};ht.prototype.eat=function(e,i){return i===void 0&&(i=!1),this.current(i)===e?(this.advance(i),!0):!1};ht.prototype.eatChars=function(e,i){i===void 0&&(i=!1);for(var r=this.pos,n=0,s=e;n<s.length;n+=1){var a=s[n],o=this.at(r,i);if(o===-1||o!==a)return!1;r=this.nextIndex(r,i)}return this.pos=r,!0};D.validateRegExpFlags=function(t){for(var e=t.validFlags,i=t.flags,r=!1,n=!1,s=0;s<i.length;s++){var a=i.charAt(s);e.indexOf(a)===-1&&this.raise(t.start,"Invalid regular expression flag"),i.indexOf(a,s+1)>-1&&this.raise(t.start,"Duplicate regular expression flag"),a==="u"&&(r=!0),a==="v"&&(n=!0)}this.options.ecmaVersion>=15&&r&&n&&this.raise(t.start,"Invalid regular expression flag")};function Km(t){for(var e in t)return!0;return!1}D.validateRegExpPattern=function(t){this.regexp_pattern(t),!t.switchN&&this.options.ecmaVersion>=9&&Km(t.groupNames)&&(t.switchN=!0,this.regexp_pattern(t))};D.regexp_pattern=function(t){t.pos=0,t.lastIntValue=0,t.lastStringValue="",t.lastAssertionIsQuantifiable=!1,t.numCapturingParens=0,t.maxBackReference=0,t.groupNames=Object.create(null),t.backReferenceNames.length=0,t.branchID=null,this.regexp_disjunction(t),t.pos!==t.source.length&&(t.eat(41)&&t.raise("Unmatched ')'"),(t.eat(93)||t.eat(125))&&t.raise("Lone quantifier brackets")),t.maxBackReference>t.numCapturingParens&&t.raise("Invalid escape");for(var e=0,i=t.backReferenceNames;e<i.length;e+=1){var r=i[e];t.groupNames[r]||t.raise("Invalid named capture referenced")}};D.regexp_disjunction=function(t){var e=this.options.ecmaVersion>=16;for(e&&(t.branchID=new Gi(t.branchID,null)),this.regexp_alternative(t);t.eat(124);)e&&(t.branchID=t.branchID.sibling()),this.regexp_alternative(t);e&&(t.branchID=t.branchID.parent),this.regexp_eatQuantifier(t,!0)&&t.raise("Nothing to repeat"),t.eat(123)&&t.raise("Lone quantifier brackets")};D.regexp_alternative=function(t){for(;t.pos<t.source.length&&this.regexp_eatTerm(t););};D.regexp_eatTerm=function(t){return this.regexp_eatAssertion(t)?(t.lastAssertionIsQuantifiable&&this.regexp_eatQuantifier(t)&&t.switchU&&t.raise("Invalid quantifier"),!0):(t.switchU?this.regexp_eatAtom(t):this.regexp_eatExtendedAtom(t))?(this.regexp_eatQuantifier(t),!0):!1};D.regexp_eatAssertion=function(t){var e=t.pos;if(t.lastAssertionIsQuantifiable=!1,t.eat(94)||t.eat(36))return!0;if(t.eat(92)){if(t.eat(66)||t.eat(98))return!0;t.pos=e}if(t.eat(40)&&t.eat(63)){var i=!1;if(this.options.ecmaVersion>=9&&(i=t.eat(60)),t.eat(61)||t.eat(33))return this.regexp_disjunction(t),t.eat(41)||t.raise("Unterminated group"),t.lastAssertionIsQuantifiable=!i,!0}return t.pos=e,!1};D.regexp_eatQuantifier=function(t,e){return e===void 0&&(e=!1),this.regexp_eatQuantifierPrefix(t,e)?(t.eat(63),!0):!1};D.regexp_eatQuantifierPrefix=function(t,e){return t.eat(42)||t.eat(43)||t.eat(63)||this.regexp_eatBracedQuantifier(t,e)};D.regexp_eatBracedQuantifier=function(t,e){var i=t.pos;if(t.eat(123)){var r=0,n=-1;if(this.regexp_eatDecimalDigits(t)&&(r=t.lastIntValue,t.eat(44)&&this.regexp_eatDecimalDigits(t)&&(n=t.lastIntValue),t.eat(125)))return n!==-1&&n<r&&!e&&t.raise("numbers out of order in {} quantifier"),!0;t.switchU&&!e&&t.raise("Incomplete quantifier"),t.pos=i}return!1};D.regexp_eatAtom=function(t){return this.regexp_eatPatternCharacters(t)||t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)};D.regexp_eatReverseSolidusAtomEscape=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatAtomEscape(t))return!0;t.pos=e}return!1};D.regexp_eatUncapturingGroup=function(t){var e=t.pos;if(t.eat(40)){if(t.eat(63)){if(this.options.ecmaVersion>=16){var i=this.regexp_eatModifiers(t),r=t.eat(45);if(i||r){for(var n=0;n<i.length;n++){var s=i.charAt(n);i.indexOf(s,n+1)>-1&&t.raise("Duplicate regular expression modifiers")}if(r){var a=this.regexp_eatModifiers(t);!i&&!a&&t.current()===58&&t.raise("Invalid regular expression modifiers");for(var o=0;o<a.length;o++){var l=a.charAt(o);(a.indexOf(l,o+1)>-1||i.indexOf(l)>-1)&&t.raise("Duplicate regular expression modifiers")}}}}if(t.eat(58)){if(this.regexp_disjunction(t),t.eat(41))return!0;t.raise("Unterminated group")}}t.pos=e}return!1};D.regexp_eatCapturingGroup=function(t){if(t.eat(40)){if(this.options.ecmaVersion>=9?this.regexp_groupSpecifier(t):t.current()===63&&t.raise("Invalid group"),this.regexp_disjunction(t),t.eat(41))return t.numCapturingParens+=1,!0;t.raise("Unterminated group")}return!1};D.regexp_eatModifiers=function(t){for(var e="",i=0;(i=t.current())!==-1&&Hm(i);)e+=gt(i),t.advance();return e};function Hm(t){return t===105||t===109||t===115}D.regexp_eatExtendedAtom=function(t){return t.eat(46)||this.regexp_eatReverseSolidusAtomEscape(t)||this.regexp_eatCharacterClass(t)||this.regexp_eatUncapturingGroup(t)||this.regexp_eatCapturingGroup(t)||this.regexp_eatInvalidBracedQuantifier(t)||this.regexp_eatExtendedPatternCharacter(t)};D.regexp_eatInvalidBracedQuantifier=function(t){return this.regexp_eatBracedQuantifier(t,!0)&&t.raise("Nothing to repeat"),!1};D.regexp_eatSyntaxCharacter=function(t){var e=t.current();return fa(e)?(t.lastIntValue=e,t.advance(),!0):!1};function fa(t){return t===36||t>=40&&t<=43||t===46||t===63||t>=91&&t<=94||t>=123&&t<=125}D.regexp_eatPatternCharacters=function(t){for(var e=t.pos,i=0;(i=t.current())!==-1&&!fa(i);)t.advance();return t.pos!==e};D.regexp_eatExtendedPatternCharacter=function(t){var e=t.current();return e!==-1&&e!==36&&!(e>=40&&e<=43)&&e!==46&&e!==63&&e!==91&&e!==94&&e!==124?(t.advance(),!0):!1};D.regexp_groupSpecifier=function(t){if(t.eat(63)){this.regexp_eatGroupName(t)||t.raise("Invalid group");var e=this.options.ecmaVersion>=16,i=t.groupNames[t.lastStringValue];if(i)if(e)for(var r=0,n=i;r<n.length;r+=1){var s=n[r];s.separatedFrom(t.branchID)||t.raise("Duplicate capture group name")}else t.raise("Duplicate capture group name");e?(i||(t.groupNames[t.lastStringValue]=[])).push(t.branchID):t.groupNames[t.lastStringValue]=!0}};D.regexp_eatGroupName=function(t){if(t.lastStringValue="",t.eat(60)){if(this.regexp_eatRegExpIdentifierName(t)&&t.eat(62))return!0;t.raise("Invalid capture group name")}return!1};D.regexp_eatRegExpIdentifierName=function(t){if(t.lastStringValue="",this.regexp_eatRegExpIdentifierStart(t)){for(t.lastStringValue+=gt(t.lastIntValue);this.regexp_eatRegExpIdentifierPart(t);)t.lastStringValue+=gt(t.lastIntValue);return!0}return!1};D.regexp_eatRegExpIdentifierStart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),Gm(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Gm(t){return ut(t,!0)||t===36||t===95}D.regexp_eatRegExpIdentifierPart=function(t){var e=t.pos,i=this.options.ecmaVersion>=11,r=t.current(i);return t.advance(i),r===92&&this.regexp_eatRegExpUnicodeEscapeSequence(t,i)&&(r=t.lastIntValue),Ym(r)?(t.lastIntValue=r,!0):(t.pos=e,!1)};function Ym(t){return kt(t,!0)||t===36||t===95||t===8204||t===8205}D.regexp_eatAtomEscape=function(t){return this.regexp_eatBackReference(t)||this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)||t.switchN&&this.regexp_eatKGroupName(t)?!0:(t.switchU&&(t.current()===99&&t.raise("Invalid unicode escape"),t.raise("Invalid escape")),!1)};D.regexp_eatBackReference=function(t){var e=t.pos;if(this.regexp_eatDecimalEscape(t)){var i=t.lastIntValue;if(t.switchU)return i>t.maxBackReference&&(t.maxBackReference=i),!0;if(i<=t.numCapturingParens)return!0;t.pos=e}return!1};D.regexp_eatKGroupName=function(t){if(t.eat(107)){if(this.regexp_eatGroupName(t))return t.backReferenceNames.push(t.lastStringValue),!0;t.raise("Invalid named reference")}return!1};D.regexp_eatCharacterEscape=function(t){return this.regexp_eatControlEscape(t)||this.regexp_eatCControlLetter(t)||this.regexp_eatZero(t)||this.regexp_eatHexEscapeSequence(t)||this.regexp_eatRegExpUnicodeEscapeSequence(t,!1)||!t.switchU&&this.regexp_eatLegacyOctalEscapeSequence(t)||this.regexp_eatIdentityEscape(t)};D.regexp_eatCControlLetter=function(t){var e=t.pos;if(t.eat(99)){if(this.regexp_eatControlLetter(t))return!0;t.pos=e}return!1};D.regexp_eatZero=function(t){return t.current()===48&&!sr(t.lookahead())?(t.lastIntValue=0,t.advance(),!0):!1};D.regexp_eatControlEscape=function(t){var e=t.current();return e===116?(t.lastIntValue=9,t.advance(),!0):e===110?(t.lastIntValue=10,t.advance(),!0):e===118?(t.lastIntValue=11,t.advance(),!0):e===102?(t.lastIntValue=12,t.advance(),!0):e===114?(t.lastIntValue=13,t.advance(),!0):!1};D.regexp_eatControlLetter=function(t){var e=t.current();return da(e)?(t.lastIntValue=e%32,t.advance(),!0):!1};function da(t){return t>=65&&t<=90||t>=97&&t<=122}D.regexp_eatRegExpUnicodeEscapeSequence=function(t,e){e===void 0&&(e=!1);var i=t.pos,r=e||t.switchU;if(t.eat(117)){if(this.regexp_eatFixedHexDigits(t,4)){var n=t.lastIntValue;if(r&&n>=55296&&n<=56319){var s=t.pos;if(t.eat(92)&&t.eat(117)&&this.regexp_eatFixedHexDigits(t,4)){var a=t.lastIntValue;if(a>=56320&&a<=57343)return t.lastIntValue=(n-55296)*1024+(a-56320)+65536,!0}t.pos=s,t.lastIntValue=n}return!0}if(r&&t.eat(123)&&this.regexp_eatHexDigits(t)&&t.eat(125)&&Xm(t.lastIntValue))return!0;r&&t.raise("Invalid unicode escape"),t.pos=i}return!1};function Xm(t){return t>=0&&t<=1114111}D.regexp_eatIdentityEscape=function(t){if(t.switchU)return this.regexp_eatSyntaxCharacter(t)?!0:t.eat(47)?(t.lastIntValue=47,!0):!1;var e=t.current();return e!==99&&(!t.switchN||e!==107)?(t.lastIntValue=e,t.advance(),!0):!1};D.regexp_eatDecimalEscape=function(t){t.lastIntValue=0;var e=t.current();if(e>=49&&e<=57){do t.lastIntValue=10*t.lastIntValue+(e-48),t.advance();while((e=t.current())>=48&&e<=57);return!0}return!1};var ma=0,xt=1,Ke=2;D.regexp_eatCharacterClassEscape=function(t){var e=t.current();if(Zm(e))return t.lastIntValue=-1,t.advance(),xt;var i=!1;if(t.switchU&&this.options.ecmaVersion>=9&&((i=e===80)||e===112)){t.lastIntValue=-1,t.advance();var r;if(t.eat(123)&&(r=this.regexp_eatUnicodePropertyValueExpression(t))&&t.eat(125))return i&&r===Ke&&t.raise("Invalid property name"),r;t.raise("Invalid property name")}return ma};function Zm(t){return t===100||t===68||t===115||t===83||t===119||t===87}D.regexp_eatUnicodePropertyValueExpression=function(t){var e=t.pos;if(this.regexp_eatUnicodePropertyName(t)&&t.eat(61)){var i=t.lastStringValue;if(this.regexp_eatUnicodePropertyValue(t)){var r=t.lastStringValue;return this.regexp_validateUnicodePropertyNameAndValue(t,i,r),xt}}if(t.pos=e,this.regexp_eatLoneUnicodePropertyNameOrValue(t)){var n=t.lastStringValue;return this.regexp_validateUnicodePropertyNameOrValue(t,n)}return ma};D.regexp_validateUnicodePropertyNameAndValue=function(t,e,i){ni(t.unicodeProperties.nonBinary,e)||t.raise("Invalid property name"),t.unicodeProperties.nonBinary[e].test(i)||t.raise("Invalid property value")};D.regexp_validateUnicodePropertyNameOrValue=function(t,e){if(t.unicodeProperties.binary.test(e))return xt;if(t.switchV&&t.unicodeProperties.binaryOfStrings.test(e))return Ke;t.raise("Invalid property name")};D.regexp_eatUnicodePropertyName=function(t){var e=0;for(t.lastStringValue="";ya(e=t.current());)t.lastStringValue+=gt(e),t.advance();return t.lastStringValue!==""};function ya(t){return da(t)||t===95}D.regexp_eatUnicodePropertyValue=function(t){var e=0;for(t.lastStringValue="";Qm(e=t.current());)t.lastStringValue+=gt(e),t.advance();return t.lastStringValue!==""};function Qm(t){return ya(t)||sr(t)}D.regexp_eatLoneUnicodePropertyNameOrValue=function(t){return this.regexp_eatUnicodePropertyValue(t)};D.regexp_eatCharacterClass=function(t){if(t.eat(91)){var e=t.eat(94),i=this.regexp_classContents(t);return t.eat(93)||t.raise("Unterminated character class"),e&&i===Ke&&t.raise("Negated character class may contain strings"),!0}return!1};D.regexp_classContents=function(t){return t.current()===93?xt:t.switchV?this.regexp_classSetExpression(t):(this.regexp_nonEmptyClassRanges(t),xt)};D.regexp_nonEmptyClassRanges=function(t){for(;this.regexp_eatClassAtom(t);){var e=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassAtom(t)){var i=t.lastIntValue;t.switchU&&(e===-1||i===-1)&&t.raise("Invalid character class"),e!==-1&&i!==-1&&e>i&&t.raise("Range out of order in character class")}}};D.regexp_eatClassAtom=function(t){var e=t.pos;if(t.eat(92)){if(this.regexp_eatClassEscape(t))return!0;if(t.switchU){var i=t.current();(i===99||xa(i))&&t.raise("Invalid class escape"),t.raise("Invalid escape")}t.pos=e}var r=t.current();return r!==93?(t.lastIntValue=r,t.advance(),!0):!1};D.regexp_eatClassEscape=function(t){var e=t.pos;if(t.eat(98))return t.lastIntValue=8,!0;if(t.switchU&&t.eat(45))return t.lastIntValue=45,!0;if(!t.switchU&&t.eat(99)){if(this.regexp_eatClassControlLetter(t))return!0;t.pos=e}return this.regexp_eatCharacterClassEscape(t)||this.regexp_eatCharacterEscape(t)};D.regexp_classSetExpression=function(t){var e=xt,i;if(!this.regexp_eatClassSetRange(t))if(i=this.regexp_eatClassSetOperand(t)){i===Ke&&(e=Ke);for(var r=t.pos;t.eatChars([38,38]);){if(t.current()!==38&&(i=this.regexp_eatClassSetOperand(t))){i!==Ke&&(e=xt);continue}t.raise("Invalid character in character class")}if(r!==t.pos)return e;for(;t.eatChars([45,45]);)this.regexp_eatClassSetOperand(t)||t.raise("Invalid character in character class");if(r!==t.pos)return e}else t.raise("Invalid character in character class");for(;;)if(!this.regexp_eatClassSetRange(t)){if(i=this.regexp_eatClassSetOperand(t),!i)return e;i===Ke&&(e=Ke)}};D.regexp_eatClassSetRange=function(t){var e=t.pos;if(this.regexp_eatClassSetCharacter(t)){var i=t.lastIntValue;if(t.eat(45)&&this.regexp_eatClassSetCharacter(t)){var r=t.lastIntValue;return i!==-1&&r!==-1&&i>r&&t.raise("Range out of order in character class"),!0}t.pos=e}return!1};D.regexp_eatClassSetOperand=function(t){return this.regexp_eatClassSetCharacter(t)?xt:this.regexp_eatClassStringDisjunction(t)||this.regexp_eatNestedClass(t)};D.regexp_eatNestedClass=function(t){var e=t.pos;if(t.eat(91)){var i=t.eat(94),r=this.regexp_classContents(t);if(t.eat(93))return i&&r===Ke&&t.raise("Negated character class may contain strings"),r;t.pos=e}if(t.eat(92)){var n=this.regexp_eatCharacterClassEscape(t);if(n)return n;t.pos=e}return null};D.regexp_eatClassStringDisjunction=function(t){var e=t.pos;if(t.eatChars([92,113])){if(t.eat(123)){var i=this.regexp_classStringDisjunctionContents(t);if(t.eat(125))return i}else t.raise("Invalid escape");t.pos=e}return null};D.regexp_classStringDisjunctionContents=function(t){for(var e=this.regexp_classString(t);t.eat(124);)this.regexp_classString(t)===Ke&&(e=Ke);return e};D.regexp_classString=function(t){for(var e=0;this.regexp_eatClassSetCharacter(t);)e++;return e===1?xt:Ke};D.regexp_eatClassSetCharacter=function(t){var e=t.pos;if(t.eat(92))return this.regexp_eatCharacterEscape(t)||this.regexp_eatClassSetReservedPunctuator(t)?!0:t.eat(98)?(t.lastIntValue=8,!0):(t.pos=e,!1);var i=t.current();return i<0||i===t.lookahead()&&Jm(i)||ey(i)?!1:(t.advance(),t.lastIntValue=i,!0)};function Jm(t){return t===33||t>=35&&t<=38||t>=42&&t<=44||t===46||t>=58&&t<=64||t===94||t===96||t===126}function ey(t){return t===40||t===41||t===45||t===47||t>=91&&t<=93||t>=123&&t<=125}D.regexp_eatClassSetReservedPunctuator=function(t){var e=t.current();return ty(e)?(t.lastIntValue=e,t.advance(),!0):!1};function ty(t){return t===33||t===35||t===37||t===38||t===44||t===45||t>=58&&t<=62||t===64||t===96||t===126}D.regexp_eatClassControlLetter=function(t){var e=t.current();return sr(e)||e===95?(t.lastIntValue=e%32,t.advance(),!0):!1};D.regexp_eatHexEscapeSequence=function(t){var e=t.pos;if(t.eat(120)){if(this.regexp_eatFixedHexDigits(t,2))return!0;t.switchU&&t.raise("Invalid escape"),t.pos=e}return!1};D.regexp_eatDecimalDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;sr(i=t.current());)t.lastIntValue=10*t.lastIntValue+(i-48),t.advance();return t.pos!==e};function sr(t){return t>=48&&t<=57}D.regexp_eatHexDigits=function(t){var e=t.pos,i=0;for(t.lastIntValue=0;_a(i=t.current());)t.lastIntValue=16*t.lastIntValue+ga(i),t.advance();return t.pos!==e};function _a(t){return t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102}function ga(t){return t>=65&&t<=70?10+(t-65):t>=97&&t<=102?10+(t-97):t-48}D.regexp_eatLegacyOctalEscapeSequence=function(t){if(this.regexp_eatOctalDigit(t)){var e=t.lastIntValue;if(this.regexp_eatOctalDigit(t)){var i=t.lastIntValue;e<=3&&this.regexp_eatOctalDigit(t)?t.lastIntValue=e*64+i*8+t.lastIntValue:t.lastIntValue=e*8+i}else t.lastIntValue=e;return!0}return!1};D.regexp_eatOctalDigit=function(t){var e=t.current();return xa(e)?(t.lastIntValue=e-48,t.advance(),!0):(t.lastIntValue=0,!1)};function xa(t){return t>=48&&t<=55}D.regexp_eatFixedHexDigits=function(t,e){var i=t.pos;t.lastIntValue=0;for(var r=0;r<e;++r){var n=t.current();if(!_a(n))return t.pos=i,!1;t.lastIntValue=16*t.lastIntValue+ga(n),t.advance()}return!0};var Yr=function(e){this.type=e.type,this.value=e.value,this.start=e.start,this.end=e.end,e.options.locations&&(this.loc=new er(e,e.startLoc,e.endLoc)),e.options.ranges&&(this.range=[e.start,e.end])},K=pe.prototype;K.next=function(t){!t&&this.type.keyword&&this.containsEsc&&this.raiseRecoverable(this.start,"Escape sequence in keyword "+this.type.keyword),this.options.onToken&&this.options.onToken(new Yr(this)),this.lastTokEnd=this.end,this.lastTokStart=this.start,this.lastTokEndLoc=this.endLoc,this.lastTokStartLoc=this.startLoc,this.nextToken()};K.getToken=function(){return this.next(),new Yr(this)};typeof Symbol<"u"&&(K[Symbol.iterator]=function(){var t=this;return{next:function(){var e=t.getToken();return{done:e.type===_.eof,value:e}}}});K.nextToken=function(){var t=this.curContext();if((!t||!t.preserveSpace)&&this.skipSpace(),this.start=this.pos,this.options.locations&&(this.startLoc=this.curPosition()),this.pos>=this.input.length)return this.finishToken(_.eof);if(t.override)return t.override(this);this.readToken(this.fullCharCodeAtPos())};K.readToken=function(t){return ut(t,this.options.ecmaVersion>=6)||t===92?this.readWord():this.getTokenFromCode(t)};K.fullCharCodeAt=function(t){var e=this.input.charCodeAt(t);if(e<=55295||e>=56320)return e;var i=this.input.charCodeAt(t+1);return i<=56319||i>=57344?e:(e<<10)+i-56613888};K.fullCharCodeAtPos=function(){return this.fullCharCodeAt(this.pos)};K.skipBlockComment=function(){var t=this.options.onComment&&this.curPosition(),e=this.pos,i=this.input.indexOf("*/",this.pos+=2);if(i===-1&&this.raise(this.pos-2,"Unterminated comment"),this.pos=i+2,this.options.locations)for(var r=void 0,n=e;(r=Ws(this.input,n,this.pos))>-1;)++this.curLine,n=this.lineStart=r;this.options.onComment&&this.options.onComment(!0,this.input.slice(e+2,i),e,this.pos,t,this.curPosition())};K.skipLineComment=function(t){for(var e=this.pos,i=this.options.onComment&&this.curPosition(),r=this.input.charCodeAt(this.pos+=t);this.pos<this.input.length&&!ri(r);)r=this.input.charCodeAt(++this.pos);this.options.onComment&&this.options.onComment(!1,this.input.slice(e+t,this.pos),e,this.pos,i,this.curPosition())};K.skipSpace=function(){e:for(;this.pos<this.input.length;){var t=this.input.charCodeAt(this.pos);switch(t){case 32:case 160:++this.pos;break;case 13:this.input.charCodeAt(this.pos+1)===10&&++this.pos;case 10:case 8232:case 8233:++this.pos,this.options.locations&&(++this.curLine,this.lineStart=this.pos);break;case 47:switch(this.input.charCodeAt(this.pos+1)){case 42:this.skipBlockComment();break;case 47:this.skipLineComment(2);break;default:break e}break;default:if(t>8&&t<14||t>=5760&&Us.test(String.fromCharCode(t)))++this.pos;else break e}}};K.finishToken=function(t,e){this.end=this.pos,this.options.locations&&(this.endLoc=this.curPosition());var i=this.type;this.type=t,this.value=e,this.updateContext(i)};K.readToken_dot=function(){var t=this.input.charCodeAt(this.pos+1);if(t>=48&&t<=57)return this.readNumber(!0);var e=this.input.charCodeAt(this.pos+2);return this.options.ecmaVersion>=6&&t===46&&e===46?(this.pos+=3,this.finishToken(_.ellipsis)):(++this.pos,this.finishToken(_.dot))};K.readToken_slash=function(){var t=this.input.charCodeAt(this.pos+1);return this.exprAllowed?(++this.pos,this.readRegexp()):t===61?this.finishOp(_.assign,2):this.finishOp(_.slash,1)};K.readToken_mult_modulo_exp=function(t){var e=this.input.charCodeAt(this.pos+1),i=1,r=t===42?_.star:_.modulo;return this.options.ecmaVersion>=7&&t===42&&e===42&&(++i,r=_.starstar,e=this.input.charCodeAt(this.pos+2)),e===61?this.finishOp(_.assign,i+1):this.finishOp(r,i)};K.readToken_pipe_amp=function(t){var e=this.input.charCodeAt(this.pos+1);if(e===t){if(this.options.ecmaVersion>=12){var i=this.input.charCodeAt(this.pos+2);if(i===61)return this.finishOp(_.assign,3)}return this.finishOp(t===124?_.logicalOR:_.logicalAND,2)}return e===61?this.finishOp(_.assign,2):this.finishOp(t===124?_.bitwiseOR:_.bitwiseAND,1)};K.readToken_caret=function(){var t=this.input.charCodeAt(this.pos+1);return t===61?this.finishOp(_.assign,2):this.finishOp(_.bitwiseXOR,1)};K.readToken_plus_min=function(t){var e=this.input.charCodeAt(this.pos+1);return e===t?e===45&&!this.inModule&&this.input.charCodeAt(this.pos+2)===62&&(this.lastTokEnd===0||Oe.test(this.input.slice(this.lastTokEnd,this.pos)))?(this.skipLineComment(3),this.skipSpace(),this.nextToken()):this.finishOp(_.incDec,2):e===61?this.finishOp(_.assign,2):this.finishOp(_.plusMin,1)};K.readToken_lt_gt=function(t){var e=this.input.charCodeAt(this.pos+1),i=1;return e===t?(i=t===62&&this.input.charCodeAt(this.pos+2)===62?3:2,this.input.charCodeAt(this.pos+i)===61?this.finishOp(_.assign,i+1):this.finishOp(_.bitShift,i)):e===33&&t===60&&!this.inModule&&this.input.charCodeAt(this.pos+2)===45&&this.input.charCodeAt(this.pos+3)===45?(this.skipLineComment(4),this.skipSpace(),this.nextToken()):(e===61&&(i=2),this.finishOp(_.relational,i))};K.readToken_eq_excl=function(t){var e=this.input.charCodeAt(this.pos+1);return e===61?this.finishOp(_.equality,this.input.charCodeAt(this.pos+2)===61?3:2):t===61&&e===62&&this.options.ecmaVersion>=6?(this.pos+=2,this.finishToken(_.arrow)):this.finishOp(t===61?_.eq:_.prefix,1)};K.readToken_question=function(){var t=this.options.ecmaVersion;if(t>=11){var e=this.input.charCodeAt(this.pos+1);if(e===46){var i=this.input.charCodeAt(this.pos+2);if(i<48||i>57)return this.finishOp(_.questionDot,2)}if(e===63){if(t>=12){var r=this.input.charCodeAt(this.pos+2);if(r===61)return this.finishOp(_.assign,3)}return this.finishOp(_.coalesce,2)}}return this.finishOp(_.question,1)};K.readToken_numberSign=function(){var t=this.options.ecmaVersion,e=35;if(t>=13&&(++this.pos,e=this.fullCharCodeAtPos(),ut(e,!0)||e===92))return this.finishToken(_.privateId,this.readWord1());this.raise(this.pos,"Unexpected character '"+gt(e)+"'")};K.getTokenFromCode=function(t){switch(t){case 46:return this.readToken_dot();case 40:return++this.pos,this.finishToken(_.parenL);case 41:return++this.pos,this.finishToken(_.parenR);case 59:return++this.pos,this.finishToken(_.semi);case 44:return++this.pos,this.finishToken(_.comma);case 91:return++this.pos,this.finishToken(_.bracketL);case 93:return++this.pos,this.finishToken(_.bracketR);case 123:return++this.pos,this.finishToken(_.braceL);case 125:return++this.pos,this.finishToken(_.braceR);case 58:return++this.pos,this.finishToken(_.colon);case 96:if(this.options.ecmaVersion<6)break;return++this.pos,this.finishToken(_.backQuote);case 48:var e=this.input.charCodeAt(this.pos+1);if(e===120||e===88)return this.readRadixNumber(16);if(this.options.ecmaVersion>=6){if(e===111||e===79)return this.readRadixNumber(8);if(e===98||e===66)return this.readRadixNumber(2)}case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return this.readNumber(!1);case 34:case 39:return this.readString(t);case 47:return this.readToken_slash();case 37:case 42:return this.readToken_mult_modulo_exp(t);case 124:case 38:return this.readToken_pipe_amp(t);case 94:return this.readToken_caret();case 43:case 45:return this.readToken_plus_min(t);case 60:case 62:return this.readToken_lt_gt(t);case 61:case 33:return this.readToken_eq_excl(t);case 63:return this.readToken_question();case 126:return this.finishOp(_.prefix,1);case 35:return this.readToken_numberSign()}this.raise(this.pos,"Unexpected character '"+gt(t)+"'")};K.finishOp=function(t,e){var i=this.input.slice(this.pos,this.pos+e);return this.pos+=e,this.finishToken(t,i)};K.readRegexp=function(){for(var t,e,i=this.pos;;){this.pos>=this.input.length&&this.raise(i,"Unterminated regular expression");var r=this.input.charAt(this.pos);if(Oe.test(r)&&this.raise(i,"Unterminated regular expression"),t)t=!1;else{if(r==="[")e=!0;else if(r==="]"&&e)e=!1;else if(r==="/"&&!e)break;t=r==="\\"}++this.pos}var n=this.input.slice(i,this.pos);++this.pos;var s=this.pos,a=this.readWord1();this.containsEsc&&this.unexpected(s);var o=this.regexpState||(this.regexpState=new ht(this));o.reset(i,n,a),this.validateRegExpFlags(o),this.validateRegExpPattern(o);var l=null;try{l=new RegExp(n,a)}catch{}return this.finishToken(_.regexp,{pattern:n,flags:a,value:l})};K.readInt=function(t,e,i){for(var r=this.options.ecmaVersion>=12&&e===void 0,n=i&&this.input.charCodeAt(this.pos)===48,s=this.pos,a=0,o=0,l=0,c=e??1/0;l<c;++l,++this.pos){var u=this.input.charCodeAt(this.pos),p=void 0;if(r&&u===95){n&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed in legacy octal numeric literals"),o===95&&this.raiseRecoverable(this.pos,"Numeric separator must be exactly one underscore"),l===0&&this.raiseRecoverable(this.pos,"Numeric separator is not allowed at the first of digits"),o=u;continue}if(u>=97?p=u-97+10:u>=65?p=u-65+10:u>=48&&u<=57?p=u-48:p=1/0,p>=t)break;o=u,a=a*t+p}return r&&o===95&&this.raiseRecoverable(this.pos-1,"Numeric separator is not allowed at the last of digits"),this.pos===s||e!=null&&this.pos-s!==e?null:a};function iy(t,e){return e?parseInt(t,8):parseFloat(t.replace(/_/g,""))}function ba(t){return typeof BigInt!="function"?null:BigInt(t.replace(/_/g,""))}K.readRadixNumber=function(t){var e=this.pos;this.pos+=2;var i=this.readInt(t);return i==null&&this.raise(this.start+2,"Expected number in radix "+t),this.options.ecmaVersion>=11&&this.input.charCodeAt(this.pos)===110?(i=ba(this.input.slice(e,this.pos)),++this.pos):ut(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(_.num,i)};K.readNumber=function(t){var e=this.pos;!t&&this.readInt(10,void 0,!0)===null&&this.raise(e,"Invalid number");var i=this.pos-e>=2&&this.input.charCodeAt(e)===48;i&&this.strict&&this.raise(e,"Invalid number");var r=this.input.charCodeAt(this.pos);if(!i&&!t&&this.options.ecmaVersion>=11&&r===110){var n=ba(this.input.slice(e,this.pos));return++this.pos,ut(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number"),this.finishToken(_.num,n)}i&&/[89]/.test(this.input.slice(e,this.pos))&&(i=!1),r===46&&!i&&(++this.pos,this.readInt(10),r=this.input.charCodeAt(this.pos)),(r===69||r===101)&&!i&&(r=this.input.charCodeAt(++this.pos),(r===43||r===45)&&++this.pos,this.readInt(10)===null&&this.raise(e,"Invalid number")),ut(this.fullCharCodeAtPos())&&this.raise(this.pos,"Identifier directly after number");var s=iy(this.input.slice(e,this.pos),i);return this.finishToken(_.num,s)};K.readCodePoint=function(){var t=this.input.charCodeAt(this.pos),e;if(t===123){this.options.ecmaVersion<6&&this.unexpected();var i=++this.pos;e=this.readHexChar(this.input.indexOf("}",this.pos)-this.pos),++this.pos,e>1114111&&this.invalidStringToken(i,"Code point out of bounds")}else e=this.readHexChar(4);return e};K.readString=function(t){for(var e="",i=++this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated string constant");var r=this.input.charCodeAt(this.pos);if(r===t)break;r===92?(e+=this.input.slice(i,this.pos),e+=this.readEscapedChar(!1),i=this.pos):r===8232||r===8233?(this.options.ecmaVersion<10&&this.raise(this.start,"Unterminated string constant"),++this.pos,this.options.locations&&(this.curLine++,this.lineStart=this.pos)):(ri(r)&&this.raise(this.start,"Unterminated string constant"),++this.pos)}return e+=this.input.slice(i,this.pos++),this.finishToken(_.string,e)};var va={};K.tryReadTemplateToken=function(){this.inTemplateElement=!0;try{this.readTmplToken()}catch(t){if(t===va)this.readInvalidTemplateToken();else throw t}this.inTemplateElement=!1};K.invalidStringToken=function(t,e){if(this.inTemplateElement&&this.options.ecmaVersion>=9)throw va;this.raise(t,e)};K.readTmplToken=function(){for(var t="",e=this.pos;;){this.pos>=this.input.length&&this.raise(this.start,"Unterminated template");var i=this.input.charCodeAt(this.pos);if(i===96||i===36&&this.input.charCodeAt(this.pos+1)===123)return this.pos===this.start&&(this.type===_.template||this.type===_.invalidTemplate)?i===36?(this.pos+=2,this.finishToken(_.dollarBraceL)):(++this.pos,this.finishToken(_.backQuote)):(t+=this.input.slice(e,this.pos),this.finishToken(_.template,t));if(i===92)t+=this.input.slice(e,this.pos),t+=this.readEscapedChar(!0),e=this.pos;else if(ri(i)){switch(t+=this.input.slice(e,this.pos),++this.pos,i){case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:t+=`
|
|
7
|
+
`;break;default:t+=String.fromCharCode(i);break}this.options.locations&&(++this.curLine,this.lineStart=this.pos),e=this.pos}else++this.pos}};K.readInvalidTemplateToken=function(){for(;this.pos<this.input.length;this.pos++)switch(this.input[this.pos]){case"\\":++this.pos;break;case"$":if(this.input[this.pos+1]!=="{")break;case"`":return this.finishToken(_.invalidTemplate,this.input.slice(this.start,this.pos));case"\r":this.input[this.pos+1]===`
|
|
8
8
|
`&&++this.pos;case`
|
|
9
|
-
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};
|
|
10
|
-
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return gt(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),t){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=parseInt(r,8)),this.pos+=r.length-1,e=this.input.charCodeAt(this.pos),(r!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-r.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(n)}return ri(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};
|
|
9
|
+
`:case"\u2028":case"\u2029":++this.curLine,this.lineStart=this.pos+1;break}this.raise(this.start,"Unterminated template")};K.readEscapedChar=function(t){var e=this.input.charCodeAt(++this.pos);switch(++this.pos,e){case 110:return`
|
|
10
|
+
`;case 114:return"\r";case 120:return String.fromCharCode(this.readHexChar(2));case 117:return gt(this.readCodePoint());case 116:return" ";case 98:return"\b";case 118:return"\v";case 102:return"\f";case 13:this.input.charCodeAt(this.pos)===10&&++this.pos;case 10:return this.options.locations&&(this.lineStart=this.pos,++this.curLine),"";case 56:case 57:if(this.strict&&this.invalidStringToken(this.pos-1,"Invalid escape sequence"),t){var i=this.pos-1;this.invalidStringToken(i,"Invalid escape sequence in template string")}default:if(e>=48&&e<=55){var r=this.input.substr(this.pos-1,3).match(/^[0-7]+/)[0],n=parseInt(r,8);return n>255&&(r=r.slice(0,-1),n=parseInt(r,8)),this.pos+=r.length-1,e=this.input.charCodeAt(this.pos),(r!=="0"||e===56||e===57)&&(this.strict||t)&&this.invalidStringToken(this.pos-1-r.length,t?"Octal literal in template string":"Octal literal in strict mode"),String.fromCharCode(n)}return ri(e)?(this.options.locations&&(this.lineStart=this.pos,++this.curLine),""):String.fromCharCode(e)}};K.readHexChar=function(t){var e=this.pos,i=this.readInt(16,t);return i===null&&this.invalidStringToken(e,"Bad character escape sequence"),i};K.readWord1=function(){this.containsEsc=!1;for(var t="",e=!0,i=this.pos,r=this.options.ecmaVersion>=6;this.pos<this.input.length;){var n=this.fullCharCodeAtPos();if(kt(n,r))this.pos+=n<=65535?1:2;else if(n===92){this.containsEsc=!0,t+=this.input.slice(i,this.pos);var s=this.pos;this.input.charCodeAt(++this.pos)!==117&&this.invalidStringToken(this.pos,"Expecting Unicode escape sequence \\uXXXX"),++this.pos;var a=this.readCodePoint();(e?ut:kt)(a,r)||this.invalidStringToken(s,"Invalid Unicode escape"),t+=gt(a),i=this.pos}else break;e=!1}return t+this.input.slice(i,this.pos)};K.readWord=function(){var t=this.readWord1(),e=_.name;return this.keywords.test(t)&&(e=Ur[t]),this.finishToken(e,t)};var ry="8.16.0";pe.acorn={Parser:pe,version:ry,defaultOptions:Ar,Position:bi,SourceLocation:er,getLineInfo:zs,Node:nr,TokenType:Y,tokTypes:_,keywordTypes:Ur,TokContext:Je,tokContexts:re,isIdentifierChar:kt,isIdentifierStart:ut,Token:Yr,isNewLine:ri,lineBreak:Oe,lineBreakG:Nm,nonASCIIwhitespace:Us};function Xr(t,e){return pe.parse(t,e)}const{stringify:ny}=JSON;if(!String.prototype.repeat)throw new Error("String.prototype.repeat is undefined, see https://github.com/davidbonnet/astring#installation");if(!String.prototype.endsWith)throw new Error("String.prototype.endsWith is undefined, see https://github.com/davidbonnet/astring#installation");const Ti={"||":2,"??":3,"&&":4,"|":5,"^":6,"&":7,"==":8,"!=":8,"===":8,"!==":8,"<":9,">":9,"<=":9,">=":9,in:9,instanceof:9,"<<":10,">>":10,">>>":10,"+":11,"-":11,"*":12,"%":12,"/":12,"**":13},tt=17,sy={ArrayExpression:20,TaggedTemplateExpression:20,ThisExpression:20,Identifier:20,PrivateIdentifier:20,Literal:18,TemplateLiteral:20,Super:20,SequenceExpression:20,MemberExpression:19,ChainExpression:19,CallExpression:19,NewExpression:19,ArrowFunctionExpression:tt,ClassExpression:tt,FunctionExpression:tt,ObjectExpression:tt,UpdateExpression:16,UnaryExpression:15,AwaitExpression:15,BinaryExpression:14,LogicalExpression:13,ConditionalExpression:4,AssignmentExpression:3,YieldExpression:2,RestElement:1};function Xt(t,e){const{generator:i}=t;if(t.write("("),e!=null&&e.length>0){i[e[0].type](e[0],t);const{length:r}=e;for(let n=1;n<r;n++){const s=e[n];t.write(", "),i[s.type](s,t)}}t.write(")")}function wa(t,e,i,r){const n=t.expressionsPrecedence[e.type];if(n===tt)return!0;const s=t.expressionsPrecedence[i.type];return n!==s?!r&&n===15&&s===14&&i.operator==="**"||n<s:n!==13&&n!==14?!1:e.operator==="**"&&i.operator==="**"?!r:n===13&&s===13&&(e.operator==="??"||i.operator==="??")?!0:r?Ti[e.operator]<=Ti[i.operator]:Ti[e.operator]<Ti[i.operator]}function Ai(t,e,i,r){const{generator:n}=t;wa(t,e,i,r)?(t.write("("),n[e.type](e,t),t.write(")")):n[e.type](e,t)}function ay(t,e,i,r){const n=e.split(`
|
|
11
11
|
`),s=n.length-1;if(t.write(n[0].trim()),s>0){t.write(r);for(let a=1;a<s;a++)t.write(i+n[a].trim()+r);t.write(i+n[s].trim())}}function Ce(t,e,i,r){const{length:n}=e;for(let s=0;s<n;s++){const a=e[s];t.write(i),a.type[0]==="L"?t.write("// "+a.value.trim()+`
|
|
12
12
|
`,a):(t.write("/*"),ay(t,a.value,i,r),t.write("*/"+r))}}function oy(t){let e=t;for(;e!=null;){const{type:i}=e;if(i[0]==="C"&&i[1]==="a")return!0;if(i[0]==="M"&&i[1]==="e"&&i[2]==="m")e=e.object;else return!1}}function yr(t,e){const{generator:i}=t,{declarations:r}=e;t.write(e.kind+" ");const{length:n}=r;if(n>0){i.VariableDeclarator(r[0],t);for(let s=1;s<n;s++)t.write(", "),i.VariableDeclarator(r[s],t)}}let kn,Tn,An,Pn,Dn,Mn;const Zr={Program(t,e){const i=e.indent.repeat(e.indentLevel),{lineEnd:r,writeComments:n}=e;n&&t.comments!=null&&Ce(e,t.comments,i,r);const s=t.body,{length:a}=s;for(let o=0;o<a;o++){const l=s[o];n&&l.comments!=null&&Ce(e,l.comments,i,r),e.write(i),this[l.type](l,e),e.write(r)}n&&t.trailingComments!=null&&Ce(e,t.trailingComments,i,r)},BlockStatement:Mn=function(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,s=i+e.indent;e.write("{");const a=t.body;if(a!=null&&a.length>0){e.write(r),n&&t.comments!=null&&Ce(e,t.comments,s,r);const{length:o}=a;for(let l=0;l<o;l++){const c=a[l];n&&c.comments!=null&&Ce(e,c.comments,s,r),e.write(s),this[c.type](c,e),e.write(r)}e.write(i)}else n&&t.comments!=null&&(e.write(r),Ce(e,t.comments,s,r),e.write(i));n&&t.trailingComments!=null&&Ce(e,t.trailingComments,s,r),e.write("}"),e.indentLevel--},ClassBody:Mn,StaticBlock(t,e){e.write("static "),this.BlockStatement(t,e)},EmptyStatement(t,e){e.write(";")},ExpressionStatement(t,e){const i=e.expressionsPrecedence[t.expression.type];i===tt||i===3&&t.expression.left.type[0]==="O"?(e.write("("),this[t.expression.type](t.expression,e),e.write(")")):this[t.expression.type](t.expression,e),e.write(";")},IfStatement(t,e){e.write("if ("),this[t.test.type](t.test,e),e.write(") "),this[t.consequent.type](t.consequent,e),t.alternate!=null&&(e.write(" else "),this[t.alternate.type](t.alternate,e))},LabeledStatement(t,e){this[t.label.type](t.label,e),e.write(": "),this[t.body.type](t.body,e)},BreakStatement(t,e){e.write("break"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},ContinueStatement(t,e){e.write("continue"),t.label!=null&&(e.write(" "),this[t.label.type](t.label,e)),e.write(";")},WithStatement(t,e){e.write("with ("),this[t.object.type](t.object,e),e.write(") "),this[t.body.type](t.body,e)},SwitchStatement(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e;e.indentLevel++;const s=i+e.indent,a=s+e.indent;e.write("switch ("),this[t.discriminant.type](t.discriminant,e),e.write(") {"+r);const{cases:o}=t,{length:l}=o;for(let c=0;c<l;c++){const u=o[c];n&&u.comments!=null&&Ce(e,u.comments,s,r),u.test?(e.write(s+"case "),this[u.test.type](u.test,e),e.write(":"+r)):e.write(s+"default:"+r);const{consequent:p}=u,{length:h}=p;for(let f=0;f<h;f++){const d=p[f];n&&d.comments!=null&&Ce(e,d.comments,a,r),e.write(a),this[d.type](d,e),e.write(r)}}e.indentLevel-=2,e.write(i+"}")},ReturnStatement(t,e){e.write("return"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e)),e.write(";")},ThrowStatement(t,e){e.write("throw "),this[t.argument.type](t.argument,e),e.write(";")},TryStatement(t,e){if(e.write("try "),this[t.block.type](t.block,e),t.handler){const{handler:i}=t;i.param==null?e.write(" catch "):(e.write(" catch ("),this[i.param.type](i.param,e),e.write(") ")),this[i.body.type](i.body,e)}t.finalizer&&(e.write(" finally "),this[t.finalizer.type](t.finalizer,e))},WhileStatement(t,e){e.write("while ("),this[t.test.type](t.test,e),e.write(") "),this[t.body.type](t.body,e)},DoWhileStatement(t,e){e.write("do "),this[t.body.type](t.body,e),e.write(" while ("),this[t.test.type](t.test,e),e.write(");")},ForStatement(t,e){if(e.write("for ("),t.init!=null){const{init:i}=t;i.type[0]==="V"?yr(e,i):this[i.type](i,e)}e.write("; "),t.test&&this[t.test.type](t.test,e),e.write("; "),t.update&&this[t.update.type](t.update,e),e.write(") "),this[t.body.type](t.body,e)},ForInStatement:kn=function(t,e){e.write(`for ${t.await?"await ":""}(`);const{left:i}=t;i.type[0]==="V"?yr(e,i):this[i.type](i,e),e.write(t.type[3]==="I"?" in ":" of "),this[t.right.type](t.right,e),e.write(") "),this[t.body.type](t.body,e)},ForOfStatement:kn,DebuggerStatement(t,e){e.write("debugger;",t)},FunctionDeclaration:Tn=function(t,e){e.write((t.async?"async ":"")+(t.generator?"function* ":"function ")+(t.id?t.id.name:""),t),Xt(e,t.params),e.write(" "),this[t.body.type](t.body,e)},FunctionExpression:Tn,VariableDeclaration(t,e){yr(e,t),e.write(";")},VariableDeclarator(t,e){this[t.id.type](t.id,e),t.init!=null&&(e.write(" = "),this[t.init.type](t.init,e))},ClassDeclaration(t,e){if(e.write("class "+(t.id?`${t.id.name} `:""),t),t.superClass){e.write("extends ");const{superClass:i}=t,{type:r}=i,n=e.expressionsPrecedence[r];(r[0]!=="C"||r[1]!=="l"||r[5]!=="E")&&(n===tt||n<e.expressionsPrecedence.ClassExpression)?(e.write("("),this[t.superClass.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ")}this.ClassBody(t.body,e)},ImportDeclaration(t,e){e.write("import ");const{specifiers:i,attributes:r}=t,{length:n}=i;let s=0;if(n>0){for(;s<n;){s>0&&e.write(", ");const a=i[s],o=a.type[6];if(o==="D")e.write(a.local.name,a),s++;else if(o==="N")e.write("* as "+a.local.name,a),s++;else break}if(s<n){for(e.write("{");;){const a=i[s],{name:o}=a.imported;if(e.write(o,a),o!==a.local.name&&e.write(" as "+a.local.name),++s<n)e.write(", ");else break}e.write("}")}e.write(" from ")}if(this.Literal(t.source,e),r&&r.length>0){e.write(" with { ");for(let a=0;a<r.length;a++)this.ImportAttribute(r[a],e),a<r.length-1&&e.write(", ");e.write(" }")}e.write(";")},ImportAttribute(t,e){this.Identifier(t.key,e),e.write(": "),this.Literal(t.value,e)},ImportExpression(t,e){e.write("import("),this[t.source.type](t.source,e),e.write(")")},ExportDefaultDeclaration(t,e){e.write("export default "),this[t.declaration.type](t.declaration,e),e.expressionsPrecedence[t.declaration.type]!=null&&t.declaration.type[0]!=="F"&&e.write(";")},ExportNamedDeclaration(t,e){if(e.write("export "),t.declaration)this[t.declaration.type](t.declaration,e);else{e.write("{");const{specifiers:i}=t,{length:r}=i;if(r>0)for(let n=0;;){const s=i[n],{name:a}=s.local;if(e.write(a,s),a!==s.exported.name&&e.write(" as "+s.exported.name),++n<r)e.write(", ");else break}if(e.write("}"),t.source&&(e.write(" from "),this.Literal(t.source,e)),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let n=0;n<t.attributes.length;n++)this.ImportAttribute(t.attributes[n],e),n<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")}},ExportAllDeclaration(t,e){if(t.exported!=null?e.write("export * as "+t.exported.name+" from "):e.write("export * from "),this.Literal(t.source,e),t.attributes&&t.attributes.length>0){e.write(" with { ");for(let i=0;i<t.attributes.length;i++)this.ImportAttribute(t.attributes[i],e),i<t.attributes.length-1&&e.write(", ");e.write(" }")}e.write(";")},MethodDefinition(t,e){t.static&&e.write("static ");const i=t.kind[0];(i==="g"||i==="s")&&e.write(t.kind+" "),t.value.async&&e.write("async "),t.value.generator&&e.write("*"),t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),Xt(e,t.value.params),e.write(" "),this[t.value.body.type](t.value.body,e)},ClassExpression(t,e){this.ClassDeclaration(t,e)},ArrowFunctionExpression(t,e){e.write(t.async?"async ":"",t);const{params:i}=t;i!=null&&(i.length===1&&i[0].type[0]==="I"?e.write(i[0].name,i[0]):Xt(e,t.params)),e.write(" => "),t.body.type[0]==="O"?(e.write("("),this.ObjectExpression(t.body,e),e.write(")")):this[t.body.type](t.body,e)},ThisExpression(t,e){e.write("this",t)},Super(t,e){e.write("super",t)},RestElement:An=function(t,e){e.write("..."),this[t.argument.type](t.argument,e)},SpreadElement:An,YieldExpression(t,e){e.write(t.delegate?"yield*":"yield"),t.argument&&(e.write(" "),this[t.argument.type](t.argument,e))},AwaitExpression(t,e){e.write("await ",t),Ai(e,t.argument,t)},TemplateLiteral(t,e){const{quasis:i,expressions:r}=t;e.write("`");const{length:n}=r;for(let a=0;a<n;a++){const o=r[a],l=i[a];e.write(l.value.raw,l),e.write("${"),this[o.type](o,e),e.write("}")}const s=i[i.length-1];e.write(s.value.raw,s),e.write("`")},TemplateElement(t,e){e.write(t.value.raw,t)},TaggedTemplateExpression(t,e){Ai(e,t.tag,t),this[t.quasi.type](t.quasi,e)},ArrayExpression:Dn=function(t,e){if(e.write("["),t.elements.length>0){const{elements:i}=t,{length:r}=i;for(let n=0;;){const s=i[n];if(s!=null&&this[s.type](s,e),++n<r)e.write(", ");else{s==null&&e.write(", ");break}}}e.write("]")},ArrayPattern:Dn,ObjectExpression(t,e){const i=e.indent.repeat(e.indentLevel++),{lineEnd:r,writeComments:n}=e,s=i+e.indent;if(e.write("{"),t.properties.length>0){e.write(r),n&&t.comments!=null&&Ce(e,t.comments,s,r);const a=","+r,{properties:o}=t,{length:l}=o;for(let c=0;;){const u=o[c];if(n&&u.comments!=null&&Ce(e,u.comments,s,r),e.write(s),this[u.type](u,e),++c<l)e.write(a);else break}e.write(r),n&&t.trailingComments!=null&&Ce(e,t.trailingComments,s,r),e.write(i+"}")}else n?t.comments!=null?(e.write(r),Ce(e,t.comments,s,r),t.trailingComments!=null&&Ce(e,t.trailingComments,s,r),e.write(i+"}")):t.trailingComments!=null?(e.write(r),Ce(e,t.trailingComments,s,r),e.write(i+"}")):e.write("}"):e.write("}");e.indentLevel--},Property(t,e){t.method||t.kind[0]!=="i"?this.MethodDefinition(t,e):(t.shorthand||(t.computed?(e.write("["),this[t.key.type](t.key,e),e.write("]")):this[t.key.type](t.key,e),e.write(": ")),this[t.value.type](t.value,e))},PropertyDefinition(t,e){if(t.static&&e.write("static "),t.computed&&e.write("["),this[t.key.type](t.key,e),t.computed&&e.write("]"),t.value==null){t.key.type[0]!=="F"&&e.write(";");return}e.write(" = "),this[t.value.type](t.value,e),e.write(";")},ObjectPattern(t,e){if(e.write("{"),t.properties.length>0){const{properties:i}=t,{length:r}=i;for(let n=0;this[i[n].type](i[n],e),++n<r;)e.write(", ")}e.write("}")},SequenceExpression(t,e){Xt(e,t.expressions)},UnaryExpression(t,e){if(t.prefix){const{operator:i,argument:r,argument:{type:n}}=t;e.write(i);const s=wa(e,r,t);!s&&(i.length>1||n[0]==="U"&&(n[1]==="n"||n[1]==="p")&&r.prefix&&r.operator[0]===i&&(i==="+"||i==="-"))&&e.write(" "),s?(e.write(i.length>1?" (":"("),this[n](r,e),e.write(")")):this[n](r,e)}else this[t.argument.type](t.argument,e),e.write(t.operator)},UpdateExpression(t,e){t.prefix?(e.write(t.operator),this[t.argument.type](t.argument,e)):(this[t.argument.type](t.argument,e),e.write(t.operator))},AssignmentExpression(t,e){this[t.left.type](t.left,e),e.write(" "+t.operator+" "),this[t.right.type](t.right,e)},AssignmentPattern(t,e){this[t.left.type](t.left,e),e.write(" = "),this[t.right.type](t.right,e)},BinaryExpression:Pn=function(t,e){const i=t.operator==="in";i&&e.write("("),Ai(e,t.left,t,!1),e.write(" "+t.operator+" "),Ai(e,t.right,t,!0),i&&e.write(")")},LogicalExpression:Pn,ConditionalExpression(t,e){const{test:i}=t,r=e.expressionsPrecedence[i.type];r===tt||r<=e.expressionsPrecedence.ConditionalExpression?(e.write("("),this[i.type](i,e),e.write(")")):this[i.type](i,e),e.write(" ? "),this[t.consequent.type](t.consequent,e),e.write(" : "),this[t.alternate.type](t.alternate,e)},NewExpression(t,e){e.write("new ");const i=e.expressionsPrecedence[t.callee.type];i===tt||i<e.expressionsPrecedence.CallExpression||oy(t.callee)?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),Xt(e,t.arguments)},CallExpression(t,e){const i=e.expressionsPrecedence[t.callee.type];i===tt||i<e.expressionsPrecedence.CallExpression?(e.write("("),this[t.callee.type](t.callee,e),e.write(")")):this[t.callee.type](t.callee,e),t.optional&&e.write("?."),Xt(e,t.arguments)},ChainExpression(t,e){this[t.expression.type](t.expression,e)},MemberExpression(t,e){const i=e.expressionsPrecedence[t.object.type];i===tt||i<e.expressionsPrecedence.MemberExpression?(e.write("("),this[t.object.type](t.object,e),e.write(")")):this[t.object.type](t.object,e),t.computed?(t.optional&&e.write("?."),e.write("["),this[t.property.type](t.property,e),e.write("]")):(t.optional?e.write("?."):e.write("."),this[t.property.type](t.property,e))},MetaProperty(t,e){e.write(t.meta.name+"."+t.property.name,t)},Identifier(t,e){e.write(t.name,t)},PrivateIdentifier(t,e){e.write(`#${t.name}`,t)},Literal(t,e){t.raw!=null?e.write(t.raw,t):t.regex!=null?this.RegExpLiteral(t,e):t.bigint!=null?e.write(t.bigint+"n",t):e.write(ny(t.value),t)},RegExpLiteral(t,e){const{regex:i}=t;e.write(`/${i.pattern}/${i.flags}`,t)}},ly={},cy=Zr;class uy{constructor(e){const i=e??ly;this.output="",i.output!=null?(this.output=i.output,this.write=this.writeToStream):this.output="",this.generator=i.generator!=null?i.generator:Zr,this.expressionsPrecedence=i.expressionsPrecedence!=null?i.expressionsPrecedence:sy,this.indent=i.indent!=null?i.indent:" ",this.lineEnd=i.lineEnd!=null?i.lineEnd:`
|
|
13
13
|
`,this.indentLevel=i.startingIndentLevel!=null?i.startingIndentLevel:0,this.writeComments=i.comments?i.comments:!1,i.sourceMap!=null&&(this.write=i.output==null?this.writeAndMap:this.writeToStreamAndMap,this.sourceMap=i.sourceMap,this.line=1,this.column=0,this.lineEndSize=this.lineEnd.split(`
|
|
14
14
|
`).length-1,this.mapping={original:null,generated:this,name:void 0,source:i.sourceMap.file||i.sourceMap._file})}write(e){this.output+=e}writeToStream(e){this.output.write(e)}writeAndMap(e,i){this.output+=e,this.map(e,i)}writeToStreamAndMap(e,i){this.output.write(e),this.map(e,i)}map(e,i){if(i!=null){const{type:s}=i;if(s[0]==="L"&&s[2]==="n"){this.column=0,this.line++;return}if(i.loc!=null){const{mapping:a}=this;a.original=i.loc.start,a.name=i.name,this.sourceMap.addMapping(a)}if(s[0]==="T"&&s[8]==="E"||s[0]==="L"&&s[1]==="i"&&typeof i.value=="string"){const{length:a}=e;let{column:o,line:l}=this;for(let c=0;c<a;c++)e[c]===`
|
|
15
|
-
`?(o=0,l++):o++;this.column=o,this.line=l;return}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(n.length===1?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function Qr(t,e){const i=new uy(e);return i.generator[t.type](t,i),i.output}var hy=Object.defineProperty,py=(t,e,i)=>e in t?hy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,X=(t,e,i)=>py(t,typeof e!="symbol"?e+"":e,i);const fy=new Set(["Infinity","NaN","undefined","null","true","false"]),dy=new Set(["Math","Array","Object","String","Number","Boolean","Date","RegExp","Error","JSON","Promise","Set","Map","WeakSet","WeakMap","Symbol","BigInt","Proxy","Reflect","console","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]);class my{constructor(){X(this,"scopes",[]),X(this,"scopeTypes",[]),X(this,"scopeCounts",new Map),X(this,"contextBoundVars",new Set),X(this,"arrayPatternElements",new Set),X(this,"rootParams",new Set),X(this,"localSeriesVars",new Set),X(this,"varKinds",new Map),X(this,"loopVars",new Set),X(this,"loopVarNames",new Map),X(this,"paramIdCounter",0),X(this,"cacheIdCounter",0),X(this,"tempVarCounter",0),X(this,"taCallIdCounter",0),X(this,"userCallIdCounter",0),X(this,"plotCallIdCounter",0),X(this,"alertCallIdCounter",0),X(this,"loopGuardCounter",0),X(this,"hoistingStack",[]),X(this,"suppressHoisting",!1),X(this,"reservedNames",new Set),X(this,"userFunctions",new Set),X(this,"userMethods",new Set),X(this,"regularUserFunctions",new Set),X(this,"udtTypeNames",new Map),X(this,"udtInstances",new Map),X(this,"functionReturnTypes",new Map),X(this,"functionReturnTupleTypes",new Map),X(this,"functionParamUdtTypes",new Map),this.pushScope("glb")}get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}get nextCacheIdArg(){return{type:"Identifier",name:`'cache_${this.cacheIdCounter++}'`}}getNextTACallId(){return{type:"Literal",value:`_ta${this.taCallIdCounter++}`}}getNextUserCallId(){return{type:"Literal",value:`_fn${this.userCallIdCounter++}`}}getNextPlotCallId(){return{type:"Literal",value:`#${this.plotCallIdCounter++}`}}getNextAlertCallId(){return{type:"Literal",value:`alert_${this.alertCallIdCounter++}`}}getNextLoopGuardName(){return`__lg${this.loopGuardCounter++}`}pushScope(e){this.scopes.push(new Map),this.scopeTypes.push(e),this.scopeCounts.set(e,(this.scopeCounts.get(e)||0)+1)}popScope(){this.scopes.pop(),this.scopeTypes.pop()}getCurrentScopeType(){return this.scopeTypes[this.scopeTypes.length-1]}isInsideFunctionScope(){for(let e=this.scopeTypes.length-1;e>=0;e--)if(this.scopeTypes[e]==="fn")return!0;return!1}getCurrentScopeCount(){return this.scopeCounts.get(this.getCurrentScopeType())||1}addLocalSeriesVar(e){this.localSeriesVars.add(e)}removeLocalSeriesVar(e){this.localSeriesVars.delete(e)}isLocalSeriesVar(e){return this.localSeriesVars.has(e)}addUdtTypeName(e,i={}){this.udtTypeNames.set(e,i)}isUdtTypeName(e){return this.udtTypeNames.has(e)}getUdtTypeFields(e){return this.udtTypeNames.get(e)}markVariableAsUdtInstance(e,i){this.udtInstances.set(e,i)}getVariableUdtType(e){return this.udtInstances.get(e)}isUdtInstance(e){return this.udtInstances.has(e)}setFunctionReturnType(e,i){const r=this.functionReturnTypes.get(e);if(r&&r!==i){this.functionReturnTypes.delete(e);return}this.functionReturnTypes.set(e,i)}getFunctionReturnType(e){return this.functionReturnTypes.get(e)}setFunctionReturnTupleType(e,i){const r=this.functionReturnTupleTypes.get(e);if(r&&(r.length!==i.length||r.some((n,s)=>n!==i[s]))){this.functionReturnTupleTypes.delete(e);return}this.functionReturnTupleTypes.set(e,i)}getFunctionReturnTupleType(e){return this.functionReturnTupleTypes.get(e)}setFunctionParamUdtTypes(e,i){this.functionParamUdtTypes.set(e,i)}getFunctionParamUdtTypes(e){return this.functionParamUdtTypes.get(e)}unmarkVariableAsUdtInstance(e){this.udtInstances.delete(e)}addContextBoundVar(e,i=!1){this.contextBoundVars.add(e),i&&this.rootParams.add(e)}removeContextBoundVar(e){this.contextBoundVars.has(e)&&(this.contextBoundVars.delete(e),this.rootParams.has(e)&&this.rootParams.delete(e))}addArrayPatternElement(e){this.arrayPatternElements.add(e)}isContextBound(e){return fy.has(e)||dy.has(e)?!1:this.contextBoundVars.has(e)}isArrayPatternElement(e){return this.arrayPatternElements.has(e)}isRootParam(e){return this.rootParams.has(e)}addLoopVariable(e,i){this.loopVars.add(e),this.loopVarNames.set(e,i)}removeLoopVariable(e){this.loopVars.delete(e),this.loopVarNames.delete(e)}getLoopVariableName(e){return this.loopVarNames.get(e)}isLoopVariable(e){return this.loopVars.has(e)}addReservedName(e){this.reservedNames.add(e)}addUserFunction(e){this.userFunctions.add(e)}isUserFunction(e){return this.userFunctions.has(e)}addUserMethod(e){this.userMethods.add(e)}isUserMethod(e){return this.userMethods.has(e)}addRegularUserFunction(e){this.regularUserFunctions.add(e)}isRegularUserFunction(e){return this.regularUserFunctions.has(e)}addVariable(e,i){if(this.isContextBound(e))return e;const r=this.scopes[this.scopes.length-1],n=this.scopeTypes[this.scopeTypes.length-1],s=this.scopeCounts.get(n)||1,a=`${n}${s}_${e}`;return r.set(e,a),this.varKinds.set(a,i),a}getVariable(e){if(this.loopVars.has(e)){const i=this.loopVarNames.get(e);if(i)return[i,"let"]}if(this.isContextBound(e))return[e,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(e)){const n=r.get(e),s=this.varKinds.get(n)||"let";return[n,s]}}return[e,"let"]}isVariableInFunctionScope(e){for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e)){for(let r=0;r<=i;r++)if(this.scopeTypes[r]==="fn")return!0;return!1}return!1}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(e){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(e)}addOuterHoistedStatement(e){if(this.hoistingStack.length>0&&!this.suppressHoisting){const i=Math.min(1,this.hoistingStack.length-1);this.hoistingStack[i].push(e)}}getCurrentHoistingScope(){return this.hoistingStack.length===0?null:this.hoistingStack[this.hoistingStack.length-1]}setSuppressHoisting(e){this.suppressHoisting=e}shouldSuppressHoisting(){return this.suppressHoisting}hasVariableInScope(e){if(this.reservedNames.has(e))return!0;for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e))return!0;return!!(this.contextBoundVars.has(e)||this.loopVars.has(e)||this.localSeriesVars.has(e))}generateParamId(){let e=`p${this.paramIdCounter++}`;for(;this.hasVariableInScope(e);)e=`p${this.paramIdCounter++}`;const i=this.scopes[this.scopes.length-1];return i&&i.set(e,e),e}}function He(t,e,i,r,n){i||(i=I),(function s(a,o,l){var c=l||a.type;Sa(i,c,a,o,s),e[c]&&e[c](a,o)})(t,r,n)}function yy(t,e,i,r,n){var s=[];i||(i=I),(function a(o,l,c){var u=c||o.type,p=o!==s[s.length-1];p&&s.push(o),Sa(i,u,o,l,a),e[u]&&e[u](o,l||s,s),p&&s.pop()})(t,r,n)}function ue(t,e,i,r,n){var s=i?_y(i,r||void 0):r;(function a(o,l,c){s[c||o.type](o,l,a)})(t,e,n)}function _y(t,e){var i=Object.create(e||I);for(var r in t)i[r]=t[r];return i}function Jr(t,e,i){i(t,e)}function jt(t,e,i){}function Sa(t,e,i,r,n){if(t[e]==null)throw new Error("No walker function defined for node type "+e);t[e](i,r,n)}var I={};I.Program=I.BlockStatement=I.StaticBlock=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var s=n[r];i(s,e,"Statement")}};I.Statement=Jr;I.EmptyStatement=jt;I.ExpressionStatement=I.ParenthesizedExpression=I.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};I.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};I.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};I.BreakStatement=I.ContinueStatement=jt;I.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};I.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,n=t.cases;r<n.length;r+=1){var s=n[r];i(s,e)}};I.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,n=t.consequent;r<n.length;r+=1){var s=n[r];i(s,e,"Statement")}};I.ReturnStatement=I.YieldExpression=I.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};I.ThrowStatement=I.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};I.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};I.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};I.WhileStatement=I.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};I.ForStatement=function(t,e,i){t.init&&i(t.init,e,"ForInit"),t.test&&i(t.test,e,"Expression"),t.update&&i(t.update,e,"Expression"),i(t.body,e,"Statement")};I.ForInStatement=I.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};I.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};I.DebuggerStatement=jt;I.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};I.VariableDeclaration=function(t,e,i){for(var r=0,n=t.declarations;r<n.length;r+=1){var s=n[r];i(s,e)}};I.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};I.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,n=t.params;r<n.length;r+=1){var s=n[r];i(s,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};I.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};I.VariablePattern=jt;I.MemberPattern=Jr;I.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};I.ArrayPattern=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var s=n[r];s&&i(s,e,"Pattern")}};I.ObjectPattern=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];s.type==="Property"?(s.computed&&i(s.key,e,"Expression"),i(s.value,e,"Pattern")):s.type==="RestElement"&&i(s.argument,e,"Pattern")}};I.Expression=Jr;I.ThisExpression=I.Super=I.MetaProperty=jt;I.ArrayExpression=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var s=n[r];s&&i(s,e,"Expression")}};I.ObjectExpression=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];i(s,e)}};I.FunctionExpression=I.ArrowFunctionExpression=I.FunctionDeclaration;I.SequenceExpression=function(t,e,i){for(var r=0,n=t.expressions;r<n.length;r+=1){var s=n[r];i(s,e,"Expression")}};I.TemplateLiteral=function(t,e,i){for(var r=0,n=t.quasis;r<n.length;r+=1){var s=n[r];i(s,e)}for(var a=0,o=t.expressions;a<o.length;a+=1){var l=o[a];i(l,e,"Expression")}};I.TemplateElement=jt;I.UnaryExpression=I.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};I.BinaryExpression=I.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};I.AssignmentExpression=I.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};I.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};I.NewExpression=I.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,n=t.arguments;r<n.length;r+=1){var s=n[r];i(s,e,"Expression")}};I.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};I.ExportNamedDeclaration=I.ExportDefaultDeclaration=function(t,e,i){if(t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var s=n[r];i(s,e)}};I.ExportAllDeclaration=function(t,e,i){if(t.exported&&i(t.exported,e),i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var s=n[r];i(s,e)}};I.ImportAttribute=function(t,e,i){i(t.value,e,"Expression")};I.ImportDeclaration=function(t,e,i){for(var r=0,n=t.specifiers;r<n.length;r+=1){var s=n[r];i(s,e)}if(i(t.source,e,"Expression"),t.attributes)for(var a=0,o=t.attributes;a<o.length;a+=1){var l=o[a];i(l,e)}};I.ImportExpression=function(t,e,i){i(t.source,e,"Expression"),t.options&&i(t.options,e,"Expression")};I.ImportSpecifier=I.ImportDefaultSpecifier=I.ImportNamespaceSpecifier=I.Identifier=I.PrivateIdentifier=I.Literal=jt;I.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};I.ClassDeclaration=I.ClassExpression=function(t,e,i){return i(t,e,"Class")};I.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};I.ClassBody=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var s=n[r];i(s,e)}};I.MethodDefinition=I.PropertyDefinition=I.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const se="$",S={createIdentifier(t){return{type:"Identifier",name:t}},createLiteral(t){return{type:"Literal",value:t}},createMemberExpression(t,e,i=!1){return{type:"MemberExpression",object:t,property:e,computed:i}},createContextIdentifier(){return this.createIdentifier("$")},createLocalContextIdentifier(){return this.createIdentifier("$$")},createContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createDynamicContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(i,r,!1),e,!0)},createContextVariableAccess0(t,e){const i=this.createContextVariableReference(t,e);return this.createGetCall(i,0)},createDynamicContextVariableAccess0(t,e){const i=this.createDynamicContextVariableReference(t,e);return this.createGetCall(i,0)},createArrayAccess(t,e){const i=typeof e=="number"?this.createLiteral(e):e;return this.createMemberExpression(t,i,!0)},createCallExpression(t,e){return{type:"CallExpression",callee:t,arguments:e}},createAssignmentExpression(t,e,i="="){return{type:"AssignmentExpression",operator:i,left:t,right:e}},createExpressionStatement(t){return{type:"ExpressionStatement",expression:t}},createInitCall(t,e,i){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),n=[t,e];return i&&n.push(i),this.createCallExpression(r,n)},createInitVarCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[t,e];return this.createCallExpression(i,r)},createGetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof e=="number"?this.createLiteral(e):e;return this.createCallExpression(i,[t,r])},createSetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(i,[t,e])},createMathEqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(n,[t,e])},createMathNeqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__neq"),!1);return this.createCallExpression(n,[t,e])},createWrapperFunction(t){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}},createVariableDeclaration(t,e){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(t),init:e}]}},createAwaitExpression(t){return{type:"AwaitExpression",argument:t}}},Tt=["ta","math","request","array","input","color","ticker","strategy"],it=["hline","plot","fill","label","line","box","linefill","polyline","table","na","alert","time","time_close","dayofmonth","dayofweek","hour","minute","month","second","weekofyear","year"],gy=["request.security","request.security_lower_tf"],xy=["chart.left_visible_bar_time","chart.right_visible_bar_time"],Rn=["plot","hline","fill","strategy.exit"],by=["line.new","line.copy","label.new","label.copy","polyline.new","box.new","box.copy","table.new","linefill.new"],vy=new Set([...Tt,"fill","plot","hline","label","line","size","extend","display","format","location","shape","text","xloc","yloc","linefill","polyline","box","table","map","matrix","chart","alert","barstate","syminfo","timeframe","strategy","log","str"]),On=new Set(["await","debugger","default","delete","extends","finally","function","implements","instanceof","interface","let","new","package","private","protected","public","static","super","throw","typeof","void","with","yield"]),Ea=["open","high","low","close","volume","hl2","hlc3","ohlc4","hlcc4","openTime","closeTime"],en=[...Tt,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","library","alertcondition","alert","error","max_bars_back","fixnan","na","nz","timestamp","str","box","line","label","table","chart","linefill","polyline","map","matrix","log","Type","bool","int","float","string","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","time","time_close","time_tradingday","dayofmonth","hour","minute","month","second","weekofyear","year","order","currency","display","shape","location","size","format","dayofweek","xloc","yloc","text","font","extend","position","barmerge","adjustment","backadjustment","earnings","dividends","splits"],wy=["na","nz","plot","plotchar","color","hline","fill"];function Sy(t){let e=null,i=se;if(t.type==="Program"&&t.body.length>0){const f=t.body[0];if(f.type==="ExpressionStatement"&&(f.expression.type==="ArrowFunctionExpression"||f.expression.type==="FunctionExpression")){const d=f.expression;d.body.type==="BlockStatement"&&(e=d.body.body,d.params.length>0&&d.params[0].type==="Identifier"&&(i=d.params[0].name))}}if(!e)return;const r=new Set,n=new Set,s=f=>{f.type==="Identifier"?r.add(f.name):f.type==="ObjectPattern"?f.properties.forEach(d=>s(d.value)):f.type==="ArrayPattern"&&f.elements.forEach(d=>{d&&s(d)})};ue(t,{},{VariableDeclarator(f,d,m){s(f.id),f.init&&m(f.init,d)},FunctionDeclaration(f,d,m){s(f.id);for(const x of f.params)x&&x.type==="AssignmentPattern"&&x.right&&m(x.right,d);m(f.body,d)},Identifier(f,d,m){n.add(f.name)},MemberExpression(f,d,m){m(f.object,d),f.computed&&m(f.property,d)},Property(f,d,m){f.computed&&m(f.key,d),m(f.value,d)}}),e.forEach(f=>{f.type==="VariableDeclaration"?f.declarations.forEach(d=>s(d.id)):f.type==="FunctionDeclaration"&&s(f.id)});const a=Ea,o=en,l=a.filter(f=>!r.has(f)),c=o.filter(f=>!r.has(f)),u=l.filter(f=>n.has(f)),p=c.filter(f=>n.has(f)),h=[];u.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:u.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),h.length>0&&e.unshift(...h)}function Ey(t){let e=null,i=se;if(t.type==="Program"&&t.body.length>0){const o=t.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const l=o.expression;l.body.type==="BlockStatement"&&(e=l.body.body,l.params.length>0&&l.params[0].type==="Identifier"&&(i=l.params[0].name))}}if(!e)return;const r=new Set(Ea),n=new Set(en),s=new Set(wy),a=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(l=>{if(l.init&&l.init.type==="MemberExpression"&&l.init.object.type==="Identifier"&&l.init.object.name===i&&l.init.property.type==="Identifier"){const c=l.init.property.name;let u=null;if(c==="data"?u=r:c==="pine"?u=n:c==="core"&&(u=s),u&&l.id.type==="ObjectPattern")l.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const h=p.key.name,f=p.value.name;u.has(h)&&h!==f&&(a.set(f,h),p.value.name=h,p.shorthand=!0)}});else if(l.id.type==="Identifier"&&Tt.includes(c)){const p=c,h=l.id.name;p!==h&&(a.set(h,p),l.id.name=p)}}})}),a.size>0&&ue(t,{},{Identifier(o){a.has(o.name)&&(o.name=a.get(o.name))},MemberExpression(o,l,c){c(o.object,l),o.computed&&c(o.property,l)},Property(o,l,c){o.computed&&c(o.key,l),c(o.value,l)}})}function Ny(t){try{const e=Xr(t,{ecmaVersion:"latest",sourceType:"module"});if(e.type==="Program"&&e.body.length===1){const i=e.body[0];if(i.type==="ExpressionStatement"){const r=i.expression;if(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")return{isWrapped:!0,isAsync:r.async||!1,functionNode:r}}if(i.type==="FunctionDeclaration")return{isWrapped:!0,isAsync:i.async||!1,functionNode:i}}return{isWrapped:!1,isAsync:!1}}catch{return{isWrapped:!1,isAsync:!1}}}function Cy(t){return t.async=!0,Qr(t)}function Iy(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=Ny(t);return e&&r?i?t:Cy(r):`async (context) => {
|
|
15
|
+
`?(o=0,l++):o++;this.column=o,this.line=l;return}}const{length:r}=e,{lineEnd:n}=this;r>0&&(this.lineEndSize>0&&(n.length===1?e[r-1]===n:e.endsWith(n))?(this.line+=this.lineEndSize,this.column=0):this.column+=r)}toString(){return this.output}}function Qr(t,e){const i=new uy(e);return i.generator[t.type](t,i),i.output}var hy=Object.defineProperty,py=(t,e,i)=>e in t?hy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,X=(t,e,i)=>py(t,typeof e!="symbol"?e+"":e,i);const fy=new Set(["Infinity","NaN","undefined","null","true","false"]),dy=new Set(["Math","Array","Object","String","Number","Boolean","Date","RegExp","Error","JSON","Promise","Set","Map","WeakSet","WeakMap","Symbol","BigInt","Proxy","Reflect","console","isNaN","isFinite","parseInt","parseFloat","encodeURI","decodeURI","encodeURIComponent","decodeURIComponent"]);class my{constructor(){X(this,"scopes",[]),X(this,"scopeTypes",[]),X(this,"scopeCounts",new Map),X(this,"contextBoundVars",new Set),X(this,"arrayPatternElements",new Set),X(this,"rootParams",new Set),X(this,"localSeriesVars",new Set),X(this,"varKinds",new Map),X(this,"loopVars",new Set),X(this,"loopVarNames",new Map),X(this,"paramIdCounter",0),X(this,"cacheIdCounter",0),X(this,"tempVarCounter",0),X(this,"taCallIdCounter",0),X(this,"userCallIdCounter",0),X(this,"plotCallIdCounter",0),X(this,"alertCallIdCounter",0),X(this,"loopGuardCounter",0),X(this,"hoistingStack",[]),X(this,"suppressHoisting",!1),X(this,"reservedNames",new Set),X(this,"userFunctions",new Set),X(this,"userMethods",new Set),X(this,"regularUserFunctions",new Set),X(this,"udtTypeNames",new Map),X(this,"udtInstances",new Map),X(this,"functionReturnTypes",new Map),X(this,"functionReturnTupleTypes",new Map),X(this,"functionParamUdtTypes",new Map),this.pushScope("glb")}get nextParamIdArg(){return{type:"Identifier",name:`'p${this.paramIdCounter++}'`}}get nextCacheIdArg(){return{type:"Identifier",name:`'cache_${this.cacheIdCounter++}'`}}getNextTACallId(){return{type:"Literal",value:`_ta${this.taCallIdCounter++}`}}getNextUserCallId(){return{type:"Literal",value:`_fn${this.userCallIdCounter++}`}}getNextPlotCallId(){return{type:"Literal",value:`#${this.plotCallIdCounter++}`}}getNextAlertCallId(){return{type:"Literal",value:`alert_${this.alertCallIdCounter++}`}}getNextLoopGuardName(){return`__lg${this.loopGuardCounter++}`}pushScope(e){this.scopes.push(new Map),this.scopeTypes.push(e),this.scopeCounts.set(e,(this.scopeCounts.get(e)||0)+1)}popScope(){this.scopes.pop(),this.scopeTypes.pop()}getCurrentScopeType(){return this.scopeTypes[this.scopeTypes.length-1]}isInsideFunctionScope(){for(let e=this.scopeTypes.length-1;e>=0;e--)if(this.scopeTypes[e]==="fn")return!0;return!1}getCurrentScopeCount(){return this.scopeCounts.get(this.getCurrentScopeType())||1}addLocalSeriesVar(e){this.localSeriesVars.add(e)}removeLocalSeriesVar(e){this.localSeriesVars.delete(e)}isLocalSeriesVar(e){return this.localSeriesVars.has(e)}addUdtTypeName(e,i={}){this.udtTypeNames.set(e,i)}isUdtTypeName(e){return this.udtTypeNames.has(e)}getUdtTypeFields(e){return this.udtTypeNames.get(e)}markVariableAsUdtInstance(e,i){this.udtInstances.set(e,i)}getVariableUdtType(e){return this.udtInstances.get(e)}isUdtInstance(e){return this.udtInstances.has(e)}setFunctionReturnType(e,i){const r=this.functionReturnTypes.get(e);if(r&&r!==i){this.functionReturnTypes.delete(e);return}this.functionReturnTypes.set(e,i)}getFunctionReturnType(e){return this.functionReturnTypes.get(e)}setFunctionReturnTupleType(e,i){const r=this.functionReturnTupleTypes.get(e);if(r&&(r.length!==i.length||r.some((n,s)=>n!==i[s]))){this.functionReturnTupleTypes.delete(e);return}this.functionReturnTupleTypes.set(e,i)}getFunctionReturnTupleType(e){return this.functionReturnTupleTypes.get(e)}setFunctionParamUdtTypes(e,i){this.functionParamUdtTypes.set(e,i)}getFunctionParamUdtTypes(e){return this.functionParamUdtTypes.get(e)}unmarkVariableAsUdtInstance(e){this.udtInstances.delete(e)}addContextBoundVar(e,i=!1){this.contextBoundVars.add(e),i&&this.rootParams.add(e)}removeContextBoundVar(e){this.contextBoundVars.has(e)&&(this.contextBoundVars.delete(e),this.rootParams.has(e)&&this.rootParams.delete(e))}addArrayPatternElement(e){this.arrayPatternElements.add(e)}isContextBound(e){return fy.has(e)||dy.has(e)?!1:this.contextBoundVars.has(e)}isArrayPatternElement(e){return this.arrayPatternElements.has(e)}isRootParam(e){return this.rootParams.has(e)}addLoopVariable(e,i){this.loopVars.add(e),this.loopVarNames.set(e,i)}removeLoopVariable(e){this.loopVars.delete(e),this.loopVarNames.delete(e)}getLoopVariableName(e){return this.loopVarNames.get(e)}isLoopVariable(e){return this.loopVars.has(e)}addReservedName(e){this.reservedNames.add(e)}addUserFunction(e){this.userFunctions.add(e)}isUserFunction(e){return this.userFunctions.has(e)}addUserMethod(e){this.userMethods.add(e)}isUserMethod(e){return this.userMethods.has(e)}addRegularUserFunction(e){this.regularUserFunctions.add(e)}isRegularUserFunction(e){return this.regularUserFunctions.has(e)}addVariable(e,i){if(this.isContextBound(e))return e;const r=this.scopes[this.scopes.length-1],n=this.scopeTypes[this.scopeTypes.length-1],s=this.scopeCounts.get(n)||1,a=`${n}${s}_${e}`;return r.set(e,a),this.varKinds.set(a,i),a}getVariable(e){if(this.loopVars.has(e)){const i=this.loopVarNames.get(e);if(i)return[i,"let"]}if(this.isContextBound(e))return[e,"let"];for(let i=this.scopes.length-1;i>=0;i--){const r=this.scopes[i];if(r.has(e)){const n=r.get(e),s=this.varKinds.get(n)||"let";return[n,s]}}return[e,"let"]}isVariableInFunctionScope(e){for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e)){for(let r=0;r<=i;r++)if(this.scopeTypes[r]==="fn")return!0;return!1}return!1}generateTempVar(){return`temp_${++this.tempVarCounter}`}enterHoistingScope(){this.hoistingStack.push([])}exitHoistingScope(){return this.hoistingStack.pop()||[]}addHoistedStatement(e){this.hoistingStack.length>0&&!this.suppressHoisting&&this.hoistingStack[this.hoistingStack.length-1].push(e)}addOuterHoistedStatement(e){if(this.hoistingStack.length>0&&!this.suppressHoisting){const i=Math.min(1,this.hoistingStack.length-1);this.hoistingStack[i].push(e)}}getCurrentHoistingScope(){return this.hoistingStack.length===0?null:this.hoistingStack[this.hoistingStack.length-1]}setSuppressHoisting(e){this.suppressHoisting=e}shouldSuppressHoisting(){return this.suppressHoisting}hasVariableInScope(e){if(this.reservedNames.has(e))return!0;for(let i=this.scopes.length-1;i>=0;i--)if(this.scopes[i].has(e))return!0;return!!(this.contextBoundVars.has(e)||this.loopVars.has(e)||this.localSeriesVars.has(e))}generateParamId(){let e=`p${this.paramIdCounter++}`;for(;this.hasVariableInScope(e);)e=`p${this.paramIdCounter++}`;const i=this.scopes[this.scopes.length-1];return i&&i.set(e,e),e}}function He(t,e,i,r,n){i||(i=I),(function s(a,o,l){var c=l||a.type;Sa(i,c,a,o,s),e[c]&&e[c](a,o)})(t,r,n)}function yy(t,e,i,r,n){var s=[];i||(i=I),(function a(o,l,c){var u=c||o.type,p=o!==s[s.length-1];p&&s.push(o),Sa(i,u,o,l,a),e[u]&&e[u](o,l||s,s),p&&s.pop()})(t,r,n)}function ue(t,e,i,r,n){var s=i?_y(i,r||void 0):r;(function a(o,l,c){s[c||o.type](o,l,a)})(t,e,n)}function _y(t,e){var i=Object.create(e||I);for(var r in t)i[r]=t[r];return i}function Jr(t,e,i){i(t,e)}function jt(t,e,i){}function Sa(t,e,i,r,n){if(t[e]==null)throw new Error("No walker function defined for node type "+e);t[e](i,r,n)}var I={};I.Program=I.BlockStatement=I.StaticBlock=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var s=n[r];i(s,e,"Statement")}};I.Statement=Jr;I.EmptyStatement=jt;I.ExpressionStatement=I.ParenthesizedExpression=I.ChainExpression=function(t,e,i){return i(t.expression,e,"Expression")};I.IfStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Statement"),t.alternate&&i(t.alternate,e,"Statement")};I.LabeledStatement=function(t,e,i){return i(t.body,e,"Statement")};I.BreakStatement=I.ContinueStatement=jt;I.WithStatement=function(t,e,i){i(t.object,e,"Expression"),i(t.body,e,"Statement")};I.SwitchStatement=function(t,e,i){i(t.discriminant,e,"Expression");for(var r=0,n=t.cases;r<n.length;r+=1){var s=n[r];i(s,e)}};I.SwitchCase=function(t,e,i){t.test&&i(t.test,e,"Expression");for(var r=0,n=t.consequent;r<n.length;r+=1){var s=n[r];i(s,e,"Statement")}};I.ReturnStatement=I.YieldExpression=I.AwaitExpression=function(t,e,i){t.argument&&i(t.argument,e,"Expression")};I.ThrowStatement=I.SpreadElement=function(t,e,i){return i(t.argument,e,"Expression")};I.TryStatement=function(t,e,i){i(t.block,e,"Statement"),t.handler&&i(t.handler,e),t.finalizer&&i(t.finalizer,e,"Statement")};I.CatchClause=function(t,e,i){t.param&&i(t.param,e,"Pattern"),i(t.body,e,"Statement")};I.WhileStatement=I.DoWhileStatement=function(t,e,i){i(t.test,e,"Expression"),i(t.body,e,"Statement")};I.ForStatement=function(t,e,i){t.init&&i(t.init,e,"ForInit"),t.test&&i(t.test,e,"Expression"),t.update&&i(t.update,e,"Expression"),i(t.body,e,"Statement")};I.ForInStatement=I.ForOfStatement=function(t,e,i){i(t.left,e,"ForInit"),i(t.right,e,"Expression"),i(t.body,e,"Statement")};I.ForInit=function(t,e,i){t.type==="VariableDeclaration"?i(t,e):i(t,e,"Expression")};I.DebuggerStatement=jt;I.FunctionDeclaration=function(t,e,i){return i(t,e,"Function")};I.VariableDeclaration=function(t,e,i){for(var r=0,n=t.declarations;r<n.length;r+=1){var s=n[r];i(s,e)}};I.VariableDeclarator=function(t,e,i){i(t.id,e,"Pattern"),t.init&&i(t.init,e,"Expression")};I.Function=function(t,e,i){t.id&&i(t.id,e,"Pattern");for(var r=0,n=t.params;r<n.length;r+=1){var s=n[r];i(s,e,"Pattern")}i(t.body,e,t.expression?"Expression":"Statement")};I.Pattern=function(t,e,i){t.type==="Identifier"?i(t,e,"VariablePattern"):t.type==="MemberExpression"?i(t,e,"MemberPattern"):i(t,e)};I.VariablePattern=jt;I.MemberPattern=Jr;I.RestElement=function(t,e,i){return i(t.argument,e,"Pattern")};I.ArrayPattern=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var s=n[r];s&&i(s,e,"Pattern")}};I.ObjectPattern=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];s.type==="Property"?(s.computed&&i(s.key,e,"Expression"),i(s.value,e,"Pattern")):s.type==="RestElement"&&i(s.argument,e,"Pattern")}};I.Expression=Jr;I.ThisExpression=I.Super=I.MetaProperty=jt;I.ArrayExpression=function(t,e,i){for(var r=0,n=t.elements;r<n.length;r+=1){var s=n[r];s&&i(s,e,"Expression")}};I.ObjectExpression=function(t,e,i){for(var r=0,n=t.properties;r<n.length;r+=1){var s=n[r];i(s,e)}};I.FunctionExpression=I.ArrowFunctionExpression=I.FunctionDeclaration;I.SequenceExpression=function(t,e,i){for(var r=0,n=t.expressions;r<n.length;r+=1){var s=n[r];i(s,e,"Expression")}};I.TemplateLiteral=function(t,e,i){for(var r=0,n=t.quasis;r<n.length;r+=1){var s=n[r];i(s,e)}for(var a=0,o=t.expressions;a<o.length;a+=1){var l=o[a];i(l,e,"Expression")}};I.TemplateElement=jt;I.UnaryExpression=I.UpdateExpression=function(t,e,i){i(t.argument,e,"Expression")};I.BinaryExpression=I.LogicalExpression=function(t,e,i){i(t.left,e,"Expression"),i(t.right,e,"Expression")};I.AssignmentExpression=I.AssignmentPattern=function(t,e,i){i(t.left,e,"Pattern"),i(t.right,e,"Expression")};I.ConditionalExpression=function(t,e,i){i(t.test,e,"Expression"),i(t.consequent,e,"Expression"),i(t.alternate,e,"Expression")};I.NewExpression=I.CallExpression=function(t,e,i){if(i(t.callee,e,"Expression"),t.arguments)for(var r=0,n=t.arguments;r<n.length;r+=1){var s=n[r];i(s,e,"Expression")}};I.MemberExpression=function(t,e,i){i(t.object,e,"Expression"),t.computed&&i(t.property,e,"Expression")};I.ExportNamedDeclaration=I.ExportDefaultDeclaration=function(t,e,i){if(t.declaration&&i(t.declaration,e,t.type==="ExportNamedDeclaration"||t.declaration.id?"Statement":"Expression"),t.source&&i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var s=n[r];i(s,e)}};I.ExportAllDeclaration=function(t,e,i){if(t.exported&&i(t.exported,e),i(t.source,e,"Expression"),t.attributes)for(var r=0,n=t.attributes;r<n.length;r+=1){var s=n[r];i(s,e)}};I.ImportAttribute=function(t,e,i){i(t.value,e,"Expression")};I.ImportDeclaration=function(t,e,i){for(var r=0,n=t.specifiers;r<n.length;r+=1){var s=n[r];i(s,e)}if(i(t.source,e,"Expression"),t.attributes)for(var a=0,o=t.attributes;a<o.length;a+=1){var l=o[a];i(l,e)}};I.ImportExpression=function(t,e,i){i(t.source,e,"Expression"),t.options&&i(t.options,e,"Expression")};I.ImportSpecifier=I.ImportDefaultSpecifier=I.ImportNamespaceSpecifier=I.Identifier=I.PrivateIdentifier=I.Literal=jt;I.TaggedTemplateExpression=function(t,e,i){i(t.tag,e,"Expression"),i(t.quasi,e,"Expression")};I.ClassDeclaration=I.ClassExpression=function(t,e,i){return i(t,e,"Class")};I.Class=function(t,e,i){t.id&&i(t.id,e,"Pattern"),t.superClass&&i(t.superClass,e,"Expression"),i(t.body,e)};I.ClassBody=function(t,e,i){for(var r=0,n=t.body;r<n.length;r+=1){var s=n[r];i(s,e)}};I.MethodDefinition=I.PropertyDefinition=I.Property=function(t,e,i){t.computed&&i(t.key,e,"Expression"),t.value&&i(t.value,e,"Expression")};const se="$",E={createIdentifier(t){return{type:"Identifier",name:t}},createLiteral(t){return{type:"Literal",value:t}},createMemberExpression(t,e,i=!1){return{type:"MemberExpression",object:t,property:e,computed:i}},createContextIdentifier(){return this.createIdentifier("$")},createLocalContextIdentifier(){return this.createIdentifier("$$")},createContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createLocalContextVariableReference(t,e){const i=this.createLocalContextIdentifier(),r=this.createIdentifier(t),n=this.createIdentifier(e);return this.createMemberExpression(this.createMemberExpression(i,r,!1),n,!1)},createDynamicContextVariableReference(t,e){const i=this.createContextIdentifier(),r=this.createIdentifier(t);return this.createMemberExpression(this.createMemberExpression(i,r,!1),e,!0)},createContextVariableAccess0(t,e){const i=this.createContextVariableReference(t,e);return this.createGetCall(i,0)},createDynamicContextVariableAccess0(t,e){const i=this.createDynamicContextVariableReference(t,e);return this.createGetCall(i,0)},createArrayAccess(t,e){const i=typeof e=="number"?this.createLiteral(e):e;return this.createMemberExpression(t,i,!0)},createCallExpression(t,e){return{type:"CallExpression",callee:t,arguments:e}},createAssignmentExpression(t,e,i="="){return{type:"AssignmentExpression",operator:i,left:t,right:e}},createExpressionStatement(t){return{type:"ExpressionStatement",expression:t}},createInitCall(t,e,i){const r=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("init"),!1),n=[t,e];return i&&n.push(i),this.createCallExpression(r,n)},createInitVarCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("initVar"),!1),r=[t,e];return this.createCallExpression(i,r)},createGetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("get"),!1),r=typeof e=="number"?this.createLiteral(e):e;return this.createCallExpression(i,[t,r])},createSetCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("set"),!1);return this.createCallExpression(i,[t,e])},createMathEqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__eq"),!1);return this.createCallExpression(n,[t,e])},createMathNeqCall(t,e){const i=this.createMemberExpression(this.createContextIdentifier(),this.createIdentifier("pine"),!1),r=this.createMemberExpression(i,this.createIdentifier("math"),!1),n=this.createMemberExpression(r,this.createIdentifier("__neq"),!1);return this.createCallExpression(n,[t,e])},createWrapperFunction(t){return{type:"FunctionDeclaration",id:null,params:[this.createIdentifier("context")],body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:t}]}}},createVariableDeclaration(t,e){return{type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:this.createIdentifier(t),init:e}]}},createAwaitExpression(t){return{type:"AwaitExpression",argument:t}}},Tt=["ta","math","request","array","input","color","ticker","strategy"],it=["hline","plot","fill","label","line","box","linefill","polyline","table","na","alert","time","time_close","dayofmonth","dayofweek","hour","minute","month","second","weekofyear","year"],gy=["request.security","request.security_lower_tf"],xy=["chart.left_visible_bar_time","chart.right_visible_bar_time"],Rn=["plot","hline","fill","strategy.exit"],by=["line.new","line.copy","label.new","label.copy","polyline.new","box.new","box.copy","table.new","linefill.new"],vy=new Set([...Tt,"fill","plot","hline","label","line","size","extend","display","format","location","shape","text","xloc","yloc","linefill","polyline","box","table","map","matrix","chart","alert","barstate","syminfo","timeframe","strategy","log","str"]),On=new Set(["await","debugger","default","delete","extends","finally","function","implements","instanceof","interface","let","new","package","private","protected","public","static","super","throw","typeof","void","with","yield"]),Ea=["open","high","low","close","volume","hl2","hlc3","ohlc4","hlcc4","openTime","closeTime"],en=[...Tt,"plotchar","plotshape","plotarrow","plotbar","plotcandle","plot","bgcolor","barcolor","hline","fill","indicator","library","alertcondition","alert","error","max_bars_back","fixnan","na","nz","timestamp","str","box","line","label","table","chart","linefill","polyline","map","matrix","log","Type","bool","int","float","string","timeframe","syminfo","barstate","bar_index","last_bar_index","last_bar_time","inputs","time","time_close","time_tradingday","dayofmonth","hour","minute","month","second","weekofyear","year","order","currency","display","shape","location","size","format","dayofweek","xloc","yloc","text","font","extend","position","barmerge","adjustment","backadjustment","earnings","dividends","splits"],wy=["na","nz","plot","plotchar","color","hline","fill"];function Sy(t){let e=null,i=se;if(t.type==="Program"&&t.body.length>0){const f=t.body[0];if(f.type==="ExpressionStatement"&&(f.expression.type==="ArrowFunctionExpression"||f.expression.type==="FunctionExpression")){const d=f.expression;d.body.type==="BlockStatement"&&(e=d.body.body,d.params.length>0&&d.params[0].type==="Identifier"&&(i=d.params[0].name))}}if(!e)return;const r=new Set,n=new Set,s=f=>{f.type==="Identifier"?r.add(f.name):f.type==="ObjectPattern"?f.properties.forEach(d=>s(d.value)):f.type==="ArrayPattern"&&f.elements.forEach(d=>{d&&s(d)})};ue(t,{},{VariableDeclarator(f,d,m){s(f.id),f.init&&m(f.init,d)},FunctionDeclaration(f,d,m){s(f.id);for(const x of f.params)x&&x.type==="AssignmentPattern"&&x.right&&m(x.right,d);m(f.body,d)},Identifier(f,d,m){n.add(f.name)},MemberExpression(f,d,m){m(f.object,d),f.computed&&m(f.property,d)},Property(f,d,m){f.computed&&m(f.key,d),m(f.value,d)}}),e.forEach(f=>{f.type==="VariableDeclaration"?f.declarations.forEach(d=>s(d.id)):f.type==="FunctionDeclaration"&&s(f.id)});const a=Ea,o=en,l=a.filter(f=>!r.has(f)),c=o.filter(f=>!r.has(f)),u=l.filter(f=>n.has(f)),p=c.filter(f=>n.has(f)),h=[];u.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:u.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"data"},computed:!1}}]}),p.length>0&&h.push({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"ObjectPattern",properties:p.map(f=>({type:"Property",key:{type:"Identifier",name:f},value:{type:"Identifier",name:f},kind:"init",shorthand:!0}))},init:{type:"MemberExpression",object:{type:"Identifier",name:i},property:{type:"Identifier",name:"pine"},computed:!1}}]}),h.length>0&&e.unshift(...h)}function Ey(t){let e=null,i=se;if(t.type==="Program"&&t.body.length>0){const o=t.body[0];if(o.type==="ExpressionStatement"&&(o.expression.type==="ArrowFunctionExpression"||o.expression.type==="FunctionExpression")){const l=o.expression;l.body.type==="BlockStatement"&&(e=l.body.body,l.params.length>0&&l.params[0].type==="Identifier"&&(i=l.params[0].name))}}if(!e)return;const r=new Set(Ea),n=new Set(en),s=new Set(wy),a=new Map;e.forEach(o=>{o.type==="VariableDeclaration"&&o.declarations.forEach(l=>{if(l.init&&l.init.type==="MemberExpression"&&l.init.object.type==="Identifier"&&l.init.object.name===i&&l.init.property.type==="Identifier"){const c=l.init.property.name;let u=null;if(c==="data"?u=r:c==="pine"?u=n:c==="core"&&(u=s),u&&l.id.type==="ObjectPattern")l.id.properties.forEach(p=>{if(p.type==="Property"&&p.key.type==="Identifier"&&p.value.type==="Identifier"){const h=p.key.name,f=p.value.name;u.has(h)&&h!==f&&(a.set(f,h),p.value.name=h,p.shorthand=!0)}});else if(l.id.type==="Identifier"&&Tt.includes(c)){const p=c,h=l.id.name;p!==h&&(a.set(h,p),l.id.name=p)}}})}),a.size>0&&ue(t,{},{Identifier(o){a.has(o.name)&&(o.name=a.get(o.name))},MemberExpression(o,l,c){c(o.object,l),o.computed&&c(o.property,l)},Property(o,l,c){o.computed&&c(o.key,l),c(o.value,l)}})}function Ny(t){try{const e=Xr(t,{ecmaVersion:"latest",sourceType:"module"});if(e.type==="Program"&&e.body.length===1){const i=e.body[0];if(i.type==="ExpressionStatement"){const r=i.expression;if(r.type==="ArrowFunctionExpression"||r.type==="FunctionExpression")return{isWrapped:!0,isAsync:r.async||!1,functionNode:r}}if(i.type==="FunctionDeclaration")return{isWrapped:!0,isAsync:i.async||!1,functionNode:i}}return{isWrapped:!1,isAsync:!1}}catch{return{isWrapped:!1,isAsync:!1}}}function Cy(t){return t.async=!0,Qr(t)}function Iy(t){t=t.trim();const{isWrapped:e,isAsync:i,functionNode:r}=Ny(t);return e&&r?i?t:Cy(r):`async (context) => {
|
|
16
16
|
${t}
|
|
17
|
-
}`}function ky(t){ue(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(n=>{if(n.init&&n.init.type==="ArrowFunctionExpression"&&n.init.start!==0){const s={type:"FunctionDeclaration",id:n.id,params:n.init.params,body:n.init.body.type==="BlockStatement"?n.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:n.init.body}]},async:n.init.async,generator:!1};Object.assign(e,s)}}),e.body&&e.body.body&&e.body.body.forEach(n=>r(n,i))}})}function Ty(t,e){He(t,{VariableDeclaration(r){for(const n of r.declarations)if(!(n.id?.type!=="Identifier"||!n.init)&&n.init.type==="CallExpression"&&n.init.callee?.type==="Identifier"&&n.init.callee.name==="Type"&&n.init.arguments?.length===1&&n.init.arguments[0]?.type==="ObjectExpression"){const s={};for(const a of n.init.arguments[0].properties)a.type!=="Property"||a.key?.type!=="Identifier"||(a.value?.type==="ArrayExpression"&&a.value.elements?.[0]?.type==="Literal"?s[a.key.name]=String(a.value.elements[0].value):a.value?.type==="Literal"&&(s[a.key.name]=String(a.value.value)));e.addUdtTypeName(n.id.name,s)}}});let i=!0;for(;i;)i=!1,He(t,{FunctionDeclaration(r){if(!r.id?.name)return;const n=r.id.name;if(e.getFunctionReturnType(n)||e.getFunctionReturnTupleType(n))return;const s=Ay(r.body);if(s.length===0)return;if(s.every(l=>l.type==="ArrayExpression")){const l=s[0].elements.length;if(l>0&&s.every(c=>c.elements.length===l)){const c=[];let u=!0;for(let p=0;p<l;p++){const h=s.map(d=>yi(d.elements[p],e)),f=h[0];if(!h.every(d=>d===f)){u=!1;break}c.push(f)}if(u&&c.some(p=>!!p)){e.setFunctionReturnTupleType(n,c),i=!0;return}}}const a=s.map(l=>yi(l,e)),o=a[0];!o||!a.every(l=>l===o)||(e.setFunctionReturnType(n,o),i=!0)}});He(t,{VariableDeclaration(r){for(const n of r.declarations)if(n.init){if(n.id?.type==="Identifier"){const s=yi(n.init,e);s&&e.markVariableAsUdtInstance(n.id.name,s);continue}if(n.id?.type==="ArrayPattern"&&n.init.type==="CallExpression"&&n.init.callee?.type==="Identifier"){const s=e.getFunctionReturnTupleType(n.init.callee.name);if(!s)continue;n.id.elements?.forEach((a,o)=>{if(!a||a.type!=="Identifier")return;const l=s[o];l&&e.markVariableAsUdtInstance(a.name,l)})}}},ExpressionStatement(r){const n=r.expression;if(n?.type==="Literal"&&typeof n.value=="string"&&n.value.startsWith("__pineUdtVar:")){const s=n.value.match(/^__pineUdtVar:([A-Za-z_$][\w$]*)=([A-Za-z_$][\w$]*)$/);if(s){const[,a,o]=s;e.isUdtTypeName(o)&&e.markVariableAsUdtInstance(a,o)}}}}),He(t,{ExpressionStatement(r){const n=r.expression;if(!n||n.type!=="AssignmentExpression"||n.operator!=="=")return;const s=n.left;if(s?.type!=="MemberExpression"||s.computed||s.property?.type!=="Identifier"||s.property.name!=="__pineParamTypes__"||s.object?.type!=="Identifier"||n.right?.type!=="ObjectExpression")return;const a=s.object.name,o=a.startsWith("$M_")?a.slice(3):a,l={};for(const c of n.right.properties){if(c.type!=="Property")continue;let u;if(c.key?.type==="Identifier"?u=c.key.name:c.key?.type==="Literal"&&typeof c.key.value=="string"&&(u=c.key.value),!u||c.value?.type!=="Literal"||typeof c.value.value!="string")continue;const p=c.value.value.split(/\s+/).pop();e.isUdtTypeName(p)&&(l[u]=p)}Object.keys(l).length>0&&e.setFunctionParamUdtTypes(o,l)}})}function Ay(t){const e=[];if(!t)return e;function i(r){if(!(!r||typeof r!="object")&&!(r.type==="FunctionDeclaration"||r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression")){if(r.type==="ReturnStatement"&&r.argument){e.push(r.argument);return}for(const n of Object.keys(r)){if(n==="type")continue;const s=r[n];Array.isArray(s)?s.forEach(i):s&&typeof s=="object"&&s.type&&i(s)}}}return i(t),e}function yi(t,e){if(t){if(t.type==="CallExpression"&&t.callee?.type==="MemberExpression"&&!t.callee.computed&&t.callee.object?.type==="Identifier"&&t.callee.property?.type==="Identifier"&&(t.callee.property.name==="new"||t.callee.property.name==="copy")&&e.isUdtTypeName(t.callee.object.name))return t.callee.object.name;if(t.type==="CallExpression"&&t.callee?.type==="Identifier"){const i=e.getFunctionReturnType(t.callee.name);if(i)return i}if(t.type==="ConditionalExpression"){const i=yi(t.consequent,e),r=yi(t.alternate,e);if(i&&i===r)return i}}}function Py(t,e){He(t,{VariableDeclaration(i){i.declarations.forEach(r=>{const n=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===se||r.init.object.name==="context2"),s=r.init&&r.init.type==="MemberExpression"&&r.init.object?.object&&(r.init.object.object.name==="context"||r.init.object.object.name===se||r.init.object.object.name==="context2");(n||s)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(a=>{a.key.name&&e.addContextBoundVar(a.key.name)}))})}})}function Dy(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function My(t,e){let i;return yy(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name),r.id.name.startsWith("$M_")||e.addRegularUserFunction(r.id.name))},ExpressionStatement(r){const n=r.expression;if(n&&n.type==="AssignmentExpression"&&n.operator==="="&&n.left?.type==="MemberExpression"&&n.left.property?.name==="__pineMethod__"&&n.left.object?.type==="Identifier"&&n.right?.value===!0){const s=n.left.object.name,a=s.startsWith("$M_")?s.slice(3):s;e.addUserMethod(a),e.addUserFunction(a)}},ArrowFunctionExpression(r){const n=r.start===0;n&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=se),Dy(r,e,n)},VariableDeclaration(r,n){const s=n.length>1?n[n.length-2]:null,a=s&&(s.type==="ForOfStatement"||s.type==="ForInStatement")&&s.left===r;r.declarations.forEach(o=>{if(o.id.type==="Identifier")e.addReservedName(o.id.name);else if(o.id.type==="ObjectPattern")o.id.properties.forEach(l=>{l.key&&l.key.type==="Identifier"&&e.addReservedName(l.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(h=>{h&&h.type==="Identifier"&&e.addReservedName(h.name)}),a)return;const l=e.generateTempVar(),c={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:l},init:o.init}]},u=c.declarations[0].init;u&&u.type==="CallExpression"&&(u.callee.type==="ArrowFunctionExpression"||u.callee.type==="FunctionExpression")&&He(u.callee.body,{ReturnStatement(h){h.argument&&h.argument.type==="ArrayExpression"&&(h.argument={type:"ArrayExpression",elements:[h.argument]})}}),o.id.elements?.forEach(h=>{h.type==="Identifier"&&e.addArrayPatternElement(h.name)});const p=o.id.elements.map((h,f)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:h,init:{type:"MemberExpression",object:{type:"Identifier",name:l},property:{type:"Literal",value:f},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[c,...p]})}})},ForStatement(r){}}),i}const Mr={type:"Identifier",name:"undefined"};function Vi(t,e){const i={type:"Identifier",name:`'${e}'`};if(!t.isInsideFunctionScope())return i;const[r]=t.getVariable("$$");return r?{type:"BinaryExpression",operator:"+",left:S.createMemberExpression(S.createLocalContextIdentifier(),S.createIdentifier("id")),right:i}:i}function he(t,e){const[i,r]=e.getVariable(t);if((i.match(/^fn\d+_/)||e.isVariableInFunctionScope(t))&&t!=="$$"){const[n]=e.getVariable("$$");if(n)return S.createLocalContextVariableReference(r,i)}return S.createContextVariableReference(r,i)}function Rr(t,e){const i=he(t,e);return S.createGetCall(i,0)}function Lt(t,e){if(t.computed&&t.property.type==="Identifier"){if(e.isLoopVariable(t.property.name)){if(t.object.type==="Identifier"&&!e.isLoopVariable(t.object.name)){if(e.isLocalSeriesVar(t.object.name)){const i=S.createIdentifier(t.object.name);i._skipTransformation=!0;const r=S.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=he(t.object.name,e),r=S.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}if(!e.isContextBound(t.property.name))if(e.isLocalSeriesVar(t.property.name)){const i=S.createIdentifier(t.property.name);i._skipTransformation=!0,t.property=S.createGetCall(i,0)}else t.property=he(t.property.name,e),t.property=S.createGetCall(t.property,0)}if(t.computed&&t.object.type==="Identifier"){if(e.isLoopVariable(t.object.name))return;if(e.isLocalSeriesVar(t.object.name)){const i=S.createIdentifier(t.object.name);i._skipTransformation=!0;const r=S.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=he(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(Lt(i,e),i._indexTransformed=!0)}}t.computed&&t.property.type!=="Identifier"&&t.property.type!=="MemberExpression"&&!t._indexTransformed&&(t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression")&&(t.property=ct(t.property,e))}function ke(t,e){const i=S.createGetCall(S.createIdentifier(t.name),0);t.start!==void 0&&(i.start=t.start),t.end!==void 0&&(i.end=t.end),i._indexTransformed=!0,Object.assign(t,i)}function le(t,e){if(!t._skipTransformation&&t.name!==se){if(it.includes(t.name)&&e.isContextBound(t.name)){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,f=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&!t.parent.computed;if(!h&&!f){const d={type:"MemberExpression",object:{type:"Identifier",name:t.name},property:{type:"Identifier",name:"__value"},computed:!1},m=S.createGetCall(d,0);Object.assign(t,m),delete t.name;return}}if(t.name==="Math"||t.name==="NaN"||t.name==="undefined"||t.name==="Infinity"||t.name==="null"||t.name.startsWith("'")&&t.name.endsWith("'")||t.name.startsWith('"')&&t.name.endsWith('"')||t.name.startsWith("`")&&t.name.endsWith("`")||e.isLoopVariable(t.name))return;let i=!1;if(t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t)){const h=t.parent.callee;if(h.type==="MemberExpression"&&h.object&&h.object.name===se&&["get","set","init","param","call"].includes(h.property.name)){const f=t.parent.arguments.indexOf(t);h.property.name==="call"?f>=2&&(i=!0):f===0&&(i=!0)}else{const f=h.type==="MemberExpression"&&h.object&&h.object.type==="Identifier"&&Tt.includes(h.object.name);h.type==="MemberExpression"&&!f?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),n=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.property.name==="param";t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left;const s=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,a=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.object===t,o=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.property===t&&t.parent.parent&&t.parent.parent.type==="CallExpression"&&t.parent.parent.callee&&t.parent.parent.callee.type==="MemberExpression"&&e.isContextBound(t.parent.parent.callee.object.name);if(r||n||i||o||s){if(s||t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.object&&t.parent.callee.object.name===se&&t.parent.callee.property.name==="call"&&t.parent.arguments[0]===t||e.isLocalSeriesVar(t.name)||e.isContextBound(t.name)&&!e.isRootParam(t.name))return;const h=he(t.name,e);Object.assign(t,h);return}const l=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(l){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),f=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,d=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!h&&!f&&!d)return}if(e.isLocalSeriesVar(t.name)){if(!a){const h=S.createIdentifier(t.name),f=S.createGetCall(h,0);Object.assign(t,f)}return}const[c,u]=e.getVariable(t.name);let p;if(l)p=S.createIdentifier(t.name);else{if(c===t.name&&!e.isContextBound(t.name))return;p=he(t.name,e)}if(a)Object.assign(t,p);else{const h=S.createGetCall(p,0);Object.assign(t,h)}}}function ye(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&Tt.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const l=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,c=t.parent&&(t.parent.type==="VariableDeclarator"&&(t.parent.id.type==="ArrayPattern"||t.parent.id.type==="ObjectPattern")||t.parent.type==="AssignmentExpression"&&(t.parent.left.type==="ArrayPattern"||t.parent.left.type==="ObjectPattern")||t.parent.type==="Property");if(!l&&!c){const u={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(u.start=t.start),t.end!==void 0&&(u.end=t.end),Object.assign(t,u);return}}if(!t.computed&&t.object&&t.object.type==="Identifier"&&i.isLocalSeriesVar(t.object.name)){const l=S.createIdentifier(t.object.name);l._skipTransformation=!0,t.object=S.createGetCall(l,0);return}const r=i.getCurrentScopeType()=="if",n=i.getCurrentScopeType()=="els",s=i.getCurrentScopeType()=="for";if(!r&&!n&&!s&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(Lt(t,i),t._indexTransformed=!0);const a=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===se||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(a||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;t.object.type==="Identifier"&&it.includes(t.object.name)&&i.isContextBound(t.object.name)&&(t.object={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1});const l=S.createGetCall(t.object,t.property);t.start&&(l.start=t.start),t.end&&(l.end=t.end),Object.assign(t,l),delete t.object,delete t.property,delete t.computed;return}if(t.computed&&t.object&&t.object.type==="MemberExpression"){let l=t.object;for(;l.object&&l.object.type==="MemberExpression";)l=l.object;if(l.object&&l.object.type==="Identifier"&&i.isUdtInstance(l.object.name)){const c=l.object.name,u=i.isLocalSeriesVar(c)?(()=>{const h=S.createIdentifier(c);return h._skipTransformation=!0,h})():he(c,i);l.object=S.createGetCall(u,t.property);const p=t.object;Object.assign(t,p),delete t.computed;return}}}function _i(t,e){if(t.type==="Identifier"){if(it.includes(t.name)&&e.isContextBound(t.name)){const s=t.name;return Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:s},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name,t}if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[s,a]=e.getVariable(t.name);return S.createContextVariableReference(a,s)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),n=i!==t.name;return e.isLocalSeriesVar(t.name)&&!n?t:n?he(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:he(t.name,e)}return t}function ct(t,e,i=""){switch(t.type){case"BinaryExpression":return ji(t,e,i);case"LogicalExpression":return Li(t,e,i);case"MemberExpression":{const r=!t.computed&&t.object.type==="Identifier"&&it.includes(t.object.name)&&e.isContextBound(t.object.name);if(t.computed&&t.object.type==="Identifier"&&it.includes(t.object.name)&&e.isContextBound(t.object.name)){const a={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1};return S.createGetCall(a,t.property)}const n=t.object.type==="Identifier"&&!r?_i(t.object,e):t.object;let s=n;if(!t.computed&&t.object.type==="Identifier"&&!r){const[a]=e.getVariable(t.object.name);a!==t.object.name&&!e.isLoopVariable(t.object.name)&&(s=S.createGetCall(n,0))}return{type:"MemberExpression",object:s,property:t.property,computed:t.computed}}case"Identifier":{if(e.isLoopVariable(t.name)||t.parent&&t.parent.type==="MemberExpression"&&t.parent.property===t)return t;const r=_i(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:S.createGetCall(r,0)}case"UnaryExpression":return Bi(t,e,i);case"ConditionalExpression":{const r=ct(t.test,e,i),n=ct(t.consequent,e,i),s=ct(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:n,alternate:s,start:t.start,end:t.end}}}return t}function ji(t,e,i){const r=ct(t.left,e,i),n=ct(t.right,e,i),s={type:"BinaryExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return ue(s,e,{CallExpression(a,o){a._transformed||ce(a,o)},MemberExpression(a){ye(a,"",e)}}),s}function Li(t,e,i){const r=ct(t.left,e,i),n=ct(t.right,e,i),s={type:"LogicalExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return ue(s,e,{CallExpression(a,o){a._transformed||ce(a,o)}}),s}function _r(t,e,i){ue(t,{parent:t,inNamespaceCall:!1},{Identifier(a,o,l){if(a.name=="NaN")return;if(it.includes(a.name)&&e.isContextBound(a.name)){if(o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===a&&!o.parent.computed)return;const u={type:"MemberExpression",object:{type:"Identifier",name:a.name},property:{type:"Identifier",name:"__value"},computed:!1},p=S.createGetCall(u,0);Object.assign(a,p),delete a.name;return}a.parent=o.parent,le(a,e);const c=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||c)&&(a.type==="MemberExpression"?Lt(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===se&&a.parent.callee.property.name==="get"||ke(a)))},MemberExpression(a,o,l){ye(a,"",e),a.object&&l(a.object,{parent:a,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(a,o,l){const c={...o,parent:a};a.test&&l(a.test,c),a.consequent&&l(a.consequent,c),a.alternate&&l(a.alternate,c)},BinaryExpression(a,o,l){const c={...o,parent:a};l(a.left,c),l(a.right,c)},LogicalExpression(a,o,l){const c={...o,parent:a};l(a.left,c),l(a.right,c)},UnaryExpression(a,o,l){const c={...o,parent:a};l(a.argument,c)},CallExpression(a,o,l){const c=a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&a.callee.object.type==="Identifier"&&e.isContextBound(a.callee.object.name);ce(a,e),a.arguments.forEach(u=>l(u,{parent:a,inNamespaceCall:c||o.inNamespaceCall}))}});const r=S.createMemberExpression(S.createIdentifier(i),S.createIdentifier("param")),n=e.generateParamId(),s={type:"CallExpression",callee:r,arguments:[t,Mr,Vi(e,n)],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const a=n;e.addLocalSeriesVar(a);const o=S.createVariableDeclaration(a,s);return e.addHoistedStatement(o),S.createIdentifier(a)}return s}function Bi(t,e,i){const r=ct(t.argument,e,i),n={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return ue(n,e,{CallExpression(s,a){s._transformed||ce(s,a)},MemberExpression(s){ye(s,"",e)}}),n}function Mt(t,e,i){switch(t?.type){case"BinaryExpression":t=ji(t,i,e);break;case"LogicalExpression":t=Li(t,i,e);break;case"ConditionalExpression":return _r(t,i,e);case"UnaryExpression":t=Bi(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(c=>{if(c.type==="Identifier"){if(i.isContextBound(c.name)&&!i.isRootParam(c.name))return c;if(i.isLocalSeriesVar(c.name)){const u=S.createIdentifier(c.name);return S.createGetCall(u,0)}return Rr(c.name,i)}return c.type==="CallExpression"?(ce(c,i),c):c.type==="BinaryExpression"?ji(c,i,e):c.type==="LogicalExpression"?Li(c,i,e):c.type==="ConditionalExpression"?_r(c,i,e):c.type==="UnaryExpression"?Bi(c,i,e):(c.type==="MemberExpression"&&ye(c,e,i),c)});break}const r=t.type==="MemberExpression"&&t.computed&&t.property,n=t.type==="MemberExpression"&&!t.computed;if(r){if(t.object&&t.object.type==="MemberExpression"){let d=t.object;for(;d.object&&d.object.type==="MemberExpression";)d=d.object;if(d.object?.type==="Identifier"&&i.isUdtInstance(d.object.name)){const m=d.object.name,x=i.isLocalSeriesVar(m)?(()=>{const b=S.createIdentifier(m);return b._skipTransformation=!0,b})():he(m,i);return d.object=S.createGetCall(x,t.property),t.object}}if(t.object.type==="CallExpression")ce(t.object,i);else if(t.object.type==="MemberExpression"){ye(t.object,"",i);let d=t.object;for(;d&&d.type==="MemberExpression"&&d.object;){if(d.object.type==="Identifier"){const m=d.object,[x]=i.getVariable(m.name);x!==m.name&&!i.isContextBound(m.name)&&!i.isRootParam(m.name)&&!i.isLoopVariable(m.name)&&!i.isLocalSeriesVar(m.name)&&!it.includes(m.name)&&!Tt.includes(m.name)&&(d.object=Rr(m.name,i));break}d=d.object}}else t.object.type==="BinaryExpression"?t.object=ji(t.object,i,e):t.object.type==="LogicalExpression"?t.object=Li(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=_r(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=Bi(t.object,i,e));const c=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:_i(t.object,i);let u;t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?u=S.createGetCall(_i(t.property,i),0):t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression"?u=ct(t.property,i,e):u=t.property;const p=S.createMemberExpression(S.createIdentifier(e),S.createIdentifier("param")),h=i.generateParamId(),f={type:"CallExpression",callee:p,arguments:[c,u,Vi(i,h)],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const d=h;i.addLocalSeriesVar(d);const m=S.createVariableDeclaration(d,f);return i.addHoistedStatement(m),S.createIdentifier(d)}return f}if(n){if(t.object.type==="Identifier"&&Tt.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const c=t.object.name,u={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:t.property.name},computed:!1},arguments:[],_transformed:!0};c==="ta"&&u.arguments.push(i.getNextTACallId());const p=i.generateTempVar();i.addLocalSeriesVar(p);const h=S.createVariableDeclaration(p,u);return i.addOuterHoistedStatement(h),Object.assign(t,S.createIdentifier(p)),t}if(t.object.type==="Identifier"){const c=t.object.name,[u,p]=i.getVariable(c);if(u!==c&&!i.isLoopVariable(c)){const h=he(c,i),f=S.createGetCall(h,0);t.object=f}else if(i.isLocalSeriesVar(c)){const h=S.createIdentifier(c);h._skipTransformation=!0,t.object=S.createGetCall(h,0)}}else t.object.type==="MemberExpression"?Mt(t.object,e,i):t.object.type==="CallExpression"&&(t.object._transformed||ce(t.object,i))}if(t.type==="ObjectExpression"&&(t.properties=t.properties.map(c=>c.value.name?i.isContextBound(c.value.name)||i.isLocalSeriesVar(c.value.name)||i.isLoopVariable(c.value.name)?{type:"Property",key:{type:"Identifier",name:c.key.name},value:S.createIdentifier(c.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:c.key.name},value:he(c.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(c.value.type!=="Literal"&&(c.value=Mt(c.value,e,i)),c))),t.type==="Identifier"){if(it.includes(t.name)&&i.isContextBound(t.name)){const c=t.name;Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name}else if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const c=S.createMemberExpression(S.createIdentifier(e),S.createIdentifier("param")),u=i.generateParamId(),p={type:"CallExpression",callee:c,arguments:[t,Mr,Vi(i,u)],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const h=u;i.addLocalSeriesVar(h);const f=S.createVariableDeclaration(h,p);return i.addHoistedStatement(f),S.createIdentifier(h)}return p}}t?.type==="CallExpression"&&ce(t,i);const s=S.createMemberExpression(S.createIdentifier(e),S.createIdentifier("param")),a=t.type==="Identifier"?_i(t,i):t,o=i.generateParamId(),l={type:"CallExpression",callee:s,arguments:[a,Mr,Vi(i,o)],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const c=o;i.addLocalSeriesVar(c);const u=S.createVariableDeclaration(c,l);return i.addHoistedStatement(u),S.createIdentifier(c)}return l}function ui(t){if(!t)return!1;if(Na(t))return!0;if(t.type==="MemberExpression")return ui(t.object);if(t.type==="ChainExpression")return ui(t.expression);if(t.type==="CallExpression"){const e=t.callee;if(e?.type==="MemberExpression")return ui(e.object);if(e?.type==="ChainExpression")return ui(e.expression)}return!1}function Na(t){return t?.type==="CallExpression"&&t.callee?.type==="MemberExpression"&&t.callee.object?.name==="$"&&t.callee.property?.name==="get"}function Or(t,e,i){t&&(t.type==="Identifier"?(t.parent=e,le(t,i)):t.type==="MemberExpression"?Or(t.object,t,i):t.type==="CallExpression"&&(t.callee&&t.callee.type==="MemberExpression"&&Or(t.callee.object,t.callee,i),t._transformed||ce(t,i)))}function ce(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(Tt.includes(t.callee.name)||it.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=S.createMemberExpression(t.callee,S.createIdentifier("any")));const r=t.callee&&t.callee.type==="MemberExpression"&&t.callee.object&&t.callee.object.type==="Identifier"&&(e.isContextBound(t.callee.object.name)||t.callee.object.name==="math"||t.callee.object.name==="ta");if(r){if(t.callee.object.name===se&&["get","init","param"].includes(t.callee.property.name))return;const n=t.callee.object.name,s=[];t.arguments.forEach(h=>{if(h._isParamCall){s.push(h);return}s.push(Mt(h,n,e))}),t.arguments=s;const a=t.callee.property.name,o=`${n}.${a}`;if(Rn.includes(n)||Rn.includes(o)){const h=e.getNextPlotCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:h,kind:"init",computed:!1,shorthand:!1}]})}if(n==="alert"){const h=e.getNextAlertCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:h,kind:"init",computed:!1,shorthand:!1}]})}if(n==="ta")if(e.getCurrentScopeType()==="fn"){const h=e.getNextTACallId(),[f]=e.getVariable("$$");let d;f?d=S.createMemberExpression(S.createLocalContextIdentifier(),S.createIdentifier("id")):d=S.createLiteral("");const m={type:"BinaryExpression",operator:"+",left:d,right:h};t.arguments.push(m)}else t.arguments.push(e.getNextTACallId());const l=t.callee.property.name,c=`${n}.${l}`,u=gy.includes(c),p=t._insideAwait===!0;if(u&&!p){const h=Object.assign({},t),f=S.createAwaitExpression(h);Object.assign(t,f)}if(!e.shouldSuppressHoisting()){const h=e.generateTempVar();e.addLocalSeriesVar(h);const f=t._insideAwait===!0;let d=Object.assign({},t);f&&(d=S.createAwaitExpression(d));const m=S.createVariableDeclaration(h,d);e.addHoistedStatement(m);const x=S.createIdentifier(h);Object.assign(t,x),t._wasHoisted=!0,t._wasInsideAwait=f;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(n=>n._isParamCall?n:Mt(n,se,e)),!e.isContextBound(t.callee.name)){const n=e.getNextUserCallId(),s=S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("call")),a=t.callee.name;let o=t.callee;e.isUserMethod(a)&&!e.isRegularUserFunction(a)&&(o=S.createIdentifier(`$M_${a}`),o._skipTransformation=!0);const l=[o,n,...t.arguments];t.callee=s,t.arguments=l}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.property.name,s=e.isUserFunction(n),a=t.callee.object,o=a.type==="Identifier"&&e.isLocalSeriesVar(a.name),l=a.type==="MemberExpression",c=e.isUserMethod(n),u=!!a.name&&e.isUdtInstance(a.name);if(s&&c&&!e.isContextBound(n)&&!o&&!l&&u){const p=t.callee.object;t.callee.property;const h=t.arguments.map(v=>v._isParamCall?v:Mt(v,se,e));let f=p;p.type==="Identifier"?f=Mt(p,se,e):p.type==="CallExpression"&&(ce(p,e),f=Mt(p,se,e));const d=S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("call")),m=e.getNextUserCallId(),x=S.createIdentifier(`$M_${n}`);x._skipTransformation=!0;const b=[x,m,f,...h];t.callee=d,t.arguments=b,t._transformed=!0;return}t.callee.object.type==="Identifier"?le(t.callee.object,e):Or(t.callee.object,t.callee,e)}if(t.arguments.forEach(n=>{ue(n,{parent:t},{Identifier(s,a,o){s.parent=a.parent,le(s,e);const l=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||l)&&(s.type==="MemberExpression"?Lt(s,e):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===se&&s.parent.callee.property.name==="get"||ke(s)))},BinaryExpression(s,a,o){const l={...a,parent:s};o(s.left,l),o(s.right,l)},LogicalExpression(s,a,o){const l={...a,parent:s};o(s.left,l),o(s.right,l)},UnaryExpression(s,a,o){const l={...a,parent:s};o(s.argument,l)},CallExpression(s,a,o){s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&(s.callee.object.parent=s.callee,o(s.callee.object,{parent:s.callee})),s._transformed||ce(s,e)},MemberExpression(s,a,o){ye(s,"",e),s.object&&o(s.object,{parent:s})}})}),t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.object,s=Na(n),a=n?.type==="MemberExpression"&&ui(n);if(s||a){const o=Object.assign({},t.callee,{optional:!0});t.callee={type:"ChainExpression",expression:o},t.optional=!0}}}function tn(t){const e={type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:{type:"Literal",value:0}}]},i={type:"IfStatement",test:{type:"BinaryExpression",operator:">",left:{type:"UpdateExpression",operator:"++",prefix:!0,argument:{type:"Identifier",name:t}},right:{type:"Identifier",name:"__maxLoops"}},consequent:{type:"ThrowStatement",argument:{type:"NewExpression",callee:{type:"Identifier",name:"Error"},arguments:[{type:"Literal",value:`Loop exceeded maximum iterations (${t})`}]}},alternate:null};return{counterDecl:e,guardCheck:i}}function Yi(t,e){let i=null;if(t.left.type==="Identifier")i=he(t.left.name,e);else if(t.left.type==="MemberExpression"&&t.left.computed){if(t.left.object.type==="Identifier"){const r=t.left.object.name,[n,s]=e.getVariable(r),a=n!==r,o=e.isContextBound(r);(a||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=he(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed){let r=null,n=t.left;for(;n.type==="MemberExpression"&&!n.computed;){if(n.object.type==="Identifier"){r=n;break}n=n.object}if(r){const s=r.object.name,[a,o]=e.getVariable(s);if(a!==s&&!e.isLoopVariable(s)){const l=he(s,e),c=S.createGetCall(l,0);r.object=c}else if(e.isLocalSeriesVar(s)){const l=S.createIdentifier(s);l._skipTransformation=!0,r.object=S.createGetCall(l,0)}}}if(ue(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,n,s){const a=n.parent&&n.parent.type==="MemberExpression"&&!n.parent.computed&&n.parent.object===r;if(it.includes(r.name)&&e.isContextBound(r.name)&&!a){const m={type:"MemberExpression",object:{type:"Identifier",name:r.name},property:{type:"Identifier",name:"__value"},computed:!1},x=S.createGetCall(m,0);Object.assign(r,x),delete r.name;return}r.parent=n.parent,le(r,e);const o=r.parent&&r.parent.type==="BinaryExpression",l=r.parent&&r.parent.type==="ConditionalExpression",c=e.isContextBound(r.name)&&!e.isRootParam(r.name),u=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,p=r.parent&&r.parent._isParamCall,h=r.parent&&r.parent.type==="MemberExpression",f=r.name==="NaN",d=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===se&&r.parent.callee.property.name==="get";(c||l||o)&&(r.type==="MemberExpression"?Lt(r,e):r.type==="Identifier"&&!h&&!u&&!p&&!f&&!d&&ke(r))},MemberExpression(r,n,s){ye(r,"",e),r.type==="CallExpression"?r.arguments.forEach(a=>s(a,{parent:r,inNamespaceCall:n.inNamespaceCall})):r.object&&s(r.object,{parent:r,inNamespaceCall:n.inNamespaceCall})},CallExpression(r,n,s){const a=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);ce(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&s(r.callee,{parent:r,inNamespaceCall:a||n.inNamespaceCall}),r.arguments.forEach(o=>s(o,{parent:r,inNamespaceCall:a||n.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const s=t.operator.replace("=",""),a=S.createGetCall(i,0);r={type:"BinaryExpression",operator:s,left:a,right:t.right,start:t.start,end:t.end}}const n=S.createSetCall(i,r);t.start&&(n.start=t.start),t.end&&(n.end=t.end),Object.assign(t,n)}}function Ca(t,e){t._skipTransformation||t.declarations.forEach(i=>{if(i.init&&i.init.type==="Identifier"&&it.includes(i.init.name)&&e.isContextBound(i.init.name)){const h=i.init.name;Object.assign(i.init,{type:"MemberExpression",object:{type:"Identifier",name:h},property:{type:"Identifier",name:"__value"},computed:!1}),delete i.init.name}const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===se||i.init.object.name==="context2"),n=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===se||i.init.object.object.name==="context2"),s=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.name=se;return}if(n){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.object.name=se;return}e.addVariable(i.id.name,t.kind);const a=t.kind,o=e.isArrayPatternElement(i.id.name)&&i.init&&i.init.type==="MemberExpression"&&i.init.computed;i.init&&!s&&!o&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&e.isContextBound(i.init.callee.object.name)?ce(i.init,e):ue(i.init,{parent:i.init},{Identifier(h,f){h.parent=f.parent,le(h,e);const d=h.parent&&h.parent.type==="BinaryExpression",m=h.parent&&h.parent.type==="UnaryExpression",x=h.parent&&h.parent.type==="ConditionalExpression",b=h.parent&&h.parent.type==="CallExpression"&&h.parent.callee&&h.parent.callee.object&&h.parent.callee.object.name===se&&h.parent.callee.property.name==="get";h.type==="Identifier"&&(d||m||x)&&!b&&ke(h)},CallExpression(h,f,d){h.callee.type==="Identifier"&&(h.callee.parent=h),h.arguments.forEach(m=>{m.type==="Identifier"&&(m.parent=h)}),(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&d(h.callee,{parent:h}),ce(h,e),h.type==="CallExpression"&&(h.callee.type==="MemberExpression"&&d(h.callee,{parent:h}),h.arguments.forEach(m=>d(m,{parent:h})))},BinaryExpression(h,f,d){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),d(h.left,{parent:h}),d(h.right,{parent:h})},LogicalExpression(h,f,d){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),d(h.left,{parent:h}),d(h.right,{parent:h})},UnaryExpression(h,f,d){h.argument.type==="Identifier"&&(h.argument.parent=h),d(h.argument,{parent:h})},MemberExpression(h,f,d){h.object&&h.object.type==="Identifier"&&(h.object.parent=h),h.property&&h.property.type==="Identifier"&&(h.property.parent=h),ye(h,"",e),h.type==="CallExpression"?h.arguments.forEach(m=>d(m,{parent:h})):h.object&&d(h.object,{parent:h})},AwaitExpression(h,f,d){h.argument&&(h.argument._insideAwait=!0,d(h.argument,{parent:h}),h.argument.type==="Identifier"&&h.argument._wasInsideAwait&&Object.assign(h,h.argument))},ArrowFunctionExpression(h,f,d){if(h.body)if(h.body.type==="BlockStatement"){const m=[];h.body.body.forEach(x=>{e.enterHoistingScope(),d(x,{parent:h.body,insideIIFE:!0});const b=e.exitHoistingScope();m.push(...b),m.push(x)}),h.body.body=m}else d(h.body,{parent:h,insideIIFE:!0})},FunctionExpression(h,f,d){if(h.body&&h.body.type==="BlockStatement"){const m=[];h.body.body.forEach(x=>{e.enterHoistingScope(),d(x,{parent:h.body,insideIIFE:!0});const b=e.exitHoistingScope();m.push(...b),m.push(x)}),h.body.body=m}},SwitchStatement(h,f,d){h.discriminant&&(h.discriminant.parent=h,d(h.discriminant,{parent:h})),h.cases&&h.cases.forEach(m=>{m.parent=h,d(m,{parent:h})})},SwitchCase(h,f,d){if(h.test&&(h.test.parent=h,d(h.test,{parent:h})),h.consequent){const m=[];h.consequent.forEach(x=>{e.enterHoistingScope(),x.parent=h,d(x,{parent:h});const b=e.exitHoistingScope();m.push(...b),m.push(x)}),h.consequent=m}},AssignmentExpression(h,f,d){if(f.insideIIFE){if(h.left.type==="Identifier"){const[m]=e.getVariable(h.left.name);if(m===h.left.name&&!e.isContextBound(h.left.name)){d(h.right,{parent:h});return}}Yi(h,e)}}}));const l=he(i.id.name,e),c=!o&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");if(i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(Lt(i.init.property,e),i.init.property._indexTransformed=!0)),a==="var"){const h=e.getCurrentHoistingScope();if(h){for(const f of h)if(f.type==="VariableDeclaration")for(const d of f.declarations){if(!d.init||d.init.type!=="CallExpression")continue;const m=d.init.callee;if(m?.type!=="MemberExpression")continue;let x;const b=m.property?.name;if(m.object?.type==="Identifier"?x=m.object.name:m.object?.type==="MemberExpression"&&m.object.property?.name&&(x=m.object.property.name),x&&b){const v=`${x}.${b}`;by.includes(v)&&(d.init={type:"ArrowFunctionExpression",params:[],body:d.init,expression:!0,async:!1})}}}}let u;i.init?s||o?u=i.init:a==="var"?u=S.createInitVarCall(l,i.init):u=S.createInitCall(l,c?i.init.object:i.init,c?i.init.property:void 0):u=S.createIdentifier("undefined");const p=S.createExpressionStatement(S.createAssignmentExpression(l,u));if(o){const h=i.init.object.name,f=he(h,e),d=i.init.property.value,m={type:"MemberExpression",object:S.createGetCall(f,0),property:{type:"Literal",value:d},computed:!0};p.expression.right=S.createCallExpression(S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("init")),[l,m])}s&&(e.pushScope("fn"),ue(i.init.body,e,{IfStatement(h,f,d){f.pushScope("if"),h.test&&Ia(h.test,f),d(h.consequent,f),h.alternate&&(f.pushScope("els"),d(h.alternate,f),f.popScope()),f.popScope()},VariableDeclaration(h,f){Ca(h,f)},Identifier(h,f){le(h,f)},AssignmentExpression(h,f){Yi(h,f)},SwitchStatement(h,f,d){h.discriminant.parent=h,d(h.discriminant,f),h.cases.forEach(m=>{m.parent=h,d(m,f)})},SwitchCase(h,f,d){h.test&&(h.test.parent=h,d(h.test,f));const m=[];h.consequent.forEach(x=>{f.enterHoistingScope(),d(x,f);const b=f.exitHoistingScope();m.push(...b),m.push(x)}),h.consequent=m},BlockStatement(h,f,d){const m=[];h.body.forEach(x=>{f.enterHoistingScope(),d(x,f);const b=f.exitHoistingScope();m.push(...b),m.push(x)}),h.body=m}}),e.popScope()),Object.assign(t,p)})}function Ry(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const s=t.init.declarations[0],a=s.id.name;e.addLoopVariable(a,a),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s.init}]},s.init&&ue(s.init,e,{Identifier(o,l){!e.isLoopVariable(o.name)&&!o.computed&&(e.pushScope("for"),le(o,l),o.type==="Identifier"&&(e.isContextBound(o.name)&&o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===o||(o.computed=!0,ke(o))),e.popScope())},MemberExpression(o,l,c){e.pushScope("for"),ye(o,"",e),e.popScope(),o.type==="MemberExpression"&&o.object&&(o.object.type!=="Identifier"||!e.isContextBound(o.object.name))&&c(o.object,l)},CallExpression(o,l,c){o.callee.parent=o,c(o.callee,l);for(const u of o.arguments)c(u,l)}})}t.test&&ue(t.test,e,{Identifier(s,a){!e.isLoopVariable(s.name)&&!s.computed&&(e.pushScope("for"),le(s,a),s.type==="Identifier"&&(e.isContextBound(s.name)&&s.parent&&s.parent.type==="MemberExpression"&&s.parent.object===s||(s.computed=!0,ke(s))),e.popScope())},MemberExpression(s,a,o){e.pushScope("for"),ye(s,"",e),e.popScope(),s.type==="MemberExpression"&&s.object&&(s.object.type!=="Identifier"||!e.isContextBound(s.object.name))&&o(s.object,a)},CallExpression(s,a,o){s.callee.parent=s,o(s.callee,a);for(const l of s.arguments)o(l,a)}}),t.update&&ue(t.update,e,{Identifier(s,a){!e.isLoopVariable(s.name)&&!s.computed&&(e.pushScope("for"),le(s,a),s.type==="Identifier"&&(e.isContextBound(s.name)&&s.parent&&s.parent.type==="MemberExpression"&&s.parent.object===s||(s.computed=!0,ke(s))),e.popScope())},MemberExpression(s,a,o){e.pushScope("for"),ye(s,"",e),e.popScope(),s.type==="MemberExpression"&&s.object&&(s.object.type!=="Identifier"||!e.isContextBound(s.object.name))&&o(s.object,a)},CallExpression(s,a,o){s.callee.parent=s,o(s.callee,a);for(const l of s.arguments)o(l,a)}}),e.setSuppressHoisting(!1);const r=e.getNextLoopGuardName(),n=tn(r);if(e.addHoistedStatement(n.counterDecl),e.pushScope("for"),i(t.body,e),e.popScope(),t.body.type==="BlockStatement"&&t.body.body.unshift(n.guardCheck),t.init&&t.init.type==="VariableDeclaration"){const s=t.init.declarations[0];e.removeLoopVariable(s.id.name)}}function Oy(t,e,i){e.setSuppressHoisting(!0),t.test&&ue(t.test,e,{Identifier(s,a){s.computed||(le(s,a),s.type==="Identifier"&&(e.isContextBound(s.name)&&s.parent&&s.parent.type==="MemberExpression"&&s.parent.object===s||(s.computed=!0,ke(s))))},MemberExpression(s,a,o){ye(s,"",e),s.type==="MemberExpression"&&s.object&&(s.object.type!=="Identifier"||!e.isContextBound(s.object.name))&&o(s.object,a)},CallExpression(s,a,o){if(s.callee.parent=s,o(s.callee,a),ce(s,a),s.arguments)for(const l of s.arguments)o(l,a)}}),e.setSuppressHoisting(!1);const r=e.getNextLoopGuardName(),n=tn(r);e.addHoistedStatement(n.counterDecl),e.pushScope("whl"),i(t.body,e),e.popScope(),t.body.type==="BlockStatement"&&t.body.body.unshift(n.guardCheck)}function Ia(t,e){ue(t,e,{MemberExpression(i,r,n){i.object&&i.object.type==="Identifier"&&!e.isContextBound(i.object.name)&&!i.computed&&(i.object.parent=i,n(i.object,r)),ye(i,"",e)},CallExpression(i,r){ce(i,r)},BinaryExpression(i,r,n){i.left.type==="Identifier"&&(i.left.parent=i),i.right.type==="Identifier"&&(i.right.parent=i),n(i.left,r),n(i.right,r)},LogicalExpression(i,r,n){i.left.type==="Identifier"&&(i.left.parent=i),i.right.type==="Identifier"&&(i.right.parent=i),n(i.left,r),n(i.right,r)},UnaryExpression(i,r,n){i.argument.type==="Identifier"&&(i.argument.parent=i),n(i.argument,r)},Identifier(i,r){const n=i.parent,s=n&&n.type==="UnaryExpression",a=n&&n.type==="BinaryExpression",o=n&&n.type==="LogicalExpression",l=n&&n.type==="ConditionalExpression";le(i,r),i.type==="Identifier"&&(s||a||o||l)&&(n&&n.type==="CallExpression"&&n.callee&&n.callee.object&&n.callee.object.name===se&&n.callee.property?.name==="get"||ke(i));const c=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&c&&ke(i)}})}function $y(t,e,i){t.test&&(e.pushScope("if"),Ia(t.test,e),e.popScope()),e.pushScope("if"),i(t.consequent,e),e.popScope(),t.alternate&&(e.pushScope("els"),i(t.alternate,e),e.popScope())}function Vy(t,e){const i=e.getCurrentScopeType();if(t.argument){if(t.argument.type==="ArrayExpression")t.argument.elements=t.argument.elements.map(r=>r.type==="Identifier"?e.isContextBound(r.name)&&!e.isRootParam(r.name)?S.createGetCall(r,0):Rr(r.name,e):r.type==="MemberExpression"?r.object&&r.object.type==="MemberExpression"&&r.object.object&&r.object.object.type==="Identifier"&&r.object.object.name==="$"&&r.object.property&&["const","let","var","params"].includes(r.object.property.name)?S.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||ye(r,"",e),r):((r.type==="BinaryExpression"||r.type==="LogicalExpression"||r.type==="ConditionalExpression"||r.type==="CallExpression"||r.type==="UnaryExpression")&&ue(r,e,{Identifier(n,s){le(n,s),n.type==="Identifier"&&!n._arrayAccessed&&(ke(n),n._arrayAccessed=!0)},MemberExpression(n){ye(n,"",e)},CallExpression(n,s,a){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&a(n.callee,s),ce(n,s),n.type==="CallExpression"&&n.arguments.forEach(o=>a(o,s))},BinaryExpression(n,s,a){a(n.left,s),a(n.right,s)}}),r)),t.argument={type:"ArrayExpression",elements:[t.argument]};else if(t.argument.type==="ObjectExpression")t.argument.properties=t.argument.properties.map(r=>r.shorthand?e.isContextBound(r.value.name)?r:(e.getVariable(r.value.name),{type:"Property",key:S.createIdentifier(r.key.name),value:he(r.value.name,e),kind:"init",method:!1,shorthand:!1,computed:!1}):(r.value&&r.value.type==="Identifier"&&(e.isContextBound(r.value.name)&&!e.isRootParam(r.value.name)||e.isContextBound(r.value.name)||(r.value=he(r.value.name,e))),r));else if(t.argument.type==="Identifier")le(t.argument,e),t.argument.type==="Identifier"&&ke(t.argument);else if(t.argument.type==="MemberExpression"){if(t.argument.object.type==="Identifier"&&!e.isContextBound(t.argument.object.name)&&!e.isLoopVariable(t.argument.object.name))le(t.argument.object,e);else if(t.argument.computed&&t.argument.object.type==="MemberExpression"){let r=t.argument.object;for(;r.object&&r.object.type==="MemberExpression";)r=r.object;r.object?.type==="Identifier"&&e.isUdtInstance(r.object.name)&&ye(t.argument,"",e)}}if(i==="fn"){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=S.createArrayAccess(t.argument,0):t.argument.type==="MemberExpression"?t.argument.object.type==="Identifier"&&e.isContextBound(t.argument.object.name)&&!e.isRootParam(t.argument.object.name)&&(t.argument._indexTransformed||(Lt(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression"||t.argument.type==="UnaryExpression"||t.argument.type==="AssignmentExpression")&&ue(t.argument,e,{Identifier(n,s){le(n,s),n.type==="Identifier"&&!n._arrayAccessed&&(ke(n),n._arrayAccessed=!0)},MemberExpression(n){ye(n,"",e)},AssignmentExpression(n,s){Yi(n,s)},CallExpression(n,s,a){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&a(n.callee,s),ce(n,s),n.type==="CallExpression"&&n.arguments.forEach(o=>a(o,s))},BinaryExpression(n,s,a){a(n.left,s),a(n.right,s)},ArrowFunctionExpression(n,s,a){if(n.body)if(n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),a(l,s);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}else a(n.body,s)},FunctionExpression(n,s,a){if(n.body&&n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),a(l,s);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}},SwitchStatement(n,s,a){n.discriminant.parent=n,a(n.discriminant,s),n.cases.forEach(o=>{o.parent=n,a(o,s)})},SwitchCase(n,s,a){n.test&&(n.test.parent=n,a(n.test,s));const o=[];n.consequent.forEach(l=>{e.enterHoistingScope(),a(l,s);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.consequent=o},BlockStatement(n,s,a){const o=[];n.body.forEach(l=>{s.enterHoistingScope(),a(l,s);const c=s.exitHoistingScope();o.push(...c),o.push(l)}),n.body=o}});const r=S.createCallExpression(S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("precision")),[t.argument]);t.argument=r}}}function jy(t,e,i){const r=S.createVariableDeclaration("$$",S.createCallExpression(S.createMemberExpression(S.createContextIdentifier(),S.createIdentifier("peekCtx")),[]));if(r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"){t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(l=>{l.type==="Identifier"&&e.addLocalSeriesVar(l.name)});const n=t.id?.name,s=n?.startsWith("$M_")?n.slice(3):n,a=s?e.getFunctionParamUdtTypes(s):void 0,o={};if(a)for(const[l,c]of Object.entries(a))o[l]=e.getVariableUdtType(l),e.markVariableAsUdtInstance(l,c);if(i(t.body,e),t.params.forEach(l=>{l.type==="Identifier"&&e.removeLocalSeriesVar(l.name)}),a)for(const l of Object.keys(a)){e.unmarkVariableAsUdtInstance(l);const c=o[l];c!==void 0&&e.markVariableAsUdtInstance(l,c)}e.popScope()}}function Ly(t){const e={...I,LineComment:()=>{}};function i(o){return o?o.type==="Identifier"?o.name:o.type==="CallExpression"&&o.callee?.type==="MemberExpression"&&o.callee.object?.name==="$"&&o.callee.property?.name==="get"&&o.arguments?.[0]?.type==="Identifier"?o.arguments[0].name:null:null}const r=new Map;He(t,{FunctionDeclaration(o){o.id?.name&&r.set(o.id.name,o)}},e);function n(o){let l=!1;const c={...e,FunctionDeclaration:()=>{},FunctionExpression:()=>{},ArrowFunctionExpression:()=>{}};return He(o,{AwaitExpression(){l=!0}},c),l}let s=!0,a=0;for(;s&&a<20;){s=!1,a++,He(t,{ArrowFunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,s=!0)},FunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,s=!0)}},e);const o=[];He(t,{CallExpression(c){!c._asyncWrapped&&(c.callee?.type==="ArrowFunctionExpression"||c.callee?.type==="FunctionExpression")&&c.callee.async===!0&&o.push(c)}},e);for(const c of o){const u={};for(const p of Object.keys(c))u[p]=c[p];u._asyncWrapped=!0;for(const p of Object.keys(c))delete c[p];c.type="AwaitExpression",c.argument=u,s=!0}const l=new Set;for(const[c,u]of r)n(u.body)&&(u.async||(u.async=!0,s=!0),l.add(c));if(l.size>0){const c=[];He(t,{CallExpression(u){if(!u._asyncWrapped&&u.callee?.type==="MemberExpression"&&u.callee.object?.name==="$"&&u.callee.property?.name==="call"&&u.arguments?.length>0){const p=i(u.arguments[0]);p&&l.has(p)&&c.push(u)}}},e);for(const u of c){const p={};for(const h of Object.keys(u))p[h]=u[h];p._asyncWrapped=!0;for(const h of Object.keys(u))delete u[h];u.type="AwaitExpression",u.argument=p,s=!0}}}}function By(t){const e={...I,LineComment:()=>{}};He(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=S.createMathEqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}else if(i.operator==="!="||i.operator==="!=="){const r=S.createMathNeqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}}},e)}function Fy(t,e,i,r={debug:!1,ln:!1},n=[]){const s=a=>{if(!r.debug||!a.loc||!n.length)return null;const o=a.loc.start.line-1;if(o>=0&&o<n.length){const l=n[o].trim();if(l)return{type:"LineComment",value:`${r.ln?` [Line ${a.loc.start.line}]`:""} ${l}`}}return null};ue(t,e,{Program(a,o,l){const c=[];a.body.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope(),h=s(u);h&&c.push(h),c.push(...p),c.push(u)}),a.body=c},BlockStatement(a,o,l){const c=[];a.body.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope(),h=s(u);h&&c.push(h),c.push(...p),c.push(u)}),a.body=c},ReturnStatement(a,o,l){a.argument&&a.argument.type!=="ArrayExpression"&&a.argument.type!=="ObjectExpression"&&a.argument.type!=="Identifier"&&a.argument.type!=="MemberExpression"&&o.getCurrentScopeType()!=="fn"&&l(a.argument,o),Vy(a,o)},VariableDeclaration(a,o){Ca(a,o)},Identifier(a,o){le(a,o)},CallExpression(a,o,l){a.callee&&(a.callee.type==="ArrowFunctionExpression"||a.callee.type==="FunctionExpression")?l(a.callee,o):a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&(a.callee.object.parent=a.callee,l(a.callee.object,o)),ce(a,o)},ArrowFunctionExpression(a,o,l){a.body&&l(a.body,o)},FunctionExpression(a,o,l){a.body&&l(a.body,o)},ForOfStatement(a,o,l){if(a.left&&a.left.type==="VariableDeclaration"){a.left._skipTransformation=!0;const p=a.left.declarations[0];p.id.type==="Identifier"?o.addLoopVariable(p.id.name,p.id.name):p.id.type==="ArrayPattern"&&p.id.elements.forEach(h=>{h.type==="Identifier"&&o.addLoopVariable(h.name,h.name)})}if(a.right){a.right.type==="Identifier"?(le(a.right,o),a.right.type==="Identifier"&&ke(a.right)):l(a.right,o);const p=a.left&&a.left.type==="VariableDeclaration"&&a.left.declarations[0].id.type==="ArrayPattern"?"entries":"iter",h={...a.right},f=S.createCallExpression(S.createMemberExpression(S.createIdentifier("$"),S.createIdentifier(p),!1),[h]);Object.assign(a.right,f)}const c=o.getNextLoopGuardName(),u=tn(c);if(o.addHoistedStatement(u.counterDecl),a.body&&l(a.body,o),a.body&&a.body.type==="BlockStatement"&&a.body.body.unshift(u.guardCheck),a.left&&a.left.type==="VariableDeclaration"){const p=a.left.declarations[0];p.id.type==="Identifier"?o.removeLoopVariable(p.id.name):p.id.type==="ArrayPattern"&&p.id.elements.forEach(h=>{h.type==="Identifier"&&o.removeLoopVariable(h.name)})}},ForInStatement(a,o,l){a.left&&a.left.type==="VariableDeclaration"&&(a.left._skipTransformation=!0),a.right&&a.right.type==="Identifier"?(le(a.right,o),a.right.type==="Identifier"&&ke(a.right)):a.right&&l(a.right,o),a.body&&l(a.body,o)},MemberExpression(a,o,l){a.object&&(a.object.type==="CallExpression"||a.object.type==="MemberExpression")&&(a.object.parent=a,l(a.object,o)),a.object&&a.object.type==="Identifier"&&!o.isContextBound(a.object.name)&&(a.object.parent=a,l(a.object,o)),ye(a,i,o)},AssignmentExpression(a,o,l){if(Yi(a,o),a.type==="CallExpression"&&a.arguments){const c=u=>{u&&(u.type==="CallExpression"&&u.callee&&(u.callee.type==="ArrowFunctionExpression"||u.callee.type==="FunctionExpression")&&l(u.callee,o),u.type==="BinaryExpression"&&(c(u.left),c(u.right)))};a.arguments.forEach(u=>c(u))}},FunctionDeclaration(a,o,l){jy(a,o,l)},ForStatement(a,o,l){Ry(a,o,l)},WhileStatement(a,o,l){Oy(a,o,l)},IfStatement(a,o,l){$y(a,o,l)},SwitchStatement(a,o,l){a.discriminant.parent=a,l(a.discriminant,o),a.cases.forEach(c=>{c.parent=a,l(c,o)})},SwitchCase(a,o,l){a.test&&(a.test.parent=a,l(a.test,o));const c=[];a.consequent.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope();c.push(...p),c.push(u)}),a.consequent=c},AwaitExpression(a,o,l){a.argument&&(a.argument._insideAwait=!0,l(a.argument,o),a.argument.type==="Identifier"&&a.argument._wasInsideAwait===!0&&(a.type="Identifier",a.name=a.argument.name,a.argument._wasHoisted&&(a._wasHoisted=a.argument._wasHoisted),delete a.argument))}})}const g={NUMBER:"NUMBER",STRING:"STRING",BOOLEAN:"BOOLEAN",IDENTIFIER:"IDENTIFIER",KEYWORD:"KEYWORD",OPERATOR:"OPERATOR",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",SEMICOLON:"SEMICOLON",INDENT:"INDENT",DEDENT:"DEDENT",NEWLINE:"NEWLINE",COMMENT:"COMMENT",EOF:"EOF"},Wy=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends","enum"]),Uy=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class qy{constructor(e,i,r,n,s=0){this.type=e,this.value=i,this.line=r,this.column=n,this.indent=s}}var zy=Object.defineProperty,Ky=(t,e,i)=>e in t?zy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,nt=(t,e,i)=>Ky(t,typeof e!="symbol"?e+"":e,i);class Hy{constructor(e){nt(this,"source"),nt(this,"pos"),nt(this,"line"),nt(this,"column"),nt(this,"tokens"),nt(this,"indentStack"),nt(this,"atLineStart"),nt(this,"parenDepth"),nt(this,"bracketDepth"),nt(this,"braceDepth"),this.source=e,this.pos=0,this.line=1,this.column=1,this.tokens=[],this.indentStack=[0],this.atLineStart=!0,this.parenDepth=0,this.bracketDepth=0,this.braceDepth=0}tokenize(){for(;this.pos<this.source.length;){const e=this.peek();if(e==="\r"){this.advance();continue}if(e===`
|
|
17
|
+
}`}function ky(t){ue(t,null,{VariableDeclaration(e,i,r){e.declarations&&e.declarations.length>0&&e.declarations.forEach(n=>{if(n.init&&n.init.type==="ArrowFunctionExpression"&&n.init.start!==0){const s={type:"FunctionDeclaration",id:n.id,params:n.init.params,body:n.init.body.type==="BlockStatement"?n.init.body:{type:"BlockStatement",body:[{type:"ReturnStatement",argument:n.init.body}]},async:n.init.async,generator:!1};Object.assign(e,s)}}),e.body&&e.body.body&&e.body.body.forEach(n=>r(n,i))}})}function Ty(t,e){He(t,{VariableDeclaration(r){for(const n of r.declarations)if(!(n.id?.type!=="Identifier"||!n.init)&&n.init.type==="CallExpression"&&n.init.callee?.type==="Identifier"&&n.init.callee.name==="Type"&&n.init.arguments?.length===1&&n.init.arguments[0]?.type==="ObjectExpression"){const s={};for(const a of n.init.arguments[0].properties)a.type!=="Property"||a.key?.type!=="Identifier"||(a.value?.type==="ArrayExpression"&&a.value.elements?.[0]?.type==="Literal"?s[a.key.name]=String(a.value.elements[0].value):a.value?.type==="Literal"&&(s[a.key.name]=String(a.value.value)));e.addUdtTypeName(n.id.name,s)}}});let i=!0;for(;i;)i=!1,He(t,{FunctionDeclaration(r){if(!r.id?.name)return;const n=r.id.name;if(e.getFunctionReturnType(n)||e.getFunctionReturnTupleType(n))return;const s=Ay(r.body);if(s.length===0)return;if(s.every(l=>l.type==="ArrayExpression")){const l=s[0].elements.length;if(l>0&&s.every(c=>c.elements.length===l)){const c=[];let u=!0;for(let p=0;p<l;p++){const h=s.map(d=>yi(d.elements[p],e)),f=h[0];if(!h.every(d=>d===f)){u=!1;break}c.push(f)}if(u&&c.some(p=>!!p)){e.setFunctionReturnTupleType(n,c),i=!0;return}}}const a=s.map(l=>yi(l,e)),o=a[0];!o||!a.every(l=>l===o)||(e.setFunctionReturnType(n,o),i=!0)}});He(t,{VariableDeclaration(r){for(const n of r.declarations)if(n.init){if(n.id?.type==="Identifier"){const s=yi(n.init,e);s&&e.markVariableAsUdtInstance(n.id.name,s);continue}if(n.id?.type==="ArrayPattern"&&n.init.type==="CallExpression"&&n.init.callee?.type==="Identifier"){const s=e.getFunctionReturnTupleType(n.init.callee.name);if(!s)continue;n.id.elements?.forEach((a,o)=>{if(!a||a.type!=="Identifier")return;const l=s[o];l&&e.markVariableAsUdtInstance(a.name,l)})}}},ExpressionStatement(r){const n=r.expression;if(n?.type==="Literal"&&typeof n.value=="string"&&n.value.startsWith("__pineUdtVar:")){const s=n.value.match(/^__pineUdtVar:([A-Za-z_$][\w$]*)=([A-Za-z_$][\w$]*)$/);if(s){const[,a,o]=s;e.isUdtTypeName(o)&&e.markVariableAsUdtInstance(a,o)}}}}),He(t,{ExpressionStatement(r){const n=r.expression;if(!n||n.type!=="AssignmentExpression"||n.operator!=="=")return;const s=n.left;if(s?.type!=="MemberExpression"||s.computed||s.property?.type!=="Identifier"||s.property.name!=="__pineParamTypes__"||s.object?.type!=="Identifier"||n.right?.type!=="ObjectExpression")return;const a=s.object.name,o=a.startsWith("$M_")?a.slice(3):a,l={};for(const c of n.right.properties){if(c.type!=="Property")continue;let u;if(c.key?.type==="Identifier"?u=c.key.name:c.key?.type==="Literal"&&typeof c.key.value=="string"&&(u=c.key.value),!u||c.value?.type!=="Literal"||typeof c.value.value!="string")continue;const p=c.value.value.split(/\s+/).pop();e.isUdtTypeName(p)&&(l[u]=p)}Object.keys(l).length>0&&e.setFunctionParamUdtTypes(o,l)}})}function Ay(t){const e=[];if(!t)return e;function i(r){if(!(!r||typeof r!="object")&&!(r.type==="FunctionDeclaration"||r.type==="FunctionExpression"||r.type==="ArrowFunctionExpression")){if(r.type==="ReturnStatement"&&r.argument){e.push(r.argument);return}for(const n of Object.keys(r)){if(n==="type")continue;const s=r[n];Array.isArray(s)?s.forEach(i):s&&typeof s=="object"&&s.type&&i(s)}}}return i(t),e}function yi(t,e){if(t){if(t.type==="CallExpression"&&t.callee?.type==="MemberExpression"&&!t.callee.computed&&t.callee.object?.type==="Identifier"&&t.callee.property?.type==="Identifier"&&(t.callee.property.name==="new"||t.callee.property.name==="copy")&&e.isUdtTypeName(t.callee.object.name))return t.callee.object.name;if(t.type==="CallExpression"&&t.callee?.type==="Identifier"){const i=e.getFunctionReturnType(t.callee.name);if(i)return i}if(t.type==="ConditionalExpression"){const i=yi(t.consequent,e),r=yi(t.alternate,e);if(i&&i===r)return i}}}function Py(t,e){He(t,{VariableDeclaration(i){i.declarations.forEach(r=>{const n=r.init&&r.init.type==="MemberExpression"&&r.init.object&&(r.init.object.name==="context"||r.init.object.name===se||r.init.object.name==="context2"),s=r.init&&r.init.type==="MemberExpression"&&r.init.object?.object&&(r.init.object.object.name==="context"||r.init.object.object.name===se||r.init.object.object.name==="context2");(n||s)&&(r.id.name&&e.addContextBoundVar(r.id.name),r.id.properties&&r.id.properties.forEach(a=>{a.key.name&&e.addContextBoundVar(a.key.name)}))})}})}function Dy(t,e,i=!1){t.params.forEach(r=>{r.type==="Identifier"&&i&&e.addContextBoundVar(r.name,i)})}function My(t,e){let i;return yy(t,{FunctionDeclaration(r){r.id&&r.id.name&&(e.addReservedName(r.id.name),e.addUserFunction(r.id.name),r.id.name.startsWith("$M_")||e.addRegularUserFunction(r.id.name))},ExpressionStatement(r){const n=r.expression;if(n&&n.type==="AssignmentExpression"&&n.operator==="="&&n.left?.type==="MemberExpression"&&n.left.property?.name==="__pineMethod__"&&n.left.object?.type==="Identifier"&&n.right?.value===!0){const s=n.left.object.name,a=s.startsWith("$M_")?s.slice(3):s;e.addUserMethod(a),e.addUserFunction(a)}},ArrowFunctionExpression(r){const n=r.start===0;n&&r.params&&r.params.length>0&&(i=r.params[0].name,r.params[0].name=se),Dy(r,e,n)},VariableDeclaration(r,n){const s=n.length>1?n[n.length-2]:null,a=s&&(s.type==="ForOfStatement"||s.type==="ForInStatement")&&s.left===r;r.declarations.forEach(o=>{if(o.id.type==="Identifier")e.addReservedName(o.id.name);else if(o.id.type==="ObjectPattern")o.id.properties.forEach(l=>{l.key&&l.key.type==="Identifier"&&e.addReservedName(l.key.name)});else if(o.id.type==="ArrayPattern"){if(o.id.elements?.forEach(h=>{h&&h.type==="Identifier"&&e.addReservedName(h.name)}),a)return;const l=e.generateTempVar(),c={type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:l},init:o.init}]},u=c.declarations[0].init;u&&u.type==="CallExpression"&&(u.callee.type==="ArrowFunctionExpression"||u.callee.type==="FunctionExpression")&&He(u.callee.body,{ReturnStatement(h){h.argument&&h.argument.type==="ArrayExpression"&&(h.argument={type:"ArrayExpression",elements:[h.argument]})}}),o.id.elements?.forEach(h=>{h.type==="Identifier"&&e.addArrayPatternElement(h.name)});const p=o.id.elements.map((h,f)=>({type:"VariableDeclaration",kind:r.kind,declarations:[{type:"VariableDeclarator",id:h,init:{type:"MemberExpression",object:{type:"Identifier",name:l},property:{type:"Literal",value:f},computed:!0}}]}));Object.assign(r,{type:"BlockStatement",body:[c,...p]})}})},ForStatement(r){}}),i}const Mr={type:"Identifier",name:"undefined"};function Vi(t,e){const i={type:"Identifier",name:`'${e}'`};if(!t.isInsideFunctionScope())return i;const[r]=t.getVariable("$$");return r?{type:"BinaryExpression",operator:"+",left:E.createMemberExpression(E.createLocalContextIdentifier(),E.createIdentifier("id")),right:i}:i}function he(t,e){const[i,r]=e.getVariable(t);if((i.match(/^fn\d+_/)||e.isVariableInFunctionScope(t))&&t!=="$$"){const[n]=e.getVariable("$$");if(n)return E.createLocalContextVariableReference(r,i)}return E.createContextVariableReference(r,i)}function Rr(t,e){const i=he(t,e);return E.createGetCall(i,0)}function Lt(t,e){if(t.computed&&t.property.type==="Identifier"){if(e.isLoopVariable(t.property.name)){if(t.object.type==="Identifier"&&!e.isLoopVariable(t.object.name)){if(e.isLocalSeriesVar(t.object.name)){const i=E.createIdentifier(t.object.name);i._skipTransformation=!0;const r=E.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(!e.isContextBound(t.object.name)){const i=he(t.object.name,e),r=E.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0}}return}if(!e.isContextBound(t.property.name))if(e.isLocalSeriesVar(t.property.name)){const i=E.createIdentifier(t.property.name);i._skipTransformation=!0,t.property=E.createGetCall(i,0)}else t.property=he(t.property.name,e),t.property=E.createGetCall(t.property,0)}if(t.computed&&t.object.type==="Identifier"){if(e.isLoopVariable(t.object.name))return;if(e.isLocalSeriesVar(t.object.name)){const i=E.createIdentifier(t.object.name);i._skipTransformation=!0;const r=E.createGetCall(i,t.property);Object.assign(t,r),t._indexTransformed=!0;return}if(e.isContextBound(t.object.name)||(t.object=he(t.object.name,e)),t.property.type==="MemberExpression"){const i=t.property;i._indexTransformed||(Lt(i,e),i._indexTransformed=!0)}}t.computed&&t.property.type!=="Identifier"&&t.property.type!=="MemberExpression"&&!t._indexTransformed&&(t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression")&&(t.property=ct(t.property,e))}function ke(t,e){const i=E.createGetCall(E.createIdentifier(t.name),0);t.start!==void 0&&(i.start=t.start),t.end!==void 0&&(i.end=t.end),i._indexTransformed=!0,Object.assign(t,i)}function le(t,e){if(!t._skipTransformation&&t.name!==se){if(it.includes(t.name)&&e.isContextBound(t.name)){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,f=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&!t.parent.computed;if(!h&&!f){const d={type:"MemberExpression",object:{type:"Identifier",name:t.name},property:{type:"Identifier",name:"__value"},computed:!1},m=E.createGetCall(d,0);Object.assign(t,m),delete t.name;return}}if(t.name==="Math"||t.name==="NaN"||t.name==="undefined"||t.name==="Infinity"||t.name==="null"||t.name.startsWith("'")&&t.name.endsWith("'")||t.name.startsWith('"')&&t.name.endsWith('"')||t.name.startsWith("`")&&t.name.endsWith("`")||e.isLoopVariable(t.name))return;let i=!1;if(t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t)){const h=t.parent.callee;if(h.type==="MemberExpression"&&h.object&&h.object.name===se&&["get","set","init","param","call"].includes(h.property.name)){const f=t.parent.arguments.indexOf(t);h.property.name==="call"?f>=2&&(i=!0):f===0&&(i=!0)}else{const f=h.type==="MemberExpression"&&h.object&&h.object.type==="Identifier"&&Tt.includes(h.object.name);h.type==="MemberExpression"&&!f?i=!1:i=!0}}const r=t.parent&&t.parent.type==="MemberExpression"&&t.parent.object===t&&e.isContextBound(t.name),n=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.property.name==="param";t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left;const s=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,a=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.object===t,o=t.parent&&t.parent.type==="MemberExpression"&&t.parent.computed&&t.parent.property===t&&t.parent.parent&&t.parent.parent.type==="CallExpression"&&t.parent.parent.callee&&t.parent.parent.callee.type==="MemberExpression"&&e.isContextBound(t.parent.parent.callee.object.name);if(r||n||i||o||s){if(s||t.parent&&t.parent.type==="CallExpression"&&t.parent.callee&&t.parent.callee.type==="MemberExpression"&&t.parent.callee.object&&t.parent.callee.object.name===se&&t.parent.callee.property.name==="call"&&t.parent.arguments[0]===t||e.isLocalSeriesVar(t.name)||e.isContextBound(t.name)&&!e.isRootParam(t.name))return;const h=he(t.name,e);Object.assign(t,h);return}const l=e.isContextBound(t.name)&&!e.isRootParam(t.name);if(l){const h=t.parent&&t.parent.type==="CallExpression"&&t.parent.arguments.includes(t),f=t.parent&&t.parent.type==="SwitchStatement"&&t.parent.discriminant===t,d=t.parent&&t.parent.type==="SwitchCase"&&t.parent.test===t;if(!h&&!f&&!d)return}if(e.isLocalSeriesVar(t.name)){if(!a){const h=E.createIdentifier(t.name),f=E.createGetCall(h,0);Object.assign(t,f)}return}const[c,u]=e.getVariable(t.name);let p;if(l)p=E.createIdentifier(t.name);else{if(c===t.name&&!e.isContextBound(t.name))return;p=he(t.name,e)}if(a)Object.assign(t,p);else{const h=E.createGetCall(p,0);Object.assign(t,h)}}}function ye(t,e,i){if(t.object&&t.object.type==="Identifier"&&t.object.name==="Math")return;if(t.object&&t.object.type==="Identifier"&&Tt.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const l=t.parent&&t.parent.type==="CallExpression"&&t.parent.callee===t,c=t.parent&&(t.parent.type==="VariableDeclarator"&&(t.parent.id.type==="ArrayPattern"||t.parent.id.type==="ObjectPattern")||t.parent.type==="AssignmentExpression"&&(t.parent.left.type==="ArrayPattern"||t.parent.left.type==="ObjectPattern")||t.parent.type==="Property");if(!l&&!c){const u={type:"CallExpression",callee:{type:"MemberExpression",object:t.object,property:t.property,computed:!1},arguments:[],_transformed:!1};t.start!==void 0&&(u.start=t.start),t.end!==void 0&&(u.end=t.end),Object.assign(t,u);return}}if(!t.computed&&t.object&&t.object.type==="Identifier"&&i.isLocalSeriesVar(t.object.name)){const l=E.createIdentifier(t.object.name);l._skipTransformation=!0,t.object=E.createGetCall(l,0);return}const r=i.getCurrentScopeType()=="if",n=i.getCurrentScopeType()=="els",s=i.getCurrentScopeType()=="for";if(!r&&!n&&!s&&t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)&&!t.computed)return;t._indexTransformed||(Lt(t,i),t._indexTransformed=!0);const a=t.object&&t.object.type==="MemberExpression"&&t.object.object&&t.object.object.type==="MemberExpression"&&t.object.object.object&&(t.object.object.object.name===se||t.object.object.object.name==="$$"),o=t.object&&t.object.type==="Identifier"&&i.isContextBound(t.object.name);if(t.computed&&(a||o)){if(t.parent&&t.parent.type==="AssignmentExpression"&&t.parent.left===t)return;t.object.type==="Identifier"&&it.includes(t.object.name)&&i.isContextBound(t.object.name)&&(t.object={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1});const l=E.createGetCall(t.object,t.property);t.start&&(l.start=t.start),t.end&&(l.end=t.end),Object.assign(t,l),delete t.object,delete t.property,delete t.computed;return}if(t.computed&&t.object&&t.object.type==="MemberExpression"){let l=t.object;for(;l.object&&l.object.type==="MemberExpression";)l=l.object;if(l.object&&l.object.type==="Identifier"&&i.isUdtInstance(l.object.name)){const c=l.object.name,u=i.isLocalSeriesVar(c)?(()=>{const h=E.createIdentifier(c);return h._skipTransformation=!0,h})():he(c,i);l.object=E.createGetCall(u,t.property);const p=t.object;Object.assign(t,p),delete t.computed;return}}}function _i(t,e){if(t.type==="Identifier"){if(it.includes(t.name)&&e.isContextBound(t.name)){const s=t.name;return Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:s},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name,t}if(e.isLoopVariable(t.name))return t;if(e.isRootParam(t.name)){const[s,a]=e.getVariable(t.name);return E.createContextVariableReference(a,s)}if(e.isContextBound(t.name))return t;const[i,r]=e.getVariable(t.name),n=i!==t.name;return e.isLocalSeriesVar(t.name)&&!n?t:n?he(t.name,e):i===t.name&&!e.isContextBound(t.name)?t:he(t.name,e)}return t}function ct(t,e,i=""){switch(t.type){case"BinaryExpression":return ji(t,e,i);case"LogicalExpression":return Li(t,e,i);case"MemberExpression":{const r=!t.computed&&t.object.type==="Identifier"&&it.includes(t.object.name)&&e.isContextBound(t.object.name);if(t.computed&&t.object.type==="Identifier"&&it.includes(t.object.name)&&e.isContextBound(t.object.name)){const a={type:"MemberExpression",object:{type:"Identifier",name:t.object.name},property:{type:"Identifier",name:"__value"},computed:!1};return E.createGetCall(a,t.property)}const n=t.object.type==="Identifier"&&!r?_i(t.object,e):t.object;let s=n;if(!t.computed&&t.object.type==="Identifier"&&!r){const[a]=e.getVariable(t.object.name);a!==t.object.name&&!e.isLoopVariable(t.object.name)&&(s=E.createGetCall(n,0))}return{type:"MemberExpression",object:s,property:t.property,computed:t.computed}}case"Identifier":{if(e.isLoopVariable(t.name)||t.parent&&t.parent.type==="MemberExpression"&&t.parent.property===t)return t;const r=_i(t,e);return r.type==="Identifier"&&(r.name==="NaN"||r.name==="undefined"||r.name==="Infinity"||r.name==="null"||r.name==="Math")?r:E.createGetCall(r,0)}case"UnaryExpression":return Bi(t,e,i);case"ConditionalExpression":{const r=ct(t.test,e,i),n=ct(t.consequent,e,i),s=ct(t.alternate,e,i);return{type:"ConditionalExpression",test:r,consequent:n,alternate:s,start:t.start,end:t.end}}}return t}function ji(t,e,i){const r=ct(t.left,e,i),n=ct(t.right,e,i),s={type:"BinaryExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return ue(s,e,{CallExpression(a,o){a._transformed||ce(a,o)},MemberExpression(a){ye(a,"",e)}}),s}function Li(t,e,i){const r=ct(t.left,e,i),n=ct(t.right,e,i),s={type:"LogicalExpression",operator:t.operator,left:r,right:n,start:t.start,end:t.end};return ue(s,e,{CallExpression(a,o){a._transformed||ce(a,o)}}),s}function _r(t,e,i){ue(t,{parent:t,inNamespaceCall:!1},{Identifier(a,o,l){if(a.name=="NaN")return;if(it.includes(a.name)&&e.isContextBound(a.name)){if(o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===a&&!o.parent.computed)return;const u={type:"MemberExpression",object:{type:"Identifier",name:a.name},property:{type:"Identifier",name:"__value"},computed:!1},p=E.createGetCall(u,0);Object.assign(a,p),delete a.name;return}a.parent=o.parent,le(a,e);const c=a.parent&&a.parent.type==="BinaryExpression";(a.parent&&a.parent.type==="ConditionalExpression"||c)&&(a.type==="MemberExpression"?Lt(a,e):a.type==="Identifier"&&(a.parent&&a.parent.type==="CallExpression"&&a.parent.callee&&a.parent.callee.object&&a.parent.callee.object.name===se&&a.parent.callee.property.name==="get"||ke(a)))},MemberExpression(a,o,l){ye(a,"",e),a.object&&l(a.object,{parent:a,inNamespaceCall:o.inNamespaceCall})},ConditionalExpression(a,o,l){const c={...o,parent:a};a.test&&l(a.test,c),a.consequent&&l(a.consequent,c),a.alternate&&l(a.alternate,c)},BinaryExpression(a,o,l){const c={...o,parent:a};l(a.left,c),l(a.right,c)},LogicalExpression(a,o,l){const c={...o,parent:a};l(a.left,c),l(a.right,c)},UnaryExpression(a,o,l){const c={...o,parent:a};l(a.argument,c)},CallExpression(a,o,l){const c=a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&a.callee.object.type==="Identifier"&&e.isContextBound(a.callee.object.name);ce(a,e),a.arguments.forEach(u=>l(u,{parent:a,inNamespaceCall:c||o.inNamespaceCall}))}});const r=E.createMemberExpression(E.createIdentifier(i),E.createIdentifier("param")),n=e.generateParamId(),s={type:"CallExpression",callee:r,arguments:[t,Mr,Vi(e,n)],_transformed:!0,_isParamCall:!0};if(!e.shouldSuppressHoisting()){const a=n;e.addLocalSeriesVar(a);const o=E.createVariableDeclaration(a,s);return e.addHoistedStatement(o),E.createIdentifier(a)}return s}function Bi(t,e,i){const r=ct(t.argument,e,i),n={type:"UnaryExpression",operator:t.operator,prefix:t.prefix,argument:r,start:t.start,end:t.end};return ue(n,e,{CallExpression(s,a){s._transformed||ce(s,a)},MemberExpression(s){ye(s,"",e)}}),n}function Mt(t,e,i){switch(t?.type){case"BinaryExpression":t=ji(t,i,e);break;case"LogicalExpression":t=Li(t,i,e);break;case"ConditionalExpression":return _r(t,i,e);case"UnaryExpression":t=Bi(t,i,e);break;case"ArrayExpression":t.elements=t.elements.map(c=>{if(c.type==="Identifier"){if(i.isContextBound(c.name)&&!i.isRootParam(c.name))return c;if(i.isLocalSeriesVar(c.name)){const u=E.createIdentifier(c.name);return E.createGetCall(u,0)}return Rr(c.name,i)}return c.type==="CallExpression"?(ce(c,i),c):c.type==="BinaryExpression"?ji(c,i,e):c.type==="LogicalExpression"?Li(c,i,e):c.type==="ConditionalExpression"?_r(c,i,e):c.type==="UnaryExpression"?Bi(c,i,e):(c.type==="MemberExpression"&&ye(c,e,i),c)});break}const r=t.type==="MemberExpression"&&t.computed&&t.property,n=t.type==="MemberExpression"&&!t.computed;if(r){if(t.object&&t.object.type==="MemberExpression"){let d=t.object;for(;d.object&&d.object.type==="MemberExpression";)d=d.object;if(d.object?.type==="Identifier"&&i.isUdtInstance(d.object.name)){const m=d.object.name,x=i.isLocalSeriesVar(m)?(()=>{const b=E.createIdentifier(m);return b._skipTransformation=!0,b})():he(m,i);return d.object=E.createGetCall(x,t.property),t.object}}if(t.object.type==="CallExpression")ce(t.object,i);else if(t.object.type==="MemberExpression"){ye(t.object,"",i);let d=t.object;for(;d&&d.type==="MemberExpression"&&d.object;){if(d.object.type==="Identifier"){const m=d.object,[x]=i.getVariable(m.name);x!==m.name&&!i.isContextBound(m.name)&&!i.isRootParam(m.name)&&!i.isLoopVariable(m.name)&&!i.isLocalSeriesVar(m.name)&&!it.includes(m.name)&&!Tt.includes(m.name)&&(d.object=Rr(m.name,i));break}d=d.object}}else t.object.type==="BinaryExpression"?t.object=ji(t.object,i,e):t.object.type==="LogicalExpression"?t.object=Li(t.object,i,e):t.object.type==="ConditionalExpression"?t.object=_r(t.object,i,e):t.object.type==="UnaryExpression"&&(t.object=Bi(t.object,i,e));const c=t.object.type==="Identifier"&&i.isContextBound(t.object.name)&&!i.isRootParam(t.object.name)?t.object:_i(t.object,i);let u;t.property.type==="Identifier"&&!i.isContextBound(t.property.name)&&!i.isLoopVariable(t.property.name)?u=E.createGetCall(_i(t.property,i),0):t.property.type==="BinaryExpression"||t.property.type==="UnaryExpression"||t.property.type==="LogicalExpression"||t.property.type==="ConditionalExpression"?u=ct(t.property,i,e):u=t.property;const p=E.createMemberExpression(E.createIdentifier(e),E.createIdentifier("param")),h=i.generateParamId(),f={type:"CallExpression",callee:p,arguments:[c,u,Vi(i,h)],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const d=h;i.addLocalSeriesVar(d);const m=E.createVariableDeclaration(d,f);return i.addHoistedStatement(m),E.createIdentifier(d)}return f}if(n){if(t.object.type==="Identifier"&&Tt.includes(t.object.name)&&i.isContextBound(t.object.name)&&!t.computed){const c=t.object.name,u={type:"CallExpression",callee:{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:t.property.name},computed:!1},arguments:[],_transformed:!0};c==="ta"&&u.arguments.push(i.getNextTACallId());const p=i.generateTempVar();i.addLocalSeriesVar(p);const h=E.createVariableDeclaration(p,u);return i.addOuterHoistedStatement(h),Object.assign(t,E.createIdentifier(p)),t}if(t.object.type==="Identifier"){const c=t.object.name,[u,p]=i.getVariable(c);if(u!==c&&!i.isLoopVariable(c)){const h=he(c,i),f=E.createGetCall(h,0);t.object=f}else if(i.isLocalSeriesVar(c)){const h=E.createIdentifier(c);h._skipTransformation=!0,t.object=E.createGetCall(h,0)}}else t.object.type==="MemberExpression"?Mt(t.object,e,i):t.object.type==="CallExpression"&&(t.object._transformed||ce(t.object,i))}if(t.type==="ObjectExpression"&&(t.properties=t.properties.map(c=>c.value.name?i.isContextBound(c.value.name)||i.isLocalSeriesVar(c.value.name)||i.isLoopVariable(c.value.name)?{type:"Property",key:{type:"Identifier",name:c.key.name},value:E.createIdentifier(c.value.name),kind:"init",method:!1,shorthand:!1,computed:!1}:{type:"Property",key:{type:"Identifier",name:c.key.name},value:he(c.value.name,i),kind:"init",method:!1,shorthand:!1,computed:!1}:(c.value.type!=="Literal"&&(c.value=Mt(c.value,e,i)),c))),t.type==="Identifier"){if(it.includes(t.name)&&i.isContextBound(t.name)){const c=t.name;Object.assign(t,{type:"MemberExpression",object:{type:"Identifier",name:c},property:{type:"Identifier",name:"__value"},computed:!1}),delete t.name}else if(i.isContextBound(t.name)&&!i.isRootParam(t.name)){const c=E.createMemberExpression(E.createIdentifier(e),E.createIdentifier("param")),u=i.generateParamId(),p={type:"CallExpression",callee:c,arguments:[t,Mr,Vi(i,u)],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const h=u;i.addLocalSeriesVar(h);const f=E.createVariableDeclaration(h,p);return i.addHoistedStatement(f),E.createIdentifier(h)}return p}}t?.type==="CallExpression"&&ce(t,i);const s=E.createMemberExpression(E.createIdentifier(e),E.createIdentifier("param")),a=t.type==="Identifier"?_i(t,i):t,o=i.generateParamId(),l={type:"CallExpression",callee:s,arguments:[a,Mr,Vi(i,o)],_transformed:!0,_isParamCall:!0};if(!i.shouldSuppressHoisting()){const c=o;i.addLocalSeriesVar(c);const u=E.createVariableDeclaration(c,l);return i.addHoistedStatement(u),E.createIdentifier(c)}return l}function ui(t){if(!t)return!1;if(Na(t))return!0;if(t.type==="MemberExpression")return ui(t.object);if(t.type==="ChainExpression")return ui(t.expression);if(t.type==="CallExpression"){const e=t.callee;if(e?.type==="MemberExpression")return ui(e.object);if(e?.type==="ChainExpression")return ui(e.expression)}return!1}function Na(t){return t?.type==="CallExpression"&&t.callee?.type==="MemberExpression"&&t.callee.object?.name==="$"&&t.callee.property?.name==="get"}function Or(t,e,i){t&&(t.type==="Identifier"?(t.parent=e,le(t,i)):t.type==="MemberExpression"?Or(t.object,t,i):t.type==="CallExpression"&&(t.callee&&t.callee.type==="MemberExpression"&&Or(t.callee.object,t.callee,i),t._transformed||ce(t,i)))}function ce(t,e,i){if(t._transformed)return;t.callee&&t.callee.name,t.callee&&t.callee.type==="Identifier"&&(Tt.includes(t.callee.name)||it.includes(t.callee.name))&&e.isContextBound(t.callee.name)&&(t.callee=E.createMemberExpression(t.callee,E.createIdentifier("any")));const r=t.callee&&t.callee.type==="MemberExpression"&&t.callee.object&&t.callee.object.type==="Identifier"&&(e.isContextBound(t.callee.object.name)||t.callee.object.name==="math"||t.callee.object.name==="ta");if(r){if(t.callee.object.name===se&&["get","init","param"].includes(t.callee.property.name))return;const n=t.callee.object.name,s=[];t.arguments.forEach(h=>{if(h._isParamCall){s.push(h);return}s.push(Mt(h,n,e))}),t.arguments=s;const a=t.callee.property.name,o=`${n}.${a}`;if(Rn.includes(n)||Rn.includes(o)){const h=e.getNextPlotCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:h,kind:"init",computed:!1,shorthand:!1}]})}if(n==="alert"){const h=e.getNextAlertCallId();t.arguments.push({type:"ObjectExpression",properties:[{type:"Property",key:{type:"Identifier",name:"__callsiteId"},value:h,kind:"init",computed:!1,shorthand:!1}]})}if(n==="ta")if(e.getCurrentScopeType()==="fn"){const h=e.getNextTACallId(),[f]=e.getVariable("$$");let d;f?d=E.createMemberExpression(E.createLocalContextIdentifier(),E.createIdentifier("id")):d=E.createLiteral("");const m={type:"BinaryExpression",operator:"+",left:d,right:h};t.arguments.push(m)}else t.arguments.push(e.getNextTACallId());const l=t.callee.property.name,c=`${n}.${l}`,u=gy.includes(c),p=t._insideAwait===!0;if(u&&!p){const h=Object.assign({},t),f=E.createAwaitExpression(h);Object.assign(t,f)}if(!e.shouldSuppressHoisting()){const h=e.generateTempVar();e.addLocalSeriesVar(h);const f=t._insideAwait===!0;let d=Object.assign({},t);f&&(d=E.createAwaitExpression(d));const m=E.createVariableDeclaration(h,d);e.addHoistedStatement(m);const x=E.createIdentifier(h);Object.assign(t,x),t._wasHoisted=!0,t._wasInsideAwait=f;return}t._transformed=!0}else if(t.callee&&t.callee.type==="Identifier"){if(t.arguments=t.arguments.map(n=>n._isParamCall?n:Mt(n,se,e)),!e.isContextBound(t.callee.name)){const n=e.getNextUserCallId(),s=E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("call")),a=t.callee.name;let o=t.callee;e.isUserMethod(a)&&!e.isRegularUserFunction(a)&&(o=E.createIdentifier(`$M_${a}`),o._skipTransformation=!0);const l=[o,n,...t.arguments];t.callee=s,t.arguments=l}t._transformed=!0}if(!r&&t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.property.name,s=e.isUserFunction(n),a=t.callee.object,o=a.type==="Identifier"&&e.isLocalSeriesVar(a.name),l=a.type==="MemberExpression",c=e.isUserMethod(n),u=!!a.name&&e.isUdtInstance(a.name);if(s&&c&&!e.isContextBound(n)&&!o&&!l&&u){const p=t.callee.object;t.callee.property;const h=t.arguments.map(v=>v._isParamCall?v:Mt(v,se,e));let f=p;p.type==="Identifier"?f=Mt(p,se,e):p.type==="CallExpression"&&(ce(p,e),f=Mt(p,se,e));const d=E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("call")),m=e.getNextUserCallId(),x=E.createIdentifier(`$M_${n}`);x._skipTransformation=!0;const b=[x,m,f,...h];t.callee=d,t.arguments=b,t._transformed=!0;return}t.callee.object.type==="Identifier"?le(t.callee.object,e):Or(t.callee.object,t.callee,e)}if(t.arguments.forEach(n=>{ue(n,{parent:t},{Identifier(s,a,o){s.parent=a.parent,le(s,e);const l=s.parent&&s.parent.type==="BinaryExpression";(s.parent&&s.parent.type==="ConditionalExpression"||l)&&(s.type==="MemberExpression"?Lt(s,e):s.type==="Identifier"&&(s.parent&&s.parent.type==="CallExpression"&&s.parent.callee&&s.parent.callee.object&&s.parent.callee.object.name===se&&s.parent.callee.property.name==="get"||ke(s)))},BinaryExpression(s,a,o){const l={...a,parent:s};o(s.left,l),o(s.right,l)},LogicalExpression(s,a,o){const l={...a,parent:s};o(s.left,l),o(s.right,l)},UnaryExpression(s,a,o){const l={...a,parent:s};o(s.argument,l)},CallExpression(s,a,o){s.callee&&s.callee.type==="MemberExpression"&&s.callee.object&&(s.callee.object.parent=s.callee,o(s.callee.object,{parent:s.callee})),s._transformed||ce(s,e)},MemberExpression(s,a,o){ye(s,"",e),s.object&&o(s.object,{parent:s})}})}),t.callee&&t.callee.type==="MemberExpression"){const n=t.callee.object,s=Na(n),a=n?.type==="MemberExpression"&&ui(n);if(s||a){const o=Object.assign({},t.callee,{optional:!0});t.callee={type:"ChainExpression",expression:o},t.optional=!0}}}function tn(t){const e={type:"VariableDeclaration",kind:"let",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:t},init:{type:"Literal",value:0}}]},i={type:"IfStatement",test:{type:"BinaryExpression",operator:">",left:{type:"UpdateExpression",operator:"++",prefix:!0,argument:{type:"Identifier",name:t}},right:{type:"Identifier",name:"__maxLoops"}},consequent:{type:"ThrowStatement",argument:{type:"NewExpression",callee:{type:"Identifier",name:"Error"},arguments:[{type:"Literal",value:`Loop exceeded maximum iterations (${t})`}]}},alternate:null};return{counterDecl:e,guardCheck:i}}function Yi(t,e){let i=null;if(t.left.type==="Identifier")i=he(t.left.name,e);else if(t.left.type==="MemberExpression"&&t.left.computed){if(t.left.object.type==="Identifier"){const r=t.left.object.name,[n,s]=e.getVariable(r),a=n!==r,o=e.isContextBound(r);(a||o)&&!e.isLoopVariable(r)&&t.left.property.type==="Literal"&&t.left.property.value===0&&(i=he(r,e))}}else if(t.left.type==="MemberExpression"&&!t.left.computed){let r=null,n=t.left;for(;n.type==="MemberExpression"&&!n.computed;){if(n.object.type==="Identifier"){r=n;break}n=n.object}if(r){const s=r.object.name,[a,o]=e.getVariable(s);if(a!==s&&!e.isLoopVariable(s)){const l=he(s,e),c=E.createGetCall(l,0);r.object=c}else if(e.isLocalSeriesVar(s)){const l=E.createIdentifier(s);l._skipTransformation=!0,r.object=E.createGetCall(l,0)}}}if(ue(t.right,{parent:t.right,inNamespaceCall:!1},{Identifier(r,n,s){const a=n.parent&&n.parent.type==="MemberExpression"&&!n.parent.computed&&n.parent.object===r;if(it.includes(r.name)&&e.isContextBound(r.name)&&!a){const m={type:"MemberExpression",object:{type:"Identifier",name:r.name},property:{type:"Identifier",name:"__value"},computed:!1},x=E.createGetCall(m,0);Object.assign(r,x),delete r.name;return}r.parent=n.parent,le(r,e);const o=r.parent&&r.parent.type==="BinaryExpression",l=r.parent&&r.parent.type==="ConditionalExpression",c=e.isContextBound(r.name)&&!e.isRootParam(r.name),u=r.parent&&r.parent.type==="MemberExpression"&&r.parent.computed&&r.parent.object===r,p=r.parent&&r.parent._isParamCall,h=r.parent&&r.parent.type==="MemberExpression",f=r.name==="NaN",d=r.parent&&r.parent.type==="CallExpression"&&r.parent.callee&&r.parent.callee.object&&r.parent.callee.object.name===se&&r.parent.callee.property.name==="get";(c||l||o)&&(r.type==="MemberExpression"?Lt(r,e):r.type==="Identifier"&&!h&&!u&&!p&&!f&&!d&&ke(r))},MemberExpression(r,n,s){ye(r,"",e),r.type==="CallExpression"?r.arguments.forEach(a=>s(a,{parent:r,inNamespaceCall:n.inNamespaceCall})):r.object&&s(r.object,{parent:r,inNamespaceCall:n.inNamespaceCall})},CallExpression(r,n,s){const a=r.callee&&r.callee.type==="MemberExpression"&&r.callee.object&&r.callee.object.type==="Identifier"&&e.isContextBound(r.callee.object.name);ce(r,e),r.type==="CallExpression"&&(r.callee.type==="MemberExpression"&&s(r.callee,{parent:r,inNamespaceCall:a||n.inNamespaceCall}),r.arguments.forEach(o=>s(o,{parent:r,inNamespaceCall:a||n.inNamespaceCall})))}}),i){let r=t.right;if(t.operator!=="="){const s=t.operator.replace("=",""),a=E.createGetCall(i,0);r={type:"BinaryExpression",operator:s,left:a,right:t.right,start:t.start,end:t.end}}const n=E.createSetCall(i,r);t.start&&(n.start=t.start),t.end&&(n.end=t.end),Object.assign(t,n)}}function Ca(t,e){t._skipTransformation||t.declarations.forEach(i=>{if(i.init&&i.init.type==="Identifier"&&it.includes(i.init.name)&&e.isContextBound(i.init.name)){const h=i.init.name;Object.assign(i.init,{type:"MemberExpression",object:{type:"Identifier",name:h},property:{type:"Identifier",name:"__value"},computed:!1}),delete i.init.name}const r=i.init&&i.init.type==="MemberExpression"&&i.init.object&&(i.init.object.name==="context"||i.init.object.name===se||i.init.object.name==="context2"),n=i.init&&i.init.type==="MemberExpression"&&i.init.object?.object&&(i.init.object.object.name==="context"||i.init.object.object.name===se||i.init.object.object.name==="context2"),s=i.init&&i.init.type==="ArrowFunctionExpression";if(r){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.name=se;return}if(n){i.id.name&&e.addContextBoundVar(i.id.name),i.id.properties&&i.id.properties.forEach(h=>{h.key.name&&e.addContextBoundVar(h.key.name)}),i.init.object.object.name=se;return}e.addVariable(i.id.name,t.kind);const a=t.kind,o=e.isArrayPatternElement(i.id.name)&&i.init&&i.init.type==="MemberExpression"&&i.init.computed;i.init&&!s&&!o&&(i.init.type==="CallExpression"&&i.init.callee.type==="MemberExpression"&&i.init.callee.object&&i.init.callee.object.type==="Identifier"&&e.isContextBound(i.init.callee.object.name)?ce(i.init,e):ue(i.init,{parent:i.init},{Identifier(h,f){h.parent=f.parent,le(h,e);const d=h.parent&&h.parent.type==="BinaryExpression",m=h.parent&&h.parent.type==="UnaryExpression",x=h.parent&&h.parent.type==="ConditionalExpression",b=h.parent&&h.parent.type==="CallExpression"&&h.parent.callee&&h.parent.callee.object&&h.parent.callee.object.name===se&&h.parent.callee.property.name==="get";h.type==="Identifier"&&(d||m||x)&&!b&&ke(h)},CallExpression(h,f,d){h.callee.type==="Identifier"&&(h.callee.parent=h),h.arguments.forEach(m=>{m.type==="Identifier"&&(m.parent=h)}),(h.callee.type==="ArrowFunctionExpression"||h.callee.type==="FunctionExpression")&&d(h.callee,{parent:h}),ce(h,e),h.type==="CallExpression"&&(h.callee.type==="MemberExpression"&&d(h.callee,{parent:h}),h.arguments.forEach(m=>d(m,{parent:h})))},BinaryExpression(h,f,d){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),d(h.left,{parent:h}),d(h.right,{parent:h})},LogicalExpression(h,f,d){h.left.type==="Identifier"&&(h.left.parent=h),h.right.type==="Identifier"&&(h.right.parent=h),d(h.left,{parent:h}),d(h.right,{parent:h})},UnaryExpression(h,f,d){h.argument.type==="Identifier"&&(h.argument.parent=h),d(h.argument,{parent:h})},MemberExpression(h,f,d){h.object&&h.object.type==="Identifier"&&(h.object.parent=h),h.property&&h.property.type==="Identifier"&&(h.property.parent=h),ye(h,"",e),h.type==="CallExpression"?h.arguments.forEach(m=>d(m,{parent:h})):h.object&&d(h.object,{parent:h})},AwaitExpression(h,f,d){h.argument&&(h.argument._insideAwait=!0,d(h.argument,{parent:h}),h.argument.type==="Identifier"&&h.argument._wasInsideAwait&&Object.assign(h,h.argument))},ArrowFunctionExpression(h,f,d){if(h.body)if(h.body.type==="BlockStatement"){const m=[];h.body.body.forEach(x=>{e.enterHoistingScope(),d(x,{parent:h.body,insideIIFE:!0});const b=e.exitHoistingScope();m.push(...b),m.push(x)}),h.body.body=m}else d(h.body,{parent:h,insideIIFE:!0})},FunctionExpression(h,f,d){if(h.body&&h.body.type==="BlockStatement"){const m=[];h.body.body.forEach(x=>{e.enterHoistingScope(),d(x,{parent:h.body,insideIIFE:!0});const b=e.exitHoistingScope();m.push(...b),m.push(x)}),h.body.body=m}},SwitchStatement(h,f,d){h.discriminant&&(h.discriminant.parent=h,d(h.discriminant,{parent:h})),h.cases&&h.cases.forEach(m=>{m.parent=h,d(m,{parent:h})})},SwitchCase(h,f,d){if(h.test&&(h.test.parent=h,d(h.test,{parent:h})),h.consequent){const m=[];h.consequent.forEach(x=>{e.enterHoistingScope(),x.parent=h,d(x,{parent:h});const b=e.exitHoistingScope();m.push(...b),m.push(x)}),h.consequent=m}},AssignmentExpression(h,f,d){if(f.insideIIFE){if(h.left.type==="Identifier"){const[m]=e.getVariable(h.left.name);if(m===h.left.name&&!e.isContextBound(h.left.name)){d(h.right,{parent:h});return}}Yi(h,e)}}}));const l=he(i.id.name,e),c=!o&&i.init&&i.init.type==="MemberExpression"&&i.init.computed&&i.init.property&&(i.init.property.type==="Literal"||i.init.property.type==="MemberExpression");if(i.init?.property?.type==="MemberExpression"&&(i.init.property._indexTransformed||(Lt(i.init.property,e),i.init.property._indexTransformed=!0)),a==="var"){const h=e.getCurrentHoistingScope();if(h){for(const f of h)if(f.type==="VariableDeclaration")for(const d of f.declarations){if(!d.init||d.init.type!=="CallExpression")continue;const m=d.init.callee;if(m?.type!=="MemberExpression")continue;let x;const b=m.property?.name;if(m.object?.type==="Identifier"?x=m.object.name:m.object?.type==="MemberExpression"&&m.object.property?.name&&(x=m.object.property.name),x&&b){const v=`${x}.${b}`;by.includes(v)&&(d.init={type:"ArrowFunctionExpression",params:[],body:d.init,expression:!0,async:!1})}}}}let u;i.init?s||o?u=i.init:a==="var"?u=E.createInitVarCall(l,i.init):u=E.createInitCall(l,c?i.init.object:i.init,c?i.init.property:void 0):u=E.createIdentifier("undefined");const p=E.createExpressionStatement(E.createAssignmentExpression(l,u));if(o){const h=i.init.object.name,f=he(h,e),d=i.init.property.value,m={type:"MemberExpression",object:E.createGetCall(f,0),property:{type:"Literal",value:d},computed:!0};p.expression.right=E.createCallExpression(E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("init")),[l,m])}s&&(e.pushScope("fn"),ue(i.init.body,e,{IfStatement(h,f,d){f.pushScope("if"),h.test&&Ia(h.test,f),d(h.consequent,f),h.alternate&&(f.pushScope("els"),d(h.alternate,f),f.popScope()),f.popScope()},VariableDeclaration(h,f){Ca(h,f)},Identifier(h,f){le(h,f)},AssignmentExpression(h,f){Yi(h,f)},SwitchStatement(h,f,d){h.discriminant.parent=h,d(h.discriminant,f),h.cases.forEach(m=>{m.parent=h,d(m,f)})},SwitchCase(h,f,d){h.test&&(h.test.parent=h,d(h.test,f));const m=[];h.consequent.forEach(x=>{f.enterHoistingScope(),d(x,f);const b=f.exitHoistingScope();m.push(...b),m.push(x)}),h.consequent=m},BlockStatement(h,f,d){const m=[];h.body.forEach(x=>{f.enterHoistingScope(),d(x,f);const b=f.exitHoistingScope();m.push(...b),m.push(x)}),h.body=m}}),e.popScope()),Object.assign(t,p)})}function Ry(t,e,i){if(e.setSuppressHoisting(!0),t.init&&t.init.type==="VariableDeclaration"){const s=t.init.declarations[0],a=s.id.name;e.addLoopVariable(a,a),t.init={type:"VariableDeclaration",kind:t.init.kind,declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:a},init:s.init}]},s.init&&ue(s.init,e,{Identifier(o,l){!e.isLoopVariable(o.name)&&!o.computed&&(e.pushScope("for"),le(o,l),o.type==="Identifier"&&(e.isContextBound(o.name)&&o.parent&&o.parent.type==="MemberExpression"&&o.parent.object===o||(o.computed=!0,ke(o))),e.popScope())},MemberExpression(o,l,c){e.pushScope("for"),ye(o,"",e),e.popScope(),o.type==="MemberExpression"&&o.object&&(o.object.type!=="Identifier"||!e.isContextBound(o.object.name))&&c(o.object,l)},CallExpression(o,l,c){o.callee.parent=o,c(o.callee,l);for(const u of o.arguments)c(u,l)}})}t.test&&ue(t.test,e,{Identifier(s,a){!e.isLoopVariable(s.name)&&!s.computed&&(e.pushScope("for"),le(s,a),s.type==="Identifier"&&(e.isContextBound(s.name)&&s.parent&&s.parent.type==="MemberExpression"&&s.parent.object===s||(s.computed=!0,ke(s))),e.popScope())},MemberExpression(s,a,o){e.pushScope("for"),ye(s,"",e),e.popScope(),s.type==="MemberExpression"&&s.object&&(s.object.type!=="Identifier"||!e.isContextBound(s.object.name))&&o(s.object,a)},CallExpression(s,a,o){s.callee.parent=s,o(s.callee,a);for(const l of s.arguments)o(l,a)}}),t.update&&ue(t.update,e,{Identifier(s,a){!e.isLoopVariable(s.name)&&!s.computed&&(e.pushScope("for"),le(s,a),s.type==="Identifier"&&(e.isContextBound(s.name)&&s.parent&&s.parent.type==="MemberExpression"&&s.parent.object===s||(s.computed=!0,ke(s))),e.popScope())},MemberExpression(s,a,o){e.pushScope("for"),ye(s,"",e),e.popScope(),s.type==="MemberExpression"&&s.object&&(s.object.type!=="Identifier"||!e.isContextBound(s.object.name))&&o(s.object,a)},CallExpression(s,a,o){s.callee.parent=s,o(s.callee,a);for(const l of s.arguments)o(l,a)}}),e.setSuppressHoisting(!1);const r=e.getNextLoopGuardName(),n=tn(r);if(e.addHoistedStatement(n.counterDecl),e.pushScope("for"),i(t.body,e),e.popScope(),t.body.type==="BlockStatement"&&t.body.body.unshift(n.guardCheck),t.init&&t.init.type==="VariableDeclaration"){const s=t.init.declarations[0];e.removeLoopVariable(s.id.name)}}function Oy(t,e,i){e.setSuppressHoisting(!0),t.test&&ue(t.test,e,{Identifier(s,a){s.computed||(le(s,a),s.type==="Identifier"&&(e.isContextBound(s.name)&&s.parent&&s.parent.type==="MemberExpression"&&s.parent.object===s||(s.computed=!0,ke(s))))},MemberExpression(s,a,o){ye(s,"",e),s.type==="MemberExpression"&&s.object&&(s.object.type!=="Identifier"||!e.isContextBound(s.object.name))&&o(s.object,a)},CallExpression(s,a,o){if(s.callee.parent=s,o(s.callee,a),ce(s,a),s.arguments)for(const l of s.arguments)o(l,a)}}),e.setSuppressHoisting(!1);const r=e.getNextLoopGuardName(),n=tn(r);e.addHoistedStatement(n.counterDecl),e.pushScope("whl"),i(t.body,e),e.popScope(),t.body.type==="BlockStatement"&&t.body.body.unshift(n.guardCheck)}function Ia(t,e){ue(t,e,{MemberExpression(i,r,n){i.object&&i.object.type==="Identifier"&&!e.isContextBound(i.object.name)&&!i.computed&&(i.object.parent=i,n(i.object,r)),ye(i,"",e)},CallExpression(i,r){ce(i,r)},BinaryExpression(i,r,n){i.left.type==="Identifier"&&(i.left.parent=i),i.right.type==="Identifier"&&(i.right.parent=i),n(i.left,r),n(i.right,r)},LogicalExpression(i,r,n){i.left.type==="Identifier"&&(i.left.parent=i),i.right.type==="Identifier"&&(i.right.parent=i),n(i.left,r),n(i.right,r)},UnaryExpression(i,r,n){i.argument.type==="Identifier"&&(i.argument.parent=i),n(i.argument,r)},Identifier(i,r){const n=i.parent,s=n&&n.type==="UnaryExpression",a=n&&n.type==="BinaryExpression",o=n&&n.type==="LogicalExpression",l=n&&n.type==="ConditionalExpression";le(i,r),i.type==="Identifier"&&(s||a||o||l)&&(n&&n.type==="CallExpression"&&n.callee&&n.callee.object&&n.callee.object.name===se&&n.callee.property?.name==="get"||ke(i));const c=e.getCurrentScopeType()==="if";e.isContextBound(i.name)&&!e.isRootParam(i.name)&&c&&ke(i)}})}function $y(t,e,i){t.test&&(e.pushScope("if"),Ia(t.test,e),e.popScope()),e.pushScope("if"),i(t.consequent,e),e.popScope(),t.alternate&&(e.pushScope("els"),i(t.alternate,e),e.popScope())}function Vy(t,e){const i=e.getCurrentScopeType();if(t.argument){if(t.argument.type==="ArrayExpression")t.argument.elements=t.argument.elements.map(r=>r.type==="Identifier"?e.isContextBound(r.name)&&!e.isRootParam(r.name)?E.createGetCall(r,0):Rr(r.name,e):r.type==="MemberExpression"?r.object&&r.object.type==="MemberExpression"&&r.object.object&&r.object.object.type==="Identifier"&&r.object.object.name==="$"&&r.object.property&&["const","let","var","params"].includes(r.object.property.name)?E.createGetCall(r,0):(r.computed&&r.object.type==="Identifier"&&e.isContextBound(r.object.name)&&!e.isRootParam(r.object.name)||ye(r,"",e),r):((r.type==="BinaryExpression"||r.type==="LogicalExpression"||r.type==="ConditionalExpression"||r.type==="CallExpression"||r.type==="UnaryExpression")&&ue(r,e,{Identifier(n,s){le(n,s),n.type==="Identifier"&&!n._arrayAccessed&&(ke(n),n._arrayAccessed=!0)},MemberExpression(n){ye(n,"",e)},CallExpression(n,s,a){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&a(n.callee,s),ce(n,s),n.type==="CallExpression"&&n.arguments.forEach(o=>a(o,s))},BinaryExpression(n,s,a){a(n.left,s),a(n.right,s)}}),r)),t.argument={type:"ArrayExpression",elements:[t.argument]};else if(t.argument.type==="ObjectExpression")t.argument.properties=t.argument.properties.map(r=>r.shorthand?e.isContextBound(r.value.name)?r:(e.getVariable(r.value.name),{type:"Property",key:E.createIdentifier(r.key.name),value:he(r.value.name,e),kind:"init",method:!1,shorthand:!1,computed:!1}):(r.value&&r.value.type==="Identifier"&&(e.isContextBound(r.value.name)&&!e.isRootParam(r.value.name)||e.isContextBound(r.value.name)||(r.value=he(r.value.name,e))),r));else if(t.argument.type==="Identifier")le(t.argument,e),t.argument.type==="Identifier"&&ke(t.argument);else if(t.argument.type==="MemberExpression"){if(t.argument.object.type==="Identifier"&&!e.isContextBound(t.argument.object.name)&&!e.isLoopVariable(t.argument.object.name))le(t.argument.object,e);else if(t.argument.computed&&t.argument.object.type==="MemberExpression"){let r=t.argument.object;for(;r.object&&r.object.type==="MemberExpression";)r=r.object;r.object?.type==="Identifier"&&e.isUdtInstance(r.object.name)&&ye(t.argument,"",e)}}if(i==="fn"){t.argument.type==="Identifier"&&e.isContextBound(t.argument.name)&&!e.isRootParam(t.argument.name)?t.argument=E.createArrayAccess(t.argument,0):t.argument.type==="MemberExpression"?t.argument.object.type==="Identifier"&&e.isContextBound(t.argument.object.name)&&!e.isRootParam(t.argument.object.name)&&(t.argument._indexTransformed||(Lt(t.argument,e),t.argument._indexTransformed=!0)):(t.argument.type==="BinaryExpression"||t.argument.type==="LogicalExpression"||t.argument.type==="ConditionalExpression"||t.argument.type==="CallExpression"||t.argument.type==="UnaryExpression"||t.argument.type==="AssignmentExpression")&&ue(t.argument,e,{Identifier(n,s){le(n,s),n.type==="Identifier"&&!n._arrayAccessed&&(ke(n),n._arrayAccessed=!0)},MemberExpression(n){ye(n,"",e)},AssignmentExpression(n,s){Yi(n,s)},CallExpression(n,s,a){(n.callee.type==="ArrowFunctionExpression"||n.callee.type==="FunctionExpression")&&a(n.callee,s),ce(n,s),n.type==="CallExpression"&&n.arguments.forEach(o=>a(o,s))},BinaryExpression(n,s,a){a(n.left,s),a(n.right,s)},ArrowFunctionExpression(n,s,a){if(n.body)if(n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),a(l,s);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}else a(n.body,s)},FunctionExpression(n,s,a){if(n.body&&n.body.type==="BlockStatement"){const o=[];n.body.body.forEach(l=>{e.enterHoistingScope(),a(l,s);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.body.body=o}},SwitchStatement(n,s,a){n.discriminant.parent=n,a(n.discriminant,s),n.cases.forEach(o=>{o.parent=n,a(o,s)})},SwitchCase(n,s,a){n.test&&(n.test.parent=n,a(n.test,s));const o=[];n.consequent.forEach(l=>{e.enterHoistingScope(),a(l,s);const c=e.exitHoistingScope();o.push(...c),o.push(l)}),n.consequent=o},BlockStatement(n,s,a){const o=[];n.body.forEach(l=>{s.enterHoistingScope(),a(l,s);const c=s.exitHoistingScope();o.push(...c),o.push(l)}),n.body=o}});const r=E.createCallExpression(E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("precision")),[t.argument]);t.argument=r}}}function jy(t,e,i){const r=E.createVariableDeclaration("$$",E.createCallExpression(E.createMemberExpression(E.createContextIdentifier(),E.createIdentifier("peekCtx")),[]));if(r._skipTransformation=!0,e.addLoopVariable("$$","$$"),t.body&&t.body.type==="BlockStatement"){t.body.body.unshift(r),e.pushScope("fn"),t.params.forEach(l=>{l.type==="Identifier"&&e.addLocalSeriesVar(l.name)});const n=t.id?.name,s=n?.startsWith("$M_")?n.slice(3):n,a=s?e.getFunctionParamUdtTypes(s):void 0,o={};if(a)for(const[l,c]of Object.entries(a))o[l]=e.getVariableUdtType(l),e.markVariableAsUdtInstance(l,c);if(i(t.body,e),t.params.forEach(l=>{l.type==="Identifier"&&e.removeLocalSeriesVar(l.name)}),a)for(const l of Object.keys(a)){e.unmarkVariableAsUdtInstance(l);const c=o[l];c!==void 0&&e.markVariableAsUdtInstance(l,c)}e.popScope()}}function Ly(t){const e={...I,LineComment:()=>{}};function i(o){return o?o.type==="Identifier"?o.name:o.type==="CallExpression"&&o.callee?.type==="MemberExpression"&&o.callee.object?.name==="$"&&o.callee.property?.name==="get"&&o.arguments?.[0]?.type==="Identifier"?o.arguments[0].name:null:null}const r=new Map;He(t,{FunctionDeclaration(o){o.id?.name&&r.set(o.id.name,o)}},e);function n(o){let l=!1;const c={...e,FunctionDeclaration:()=>{},FunctionExpression:()=>{},ArrowFunctionExpression:()=>{}};return He(o,{AwaitExpression(){l=!0}},c),l}let s=!0,a=0;for(;s&&a<20;){s=!1,a++,He(t,{ArrowFunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,s=!0)},FunctionExpression(c){!c.async&&n(c.body)&&(c.async=!0,s=!0)}},e);const o=[];He(t,{CallExpression(c){!c._asyncWrapped&&(c.callee?.type==="ArrowFunctionExpression"||c.callee?.type==="FunctionExpression")&&c.callee.async===!0&&o.push(c)}},e);for(const c of o){const u={};for(const p of Object.keys(c))u[p]=c[p];u._asyncWrapped=!0;for(const p of Object.keys(c))delete c[p];c.type="AwaitExpression",c.argument=u,s=!0}const l=new Set;for(const[c,u]of r)n(u.body)&&(u.async||(u.async=!0,s=!0),l.add(c));if(l.size>0){const c=[];He(t,{CallExpression(u){if(!u._asyncWrapped&&u.callee?.type==="MemberExpression"&&u.callee.object?.name==="$"&&u.callee.property?.name==="call"&&u.arguments?.length>0){const p=i(u.arguments[0]);p&&l.has(p)&&c.push(u)}}},e);for(const u of c){const p={};for(const h of Object.keys(u))p[h]=u[h];p._asyncWrapped=!0;for(const h of Object.keys(u))delete u[h];u.type="AwaitExpression",u.argument=p,s=!0}}}}function By(t){const e={...I,LineComment:()=>{}};He(t,{BinaryExpression(i){if(i.operator==="=="||i.operator==="==="){const r=E.createMathEqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}else if(i.operator==="!="||i.operator==="!=="){const r=E.createMathNeqCall(i.left,i.right);r._transformed=!0,Object.assign(i,r)}}},e)}function Fy(t,e,i,r={debug:!1,ln:!1},n=[]){const s=a=>{if(!r.debug||!a.loc||!n.length)return null;const o=a.loc.start.line-1;if(o>=0&&o<n.length){const l=n[o].trim();if(l)return{type:"LineComment",value:`${r.ln?` [Line ${a.loc.start.line}]`:""} ${l}`}}return null};ue(t,e,{Program(a,o,l){const c=[];a.body.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope(),h=s(u);h&&c.push(h),c.push(...p),c.push(u)}),a.body=c},BlockStatement(a,o,l){const c=[];a.body.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope(),h=s(u);h&&c.push(h),c.push(...p),c.push(u)}),a.body=c},ReturnStatement(a,o,l){a.argument&&a.argument.type!=="ArrayExpression"&&a.argument.type!=="ObjectExpression"&&a.argument.type!=="Identifier"&&a.argument.type!=="MemberExpression"&&o.getCurrentScopeType()!=="fn"&&l(a.argument,o),Vy(a,o)},VariableDeclaration(a,o){Ca(a,o)},Identifier(a,o){le(a,o)},CallExpression(a,o,l){a.callee&&(a.callee.type==="ArrowFunctionExpression"||a.callee.type==="FunctionExpression")?l(a.callee,o):a.callee&&a.callee.type==="MemberExpression"&&a.callee.object&&(a.callee.object.parent=a.callee,l(a.callee.object,o)),ce(a,o)},ArrowFunctionExpression(a,o,l){a.body&&l(a.body,o)},FunctionExpression(a,o,l){a.body&&l(a.body,o)},ForOfStatement(a,o,l){if(a.left&&a.left.type==="VariableDeclaration"){a.left._skipTransformation=!0;const p=a.left.declarations[0];p.id.type==="Identifier"?o.addLoopVariable(p.id.name,p.id.name):p.id.type==="ArrayPattern"&&p.id.elements.forEach(h=>{h.type==="Identifier"&&o.addLoopVariable(h.name,h.name)})}if(a.right){a.right.type==="Identifier"?(le(a.right,o),a.right.type==="Identifier"&&ke(a.right)):l(a.right,o);const p=a.left&&a.left.type==="VariableDeclaration"&&a.left.declarations[0].id.type==="ArrayPattern"?"entries":"iter",h={...a.right},f=E.createCallExpression(E.createMemberExpression(E.createIdentifier("$"),E.createIdentifier(p),!1),[h]);Object.assign(a.right,f)}const c=o.getNextLoopGuardName(),u=tn(c);if(o.addHoistedStatement(u.counterDecl),a.body&&l(a.body,o),a.body&&a.body.type==="BlockStatement"&&a.body.body.unshift(u.guardCheck),a.left&&a.left.type==="VariableDeclaration"){const p=a.left.declarations[0];p.id.type==="Identifier"?o.removeLoopVariable(p.id.name):p.id.type==="ArrayPattern"&&p.id.elements.forEach(h=>{h.type==="Identifier"&&o.removeLoopVariable(h.name)})}},ForInStatement(a,o,l){a.left&&a.left.type==="VariableDeclaration"&&(a.left._skipTransformation=!0),a.right&&a.right.type==="Identifier"?(le(a.right,o),a.right.type==="Identifier"&&ke(a.right)):a.right&&l(a.right,o),a.body&&l(a.body,o)},MemberExpression(a,o,l){a.object&&(a.object.type==="CallExpression"||a.object.type==="MemberExpression")&&(a.object.parent=a,l(a.object,o)),a.object&&a.object.type==="Identifier"&&!o.isContextBound(a.object.name)&&(a.object.parent=a,l(a.object,o)),ye(a,i,o)},AssignmentExpression(a,o,l){if(Yi(a,o),a.type==="CallExpression"&&a.arguments){const c=u=>{u&&(u.type==="CallExpression"&&u.callee&&(u.callee.type==="ArrowFunctionExpression"||u.callee.type==="FunctionExpression")&&l(u.callee,o),u.type==="BinaryExpression"&&(c(u.left),c(u.right)))};a.arguments.forEach(u=>c(u))}},FunctionDeclaration(a,o,l){jy(a,o,l)},ForStatement(a,o,l){Ry(a,o,l)},WhileStatement(a,o,l){Oy(a,o,l)},IfStatement(a,o,l){$y(a,o,l)},SwitchStatement(a,o,l){a.discriminant.parent=a,l(a.discriminant,o),a.cases.forEach(c=>{c.parent=a,l(c,o)})},SwitchCase(a,o,l){a.test&&(a.test.parent=a,l(a.test,o));const c=[];a.consequent.forEach(u=>{o.enterHoistingScope(),l(u,o);const p=o.exitHoistingScope();c.push(...p),c.push(u)}),a.consequent=c},AwaitExpression(a,o,l){a.argument&&(a.argument._insideAwait=!0,l(a.argument,o),a.argument.type==="Identifier"&&a.argument._wasInsideAwait===!0&&(a.type="Identifier",a.name=a.argument.name,a.argument._wasHoisted&&(a._wasHoisted=a.argument._wasHoisted),delete a.argument))}})}const g={NUMBER:"NUMBER",STRING:"STRING",BOOLEAN:"BOOLEAN",IDENTIFIER:"IDENTIFIER",KEYWORD:"KEYWORD",OPERATOR:"OPERATOR",LPAREN:"LPAREN",RPAREN:"RPAREN",LBRACKET:"LBRACKET",RBRACKET:"RBRACKET",LBRACE:"LBRACE",RBRACE:"RBRACE",COMMA:"COMMA",DOT:"DOT",COLON:"COLON",SEMICOLON:"SEMICOLON",INDENT:"INDENT",DEDENT:"DEDENT",NEWLINE:"NEWLINE",COMMENT:"COMMENT",EOF:"EOF"},Wy=new Set(["if","else","for","while","switch","break","continue","var","varip","type","and","or","not","to","by","in","import","export","method","extends","enum"]),Uy=["==","!=","<=",">=",":=","+=","-=","*=","/=","%=","=>","//","and","or","not"];class qy{constructor(e,i,r,n,s=0){this.type=e,this.value=i,this.line=r,this.column=n,this.indent=s}}var zy=Object.defineProperty,Ky=(t,e,i)=>e in t?zy(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,nt=(t,e,i)=>Ky(t,typeof e!="symbol"?e+"":e,i);class Hy{constructor(e){nt(this,"source"),nt(this,"pos"),nt(this,"line"),nt(this,"column"),nt(this,"tokens"),nt(this,"indentStack"),nt(this,"atLineStart"),nt(this,"parenDepth"),nt(this,"bracketDepth"),nt(this,"braceDepth"),this.source=e,this.pos=0,this.line=1,this.column=1,this.tokens=[],this.indentStack=[0],this.atLineStart=!0,this.parenDepth=0,this.bracketDepth=0,this.braceDepth=0}tokenize(){for(;this.pos<this.source.length;){const e=this.peek();if(e==="\r"){this.advance();continue}if(e===`
|
|
18
18
|
`){this.handleNewline();continue}if(this.atLineStart&&e!==`
|
|
19
19
|
`){this.handleIndentation(),this.atLineStart=!1;continue}if(e===" "||e===" "){this.advance();continue}if(this.pos>=this.source.length)break;if(e==="/"&&this.peek(1)==="/"){this.readComment();continue}if(e==='"'||e==="'"){this.readString();continue}if(e==="#"){this.readColorLiteral();continue}if(this.isDigit(e)){this.readNumber();continue}if(this.isIdentifierStart(e)){this.readIdentifier();continue}if(!this.readOperatorOrPunctuation())throw new Error(`Unexpected character '${e}' at ${this.line}:${this.column}`)}for(;this.indentStack.length>1;)this.indentStack.pop(),this.addToken(g.DEDENT,"",this.getCurrentIndent());return this.addToken(g.EOF,""),this.tokens}handleNewline(){this.parenDepth===0&&this.bracketDepth===0&&this.braceDepth===0&&(this.addToken(g.NEWLINE,`
|
|
20
20
|
`),this.atLineStart=!0),this.advance(),this.line++,this.column=1}handleIndentation(){let e=0,i=0;for(this.pos;this.pos<this.source.length;){const n=this.peek();if(n===" ")i++,this.advance();else if(n===" ")e++,this.advance();else break}if(this.peek()===`
|
|
@@ -121,5 +121,5 @@ ${t}
|
|
|
121
121
|
`),this.indent--,this.write(this.indentStr.repeat(this.indent)),this.write("})()")}generateSequenceExpression(e){this.write("(");for(let i=0;i<e.expressions.length;i++)this.generateExpression(e.expressions[i]),i<e.expressions.length-1&&this.write(", ");this.write(")")}getPrecedence(e){switch(e.type){case"Literal":case"Identifier":case"ArrayExpression":case"ObjectExpression":return 20;case"CallExpression":case"MemberExpression":return 19;case"UnaryExpression":case"UpdateExpression":return 15;case"BinaryExpression":case"LogicalExpression":switch(e.operator){case"*":case"/":case"%":return 13;case"+":case"-":return 12;case"<":case"<=":case">":case">=":return 10;case"==":case"!=":return 9;case"and":case"&&":return 5;case"or":case"||":return 4;default:return 0}case"ConditionalExpression":return 3;case"AssignmentExpression":case"AssignmentPattern":return 2;case"SequenceExpression":return 1;default:return 0}}}function Ta(t){const e=/^\s*\/\/\s*@version\s*=\s*(\d+)\s*$/im,i=t.match(e);return i&&i[1]?parseInt(i[1],10):null}function rn(t,e={}){const i=Ta(t);if(i===null)return{success:!1,version:null,error:"Pine Script version not found. Please add //@version=X comment to your script."};if(i<5)return{success:!1,version:i,error:`Pine Script version ${i} is not supported. Only version 5 and above are supported.`};try{const r=new Hy(t).tokenize(),n=new a_(r).parse(),s={...e,sourceCode:t},a=new u_(s).generate(n);return{success:!0,version:i,code:a,ast:n,tokens:r}}catch(r){return{success:!1,version:i,error:r.message,stack:r.stack}}}const h_=new Set(["security_lower_tf","security"]),Aa=new Set(["type","loc","start","end","range","parent","leadingComments","trailingComments"]);function p_(t){if(!t||t.type!=="CallExpression")return!1;const e=t.callee;return!e||e.type!=="MemberExpression"||e.computed||e.object?.type!=="Identifier"||e.object.name!=="request"||e.property?.type!=="Identifier"?!1:h_.has(e.property.name)}function f_(t){const e=t?.arguments?.[2];return e?.type==="Identifier"&&typeof e.name=="string"?e.name:null}function d_(t){const e=[],i=new WeakSet;function r(n,s){if(!n||typeof n!="object"||i.has(n))return;i.add(n);const a=s.concat([n]);p_(n)&&e.push({call:n,path:a});for(const o of Object.keys(n)){if(Aa.has(o))continue;const l=n[o];if(Array.isArray(l))for(const c of l)r(c,a);else l&&typeof l=="object"&&r(l,a)}}return r(t,[]),e}function Vr(t){return t?t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression"||t.type==="FunctionDeclaration":!1}function ot(t,e,i){if(i>=e.length-1)return t;const r=e[i+1];switch(t.type){case"BlockStatement":{const n=t.body.indexOf(r);if(n<0)return t;const s=t.body.slice(0,n);return s.push(ot(r,e,i+1)),{...t,body:s}}case"IfStatement":return r===t.test?{...t,test:ot(r,e,i+1),consequent:{type:"BlockStatement",body:[]},alternate:null}:r===t.consequent?{...t,consequent:ot(r,e,i+1),alternate:null}:r===t.alternate?{...t,alternate:ot(r,e,i+1)}:t;case"ForStatement":case"WhileStatement":case"DoWhileStatement":case"ForInStatement":case"ForOfStatement":return r===t.body?{...t,body:ot(r,e,i+1)}:t;case"SwitchStatement":{const n=t.cases.indexOf(r);if(n>=0){const s=t.cases.slice(0,n);return s.push(ot(r,e,i+1)),{...t,cases:s}}return t}case"SwitchCase":{const n=t.consequent.indexOf(r);if(n>=0){const s=t.consequent.slice(0,n);return s.push(ot(r,e,i+1)),{...t,consequent:s}}return t}case"FunctionDeclaration":case"FunctionExpression":case"ArrowFunctionExpression":return r===t.body?{...t,body:ot(r,e,i+1)}:t;default:return t}}function m_(t){if(!t||t.type!=="CallExpression")return null;const e=t.callee;if(!e||e.type!=="MemberExpression"||e.computed||e.object?.type!=="Identifier"||e.object.name!=="$"||e.property?.type!=="Identifier"||e.property.name!=="call")return null;const i=t.arguments?.[0];return i?.type==="Identifier"&&typeof i.name=="string"?i.name:null}function y_(t,e,i){const r=t.body||[];for(let n=0;n<r.length;n++){const s=r[n];if(s!==i&&__(s,e))return n}return-1}function __(t,e){let i=!1;const r=new WeakSet;function n(s){if(!(i||!s||typeof s!="object")&&!r.has(s)){if(r.add(s),m_(s)===e){i=!0;return}for(const a of Object.keys(s)){if(Aa.has(a))continue;const o=s[a];if(Array.isArray(o))for(const l of o)n(l);else o&&typeof o=="object"&&n(o)}}}return n(t),i}function g_(t,e){let i=-1;for(let h=1;h<e.length;h++)if(Vr(e[h])){i=h;break}if(i<0)return null;const r=e[i];for(let h=i+1;h<e.length;h++)if(Vr(e[h]))return null;if(r.type!=="FunctionDeclaration"||!r.id?.name)return null;const n=r.id.name,s=e.slice(i),a=ot(r,s,0),o=y_(t,n,r);if(o<0)return null;const l=t.body||[],c=l.indexOf(r);if(c<0)return null;const u=[],p=Math.max(o,c);for(let h=0;h<=p;h++){const f=l[h];u.push(f===r?a:f)}return u}function x_(t,e){const i={type:"Program",sourceType:"module",body:[{type:"ExpressionStatement",expression:{type:"ArrowFunctionExpression",async:!!t.async,params:t.params,body:{type:"BlockStatement",body:e}}}]},r=`var _r = ${Qr(i)}
|
|
122
122
|
; return _r;`;return new Function("",r)()}function b_(t){const e={};if(!t||t.type!=="Program"||!Array.isArray(t.body)||t.body.length===0)return e;const i=t.body[0];let r=null;if(i.type==="ExpressionStatement"){const s=i.expression;s&&(s.type==="ArrowFunctionExpression"||s.type==="FunctionExpression")&&(r=s)}else i.type==="FunctionDeclaration"&&(r=i);if(!r||r.body?.type!=="BlockStatement")return e;const n=d_(r.body);for(const{call:s,path:a}of n){const o=f_(s);if(!o||o in e)continue;const l=a.some(p=>Vr(p));let c=null;if(l)c=g_(r.body,a);else{const p=ot(r.body,a,0);c=p&&p.body?p.body:[]}if(!c||c.length===0)continue;const u=x_(r,c);e[o]=u}return e}function v_(t){if(typeof t=="function")return t.toString();{const e=Ta(t);if(e===null)return t;if(e>=5){const i=rn(t);if(i.success)return i.code;throw new Error(`Failed to transpile Pine Script version ${e}: ${i.error}`)}else throw new Error(`Unsupported Pine Script version ${e}. Only version 5 and above are supported.`)}}function w_(t,e={debug:!1,ln:!1}){typeof e=="boolean"&&(e={debug:e,ln:!0});const{debug:i}=e;let r=v_(t);r=Iy(r);const n=i?r.split(`
|
|
123
123
|
`):[],s=Xr(r,{ecmaVersion:"latest",sourceType:"module",locations:i});ky(s),Ey(s),Sy(s);const a=new my;Py(s,a),Ty(s,a);const o=My(s,a)||"";if(Fy(s,a,o,e,n),By(s),Ly(s),s.type==="Program"&&s.body.length>0){const f=s.body[0],d=f?.expression||f;d.body?.type==="BlockStatement"&&d.body.body.unshift({type:"VariableDeclaration",kind:"const",declarations:[{type:"VariableDeclarator",id:{type:"Identifier",name:"__maxLoops"},init:{type:"LogicalExpression",operator:"||",left:{type:"MemberExpression",object:{type:"Identifier",name:"$"},property:{type:"Identifier",name:"__maxLoops"},computed:!1},right:{type:"Literal",value:5e5}}}]})}const l=cy||Zr||void 0,c=Object.assign({},l,{LineComment(f,d){d.write("//"+f.value)}}),u=Qr(s,{generator:c,comments:i}),p=typeof process<"u"&&process?.env?.PINETS_DISABLE_LTF_SLICING==="1"?{}:b_(s),h=new Function("",`var _r = ${u}
|
|
124
|
-
; return _r;`)(this);return p&&Object.keys(p).length>0&&(h._ltfSlices=p),h}const Pa=new Set(["open","high","low","close","hl2","hlc3","ohlc4","hlcc4","volume"]),Kn={"":["defval","title","tooltip","inline","group","display","active"],bool:["defval","title","tooltip","inline","group","confirm","display","active"],color:["defval","title","tooltip","inline","group","confirm","display","active"],enum:["defval","title","options","tooltip","inline","group","confirm","display","active"],price:["defval","title","tooltip","inline","group","confirm","display","active"],session:["defval","title","options","tooltip","inline","group","confirm","display","active"],source:["defval","title","tooltip","inline","group","display","active","confirm"],string:["defval","title","options","tooltip","inline","group","confirm","display","active"],symbol:["defval","title","tooltip","inline","group","confirm","display","active"],text_area:["defval","title","tooltip","group","confirm","display","active"],time:["defval","title","tooltip","inline","group","confirm","display","active"],timeframe:["defval","title","options","tooltip","inline","group","confirm","display","active"]},S_={bool:"bool",color:"color",enum:"enum",float:"float",int:"int",price:"price",session:"session",source:"source",string:"string",symbol:"symbol",text_area:"text_area",time:"time",timeframe:"timeframe"};function E_(t){if(typeof t!="string")return[];const e=rn(t);if(!e.success||!e.ast)return[];const i=N_(e.ast),r=[],n=new Set;return Nt(e.ast,s=>{const a=C_(s,i);if(a){if(a.title!==void 0){if(n.has(a.title)){console.warn(`[Indicator] duplicate input title "${a.title}" \u2014 first declaration wins for .input access`);return}n.add(a.title)}r.push(a)}}),r}function N_(t){const e=new Map;return Nt(t,i=>{if(i.type==="VariableDeclaration")for(const r of i.declarations??[]){const n=r?.id?.name,s=r?.init;if(!n||!s||s.type!=="ObjectExpression"||!(s.properties??[]).every(a=>a.value?.type==="Literal"&&typeof a.value.value=="string")||s.properties.length===0)return;for(const a of s.properties)e.set(`${n}.${a.key.name}`,a.value.value)}}),e}function C_(t,e){if(t.type!=="VariableDeclaration")return null;for(const i of t.declarations??[]){const r=i?.init;if(!r||r.type!=="CallExpression")continue;const n=r.callee;let s=null;if(n?.type==="MemberExpression"&&n.object?.type==="Identifier"&&n.object.name==="input"&&n.property?.type==="Identifier"?s=n.property.name:n?.type==="Identifier"&&n.name==="input"&&(s=""),s===null||s!==""&&!(s==="int"||s==="float")&&!(s in Kn))continue;const a=r.arguments??[],o=a[a.length-1],l=o?.type==="ObjectExpression",c=l?a.slice(0,-1):a.slice(),u=l?o.properties??[]:[],p={};s==="int"||s==="float"?I_(c,u,p):Da(Kn[s],c,p);for(const m of u)m.type!=="Property"||!m.key?.name||(p[m.key.name]=m.value);const h={};for(const m of Object.keys(p))h[m]=Ma(p[m],e);const f=s===""?k_(h.defval):S_[s];if(!f)continue;const d={type:f,defval:h.defval};return h.title!==void 0&&(d.title=String(h.title)),h.tooltip!==void 0&&(d.tooltip=String(h.tooltip)),h.group!==void 0&&(d.group=String(h.group)),h.inline!==void 0&&(d.inline=String(h.inline)),h.confirm!==void 0&&(d.confirm=!!h.confirm),h.active!==void 0&&(d.active=!!h.active),h.display!==void 0&&(d.display=T_(h.display)),h.options!==void 0&&Array.isArray(h.options)&&(d.options=h.options),typeof h.minval=="number"&&(d.minval=h.minval),typeof h.maxval=="number"&&(d.maxval=h.maxval),typeof h.step=="number"&&(d.step=h.step),d}return null}function I_(t,e,i){const r=new Set(e.map(n=>n.key?.name).filter(Boolean)).has("options")||t[2]?.type==="ArrayExpression"?["defval","title","options","tooltip","inline","group","confirm","display","active"]:["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display","active"];Da(r,t,i)}function Da(t,e,i){for(let r=0;r<e.length&&r<t.length;r++){const n=t[r];i[n]===void 0&&(i[n]=e[r])}}function Ma(t,e){if(t!=null)switch(t.type){case"Literal":return t.value;case"Identifier":return Pa.has(t.name),t.name;case"MemberExpression":{const i=t.object?.type==="Identifier"?t.object.name:null,r=t.property?.type==="Identifier"?t.property.name:null;if(i&&r){const n=`${i}.${r}`;return e.has(n)?e.get(n):i==="display"?r:n}return}case"ArrayExpression":return(t.elements??[]).map(i=>Ma(i,e));case"UnaryExpression":return t.operator==="-"&&t.argument?.type==="Literal"&&typeof t.argument.value=="number"?-t.argument.value:void 0;default:return}}function k_(t){return typeof t=="boolean"?"bool":typeof t=="number"?Number.isInteger(t)?"int":"float":typeof t=="string"?Pa.has(t)?"source":t.startsWith("#")?"color":"string":null}function T_(t){if(typeof t!="string")return;const e=t.startsWith("display.")?t.slice(8):t;if(e==="none"||e==="data_window"||e==="status_line"||e==="all")return e}function Nt(t,e){if(!(!t||typeof t!="object")){if(e(t),Array.isArray(t.body))for(const i of t.body)Nt(i,e);else t.body&&Nt(t.body,e);if(Array.isArray(t.consequent))for(const i of t.consequent)Nt(i,e);else t.consequent&&Nt(t.consequent,e);if(t.alternate&&Nt(t.alternate,e),Array.isArray(t.declarations))for(const i of t.declarations)Nt(i,e)}}function Ra(t,e,i,r,n="key"){const s={},a=new Map;for(const o of t)a.set(o.key,o),s[o.key]=r&&o.key in r?r[o.key]:o.defval;return{proxy:new Proxy(s,{get(o,l){return o[l]},set(o,l,c){if(typeof l!="string")return!1;const u=a.get(l);if(!u)throw new Error(`[${e}] unknown ${n} "${l}". Known: ${[...a.keys()].join(", ")||"(none)"}`);return A_(u,c,e),o[l]=c,i?.(l),!0},deleteProperty(o,l){throw new Error(`[${e}] cannot delete "${String(l)}" \u2014 keys are fixed by the script's source.`)},defineProperty(){throw new Error(`[${e}] cannot define new properties \u2014 keys are fixed by the script's source.`)},ownKeys(o){return Reflect.ownKeys(o)},getOwnPropertyDescriptor(o,l){return Reflect.getOwnPropertyDescriptor(o,l)},has(o,l){return typeof l=="string"&&l in o}}),values:s,entryByKey:a}}function A_(t,e,i){const r=t.key;switch(t.type){case"int":if(typeof e!="number"||!Number.isInteger(e))throw new TypeError(`[${i}] "${r}" expects an int; got ${Zt(e)}`);break;case"float":case"price":case"time":if(typeof e!="number"||!Number.isFinite(e))throw new TypeError(`[${i}] "${r}" expects a number; got ${Zt(e)}`);break;case"bool":if(typeof e!="boolean")throw new TypeError(`[${i}] "${r}" expects a boolean; got ${Zt(e)}`);break;case"string":case"session":case"symbol":case"timeframe":case"text_area":case"color":case"enum":case"source":if(typeof e!="string")throw new TypeError(`[${i}] "${r}" expects a string; got ${Zt(e)}`);break}if(t.options&&!t.options.some(n=>P_(n,e)))throw new RangeError(`[${i}] "${r}" value ${Zt(e)} is not one of: ${t.options.map(Zt).join(", ")}`);if(typeof e=="number"){if(typeof t.minval=="number"&&e<t.minval)throw new RangeError(`[${i}] "${r}" value ${e} is below minval ${t.minval}`);if(typeof t.maxval=="number"&&e>t.maxval)throw new RangeError(`[${i}] "${r}" value ${e} is above maxval ${t.maxval}`)}}function P_(t,e){return t===e?!0:typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<1e-12:!1}function Zt(t){return t===null?"null":typeof t=="string"?JSON.stringify(t):String(t)}function D_(t,e){const i=new Map,r=[];for(const a of t)a.title&&(i.set(a.title,a),r.push({key:a.title,type:a.type,defval:a.defval,options:a.options,minval:a.minval,maxval:a.maxval}));const{proxy:n,values:s}=Ra(r,"Indicator.input",e,void 0,"input title");return{proxy:n,values:s,metaByTitle:i}}const Oa=[{name:"title",type:"string",defval:"",mutable:!1,appliesTo:"both"},{name:"shorttitle",type:"string",defval:"",mutable:!1,appliesTo:"both"},{name:"overlay",type:"bool",defval:!1,mutable:!0,appliesTo:"both"},{name:"format",type:"enum",defval:"inherit",options:["inherit","price","volume","percent","mintick"],mutable:!0,appliesTo:"both"},{name:"precision",type:"int",defval:10,minval:0,maxval:16,mutable:!0,appliesTo:"both"},{name:"scale",type:"enum",defval:"right",options:["right","left","none"],mutable:!0,appliesTo:"both"},{name:"max_bars_back",type:"int",defval:0,minval:0,maxval:5e3,mutable:!0,appliesTo:"both"},{name:"explicit_plot_zorder",type:"bool",defval:!1,mutable:!0,appliesTo:"both"},{name:"max_lines_count",type:"int",defval:50,minval:1,maxval:500,mutable:!0,appliesTo:"both"},{name:"max_labels_count",type:"int",defval:50,minval:1,maxval:500,mutable:!0,appliesTo:"both"},{name:"max_boxes_count",type:"int",defval:50,minval:1,maxval:500,mutable:!0,appliesTo:"both"},{name:"calc_bars_count",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"both"},{name:"max_polylines_count",type:"int",defval:50,minval:1,maxval:100,mutable:!0,appliesTo:"both"},{name:"dynamic_requests",type:"bool",defval:!0,mutable:!0,appliesTo:"both",version:6},{name:"behind_chart",type:"bool",defval:!0,mutable:!0,appliesTo:"both",version:6}],$a=[...Oa.filter(t=>t.appliesTo==="both").map(t=>({...t,appliesTo:"indicator"})),{name:"timeframe",type:"string",defval:"",mutable:!0,appliesTo:"indicator"},{name:"timeframe_gaps",type:"bool",defval:!0,mutable:!0,appliesTo:"indicator"}],Va=[...Oa.filter(t=>t.appliesTo==="both").map(t=>({...t,appliesTo:"strategy"})),{name:"pyramiding",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"calc_on_order_fills",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"calc_on_every_tick",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"backtest_fill_limits_assumption",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"default_qty_type",type:"enum",defval:"fixed",options:["fixed","cash","percent_of_equity"],mutable:!0,appliesTo:"strategy"},{name:"default_qty_value",type:"float",defval:1,minval:0,mutable:!0,appliesTo:"strategy"},{name:"initial_capital",type:"float",defval:1e6,minval:0,mutable:!0,appliesTo:"strategy"},{name:"currency",type:"enum",defval:"USD",options:["AED","ARS","AUD","BDT","BHD","BRL","BTC","CAD","CHF","CLP","CNY","COP","CZK","DKK","EGP","ETH","EUR","GBP","HKD","HUF","IDR","ILS","INR","ISK","JPY","KES","KRW","KWD","LKR","MAD","MXN","MYR","NGN","NOK","NONE","NZD","PEN","PHP","PKR","PLN","QAR","RON","RSD","RUB","SAR","SEK","SGD","THB","TND","TRY","TWD","USD","USDT","VES","VND","ZAR"],mutable:!0,appliesTo:"strategy"},{name:"slippage",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"commission_type",type:"enum",defval:"percent",options:["percent","cash_per_contract","cash_per_order"],mutable:!0,appliesTo:"strategy"},{name:"commission_value",type:"float",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"process_orders_on_close",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"close_entries_rule",type:"enum",defval:"FIFO",options:["FIFO","ANY"],mutable:!0,appliesTo:"strategy"},{name:"margin_long",type:"float",defval:100,minval:0,maxval:100,mutable:!0,appliesTo:"strategy"},{name:"margin_short",type:"float",defval:100,minval:0,maxval:100,mutable:!0,appliesTo:"strategy"},{name:"risk_free_rate",type:"float",defval:2,mutable:!0,appliesTo:"strategy"},{name:"use_bar_magnifier",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"fill_orders_on_standard_ohlc",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"}];function M_(t){return t==="strategy"?Va:$a}function R_(t){return typeof t=="string"?O_(t):typeof t=="function"?$_(t):{type:null,args:{}}}function O_(t){const e=rn(t);if(!e.success||!e.ast)return{type:null,args:{}};let i=null;return Xi(e.ast,r=>{if(i||r.type!=="ExpressionStatement"&&r.type!=="VariableDeclaration")return;const n=r.type==="ExpressionStatement"?r.expression:r.declarations?.[0]?.init;if(!n||n.type!=="CallExpression")return;const s=n.callee;s?.type==="Identifier"&&(s.name!=="indicator"&&s.name!=="strategy"||(i={type:s.name,args:La(n.arguments??[],ja(s.name))}))}),i??{type:null,args:{}}}function $_(t){let e;try{e=Xr(`(${t.toString()})`,{ecmaVersion:"latest"})}catch{return{type:null,args:{}}}let i=null;return Xi(e,r=>{if(i||r.type!=="CallExpression")return;const n=r.callee;n?.type==="Identifier"&&(n.name!=="indicator"&&n.name!=="strategy"||(i={type:n.name,args:La(r.arguments??[],ja(n.name))}))}),i??{type:null,args:{}}}function ja(t){return t==="strategy"?Va:$a}function La(t,e){const i={},r=t[t.length-1],n=r?.type==="ObjectExpression",s=n?t.slice(0,-1):t.slice();for(let a=0;a<s.length&&a<e.length;a++){const o=e[a].name;i[o]=jr(s[a])}if(n)for(const a of r.properties??[])a.type!=="Property"||!a.key?.name||(i[a.key.name]=jr(a.value));return i}function jr(t){if(t!=null)switch(t.type){case"Literal":return t.value;case"Identifier":return t.name;case"MemberExpression":{let e=t;for(;e?.type==="MemberExpression";)e=e.property;return e?.type==="Identifier"?e.name:void 0}case"UnaryExpression":return t.operator==="-"&&t.argument?.type==="Literal"&&typeof t.argument.value=="number"?-t.argument.value:void 0;case"ArrayExpression":return(t.elements??[]).map(jr);default:return}}function Xi(t,e){if(!(!t||typeof t!="object")){e(t);for(const i of Object.keys(t)){const r=t[i];if(!(i==="loc"||i==="range"||i==="start"||i==="end"))if(Array.isArray(r))for(const n of r)Xi(n,e);else r&&typeof r=="object"&&typeof r.type=="string"&&Xi(r,e)}}}function V_(t,e,i){const r=new Map,n=[];for(const o of t)r.set(o.name,o),o.mutable&&n.push({key:o.name,type:o.type,defval:o.defval,options:o.options,minval:o.minval,maxval:o.maxval});const{proxy:s,values:a}=Ra(n,"Indicator.prop",i,e);return{proxy:s,values:a,propByName:r}}var j_=Object.defineProperty,L_=(t,e,i)=>e in t?j_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,je=(t,e,i)=>L_(t,typeof e!="symbol"?e+"":e,i);class vi{constructor(e,i={}){je(this,"source"),je(this,"inputs"),je(this,"_prepared",null),je(this,"_inputMeta",null),je(this,"_inputValues",{}),je(this,"_explicitOverrides",new Set),je(this,"_inputProxy",null),je(this,"_propMeta",null),je(this,"_propValues",{}),je(this,"_propProxy",null),je(this,"_declarationType",null),je(this,"_sourcePropArgs",{}),je(this,"_explicitPropOverrides",new Set),this.source=e,this.inputs=i,Object.defineProperty(this,"input",{get:()=>this._getInputProxy(),set:()=>{throw new Error('[Indicator] .input cannot be replaced \u2014 mutate individual keys (e.g. ind.input["My Title"] = 20).')},enumerable:!0,configurable:!1}),Object.defineProperty(this,"prop",{get:()=>this._getPropProxy(),set:()=>{throw new Error('[Indicator] .prop cannot be replaced \u2014 mutate individual keys (e.g. ind.prop["initial_capital"] = 50000).')},enumerable:!0,configurable:!1})}static from(e){return e instanceof vi?e:new vi(e)}prepare(e={}){if(this._prepared)return this._prepared;const i=w_(this.source,{debug:!!e.debug,ln:e.ln}),r=B_(i),n=i._ltfSlices;return this._prepared={fn:i,inputs:this.getRuntimeInputs(),usesVisibleRange:r,ltfSlices:n},this._prepared}usesVisibleRange(){return this.prepare().usesVisibleRange}getRuntimeInputs(){const e={...this.inputs??{}};if(this._inputMeta)for(const i of this._explicitOverrides)e[i]=this._inputValues[i];return e}getInputsMeta(){return this._ensureInputsScanned(),this._inputMeta}getPropsMeta(){return this._ensurePropsScanned(),this._propMeta}getRuntimePropOverrides(){const e={};if(this._propMeta)for(const i of this._explicitPropOverrides)e[i]=this._propValues[i];return e}getDeclarationType(){return this._ensurePropsScanned(),this._declarationType}_ensureInputsScanned(){if(this._inputMeta)return;this._inputMeta=E_(this.source);const e=D_(this._inputMeta,i=>this._explicitOverrides.add(i));this._inputValues=e.values,this._inputProxy=e.proxy}_getInputProxy(){return this._ensureInputsScanned(),this._inputProxy}_ensurePropsScanned(){if(this._propMeta)return;const e=R_(this.source);this._declarationType=e.type,this._sourcePropArgs=e.args,this._propMeta=M_(e.type);const i=V_(this._propMeta,this._sourcePropArgs,r=>this._explicitPropOverrides.add(r));this._propValues=i.values,this._propProxy=i.proxy}_getPropProxy(){return this._ensurePropsScanned(),this._propProxy}}function B_(t){const e=t.toString();return xy.some(i=>{const r=i.replace(/\./g,"\\.");return new RegExp(`\\b${r}\\b`).test(e)})}var F_=Object.defineProperty,W_=(t,e,i)=>e in t?F_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Q=(t,e,i)=>W_(t,typeof e!="symbol"?e+"":e,i);const Hn={1:6e4,3:18e4,5:3e5,15:9e5,30:18e5,60:36e5,120:72e5,180:108e5,240:144e5,"4H":144e5,"1D":864e5,D:864e5,"1W":6048e5,W:6048e5,"1M":30*864e5,M:30*864e5};function U_(t){return t?Hn[t]??Hn[t.toUpperCase()]??864e5:864e5}class nn{constructor(e,i,r,n,s,a){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=n,this.sDate=s,this.eDate=a,Q(this,"data",[]),Q(this,"open",[]),Q(this,"high",[]),Q(this,"low",[]),Q(this,"close",[]),Q(this,"volume",[]),Q(this,"hl2",[]),Q(this,"hlc3",[]),Q(this,"ohlc4",[]),Q(this,"hlcc4",[]),Q(this,"openTime",[]),Q(this,"closeTime",[]),Q(this,"_readyPromise",null),Q(this,"_ready",!1),Q(this,"_debugSettings",{ln:!1,debug:!1}),Q(this,"_transpiledCode",null),Q(this,"_currentIndicator",null),Q(this,"_isSecondaryContext",!1),Q(this,"_syminfo"),Q(this,"_chartTimezone",null),Q(this,"_maxLoops",5e5),Q(this,"_alertMode","realtime"),Q(this,"_viewportLeft"),Q(this,"_viewportRight"),Q(this,"_usesVisibleRange",!1),Q(this,"_lastRunViewport",{}),Q(this,"_lastResult",null),Q(this,"_lastPineTSCode",null),this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,n,s,a).then(l=>{const c=l;this.data=c;const u=c.map(N=>N.open),p=c.map(N=>N.close),h=c.map(N=>N.high),f=c.map(N=>N.low),d=c.map(N=>N.volume),m=c.map(N=>(N.high+N.low+N.close)/3),x=c.map(N=>(N.high+N.low)/2),b=c.map(N=>(N.high+N.low+N.open+N.close)/4),v=c.map(N=>(N.high+N.low+N.close+N.close)/4),w=c.map(N=>N.openTime),E=U_(this.timeframe),T=c.map(N=>N.closeTime!=null?N.closeTime:N.openTime+E);this.open=u,this.close=p,this.high=h,this.low=f,this.volume=d,this.hl2=x,this.hlc3=m,this.ohlc4=b,this.hlcc4=v,this.openTime=w,this.closeTime=T,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(N=>{this._syminfo=N,this._ready=!0,o(!0)}).catch(N=>{console.warn("Failed to get symbol info, using default values:",N),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}get transpiledCode(){return this._transpiledCode}markAsSecondary(){this._isSecondaryContext=!0}setTimezone(e){this._chartTimezone=e}setMaxLoops(e){this._maxLoops=e}setAlertMode(e){this._alertMode=e}setVisibleRange(e,i){this._viewportLeft=e,this._viewportRight=i}usesVisibleRange(){return this._usesVisibleRange}get visibleRangeLeft(){return this._viewportLeft}get visibleRangeRight(){return this._viewportRight}async update(e){const i=e??this._lastPineTSCode;if(!i)throw new Error("pine.update(): pineTSCode is required on the first call.");const r=this._lastResult===null,n=this._viewportLeft!==this._lastRunViewport.left||this._viewportRight!==this._lastRunViewport.right;return r||this._usesVisibleRange&&n?(this._lastPineTSCode=i,this._lastRunViewport={left:this._viewportLeft,right:this._viewportRight},this._lastResult=await this.run(i),this._lastResult):this._lastResult}setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,n,s,a){return Array.isArray(e)?e:e.getMarketData(i,r,n,s,a)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(e,i,r){const n=vi.from(e);if(this._currentIndicator=n,r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(n,i,r,s)}else return this._runComplete(n,i)}stream(e,i={}){const{live:r=!0,interval:n=1e3}=i,s=i.pageSize||this.data.length,a=vi.from(e);this._currentIndicator=a;const o={data:[],error:[],warning:[],alert:[]};let l=!1;const c=(h,...f)=>{o[h]&&o[h].forEach(d=>d(...f))},u=(h,f)=>{o[h]||(o[h]=[]),o[h].push(f)},p=()=>{l=!0};return(async()=>{try{r&&typeof this.eDate<"u"&&(this.eDate=Math.max(this.eDate,Date.now()));const h=!Array.isArray(this.source)&&r,f=this._runPaginated(a,void 0,s,h);for await(const d of f){if(l)break;if(d===null){await new Promise(m=>setTimeout(m,n));continue}if(c("data",d),d.warnings&&d.warnings.length>0){for(const m of d.warnings)c("warning",m);d.warnings.length=0}if(d.alerts&&d.alerts.length>0){for(const m of d.alerts)c("alert",m);d.alerts.length=0}if(h&&!l){const m=d.marketData[d.idx],x=m&&m.closeTime<Date.now(),b=d.idx>=d.marketData.length-1;(!x||b)&&await new Promise(v=>setTimeout(v,n))}}}catch(h){c("error",h)}})(),{on:u,stop:p}}async runPretranspiled(e,i={},r){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(null,i,this._isSecondaryContext);this._transpiledCode=e;const s=e._ltfSlices;return s&&(n._ltfTruncatedBodies=s),await this._executeIterations(n,e,this.data.length-r,this.data.length),n}async _runComplete(e,i){await this.ready(),i||(i=this.data.length);const r=e.prepare(this._debugSettings);this._usesVisibleRange=r.usesVisibleRange;const n=this._initializeContext(e.source??null,r.inputs,this._isSecondaryContext);this._transpiledCode=r.fn,r.ltfSlices&&(n._ltfTruncatedBodies=r.ltfSlices);const s=this.data.length-i,a=this.data.length;return a-s>1?(await this._executeIterations(n,r.fn,s,a-1),n._varSnapshot=this._snapshotVarState(n),await this._executeIterations(n,r.fn,a-1,a)):await this._executeIterations(n,r.fn,s,a),n}async*_runPaginated(e,i,r,n=!1){await this.ready(),i||(i=this.data.length);const s=e.prepare(this._debugSettings);this._usesVisibleRange=s.usesVisibleRange;const a=this._initializeContext(e.source??null,s.inputs,this._isSecondaryContext);this._transpiledCode=s.fn,s.ltfSlices&&(a._ltfTruncatedBodies=s.ltfSlices);let o=this.data.length-i,l=null;for(;;){const c=this.data.length,u=c-o;if(u>0){const m=Math.min(u,r),x=this._getResultLength(a.result),b=o+m;n&&b>=c&&m>1?(await this._executeIterations(a,this._transpiledCode,o,b-1),l=this._snapshotVarState(a),await this._executeIterations(a,this._transpiledCode,b-1,b)):n&&b>=c&&m===1?await this._executeIterations(a,this._transpiledCode,o,b):await this._executeIterations(a,this._transpiledCode,o,b),o+=m,yield this._createPageContext(a,x);continue}if(!n||Array.isArray(this.source))break;const p=Date.now(),{newCandles:h,updatedLastCandle:f}=await this._updateMarketData(),d=Date.now()-p;if(h===0&&!f){yield null;continue}if(h===0&&f&&d<1e3&&await new Promise(m=>setTimeout(m,1e3-d)),a.dataVersion++,a.length=this.data.length,this._restoreVarState(a,l),Array.isArray(a.result))a.result.pop();else if(typeof a.result=="object"&&a.result!==null)for(let m in a.result)Array.isArray(a.result[m])&&a.result[m].pop();a.data.close.data.pop(),a.data.open.data.pop(),a.data.high.data.pop(),a.data.low.data.pop(),a.data.volume.data.pop(),a.data.hl2.data.pop(),a.data.hlc3.data.pop(),a.data.ohlc4.data.pop(),a.data.hlcc4.data.pop(),a.data.openTime.data.pop(),a.data.closeTime&&a.data.closeTime.data.pop(),a.data.bar_index.data.pop(),o=this.data.length-(h+1),a.rollbackDrawings(o),h>0&&(l=null),a.pine.barstate.setLive()}}_getResultLength(e){if(Array.isArray(e))return e.length;if(typeof e=="object"&&e!==null){const i=Object.keys(e);if(i.length>0&&Array.isArray(e[i[0]]))return e[i[0]].length}return 0}_createPageContext(e,i){const r=new wn({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:e,inputs:e.inputs});if(r.pineTSCode=e.pineTSCode,r.idx=e.idx,Array.isArray(e.result))r.result=e.result.slice(i);else if(typeof e.result=="object"&&e.result!==null){r.result={};for(let n in e.result)Array.isArray(e.result[n])?r.result[n]=e.result[n].slice(i):r.result[n]=e.result[n]}else r.result=e.result;return r.plots={...e.plots},r.warnings=e.warnings,r.alerts=e.alerts,r}async _updateMarketData(e){if(Array.isArray(this.source))return{newCandles:0,updatedLastCandle:!1};const i=this.source,r=this.data.length-1,n=this.data[r].openTime;try{const s=await i.getMarketData(this.tickerId,this.timeframe,void 0,n,e);if(!s||s.length===0)return{newCandles:0,updatedLastCandle:!1};let a=!1,o=0;for(let l=0;l<s.length;l++){const c=s[l];c.openTime===n?(this._replaceCandle(r,c),a=!0):c.openTime>n&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:a}}catch(s){return console.error("Error updating market data:",s),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(e,i){this.data[e]=i,this.open[e]=i.open,this.close[e]=i.close,this.high[e]=i.high,this.low[e]=i.low,this.volume[e]=i.volume,this.hl2[e]=(i.high+i.low)/2,this.hlc3[e]=(i.high+i.low+i.close)/3,this.ohlc4[e]=(i.high+i.low+i.open+i.close)/4,this.hlcc4[e]=(i.high+i.low+i.close+i.close)/4,this.openTime[e]=i.openTime,this.closeTime[e]=i.closeTime}_appendCandle(e){this.data.push(e),this.open.push(e.open),this.close.push(e.close),this.high.push(e.high),this.low.push(e.low),this.volume.push(e.volume),this.hl2.push((e.high+e.low)/2),this.hlc3.push((e.high+e.low+e.close)/3),this.ohlc4.push((e.high+e.low+e.open+e.close)/4),this.hlcc4.push((e.high+e.low+e.close+e.close)/4),this.openTime.push(e.openTime),this.closeTime.push(e.closeTime)}async updateTail(e){if(this.data.length===0||Array.isArray(this.source))return!1;const{newCandles:i,updatedLastCandle:r}=await this._updateMarketData();if(i===0&&!r)return!1;const n=e._varSnapshot;if(n?this._restoreVarState(e,n):this._removeLastResult(e),Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let o in e.result)Array.isArray(e.result[o])&&e.result[o].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop(),e.data.bar_index.data.pop(),e.dataVersion=(e.dataVersion||0)+1,e.length=this.data.length;const s=this.data.length-(i+1);e.rollbackDrawings(s);const a=this.data.length;return s<a-1?(await this._executeIterations(e,this._transpiledCode,s,a-1),e._varSnapshot=this._snapshotVarState(e),await this._executeIterations(e,this._transpiledCode,a-1,a)):await this._executeIterations(e,this._transpiledCode,s,a),!0}_removeLastResult(e){if(Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let n in e.result)Array.isArray(e.result[n])&&e.result[n].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop(),e.data.bar_index.data.pop();const i=["const","var","let","params"],r=n=>{for(let s of i)if(n[s])for(let a in n[s]){const o=n[s][a];o instanceof y?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(n=>r(n))}_snapshotVarState(e){const i=["const","var","let","params"],r={main:{},lctx:[]},n=s=>{const a={};for(const o of i)if(s[o]){a[o]={};for(const l in s[o]){const c=s[o][l];if(c instanceof y){const u=c.data.length,p=u>0?c.data[u-1]:void 0;a[o][l]={len:u,lastVal:p}}}}return a};if(r.main=n(e),e.lctx){const s=[];e.lctx.forEach(a=>s.push(n(a))),r.lctx=s}return r.resultLength=this._getResultLength(e.result),r.dataLength=e.data.close?.data?.length??0,r}_restoreVarState(e,i){if(!i)return;const r=["const","var","let","params"],n=(s,a)=>{for(const o of r)if(!(!a[o]||!s[o]))for(const l in a[o]){const c=s[o][l],u=a[o][l];c instanceof y&&u&&typeof u.len=="number"&&(c.data.length>u.len&&(c.data.length=u.len),u.len>0&&u.lastVal!==void 0&&(c.data[u.len-1]=u.lastVal))}};if(n(e,i.main),e.lctx&&i.lctx){let s=0;e.lctx.forEach(a=>{i.lctx[s]&&n(a,i.lctx[s]),s++})}}_initializeContext(e,i={},r=!1){const n=new wn({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return n.pine.syminfo=this._syminfo,this._chartTimezone&&(n.chartTimezone=this._chartTimezone),n.viewportLeft=this._viewportLeft,n.viewportRight=this._viewportRight,n.__maxLoops=this._maxLoops,n._alertMode=this._alertMode,n._propOverrides=this._currentIndicator?.getRuntimePropOverrides()??{},n.pineTSCode=e,n.isSecondaryContext=r,n.data.close=new y([]),n.data.open=new y([]),n.data.high=new y([]),n.data.low=new y([]),n.data.volume=new y([]),n.data.hl2=new y([]),n.data.hlc3=new y([]),n.data.ohlc4=new y([]),n.data.hlcc4=new y([]),n.data.openTime=new y([]),n.data.closeTime=new y([]),n.length=this.data.length,n}async _executeIterations(e,i,r,n){const s=["const","var","let","params"];for(let a=r;a<n;a++){e.idx=a,e._execTick=(e._execTick||0)+1,e.data.close.data.push(this.close[a]),e.data.open.data.push(this.open[a]),e.data.high.data.push(this.high[a]),e.data.low.data.push(this.low[a]),e.data.volume.data.push(this.volume[a]),e.data.hl2.data.push(this.hl2[a]),e.data.hlc3.data.push(this.hlc3[a]),e.data.ohlc4.data.push(this.ohlc4[a]),e.data.hlcc4.data.push(this.hlcc4[a]),e.data.openTime.data.push(this.openTime[a]),e.data.closeTime.data.push(this.closeTime[a]),e.data.bar_index.data.push(a),e.strategy&&(Sp(e),Tp(e),Ap(e),Pp(e));const o=await i(e);if(typeof o=="object"){typeof e.result!="object"&&(e.result={});for(let c in o){e.result[c]===void 0&&(e.result[c]=[]);let u;o[c]instanceof y?u=o[c].get(0):Array.isArray(o[c])?u=o[c][o[c].length-1]:u=o[c],e.result[c].push(u)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);for(const c of e._drawingHelpers)c.syncToPlot&&c.syncToPlot();const l=c=>{for(let u of s)if(c[u])for(let p in c[u]){const h=c[u][p];if(h instanceof y){const f=h.get(0);h.data.push(f)}else if(Array.isArray(h)){const f=h[h.length-1];h.push(f)}}};l(e),e.lctx&&e.lctx.forEach(c=>l(c))}}}const Gn={"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6},gi={"1S":1,"5S":5,"10S":10,"15S":15,"30S":30,1:60,3:180,5:300,15:900,30:1800,45:2700,60:3600,120:7200,180:10800,240:14400,D:86400,W:604800,M:2592e3},Ag={"1S":{periodType:"second",multiplier:1},"5S":{periodType:"second",multiplier:5},"10S":{periodType:"second",multiplier:10},"15S":{periodType:"second",multiplier:15},"30S":{periodType:"second",multiplier:30},1:{periodType:"minute",multiplier:1},3:{periodType:"minute",multiplier:3},5:{periodType:"minute",multiplier:5},15:{periodType:"minute",multiplier:15},30:{periodType:"minute",multiplier:30},45:{periodType:"minute",multiplier:45},60:{periodType:"hour",multiplier:1},120:{periodType:"hour",multiplier:2},180:{periodType:"hour",multiplier:3},240:{periodType:"hour",multiplier:4},D:{periodType:"day",multiplier:1},W:{periodType:"week",multiplier:1},M:{periodType:"month",multiplier:1}};function xi(t,e,i=1){if(e==="month"){const n=new Date(t);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+i,1,n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),n.getUTCMilliseconds())}const r={second:1e3,minute:6e4,hour:36e5,day:864e5,week:7*864e5};return t+i*r[e]}function lt(t,e,i){const[r,n,s]=t.split("-").map(Number),[a,o]=e.split(":").map(Number),l=Date.UTC(r,n-1,s,a,o,0,0),c=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(new Date(l)),u=b=>parseInt(c.find(v=>v.type===b).value,10);let p=u("year"),h=u("month"),f=u("day"),d=u("hour");d===24&&(d=0);let m=u("minute");const x=Date.UTC(p,h-1,f,d,m,0,0)-l;return l-x}function Yn(t,e,i,r,n=1){if(e==="24x7")return xi(t,r,n);const s=e.split("-")[1];if(!s||s.length!==4)return xi(t,r,n);const a=s.slice(0,2),o=s.slice(2,4),l=`${a}:${o}`,c=Xn(t,i);if(r==="second"||r==="minute"||r==="hour"){const u=t+n*{second:1e3,minute:6e4,hour:36e5}[r],p=lt(c,l,i);return Math.min(u,p)}if(r==="day")return lt(c,l,i);if(r==="week"){const u=new Date(t).getUTCDay(),p=u<=5?5-u:5-u+7,h=t+p*864e5,f=Xn(h,i);return lt(f,l,i)}if(r==="month"){const u=new Date(t),p=u.getUTCFullYear(),h=u.getUTCMonth()+n,f=new Date(Date.UTC(p,h,1)),d=new Date(f.getTime()-864e5);for(;d.getUTCDay()===0||d.getUTCDay()===6;)d.setUTCDate(d.getUTCDate()-1);const m=d.toISOString().split("T")[0];return lt(m,l,i)}return xi(t,r,n)}function Xn(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(t))}function q_(t){for(let e=0;e<t.length-1;e++)t[e].closeTime=t[e+1].openTime;t.length>0&&(t[t.length-1].closeTime=t[t.length-1].closeTime+1)}const z_=["1S","5S","10S","15S","30S","1","3","5","15","30","45","60","120","180","240","D","W","M"];function K_(t,e){if(t==="W"||t==="M")return e.has("D")?"D":null;const i=gi[t];if(!i)return null;const r=z_.filter(n=>n!=="W"&&n!=="M"&&e.has(n)&&gi[n]<i&&i%gi[n]===0);return r.length===0?null:r[r.length-1]}function Ba(t,e){if(t==="W"||t==="M")return 1/0;const i=gi[t],r=gi[e];return!i||!r||r===0?1/0:i/r}function H_(t,e,i){if(t.length===0)return[];if(e==="W")return Y_(t);if(e==="M")return X_(t);const r=Ba(e,i);return G_(t,r)}function G_(t,e){if(t.length===0)return[];const i=[];let r=[t[0]];const n=Z_(t),s=n>0?n*1.5:0;for(let a=1;a<t.length;a++){const o=t[a].openTime-t[a-1].openTime;(s>0&&o>s||r.length>=e)&&(i.push(Zi(r)),r=[]),r.push(t[a])}return r.length>0&&i.push(Zi(r)),i}function Y_(t){const e=[];let i=[],r="";for(const n of t){const s=Q_(n.openTime);s!==r&&i.length>0&&(e.push(i),i=[]),r=s,i.push(n)}return i.length>0&&e.push(i),e.map(Zi)}function X_(t){const e=[];let i=[],r="";for(const n of t){const s=new Date(n.openTime),a=`${s.getUTCFullYear()}-${s.getUTCMonth()}`;a!==r&&i.length>0&&(e.push(i),i=[]),r=a,i.push(n)}return i.length>0&&e.push(i),e.map(Zi)}function Zi(t){const e=t[0],i=t[t.length-1];let r=e.high,n=e.low,s=0,a=0,o=0,l=0,c=0;for(let u=0;u<t.length;u++){const p=t[u];p.high>r&&(r=p.high),p.low<n&&(n=p.low),s+=p.volume,a+=p.quoteAssetVolume,o+=p.numberOfTrades,l+=p.takerBuyBaseAssetVolume,c+=p.takerBuyQuoteAssetVolume}return{openTime:e.openTime,open:e.open,high:r,low:n,close:i.close,volume:s,closeTime:i.closeTime,quoteAssetVolume:a,numberOfTrades:o,takerBuyBaseAssetVolume:l,takerBuyQuoteAssetVolume:c,ignore:0}}function Z_(t){if(t.length<2)return 0;const e=Math.min(t.length-1,20);let i=1/0;for(let r=0;r<e;r++){const n=t[r+1].openTime-t[r].openTime;n>0&&n<i&&(i=n)}return i===1/0?0:i}function Q_(t){const e=new Date(t),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1)),n=Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7);return`${e.getUTCFullYear()}-W${n}`}var J_=Object.defineProperty,eg=(t,e,i)=>e in t?J_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pi=(t,e,i)=>eg(t,typeof e!="symbol"?e+"":e,i);const Di={"1s":"1S","5s":"5S","10s":"10S","15s":"15S","30s":"30S","1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1D":"D","1W":"W","1M":"M","4H":"240",D:"D",W:"W",M:"M"};function tg(t){if(Di[t]!==void 0)return Di[t];const e=t.toLowerCase();return Di[e]!==void 0?Di[e]:/^\d+$/.test(t)?t:/^\d+S$/i.test(t)?t.toUpperCase():t}class ar{constructor(e){Pi(this,"_configured"),Pi(this,"_requiresApiKey"),Pi(this,"_providerName"),Pi(this,"_aggregationSubTimeframe",null),this._requiresApiKey=e.requiresApiKey,this._providerName=e.providerName,this._configured=!e.requiresApiKey}ensureConfigured(){if(!this._configured)throw new Error(`${this._providerName} requires configuration before use. Call Provider.${this._providerName}.configure({ apiKey: '...' }) or instantiate directly: new ${this._providerName}Provider({ apiKey: '...' })`)}configure(e){this._configured=!0}get isConfigured(){return this._configured}normalizeCloseTime(e){q_(e)}setAggregationSubTimeframe(e){this._aggregationSubTimeframe=e}getSupportedTimeframes(){return new Set(["1S","5S","10S","15S","30S","1","3","5","15","30","45","60","120","180","240","D","W","M"])}async getMarketData(e,i,r,n,s){const a=tg(i),o=this.getSupportedTimeframes();if(o.has(a))return this._getMarketDataNative(e,a,r,n,s);const l=this._aggregationSubTimeframe,c=l&&o.has(l)?l:K_(a,o);if(!c)return console.error(`${this._providerName}: Timeframe '${i}' is not supported and no valid sub-timeframe found for aggregation.`),[];const u=this._computeSubLimit(a,c,r),p=await this._getMarketDataNative(e,c,u,n,s);if(p.length===0)return[];const h=H_(p,a,c);return r&&r>0&&h.length>r?h.slice(h.length-r):h}_computeSubLimit(e,i,r){if(!r)return;const n=Ba(e,i);return n===1/0?e==="W"?r*7+14:e==="M"?r*31+31:r*30:Math.ceil(r*n)+Math.ceil(n)}}var ig=Object.defineProperty,rg=(t,e,i)=>e in t?ig(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Qi=(t,e,i)=>rg(t,typeof e!="symbol"?e+"":e,i);const gr="https://api.binance.com/api/v3",Zn="https://api.binance.us/api/v3",Mi={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class ng{constructor(e=300*1e3){Qi(this,"cache"),Qi(this,"cacheDuration"),this.cache=new Map,this.cacheDuration=e}generateKey(e){return Object.entries(e).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}:${r}`).join("|")}get(e){const i=this.generateKey(e),r=this.cache.get(i);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(i),null):r.data:null}set(e,i){const r=this.generateKey(e);this.cache.set(r,{data:i,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const e=Date.now();for(const[i,r]of this.cache.entries())e-r.timestamp>this.cacheDuration&&this.cache.delete(i)}}class sg extends ar{constructor(){super({requiresApiKey:!1,providerName:"Binance"}),Qi(this,"cacheManager"),Qi(this,"activeApiUrl",null),this.cacheManager=new ng(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${gr}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=gr,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Zn}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Zn,this.activeApiUrl}catch{}return gr}async _fetchRawChunk(e,i,r,n,s){const a=Mi[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];let o=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${a}`;r&&(o+=`&limit=${Math.min(r,1e3)}`),n&&(o+=`&startTime=${n}`),s&&(o+=`&endTime=${s}`);const l=await fetch(o);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return(await l.json()).map(c=>({openTime:parseInt(c[0]),open:parseFloat(c[1]),high:parseFloat(c[2]),low:parseFloat(c[3]),close:parseFloat(c[4]),volume:parseFloat(c[5]),closeTime:parseInt(c[6]),quoteAssetVolume:parseFloat(c[7]),numberOfTrades:parseInt(c[8]),takerBuyBaseAssetVolume:parseFloat(c[9]),takerBuyQuoteAssetVolume:parseFloat(c[10]),ignore:c[11]}))}async getMarketDataInterval(e,i,r,n){try{const s=Mi[i.toUpperCase()];if(!s)return console.error(`Unsupported timeframe: ${i}`),[];let a=[],o=r;const l=n,c=Gn[s];if(!c)return console.error(`Duration not defined for interval: ${s}`),[];for(;o<l;){const u=Math.min(o+1e3*c,l),p=await this._fetchRawChunk(e,i,1e3,o,u);if(p.length===0)break;a=a.concat(p),o=p[p.length-1].closeTime+1}return this.normalizeCloseTime(a),a}catch(s){return console.error("Error in getMarketDataInterval:",s),[]}}async getMarketDataBackwards(e,i,r,n){let s=r,a=[],o=n,l=0;const c=Math.ceil(r/1e3)+5;for(;s>0&&l<c;){l++;const u=Math.min(s,1e3),p=await this._fetchRawChunk(e,i,u,void 0,o);if(p.length===0||(a=p.concat(a),s-=p.length,o=p[0].openTime-1,p.length<u))break}return this.normalizeCloseTime(a),a}getSupportedTimeframes(){return new Set(["1","3","5","15","30","60","120","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,s){try{const a=s!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:n,eDate:s};if(a){const c=this.cacheManager.get(o);if(c)return c}if(!Mi[i.toUpperCase()])return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,n,s)){if(n&&s){const c=await this.getMarketDataInterval(e,i,n,s),u=r?c.slice(0,r):c;return this.cacheManager.set(o,u),u}else if(r&&r>1e3){const c=await this.getMarketDataBackwards(e,i,r,s);return this.cacheManager.set(o,c),c}}const l=await this._fetchRawChunk(e,i,r,n,s);return this.normalizeCloseTime(l),a&&this.cacheManager.set(o,l),l}catch(a){return console.error("Error in binance.klines:",a),[]}}shouldPaginate(e,i,r,n){if(i&&i>1e3)return!0;if(r&&n){const s=Mi[e.toUpperCase()],a=Gn[s];if(a)return Math.ceil((n-r)/a)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),n=e,s="";e.endsWith(".P")?(i="futures",n=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",s="Perpetual"):e.includes("_")&&(i="futures",n=e,r="https://dapi.binance.com/dapi/v1",s="Delivery");const a=i==="crypto"?`${r}/exchangeInfo?symbol=${n}`:`${r}/exchangeInfo`,o=await fetch(a);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const l=(await o.json()).symbols;if(!l||l.length===0)return console.error(`Symbol ${e} not found`),null;const c=i==="futures"?l.find(w=>w.symbol===n):l[0];if(!c)return console.error(`Symbol ${n} not found in exchange info`),null;const u=c.filters?.find(w=>w.filterType==="PRICE_FILTER"),p=c.filters?.find(w=>w.filterType==="LOT_SIZE"),h=u?parseFloat(u.tickSize):.01,f=p?parseFloat(p.minQty):0,d=Math.round(1/h),m=c.baseAsset,x=c.quoteAsset,b=s?` ${s}`:"",v=`${m} / ${x}${b}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:m,description:v,type:i,main_tickerid:`BINANCE:${e}`,current_contract:s,isin:"",basecurrency:m,currency:x,timezone:"Etc/UTC",country:"",mintick:h,pricescale:d,minmove:1,pointvalue:c.contractSize||1,mincontract:f,session:"24x7",volumetype:"base",expiration_date:c.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in binance.exchangeInfo:",i),null}}}var ag=Object.defineProperty,og=(t,e,i)=>e in t?ag(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,li=(t,e,i)=>og(t,typeof e!="symbol"?e+"":e,i);const lg="https://financialmodelingprep.com",Qn=new Set(["USD","EUR","GBP","JPY","CHF","AUD","CAD","NZD","SEK","NOK","DKK","SGD","HKD","KRW","MXN","ZAR","TRY","BRL","INR","CNY","PLN","CZK","HUF","ILS","THB","TWD","PHP","IDR","MYR","RUB","CLP","COP"]),Jn={"1D":{endpoint:"/stable/historical-price-eod/full",type:"daily"},D:{endpoint:"/stable/historical-price-eod/full",type:"daily"},1:{endpoint:"/stable/historical-chart/1min",interval:"1min",type:"intraday"},5:{endpoint:"/stable/historical-chart/5min",interval:"5min",type:"intraday"},15:{endpoint:"/stable/historical-chart/15min",interval:"15min",type:"intraday"},30:{endpoint:"/stable/historical-chart/30min",interval:"30min",type:"intraday"},60:{endpoint:"/stable/historical-chart/1hour",interval:"1hour",type:"intraday"},240:{endpoint:"/stable/historical-chart/4hour",interval:"4hour",type:"intraday"},"4H":{endpoint:"/stable/historical-chart/4hour",interval:"4hour",type:"intraday"}},es={NASDAQ:"America/New_York",NYSE:"America/New_York",AMEX:"America/New_York",NYSEArca:"America/New_York",BATS:"America/New_York",OTC:"America/New_York",PNK:"America/New_York",TSX:"America/Toronto",TSXV:"America/Toronto",LSE:"Europe/London",EURONEXT:"Europe/Paris",XETRA:"Europe/Berlin",JPX:"Asia/Tokyo",HKSE:"Asia/Hong_Kong",SSE:"Asia/Shanghai",SHZ:"Asia/Shanghai",ASX:"Australia/Sydney",NSE:"Asia/Kolkata",BSE:"Asia/Kolkata",KRX:"Asia/Seoul",CRYPTO:"Etc/UTC"},ts={NASDAQ:"0930-1600",NYSE:"0930-1600",AMEX:"0930-1600",NYSEArca:"0930-1600",BATS:"0930-1600",OTC:"0930-1600",PNK:"0930-1600",TSX:"0930-1600",TSXV:"0930-1600",LSE:"0800-1630",EURONEXT:"0900-1730",XETRA:"0900-1730",JPX:"0900-1530",HKSE:"0930-1600",SSE:"0930-1500",SHZ:"0930-1500",ASX:"1000-1600",NSE:"0915-1530",BSE:"0915-1530",KRX:"0900-1530",CRYPTO:"24x7"},cg={daily:{periodType:"day",multiplier:1},"1min":{periodType:"minute",multiplier:1},"5min":{periodType:"minute",multiplier:5},"15min":{periodType:"minute",multiplier:15},"30min":{periodType:"minute",multiplier:30},"1hour":{periodType:"hour",multiplier:1},"4hour":{periodType:"hour",multiplier:4}};class ug extends ar{constructor(e){super({requiresApiKey:!0,providerName:"FMP"}),li(this,"_apiKey",null),li(this,"_baseUrl",lg),li(this,"_profileCache",new Map),li(this,"_symbolInfoCache",new Map),li(this,"_mintickCache",new Map),e?.apiKey&&this.configure(e)}configure(e){super.configure(e),this._apiKey=e.apiKey,e.baseUrl&&(this._baseUrl=e.baseUrl)}getSupportedTimeframes(){return new Set(["1","5","15","30","60","240","D"])}async _getMarketDataNative(e,i,r,n,s){this.ensureConfigured();try{const a=i.toUpperCase(),o=Jn[a]||Jn[i];if(!o)return console.error(`FMP: Unsupported timeframe: ${i}`),[];let l;if(o.type==="intraday"?l=await this._fetchIntradayData(e,o.endpoint,o.interval,n,s,r):l=await this._fetchDailyData(e,n,s,r),l.length>0&&!this._mintickCache.has(e)){const c=this._estimateMintick(l);c!==void 0&&this._mintickCache.set(e,c)}return l}catch(a){return console.error("Error in FMPProvider.getMarketData:",a),[]}}async _fetchDailyData(e,i,r,n){let s=`${this._baseUrl}/stable/historical-price-eod/full?symbol=${e}&apikey=${this._apiKey}`;i&&(s+=`&from=${this._msToDateStr(i)}`),r&&(s+=`&to=${this._msToDateStr(r)}`);const a=await fetch(s);if(!a.ok){const p=await a.text();throw new Error(`FMP HTTP ${a.status}: ${p}`)}const o=await a.json();if(!Array.isArray(o)||o.length===0)return[];o.reverse();const l=n&&n>0&&n<o.length?o.slice(o.length-n):o,{session:c,timezone:u}=await this._resolveSessionInfo(e);return l.map(p=>{const h=this._dateStrToMs(p.date),f=Yn(h,c,u,"day");return{openTime:h,open:p.open,high:p.high,low:p.low,close:p.close,volume:p.volume,closeTime:f,quoteAssetVolume:0,numberOfTrades:0,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}})}async _fetchIntradayData(e,i,r,n,s,a){let o=`${this._baseUrl}${i}?symbol=${e}&apikey=${this._apiKey}`;n&&(o+=`&from=${this._msToDateStr(n)}`),s&&(o+=`&to=${this._msToDateStr(s)}`);const l=await fetch(o);if(!l.ok){const m=await l.text();if(l.status===403||m.includes("Restricted Endpoint"))return console.error(`FMP: Intraday data (${r}) requires a paid plan. Use daily timeframe ('D') with a free API key, or upgrade at https://financialmodelingprep.com/`),[];throw new Error(`FMP HTTP ${l.status}: ${m}`)}const c=await l.json();if(!Array.isArray(c)||c.length===0)return[];c.reverse();const u=a&&a>0&&a<c.length?c.slice(c.length-a):c,{periodType:p,multiplier:h}=cg[r]||{periodType:"minute",multiplier:1},{session:f,timezone:d}=await this._resolveSessionInfo(e);return u.map(m=>{const x=this._dateTimeStrToMs(m.date),b=Yn(x,f,d,p,h);return{openTime:x,open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume,closeTime:b,quoteAssetVolume:0,numberOfTrades:0,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}})}async getSymbolInfo(e){if(this.ensureConfigured(),this._symbolInfoCache.has(e))return this._symbolInfoCache.get(e);try{const i=await this._fetchProfile(e);let r="stock";i?.isEtf?r="etf":i?.isFund?r="fund":this._isForex(e)?r="forex":this._isCrypto(e)&&(r="crypto");const n=i?.exchange||(r==="crypto"?"CRYPTO":r==="forex"?"FX":""),s=r==="crypto"||r==="forex"?"Etc/UTC":es[n]||"America/New_York",a=r==="crypto"?"24x7":r==="forex"?"0000-0000":ts[n]||"0930-1600",o=i?.currency||(this._isForex(e)?e.slice(3,6):"USD"),l=this._isForex(e)?e.slice(0,3):i?.currency||"USD",c=this._mintickCache.get(e)??.01,u=Math.round(1/c),p=Math.round(c*u),h={ticker:i?.symbol||e,tickerid:`${n}:${i?.symbol||e}`,prefix:n,root:i?.symbol||e,description:i?.companyName||e,type:r,main_tickerid:`${n}:${i?.symbol||e}`,current_contract:"",isin:i?.isin||"",basecurrency:l,currency:o,timezone:s,country:i?.country||"",mintick:c,pricescale:u,minmove:p,pointvalue:1,mincontract:0,session:a,volumetype:"base",expiration_date:0,employees:i&&parseInt(i.fullTimeEmployees)||0,industry:i?.industry||"",sector:i?.sector||"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0};return this._mintickCache.has(e)&&this._symbolInfoCache.set(e,h),h}catch(i){return console.error("Error in FMPProvider.getSymbolInfo:",i),null}}_estimateMintick(e){const i=[];for(let o=0;o<e.length;o++){const l=e[o],c=Math.abs(l.close-l.open),u=Math.abs(l.high-l.low);if(c>0&&i.push(c),u>0&&i.push(u),o>0){const p=Math.abs(l.close-e[o-1].close);p>0&&i.push(p)}}if(i.length===0)return;const r=Math.min(...i),n=Math.floor(Math.log10(r)),s=r/10**n,a=(Math.floor(s+1e-12)<5?1:10)*10**n;return a>=1?.01:a}async _fetchProfile(e){if(this._profileCache.has(e))return this._profileCache.get(e);const i=`${this._baseUrl}/stable/profile?symbol=${e}&apikey=${this._apiKey}`,r=await fetch(i);if(!r.ok)return null;const n=await r.json();if(!Array.isArray(n)||n.length===0)return null;const s=n[0];return this._profileCache.set(e,s),s}async _resolveSessionInfo(e){try{const i=await this._fetchProfile(e);if(i){const r=i.exchange||"",n=this._isCrypto(e),s=n?"Etc/UTC":es[r]||"America/New_York";return{session:n?"24x7":ts[r]||"0930-1600",timezone:s}}}catch{}return{session:"0930-1600",timezone:"America/New_York"}}_msToDateStr(e){return new Date(e).toISOString().split("T")[0]}_dateStrToMs(e){return new Date(e+"T00:00:00Z").getTime()}_dateTimeStrToMs(e){return new Date(e.replace(" ","T")+"Z").getTime()}_isForex(e){return/^[A-Z]{6}$/.test(e)&&Qn.has(e.slice(0,3))&&Qn.has(e.slice(3,6))}_isCrypto(e){return this._isForex(e)?!1:/^[A-Z]+(USD|USDT|BTC|ETH)$/.test(e)&&e.length<=15}}var hg=Object.defineProperty,pg=(t,e,i)=>e in t?hg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dt=(t,e,i)=>pg(t,typeof e!="symbol"?e+"":e,i);const fg="https://data.alpaca.markets",dg="https://paper-api.alpaca.markets/v2",mg="https://api.alpaca.markets/v2",xr=1e4,is={1:"1Min",3:"3Min",5:"5Min",15:"15Min",30:"30Min",60:"1Hour",120:"2Hour",240:"4Hour","4H":"4Hour","1D":"1Day",D:"1Day","1W":"1Week",W:"1Week","1M":"1Month",M:"1Month"},yg={NASDAQ:"America/New_York",NYSE:"America/New_York",AMEX:"America/New_York",ARCA:"America/New_York",BATS:"America/New_York",OTC:"America/New_York",CRYPTO:"Etc/UTC"},_g={NASDAQ:"0930-1600",NYSE:"0930-1600",AMEX:"0930-1600",ARCA:"0930-1600",BATS:"0930-1600",OTC:"0930-1600",CRYPTO:"24x7"},gg={Min:"minute",Hour:"hour",Day:"day",Week:"week",Month:"month"};class xg extends ar{constructor(e){super({requiresApiKey:!0,providerName:"Alpaca"}),Dt(this,"_apiKey",null),Dt(this,"_apiSecret",null),Dt(this,"_dataUrl",fg),Dt(this,"_tradingUrl",dg),Dt(this,"_feed",null),Dt(this,"_assetCache",new Map),Dt(this,"_calendarCache",new Map),e?.apiKey&&e?.apiSecret&&this.configure(e)}configure(e){super.configure(e),this._apiKey=e.apiKey,this._apiSecret=e.apiSecret,e.feed&&(this._feed=e.feed),e.dataUrl&&(this._dataUrl=e.dataUrl),e.tradingUrl?this._tradingUrl=e.tradingUrl:e.paper===!1&&(this._tradingUrl=mg)}_headers(){return{"APCA-API-KEY-ID":this._apiKey,"APCA-API-SECRET-KEY":this._apiSecret}}getSupportedTimeframes(){return new Set(["1","3","5","15","30","45","60","120","180","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,s){this.ensureConfigured();try{const a=this._resolveTimeframe(i);if(!a)return console.error(`Alpaca: Unsupported timeframe: ${i}`),[];const o=this._isCrypto(e),l=await this._fetchAllBars(e,a,o,n,s,r);if(l.length===0)return[];const{periodType:c,multiplier:u}=this._parseAlpacaTimeframe(a);if(o)return this._convertBarsCrypto(l,c,u);const p=l[0].t.slice(0,10),h=l[l.length-1].t.slice(0,10),f=this._addDaysToDate(h,40);return await this._ensureCalendar(p,f),this._convertBarsStock(l,c,u)}catch(a){return console.error("Error in AlpacaProvider.getMarketData:",a),[]}}async _fetchAllBars(e,i,r,n,s,a){const o=[];let l=null;const c=a||1/0,u=Math.min(a||xr,xr);do{const p=this._buildBarsUrl(e,i,r,n,s,u,l),h=await fetch(p,{headers:this._headers()});if(!h.ok){const m=await h.text();throw new Error(`Alpaca HTTP ${h.status}: ${m}`)}const f=await h.json(),d=Object.keys(f.bars||{})[0];if(!d||!f.bars[d]||(o.push(...f.bars[d]),l=f.next_page_token,o.length>=c))break}while(l);return a&&a>0&&o.length>a?o.slice(0,a):o}_buildBarsUrl(e,i,r,n,s,a,o){const l=r?`${this._dataUrl}/v1beta3/crypto/us/bars`:`${this._dataUrl}/v2/stocks/bars`,c=new URLSearchParams;return c.set("symbols",e),c.set("timeframe",i),c.set("sort","asc"),n&&c.set("start",new Date(n).toISOString()),s&&c.set("end",new Date(s).toISOString()),a&&c.set("limit",String(Math.min(a,xr))),o&&c.set("page_token",o),!r&&this._feed&&c.set("feed",this._feed),`${l}?${c.toString()}`}async getSymbolInfo(e){this.ensureConfigured();try{const i=await this._fetchAsset(e);if(!i)return console.error(`Alpaca: Symbol ${e} not found`),null;const r=i.exchange||"",n=i.class==="crypto",s=n?"Etc/UTC":yg[r]||"America/New_York",a=n?"24x7":_g[r]||"0930-1600";let o="stock";n&&(o="crypto");const l=n&&e.split("/")[1]||"USD",c=n?e.split("/")[0]||e:l,u=i.price_increment?parseFloat(i.price_increment):.01,p=Math.round(1/u);return{ticker:i.symbol,tickerid:`${r}:${i.symbol}`,prefix:r,root:n?e.split("/")[0]:i.symbol,description:i.name||i.symbol,type:o,main_tickerid:`${r}:${i.symbol}`,current_contract:"",isin:"",basecurrency:c,currency:l,timezone:s,country:n?"":"US",mintick:u,pricescale:p,minmove:1,pointvalue:1,mincontract:i.min_order_size?parseFloat(i.min_order_size):0,session:a,volumetype:"base",expiration_date:0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in AlpacaProvider.getSymbolInfo:",i),null}}_convertBarsCrypto(e,i,r){return e.map((n,s,a)=>{const o=new Date(n.t).getTime(),l=s<a.length-1?new Date(a[s+1].t).getTime():xi(o,i,r);return this._toKline(n,o,l)})}_convertBarsStock(e,i,r){const n="America/New_York";return e.map(s=>{const a=new Date(s.t).getTime(),o=s.t.slice(0,10);let l;if(i==="day"){const c=this._calendarCache.get(o),u=c?c.close:"16:00";l=lt(o,u,n)}else if(i==="minute"||i==="hour"){const c=a+r*{minute:6e4,hour:36e5}[i],u=this._calendarCache.get(o),p=u?u.close:"16:00",h=lt(o,p,n);l=Math.min(c,h)}else i==="week"?l=this._weeklyCloseFromCalendar(o,n):i==="month"?l=this._monthlyCloseFromCalendar(o,n):l=xi(a,i,r);return this._toKline(s,a,l)})}_toKline(e,i,r){return{openTime:i,open:e.o,high:e.h,low:e.l,close:e.c,volume:e.v,closeTime:r,quoteAssetVolume:0,numberOfTrades:e.n,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}}_weeklyCloseFromCalendar(e,i){const r=new Date(e+"T00:00:00Z"),n=r.getUTCDay(),s=n<=5?5-n:5-n+7;for(let l=s;l>=0;l--){const c=r.getTime()+l*864e5,u=new Date(c).toISOString().split("T")[0],p=this._calendarCache.get(u);if(p)return lt(u,p.close,i)}const a=r.getTime()+s*864e5,o=new Date(a).toISOString().split("T")[0];return lt(o,"16:00",i)}_monthlyCloseFromCalendar(e,i){const[r,n]=e.split("-").map(Number),s=new Date(Date.UTC(r,n,0)).getUTCDate();for(let o=s;o>=1;o--){const l=`${r}-${String(n).padStart(2,"0")}-${String(o).padStart(2,"0")}`,c=this._calendarCache.get(l);if(c)return lt(l,c.close,i)}const a=new Date(Date.UTC(r,n,0));for(;a.getUTCDay()===0||a.getUTCDay()===6;)a.setUTCDate(a.getUTCDate()-1);return lt(a.toISOString().split("T")[0],"16:00",i)}async _ensureCalendar(e,i){if(this._calendarCache.has(e)&&this._calendarCache.has(i))return;const r=`${this._tradingUrl}/calendar?start=${e}&end=${i}`,n=await fetch(r,{headers:this._headers()});if(!n.ok){console.warn(`Alpaca calendar API returned ${n.status}, falling back to defaults`);return}const s=await n.json();for(const a of s)this._calendarCache.set(a.date,a)}async _fetchAsset(e){if(this._assetCache.has(e))return this._assetCache.get(e);const i=encodeURIComponent(e),r=`${this._tradingUrl}/assets/${i}`,n=await fetch(r,{headers:this._headers()});if(!n.ok)return null;const s=await n.json();return this._assetCache.set(e,s),s}_parseAlpacaTimeframe(e){const i=e.match(/^(\d+)(Min|Hour|Day|Week|Month)$/);if(i){const r=parseInt(i[1],10),n=gg[i[2]];if(n)return{periodType:n,multiplier:r}}return{periodType:"day",multiplier:1}}_resolveTimeframe(e){return is[e.toUpperCase()]||is[e]||null}_isCrypto(e){return e.includes("/")}_addDaysToDate(e,i){const r=new Date(e+"T00:00:00Z");return r.setUTCDate(r.getUTCDate()+i),r.toISOString().split("T")[0]}}var bg=Object.defineProperty,vg=(t,e,i)=>e in t?bg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,br=(t,e,i)=>vg(t,typeof e!="symbol"?e+"":e,i);const wg=Wa(import.meta.url),Sg=ci.dirname(wg);class Eg extends ar{constructor(e){super({requiresApiKey:!1,providerName:"Mock"}),br(this,"dataCache",new Map),br(this,"exchangeInfoCache",{}),br(this,"dataDirectory");const i=typeof e=="string"?e:e?.dataDirectory;if(i)this.dataDirectory=i;else{const r=ci.resolve(Sg,"../../../");this.dataDirectory=ci.join(r,"tests","compatibility","_data")}}configure(e){super.configure(e),e.dataDirectory&&(this.dataDirectory=e.dataDirectory)}getDataFileName(e,i,r,n){return r&&n?`${e}-${i}-${r}-${n}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=ci.join(this.dataDirectory,e);if(!Ut.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const n=Ut.readFileSync(r,"utf-8"),s=JSON.parse(n);return this.dataCache.set(i,s),s}findDataFile(e,i,r,n){if(!Ut.existsSync(this.dataDirectory))return null;const s=Ut.readdirSync(this.dataDirectory).filter(l=>l.endsWith(".json"));if(r&&n){const l=`${e}-${i}-${r}-${n}.json`;if(s.includes(l))return l}const a=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=s.filter(l=>a.test(l)).map(l=>{const c=l.match(a);return{file:l,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((l,c)=>c.endTime-l.endTime);if(o.length===0)return null;if(r&&n){const l=o.find(c=>c.startTime<=r&&c.endTime>=n);if(l)return l.file}return o[0].file}filterData(e,i,r,n){let s=e;return(i||r)&&(s=e.filter(a=>{const o=!i||a.openTime>=i,l=!r||a.openTime<=r;return o&&l})),s.sort((a,o)=>a.openTime-o.openTime),n&&n>0&&(s=s.slice(0,n)),s}normalizeTimeframe(e){return{1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"}[e.toUpperCase()]||e.toLowerCase()}getSupportedTimeframes(){return new Set(["1","3","5","15","30","45","60","120","180","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,s){try{const a=this.normalizeTimeframe(i),o=this.findDataFile(e,a,n,s);if(!o)return console.warn(`No mock data file found for ${e} ${a}. Searched in: ${this.dataDirectory}`),[];const l=this.loadDataFromFile(o),c=this.filterData(l,n,s,r);return this.normalizeCloseTime(c),c}catch(a){return console.error("Error in MockProvider.getMarketData:",a),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=ci.join(this.dataDirectory,i);if(!Ut.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const n=Ut.readFileSync(r,"utf-8"),s=JSON.parse(n);return this.exchangeInfoCache[e]=s,s}catch(n){return console.error(`Error loading exchange info from ${i}:`,n),null}}async getSymbolInfo(e){try{let i="crypto",r=e,n="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),n="Perpetual"):e.includes("_")&&(i="futures",r=e,n="Delivery");const s=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!s||!s.symbols)return console.error(`Exchange info not available for ${i}`),null;const a=s.symbols.find(x=>x.symbol===r);if(!a)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=a.filters?.find(x=>x.filterType==="PRICE_FILTER"),l=a.filters?.find(x=>x.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,u=l?parseFloat(l.minQty):0,p=Math.round(1/c),h=a.baseAsset,f=a.quoteAsset,d=n?` ${n}`:"",m=`${h} / ${f}${d}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:h,description:m,type:i,main_tickerid:`BINANCE:${e}`,current_contract:n,isin:"",basecurrency:h,currency:f,timezone:"Etc/UTC",country:"",mintick:c,pricescale:p,minmove:1,pointvalue:a.contractSize||1,mincontract:u,session:"24x7",volumetype:"base",expiration_date:a.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in MockProvider.getSymbolInfo:",i),null}}clearCache(){this.dataCache.clear(),this.exchangeInfoCache={}}setDataDirectory(e){this.dataDirectory=e,this.clearCache()}}const Ng=typeof process<"u"&&process.versions&&process.versions.node;let Ji=null;if(Ng)try{Ji=new Eg}catch{Ji=null}const Pg={Binance:new sg,FMP:new ug,Alpaca:new xg,...Ji?{Mock:Ji}:{}};var Cg=Object.defineProperty,Ig=(t,e,i)=>e in t?Cg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,kg=(t,e,i)=>Ig(t,typeof e!="symbol"?e+"":e,i);class Dg extends Error{constructor(e,i){super(e),kg(this,"method"),this.name="PineRuntimeError",this.method=i}}export{xg as AlpacaProvider,ar as BaseProvider,sg as BinanceProvider,wn as Context,ug as FMPProvider,$a as INDICATOR_PROPS,vi as Indicator,Dg as PineRuntimeError,nn as PineTS,Pg as Provider,Va as STRATEGY_PROPS,Ag as TIMEFRAME_PERIOD_INFO,gi as TIMEFRAME_SECONDS,H_ as aggregateCandles,xi as computeNextPeriodStart,Yn as computeSessionClose,Ba as getAggregationRatio,lt as localTimeToUTC,M_ as propsForDeclaration,K_ as selectSubTimeframe};
|
|
124
|
+
; return _r;`)(this);return p&&Object.keys(p).length>0&&(h._ltfSlices=p),h}const Pa=new Set(["open","high","low","close","hl2","hlc3","ohlc4","hlcc4","volume"]),Kn={"":["defval","title","tooltip","inline","group","display","active"],bool:["defval","title","tooltip","inline","group","confirm","display","active"],color:["defval","title","tooltip","inline","group","confirm","display","active"],enum:["defval","title","options","tooltip","inline","group","confirm","display","active"],price:["defval","title","tooltip","inline","group","confirm","display","active"],session:["defval","title","options","tooltip","inline","group","confirm","display","active"],source:["defval","title","tooltip","inline","group","display","active","confirm"],string:["defval","title","options","tooltip","inline","group","confirm","display","active"],symbol:["defval","title","tooltip","inline","group","confirm","display","active"],text_area:["defval","title","tooltip","group","confirm","display","active"],time:["defval","title","tooltip","inline","group","confirm","display","active"],timeframe:["defval","title","options","tooltip","inline","group","confirm","display","active"]},S_={bool:"bool",color:"color",enum:"enum",float:"float",int:"int",price:"price",session:"session",source:"source",string:"string",symbol:"symbol",text_area:"text_area",time:"time",timeframe:"timeframe"};function E_(t){if(typeof t!="string")return[];const e=rn(t);if(!e.success||!e.ast)return[];const i=N_(e.ast),r=[],n=new Set;return Nt(e.ast,s=>{const a=C_(s,i);if(a){if(a.title!==void 0){if(n.has(a.title)){console.warn(`[Indicator] duplicate input title "${a.title}" \u2014 first declaration wins for .input access`);return}n.add(a.title)}r.push(a)}}),r}function N_(t){const e=new Map;return Nt(t,i=>{if(i.type==="VariableDeclaration")for(const r of i.declarations??[]){const n=r?.id?.name,s=r?.init;if(!n||!s||s.type!=="ObjectExpression"||!(s.properties??[]).every(a=>a.value?.type==="Literal"&&typeof a.value.value=="string")||s.properties.length===0)return;for(const a of s.properties)e.set(`${n}.${a.key.name}`,a.value.value)}}),e}function C_(t,e){if(t.type!=="VariableDeclaration")return null;for(const i of t.declarations??[]){const r=i?.init;if(!r||r.type!=="CallExpression")continue;const n=r.callee;let s=null;if(n?.type==="MemberExpression"&&n.object?.type==="Identifier"&&n.object.name==="input"&&n.property?.type==="Identifier"?s=n.property.name:n?.type==="Identifier"&&n.name==="input"&&(s=""),s===null||s!==""&&!(s==="int"||s==="float")&&!(s in Kn))continue;const a=r.arguments??[],o=a[a.length-1],l=o?.type==="ObjectExpression",c=l?a.slice(0,-1):a.slice(),u=l?o.properties??[]:[],p={};s==="int"||s==="float"?I_(c,u,p):Da(Kn[s],c,p);for(const m of u)m.type!=="Property"||!m.key?.name||(p[m.key.name]=m.value);const h={};for(const m of Object.keys(p))h[m]=Ma(p[m],e);const f=s===""?k_(h.defval):S_[s];if(!f)continue;const d={type:f,defval:h.defval};return h.title!==void 0&&(d.title=String(h.title)),h.tooltip!==void 0&&(d.tooltip=String(h.tooltip)),h.group!==void 0&&(d.group=String(h.group)),h.inline!==void 0&&(d.inline=String(h.inline)),h.confirm!==void 0&&(d.confirm=!!h.confirm),h.active!==void 0&&(d.active=!!h.active),h.display!==void 0&&(d.display=T_(h.display)),h.options!==void 0&&Array.isArray(h.options)&&(d.options=h.options),typeof h.minval=="number"&&(d.minval=h.minval),typeof h.maxval=="number"&&(d.maxval=h.maxval),typeof h.step=="number"&&(d.step=h.step),d}return null}function I_(t,e,i){const r=new Set(e.map(n=>n.key?.name).filter(Boolean)).has("options")||t[2]?.type==="ArrayExpression"?["defval","title","options","tooltip","inline","group","confirm","display","active"]:["defval","title","minval","maxval","step","tooltip","inline","group","confirm","display","active"];Da(r,t,i)}function Da(t,e,i){for(let r=0;r<e.length&&r<t.length;r++){const n=t[r];i[n]===void 0&&(i[n]=e[r])}}function Ma(t,e){if(t!=null)switch(t.type){case"Literal":return t.value;case"Identifier":return Pa.has(t.name),t.name;case"MemberExpression":{const i=t.object?.type==="Identifier"?t.object.name:null,r=t.property?.type==="Identifier"?t.property.name:null;if(i&&r){const n=`${i}.${r}`;return e.has(n)?e.get(n):i==="display"?r:n}return}case"ArrayExpression":return(t.elements??[]).map(i=>Ma(i,e));case"UnaryExpression":return t.operator==="-"&&t.argument?.type==="Literal"&&typeof t.argument.value=="number"?-t.argument.value:void 0;default:return}}function k_(t){return typeof t=="boolean"?"bool":typeof t=="number"?Number.isInteger(t)?"int":"float":typeof t=="string"?Pa.has(t)?"source":t.startsWith("#")?"color":"string":null}function T_(t){if(typeof t!="string")return;const e=t.startsWith("display.")?t.slice(8):t;if(e==="none"||e==="data_window"||e==="status_line"||e==="all")return e}function Nt(t,e){if(!(!t||typeof t!="object")){if(e(t),Array.isArray(t.body))for(const i of t.body)Nt(i,e);else t.body&&Nt(t.body,e);if(Array.isArray(t.consequent))for(const i of t.consequent)Nt(i,e);else t.consequent&&Nt(t.consequent,e);if(t.alternate&&Nt(t.alternate,e),Array.isArray(t.declarations))for(const i of t.declarations)Nt(i,e)}}function Ra(t,e,i,r,n="key"){const s={},a=new Map;for(const o of t)a.set(o.key,o),s[o.key]=r&&o.key in r?r[o.key]:o.defval;return{proxy:new Proxy(s,{get(o,l){return o[l]},set(o,l,c){if(typeof l!="string")return!1;const u=a.get(l);if(!u)throw new Error(`[${e}] unknown ${n} "${l}". Known: ${[...a.keys()].join(", ")||"(none)"}`);return A_(u,c,e),o[l]=c,i?.(l),!0},deleteProperty(o,l){throw new Error(`[${e}] cannot delete "${String(l)}" \u2014 keys are fixed by the script's source.`)},defineProperty(){throw new Error(`[${e}] cannot define new properties \u2014 keys are fixed by the script's source.`)},ownKeys(o){return Reflect.ownKeys(o)},getOwnPropertyDescriptor(o,l){return Reflect.getOwnPropertyDescriptor(o,l)},has(o,l){return typeof l=="string"&&l in o}}),values:s,entryByKey:a}}function A_(t,e,i){const r=t.key;switch(t.type){case"int":if(typeof e!="number"||!Number.isInteger(e))throw new TypeError(`[${i}] "${r}" expects an int; got ${Zt(e)}`);break;case"float":case"price":case"time":if(typeof e!="number"||!Number.isFinite(e))throw new TypeError(`[${i}] "${r}" expects a number; got ${Zt(e)}`);break;case"bool":if(typeof e!="boolean")throw new TypeError(`[${i}] "${r}" expects a boolean; got ${Zt(e)}`);break;case"string":case"session":case"symbol":case"timeframe":case"text_area":case"color":case"enum":case"source":if(typeof e!="string")throw new TypeError(`[${i}] "${r}" expects a string; got ${Zt(e)}`);break}if(t.options&&!t.options.some(n=>P_(n,e)))throw new RangeError(`[${i}] "${r}" value ${Zt(e)} is not one of: ${t.options.map(Zt).join(", ")}`);if(typeof e=="number"){if(typeof t.minval=="number"&&e<t.minval)throw new RangeError(`[${i}] "${r}" value ${e} is below minval ${t.minval}`);if(typeof t.maxval=="number"&&e>t.maxval)throw new RangeError(`[${i}] "${r}" value ${e} is above maxval ${t.maxval}`)}}function P_(t,e){return t===e?!0:typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<1e-12:!1}function Zt(t){return t===null?"null":typeof t=="string"?JSON.stringify(t):String(t)}function D_(t,e){const i=new Map,r=[];for(const a of t)a.title&&(i.set(a.title,a),r.push({key:a.title,type:a.type,defval:a.defval,options:a.options,minval:a.minval,maxval:a.maxval}));const{proxy:n,values:s}=Ra(r,"Indicator.input",e,void 0,"input title");return{proxy:n,values:s,metaByTitle:i}}const Oa=[{name:"title",type:"string",defval:"",mutable:!1,appliesTo:"both"},{name:"shorttitle",type:"string",defval:"",mutable:!1,appliesTo:"both"},{name:"overlay",type:"bool",defval:!1,mutable:!0,appliesTo:"both"},{name:"format",type:"enum",defval:"inherit",options:["inherit","price","volume","percent","mintick"],mutable:!0,appliesTo:"both"},{name:"precision",type:"int",defval:10,minval:0,maxval:16,mutable:!0,appliesTo:"both"},{name:"scale",type:"enum",defval:"right",options:["right","left","none"],mutable:!0,appliesTo:"both"},{name:"max_bars_back",type:"int",defval:0,minval:0,maxval:5e3,mutable:!0,appliesTo:"both"},{name:"explicit_plot_zorder",type:"bool",defval:!1,mutable:!0,appliesTo:"both"},{name:"max_lines_count",type:"int",defval:50,minval:1,maxval:500,mutable:!0,appliesTo:"both"},{name:"max_labels_count",type:"int",defval:50,minval:1,maxval:500,mutable:!0,appliesTo:"both"},{name:"max_boxes_count",type:"int",defval:50,minval:1,maxval:500,mutable:!0,appliesTo:"both"},{name:"calc_bars_count",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"both"},{name:"max_polylines_count",type:"int",defval:50,minval:1,maxval:100,mutable:!0,appliesTo:"both"},{name:"dynamic_requests",type:"bool",defval:!0,mutable:!0,appliesTo:"both",version:6},{name:"behind_chart",type:"bool",defval:!0,mutable:!0,appliesTo:"both",version:6}],$a=[...Oa.filter(t=>t.appliesTo==="both").map(t=>({...t,appliesTo:"indicator"})),{name:"timeframe",type:"string",defval:"",mutable:!0,appliesTo:"indicator"},{name:"timeframe_gaps",type:"bool",defval:!0,mutable:!0,appliesTo:"indicator"}],Va=[...Oa.filter(t=>t.appliesTo==="both").map(t=>({...t,appliesTo:"strategy"})),{name:"pyramiding",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"calc_on_order_fills",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"calc_on_every_tick",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"backtest_fill_limits_assumption",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"default_qty_type",type:"enum",defval:"fixed",options:["fixed","cash","percent_of_equity"],mutable:!0,appliesTo:"strategy"},{name:"default_qty_value",type:"float",defval:1,minval:0,mutable:!0,appliesTo:"strategy"},{name:"initial_capital",type:"float",defval:1e6,minval:0,mutable:!0,appliesTo:"strategy"},{name:"currency",type:"enum",defval:"USD",options:["AED","ARS","AUD","BDT","BHD","BRL","BTC","CAD","CHF","CLP","CNY","COP","CZK","DKK","EGP","ETH","EUR","GBP","HKD","HUF","IDR","ILS","INR","ISK","JPY","KES","KRW","KWD","LKR","MAD","MXN","MYR","NGN","NOK","NONE","NZD","PEN","PHP","PKR","PLN","QAR","RON","RSD","RUB","SAR","SEK","SGD","THB","TND","TRY","TWD","USD","USDT","VES","VND","ZAR"],mutable:!0,appliesTo:"strategy"},{name:"slippage",type:"int",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"commission_type",type:"enum",defval:"percent",options:["percent","cash_per_contract","cash_per_order"],mutable:!0,appliesTo:"strategy"},{name:"commission_value",type:"float",defval:0,minval:0,mutable:!0,appliesTo:"strategy"},{name:"process_orders_on_close",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"close_entries_rule",type:"enum",defval:"FIFO",options:["FIFO","ANY"],mutable:!0,appliesTo:"strategy"},{name:"margin_long",type:"float",defval:100,minval:0,maxval:100,mutable:!0,appliesTo:"strategy"},{name:"margin_short",type:"float",defval:100,minval:0,maxval:100,mutable:!0,appliesTo:"strategy"},{name:"risk_free_rate",type:"float",defval:2,mutable:!0,appliesTo:"strategy"},{name:"use_bar_magnifier",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"},{name:"fill_orders_on_standard_ohlc",type:"bool",defval:!1,mutable:!0,appliesTo:"strategy"}];function M_(t){return t==="strategy"?Va:$a}function R_(t){return typeof t=="string"?O_(t):typeof t=="function"?$_(t):{type:null,args:{}}}function O_(t){const e=rn(t);if(!e.success||!e.ast)return{type:null,args:{}};let i=null;return Xi(e.ast,r=>{if(i||r.type!=="ExpressionStatement"&&r.type!=="VariableDeclaration")return;const n=r.type==="ExpressionStatement"?r.expression:r.declarations?.[0]?.init;if(!n||n.type!=="CallExpression")return;const s=n.callee;s?.type==="Identifier"&&(s.name!=="indicator"&&s.name!=="strategy"||(i={type:s.name,args:La(n.arguments??[],ja(s.name))}))}),i??{type:null,args:{}}}function $_(t){let e;try{e=Xr(`(${t.toString()})`,{ecmaVersion:"latest"})}catch{return{type:null,args:{}}}let i=null;return Xi(e,r=>{if(i||r.type!=="CallExpression")return;const n=r.callee;n?.type==="Identifier"&&(n.name!=="indicator"&&n.name!=="strategy"||(i={type:n.name,args:La(r.arguments??[],ja(n.name))}))}),i??{type:null,args:{}}}function ja(t){return t==="strategy"?Va:$a}function La(t,e){const i={},r=t[t.length-1],n=r?.type==="ObjectExpression",s=n?t.slice(0,-1):t.slice();for(let a=0;a<s.length&&a<e.length;a++){const o=e[a].name;i[o]=jr(s[a])}if(n)for(const a of r.properties??[])a.type!=="Property"||!a.key?.name||(i[a.key.name]=jr(a.value));return i}function jr(t){if(t!=null)switch(t.type){case"Literal":return t.value;case"Identifier":return t.name;case"MemberExpression":{let e=t;for(;e?.type==="MemberExpression";)e=e.property;return e?.type==="Identifier"?e.name:void 0}case"UnaryExpression":return t.operator==="-"&&t.argument?.type==="Literal"&&typeof t.argument.value=="number"?-t.argument.value:void 0;case"ArrayExpression":return(t.elements??[]).map(jr);default:return}}function Xi(t,e){if(!(!t||typeof t!="object")){e(t);for(const i of Object.keys(t)){const r=t[i];if(!(i==="loc"||i==="range"||i==="start"||i==="end"))if(Array.isArray(r))for(const n of r)Xi(n,e);else r&&typeof r=="object"&&typeof r.type=="string"&&Xi(r,e)}}}function V_(t,e,i){const r=new Map,n=[];for(const o of t)r.set(o.name,o),o.mutable&&n.push({key:o.name,type:o.type,defval:o.defval,options:o.options,minval:o.minval,maxval:o.maxval});const{proxy:s,values:a}=Ra(n,"Indicator.prop",i,e);return{proxy:s,values:a,propByName:r}}var j_=Object.defineProperty,L_=(t,e,i)=>e in t?j_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,je=(t,e,i)=>L_(t,typeof e!="symbol"?e+"":e,i);class vi{constructor(e,i={}){je(this,"source"),je(this,"inputs"),je(this,"_prepared",null),je(this,"_inputMeta",null),je(this,"_inputValues",{}),je(this,"_explicitOverrides",new Set),je(this,"_inputProxy",null),je(this,"_propMeta",null),je(this,"_propValues",{}),je(this,"_propProxy",null),je(this,"_declarationType",null),je(this,"_sourcePropArgs",{}),je(this,"_explicitPropOverrides",new Set),this.source=e,this.inputs=i,Object.defineProperty(this,"input",{get:()=>this._getInputProxy(),set:()=>{throw new Error('[Indicator] .input cannot be replaced \u2014 mutate individual keys (e.g. ind.input["My Title"] = 20).')},enumerable:!0,configurable:!1}),Object.defineProperty(this,"prop",{get:()=>this._getPropProxy(),set:()=>{throw new Error('[Indicator] .prop cannot be replaced \u2014 mutate individual keys (e.g. ind.prop["initial_capital"] = 50000).')},enumerable:!0,configurable:!1})}static from(e){return e instanceof vi?e:new vi(e)}prepare(e={}){if(this._prepared)return this._prepared;const i=w_(this.source,{debug:!!e.debug,ln:e.ln}),r=B_(i),n=i._ltfSlices;return this._prepared={fn:i,inputs:this.getRuntimeInputs(),usesVisibleRange:r,ltfSlices:n},this._prepared}usesVisibleRange(){return this.prepare().usesVisibleRange}getRuntimeInputs(){const e={...this.inputs??{}};if(this._inputMeta)for(const i of this._explicitOverrides)e[i]=this._inputValues[i];return e}getInputsMeta(){return this._ensureInputsScanned(),this._inputMeta}getPropsMeta(){return this._ensurePropsScanned(),this._propMeta}getRuntimePropOverrides(){const e={};if(this._propMeta)for(const i of this._explicitPropOverrides)e[i]=this._propValues[i];return e}getDeclarationType(){return this._ensurePropsScanned(),this._declarationType}_ensureInputsScanned(){if(this._inputMeta)return;this._inputMeta=E_(this.source);const e=D_(this._inputMeta,i=>this._explicitOverrides.add(i));this._inputValues=e.values,this._inputProxy=e.proxy}_getInputProxy(){return this._ensureInputsScanned(),this._inputProxy}_ensurePropsScanned(){if(this._propMeta)return;const e=R_(this.source);this._declarationType=e.type,this._sourcePropArgs=e.args,this._propMeta=M_(e.type);const i=V_(this._propMeta,this._sourcePropArgs,r=>this._explicitPropOverrides.add(r));this._propValues=i.values,this._propProxy=i.proxy}_getPropProxy(){return this._ensurePropsScanned(),this._propProxy}}function B_(t){const e=t.toString();return xy.some(i=>{const r=i.replace(/\./g,"\\.");return new RegExp(`\\b${r}\\b`).test(e)})}var F_=Object.defineProperty,W_=(t,e,i)=>e in t?F_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Q=(t,e,i)=>W_(t,typeof e!="symbol"?e+"":e,i);const Hn={1:6e4,3:18e4,5:3e5,15:9e5,30:18e5,60:36e5,120:72e5,180:108e5,240:144e5,"4H":144e5,"1D":864e5,D:864e5,"1W":6048e5,W:6048e5,"1M":30*864e5,M:30*864e5};function U_(t){return t?Hn[t]??Hn[t.toUpperCase()]??864e5:864e5}class nn{constructor(e,i,r,n,s,a){this.source=e,this.tickerId=i,this.timeframe=r,this.limit=n,this.sDate=s,this.eDate=a,Q(this,"data",[]),Q(this,"open",[]),Q(this,"high",[]),Q(this,"low",[]),Q(this,"close",[]),Q(this,"volume",[]),Q(this,"hl2",[]),Q(this,"hlc3",[]),Q(this,"ohlc4",[]),Q(this,"hlcc4",[]),Q(this,"openTime",[]),Q(this,"closeTime",[]),Q(this,"_readyPromise",null),Q(this,"_ready",!1),Q(this,"_debugSettings",{ln:!1,debug:!1}),Q(this,"_transpiledCode",null),Q(this,"_currentIndicator",null),Q(this,"_isSecondaryContext",!1),Q(this,"_syminfo"),Q(this,"_chartTimezone",null),Q(this,"_maxLoops",5e5),Q(this,"_alertMode","realtime"),Q(this,"_viewportLeft"),Q(this,"_viewportRight"),Q(this,"_usesVisibleRange",!1),Q(this,"_lastRunViewport",{}),Q(this,"_lastResult",null),Q(this,"_lastPineTSCode",null),this._readyPromise=new Promise(o=>{this.loadMarketData(e,i,r,n,s,a).then(l=>{const c=l;this.data=c;const u=c.map(N=>N.open),p=c.map(N=>N.close),h=c.map(N=>N.high),f=c.map(N=>N.low),d=c.map(N=>N.volume),m=c.map(N=>(N.high+N.low+N.close)/3),x=c.map(N=>(N.high+N.low)/2),b=c.map(N=>(N.high+N.low+N.open+N.close)/4),v=c.map(N=>(N.high+N.low+N.close+N.close)/4),w=c.map(N=>N.openTime),S=U_(this.timeframe),T=c.map(N=>N.closeTime!=null?N.closeTime:N.openTime+S);this.open=u,this.close=p,this.high=h,this.low=f,this.volume=d,this.hl2=x,this.hlc3=m,this.ohlc4=b,this.hlcc4=v,this.openTime=w,this.closeTime=T,e&&e.getSymbolInfo?e.getSymbolInfo(i).then(N=>{this._syminfo=N,this._ready=!0,o(!0)}).catch(N=>{console.warn("Failed to get symbol info, using default values:",N),this._ready=!0,o(!0)}):(this._ready=!0,o(!0))})})}get transpiledCode(){return this._transpiledCode}markAsSecondary(){this._isSecondaryContext=!0}setTimezone(e){this._chartTimezone=e}setMaxLoops(e){this._maxLoops=e}setAlertMode(e){this._alertMode=e}setVisibleRange(e,i){this._viewportLeft=e,this._viewportRight=i}usesVisibleRange(){return this._usesVisibleRange}get visibleRangeLeft(){return this._viewportLeft}get visibleRangeRight(){return this._viewportRight}async update(e){const i=e??this._lastPineTSCode;if(!i)throw new Error("pine.update(): pineTSCode is required on the first call.");const r=this._lastResult===null,n=this._viewportLeft!==this._lastRunViewport.left||this._viewportRight!==this._lastRunViewport.right;return r||this._usesVisibleRange&&n?(this._lastPineTSCode=i,this._lastRunViewport={left:this._viewportLeft,right:this._viewportRight},this._lastResult=await this.run(i),this._lastResult):this._lastResult}setDebugSettings({ln:e,debug:i}){this._debugSettings.ln=e,this._debugSettings.debug=i}async loadMarketData(e,i,r,n,s,a){return Array.isArray(e)?e:e.getMarketData(i,r,n,s,a)}async ready(){if(this._ready)return!0;if(!this._readyPromise)throw new Error("PineTS is not ready");return this._readyPromise}run(e,i,r){const n=vi.from(e);if(this._currentIndicator=n,r&&r>0){const s=typeof this.eDate>"u"&&!Array.isArray(this.source);return this._runPaginated(n,i,r,s)}else return this._runComplete(n,i)}stream(e,i={}){const{live:r=!0,interval:n=1e3}=i,s=i.pageSize||this.data.length,a=vi.from(e);this._currentIndicator=a;const o={data:[],error:[],warning:[],alert:[]};let l=!1;const c=(h,...f)=>{o[h]&&o[h].forEach(d=>d(...f))},u=(h,f)=>{o[h]||(o[h]=[]),o[h].push(f)},p=()=>{l=!0};return(async()=>{try{r&&typeof this.eDate<"u"&&(this.eDate=Math.max(this.eDate,Date.now()));const h=!Array.isArray(this.source)&&r,f=this._runPaginated(a,void 0,s,h);for await(const d of f){if(l)break;if(d===null){await new Promise(m=>setTimeout(m,n));continue}if(c("data",d),d.warnings&&d.warnings.length>0){for(const m of d.warnings)c("warning",m);d.warnings.length=0}if(d.alerts&&d.alerts.length>0){for(const m of d.alerts)c("alert",m);d.alerts.length=0}if(h&&!l){const m=d.marketData[d.idx],x=m&&m.closeTime<Date.now(),b=d.idx>=d.marketData.length-1;(!x||b)&&await new Promise(v=>setTimeout(v,n))}}}catch(h){c("error",h)}})(),{on:u,stop:p}}async runPretranspiled(e,i={},r){await this.ready(),r||(r=this.data.length);const n=this._initializeContext(null,i,this._isSecondaryContext);this._transpiledCode=e;const s=e._ltfSlices;return s&&(n._ltfTruncatedBodies=s),await this._executeIterations(n,e,this.data.length-r,this.data.length),n}async _runComplete(e,i){await this.ready(),i||(i=this.data.length);const r=e.prepare(this._debugSettings);this._usesVisibleRange=r.usesVisibleRange;const n=this._initializeContext(e.source??null,r.inputs,this._isSecondaryContext);this._transpiledCode=r.fn,r.ltfSlices&&(n._ltfTruncatedBodies=r.ltfSlices);const s=this.data.length-i,a=this.data.length;return a-s>1?(await this._executeIterations(n,r.fn,s,a-1),n._varSnapshot=this._snapshotVarState(n),await this._executeIterations(n,r.fn,a-1,a)):await this._executeIterations(n,r.fn,s,a),n}async*_runPaginated(e,i,r,n=!1){await this.ready(),i||(i=this.data.length);const s=e.prepare(this._debugSettings);this._usesVisibleRange=s.usesVisibleRange;const a=this._initializeContext(e.source??null,s.inputs,this._isSecondaryContext);this._transpiledCode=s.fn,s.ltfSlices&&(a._ltfTruncatedBodies=s.ltfSlices);let o=this.data.length-i,l=null;for(;;){const c=this.data.length,u=c-o;if(u>0){const m=Math.min(u,r),x=this._getResultLength(a.result),b=o+m;n&&b>=c&&m>1?(await this._executeIterations(a,this._transpiledCode,o,b-1),l=this._snapshotVarState(a),await this._executeIterations(a,this._transpiledCode,b-1,b)):n&&b>=c&&m===1?await this._executeIterations(a,this._transpiledCode,o,b):await this._executeIterations(a,this._transpiledCode,o,b),o+=m,yield this._createPageContext(a,x);continue}if(!n||Array.isArray(this.source))break;const p=Date.now(),{newCandles:h,updatedLastCandle:f}=await this._updateMarketData(),d=Date.now()-p;if(h===0&&!f){yield null;continue}if(h===0&&f&&d<1e3&&await new Promise(m=>setTimeout(m,1e3-d)),a.dataVersion++,a.length=this.data.length,this._restoreVarState(a,l),Array.isArray(a.result))a.result.pop();else if(typeof a.result=="object"&&a.result!==null)for(let m in a.result)Array.isArray(a.result[m])&&a.result[m].pop();a.data.close.data.pop(),a.data.open.data.pop(),a.data.high.data.pop(),a.data.low.data.pop(),a.data.volume.data.pop(),a.data.hl2.data.pop(),a.data.hlc3.data.pop(),a.data.ohlc4.data.pop(),a.data.hlcc4.data.pop(),a.data.openTime.data.pop(),a.data.closeTime&&a.data.closeTime.data.pop(),a.data.bar_index.data.pop(),o=this.data.length-(h+1),a.rollbackDrawings(o),h>0&&(l=null),a.pine.barstate.setLive()}}_getResultLength(e){if(Array.isArray(e))return e.length;if(typeof e=="object"&&e!==null){const i=Object.keys(e);if(i.length>0&&Array.isArray(e[i[0]]))return e[i[0]].length}return 0}_createPageContext(e,i){const r=new wn({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,fullContext:e,inputs:e.inputs});if(r.pineTSCode=e.pineTSCode,r.idx=e.idx,Array.isArray(e.result))r.result=e.result.slice(i);else if(typeof e.result=="object"&&e.result!==null){r.result={};for(let n in e.result)Array.isArray(e.result[n])?r.result[n]=e.result[n].slice(i):r.result[n]=e.result[n]}else r.result=e.result;return r.plots={...e.plots},r.warnings=e.warnings,r.alerts=e.alerts,r}async _updateMarketData(e){if(Array.isArray(this.source))return{newCandles:0,updatedLastCandle:!1};const i=this.source,r=this.data.length-1,n=this.data[r].openTime;try{const s=await i.getMarketData(this.tickerId,this.timeframe,void 0,n,e);if(!s||s.length===0)return{newCandles:0,updatedLastCandle:!1};let a=!1,o=0;for(let l=0;l<s.length;l++){const c=s[l];c.openTime===n?(this._replaceCandle(r,c),a=!0):c.openTime>n&&(this._appendCandle(c),o++)}return{newCandles:o,updatedLastCandle:a}}catch(s){return console.error("Error updating market data:",s),{newCandles:0,updatedLastCandle:!1}}}_replaceCandle(e,i){this.data[e]=i,this.open[e]=i.open,this.close[e]=i.close,this.high[e]=i.high,this.low[e]=i.low,this.volume[e]=i.volume,this.hl2[e]=(i.high+i.low)/2,this.hlc3[e]=(i.high+i.low+i.close)/3,this.ohlc4[e]=(i.high+i.low+i.open+i.close)/4,this.hlcc4[e]=(i.high+i.low+i.close+i.close)/4,this.openTime[e]=i.openTime,this.closeTime[e]=i.closeTime}_appendCandle(e){this.data.push(e),this.open.push(e.open),this.close.push(e.close),this.high.push(e.high),this.low.push(e.low),this.volume.push(e.volume),this.hl2.push((e.high+e.low)/2),this.hlc3.push((e.high+e.low+e.close)/3),this.ohlc4.push((e.high+e.low+e.open+e.close)/4),this.hlcc4.push((e.high+e.low+e.close+e.close)/4),this.openTime.push(e.openTime),this.closeTime.push(e.closeTime)}async updateTail(e){if(this.data.length===0||Array.isArray(this.source))return!1;const{newCandles:i,updatedLastCandle:r}=await this._updateMarketData();if(i===0&&!r)return!1;const n=e._varSnapshot;if(n?this._restoreVarState(e,n):this._removeLastResult(e),Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let o in e.result)Array.isArray(e.result[o])&&e.result[o].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop(),e.data.bar_index.data.pop(),e.dataVersion=(e.dataVersion||0)+1,e.length=this.data.length;const s=this.data.length-(i+1);e.rollbackDrawings(s);const a=this.data.length;return s<a-1?(await this._executeIterations(e,this._transpiledCode,s,a-1),e._varSnapshot=this._snapshotVarState(e),await this._executeIterations(e,this._transpiledCode,a-1,a)):await this._executeIterations(e,this._transpiledCode,s,a),!0}_removeLastResult(e){if(Array.isArray(e.result))e.result.pop();else if(typeof e.result=="object"&&e.result!==null)for(let n in e.result)Array.isArray(e.result[n])&&e.result[n].pop();e.data.close.data.pop(),e.data.open.data.pop(),e.data.high.data.pop(),e.data.low.data.pop(),e.data.volume.data.pop(),e.data.hl2.data.pop(),e.data.hlc3.data.pop(),e.data.ohlc4.data.pop(),e.data.hlcc4.data.pop(),e.data.openTime.data.pop(),e.data.closeTime&&e.data.closeTime.data.pop(),e.data.bar_index.data.pop();const i=["const","var","let","params"],r=n=>{for(let s of i)if(n[s])for(let a in n[s]){const o=n[s][a];o instanceof y?o.data.pop():Array.isArray(o)&&o.pop()}};r(e),e.lctx&&e.lctx.forEach(n=>r(n))}_snapshotVarState(e){const i=["const","var","let","params"],r={main:{},lctx:[]},n=s=>{const a={};for(const o of i)if(s[o]){a[o]={};for(const l in s[o]){const c=s[o][l];if(c instanceof y){const u=c.data.length,p=u>0?c.data[u-1]:void 0;a[o][l]={len:u,lastVal:p}}}}return a};if(r.main=n(e),e.lctx){const s=[];e.lctx.forEach(a=>s.push(n(a))),r.lctx=s}return r.resultLength=this._getResultLength(e.result),r.dataLength=e.data.close?.data?.length??0,r}_restoreVarState(e,i){if(!i)return;const r=["const","var","let","params"],n=(s,a)=>{for(const o of r)if(!(!a[o]||!s[o]))for(const l in a[o]){const c=s[o][l],u=a[o][l];c instanceof y&&u&&typeof u.len=="number"&&(c.data.length>u.len&&(c.data.length=u.len),u.len>0&&u.lastVal!==void 0&&(c.data[u.len-1]=u.lastVal))}};if(n(e,i.main),e.lctx&&i.lctx){let s=0;e.lctx.forEach(a=>{i.lctx[s]&&n(a,i.lctx[s]),s++})}}_initializeContext(e,i={},r=!1){const n=new wn({marketData:this.data,source:this.source,tickerId:this.tickerId,timeframe:this.timeframe,limit:this.limit,sDate:this.sDate,eDate:this.eDate,inputs:i});return n.pine.syminfo=this._syminfo,this._chartTimezone&&(n.chartTimezone=this._chartTimezone),n.viewportLeft=this._viewportLeft,n.viewportRight=this._viewportRight,n.__maxLoops=this._maxLoops,n._alertMode=this._alertMode,n._propOverrides=this._currentIndicator?.getRuntimePropOverrides()??{},n.pineTSCode=e,n.isSecondaryContext=r,n.data.close=new y([]),n.data.open=new y([]),n.data.high=new y([]),n.data.low=new y([]),n.data.volume=new y([]),n.data.hl2=new y([]),n.data.hlc3=new y([]),n.data.ohlc4=new y([]),n.data.hlcc4=new y([]),n.data.openTime=new y([]),n.data.closeTime=new y([]),n.length=this.data.length,n}async _executeIterations(e,i,r,n){const s=["const","var","let","params"];for(let a=r;a<n;a++){e.idx=a,e._execTick=(e._execTick||0)+1,e.data.close.data.push(this.close[a]),e.data.open.data.push(this.open[a]),e.data.high.data.push(this.high[a]),e.data.low.data.push(this.low[a]),e.data.volume.data.push(this.volume[a]),e.data.hl2.data.push(this.hl2[a]),e.data.hlc3.data.push(this.hlc3[a]),e.data.ohlc4.data.push(this.ohlc4[a]),e.data.hlcc4.data.push(this.hlcc4[a]),e.data.openTime.data.push(this.openTime[a]),e.data.closeTime.data.push(this.closeTime[a]),e.data.bar_index.data.push(a),e.strategy&&(Sp(e),Tp(e),Ap(e),Pp(e));const o=await i(e);if(typeof o=="object"){typeof e.result!="object"&&(e.result={});for(let c in o){e.result[c]===void 0&&(e.result[c]=[]);let u;o[c]instanceof y?u=o[c].get(0):Array.isArray(o[c])?u=o[c][o[c].length-1]:u=o[c],e.result[c].push(u)}}else Array.isArray(e.result)||(e.result=[]),e.result.push(o);for(const c of e._drawingHelpers)c.syncToPlot&&c.syncToPlot();const l=c=>{for(let u of s)if(c[u])for(let p in c[u]){const h=c[u][p];if(h instanceof y){const f=h.get(0);h.data.push(f)}else if(Array.isArray(h)){const f=h[h.length-1];h.push(f)}}};l(e),e.lctx&&e.lctx.forEach(c=>l(c))}}}const Gn={"1m":6e4,"3m":18e4,"5m":3e5,"15m":9e5,"30m":18e5,"1h":36e5,"2h":72e5,"4h":144e5,"1d":864e5,"1w":6048e5,"1M":2592e6},gi={"1S":1,"5S":5,"10S":10,"15S":15,"30S":30,1:60,3:180,5:300,15:900,30:1800,45:2700,60:3600,120:7200,180:10800,240:14400,D:86400,W:604800,M:2592e3},Ag={"1S":{periodType:"second",multiplier:1},"5S":{periodType:"second",multiplier:5},"10S":{periodType:"second",multiplier:10},"15S":{periodType:"second",multiplier:15},"30S":{periodType:"second",multiplier:30},1:{periodType:"minute",multiplier:1},3:{periodType:"minute",multiplier:3},5:{periodType:"minute",multiplier:5},15:{periodType:"minute",multiplier:15},30:{periodType:"minute",multiplier:30},45:{periodType:"minute",multiplier:45},60:{periodType:"hour",multiplier:1},120:{periodType:"hour",multiplier:2},180:{periodType:"hour",multiplier:3},240:{periodType:"hour",multiplier:4},D:{periodType:"day",multiplier:1},W:{periodType:"week",multiplier:1},M:{periodType:"month",multiplier:1}};function xi(t,e,i=1){if(e==="month"){const n=new Date(t);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+i,1,n.getUTCHours(),n.getUTCMinutes(),n.getUTCSeconds(),n.getUTCMilliseconds())}const r={second:1e3,minute:6e4,hour:36e5,day:864e5,week:7*864e5};return t+i*r[e]}function lt(t,e,i){const[r,n,s]=t.split("-").map(Number),[a,o]=e.split(":").map(Number),l=Date.UTC(r,n-1,s,a,o,0,0),c=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(new Date(l)),u=b=>parseInt(c.find(v=>v.type===b).value,10);let p=u("year"),h=u("month"),f=u("day"),d=u("hour");d===24&&(d=0);let m=u("minute");const x=Date.UTC(p,h-1,f,d,m,0,0)-l;return l-x}function Yn(t,e,i,r,n=1){if(e==="24x7")return xi(t,r,n);const s=e.split("-")[1];if(!s||s.length!==4)return xi(t,r,n);const a=s.slice(0,2),o=s.slice(2,4),l=`${a}:${o}`,c=Xn(t,i);if(r==="second"||r==="minute"||r==="hour"){const u=t+n*{second:1e3,minute:6e4,hour:36e5}[r],p=lt(c,l,i);return Math.min(u,p)}if(r==="day")return lt(c,l,i);if(r==="week"){const u=new Date(t).getUTCDay(),p=u<=5?5-u:5-u+7,h=t+p*864e5,f=Xn(h,i);return lt(f,l,i)}if(r==="month"){const u=new Date(t),p=u.getUTCFullYear(),h=u.getUTCMonth()+n,f=new Date(Date.UTC(p,h,1)),d=new Date(f.getTime()-864e5);for(;d.getUTCDay()===0||d.getUTCDay()===6;)d.setUTCDate(d.getUTCDate()-1);const m=d.toISOString().split("T")[0];return lt(m,l,i)}return xi(t,r,n)}function Xn(t,e){return new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(t))}function q_(t){for(let e=0;e<t.length-1;e++)t[e].closeTime=t[e+1].openTime;t.length>0&&(t[t.length-1].closeTime=t[t.length-1].closeTime+1)}const z_=["1S","5S","10S","15S","30S","1","3","5","15","30","45","60","120","180","240","D","W","M"];function K_(t,e){if(t==="W"||t==="M")return e.has("D")?"D":null;const i=gi[t];if(!i)return null;const r=z_.filter(n=>n!=="W"&&n!=="M"&&e.has(n)&&gi[n]<i&&i%gi[n]===0);return r.length===0?null:r[r.length-1]}function Ba(t,e){if(t==="W"||t==="M")return 1/0;const i=gi[t],r=gi[e];return!i||!r||r===0?1/0:i/r}function H_(t,e,i){if(t.length===0)return[];if(e==="W")return Y_(t);if(e==="M")return X_(t);const r=Ba(e,i);return G_(t,r)}function G_(t,e){if(t.length===0)return[];const i=[];let r=[t[0]];const n=Z_(t),s=n>0?n*1.5:0;for(let a=1;a<t.length;a++){const o=t[a].openTime-t[a-1].openTime;(s>0&&o>s||r.length>=e)&&(i.push(Zi(r)),r=[]),r.push(t[a])}return r.length>0&&i.push(Zi(r)),i}function Y_(t){const e=[];let i=[],r="";for(const n of t){const s=Q_(n.openTime);s!==r&&i.length>0&&(e.push(i),i=[]),r=s,i.push(n)}return i.length>0&&e.push(i),e.map(Zi)}function X_(t){const e=[];let i=[],r="";for(const n of t){const s=new Date(n.openTime),a=`${s.getUTCFullYear()}-${s.getUTCMonth()}`;a!==r&&i.length>0&&(e.push(i),i=[]),r=a,i.push(n)}return i.length>0&&e.push(i),e.map(Zi)}function Zi(t){const e=t[0],i=t[t.length-1];let r=e.high,n=e.low,s=0,a=0,o=0,l=0,c=0;for(let u=0;u<t.length;u++){const p=t[u];p.high>r&&(r=p.high),p.low<n&&(n=p.low),s+=p.volume,a+=p.quoteAssetVolume,o+=p.numberOfTrades,l+=p.takerBuyBaseAssetVolume,c+=p.takerBuyQuoteAssetVolume}return{openTime:e.openTime,open:e.open,high:r,low:n,close:i.close,volume:s,closeTime:i.closeTime,quoteAssetVolume:a,numberOfTrades:o,takerBuyBaseAssetVolume:l,takerBuyQuoteAssetVolume:c,ignore:0}}function Z_(t){if(t.length<2)return 0;const e=Math.min(t.length-1,20);let i=1/0;for(let r=0;r<e;r++){const n=t[r+1].openTime-t[r].openTime;n>0&&n<i&&(i=n)}return i===1/0?0:i}function Q_(t){const e=new Date(t),i=e.getUTCDay()||7;e.setUTCDate(e.getUTCDate()+4-i);const r=new Date(Date.UTC(e.getUTCFullYear(),0,1)),n=Math.ceil(((e.getTime()-r.getTime())/864e5+1)/7);return`${e.getUTCFullYear()}-W${n}`}var J_=Object.defineProperty,eg=(t,e,i)=>e in t?J_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Pi=(t,e,i)=>eg(t,typeof e!="symbol"?e+"":e,i);const Di={"1s":"1S","5s":"5S","10s":"10S","15s":"15S","30s":"30S","1m":"1","3m":"3","5m":"5","15m":"15","30m":"30","45m":"45","1h":"60","2h":"120","3h":"180","4h":"240","1d":"D","1w":"W","1D":"D","1W":"W","1M":"M","4H":"240",D:"D",W:"W",M:"M"};function tg(t){if(Di[t]!==void 0)return Di[t];const e=t.toLowerCase();return Di[e]!==void 0?Di[e]:/^\d+$/.test(t)?t:/^\d+S$/i.test(t)?t.toUpperCase():t}class ar{constructor(e){Pi(this,"_configured"),Pi(this,"_requiresApiKey"),Pi(this,"_providerName"),Pi(this,"_aggregationSubTimeframe",null),this._requiresApiKey=e.requiresApiKey,this._providerName=e.providerName,this._configured=!e.requiresApiKey}ensureConfigured(){if(!this._configured)throw new Error(`${this._providerName} requires configuration before use. Call Provider.${this._providerName}.configure({ apiKey: '...' }) or instantiate directly: new ${this._providerName}Provider({ apiKey: '...' })`)}configure(e){this._configured=!0}get isConfigured(){return this._configured}normalizeCloseTime(e){q_(e)}setAggregationSubTimeframe(e){this._aggregationSubTimeframe=e}getSupportedTimeframes(){return new Set(["1S","5S","10S","15S","30S","1","3","5","15","30","45","60","120","180","240","D","W","M"])}async getMarketData(e,i,r,n,s){const a=tg(i),o=this.getSupportedTimeframes();if(o.has(a))return this._getMarketDataNative(e,a,r,n,s);const l=this._aggregationSubTimeframe,c=l&&o.has(l)?l:K_(a,o);if(!c)return console.error(`${this._providerName}: Timeframe '${i}' is not supported and no valid sub-timeframe found for aggregation.`),[];const u=this._computeSubLimit(a,c,r),p=await this._getMarketDataNative(e,c,u,n,s);if(p.length===0)return[];const h=H_(p,a,c);return r&&r>0&&h.length>r?h.slice(h.length-r):h}_computeSubLimit(e,i,r){if(!r)return;const n=Ba(e,i);return n===1/0?e==="W"?r*7+14:e==="M"?r*31+31:r*30:Math.ceil(r*n)+Math.ceil(n)}}var ig=Object.defineProperty,rg=(t,e,i)=>e in t?ig(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Qi=(t,e,i)=>rg(t,typeof e!="symbol"?e+"":e,i);const gr="https://api.binance.com/api/v3",Zn="https://api.binance.us/api/v3",Mi={1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",45:null,60:"1h",120:"2h",180:null,240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"};class ng{constructor(e=300*1e3){Qi(this,"cache"),Qi(this,"cacheDuration"),this.cache=new Map,this.cacheDuration=e}generateKey(e){return Object.entries(e).filter(([i,r])=>r!==void 0).map(([i,r])=>`${i}:${r}`).join("|")}get(e){const i=this.generateKey(e),r=this.cache.get(i);return r?Date.now()-r.timestamp>this.cacheDuration?(this.cache.delete(i),null):r.data:null}set(e,i){const r=this.generateKey(e);this.cache.set(r,{data:i,timestamp:Date.now()})}clear(){this.cache.clear()}cleanup(){const e=Date.now();for(const[i,r]of this.cache.entries())e-r.timestamp>this.cacheDuration&&this.cache.delete(i)}}class sg extends ar{constructor(){super({requiresApiKey:!1,providerName:"Binance"}),Qi(this,"cacheManager"),Qi(this,"activeApiUrl",null),this.cacheManager=new ng(300*1e3)}async getBaseUrl(){if(this.activeApiUrl)return this.activeApiUrl;try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${gr}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=gr,this.activeApiUrl}catch{}try{const e=new AbortController,i=setTimeout(()=>e.abort(),5e3),r=await fetch(`${Zn}/ping`,{signal:e.signal});if(clearTimeout(i),r.ok)return this.activeApiUrl=Zn,this.activeApiUrl}catch{}return gr}async _fetchRawChunk(e,i,r,n,s){const a=Mi[i.toUpperCase()];if(!a)return console.error(`Unsupported timeframe: ${i}`),[];let o=`${await this.getBaseUrl()}/klines?symbol=${e}&interval=${a}`;r&&(o+=`&limit=${Math.min(r,1e3)}`),n&&(o+=`&startTime=${n}`),s&&(o+=`&endTime=${s}`);const l=await fetch(o);if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);return(await l.json()).map(c=>({openTime:parseInt(c[0]),open:parseFloat(c[1]),high:parseFloat(c[2]),low:parseFloat(c[3]),close:parseFloat(c[4]),volume:parseFloat(c[5]),closeTime:parseInt(c[6]),quoteAssetVolume:parseFloat(c[7]),numberOfTrades:parseInt(c[8]),takerBuyBaseAssetVolume:parseFloat(c[9]),takerBuyQuoteAssetVolume:parseFloat(c[10]),ignore:c[11]}))}async getMarketDataInterval(e,i,r,n){try{const s=Mi[i.toUpperCase()];if(!s)return console.error(`Unsupported timeframe: ${i}`),[];let a=[],o=r;const l=n,c=Gn[s];if(!c)return console.error(`Duration not defined for interval: ${s}`),[];for(;o<l;){const u=Math.min(o+1e3*c,l),p=await this._fetchRawChunk(e,i,1e3,o,u);if(p.length===0)break;a=a.concat(p),o=p[p.length-1].closeTime+1}return this.normalizeCloseTime(a),a}catch(s){return console.error("Error in getMarketDataInterval:",s),[]}}async getMarketDataBackwards(e,i,r,n){let s=r,a=[],o=n,l=0;const c=Math.ceil(r/1e3)+5;for(;s>0&&l<c;){l++;const u=Math.min(s,1e3),p=await this._fetchRawChunk(e,i,u,void 0,o);if(p.length===0||(a=p.concat(a),s-=p.length,o=p[0].openTime-1,p.length<u))break}return this.normalizeCloseTime(a),a}getSupportedTimeframes(){return new Set(["1","3","5","15","30","60","120","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,s){try{const a=s!==void 0,o={tickerId:e,timeframe:i,limit:r,sDate:n,eDate:s};if(a){const c=this.cacheManager.get(o);if(c)return c}if(!Mi[i.toUpperCase()])return console.error(`Unsupported timeframe: ${i}`),[];if(this.shouldPaginate(i,r,n,s)){if(n&&s){const c=await this.getMarketDataInterval(e,i,n,s),u=r?c.slice(0,r):c;return this.cacheManager.set(o,u),u}else if(r&&r>1e3){const c=await this.getMarketDataBackwards(e,i,r,s);return this.cacheManager.set(o,c),c}}const l=await this._fetchRawChunk(e,i,r,n,s);return this.normalizeCloseTime(l),a&&this.cacheManager.set(o,l),l}catch(a){return console.error("Error in binance.klines:",a),[]}}shouldPaginate(e,i,r,n){if(i&&i>1e3)return!0;if(r&&n){const s=Mi[e.toUpperCase()],a=Gn[s];if(a)return Math.ceil((n-r)/a)>1e3}return!1}async getSymbolInfo(e){try{let i="crypto",r=await this.getBaseUrl(),n=e,s="";e.endsWith(".P")?(i="futures",n=e.replace(".P",""),r="https://fapi.binance.com/fapi/v1",s="Perpetual"):e.includes("_")&&(i="futures",n=e,r="https://dapi.binance.com/dapi/v1",s="Delivery");const a=i==="crypto"?`${r}/exchangeInfo?symbol=${n}`:`${r}/exchangeInfo`,o=await fetch(a);if(!o.ok)throw new Error(`HTTP error! status: ${o.status}`);const l=(await o.json()).symbols;if(!l||l.length===0)return console.error(`Symbol ${e} not found`),null;const c=i==="futures"?l.find(w=>w.symbol===n):l[0];if(!c)return console.error(`Symbol ${n} not found in exchange info`),null;const u=c.filters?.find(w=>w.filterType==="PRICE_FILTER"),p=c.filters?.find(w=>w.filterType==="LOT_SIZE"),h=u?parseFloat(u.tickSize):.01,f=p?parseFloat(p.minQty):0,d=Math.round(1/h),m=c.baseAsset,x=c.quoteAsset,b=s?` ${s}`:"",v=`${m} / ${x}${b}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:m,description:v,type:i,main_tickerid:`BINANCE:${e}`,current_contract:s,isin:"",basecurrency:m,currency:x,timezone:"Etc/UTC",country:"",mintick:h,pricescale:d,minmove:1,pointvalue:c.contractSize||1,mincontract:f,session:"24x7",volumetype:"base",expiration_date:c.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in binance.exchangeInfo:",i),null}}}var ag=Object.defineProperty,og=(t,e,i)=>e in t?ag(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,li=(t,e,i)=>og(t,typeof e!="symbol"?e+"":e,i);const lg="https://financialmodelingprep.com",Qn=new Set(["USD","EUR","GBP","JPY","CHF","AUD","CAD","NZD","SEK","NOK","DKK","SGD","HKD","KRW","MXN","ZAR","TRY","BRL","INR","CNY","PLN","CZK","HUF","ILS","THB","TWD","PHP","IDR","MYR","RUB","CLP","COP"]),Jn={"1D":{endpoint:"/stable/historical-price-eod/full",type:"daily"},D:{endpoint:"/stable/historical-price-eod/full",type:"daily"},1:{endpoint:"/stable/historical-chart/1min",interval:"1min",type:"intraday"},5:{endpoint:"/stable/historical-chart/5min",interval:"5min",type:"intraday"},15:{endpoint:"/stable/historical-chart/15min",interval:"15min",type:"intraday"},30:{endpoint:"/stable/historical-chart/30min",interval:"30min",type:"intraday"},60:{endpoint:"/stable/historical-chart/1hour",interval:"1hour",type:"intraday"},240:{endpoint:"/stable/historical-chart/4hour",interval:"4hour",type:"intraday"},"4H":{endpoint:"/stable/historical-chart/4hour",interval:"4hour",type:"intraday"}},es={NASDAQ:"America/New_York",NYSE:"America/New_York",AMEX:"America/New_York",NYSEArca:"America/New_York",BATS:"America/New_York",OTC:"America/New_York",PNK:"America/New_York",TSX:"America/Toronto",TSXV:"America/Toronto",LSE:"Europe/London",EURONEXT:"Europe/Paris",XETRA:"Europe/Berlin",JPX:"Asia/Tokyo",HKSE:"Asia/Hong_Kong",SSE:"Asia/Shanghai",SHZ:"Asia/Shanghai",ASX:"Australia/Sydney",NSE:"Asia/Kolkata",BSE:"Asia/Kolkata",KRX:"Asia/Seoul",CRYPTO:"Etc/UTC"},ts={NASDAQ:"0930-1600",NYSE:"0930-1600",AMEX:"0930-1600",NYSEArca:"0930-1600",BATS:"0930-1600",OTC:"0930-1600",PNK:"0930-1600",TSX:"0930-1600",TSXV:"0930-1600",LSE:"0800-1630",EURONEXT:"0900-1730",XETRA:"0900-1730",JPX:"0900-1530",HKSE:"0930-1600",SSE:"0930-1500",SHZ:"0930-1500",ASX:"1000-1600",NSE:"0915-1530",BSE:"0915-1530",KRX:"0900-1530",CRYPTO:"24x7"},cg={daily:{periodType:"day",multiplier:1},"1min":{periodType:"minute",multiplier:1},"5min":{periodType:"minute",multiplier:5},"15min":{periodType:"minute",multiplier:15},"30min":{periodType:"minute",multiplier:30},"1hour":{periodType:"hour",multiplier:1},"4hour":{periodType:"hour",multiplier:4}};class ug extends ar{constructor(e){super({requiresApiKey:!0,providerName:"FMP"}),li(this,"_apiKey",null),li(this,"_baseUrl",lg),li(this,"_profileCache",new Map),li(this,"_symbolInfoCache",new Map),li(this,"_mintickCache",new Map),e?.apiKey&&this.configure(e)}configure(e){super.configure(e),this._apiKey=e.apiKey,e.baseUrl&&(this._baseUrl=e.baseUrl)}getSupportedTimeframes(){return new Set(["1","5","15","30","60","240","D"])}async _getMarketDataNative(e,i,r,n,s){this.ensureConfigured();try{const a=i.toUpperCase(),o=Jn[a]||Jn[i];if(!o)return console.error(`FMP: Unsupported timeframe: ${i}`),[];let l;if(o.type==="intraday"?l=await this._fetchIntradayData(e,o.endpoint,o.interval,n,s,r):l=await this._fetchDailyData(e,n,s,r),l.length>0&&!this._mintickCache.has(e)){const c=this._estimateMintick(l);c!==void 0&&this._mintickCache.set(e,c)}return l}catch(a){return console.error("Error in FMPProvider.getMarketData:",a),[]}}async _fetchDailyData(e,i,r,n){let s=`${this._baseUrl}/stable/historical-price-eod/full?symbol=${e}&apikey=${this._apiKey}`;i&&(s+=`&from=${this._msToDateStr(i)}`),r&&(s+=`&to=${this._msToDateStr(r)}`);const a=await fetch(s);if(!a.ok){const p=await a.text();throw new Error(`FMP HTTP ${a.status}: ${p}`)}const o=await a.json();if(!Array.isArray(o)||o.length===0)return[];o.reverse();const l=n&&n>0&&n<o.length?o.slice(o.length-n):o,{session:c,timezone:u}=await this._resolveSessionInfo(e);return l.map(p=>{const h=this._dateStrToMs(p.date),f=Yn(h,c,u,"day");return{openTime:h,open:p.open,high:p.high,low:p.low,close:p.close,volume:p.volume,closeTime:f,quoteAssetVolume:0,numberOfTrades:0,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}})}async _fetchIntradayData(e,i,r,n,s,a){let o=`${this._baseUrl}${i}?symbol=${e}&apikey=${this._apiKey}`;n&&(o+=`&from=${this._msToDateStr(n)}`),s&&(o+=`&to=${this._msToDateStr(s)}`);const l=await fetch(o);if(!l.ok){const m=await l.text();if(l.status===403||m.includes("Restricted Endpoint"))return console.error(`FMP: Intraday data (${r}) requires a paid plan. Use daily timeframe ('D') with a free API key, or upgrade at https://financialmodelingprep.com/`),[];throw new Error(`FMP HTTP ${l.status}: ${m}`)}const c=await l.json();if(!Array.isArray(c)||c.length===0)return[];c.reverse();const u=a&&a>0&&a<c.length?c.slice(c.length-a):c,{periodType:p,multiplier:h}=cg[r]||{periodType:"minute",multiplier:1},{session:f,timezone:d}=await this._resolveSessionInfo(e);return u.map(m=>{const x=this._dateTimeStrToMs(m.date),b=Yn(x,f,d,p,h);return{openTime:x,open:m.open,high:m.high,low:m.low,close:m.close,volume:m.volume,closeTime:b,quoteAssetVolume:0,numberOfTrades:0,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}})}async getSymbolInfo(e){if(this.ensureConfigured(),this._symbolInfoCache.has(e))return this._symbolInfoCache.get(e);try{const i=await this._fetchProfile(e);let r="stock";i?.isEtf?r="etf":i?.isFund?r="fund":this._isForex(e)?r="forex":this._isCrypto(e)&&(r="crypto");const n=i?.exchange||(r==="crypto"?"CRYPTO":r==="forex"?"FX":""),s=r==="crypto"||r==="forex"?"Etc/UTC":es[n]||"America/New_York",a=r==="crypto"?"24x7":r==="forex"?"0000-0000":ts[n]||"0930-1600",o=i?.currency||(this._isForex(e)?e.slice(3,6):"USD"),l=this._isForex(e)?e.slice(0,3):i?.currency||"USD",c=this._mintickCache.get(e)??.01,u=Math.round(1/c),p=Math.round(c*u),h={ticker:i?.symbol||e,tickerid:`${n}:${i?.symbol||e}`,prefix:n,root:i?.symbol||e,description:i?.companyName||e,type:r,main_tickerid:`${n}:${i?.symbol||e}`,current_contract:"",isin:i?.isin||"",basecurrency:l,currency:o,timezone:s,country:i?.country||"",mintick:c,pricescale:u,minmove:p,pointvalue:1,mincontract:0,session:a,volumetype:"base",expiration_date:0,employees:i&&parseInt(i.fullTimeEmployees)||0,industry:i?.industry||"",sector:i?.sector||"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0};return this._mintickCache.has(e)&&this._symbolInfoCache.set(e,h),h}catch(i){return console.error("Error in FMPProvider.getSymbolInfo:",i),null}}_estimateMintick(e){const i=[];for(let o=0;o<e.length;o++){const l=e[o],c=Math.abs(l.close-l.open),u=Math.abs(l.high-l.low);if(c>0&&i.push(c),u>0&&i.push(u),o>0){const p=Math.abs(l.close-e[o-1].close);p>0&&i.push(p)}}if(i.length===0)return;const r=Math.min(...i),n=Math.floor(Math.log10(r)),s=r/10**n,a=(Math.floor(s+1e-12)<5?1:10)*10**n;return a>=1?.01:a}async _fetchProfile(e){if(this._profileCache.has(e))return this._profileCache.get(e);const i=`${this._baseUrl}/stable/profile?symbol=${e}&apikey=${this._apiKey}`,r=await fetch(i);if(!r.ok)return null;const n=await r.json();if(!Array.isArray(n)||n.length===0)return null;const s=n[0];return this._profileCache.set(e,s),s}async _resolveSessionInfo(e){try{const i=await this._fetchProfile(e);if(i){const r=i.exchange||"",n=this._isCrypto(e),s=n?"Etc/UTC":es[r]||"America/New_York";return{session:n?"24x7":ts[r]||"0930-1600",timezone:s}}}catch{}return{session:"0930-1600",timezone:"America/New_York"}}_msToDateStr(e){return new Date(e).toISOString().split("T")[0]}_dateStrToMs(e){return new Date(e+"T00:00:00Z").getTime()}_dateTimeStrToMs(e){return new Date(e.replace(" ","T")+"Z").getTime()}_isForex(e){return/^[A-Z]{6}$/.test(e)&&Qn.has(e.slice(0,3))&&Qn.has(e.slice(3,6))}_isCrypto(e){return this._isForex(e)?!1:/^[A-Z]+(USD|USDT|BTC|ETH)$/.test(e)&&e.length<=15}}var hg=Object.defineProperty,pg=(t,e,i)=>e in t?hg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,Dt=(t,e,i)=>pg(t,typeof e!="symbol"?e+"":e,i);const fg="https://data.alpaca.markets",dg="https://paper-api.alpaca.markets/v2",mg="https://api.alpaca.markets/v2",xr=1e4,is={1:"1Min",3:"3Min",5:"5Min",15:"15Min",30:"30Min",60:"1Hour",120:"2Hour",240:"4Hour","4H":"4Hour","1D":"1Day",D:"1Day","1W":"1Week",W:"1Week","1M":"1Month",M:"1Month"},yg={NASDAQ:"America/New_York",NYSE:"America/New_York",AMEX:"America/New_York",ARCA:"America/New_York",BATS:"America/New_York",OTC:"America/New_York",CRYPTO:"Etc/UTC"},_g={NASDAQ:"0930-1600",NYSE:"0930-1600",AMEX:"0930-1600",ARCA:"0930-1600",BATS:"0930-1600",OTC:"0930-1600",CRYPTO:"24x7"},gg={Min:"minute",Hour:"hour",Day:"day",Week:"week",Month:"month"};class xg extends ar{constructor(e){super({requiresApiKey:!0,providerName:"Alpaca"}),Dt(this,"_apiKey",null),Dt(this,"_apiSecret",null),Dt(this,"_dataUrl",fg),Dt(this,"_tradingUrl",dg),Dt(this,"_feed",null),Dt(this,"_assetCache",new Map),Dt(this,"_calendarCache",new Map),e?.apiKey&&e?.apiSecret&&this.configure(e)}configure(e){super.configure(e),this._apiKey=e.apiKey,this._apiSecret=e.apiSecret,e.feed&&(this._feed=e.feed),e.dataUrl&&(this._dataUrl=e.dataUrl),e.tradingUrl?this._tradingUrl=e.tradingUrl:e.paper===!1&&(this._tradingUrl=mg)}_headers(){return{"APCA-API-KEY-ID":this._apiKey,"APCA-API-SECRET-KEY":this._apiSecret}}getSupportedTimeframes(){return new Set(["1","3","5","15","30","45","60","120","180","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,s){this.ensureConfigured();try{const a=this._resolveTimeframe(i);if(!a)return console.error(`Alpaca: Unsupported timeframe: ${i}`),[];const o=this._isCrypto(e),l=await this._fetchAllBars(e,a,o,n,s,r);if(l.length===0)return[];const{periodType:c,multiplier:u}=this._parseAlpacaTimeframe(a);if(o)return this._convertBarsCrypto(l,c,u);const p=l[0].t.slice(0,10),h=l[l.length-1].t.slice(0,10),f=this._addDaysToDate(h,40);return await this._ensureCalendar(p,f),this._convertBarsStock(l,c,u)}catch(a){return console.error("Error in AlpacaProvider.getMarketData:",a),[]}}async _fetchAllBars(e,i,r,n,s,a){const o=[];let l=null;const c=a||1/0,u=Math.min(a||xr,xr);do{const p=this._buildBarsUrl(e,i,r,n,s,u,l),h=await fetch(p,{headers:this._headers()});if(!h.ok){const m=await h.text();throw new Error(`Alpaca HTTP ${h.status}: ${m}`)}const f=await h.json(),d=Object.keys(f.bars||{})[0];if(!d||!f.bars[d]||(o.push(...f.bars[d]),l=f.next_page_token,o.length>=c))break}while(l);return a&&a>0&&o.length>a?o.slice(0,a):o}_buildBarsUrl(e,i,r,n,s,a,o){const l=r?`${this._dataUrl}/v1beta3/crypto/us/bars`:`${this._dataUrl}/v2/stocks/bars`,c=new URLSearchParams;return c.set("symbols",e),c.set("timeframe",i),c.set("sort","asc"),n&&c.set("start",new Date(n).toISOString()),s&&c.set("end",new Date(s).toISOString()),a&&c.set("limit",String(Math.min(a,xr))),o&&c.set("page_token",o),!r&&this._feed&&c.set("feed",this._feed),`${l}?${c.toString()}`}async getSymbolInfo(e){this.ensureConfigured();try{const i=await this._fetchAsset(e);if(!i)return console.error(`Alpaca: Symbol ${e} not found`),null;const r=i.exchange||"",n=i.class==="crypto",s=n?"Etc/UTC":yg[r]||"America/New_York",a=n?"24x7":_g[r]||"0930-1600";let o="stock";n&&(o="crypto");const l=n&&e.split("/")[1]||"USD",c=n?e.split("/")[0]||e:l,u=i.price_increment?parseFloat(i.price_increment):.01,p=Math.round(1/u);return{ticker:i.symbol,tickerid:`${r}:${i.symbol}`,prefix:r,root:n?e.split("/")[0]:i.symbol,description:i.name||i.symbol,type:o,main_tickerid:`${r}:${i.symbol}`,current_contract:"",isin:"",basecurrency:c,currency:l,timezone:s,country:n?"":"US",mintick:u,pricescale:p,minmove:1,pointvalue:1,mincontract:i.min_order_size?parseFloat(i.min_order_size):0,session:a,volumetype:"base",expiration_date:0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in AlpacaProvider.getSymbolInfo:",i),null}}_convertBarsCrypto(e,i,r){return e.map((n,s,a)=>{const o=new Date(n.t).getTime(),l=s<a.length-1?new Date(a[s+1].t).getTime():xi(o,i,r);return this._toKline(n,o,l)})}_convertBarsStock(e,i,r){const n="America/New_York";return e.map(s=>{const a=new Date(s.t).getTime(),o=s.t.slice(0,10);let l;if(i==="day"){const c=this._calendarCache.get(o),u=c?c.close:"16:00";l=lt(o,u,n)}else if(i==="minute"||i==="hour"){const c=a+r*{minute:6e4,hour:36e5}[i],u=this._calendarCache.get(o),p=u?u.close:"16:00",h=lt(o,p,n);l=Math.min(c,h)}else i==="week"?l=this._weeklyCloseFromCalendar(o,n):i==="month"?l=this._monthlyCloseFromCalendar(o,n):l=xi(a,i,r);return this._toKline(s,a,l)})}_toKline(e,i,r){return{openTime:i,open:e.o,high:e.h,low:e.l,close:e.c,volume:e.v,closeTime:r,quoteAssetVolume:0,numberOfTrades:e.n,takerBuyBaseAssetVolume:0,takerBuyQuoteAssetVolume:0,ignore:0}}_weeklyCloseFromCalendar(e,i){const r=new Date(e+"T00:00:00Z"),n=r.getUTCDay(),s=n<=5?5-n:5-n+7;for(let l=s;l>=0;l--){const c=r.getTime()+l*864e5,u=new Date(c).toISOString().split("T")[0],p=this._calendarCache.get(u);if(p)return lt(u,p.close,i)}const a=r.getTime()+s*864e5,o=new Date(a).toISOString().split("T")[0];return lt(o,"16:00",i)}_monthlyCloseFromCalendar(e,i){const[r,n]=e.split("-").map(Number),s=new Date(Date.UTC(r,n,0)).getUTCDate();for(let o=s;o>=1;o--){const l=`${r}-${String(n).padStart(2,"0")}-${String(o).padStart(2,"0")}`,c=this._calendarCache.get(l);if(c)return lt(l,c.close,i)}const a=new Date(Date.UTC(r,n,0));for(;a.getUTCDay()===0||a.getUTCDay()===6;)a.setUTCDate(a.getUTCDate()-1);return lt(a.toISOString().split("T")[0],"16:00",i)}async _ensureCalendar(e,i){if(this._calendarCache.has(e)&&this._calendarCache.has(i))return;const r=`${this._tradingUrl}/calendar?start=${e}&end=${i}`,n=await fetch(r,{headers:this._headers()});if(!n.ok){console.warn(`Alpaca calendar API returned ${n.status}, falling back to defaults`);return}const s=await n.json();for(const a of s)this._calendarCache.set(a.date,a)}async _fetchAsset(e){if(this._assetCache.has(e))return this._assetCache.get(e);const i=encodeURIComponent(e),r=`${this._tradingUrl}/assets/${i}`,n=await fetch(r,{headers:this._headers()});if(!n.ok)return null;const s=await n.json();return this._assetCache.set(e,s),s}_parseAlpacaTimeframe(e){const i=e.match(/^(\d+)(Min|Hour|Day|Week|Month)$/);if(i){const r=parseInt(i[1],10),n=gg[i[2]];if(n)return{periodType:n,multiplier:r}}return{periodType:"day",multiplier:1}}_resolveTimeframe(e){return is[e.toUpperCase()]||is[e]||null}_isCrypto(e){return e.includes("/")}_addDaysToDate(e,i){const r=new Date(e+"T00:00:00Z");return r.setUTCDate(r.getUTCDate()+i),r.toISOString().split("T")[0]}}var bg=Object.defineProperty,vg=(t,e,i)=>e in t?bg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,br=(t,e,i)=>vg(t,typeof e!="symbol"?e+"":e,i);const wg=Wa(import.meta.url),Sg=ci.dirname(wg);class Eg extends ar{constructor(e){super({requiresApiKey:!1,providerName:"Mock"}),br(this,"dataCache",new Map),br(this,"exchangeInfoCache",{}),br(this,"dataDirectory");const i=typeof e=="string"?e:e?.dataDirectory;if(i)this.dataDirectory=i;else{const r=ci.resolve(Sg,"../../../");this.dataDirectory=ci.join(r,"tests","compatibility","_data")}}configure(e){super.configure(e),e.dataDirectory&&(this.dataDirectory=e.dataDirectory)}getDataFileName(e,i,r,n){return r&&n?`${e}-${i}-${r}-${n}.json`:null}loadDataFromFile(e){const i=`file:${e}`;if(this.dataCache.has(i))return this.dataCache.get(i);const r=ci.join(this.dataDirectory,e);if(!Ut.existsSync(r))throw new Error(`Mock data file not found: ${r}`);const n=Ut.readFileSync(r,"utf-8"),s=JSON.parse(n);return this.dataCache.set(i,s),s}findDataFile(e,i,r,n){if(!Ut.existsSync(this.dataDirectory))return null;const s=Ut.readdirSync(this.dataDirectory).filter(l=>l.endsWith(".json"));if(r&&n){const l=`${e}-${i}-${r}-${n}.json`;if(s.includes(l))return l}const a=new RegExp(`^${e}-${i}-(\\d+)-(\\d+)\\.json$`),o=s.filter(l=>a.test(l)).map(l=>{const c=l.match(a);return{file:l,startTime:parseInt(c[1]),endTime:parseInt(c[2])}}).sort((l,c)=>c.endTime-l.endTime);if(o.length===0)return null;if(r&&n){const l=o.find(c=>c.startTime<=r&&c.endTime>=n);if(l)return l.file}return o[0].file}filterData(e,i,r,n){let s=e;return(i||r)&&(s=e.filter(a=>{const o=!i||a.openTime>=i,l=!r||a.openTime<=r;return o&&l})),s.sort((a,o)=>a.openTime-o.openTime),n&&n>0&&(s=s.slice(0,n)),s}normalizeTimeframe(e){return{1:"1m",3:"3m",5:"5m",15:"15m",30:"30m",60:"1h",120:"2h",240:"4h","4H":"4h","1D":"1d",D:"1d","1W":"1w",W:"1w","1M":"1M",M:"1M"}[e.toUpperCase()]||e.toLowerCase()}getSupportedTimeframes(){return new Set(["1","3","5","15","30","45","60","120","180","240","D","W","M"])}async _getMarketDataNative(e,i,r,n,s){try{const a=this.normalizeTimeframe(i),o=this.findDataFile(e,a,n,s);if(!o)return console.warn(`No mock data file found for ${e} ${a}. Searched in: ${this.dataDirectory}`),[];const l=this.loadDataFromFile(o),c=this.filterData(l,n,s,r);return this.normalizeCloseTime(c),c}catch(a){return console.error("Error in MockProvider.getMarketData:",a),[]}}loadExchangeInfo(e){if(this.exchangeInfoCache[e])return this.exchangeInfoCache[e];const i=e==="spot"?"api-exchangeInfo.json":"fapi-exchangeInfo.json",r=ci.join(this.dataDirectory,i);if(!Ut.existsSync(r))return console.warn(`Exchange info file not found: ${r}`),null;try{const n=Ut.readFileSync(r,"utf-8"),s=JSON.parse(n);return this.exchangeInfoCache[e]=s,s}catch(n){return console.error(`Error loading exchange info from ${i}:`,n),null}}async getSymbolInfo(e){try{let i="crypto",r=e,n="";e.endsWith(".P")?(i="futures",r=e.replace(".P",""),n="Perpetual"):e.includes("_")&&(i="futures",r=e,n="Delivery");const s=this.loadExchangeInfo(i==="futures"?"futures":"spot");if(!s||!s.symbols)return console.error(`Exchange info not available for ${i}`),null;const a=s.symbols.find(x=>x.symbol===r);if(!a)return console.error(`Symbol ${r} not found in ${i} exchange info`),null;const o=a.filters?.find(x=>x.filterType==="PRICE_FILTER"),l=a.filters?.find(x=>x.filterType==="LOT_SIZE"),c=o?parseFloat(o.tickSize):.01,u=l?parseFloat(l.minQty):0,p=Math.round(1/c),h=a.baseAsset,f=a.quoteAsset,d=n?` ${n}`:"",m=`${h} / ${f}${d}`;return{ticker:e,tickerid:`BINANCE:${e}`,prefix:"BINANCE",root:h,description:m,type:i,main_tickerid:`BINANCE:${e}`,current_contract:n,isin:"",basecurrency:h,currency:f,timezone:"Etc/UTC",country:"",mintick:c,pricescale:p,minmove:1,pointvalue:a.contractSize||1,mincontract:u,session:"24x7",volumetype:"base",expiration_date:a.deliveryDate||0,employees:0,industry:"",sector:"",shareholders:0,shares_outstanding_float:0,shares_outstanding_total:0,recommendations_buy:0,recommendations_buy_strong:0,recommendations_date:0,recommendations_hold:0,recommendations_sell:0,recommendations_sell_strong:0,recommendations_total:0,target_price_average:0,target_price_date:0,target_price_estimates:0,target_price_high:0,target_price_low:0,target_price_median:0}}catch(i){return console.error("Error in MockProvider.getSymbolInfo:",i),null}}clearCache(){this.dataCache.clear(),this.exchangeInfoCache={}}setDataDirectory(e){this.dataDirectory=e,this.clearCache()}}const Ng=typeof process<"u"&&process.versions&&process.versions.node;let Ji=null;if(Ng)try{Ji=new Eg}catch{Ji=null}const Pg={Binance:new sg,FMP:new ug,Alpaca:new xg,...Ji?{Mock:Ji}:{}};var Cg=Object.defineProperty,Ig=(t,e,i)=>e in t?Cg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,kg=(t,e,i)=>Ig(t,typeof e!="symbol"?e+"":e,i);class Dg extends Error{constructor(e,i){super(e),kg(this,"method"),this.name="PineRuntimeError",this.method=i}}export{xg as AlpacaProvider,ar as BaseProvider,sg as BinanceProvider,wn as Context,ug as FMPProvider,$a as INDICATOR_PROPS,vi as Indicator,Dg as PineRuntimeError,nn as PineTS,Pg as Provider,Va as STRATEGY_PROPS,Ag as TIMEFRAME_PERIOD_INFO,gi as TIMEFRAME_SECONDS,H_ as aggregateCandles,xi as computeNextPeriodStart,Yn as computeSessionClose,Ba as getAggregationRatio,lt as localTimeToUTC,M_ as propsForDeclaration,K_ as selectSubTimeframe};
|
|
125
125
|
//# sourceMappingURL=pinets.min.es.js.map
|