UNPKG

ag-charts-core

Version:

Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue

4 lines (3 loc) 39.8 kB
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(e,t)=>{for(var n in t)__defProp(e,n,{get:t[n],enumerable:!0})},__copyProps=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of __getOwnPropNames(t))!__hasOwnProp.call(e,i)&&i!==n&&__defProp(e,i,{get:()=>t[i],enumerable:!(r=__getOwnPropDesc(t,i))||r.enumerable});return e},__toCommonJS=e=>__copyProps(__defProp({},"__esModule",{value:!0}),e),main_exports={};__export(main_exports,{AdjacencyListGraph:()=>AdjacencyListGraph,AsyncAwaitQueue:()=>AsyncAwaitQueue,CleanupRegistry:()=>CleanupRegistry,ErrorType:()=>ErrorType,EventEmitter:()=>EventEmitter,Logger:()=>logger_exports,ModuleRegistry:()=>moduleRegistry_exports,ModuleType:()=>ModuleType,SimpleCache:()=>SimpleCache,UnknownError:()=>UnknownError,ValidationError:()=>ValidationError,Vertex:()=>Vertex,WeakCache:()=>WeakCache,and:()=>and,array:()=>array,arrayLength:()=>arrayLength,arrayOf:()=>arrayOf,arrayOfDefs:()=>arrayOfDefs,arraysEqual:()=>arraysEqual,attachDescription:()=>attachDescription,attachListener:()=>attachListener,barHighlightOptionsDef:()=>barHighlightOptionsDef,boolean:()=>boolean,borderOptionsDef:()=>borderOptionsDef,boxCollides:()=>boxCollides,boxContains:()=>boxContains,boxEmpty:()=>boxEmpty,boxesEqual:()=>boxesEqual,callback:()=>callback,callbackDefs:()=>callbackDefs,callbackOf:()=>callbackOf,circularSliceArray:()=>circularSliceArray,clamp:()=>clamp,color:()=>color,colorStopsOrderValidator:()=>colorStopsOrderValidator,colorUnion:()=>colorUnion,constant:()=>constant,countFractionDigits:()=>countFractionDigits,countLines:()=>countLines,createElement:()=>createElement,createElementId:()=>createElementId,createId:()=>createId,createNumberFormatter:()=>createNumberFormatter,createSvgElement:()=>createSvgElement,date:()=>date,debounce:()=>debounce,defined:()=>defined,diffArrays:()=>diffArrays,downloadUrl:()=>downloadUrl,dropFirstWhile:()=>dropFirstWhile,dropLastWhile:()=>dropLastWhile,entries:()=>entries,fillGradientDefaults:()=>fillGradientDefaults,fillImageDefaults:()=>fillImageDefaults,fillOptionsDef:()=>fillOptionsDef,fillPatternDefaults:()=>fillPatternDefaults,findMaxIndex:()=>findMaxIndex,findMaxValue:()=>findMaxValue,findMinIndex:()=>findMinIndex,findMinValue:()=>findMinValue,first:()=>first,fontFamilyFull:()=>fontFamilyFull,fontOptionsDef:()=>fontOptionsDef,generateUUID:()=>generateUUID,geoJson:()=>geoJson,getAttribute:()=>getAttribute,getDocument:()=>getDocument,getMaxInnerRectSize:()=>getMaxInnerRectSize,getWindow:()=>getWindow,googleFont:()=>googleFont,gradientColorStops:()=>gradientColorStops,gradientStrict:()=>gradientStrict,greaterThan:()=>greaterThan,groupBy:()=>groupBy,hasRequiredInPath:()=>hasRequiredInPath,highlightOptionsDef:()=>highlightOptionsDef,htmlElement:()=>htmlElement,inRange:()=>inRange,insertListItemsSorted:()=>insertListItemsSorted,instanceOf:()=>instanceOf,isArray:()=>isArray,isBoolean:()=>isBoolean,isColor:()=>isColor,isDate:()=>isDate,isDefined:()=>isDefined,isEmptyObject:()=>isEmptyObject,isEnumKey:()=>isEnumKey,isEnumValue:()=>isEnumValue,isFiniteNumber:()=>isFiniteNumber,isFunction:()=>isFunction,isHtmlElement:()=>isHtmlElement,isInteger:()=>isInteger,isKeyOf:()=>isKeyOf,isNegative:()=>isNegative,isNumber:()=>isNumber,isNumberEqual:()=>isNumberEqual,isObject:()=>isObject,isObjectLike:()=>isObjectLike,isPlainObject:()=>isPlainObject,isRegExp:()=>isRegExp,isString:()=>isString,isSymbol:()=>isSymbol,isValidDate:()=>isValidDate,isValidNumberFormat:()=>isValidNumberFormat,iterate:()=>iterate,joinFormatted:()=>joinFormatted,kebabCase:()=>kebabCase,labelBoxOptionsDef:()=>labelBoxOptionsDef,lessThan:()=>lessThan,levenshteinDistance:()=>levenshteinDistance,lineDashOptionsDef:()=>lineDashOptionsDef,lineHighlightOptionsDef:()=>lineHighlightOptionsDef,modulus:()=>modulus,multiSeriesHighlightOptionsDef:()=>multiSeriesHighlightOptionsDef,number:()=>number,numberMin:()=>numberMin,numberRange:()=>numberRange,object:()=>object,optionsDefs:()=>optionsDefs,or:()=>or,padding:()=>padding,paddingOptions:()=>paddingOptions,parseColor:()=>parseColor,parseNumberFormat:()=>parseNumberFormat,pause:()=>pause,positiveNumber:()=>positiveNumber,positiveNumberNonZero:()=>positiveNumberNonZero,ratio:()=>ratio,required:()=>required,resetIds:()=>resetIds,roundTo:()=>roundTo,safeCall:()=>safeCall,setAttribute:()=>setAttribute,setAttributes:()=>setAttributes,setDocument:()=>setDocument,setElementStyle:()=>setElementStyle,setElementStyles:()=>setElementStyles,setWindow:()=>setWindow,shapeHighlightOptionsDef:()=>shapeHighlightOptionsDef,sortBasedOnArray:()=>sortBasedOnArray,string:()=>string,stringLength:()=>stringLength,stringifyValue:()=>stringifyValue,strokeOptionsDef:()=>strokeOptionsDef,themeOperator:()=>themeOperator,throttle:()=>throttle,toArray:()=>toArray,toIterable:()=>toIterable,toPlainText:()=>toPlainText,typeUnion:()=>typeUnion,undocumented:()=>undocumented,union:()=>union,unionSymbol:()=>unionSymbol,unique:()=>unique,validate:()=>validate}),module.exports=__toCommonJS(main_exports);var logger_exports={};__export(logger_exports,{error:()=>error,errorOnce:()=>errorOnce,log:()=>log,logGroup:()=>logGroup,reset:()=>reset,table:()=>table,warn:()=>warn,warnOnce:()=>warnOnce});var doOnceCache=new Set;function log(...e){console.log(...e)}function warn(e,...t){console.warn(`AG Charts - ${e}`,...t)}function error(e,...t){typeof e=="object"?console.error("AG Charts error",e,...t):console.error(`AG Charts - ${e}`,...t)}function table(...e){console.table(...e)}function guardOnce(e,t,n){let r;e instanceof Error?r=e.message:typeof e=="string"?r=e:typeof e=="object"?r=JSON.stringify(e):r=String(e);const i=`${t}: ${r}`;doOnceCache.has(i)||(n(e),doOnceCache.add(i))}function warnOnce(e,...t){guardOnce(e,"Logger.warn",n=>warn(n,...t))}function errorOnce(e,...t){guardOnce(e,"Logger.error",n=>error(n,...t))}function reset(){doOnceCache.clear()}function logGroup(e,t){console.groupCollapsed(e);try{return t()}finally{console.groupEnd()}}var moduleRegistry_exports={};__export(moduleRegistry_exports,{detectChartDefinition:()=>detectChartDefinition,getAxisModule:()=>getAxisModule,getPresetModule:()=>getPresetModule,getSeriesModule:()=>getSeriesModule,hasModule:()=>hasModule,listModulesByType:()=>listModulesByType,register:()=>register,registerMany:()=>registerMany,reset:()=>reset2});var ModuleType=(e=>(e.Axis="axis",e.Chart="chart",e.Preset="preset",e.Plugin="plugin",e.Series="series",e))(ModuleType||{}),registeredModules=new Map;function register(e,t){const{def:n,version:r}=registeredModules.get(e.name)??{};if(!n){registeredModules.set(e.name,{def:e,version:t});return}if(!n.enterprise&&e.enterprise&&t===r){registeredModules.set(e.name,{def:e,version:t});return}if(r===t){warn([`AG Charts - Module '${e.name}' already registered,', 'ignoring (version: ${r}).`,"Check your code for duplicate loading of charts NPM modules."].join(" "));return}throw new Error([`AG Charts - Module '${e.name}' already registered with different version:`,`${r} vs ${t}`,"","Check your package.json for conflicting dependencies - depending on your package manager","one of these commands may help:","- npm ls ag-charts-community","- yarn why ag-charts-community"].join(` `))}function registerMany(e,t){for(const n of e)register(n,t)}function reset2(){registeredModules.clear()}function hasModule(e){return registeredModules.has(e)}function*listModulesByType(e){for(const t of registeredModules.values())isModuleType(e,t.def)&&(yield t.def)}function detectChartDefinition(e){for(const t of registeredModules.values())if(isModuleType("chart",t.def)&&t.def.detect(e))return t.def;throw new Error("AG Charts - Unknown chart type; Check options are correctly structured and series types are specified")}function getAxisModule(e){const t=registeredModules.get(e);if(isModuleType("axis",t?.def))return t?.def}function getPresetModule(e){const t=registeredModules.get(e);if(isModuleType("preset",t?.def))return t?.def}function getSeriesModule(e){const t=registeredModules.get(e);if(isModuleType("series",t?.def))return t?.def}function isModuleType(e,t){return t?.type===e}var EventEmitter=class{constructor(){this.events=new Map}on(e,t){return this.events.has(e)||this.events.set(e,new Set),this.events.get(e)?.add(t),()=>this.off(e,t)}off(e,t){const n=this.events.get(e);n&&(n.delete(t),n.size===0&&this.events.delete(e))}emit(e,t){this.events.get(e)?.forEach(n=>n(t))}clear(e){e?this.events.delete(e):this.events.clear()}},verifiedGlobals={};typeof window<"u"?verifiedGlobals.window=window:typeof global<"u"&&(verifiedGlobals.window=global.window),typeof document<"u"?verifiedGlobals.document=document:typeof global<"u"&&(verifiedGlobals.document=global.document);function getDocument(e){return e?verifiedGlobals.document?.[e]:verifiedGlobals.document}function getWindow(e){return e?verifiedGlobals.window?.[e]:verifiedGlobals.window}function setDocument(e){verifiedGlobals.document=e}function setWindow(e){verifiedGlobals.window=e}function createElement(e,t,n){const r=getDocument().createElement(e);if(typeof t=="object"&&(n=t,t=void 0),t)for(const i of t.split(" "))r.classList.add(i);return n&&Object.assign(r.style,n),r}function createSvgElement(e){return getDocument().createElementNS("http://www.w3.org/2000/svg",e)}function downloadUrl(e,t){const n=getDocument("body"),r=createElement("a",{display:"none"});r.href=e,r.download=t,n.appendChild(r),r.click(),setTimeout(()=>n.removeChild(r))}function attachListener(e,t,n,r){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var style;function parseColor(e){if(style==null){const t=getWindow("Option");style=new t().style}return style.color=e,style.color||null}function isDefined(e){return e!=null}function isArray(e){return Array.isArray(e)}function isBoolean(e){return typeof e=="boolean"}function isDate(e){return e instanceof Date}function isValidDate(e){return isDate(e)&&!isNaN(Number(e))}function isRegExp(e){return e instanceof RegExp}function isFunction(e){return typeof e=="function"}function isObject(e){return typeof e=="object"&&e!==null&&!isArray(e)}function isObjectLike(e){return isArray(e)||isPlainObject(e)}function isPlainObject(e){return typeof e=="object"&&e!==null&&e.constructor?.name==="Object"}function isEmptyObject(e){if(typeof e!="object"||e===null)return!1;for(const t in e)return!1;return!0}function isString(e){return typeof e=="string"}function isNumber(e){return typeof e=="number"}function isFiniteNumber(e){return Number.isFinite(e)}function isHtmlElement(e){return typeof window<"u"&&e instanceof HTMLElement}function isEnumKey(e,t){return isString(t)&&Object.keys(e).includes(t)}function isEnumValue(e,t){return Object.values(e).includes(t)}function isSymbol(e){return typeof e=="symbol"}function isColor(e){return isString(e)&&(e==="none"||parseColor(e)!=null)}function isKeyOf(e,t){return e in t}function debounce(e,t=0,n){const{leading:r=!1,trailing:i=!0,maxWait:o=1/0}=n??{};let a,s;if(o<t)throw new Error("Value of maxWait cannot be lower than waitMs.");function c(...l){if(r&&!s){s=Date.now(),a=setTimeout(()=>s=null,t),e(...l);return}let u=t;if(o!==1/0&&s){const f=Date.now()-s;t>o-f&&(u=o-f)}clearTimeout(a),s??(s=Date.now()),a=setTimeout(()=>{s=null,i&&e(...l)},u)}return Object.assign(c,{cancel(){clearTimeout(a),s=null}})}function throttle(e,t,n){const{leading:r=!0,trailing:i=!0}=n??{};let o,a,s=!1;function c(){i&&a?(o=setTimeout(c,t),e(...a)):s=!1,a=null}function l(...u){s?a=u:(s=!0,o=setTimeout(c,t),r?e(...u):a=u)}return Object.assign(l,{cancel(){clearTimeout(o),s=!1,a=null}})}function safeCall(e,t,n=""){try{return e(...t)}catch(r){const i=n?` \`${n}\``:"";warnOnce(`Uncaught exception in user callback${i}`,r)}}function joinFormatted(e,t="and",n=String,r=1/0){if(e.length===0)return"";if(e.length===1)return n(e[0]);e=e.map(n);const i=e.pop();if(e.length>=r){const o=e.length-(r-1);return`${e.slice(0,r-1).join(", ")}, and ${o} more ${t} ${i}`}return`${e.join(", ")} ${t} ${i}`}function stringifyValue(e,t=1/0){if(typeof e=="number"){if(isNaN(e))return"NaN";if(e===1/0)return"Infinity";if(e===-1/0)return"-Infinity"}const n=JSON.stringify(e)??typeof e;return n.length>t?`${n.slice(0,t)}... (+${n.length-t} characters)`:n}function countLines(e){let t=1;for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t++;return t}function levenshteinDistance(e,t){if(e===t)return 0;const[n,r]=e.length<t.length?[e,t]:[t,e],i=n.length,o=r.length;let a=new Array(i+1).fill(0).map((c,l)=>l),s=new Array(i+1);for(let c=1;c<=o;c++){s[0]=c;for(let l=1;l<=i;l++){const u=r[c-1]===n[l-1]?0:1;s[l]=Math.min(a[l]+1,s[l-1]+1,a[l-1]+u)}[a,s]=[s,a]}return a[i]}function kebabCase(e){return e.replace(KEBAB_CASE_REGEX,(t,n)=>(n>0?"-":"")+t.toLowerCase())}var KEBAB_CASE_REGEX=/[A-Z]+(?![a-z])|[A-Z]/g;function toPlainText(e){return isArray(e)?e.map(t=>t.text).join(""):e??""}var descriptionSymbol=Symbol("description"),requiredSymbol=Symbol("required"),markedSymbol=Symbol("marked"),undocumentedSymbol=Symbol("undocumented"),unionSymbol=Symbol("union"),similarOptionsMap=[["placement","position"],["padding","spacing","gap"],["color","fill","stroke"],["whisker","wick"],["nodeClick","seriesNodeClick"],["nodeDoubleClick","seriesNodeDoubleClick"],["src","url"]].reduce((e,t)=>{for(const n of t)e.set(n.toLowerCase(),new Set(t.filter(r=>r!==n)));return e},new Map),ErrorType=(e=>(e.Invalid="invalid",e.Required="required",e.Unknown="unknown",e))(ErrorType||{});function extendPath(e,t){return isFiniteNumber(t)?`${e}[${t}]`:e?`${e}.${t}`:t}var ValidationError=class{constructor(e,t,n,r,i){this.type=e,this.description=t,this.value=n,this.path=r,this.key=i}setUnionType(e,t){if(this.path.startsWith(t)){const n=this.path.slice(t.length);this.altPath=`${t}[type=${e}]${n}`}}getPrefix(){const{altPath:e=this.path,key:t}=this;return!e&&!t?"Value":`Option \`${t?extendPath(e,t):e}\``}toString(){const{description:e="unknown",type:t,value:n}=this;return t==="required"&&n==null?`${this.getPrefix()} is required and has not been provided; expecting ${e}, ignoring.`:`${this.getPrefix()} cannot be set to \`${stringifyValue(n,50)}\`; expecting ${e}, ignoring.`}},UnknownError=class extends ValidationError{constructor(e,t,n,r){super("unknown",void 0,t,n,r),this.suggestions=e,this.key=r}getPrefix(){return`Unknown option \`${extendPath(this.altPath??this.path,this.key)}\``}getPostfix(){const e=joinFormatted(findSuggestions(this.key,this.suggestions),"or",t=>`\`${t}\``);return e?`; Did you mean ${e}? Ignoring.`:", ignoring."}toString(){return`${this.getPrefix()}${this.getPostfix()}`}};function validate(e,t,n=""){if(!isObject(e))return{cleared:null,invalid:[new ValidationError("required","an object",e,n)]};const r={},i=[],o=new Set(Object.keys(e)),a=[];if(unionSymbol in t){const s=Object.keys(t),c=t[unionSymbol];if(e.type!=null&&s.includes(e.type)||e.type==null&&c!=null){const{type:l=c,...u}=e,f=validate(u,t[l],n);Object.assign(r,{type:l},f.cleared);for(const h of f.invalid)h.setUnionType(l,n);i.push(...f.invalid)}else{const l=joinFormatted(s,"or",u=>`'${u}'`);i.push(new ValidationError("required",`a keyword such as ${l}`,e.type,n,"type"))}return{cleared:r,invalid:i}}for(const s of Object.keys(t)){const c=t[s],l=c[requiredSymbol],u=e[s];if(o.delete(s),typeof u>"u"&&(c[undocumentedSymbol]||a.push(s),!l))continue;const f=extendPath(n,s);if(isFunction(c)){const g=c(u,{options:e,path:f});if(typeof g=="object"){if(i.push(...g.invalid),g.valid){r[s]=g.cleared;continue}else if(hasRequiredInPath(g.invalid,f))continue}else if(g){r[s]=u;continue}i.push(new ValidationError(l?"required":"invalid",c[descriptionSymbol],u,n,s))}else{const h=validate(u,c,f);h.cleared!=null&&(r[s]=h.cleared),i.push(...h.invalid)}}for(const s of o){const c=e[s];typeof c>"u"||i.push(new UnknownError(a,c,n,s))}return{cleared:r,invalid:i}}function findSuggestions(e,t,n=2){const r=[],i=e.toLowerCase(),o=similarOptionsMap.get(i);for(const a of t){const s=a.toLowerCase();(o?.has(a)||s.includes(i)||levenshteinDistance(i,s)<=n)&&r.push(a)}return r}function attachDescription(e,t){if(isFunction(e)){let r=function(i,o){return e(i,o)};var n=r;return r[descriptionSymbol]=t,r}else return{...e,[descriptionSymbol]:t}}function required(e){return Object.assign(isFunction(e)?(t,n)=>e(t,n):optionsDefs(e),{[requiredSymbol]:!0,[descriptionSymbol]:e[descriptionSymbol]})}function undocumented(e){return Object.assign(isFunction(e)?(t,n)=>e(t,n):optionsDefs(e),{[undocumentedSymbol]:!0,[descriptionSymbol]:e[descriptionSymbol]})}var optionsDefs=(e,t="an object")=>attachDescription((n,r)=>{const i=validate(n,e,r.path);return{valid:!hasRequiredInPath(i.invalid,r.path),cleared:i.cleared,invalid:i.invalid}},t),typeUnion=(e,t,n)=>({...e,[descriptionSymbol]:t,[unionSymbol]:n}),and=(...e)=>attachDescription((t,n)=>{const r=[];for(const i of e){const o=i(t,n);if(typeof o=="object"){if(r.push(...o.invalid),!o.valid)return{valid:!1,cleared:t,invalid:r};t=o.cleared}else if(!o)return!1}return{valid:!0,cleared:t,invalid:r}},e.map(t=>t[descriptionSymbol]).filter(Boolean).join(" and ")),or=(...e)=>attachDescription((t,n)=>{for(const r of e){const i=r(t,n);if(typeof i=="object"?i.valid:i)return i}return!1},e.map(t=>t[descriptionSymbol]).filter(Boolean).join(" or ")),isComparable=e=>isFiniteNumber(e)||isValidDate(e),isValidDateValue=e=>isDate(e)||(isFiniteNumber(e)||isString(e))&&isValidDate(new Date(e)),array=attachDescription(isArray,"an array"),boolean=attachDescription(isBoolean,"a boolean"),callback=attachDescription(isFunction,"a function"),color=attachDescription(isColor,"a color string"),date=attachDescription(isValidDateValue,"a date"),defined=attachDescription(isDefined,"a defined value"),number=attachDescription(isFiniteNumber,"a number"),object=attachDescription(isObject,"an object"),string=attachDescription(isString,"a string"),htmlElement=attachDescription(e=>typeof HTMLElement>"u"||e instanceof HTMLElement,"an html element"),arrayLength=(e,t=1/0)=>{let n;return t===1/0?n=`an array of at least ${e} items`:e===t?n=`an array of exactly ${e} items`:e===0?n=`an array of no more than ${t} items`:n=`an array of at least ${e} and no more than ${t} items`,attachDescription(r=>isArray(r)&&r.length>=e&&r.length<=t,n)},stringLength=(e,t=1/0)=>{let n;return t===1/0?n=`a string of at least ${e} characters`:e===t?n=`an string of exactly ${e} characters`:e===0?n=`an string of no more than ${t} characters`:n=`an string of at least ${e} and no more than ${t} characters`,attachDescription(r=>isString(r)&&r.length>=e&&r.length<=t,n)},numberMin=(e,t=!0)=>attachDescription(n=>isFiniteNumber(n)&&(n>e||t&&n===e),`a number greater than ${t?"or equal to ":""}${e}`),numberRange=(e,t)=>attachDescription(n=>isFiniteNumber(n)&&n>=e&&n<=t,`a number between ${e} and ${t} inclusive`),positiveNumber=numberMin(0),positiveNumberNonZero=numberMin(0,!1),ratio=numberRange(0,1),lessThan=e=>attachDescription((t,{options:n})=>!isComparable(t)||!isComparable(n[e])||t<n[e],`the value to be less than \`${e}\``),greaterThan=e=>attachDescription((t,{options:n})=>!isComparable(t)||!isComparable(n[e])||t>n[e],`the value to be greater than \`${e}\``);function union(...e){isObject(e[0])&&(e=Object.values(e[0]));const t=joinFormatted(e,"or",n=>`'${n}'`);return attachDescription(n=>e.includes(n),`a keyword such as ${t}`)}var constant=e=>attachDescription(t=>e===t,`the value ${JSON.stringify(e)}`),instanceOf=(e,t)=>attachDescription(n=>n instanceof e,t??`an instance of ${e.name}`),arrayOf=(e,t,n=!0)=>attachDescription((r,i)=>{if(!isArray(r))return!1;let o=n;const a=[],s=[],c=l=>o=n?o&&l:o||l;if(r.length===0)return{valid:!0,cleared:a,invalid:s};for(let l=0;l<r.length;l++){const u=r[l],f=e(u,{options:u,path:`${i.path}[${l}]`});typeof f=="object"?(o=c(f.valid),s.push(...f.invalid),f.cleared!=null&&a.push(f.cleared)):(o=c(f),f&&a.push(u))}return{valid:o,cleared:o||!n?a:null,invalid:s}},t??`${e[descriptionSymbol]} array`),arrayOfDefs=(e,t="an object array")=>attachDescription((n,r)=>{if(!isArray(n))return!1;const i=[],o=[];for(let a=0;a<n.length;a++){const s=`${r.path}[${a}]`,c=validate(n[a],e,s);hasRequiredInPath(c.invalid,s)||i.push(c.cleared),o.push(...c.invalid)}return{valid:!0,cleared:i,invalid:o}},t),callbackOf=(e,t)=>attachDescription((n,r)=>isFunction(n)?markedSymbol in n?!0:{valid:!0,cleared:Object.assign((...o)=>{const a=safeCall(n,o);if(a==null)return;const s=e(a,{options:a,path:""});if(typeof s=="object"){if(s.invalid.forEach(callbackWarnInvalid(r,t??e[descriptionSymbol])),s.valid)return s.cleared}else{if(s)return a;warnOnce(`Callback \`${r.path}\` returned an invalid value \`${stringifyValue(a,50)}\`; expecting ${t??e[descriptionSymbol]}, ignoring.`)}},{[markedSymbol]:!0}),invalid:[]}:!1,"a function"),callbackDefs=(e,t="an object")=>attachDescription((n,r)=>isFunction(n)?markedSymbol in n?!0:{valid:!0,cleared:Object.assign((...o)=>{const a=safeCall(n,o,r.path);if(a==null)return;const s=validate(a,e);return s.invalid.forEach(callbackWarnInvalid(r,t)),s.cleared},{[markedSymbol]:!0}),invalid:[]}:!1,"a function");function hasRequiredInPath(e,t){return e.some(n=>n.type==="required"&&n.path===t)}function callbackWarnInvalid(e,t){return n=>{if(n instanceof UnknownError)return warnOnce(`Callback \`${e.path}\` returned an unknown property \`${extendPath(n.path,n.key)}\`${n.getPostfix()}`);const r=stringifyValue(n.value,50);warnOnce(n.key?`Callback \`${e.path}\` returned an invalid property \`${extendPath(n.path,n.key)}\`: \`${r}\`; expecting ${n.description}, ignoring.`:`Callback \`${e.path}\` returned an invalid value \`${r}\`; expecting ${t??n.description}, ignoring.`)}}var themeOperator=e=>{if(!isObject(e))return!1;const t=Object.keys(e);return t.length===1&&t[0].startsWith("$")},colorStop=optionsDefs({color,stop:ratio},""),colorStopsOrderValidator=attachDescription(e=>{let t=-1/0;for(const n of e)if(n?.stop!=null){if(n.stop<t)return!1;t=n.stop}return!0},"color stops to be defined in ascending order"),gradientColorStops=and(arrayLength(2),arrayOf(colorStop),colorStopsOrderValidator),gradientBounds=union("axis","item","series"),gradientStrict=optionsDefs({type:required(constant("gradient")),colorStops:required(gradientColorStops),rotation:number,gradient:undocumented(union("linear","radial","conic")),bounds:undocumented(gradientBounds),reverse:undocumented(boolean)},"a gradient object with color stops"),strokeOptionsDef={stroke:color,strokeWidth:positiveNumber,strokeOpacity:ratio},fillGradientDefaults=optionsDefs({type:required(constant("gradient")),gradient:required(union("linear","radial","conic")),bounds:required(gradientBounds),colorStops:required(or(gradientColorStops,and(arrayLength(2),arrayOf(color)))),rotation:required(number),reverse:required(boolean)}),fillPatternDefaults=optionsDefs({type:required(constant("pattern")),pattern:required(union("vertical-lines","horizontal-lines","forward-slanted-lines","backward-slanted-lines","circles","squares","triangles","diamonds","stars","hearts","crosses")),path:stringLength(2),width:required(positiveNumber),height:required(positiveNumber),fill:required(color),fillOpacity:required(ratio),backgroundFill:required(color),backgroundFillOpacity:required(ratio),padding:required(positiveNumber),rotation:required(number),scale:required(positiveNumber),stroke:required(color),strokeWidth:required(positiveNumber),strokeOpacity:required(ratio)}),fillImageDefaults=optionsDefs({type:required(constant("image")),url:string,width:positiveNumber,height:positiveNumber,rotation:required(number),backgroundFill:required(color),backgroundFillOpacity:ratio,fit:required(union("stretch","contain","cover")),repeat:required(union("repeat","repeat-x","repeat-y","no-repeat"))}),colorObject=typeUnion({gradient:{colorStops:gradientColorStops,rotation:number,gradient:undocumented(union("linear","radial","conic")),bounds:undocumented(gradientBounds),reverse:undocumented(boolean)},pattern:{pattern:union("vertical-lines","horizontal-lines","forward-slanted-lines","backward-slanted-lines","circles","squares","triangles","diamonds","stars","hearts","crosses"),path:stringLength(2),width:positiveNumber,height:positiveNumber,rotation:number,scale:positiveNumber,fill:color,fillOpacity:ratio,backgroundFill:color,backgroundFillOpacity:ratio,...strokeOptionsDef,padding:undocumented(positiveNumber)},image:{url:required(string),backgroundFill:color,backgroundFillOpacity:ratio,width:positiveNumber,height:positiveNumber,fit:union("stretch","contain","cover","none"),repeat:union("repeat","repeat-x","repeat-y","no-repeat"),rotation:number}},"a color object"),colorUnion=or(color,optionsDefs(colorObject,"a color object")),fillOptionsDef={fill:colorUnion,fillOpacity:ratio};fillOptionsDef.fillGradientDefaults=undocumented(fillGradientDefaults),fillOptionsDef.fillPatternDefaults=undocumented(fillPatternDefaults),fillOptionsDef.fillImageDefaults=undocumented(fillImageDefaults);var lineDashOptionsDef={lineDash:arrayOf(positiveNumber),lineDashOffset:number},barHighlightOptionsDef={...fillOptionsDef,...strokeOptionsDef,...lineDashOptionsDef,opacity:ratio,cornerRadius:positiveNumber},lineHighlightOptionsDef={...strokeOptionsDef,...lineDashOptionsDef,opacity:ratio},shapeHighlightOptionsDef={...fillOptionsDef,...strokeOptionsDef,...lineDashOptionsDef,opacity:ratio};function highlightOptionsDef(e){return{enabled:boolean,range:union("tooltip","node"),highlightedItem:e,unhighlightedItem:e}}function multiSeriesHighlightOptionsDef(e,t){return{enabled:boolean,range:union("tooltip","node"),highlightedItem:e,unhighlightedItem:e,highlightedSeries:t,unhighlightedSeries:t,bringToFront:boolean}}var googleFont=optionsDefs({googleFont:string},"google font"),fontFamilyFull=or(string,themeOperator,googleFont,arrayOf(or(string,googleFont))),fontOptionsDef={color,fontFamily:fontFamilyFull,fontSize:positiveNumber,fontStyle:union("normal","italic","oblique"),fontWeight:or(positiveNumber,union("normal","bold","bolder","lighter"))},paddingOptions=optionsDefs({top:number,right:number,bottom:number,left:number},"padding object"),padding=or(number,paddingOptions),borderOptionsDef={enabled:boolean,stroke:color,strokeWidth:positiveNumber,strokeOpacity:ratio},labelBoxOptionsDef={border:{...borderOptionsDef},cornerRadius:number,padding,...fillOptionsDef};function getMaxInnerRectSize(e,t,n=1/0){const r=t,i=n,o=e%180*(Math.PI/180),a=Math.abs(Math.sin(o)),s=Math.abs(Math.cos(o));if(a===0)return{width:r,height:i};if(s===0)return{width:i,height:r};if(!isFinite(i)){const l=s/a,u=r/(s+l*a);return{width:u,height:l*u}}const c=s*s-a*a;if(c===0){const l=Math.min(r,i)/Math.SQRT2;return{width:l,height:l}}return{width:Math.abs((r*s-i*a)/c),height:Math.abs((i*s-r*a)/c)}}function toArray(e){return typeof e>"u"?[]:Array.isArray(e)?e:[e]}function unique(e){return Array.from(new Set(e))}function groupBy(e,t){return e.reduce((n,r)=>{const i=t(r);return n[i]??(n[i]=[]),n[i].push(r),n},{})}function arraysEqual(e,t){if(e==null||t==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(Array.isArray(e[n])&&Array.isArray(t[n])){if(!arraysEqual(e[n],t[n]))return!1}else if(e[n]!==t[n])return!1;return!0}function circularSliceArray(e,t,n=0){if(e.length===0)return[];const r=[];for(let i=0;i<t;i++)r.push(e.at((i+n)%e.length));return r}function sortBasedOnArray(e,t){const n=new Map;return t.forEach((r,i)=>{n.set(r,i)}),e.sort((r,i)=>{const o=n.get(r)??1/0,a=n.get(i)??1/0;return o-a})}function dropFirstWhile(e,t){let n=0;for(;n<e.length&&t(e[n]);)n+=1;const r=n;r!==0&&e.splice(0,r)}function dropLastWhile(e,t){let n=e.length-1;for(;n>=0&&t(e[n]);)n-=1;const r=e.length-1-n;r!==0&&e.splice(e.length-r,r)}var AsyncAwaitQueue=class{constructor(){this.queue=[]}await(e=50){return new Promise(t=>{const n=()=>{clearTimeout(i),t(!0)},i=setTimeout(()=>{const o=this.queue.indexOf(n);o<0||(this.queue.splice(o,1),t(!1))},e);this.queue.push(n)})}notify(){this.queue.splice(0).forEach(e=>e())}};function pause(e=0){return new Promise(t=>{setTimeout(t,e)})}function*iterate(...e){for(const t of e)yield*t}function toIterable(e){return e!=null&&typeof e=="object"&&Symbol.iterator in e?e:[e]}function first(e){for(const t of e)return t;throw new Error("AG Charts - no first() value found")}function*entries(e){const t=[void 0,void 0];for(const n of Object.keys(e))t[0]=n,t[1]=e[n],yield t}function booleanParser(e){return e==="true"}function numberParser(e){return Number(e)}function stringParser(e){return e}var AttributeTypeParsers={role:stringParser,"aria-checked":booleanParser,"aria-controls":stringParser,"aria-describedby":stringParser,"aria-disabled":booleanParser,"aria-expanded":booleanParser,"aria-haspopup":stringParser,"aria-hidden":booleanParser,"aria-label":stringParser,"aria-labelledby":stringParser,"aria-live":stringParser,"aria-orientation":stringParser,"aria-selected":booleanParser,"data-focus-override":booleanParser,"data-focus-visible-override":booleanParser,"data-preventdefault":booleanParser,class:stringParser,for:stringParser,id:stringParser,tabindex:numberParser,title:stringParser,placeholder:stringParser};function setAttribute(e,t,n){n==null||n===""||n===""?e?.removeAttribute(t):e?.setAttribute(t,n.toString())}function setAttributes(e,t){if(t!=null)for(const[n,r]of entries(t))n!=="class"&&setAttribute(e,n,r)}function getAttribute(e,t,n){if(!(e instanceof HTMLElement))return;const r=e.getAttribute(t);return r===null?n:AttributeTypeParsers[t]?.(r)??void 0}function setElementStyle(e,t,n){e!=null&&(n==null?e.style.removeProperty(t):e.style.setProperty(t,n.toString()))}function setElementStyles(e,t){for(const[n,r]of entries(t))setElementStyle(e,n,r)}function boxCollides(e,t,n,r,i){return t<e.x+e.width&&t+r>e.x&&n<e.y+e.height&&n+i>e.y}function boxContains(e,t,n,r=0,i=0){return t>=e.x&&t+r<=e.x+e.width&&n>=e.y&&n+i<=e.y+e.height}function boxEmpty(e){return e==null||e.height===0||e.width===0||isNaN(e.height)||isNaN(e.width)}function boxesEqual(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function findMaxIndex(e,t,n){if(e>t)return;let r;for(;t>=e;){const i=Math.floor((t+e)/2);n(i)?(r=i,e=i+1):t=i-1}return r}function findMinIndex(e,t,n){if(e>t)return;let r;for(;t>=e;){const i=Math.floor((t+e)/2);n(i)?(r=i,t=i-1):e=i+1}return r}function findMaxValue(e,t,n){if(e>t)return;let r;for(;t>=e;){const i=Math.floor((t+e)/2),o=n(i);o==null?t=i-1:(r=o,e=i+1)}return r}function findMinValue(e,t,n){if(e>t)return;let r;for(;t>=e;){const i=Math.floor((t+e)/2),o=n(i);o==null?e=i+1:(r=o,t=i-1)}return r}var SimpleCache=class{constructor(e){this.getter=e}get(){return this.result??(this.result=this.getter()),this.result}clear(){this.result=void 0}},WeakCache=class{constructor(e){this.getter=e}get(){let e=this.result?.deref();return e||(e=this.getter(),this.result=new WeakRef(e),e)}clear(){this.result=void 0}},CleanupRegistry=class{constructor(){this.callbacks=new Set}flush(){for(const e of this.callbacks)e();this.callbacks.clear()}merge(e){for(const t of e.callbacks)this.callbacks.add(t)}register(...e){for(const t of e)t&&this.callbacks.add(t)}};function diffArrays(e,t){const n=Math.max(e.length,t.length),r=new Set,i=new Set;for(let o=0;o<n;o++){const a=e[o],s=t[o];a!==s&&(i.has(s)?i.delete(s):s&&r.add(s),r.has(a)?r.delete(a):a&&i.add(a))}return{changed:r.size>0||i.size>0,added:r,removed:i}}function clamp(e,t,n){return Math.min(n,Math.max(e,t))}function inRange(e,t,n=1e-10){return e>=t[0]-n&&e<=t[1]+n}function isNumberEqual(e,t,n=1e-10){return e===t||Math.abs(e-t)<n}function isNegative(e){return Math.sign(e)===-1||Object.is(e,-0)}function isInteger(e){return e%1===0}function roundTo(e,t=2){const n=10**t;return Math.round(e*n)/n}function modulus(e,t){return Math.floor(e%t+(e<0?Math.abs(t):0))}function countFractionDigits(e){if(Math.floor(e)===e)return 0;let t=String(e),n=0;if(e<1e-6||e>=1e21){let i;[t,i]=t.split("e"),i!=null&&(n=Number(i))}const r=t.split(".")[1]?.length??0;return Math.max(r-n,0)}function isValidCoordinate(e){return Array.isArray(e)&&e.length>=2&&e.every(isFiniteNumber)}function isValidCoordinates(e){return Array.isArray(e)&&e.length>=2&&e.every(isValidCoordinate)}function hasSameStartEndPoint(e){const t=e[0],n=e[e.length-1];return isNumberEqual(t[0],n[0],.001)&&isNumberEqual(t[1],n[1],.001)}function isValidPolygon(e){return Array.isArray(e)&&e.every(isValidCoordinates)&&e.every(hasSameStartEndPoint)}function isValidGeometry(e){if(e===null)return!0;if(!isObject(e)||e.type==null)return!1;const{type:t,coordinates:n}=e;switch(t){case"GeometryCollection":return Array.isArray(e.geometries)&&e.geometries.every(isValidGeometry);case"MultiPolygon":return Array.isArray(n)&&n.every(isValidPolygon);case"Polygon":return isValidPolygon(n);case"MultiLineString":return Array.isArray(n)&&n.every(isValidCoordinates);case"LineString":return isValidCoordinates(n);case"MultiPoint":return isValidCoordinates(n);case"Point":return isValidCoordinate(n);default:return!1}}function isValidFeature(e){return isObject(e)&&e.type==="Feature"&&isValidGeometry(e.geometry)}function isValidFeatureCollection(e){return isObject(e)&&e.type==="FeatureCollection"&&Array.isArray(e.features)&&e.features.every(isValidFeature)}var geoJson=attachDescription(isValidFeatureCollection,"a GeoJSON object"),AdjacencyListGraph=class{constructor(e,t){this._vertexCount=0,this.pendingProcessingEdgesFrom=[],this.pendingProcessingEdgesTo=[],this.cachedNeighboursEdge=e,this.processedEdge=t}clear(){this._vertexCount=0,this.pendingProcessingEdgesFrom=[],this.pendingProcessingEdgesTo=[]}addVertex(e){const t=new Vertex(e);return this._vertexCount++,t}addEdge(e,t,n){n===this.cachedNeighboursEdge?e.updateCachedNeighbours().set(t.value,t):n===this.processedEdge&&(this.pendingProcessingEdgesFrom.push(e),this.pendingProcessingEdgesTo.push(t));const{edges:r}=e,i=r.get(n);i?i.indexOf(t)===-1&&i.push(t):r.set(n,[t])}removeVertex(e){this._vertexCount--;const t=e.edges;if(t){for(const[n,r]of t)this._vertexCount-=r.length;e.clear()}}removeEdge(e,t){for(const[n,r]of e.edges){const i=r.indexOf(t);r.splice(i,1),r.length===0&&e.edges.delete(n)}}removeEdges(e,t){e.edges.delete(t)}getVertexValue(e){return e.value}*neighbours(e){for(const[t,n]of e.edges)for(const r of n)yield r}*neighboursAndEdges(e){for(const[t,n]of e.edges)for(const r of n)yield[r,t]}neighboursWithEdgeValue(e,t){return e.edges.get(t)}findNeighbour(e,t){return e.edges.get(t)?.[0]}findNeighbourValue(e,t){const n=this.findNeighbour(e,t);if(n)return this.getVertexValue(n)}findNeighbourWithValue(e,t,n){const r=n==null?this.neighbours(e):this.neighboursWithEdgeValue(e,n);if(r){for(const i of r)if(this.getVertexValue(i)===t)return i}}findVertexAlongEdge(e,t,n){if(n===this.cachedNeighboursEdge){let i;for(const o of t)if(i=(i??e).readCachedNeighbours()?.get(o),!i)return;return i}if(t.length===0)return;let r=e;for(const i of t){const o=r?this.neighboursWithEdgeValue(r,n):void 0;if(!o)return;r=o.find(a=>a.value===i)}return r}adjacent(e,t){for(const[n,r]of e.edges)if(r.includes(t))return!0;return!1}},Vertex=class{constructor(e){this.value=e,this.edges=new Map}readCachedNeighbours(){return this._cachedNeighbours}updateCachedNeighbours(){return this._cachedNeighbours??(this._cachedNeighbours=new Map),this._cachedNeighbours}clear(){this.edges.clear(),this._cachedNeighbours?.clear()}},ID_MAP=new Map,elementIDBrand=Symbol("ElementID"),nextElementID=1;function resetIds(){ID_MAP.clear(),nextElementID=1}function createId(e){const t=e.constructor,n=Object.hasOwn(t,"className")?t.className:t.name;if(!n)throw new Error(`The ${t} is missing the 'className' property.`);const r=(ID_MAP.get(n)??0)+1;return ID_MAP.set(n,r),`${n}-${r}`}function createElementId(){return`ag-charts-${nextElementID++}`}function generateUUID(){return crypto.randomUUID?.()??generateUUIDv4()}function generateUUIDv4(){const e=new Uint8Array(16);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t="";for(let n=0;n<e.length;n++)(n===4||n===6||n===8||n===10)&&(t+="-"),t+=e[n].toString(16).padStart(2,"0");return t}var insertListItemsSorted=(e,t,n)=>{let r=e,i=r;for(const o of t)if(r==null||n(r.value,o)>0)r={value:o,next:r},i=r;else{for(i=i;i.next!=null&&n(i.next.value,o)<=0;)i=i.next;i.next={value:o,next:i.next}}return r},formatRegEx=/^(?:(.)?([<>=^]))?([+\-( ])?([$€£¥₣₹#])?(0)?(\d+)?(,)?(?:\.(\d+))?(~)?([%a-z])?$/i,surroundedRegEx=/^((?:[^#]|#[^{])*)#{([^}]+)}(.*)$/;function isValidNumberFormat(e){if(!isString(e))return!1;const t=surroundedRegEx.exec(e);return formatRegEx.test(t?t[2]:e)}function parseNumberFormat(e){let t,n;const r=surroundedRegEx.exec(e);r&&([,t,e,n]=r);const i=formatRegEx.exec(e);if(!i){logger_exports.warnOnce(`The number formatter is invalid: ${e}`);return}const[,o,a,s,c,l,u,f,h,g,p]=i;return{fill:o,align:a,sign:s,symbol:c,zero:l,width:parseInt(u),comma:f,precision:parseInt(h),trim:!!g,type:p,prefix:t,suffix:n}}function createNumberFormatter(e){const t=typeof e=="string"?parseNumberFormat(e):e;if(t==null)return;const{fill:n,align:r,sign:i="-",symbol:o,zero:a,width:s,comma:c,type:l,prefix:u="",suffix:f="",precision:h}=t;let{trim:g}=t;const p=h==null||isNaN(h);let y;if(!l)y=decimalTypes.g,g=!0;else if(l in decimalTypes&&l in integerTypes)y=p?integerTypes[l]:decimalTypes[l];else if(l in decimalTypes)y=decimalTypes[l];else if(l in integerTypes)y=integerTypes[l];else throw new Error(`The number formatter type is invalid: ${l}`);const v=l?6:12;let m;return p||(m=h),(b,w)=>{let d=y(b,m??w??v);return g&&(d=removeTrailingZeros(d)),c&&(d=insertSeparator(d,c)),d=addSign(b,d,i),o&&o!=="#"&&(d=`${o}${d}`),o==="#"&&l==="x"&&(d=`0x${d}`),l==="s"&&(d=`${d}${getSIPrefix(b)}`),(l==="%"||l==="p")&&(d=`${d}%`),s!=null&&!isNaN(s)&&(d=addPadding(d,s,n??a,r)),d=`${u}${d}${f}`,d}}var integerTypes={b:e=>absFloor(e).toString(2),c:e=>String.fromCharCode(e),d:e=>Math.round(Math.abs(e)).toFixed(0),o:e=>absFloor(e).toString(8),x:e=>absFloor(e).toString(16),X:e=>integerTypes.x(e).toUpperCase(),n:e=>integerTypes.d(e),"%":e=>`${absFloor(e*100).toFixed(0)}`},decimalTypes={e:(e,t)=>Math.abs(e).toExponential(t),E:(e,t)=>decimalTypes.e(e,t).toUpperCase(),f:(e,t)=>Math.abs(e).toFixed(t),F:(e,t)=>decimalTypes.f(e,t).toUpperCase(),g:(e,t)=>{if(e===0)return"0";const n=Math.abs(e),r=Math.floor(Math.log10(n));return r>=-4&&r<t?n.toFixed(t-1-r):n.toExponential(t-1)},G:(e,t)=>decimalTypes.g(e,t).toUpperCase(),n:(e,t)=>decimalTypes.g(e,t),p:(e,t)=>decimalTypes.r(e*100,t),r:(e,t)=>{if(e===0)return"0";const n=Math.abs(e),i=Math.floor(Math.log10(n))-(t-1);if(i<=0)return n.toFixed(-i);const o=10**i;return(Math.round(n/o)*o).toFixed()},s:(e,t)=>{const n=getSIPrefixPower(e);return decimalTypes.r(e/10**n,t)},"%":(e,t)=>decimalTypes.f(e*100,t)},minSIPrefix=-24,maxSIPrefix=24,siPrefixes={[minSIPrefix]:"y",[-21]:"z",[-18]:"a",[-15]:"f",[-12]:"p",[-9]:"n",[-6]:"\xB5",[-3]:"m",0:"",3:"k",6:"M",9:"G",12:"T",15:"P",18:"E",21:"Z",[maxSIPrefix]:"Y"},minusSign="\u2212";function absFloor(e){return Math.floor(Math.abs(e))}function removeTrailingZeros(e){if(!e.endsWith("0")||e.indexOf(".")===-1)return e;let t=e.length-1;for(;t>0;)if(e[t]=="0")t-=1;else if(e[t]=="."){t-=1;break}else break;return e.substring(0,t+1)}function insertSeparator(e,t){let n=e.indexOf(".");n<0&&(n=e.length);const r=e.substring(0,n).split(""),i=e.substring(n);for(let o=r.length-3;o>0;o-=3)r.splice(o,0,t);return`${r.join("")}${i}`}function getSIPrefix(e){return siPrefixes[getSIPrefixPower(e)]}function getSIPrefixPower(e){return clamp(minSIPrefix,e?Math.floor(Math.log10(Math.abs(e))/3)*3:0,maxSIPrefix)}function addSign(e,t,n=""){if(n==="(")return e>=0?t:`(${t})`;const r=n==="+"?"+":"";return`${e>=0?r:minusSign}${t}`}function addPadding(e,t,n=" ",r=">"){let i=e;if(r===">"||!r)i=i.padStart(t,n);else if(r==="<")i=i.padEnd(t,n);else if(r==="^"){const o=Math.max(0,t-i.length),a=Math.ceil(o/2),s=Math.floor(o/2);i=i.padStart(a+i.length,n),i=i.padEnd(s+i.length,n)}return i}