web_plsql 0.18.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +29 -9
  2. package/package.json +17 -7
  3. package/src/admin/client/charts.ts +598 -0
  4. package/src/admin/client/main.js +3 -0
  5. package/src/admin/client/tailwind.css +41 -0
  6. package/src/admin/favicon.svg +3 -0
  7. package/src/admin/index.html +529 -0
  8. package/src/admin/js/api.ts +170 -0
  9. package/src/admin/js/app.ts +614 -0
  10. package/src/admin/js/eslint.config.js +74 -0
  11. package/src/admin/js/schemas.ts +215 -0
  12. package/src/admin/js/templates/config.ts +147 -0
  13. package/src/admin/js/templates/errorRow.ts +21 -0
  14. package/src/admin/js/templates/index.ts +4 -0
  15. package/src/admin/js/templates/poolCard.ts +61 -0
  16. package/src/admin/js/templates/traceRow.ts +24 -0
  17. package/src/admin/js/tsconfig.json +24 -0
  18. package/src/admin/js/types.ts +336 -0
  19. package/src/admin/js/ui/components.ts +44 -0
  20. package/src/admin/js/ui/table.ts +173 -0
  21. package/src/admin/js/ui/theme.ts +93 -0
  22. package/src/admin/js/ui/views.ts +427 -0
  23. package/src/admin/js/util/format.ts +46 -0
  24. package/src/admin/js/util/metrics.ts +24 -0
  25. package/src/admin/lib/chart.bundle.css +1 -0
  26. package/src/admin/lib/chart.bundle.js +146 -0
  27. package/src/admin/style.css +1437 -0
  28. package/src/bin/load-test.js +202 -0
  29. package/src/handler/handlerAdmin.js +293 -0
  30. package/src/handler/plsql/cgi.js +1 -1
  31. package/src/handler/plsql/errorPage.js +31 -6
  32. package/src/handler/plsql/handlerPlSql.js +32 -6
  33. package/src/handler/plsql/owaPageStream.js +93 -0
  34. package/src/handler/plsql/parsePage.js +7 -3
  35. package/src/handler/plsql/procedure.js +221 -105
  36. package/src/handler/plsql/procedureNamed.js +34 -49
  37. package/src/handler/plsql/procedureSanitize.js +120 -45
  38. package/src/handler/plsql/procedureVariable.js +4 -2
  39. package/src/handler/plsql/request.js +8 -3
  40. package/src/handler/plsql/sendResponse.js +43 -5
  41. package/src/index.js +0 -1
  42. package/src/server/adminContext.js +23 -0
  43. package/src/server/config.js +1 -0
  44. package/src/server/server.js +130 -9
  45. package/src/types.js +7 -1
  46. package/src/util/cache.js +123 -0
  47. package/src/util/jsonLogger.js +47 -0
  48. package/src/util/shutdown.js +6 -2
  49. package/src/util/statsManager.js +368 -0
  50. package/src/util/trace.js +7 -6
  51. package/src/util/traceManager.js +68 -0
  52. package/src/version.js +1 -1
  53. package/types/admin/js/schemas.d.ts +384 -0
  54. package/types/admin/js/types.d.ts +312 -0
  55. package/types/handler/handlerAdmin.d.ts +79 -0
  56. package/types/handler/plsql/errorPage.d.ts +1 -0
  57. package/types/handler/plsql/handlerPlSql.d.ts +6 -1
  58. package/types/handler/plsql/owaPageStream.d.ts +28 -0
  59. package/types/handler/plsql/procedure.d.ts +4 -1
  60. package/types/handler/plsql/procedureNamed.d.ts +2 -5
  61. package/types/handler/plsql/procedureSanitize.d.ts +2 -5
  62. package/types/handler/plsql/procedureVariable.d.ts +1 -1
  63. package/types/handler/plsql/request.d.ts +3 -1
  64. package/types/handler/plsql/sendResponse.d.ts +1 -1
  65. package/types/index.d.ts +0 -1
  66. package/types/server/adminContext.d.ts +17 -0
  67. package/types/server/server.d.ts +5 -0
  68. package/types/types.d.ts +19 -1
  69. package/types/util/cache.d.ts +69 -0
  70. package/types/util/jsonLogger.d.ts +45 -0
  71. package/types/util/statsManager.d.ts +395 -0
  72. package/types/util/traceManager.d.ts +35 -0
  73. package/src/handler/handlerMetrics.js +0 -68
  74. package/types/handler/handlerMetrics.d.ts +0 -25
@@ -0,0 +1,146 @@
1
+ function v(e,t,n){function i(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:r,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const l=r.prototype,u=Object.keys(l);for(let h=0;h<u.length;h++){const d=u[h];d in a||(a[d]=l[d].bind(a))}}const s=n?.Parent??Object;class o extends s{}Object.defineProperty(o,"name",{value:e});function r(a){var c;const l=n?.Parent?new o:this;i(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const u of l._zod.deferred)u();return l}return Object.defineProperty(r,"init",{value:i}),Object.defineProperty(r,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(r,"name",{value:e}),r}class _e extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ur extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const hr={};function Vt(e){return hr}function dr(e){const t=Object.values(e).filter(i=>typeof i=="number");return Object.entries(e).filter(([i,s])=>t.indexOf(+i)===-1).map(([i,s])=>s)}function mi(e,t){return typeof t=="bigint"?t.toString():t}function zi(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Ii(e){return e==null}function Ai(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Ja(e,t){const n=(e.toString().split(".")[1]||"").length,i=t.toString();let s=(i.split(".")[1]||"").length;if(s===0&&/\d?e-\d?/.test(i)){const c=i.match(/\d?e-(\d?)/);c?.[1]&&(s=Number.parseInt(c[1]))}const o=n>s?n:s,r=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return r%a/10**o}const os=Symbol("evaluating");function j(e,t,n){let i;Object.defineProperty(e,t,{get(){if(i!==os)return i===void 0&&(i=os,i=n()),i},set(s){Object.defineProperty(e,t,{value:s})},configurable:!0})}function le(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ut(...e){const t={};for(const n of e){const i=Object.getOwnPropertyDescriptors(n);Object.assign(t,i)}return Object.defineProperties({},t)}function rs(e){return JSON.stringify(e)}function Ka(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const fr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ga=zi(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ve(e){if(kn(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(kn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function pr(e){return ve(e)?{...e}:Array.isArray(e)?[...e]:e}const Qa=new Set(["string","number","symbol"]);function Ln(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qt(e,t,n){const i=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(i._zod.parent=e),i}function P(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function tc(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const ec={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function nc(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=Ut(e._zod.def,{get shape(){const r={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(r[a]=n.shape[a])}return le(this,"shape",r),r},checks:[]});return qt(e,o)}function ic(e,t){const n=e._zod.def,i=n.checks;if(i&&i.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=Ut(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete r[a]}return le(this,"shape",r),r},checks:[]});return qt(e,o)}function sc(e,t){if(!ve(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=e._zod.def.shape;for(const r in t)if(Object.getOwnPropertyDescriptor(o,r)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const s=Ut(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return le(this,"shape",o),o}});return qt(e,s)}function oc(e,t){if(!ve(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=Ut(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return le(this,"shape",i),i}});return qt(e,n)}function rc(e,t){const n=Ut(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t._zod.def.shape};return le(this,"shape",i),i},get catchall(){return t._zod.def.catchall},checks:[]});return qt(e,n)}function ac(e,t,n){const s=t._zod.def.checks;if(s&&s.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=Ut(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return le(this,"shape",c),c},checks:[]});return qt(t,r)}function cc(e,t,n){const i=Ut(t._zod.def,{get shape(){const s=t._zod.def.shape,o={...s};if(n)for(const r in n){if(!(r in o))throw new Error(`Unrecognized key: "${r}"`);n[r]&&(o[r]=new e({type:"nonoptional",innerType:s[r]}))}else for(const r in s)o[r]=new e({type:"nonoptional",innerType:s[r]});return le(this,"shape",o),o}});return qt(t,i)}function me(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function be(e,t){return t.map(n=>{var i;return(i=n).path??(i.path=[]),n.path.unshift(e),n})}function nn(e){return typeof e=="string"?e:e?.message}function Zt(e,t,n){const i={...e,path:e.path??[]};if(!e.message){const s=nn(e.inst?._zod.def?.error?.(e))??nn(t?.error?.(e))??nn(n.customError?.(e))??nn(n.localeError?.(e))??"Invalid input";i.message=s}return delete i.inst,delete i.continue,t?.reportInput||delete i.input,i}function Di(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function We(...e){const[t,n,i]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:i}:{...t}}const gr=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,mi,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},mr=v("$ZodError",gr),br=v("$ZodError",gr,{Parent:Error});function lc(e,t=n=>n.message){const n={},i=[];for(const s of e.issues)s.path.length>0?(n[s.path[0]]=n[s.path[0]]||[],n[s.path[0]].push(t(s))):i.push(t(s));return{formErrors:i,fieldErrors:n}}function uc(e,t=n=>n.message){const n={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(r=>i({issues:r}));else if(o.code==="invalid_key")i({issues:o.issues});else if(o.code==="invalid_element")i({issues:o.issues});else if(o.path.length===0)n._errors.push(t(o));else{let r=n,a=0;for(;a<o.path.length;){const c=o.path[a];a===o.path.length-1?(r[c]=r[c]||{_errors:[]},r[c]._errors.push(t(o))):r[c]=r[c]||{_errors:[]},r=r[c],a++}}};return i(e),n}const Ri=e=>(t,n,i,s)=>{const o=i?Object.assign(i,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new _e;if(r.issues.length){const a=new(s?.Err??e)(r.issues.map(c=>Zt(c,o,Vt())));throw fr(a,s?.callee),a}return r.value},Li=e=>async(t,n,i,s)=>{const o=i?Object.assign(i,{async:!0}):{async:!0};let r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise&&(r=await r),r.issues.length){const a=new(s?.Err??e)(r.issues.map(c=>Zt(c,o,Vt())));throw fr(a,s?.callee),a}return r.value},$n=e=>(t,n,i)=>{const s=i?{...i,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},s);if(o instanceof Promise)throw new _e;return o.issues.length?{success:!1,error:new(e??mr)(o.issues.map(r=>Zt(r,s,Vt())))}:{success:!0,data:o.value}},hc=$n(br),Fn=e=>async(t,n,i)=>{const s=i?Object.assign(i,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},s);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(r=>Zt(r,s,Vt())))}:{success:!0,data:o.value}},dc=Fn(br),fc=e=>(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Ri(e)(t,n,s)},pc=e=>(t,n,i)=>Ri(e)(t,n,i),gc=e=>async(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Li(e)(t,n,s)},mc=e=>async(t,n,i)=>Li(e)(t,n,i),bc=e=>(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return $n(e)(t,n,s)},yc=e=>(t,n,i)=>$n(e)(t,n,i),_c=e=>async(t,n,i)=>{const s=i?Object.assign(i,{direction:"backward"}):{direction:"backward"};return Fn(e)(t,n,s)},xc=e=>async(t,n,i)=>Fn(e)(t,n,i),vc=/^[cC][^\s-]{8,}$/,wc=/^[0-9a-z]+$/,kc=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sc=/^[0-9a-vA-V]{20}$/,Mc=/^[A-Za-z0-9]{27}$/,Tc=/^[a-zA-Z0-9_-]{21}$/,Cc=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Pc=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,as=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Oc=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ec="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function zc(){return new RegExp(Ec,"u")}const Ic=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ac=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Dc=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Rc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Lc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,yr=/^[A-Za-z0-9_-]*$/,$c=/^\+[1-9]\d{6,14}$/,_r="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Fc=new RegExp(`^${_r}$`);function xr(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Nc(e){return new RegExp(`^${xr(e)}$`)}function Bc(e){const t=xr({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const i=`${t}(?:${n.join("|")})`;return new RegExp(`^${_r}T(?:${i})$`)}const jc=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Vc=/^-?\d+$/,vr=/^-?\d+(?:\.\d+)?$/,Zc=/^[^A-Z]*$/,Wc=/^[^a-z]*$/,pt=v("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),wr={number:"number",bigint:"bigint",object:"date"},kr=v("$ZodCheckLessThan",(e,t)=>{pt.init(e,t);const n=wr[typeof t.value];e._zod.onattach.push(i=>{const s=i._zod.bag,o=(t.inclusive?s.maximum:s.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?s.maximum=t.value:s.exclusiveMaximum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value<=t.value:i.value<t.value)||i.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Sr=v("$ZodCheckGreaterThan",(e,t)=>{pt.init(e,t);const n=wr[typeof t.value];e._zod.onattach.push(i=>{const s=i._zod.bag,o=(t.inclusive?s.minimum:s.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?s.minimum=t.value:s.exclusiveMinimum=t.value)}),e._zod.check=i=>{(t.inclusive?i.value>=t.value:i.value>t.value)||i.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:i.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hc=v("$ZodCheckMultipleOf",(e,t)=>{pt.init(e,t),e._zod.onattach.push(n=>{var i;(i=n._zod.bag).multipleOf??(i.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):Ja(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Uc=v("$ZodCheckNumberFormat",(e,t)=>{pt.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),i=n?"int":"number",[s,o]=ec[t.format];e._zod.onattach.push(r=>{const a=r._zod.bag;a.format=t.format,a.minimum=s,a.maximum=o,n&&(a.pattern=Vc)}),e._zod.check=r=>{const a=r.value;if(n){if(!Number.isInteger(a)){r.issues.push({expected:i,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?r.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort}):r.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:i,inclusive:!0,continue:!t.abort});return}}a<s&&r.issues.push({origin:"number",input:a,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),a>o&&r.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),qc=v("$ZodCheckMaxLength",(e,t)=>{var n;pt.init(e,t),(n=e._zod.def).when??(n.when=i=>{const s=i.value;return!Ii(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<s&&(i._zod.bag.maximum=t.maximum)}),e._zod.check=i=>{const s=i.value;if(s.length<=t.maximum)return;const r=Di(s);i.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Yc=v("$ZodCheckMinLength",(e,t)=>{var n;pt.init(e,t),(n=e._zod.def).when??(n.when=i=>{const s=i.value;return!Ii(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>s&&(i._zod.bag.minimum=t.minimum)}),e._zod.check=i=>{const s=i.value;if(s.length>=t.minimum)return;const r=Di(s);i.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:s,inst:e,continue:!t.abort})}}),Xc=v("$ZodCheckLengthEquals",(e,t)=>{var n;pt.init(e,t),(n=e._zod.def).when??(n.when=i=>{const s=i.value;return!Ii(s)&&s.length!==void 0}),e._zod.onattach.push(i=>{const s=i._zod.bag;s.minimum=t.length,s.maximum=t.length,s.length=t.length}),e._zod.check=i=>{const s=i.value,o=s.length;if(o===t.length)return;const r=Di(s),a=o>t.length;i.issues.push({origin:r,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:i.value,inst:e,continue:!t.abort})}}),Nn=v("$ZodCheckStringFormat",(e,t)=>{var n,i;pt.init(e,t),e._zod.onattach.push(s=>{const o=s._zod.bag;o.format=t.format,t.pattern&&(o.patterns??(o.patterns=new Set),o.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=s=>{t.pattern.lastIndex=0,!t.pattern.test(s.value)&&s.issues.push({origin:"string",code:"invalid_format",format:t.format,input:s.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(i=e._zod).check??(i.check=()=>{})}),Jc=v("$ZodCheckRegex",(e,t)=>{Nn.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Kc=v("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Zc),Nn.init(e,t)}),Gc=v("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Wc),Nn.init(e,t)}),Qc=v("$ZodCheckIncludes",(e,t)=>{pt.init(e,t);const n=Ln(t.includes),i=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=i,e._zod.onattach.push(s=>{const o=s._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(i)}),e._zod.check=s=>{s.value.includes(t.includes,t.position)||s.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:s.value,inst:e,continue:!t.abort})}}),tl=v("$ZodCheckStartsWith",(e,t)=>{pt.init(e,t);const n=new RegExp(`^${Ln(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=i=>{i.value.startsWith(t.prefix)||i.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:i.value,inst:e,continue:!t.abort})}}),el=v("$ZodCheckEndsWith",(e,t)=>{pt.init(e,t);const n=new RegExp(`.*${Ln(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(i=>{const s=i._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=i=>{i.value.endsWith(t.suffix)||i.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:i.value,inst:e,continue:!t.abort})}}),nl=v("$ZodCheckOverwrite",(e,t)=>{pt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class il{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const i=t.split(`
2
+ `).filter(r=>r),s=Math.min(...i.map(r=>r.length-r.trimStart().length)),o=i.map(r=>r.slice(s)).map(r=>" ".repeat(this.indent*2)+r);for(const r of o)this.content.push(r)}compile(){const t=Function,n=this?.args,s=[...(this?.content??[""]).map(o=>` ${o}`)];return new t(...n,s.join(`
3
+ `))}}const sl={major:4,minor:3,patch:6},J=v("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=sl;const i=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&i.unshift(e);for(const s of i)for(const o of s._zod.onattach)o(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const s=(r,a,c)=>{let l=me(r),u;for(const h of a){if(h._zod.def.when){if(!h._zod.def.when(r))continue}else if(l)continue;const d=r.issues.length,f=h._zod.check(r);if(f instanceof Promise&&c?.async===!1)throw new _e;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,r.issues.length!==d&&(l||(l=me(r,d)))});else{if(r.issues.length===d)continue;l||(l=me(r,d))}}return u?u.then(()=>r):r},o=(r,a,c)=>{if(me(r))return r.aborted=!0,r;const l=s(a,i,c);if(l instanceof Promise){if(c.async===!1)throw new _e;return l.then(u=>e._zod.parse(u,c))}return e._zod.parse(l,c)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction==="backward"){const l=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(u=>o(u,r,a)):o(l,r,a)}const c=e._zod.parse(r,a);if(c instanceof Promise){if(a.async===!1)throw new _e;return c.then(l=>s(l,i,a))}return s(c,i,a)}}j(e,"~standard",()=>({validate:s=>{try{const o=hc(e,s);return o.success?{value:o.data}:{issues:o.error?.issues}}catch{return dc(e,s).then(r=>r.success?{value:r.data}:{issues:r.error?.issues})}},vendor:"zod",version:1}))}),$i=v("$ZodString",(e,t)=>{J.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??jc(e._zod.bag),e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),q=v("$ZodStringFormat",(e,t)=>{Nn.init(e,t),$i.init(e,t)}),ol=v("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Pc),q.init(e,t)}),rl=v("$ZodUUID",(e,t)=>{if(t.version){const i={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(i===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=as(i))}else t.pattern??(t.pattern=as());q.init(e,t)}),al=v("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Oc),q.init(e,t)}),cl=v("$ZodURL",(e,t)=>{q.init(e,t),e._zod.check=n=>{try{const i=n.value.trim(),s=new URL(i);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=s.href:n.value=i;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),ll=v("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=zc()),q.init(e,t)}),ul=v("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Tc),q.init(e,t)}),hl=v("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=vc),q.init(e,t)}),dl=v("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=wc),q.init(e,t)}),fl=v("$ZodULID",(e,t)=>{t.pattern??(t.pattern=kc),q.init(e,t)}),pl=v("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Sc),q.init(e,t)}),gl=v("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Mc),q.init(e,t)}),ml=v("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Bc(t)),q.init(e,t)}),bl=v("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Fc),q.init(e,t)}),yl=v("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Nc(t)),q.init(e,t)}),_l=v("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Cc),q.init(e,t)}),xl=v("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ic),q.init(e,t),e._zod.bag.format="ipv4"}),vl=v("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ac),q.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),wl=v("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Dc),q.init(e,t)}),kl=v("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Rc),q.init(e,t),e._zod.check=n=>{const i=n.value.split("/");try{if(i.length!==2)throw new Error;const[s,o]=i;if(!o)throw new Error;const r=Number(o);if(`${r}`!==o)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${s}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Mr(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Sl=v("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Lc),q.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Mr(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ml(e){if(!yr.test(e))return!1;const t=e.replace(/[-_]/g,i=>i==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Mr(n)}const Tl=v("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=yr),q.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Ml(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Cl=v("$ZodE164",(e,t)=>{t.pattern??(t.pattern=$c),q.init(e,t)});function Pl(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[i]=n;if(!i)return!1;const s=JSON.parse(atob(i));return!("typ"in s&&s?.typ!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}}const Ol=v("$ZodJWT",(e,t)=>{q.init(e,t),e._zod.check=n=>{Pl(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Tr=v("$ZodNumber",(e,t)=>{J.init(e,t),e._zod.pattern=e._zod.bag.pattern??vr,e._zod.parse=(n,i)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const s=n.value;if(typeof s=="number"&&!Number.isNaN(s)&&Number.isFinite(s))return n;const o=typeof s=="number"?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...o?{received:o}:{}}),n}}),El=v("$ZodNumberFormat",(e,t)=>{Uc.init(e,t),Tr.init(e,t)}),zl=v("$ZodAny",(e,t)=>{J.init(e,t),e._zod.parse=n=>n}),Il=v("$ZodUnknown",(e,t)=>{J.init(e,t),e._zod.parse=n=>n}),Al=v("$ZodNever",(e,t)=>{J.init(e,t),e._zod.parse=(n,i)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function cs(e,t,n){e.issues.length&&t.issues.push(...be(n,e.issues)),t.value[n]=e.value}const Dl=v("$ZodArray",(e,t)=>{J.init(e,t),e._zod.parse=(n,i)=>{const s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=Array(s.length);const o=[];for(let r=0;r<s.length;r++){const a=s[r],c=t.element._zod.run({value:a,issues:[]},i);c instanceof Promise?o.push(c.then(l=>cs(l,n,r))):cs(c,n,r)}return o.length?Promise.all(o).then(()=>n):n}});function Sn(e,t,n,i,s){if(e.issues.length){if(s&&!(n in i))return;t.issues.push(...be(n,e.issues))}e.value===void 0?n in i&&(t.value[n]=void 0):t.value[n]=e.value}function Cr(e){const t=Object.keys(e.shape);for(const i of t)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${i}": expected a Zod schema`);const n=tc(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Pr(e,t,n,i,s,o){const r=[],a=s.keySet,c=s.catchall._zod,l=c.def.type,u=c.optout==="optional";for(const h in t){if(a.has(h))continue;if(l==="never"){r.push(h);continue}const d=c.run({value:t[h],issues:[]},i);d instanceof Promise?e.push(d.then(f=>Sn(f,n,h,t,u))):Sn(d,n,h,t,u)}return r.length&&n.issues.push({code:"unrecognized_keys",keys:r,input:t,inst:o}),e.length?Promise.all(e).then(()=>n):n}const Rl=v("$ZodObject",(e,t)=>{if(J.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const i=zi(()=>Cr(t));j(e._zod,"propValues",()=>{const a=t.shape,c={};for(const l in a){const u=a[l]._zod;if(u.values){c[l]??(c[l]=new Set);for(const h of u.values)c[l].add(h)}}return c});const s=kn,o=t.catchall;let r;e._zod.parse=(a,c)=>{r??(r=i.value);const l=a.value;if(!s(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const u=[],h=r.shape;for(const d of r.keys){const f=h[d],p=f._zod.optout==="optional",g=f._zod.run({value:l[d],issues:[]},c);g instanceof Promise?u.push(g.then(m=>Sn(m,a,d,l,p))):Sn(g,a,d,l,p)}return o?Pr(u,l,a,c,i.value,e):u.length?Promise.all(u).then(()=>a):a}}),Ll=v("$ZodObjectJIT",(e,t)=>{Rl.init(e,t);const n=e._zod.parse,i=zi(()=>Cr(t)),s=d=>{const f=new il(["shape","payload","ctx"]),p=i.value,g=w=>{const x=rs(w);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};f.write("const input = payload.value;");const m=Object.create(null);let b=0;for(const w of p.keys)m[w]=`key_${b++}`;f.write("const newResult = {};");for(const w of p.keys){const x=m[w],_=rs(w),S=d[w]?._zod?.optout==="optional";f.write(`const ${x} = ${g(w)};`),S?f.write(`
4
+ if (${x}.issues.length) {
5
+ if (${_} in input) {
6
+ payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${_}, ...iss.path] : [${_}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${x}.value === undefined) {
14
+ if (${_} in input) {
15
+ newResult[${_}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${_}] = ${x}.value;
19
+ }
20
+
21
+ `):f.write(`
22
+ if (${x}.issues.length) {
23
+ payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${_}, ...iss.path] : [${_}]
26
+ })));
27
+ }
28
+
29
+ if (${x}.value === undefined) {
30
+ if (${_} in input) {
31
+ newResult[${_}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${_}] = ${x}.value;
35
+ }
36
+
37
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");const y=f.compile();return(w,x)=>y(d,w,x)};let o;const r=kn,a=!hr.jitless,l=a&&Ga.value,u=t.catchall;let h;e._zod.parse=(d,f)=>{h??(h=i.value);const p=d.value;return r(p)?a&&l&&f?.async===!1&&f.jitless!==!0?(o||(o=s(t.shape)),d=o(d,f),u?Pr([],p,d,f,h,e):d):n(d,f):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function ls(e,t,n,i){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const s=e.filter(o=>!me(o));return s.length===1?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(r=>Zt(r,i,Vt())))}),t)}const $l=v("$ZodUnion",(e,t)=>{J.init(e,t),j(e._zod,"optin",()=>t.options.some(s=>s._zod.optin==="optional")?"optional":void 0),j(e._zod,"optout",()=>t.options.some(s=>s._zod.optout==="optional")?"optional":void 0),j(e._zod,"values",()=>{if(t.options.every(s=>s._zod.values))return new Set(t.options.flatMap(s=>Array.from(s._zod.values)))}),j(e._zod,"pattern",()=>{if(t.options.every(s=>s._zod.pattern)){const s=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${s.map(o=>Ai(o.source)).join("|")})$`)}});const n=t.options.length===1,i=t.options[0]._zod.run;e._zod.parse=(s,o)=>{if(n)return i(s,o);let r=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:s.value,issues:[]},o);if(l instanceof Promise)a.push(l),r=!0;else{if(l.issues.length===0)return l;a.push(l)}}return r?Promise.all(a).then(c=>ls(c,s,e,o)):ls(a,s,e,o)}}),Fl=v("$ZodIntersection",(e,t)=>{J.init(e,t),e._zod.parse=(n,i)=>{const s=n.value,o=t.left._zod.run({value:s,issues:[]},i),r=t.right._zod.run({value:s,issues:[]},i);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then(([c,l])=>us(n,c,l)):us(n,o,r)}});function bi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ve(e)&&ve(t)){const n=Object.keys(t),i=Object.keys(e).filter(o=>n.indexOf(o)!==-1),s={...e,...t};for(const o of i){const r=bi(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};s[o]=r.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let i=0;i<e.length;i++){const s=e[i],o=t[i],r=bi(s,o);if(!r.valid)return{valid:!1,mergeErrorPath:[i,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function us(e,t,n){const i=new Map;let s;for(const a of t.issues)if(a.code==="unrecognized_keys"){s??(s=a);for(const c of a.keys)i.has(c)||i.set(c,{}),i.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)i.has(c)||i.set(c,{}),i.get(c).r=!0;else e.issues.push(a);const o=[...i].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&s&&e.issues.push({...s,keys:o}),me(e))return e;const r=bi(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const Nl=v("$ZodRecord",(e,t)=>{J.init(e,t),e._zod.parse=(n,i)=>{const s=n.value;if(!ve(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;const o=[],r=t.keyType._zod.values;if(r){n.value={};const a=new Set;for(const l of r)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const u=t.valueType._zod.run({value:s[l],issues:[]},i);u instanceof Promise?o.push(u.then(h=>{h.issues.length&&n.issues.push(...be(l,h.issues)),n.value[l]=h.value})):(u.issues.length&&n.issues.push(...be(l,u.issues)),n.value[l]=u.value)}let c;for(const l in s)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(s)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},i);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&vr.test(a)&&c.issues.length){const h=t.keyType._zod.run({value:Number(a),issues:[]},i);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(c=h)}if(c.issues.length){t.mode==="loose"?n.value[a]=s[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>Zt(h,i,Vt())),input:a,path:[a],inst:e});continue}const u=t.valueType._zod.run({value:s[a],issues:[]},i);u instanceof Promise?o.push(u.then(h=>{h.issues.length&&n.issues.push(...be(a,h.issues)),n.value[c.value]=h.value})):(u.issues.length&&n.issues.push(...be(a,u.issues)),n.value[c.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Bl=v("$ZodEnum",(e,t)=>{J.init(e,t);const n=dr(t.entries),i=new Set(n);e._zod.values=i,e._zod.pattern=new RegExp(`^(${n.filter(s=>Qa.has(typeof s)).map(s=>typeof s=="string"?Ln(s):s.toString()).join("|")})$`),e._zod.parse=(s,o)=>{const r=s.value;return i.has(r)||s.issues.push({code:"invalid_value",values:n,input:r,inst:e}),s}}),jl=v("$ZodTransform",(e,t)=>{J.init(e,t),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ur(e.constructor.name);const s=t.transform(n.value,n);if(i.async)return(s instanceof Promise?s:Promise.resolve(s)).then(r=>(n.value=r,n));if(s instanceof Promise)throw new _e;return n.value=s,n}});function hs(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Or=v("$ZodOptional",(e,t)=>{J.init(e,t),e._zod.optin="optional",e._zod.optout="optional",j(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ai(n.source)})?$`):void 0}),e._zod.parse=(n,i)=>{if(t.innerType._zod.optin==="optional"){const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>hs(o,n.value)):hs(s,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,i)}}),Vl=v("$ZodExactOptional",(e,t)=>{Or.init(e,t),j(e._zod,"values",()=>t.innerType._zod.values),j(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,i)=>t.innerType._zod.run(n,i)}),Zl=v("$ZodNullable",(e,t)=>{J.init(e,t),j(e._zod,"optin",()=>t.innerType._zod.optin),j(e._zod,"optout",()=>t.innerType._zod.optout),j(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${Ai(n.source)}|null)$`):void 0}),j(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,i)=>n.value===null?n:t.innerType._zod.run(n,i)}),Wl=v("$ZodDefault",(e,t)=>{J.init(e,t),e._zod.optin="optional",j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);if(n.value===void 0)return n.value=t.defaultValue,n;const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>ds(o,t)):ds(s,t)}});function ds(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Hl=v("$ZodPrefault",(e,t)=>{J.init(e,t),e._zod.optin="optional",j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>(i.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,i))}),Ul=v("$ZodNonOptional",(e,t)=>{J.init(e,t),j(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,i)=>{const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>fs(o,e)):fs(s,e)}});function fs(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const ql=v("$ZodCatch",(e,t)=>{J.init(e,t),j(e._zod,"optin",()=>t.innerType._zod.optin),j(e._zod,"optout",()=>t.innerType._zod.optout),j(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(r=>Zt(r,i,Vt()))},input:n.value}),n.issues=[]),n)):(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(o=>Zt(o,i,Vt()))},input:n.value}),n.issues=[]),n)}}),Yl=v("$ZodPipe",(e,t)=>{J.init(e,t),j(e._zod,"values",()=>t.in._zod.values),j(e._zod,"optin",()=>t.in._zod.optin),j(e._zod,"optout",()=>t.out._zod.optout),j(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,i)=>{if(i.direction==="backward"){const o=t.out._zod.run(n,i);return o instanceof Promise?o.then(r=>sn(r,t.in,i)):sn(o,t.in,i)}const s=t.in._zod.run(n,i);return s instanceof Promise?s.then(o=>sn(o,t.out,i)):sn(s,t.out,i)}});function sn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Xl=v("$ZodReadonly",(e,t)=>{J.init(e,t),j(e._zod,"propValues",()=>t.innerType._zod.propValues),j(e._zod,"values",()=>t.innerType._zod.values),j(e._zod,"optin",()=>t.innerType?._zod?.optin),j(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,i)=>{if(i.direction==="backward")return t.innerType._zod.run(n,i);const s=t.innerType._zod.run(n,i);return s instanceof Promise?s.then(ps):ps(s)}});function ps(e){return e.value=Object.freeze(e.value),e}const Jl=v("$ZodCustom",(e,t)=>{pt.init(e,t),J.init(e,t),e._zod.parse=(n,i)=>n,e._zod.check=n=>{const i=n.value,s=t.fn(i);if(s instanceof Promise)return s.then(o=>gs(o,n,i,e));gs(s,n,i,e)}});function gs(e,t,n,i){if(!e){const s={code:"custom",input:n,inst:i,path:[...i._zod.def.path??[]],continue:!i._zod.def.abort};i._zod.def.params&&(s.params=i._zod.def.params),t.issues.push(We(s))}}var ms;class Kl{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const i=n[0];return this._map.set(t,i),i&&typeof i=="object"&&"id"in i&&this._idmap.set(i.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const i={...this.get(n)??{}};delete i.id;const s={...i,...this._map.get(t)};return Object.keys(s).length?s:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Gl(){return new Kl}(ms=globalThis).__zod_globalRegistry??(ms.__zod_globalRegistry=Gl());const Re=globalThis.__zod_globalRegistry;function Ql(e,t){return new e({type:"string",...P(t)})}function tu(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function bs(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function eu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function nu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function iu(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function su(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function ou(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function ru(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function au(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function cu(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function lu(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function uu(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function hu(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function du(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function fu(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function pu(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function gu(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function mu(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function bu(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function yu(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function _u(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function xu(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}function vu(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function wu(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function ku(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Su(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function Mu(e,t){return new e({type:"number",checks:[],...P(t)})}function Tu(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function Cu(e){return new e({type:"any"})}function Pu(e){return new e({type:"unknown"})}function Ou(e,t){return new e({type:"never",...P(t)})}function ys(e,t){return new kr({check:"less_than",...P(t),value:e,inclusive:!1})}function Xn(e,t){return new kr({check:"less_than",...P(t),value:e,inclusive:!0})}function _s(e,t){return new Sr({check:"greater_than",...P(t),value:e,inclusive:!1})}function Jn(e,t){return new Sr({check:"greater_than",...P(t),value:e,inclusive:!0})}function xs(e,t){return new Hc({check:"multiple_of",...P(t),value:e})}function Er(e,t){return new qc({check:"max_length",...P(t),maximum:e})}function Mn(e,t){return new Yc({check:"min_length",...P(t),minimum:e})}function zr(e,t){return new Xc({check:"length_equals",...P(t),length:e})}function Eu(e,t){return new Jc({check:"string_format",format:"regex",...P(t),pattern:e})}function zu(e){return new Kc({check:"string_format",format:"lowercase",...P(e)})}function Iu(e){return new Gc({check:"string_format",format:"uppercase",...P(e)})}function Au(e,t){return new Qc({check:"string_format",format:"includes",...P(t),includes:e})}function Du(e,t){return new tl({check:"string_format",format:"starts_with",...P(t),prefix:e})}function Ru(e,t){return new el({check:"string_format",format:"ends_with",...P(t),suffix:e})}function Te(e){return new nl({check:"overwrite",tx:e})}function Lu(e){return Te(t=>t.normalize(e))}function $u(){return Te(e=>e.trim())}function Fu(){return Te(e=>e.toLowerCase())}function Nu(){return Te(e=>e.toUpperCase())}function Bu(){return Te(e=>Ka(e))}function ju(e,t,n){return new e({type:"array",element:t,...P(n)})}function Vu(e,t,n){return new e({type:"custom",check:"custom",fn:t,...P(n)})}function Zu(e){const t=Wu(n=>(n.addIssue=i=>{if(typeof i=="string")n.issues.push(We(i,n.value,t._zod.def));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=t),s.continue??(s.continue=!t._zod.def.abort),n.issues.push(We(s))}},e(n.value,n)));return t}function Wu(e,t){const n=new pt({check:"custom",...P(t)});return n._zod.check=e,n}function Ir(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Re,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function et(e,t,n={path:[],schemaPath:[]}){var i;const s=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.schema;const r={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,r);const a=e._zod.toJSONSchema?.();if(a)r.schema=a;else{const u={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,u);else{const d=r.schema,f=t.processors[s.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);f(e,t,d,u)}const h=e._zod.parent;h&&(r.ref||(r.ref=h),et(h,t,u),t.seen.get(h).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&ht(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((i=r.schema).default??(i.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function Ar(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=new Map;for(const r of e.seen.entries()){const a=e.metadataRegistry.get(r[0])?.id;if(a){const c=i.get(a);if(c&&c!==r[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);i.set(a,r[0])}}const s=r=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const h=e.external.registry.get(r[0])?.id,d=e.external.uri??(p=>p);if(h)return{ref:d(h)};const f=r[1].defId??r[1].schema.id??`schema${e.counter++}`;return r[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${f}`}}if(r[1]===n)return{ref:"#"};const l=`#/${a}/`,u=r[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},o=r=>{if(r[1].schema.$ref)return;const a=r[1],{ref:c,defId:l}=s(r);a.def={...a.schema},l&&(a.defId=l);const u=a.schema;for(const h in u)delete u[h];u.$ref=c};if(e.cycles==="throw")for(const r of e.seen.entries()){const a=r[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
38
+
39
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const a=r[1];if(t===r[0]){o(r);continue}if(e.external){const l=e.external.registry.get(r[0])?.id;if(t!==r[0]&&l){o(r);continue}}if(e.metadataRegistry.get(r[0])?.id){o(r);continue}if(a.cycle){o(r);continue}if(a.count>1&&e.reused==="ref"){o(r);continue}}}function Dr(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const i=r=>{const a=e.seen.get(r);if(a.ref===null)return;const c=a.def??a.schema,l={...c},u=a.ref;if(a.ref=null,u){i(u);const d=e.seen.get(u),f=d.schema;if(f.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(f)):Object.assign(c,f),Object.assign(c,l),r._zod.parent===u)for(const g in c)g==="$ref"||g==="allOf"||g in l||delete c[g];if(f.$ref&&d.def)for(const g in c)g==="$ref"||g==="allOf"||g in d.def&&JSON.stringify(c[g])===JSON.stringify(d.def[g])&&delete c[g]}const h=r._zod.parent;if(h&&h!==u){i(h);const d=e.seen.get(h);if(d?.schema.$ref&&(c.$ref=d.schema.$ref,d.def))for(const f in c)f==="$ref"||f==="allOf"||f in d.def&&JSON.stringify(c[f])===JSON.stringify(d.def[f])&&delete c[f]}e.override({zodSchema:r,jsonSchema:c,path:a.path??[]})};for(const r of[...e.seen.entries()].reverse())i(r[0]);const s={};if(e.target==="draft-2020-12"?s.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?s.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(r)}Object.assign(s,n.def??n.schema);const o=e.external?.defs??{};for(const r of e.seen.entries()){const a=r[1];a.def&&a.defId&&(o[a.defId]=a.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?s.$defs=o:s.definitions=o);try{const r=JSON.parse(JSON.stringify(s));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:Tn(t,"input",e.processors),output:Tn(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch{throw new Error("Error converting schema to JSON.")}}function ht(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const i=e._zod.def;if(i.type==="transform")return!0;if(i.type==="array")return ht(i.element,n);if(i.type==="set")return ht(i.valueType,n);if(i.type==="lazy")return ht(i.getter(),n);if(i.type==="promise"||i.type==="optional"||i.type==="nonoptional"||i.type==="nullable"||i.type==="readonly"||i.type==="default"||i.type==="prefault")return ht(i.innerType,n);if(i.type==="intersection")return ht(i.left,n)||ht(i.right,n);if(i.type==="record"||i.type==="map")return ht(i.keyType,n)||ht(i.valueType,n);if(i.type==="pipe")return ht(i.in,n)||ht(i.out,n);if(i.type==="object"){for(const s in i.shape)if(ht(i.shape[s],n))return!0;return!1}if(i.type==="union"){for(const s of i.options)if(ht(s,n))return!0;return!1}if(i.type==="tuple"){for(const s of i.items)if(ht(s,n))return!0;return!!(i.rest&&ht(i.rest,n))}return!1}const Hu=(e,t={})=>n=>{const i=Ir({...n,processors:t});return et(e,i),Ar(i,e),Dr(i,e)},Tn=(e,t,n={})=>i=>{const{libraryOptions:s,target:o}=i??{},r=Ir({...s??{},target:o,io:t,processors:n});return et(e,r),Ar(r,e),Dr(r,e)},Uu={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},qu=(e,t,n,i)=>{const s=n;s.type="string";const{minimum:o,maximum:r,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof o=="number"&&(s.minLength=o),typeof r=="number"&&(s.maxLength=r),a&&(s.format=Uu[a]??a,s.format===""&&delete s.format,a==="time"&&delete s.format),l&&(s.contentEncoding=l),c&&c.size>0){const u=[...c];u.length===1?s.pattern=u[0].source:u.length>1&&(s.allOf=[...u.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Yu=(e,t,n,i)=>{const s=n,{minimum:o,maximum:r,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?s.type="integer":s.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(s.minimum=u,s.exclusiveMinimum=!0):s.exclusiveMinimum=u),typeof o=="number"&&(s.minimum=o,typeof u=="number"&&t.target!=="draft-04"&&(u>=o?delete s.minimum:delete s.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(s.maximum=l,s.exclusiveMaximum=!0):s.exclusiveMaximum=l),typeof r=="number"&&(s.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete s.maximum:delete s.exclusiveMaximum)),typeof c=="number"&&(s.multipleOf=c)},Xu=(e,t,n,i)=>{n.not={}},Ju=(e,t,n,i)=>{},Ku=(e,t,n,i)=>{},Gu=(e,t,n,i)=>{const s=e._zod.def,o=dr(s.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},Qu=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},th=(e,t,n,i)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},eh=(e,t,n,i)=>{const s=n,o=e._zod.def,{minimum:r,maximum:a}=e._zod.bag;typeof r=="number"&&(s.minItems=r),typeof a=="number"&&(s.maxItems=a),s.type="array",s.items=et(o.element,t,{...i,path:[...i.path,"items"]})},nh=(e,t,n,i)=>{const s=n,o=e._zod.def;s.type="object",s.properties={};const r=o.shape;for(const l in r)s.properties[l]=et(r[l],t,{...i,path:[...i.path,"properties",l]});const a=new Set(Object.keys(r)),c=new Set([...a].filter(l=>{const u=o.shape[l]._zod;return t.io==="input"?u.optin===void 0:u.optout===void 0}));c.size>0&&(s.required=Array.from(c)),o.catchall?._zod.def.type==="never"?s.additionalProperties=!1:o.catchall?o.catchall&&(s.additionalProperties=et(o.catchall,t,{...i,path:[...i.path,"additionalProperties"]})):t.io==="output"&&(s.additionalProperties=!1)},ih=(e,t,n,i)=>{const s=e._zod.def,o=s.inclusive===!1,r=s.options.map((a,c)=>et(a,t,{...i,path:[...i.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},sh=(e,t,n,i)=>{const s=e._zod.def,o=et(s.left,t,{...i,path:[...i.path,"allOf",0]}),r=et(s.right,t,{...i,path:[...i.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(o)?o.allOf:[o],...a(r)?r.allOf:[r]];n.allOf=c},oh=(e,t,n,i)=>{const s=n,o=e._zod.def;s.type="object";const r=o.keyType,c=r._zod.bag?.patterns;if(o.mode==="loose"&&c&&c.size>0){const u=et(o.valueType,t,{...i,path:[...i.path,"patternProperties","*"]});s.patternProperties={};for(const h of c)s.patternProperties[h.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(s.propertyNames=et(o.keyType,t,{...i,path:[...i.path,"propertyNames"]})),s.additionalProperties=et(o.valueType,t,{...i,path:[...i.path,"additionalProperties"]});const l=r._zod.values;if(l){const u=[...l].filter(h=>typeof h=="string"||typeof h=="number");u.length>0&&(s.required=u)}},rh=(e,t,n,i)=>{const s=e._zod.def,o=et(s.innerType,t,i),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=s.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},ah=(e,t,n,i)=>{const s=e._zod.def;et(s.innerType,t,i);const o=t.seen.get(e);o.ref=s.innerType},ch=(e,t,n,i)=>{const s=e._zod.def;et(s.innerType,t,i);const o=t.seen.get(e);o.ref=s.innerType,n.default=JSON.parse(JSON.stringify(s.defaultValue))},lh=(e,t,n,i)=>{const s=e._zod.def;et(s.innerType,t,i);const o=t.seen.get(e);o.ref=s.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},uh=(e,t,n,i)=>{const s=e._zod.def;et(s.innerType,t,i);const o=t.seen.get(e);o.ref=s.innerType;let r;try{r=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},hh=(e,t,n,i)=>{const s=e._zod.def,o=t.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;et(o,t,i);const r=t.seen.get(e);r.ref=o},dh=(e,t,n,i)=>{const s=e._zod.def;et(s.innerType,t,i);const o=t.seen.get(e);o.ref=s.innerType,n.readOnly=!0},Rr=(e,t,n,i)=>{const s=e._zod.def;et(s.innerType,t,i);const o=t.seen.get(e);o.ref=s.innerType},fh=v("ZodISODateTime",(e,t)=>{ml.init(e,t),Y.init(e,t)});function ph(e){return vu(fh,e)}const gh=v("ZodISODate",(e,t)=>{bl.init(e,t),Y.init(e,t)});function mh(e){return wu(gh,e)}const bh=v("ZodISOTime",(e,t)=>{yl.init(e,t),Y.init(e,t)});function yh(e){return ku(bh,e)}const _h=v("ZodISODuration",(e,t)=>{_l.init(e,t),Y.init(e,t)});function xh(e){return Su(_h,e)}const vh=(e,t)=>{mr.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>uc(e,n)},flatten:{value:n=>lc(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,mi,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,mi,2)}},isEmpty:{get(){return e.issues.length===0}}})},yt=v("ZodError",vh,{Parent:Error}),wh=Ri(yt),kh=Li(yt),Sh=$n(yt),Mh=Fn(yt),Th=fc(yt),Ch=pc(yt),Ph=gc(yt),Oh=mc(yt),Eh=bc(yt),zh=yc(yt),Ih=_c(yt),Ah=xc(yt),K=v("ZodType",(e,t)=>(J.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Tn(e,"input"),output:Tn(e,"output")}}),e.toJSONSchema=Hu(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(Ut(t,{checks:[...t.checks??[],...n.map(i=>typeof i=="function"?{_zod:{check:i,def:{check:"custom"},onattach:[]}}:i)]}),{parent:!0}),e.with=e.check,e.clone=(n,i)=>qt(e,n,i),e.brand=()=>e,e.register=((n,i)=>(n.add(e,i),e)),e.parse=(n,i)=>wh(e,n,i,{callee:e.parse}),e.safeParse=(n,i)=>Sh(e,n,i),e.parseAsync=async(n,i)=>kh(e,n,i,{callee:e.parseAsync}),e.safeParseAsync=async(n,i)=>Mh(e,n,i),e.spa=e.safeParseAsync,e.encode=(n,i)=>Th(e,n,i),e.decode=(n,i)=>Ch(e,n,i),e.encodeAsync=async(n,i)=>Ph(e,n,i),e.decodeAsync=async(n,i)=>Oh(e,n,i),e.safeEncode=(n,i)=>Eh(e,n,i),e.safeDecode=(n,i)=>zh(e,n,i),e.safeEncodeAsync=async(n,i)=>Ih(e,n,i),e.safeDecodeAsync=async(n,i)=>Ah(e,n,i),e.refine=(n,i)=>e.check(Md(n,i)),e.superRefine=n=>e.check(Td(n)),e.overwrite=n=>e.check(Te(n)),e.optional=()=>Ss(e),e.exactOptional=()=>dd(e),e.nullable=()=>Ms(e),e.nullish=()=>Ss(Ms(e)),e.nonoptional=n=>yd(e,n),e.array=()=>vt(e),e.or=n=>Fr([e,n]),e.and=n=>ad(e,n),e.transform=n=>Ts(e,ud(n)),e.default=n=>gd(e,n),e.prefault=n=>bd(e,n),e.catch=n=>xd(e,n),e.pipe=n=>Ts(e,n),e.readonly=()=>kd(e),e.describe=n=>{const i=e.clone();return Re.add(i,{description:n}),i},Object.defineProperty(e,"description",{get(){return Re.get(e)?.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Re.get(e);const i=e.clone();return Re.add(i,n[0]),i},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Lr=v("_ZodString",(e,t)=>{$i.init(e,t),K.init(e,t),e._zod.processJSONSchema=(i,s,o)=>qu(e,i,s);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...i)=>e.check(Eu(...i)),e.includes=(...i)=>e.check(Au(...i)),e.startsWith=(...i)=>e.check(Du(...i)),e.endsWith=(...i)=>e.check(Ru(...i)),e.min=(...i)=>e.check(Mn(...i)),e.max=(...i)=>e.check(Er(...i)),e.length=(...i)=>e.check(zr(...i)),e.nonempty=(...i)=>e.check(Mn(1,...i)),e.lowercase=i=>e.check(zu(i)),e.uppercase=i=>e.check(Iu(i)),e.trim=()=>e.check($u()),e.normalize=(...i)=>e.check(Lu(...i)),e.toLowerCase=()=>e.check(Fu()),e.toUpperCase=()=>e.check(Nu()),e.slugify=()=>e.check(Bu())}),Dh=v("ZodString",(e,t)=>{$i.init(e,t),Lr.init(e,t),e.email=n=>e.check(tu(Rh,n)),e.url=n=>e.check(ou(Lh,n)),e.jwt=n=>e.check(xu(Kh,n)),e.emoji=n=>e.check(ru($h,n)),e.guid=n=>e.check(bs(vs,n)),e.uuid=n=>e.check(eu(on,n)),e.uuidv4=n=>e.check(nu(on,n)),e.uuidv6=n=>e.check(iu(on,n)),e.uuidv7=n=>e.check(su(on,n)),e.nanoid=n=>e.check(au(Fh,n)),e.guid=n=>e.check(bs(vs,n)),e.cuid=n=>e.check(cu(Nh,n)),e.cuid2=n=>e.check(lu(Bh,n)),e.ulid=n=>e.check(uu(jh,n)),e.base64=n=>e.check(bu(Yh,n)),e.base64url=n=>e.check(yu(Xh,n)),e.xid=n=>e.check(hu(Vh,n)),e.ksuid=n=>e.check(du(Zh,n)),e.ipv4=n=>e.check(fu(Wh,n)),e.ipv6=n=>e.check(pu(Hh,n)),e.cidrv4=n=>e.check(gu(Uh,n)),e.cidrv6=n=>e.check(mu(qh,n)),e.e164=n=>e.check(_u(Jh,n)),e.datetime=n=>e.check(ph(n)),e.date=n=>e.check(mh(n)),e.time=n=>e.check(yh(n)),e.duration=n=>e.check(xh(n))});function E(e){return Ql(Dh,e)}const Y=v("ZodStringFormat",(e,t)=>{q.init(e,t),Lr.init(e,t)}),Rh=v("ZodEmail",(e,t)=>{al.init(e,t),Y.init(e,t)}),vs=v("ZodGUID",(e,t)=>{ol.init(e,t),Y.init(e,t)}),on=v("ZodUUID",(e,t)=>{rl.init(e,t),Y.init(e,t)}),Lh=v("ZodURL",(e,t)=>{cl.init(e,t),Y.init(e,t)}),$h=v("ZodEmoji",(e,t)=>{ll.init(e,t),Y.init(e,t)}),Fh=v("ZodNanoID",(e,t)=>{ul.init(e,t),Y.init(e,t)}),Nh=v("ZodCUID",(e,t)=>{hl.init(e,t),Y.init(e,t)}),Bh=v("ZodCUID2",(e,t)=>{dl.init(e,t),Y.init(e,t)}),jh=v("ZodULID",(e,t)=>{fl.init(e,t),Y.init(e,t)}),Vh=v("ZodXID",(e,t)=>{pl.init(e,t),Y.init(e,t)}),Zh=v("ZodKSUID",(e,t)=>{gl.init(e,t),Y.init(e,t)}),Wh=v("ZodIPv4",(e,t)=>{xl.init(e,t),Y.init(e,t)}),Hh=v("ZodIPv6",(e,t)=>{vl.init(e,t),Y.init(e,t)}),Uh=v("ZodCIDRv4",(e,t)=>{wl.init(e,t),Y.init(e,t)}),qh=v("ZodCIDRv6",(e,t)=>{kl.init(e,t),Y.init(e,t)}),Yh=v("ZodBase64",(e,t)=>{Sl.init(e,t),Y.init(e,t)}),Xh=v("ZodBase64URL",(e,t)=>{Tl.init(e,t),Y.init(e,t)}),Jh=v("ZodE164",(e,t)=>{Cl.init(e,t),Y.init(e,t)}),Kh=v("ZodJWT",(e,t)=>{Ol.init(e,t),Y.init(e,t)}),$r=v("ZodNumber",(e,t)=>{Tr.init(e,t),K.init(e,t),e._zod.processJSONSchema=(i,s,o)=>Yu(e,i,s),e.gt=(i,s)=>e.check(_s(i,s)),e.gte=(i,s)=>e.check(Jn(i,s)),e.min=(i,s)=>e.check(Jn(i,s)),e.lt=(i,s)=>e.check(ys(i,s)),e.lte=(i,s)=>e.check(Xn(i,s)),e.max=(i,s)=>e.check(Xn(i,s)),e.int=i=>e.check(ws(i)),e.safe=i=>e.check(ws(i)),e.positive=i=>e.check(_s(0,i)),e.nonnegative=i=>e.check(Jn(0,i)),e.negative=i=>e.check(ys(0,i)),e.nonpositive=i=>e.check(Xn(0,i)),e.multipleOf=(i,s)=>e.check(xs(i,s)),e.step=(i,s)=>e.check(xs(i,s)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function O(e){return Mu($r,e)}const Gh=v("ZodNumberFormat",(e,t)=>{El.init(e,t),$r.init(e,t)});function ws(e){return Tu(Gh,e)}const Qh=v("ZodAny",(e,t)=>{zl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Ju()});function ks(){return Cu(Qh)}const td=v("ZodUnknown",(e,t)=>{Il.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Ku()});function yi(){return Pu(td)}const ed=v("ZodNever",(e,t)=>{Al.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Xu(e,n,i)});function nd(e){return Ou(ed,e)}const id=v("ZodArray",(e,t)=>{Dl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>eh(e,n,i,s),e.element=t.element,e.min=(n,i)=>e.check(Mn(n,i)),e.nonempty=n=>e.check(Mn(1,n)),e.max=(n,i)=>e.check(Er(n,i)),e.length=(n,i)=>e.check(zr(n,i)),e.unwrap=()=>e.element});function vt(e,t){return ju(id,e,t)}const sd=v("ZodObject",(e,t)=>{Ll.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>nh(e,n,i,s),j(e,"shape",()=>t.shape),e.keyof=()=>Nr(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:yi()}),e.loose=()=>e.clone({...e._zod.def,catchall:yi()}),e.strict=()=>e.clone({...e._zod.def,catchall:nd()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>sc(e,n),e.safeExtend=n=>oc(e,n),e.merge=n=>rc(e,n),e.pick=n=>nc(e,n),e.omit=n=>ic(e,n),e.partial=(...n)=>ac(Br,e,n[0]),e.required=(...n)=>cc(jr,e,n[0])});function nt(e,t){const n={type:"object",shape:e??{},...P(t)};return new sd(n)}const od=v("ZodUnion",(e,t)=>{$l.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>ih(e,n,i,s),e.options=t.options});function Fr(e,t){return new od({type:"union",options:e,...P(t)})}const rd=v("ZodIntersection",(e,t)=>{Fl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>sh(e,n,i,s)});function ad(e,t){return new rd({type:"intersection",left:e,right:t})}const cd=v("ZodRecord",(e,t)=>{Nl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>oh(e,n,i,s),e.keyType=t.keyType,e.valueType=t.valueType});function rn(e,t,n){return new cd({type:"record",keyType:e,valueType:t,...P(n)})}const _i=v("ZodEnum",(e,t)=>{Bl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(i,s,o)=>Gu(e,i,s),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(i,s)=>{const o={};for(const r of i)if(n.has(r))o[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new _i({...t,checks:[],...P(s),entries:o})},e.exclude=(i,s)=>{const o={...t.entries};for(const r of i)if(n.has(r))delete o[r];else throw new Error(`Key ${r} not found in enum`);return new _i({...t,checks:[],...P(s),entries:o})}});function Nr(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(i=>[i,i])):e;return new _i({type:"enum",entries:n,...P(t)})}const ld=v("ZodTransform",(e,t)=>{jl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>th(e,n),e._zod.parse=(n,i)=>{if(i.direction==="backward")throw new ur(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(We(o,n.value,t));else{const r=o;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=e),n.issues.push(We(r))}};const s=t.transform(n.value,n);return s instanceof Promise?s.then(o=>(n.value=o,n)):(n.value=s,n)}});function ud(e){return new ld({type:"transform",transform:e})}const Br=v("ZodOptional",(e,t)=>{Or.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Rr(e,n,i,s),e.unwrap=()=>e._zod.def.innerType});function Ss(e){return new Br({type:"optional",innerType:e})}const hd=v("ZodExactOptional",(e,t)=>{Vl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Rr(e,n,i,s),e.unwrap=()=>e._zod.def.innerType});function dd(e){return new hd({type:"optional",innerType:e})}const fd=v("ZodNullable",(e,t)=>{Zl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>rh(e,n,i,s),e.unwrap=()=>e._zod.def.innerType});function Ms(e){return new fd({type:"nullable",innerType:e})}const pd=v("ZodDefault",(e,t)=>{Wl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>ch(e,n,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function gd(e,t){return new pd({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():pr(t)}})}const md=v("ZodPrefault",(e,t)=>{Hl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>lh(e,n,i,s),e.unwrap=()=>e._zod.def.innerType});function bd(e,t){return new md({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():pr(t)}})}const jr=v("ZodNonOptional",(e,t)=>{Ul.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>ah(e,n,i,s),e.unwrap=()=>e._zod.def.innerType});function yd(e,t){return new jr({type:"nonoptional",innerType:e,...P(t)})}const _d=v("ZodCatch",(e,t)=>{ql.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>uh(e,n,i,s),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function xd(e,t){return new _d({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const vd=v("ZodPipe",(e,t)=>{Yl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>hh(e,n,i,s),e.in=t.in,e.out=t.out});function Ts(e,t){return new vd({type:"pipe",in:e,out:t})}const wd=v("ZodReadonly",(e,t)=>{Xl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>dh(e,n,i,s),e.unwrap=()=>e._zod.def.innerType});function kd(e){return new wd({type:"readonly",innerType:e})}const Sd=v("ZodCustom",(e,t)=>{Jl.init(e,t),K.init(e,t),e._zod.processJSONSchema=(n,i,s)=>Qu(e,n)});function Md(e,t={}){return Vu(Sd,e,t)}function Td(e){return Zu(e)}const Cs=nt({size:O(),hits:O(),misses:O()}),Vr=nt({procedureName:Cs,argument:Cs}),Cd=nt({totalRequests:O(),totalTimeouts:O(),totalRequestsEnqueued:O().optional(),totalRequestsDequeued:O().optional(),totalRequestsFailed:O().optional()}),Pd=nt({name:E(),connectionsInUse:O(),connectionsOpen:O(),stats:Cd.nullable(),cache:Vr.optional()}),Od=nt({requestCount:O(),errorCount:O(),avgResponseTime:O(),minResponseTime:O(),maxResponseTime:O(),maxRequestsPerSecond:O()}),Ed=nt({timestamp:O(),requests:O(),errors:O(),durationMin:O(),durationMax:O(),durationAvg:O(),durationP95:O(),durationP99:O(),system:nt({cpu:O(),heapUsed:O(),heapTotal:O(),rss:O(),external:O()}),pools:vt(nt({name:E(),connectionsInUse:O(),connectionsOpen:O(),cache:Vr.optional()}))}),Ps=nt({route:E(),user:E().optional(),password:E().optional(),connectString:E().optional(),defaultPage:E().optional(),pathAlias:E().optional(),pathAliasProcedure:E().optional(),documentTable:E().optional(),exclusionList:vt(E()).optional(),requestValidationFunction:E().optional(),transactionMode:yi().optional(),errorStyle:E().optional(),directoryPath:E().optional()}),zd=nt({port:O(),adminRoute:E().optional(),adminUser:E().optional(),adminPassword:E().optional(),loggerFilename:E(),uploadFileSizeLimit:O().optional(),routePlSql:vt(Ps),routeStatic:vt(Ps)}),Id=nt({nodeVersion:E(),platform:E(),arch:E(),cpuCores:O().optional(),memory:nt({rss:O(),heapTotal:O(),heapUsed:O(),external:O(),totalMemory:O().optional(),rssMax:O().optional(),heapTotalMax:O().optional(),heapUsedMax:O().optional(),externalMax:O().optional()}),cpu:nt({user:O(),system:O(),max:O().optional(),userMax:O().optional(),systemMax:O().optional()})}),Ad=nt({version:E(),status:Nr(["running","paused","stopped"]),uptime:O(),startTime:E(),intervalMs:O().optional(),metrics:Od,history:vt(Ed).optional(),pools:vt(Pd),system:Id,config:zd.partial()}),Dd=nt({timestamp:E(),req:nt({method:E().optional(),url:E().optional()}).optional(),message:E(),details:nt({fullMessage:E().optional()}).optional()}),Rd=Fr([vt(E()),nt({message:E()})]),Ld=nt({id:E(),timestamp:E(),source:E(),url:E(),method:E(),status:E(),duration:O(),procedure:E().optional(),parameters:rn(E(),ks()).optional(),uploads:vt(ks()).optional(),downloads:nt({fileType:E(),fileSize:O()}).optional(),html:E().optional(),cookies:rn(E(),E()).optional(),headers:rn(E(),E()).optional(),cgi:rn(E(),E()).optional(),error:E().optional()});function an(e,t,n){const i=t.safeParse(e);if(!i.success)throw new Error(`Validation failed for ${n}: ${i.error.message}`);return i.data}async function Lt(e,t,n=2,i=500){for(let s=0;s<=n;s++)try{return await fetch(e,t)}catch(o){if(s===n)throw o;await new Promise(r=>setTimeout(r,i))}throw new Error("Unreachable")}const bt={async getStatus(){const e=await Lt("api/status");if(!e.ok)throw new Error(`GET api/status failed: ${e.statusText}`);const t=await e.json();return an(t,Ad,"api/status")},async getErrorLogs(e=100,t=""){const n=new URLSearchParams({limit:e.toString(),filter:t}),i=await Lt(`api/logs/error?${n.toString()}`);if(!i.ok)throw new Error(`GET api/logs/error failed: ${i.statusText}`);const s=await i.json();return an(s,vt(Dd),"api/logs/error")},async getAccessLogs(e=100,t=""){const n=new URLSearchParams({limit:e.toString(),filter:t}),i=await Lt(`api/logs/access?${n.toString()}`);if(!i.ok)throw new Error(`GET api/logs/access failed: ${i.statusText}`);const s=await i.json();return an(s,Rd,"api/logs/access")},async getTraceLogs(e=100,t=""){const n=new URLSearchParams({limit:e.toString(),filter:t}),i=await Lt(`api/trace/logs?${n.toString()}`);if(!i.ok)throw new Error(`GET api/trace/logs failed: ${i.statusText}`);const s=await i.json();return an(s,vt(Ld),"api/trace/logs")},async getTraceStatus(){const e=await Lt("api/trace/status");if(!e.ok)throw new Error(`GET api/trace/status failed: ${e.statusText}`);return await e.json()},async toggleTrace(e){const t=await Lt("api/trace/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})});if(!t.ok)throw new Error(`POST api/trace/toggle failed: ${t.statusText}`);return await t.json()},async clearTraces(){const e=await Lt("api/trace/clear",{method:"POST"});if(!e.ok)throw new Error(`POST api/trace/clear failed: ${e.statusText}`)},async post(e,t={}){const n=await Lt(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`POST ${e} failed: ${n.statusText}`)}};function Ge(e){return e+.5|0}const $t=(e,t,n)=>Math.max(Math.min(e,n),t);function Le(e){return $t(Ge(e*2.55),0,255)}function jt(e){return $t(Ge(e*255),0,255)}function Ot(e){return $t(Ge(e/2.55)/100,0,1)}function Os(e){return $t(Ge(e*100),0,100)}const mt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},xi=[..."0123456789ABCDEF"],$d=e=>xi[e&15],Fd=e=>xi[(e&240)>>4]+xi[e&15],cn=e=>(e&240)>>4===(e&15),Nd=e=>cn(e.r)&&cn(e.g)&&cn(e.b)&&cn(e.a);function Bd(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&mt[e[1]]*17,g:255&mt[e[2]]*17,b:255&mt[e[3]]*17,a:t===5?mt[e[4]]*17:255}:(t===7||t===9)&&(n={r:mt[e[1]]<<4|mt[e[2]],g:mt[e[3]]<<4|mt[e[4]],b:mt[e[5]]<<4|mt[e[6]],a:t===9?mt[e[7]]<<4|mt[e[8]]:255})),n}const jd=(e,t)=>e<255?t(e):"";function Vd(e){var t=Nd(e)?$d:Fd;return e?"#"+t(e.r)+t(e.g)+t(e.b)+jd(e.a,t):void 0}const Zd=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function Zr(e,t,n){const i=t*Math.min(n,1-n),s=(o,r=(o+e/30)%12)=>n-i*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function Wd(e,t,n){const i=(s,o=(s+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function Hd(e,t,n){const i=Zr(e,1,.5);let s;for(t+n>1&&(s=1/(t+n),t*=s,n*=s),s=0;s<3;s++)i[s]*=1-t-n,i[s]+=t;return i}function Ud(e,t,n,i,s){return e===s?(t-n)/i+(t<n?6:0):t===s?(n-e)/i+2:(e-t)/i+4}function Fi(e){const n=e.r/255,i=e.g/255,s=e.b/255,o=Math.max(n,i,s),r=Math.min(n,i,s),a=(o+r)/2;let c,l,u;return o!==r&&(u=o-r,l=a>.5?u/(2-o-r):u/(o+r),c=Ud(n,i,s,u,o),c=c*60+.5),[c|0,l||0,a]}function Ni(e,t,n,i){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,i)).map(jt)}function Bi(e,t,n){return Ni(Zr,e,t,n)}function qd(e,t,n){return Ni(Hd,e,t,n)}function Yd(e,t,n){return Ni(Wd,e,t,n)}function Wr(e){return(e%360+360)%360}function Xd(e){const t=Zd.exec(e);let n=255,i;if(!t)return;t[5]!==i&&(n=t[6]?Le(+t[5]):jt(+t[5]));const s=Wr(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?i=qd(s,o,r):t[1]==="hsv"?i=Yd(s,o,r):i=Bi(s,o,r),{r:i[0],g:i[1],b:i[2],a:n}}function Jd(e,t){var n=Fi(e);n[0]=Wr(n[0]+t),n=Bi(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Kd(e){if(!e)return;const t=Fi(e),n=t[0],i=Os(t[1]),s=Os(t[2]);return e.a<255?`hsla(${n}, ${i}%, ${s}%, ${Ot(e.a)})`:`hsl(${n}, ${i}%, ${s}%)`}const Es={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},zs={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function Gd(){const e={},t=Object.keys(zs),n=Object.keys(Es);let i,s,o,r,a;for(i=0;i<t.length;i++){for(r=a=t[i],s=0;s<n.length;s++)o=n[s],a=a.replace(o,Es[o]);o=parseInt(zs[r],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}let ln;function Qd(e){ln||(ln=Gd(),ln.transparent=[0,0,0,0]);const t=ln[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const tf=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function ef(e){const t=tf.exec(e);let n=255,i,s,o;if(t){if(t[7]!==i){const r=+t[7];n=t[8]?Le(r):$t(r*255,0,255)}return i=+t[1],s=+t[3],o=+t[5],i=255&(t[2]?Le(i):$t(i,0,255)),s=255&(t[4]?Le(s):$t(s,0,255)),o=255&(t[6]?Le(o):$t(o,0,255)),{r:i,g:s,b:o,a:n}}}function nf(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${Ot(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}const Kn=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,pe=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function sf(e,t,n){const i=pe(Ot(e.r)),s=pe(Ot(e.g)),o=pe(Ot(e.b));return{r:jt(Kn(i+n*(pe(Ot(t.r))-i))),g:jt(Kn(s+n*(pe(Ot(t.g))-s))),b:jt(Kn(o+n*(pe(Ot(t.b))-o))),a:e.a+n*(t.a-e.a)}}function un(e,t,n){if(e){let i=Fi(e);i[t]=Math.max(0,Math.min(i[t]+i[t]*n,t===0?360:1)),i=Bi(i),e.r=i[0],e.g=i[1],e.b=i[2]}}function Hr(e,t){return e&&Object.assign(t||{},e)}function Is(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=jt(e[3]))):(t=Hr(e,{r:0,g:0,b:0,a:1}),t.a=jt(t.a)),t}function of(e){return e.charAt(0)==="r"?ef(e):Xd(e)}class He{constructor(t){if(t instanceof He)return t;const n=typeof t;let i;n==="object"?i=Is(t):n==="string"&&(i=Bd(t)||Qd(t)||of(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Hr(this._rgb);return t&&(t.a=Ot(t.a)),t}set rgb(t){this._rgb=Is(t)}rgbString(){return this._valid?nf(this._rgb):void 0}hexString(){return this._valid?Vd(this._rgb):void 0}hslString(){return this._valid?Kd(this._rgb):void 0}mix(t,n){if(t){const i=this.rgb,s=t.rgb;let o;const r=n===o?.5:n,a=2*r-1,c=i.a-s.a,l=((a*c===-1?a:(a+c)/(1+a*c))+1)/2;o=1-l,i.r=255&l*i.r+o*s.r+.5,i.g=255&l*i.g+o*s.g+.5,i.b=255&l*i.b+o*s.b+.5,i.a=r*i.a+(1-r)*s.a,this.rgb=i}return this}interpolate(t,n){return t&&(this._rgb=sf(this._rgb,t._rgb,n)),this}clone(){return new He(this.rgb)}alpha(t){return this._rgb.a=jt(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=Ge(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){const n=this._rgb;return n.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return un(this._rgb,2,t),this}darken(t){return un(this._rgb,2,-t),this}saturate(t){return un(this._rgb,1,t),this}desaturate(t){return un(this._rgb,1,-t),this}rotate(t){return Jd(this._rgb,t),this}}function Tt(){}const rf=(()=>{let e=0;return()=>e++})();function R(e){return e==null}function H(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function L(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function X(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function gt(e,t){return X(e)?e:t}function z(e,t){return typeof e>"u"?t:e}const af=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100:+e/t,Ur=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function V(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function B(e,t,n,i){let s,o,r;if(H(e))for(o=e.length,s=0;s<o;s++)t.call(n,e[s],s);else if(L(e))for(r=Object.keys(e),o=r.length,s=0;s<o;s++)t.call(n,e[r[s]],r[s])}function Cn(e,t){let n,i,s,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,i=e.length;n<i;++n)if(s=e[n],o=t[n],s.datasetIndex!==o.datasetIndex||s.index!==o.index)return!1;return!0}function Pn(e){if(H(e))return e.map(Pn);if(L(e)){const t=Object.create(null),n=Object.keys(e),i=n.length;let s=0;for(;s<i;++s)t[n[s]]=Pn(e[n[s]]);return t}return e}function qr(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function cf(e,t,n,i){if(!qr(e))return;const s=t[e],o=n[e];L(s)&&L(o)?Ue(s,o,i):t[e]=Pn(o)}function Ue(e,t,n){const i=H(t)?t:[t],s=i.length;if(!L(e))return e;n=n||{};const o=n.merger||cf;let r;for(let a=0;a<s;++a){if(r=i[a],!L(r))continue;const c=Object.keys(r);for(let l=0,u=c.length;l<u;++l)o(c[l],e,r,n)}return e}function Be(e,t){return Ue(e,t,{merger:lf})}function lf(e,t,n){if(!qr(e))return;const i=t[e],s=n[e];L(i)&&L(s)?Be(i,s):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Pn(s))}const As={"":e=>e,x:e=>e.x,y:e=>e.y};function uf(e){const t=e.split("."),n=[];let i="";for(const s of t)i+=s,i.endsWith("\\")?i=i.slice(0,-1)+".":(n.push(i),i="");return n}function hf(e){const t=uf(e);return n=>{for(const i of t){if(i==="")break;n=n&&n[i]}return n}}function Wt(e,t){return(As[t]||(As[t]=hf(t)))(e)}function ji(e){return e.charAt(0).toUpperCase()+e.slice(1)}const qe=e=>typeof e<"u",Ht=e=>typeof e=="function",Ds=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function df(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const F=Math.PI,Z=2*F,ff=Z+F,On=Number.POSITIVE_INFINITY,pf=F/180,Q=F/2,Qt=F/4,Rs=F*2/3,Ft=Math.log10,Mt=Math.sign;function je(e,t,n){return Math.abs(e-t)<n}function Ls(e){const t=Math.round(e);e=je(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Ft(e))),i=e/n;return(i<=1?1:i<=2?2:i<=5?5:10)*n}function gf(e){const t=[],n=Math.sqrt(e);let i;for(i=1;i<n;i++)e%i===0&&(t.push(i),t.push(e/i));return n===(n|0)&&t.push(n),t.sort((s,o)=>s-o).pop(),t}function mf(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function we(e){return!mf(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function bf(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function Yr(e,t,n){let i,s,o;for(i=0,s=e.length;i<s;i++)o=e[i][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function xt(e){return e*(F/180)}function Vi(e){return e*(180/F)}function $s(e){if(!X(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function Xr(e,t){const n=t.x-e.x,i=t.y-e.y,s=Math.sqrt(n*n+i*i);let o=Math.atan2(i,n);return o<-.5*F&&(o+=Z),{angle:o,distance:s}}function vi(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function yf(e,t){return(e-t+ff)%Z-F}function ct(e){return(e%Z+Z)%Z}function Ye(e,t,n,i){const s=ct(e),o=ct(t),r=ct(n),a=ct(o-s),c=ct(r-s),l=ct(s-o),u=ct(s-r);return s===o||s===r||i&&o===r||a>c&&l<u}function ot(e,t,n){return Math.max(t,Math.min(n,e))}function _f(e){return ot(e,-32768,32767)}function Et(e,t,n,i=1e-6){return e>=Math.min(t,n)-i&&e<=Math.max(t,n)+i}function Zi(e,t,n){n=n||(r=>e[r]<t);let i=e.length-1,s=0,o;for(;i-s>1;)o=s+i>>1,n(o)?s=o:i=o;return{lo:s,hi:i}}const zt=(e,t,n,i)=>Zi(e,n,i?s=>{const o=e[s][t];return o<n||o===n&&e[s+1][t]===n}:s=>e[s][t]<n),xf=(e,t,n)=>Zi(e,n,i=>e[i][t]>=n);function vf(e,t,n){let i=0,s=e.length;for(;i<s&&e[i]<t;)i++;for(;s>i&&e[s-1]>n;)s--;return i>0||s<e.length?e.slice(i,s):e}const Jr=["push","pop","shift","splice","unshift"];function wf(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Jr.forEach(n=>{const i="_onData"+ji(n),s=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const r=s.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[i]=="function"&&a[i](...o)}),r}})})}function Fs(e,t){const n=e._chartjs;if(!n)return;const i=n.listeners,s=i.indexOf(t);s!==-1&&i.splice(s,1),!(i.length>0)&&(Jr.forEach(o=>{delete e[o]}),delete e._chartjs)}function Kr(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const Gr=(function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame})();function Qr(e,t){let n=[],i=!1;return function(...s){n=s,i||(i=!0,Gr.call(window,()=>{i=!1,e.apply(t,n)}))}}function kf(e,t){let n;return function(...i){return t?(clearTimeout(n),n=setTimeout(e,t,i)):e.apply(this,i),t}}const Wi=e=>e==="start"?"left":e==="end"?"right":"center",at=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,Sf=(e,t,n,i)=>e===(i?"left":"right")?n:e==="center"?(t+n)/2:t;function ta(e,t,n){const i=t.length;let s=0,o=i;if(e._sorted){const{iScale:r,vScale:a,_parsed:c}=e,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=r.axis,{min:h,max:d,minDefined:f,maxDefined:p}=r.getUserBounds();if(f){if(s=Math.min(zt(c,u,h).lo,n?i:zt(t,u,r.getPixelForValue(h)).lo),l){const g=c.slice(0,s+1).reverse().findIndex(m=>!R(m[a.axis]));s-=Math.max(0,g)}s=ot(s,0,i-1)}if(p){let g=Math.max(zt(c,r.axis,d,!0).hi+1,n?0:zt(t,u,r.getPixelForValue(d),!0).hi+1);if(l){const m=c.slice(g-1).findIndex(b=>!R(b[a.axis]));g+=Math.max(0,m)}o=ot(g,s,i)-s}else o=i-s}return{start:s,count:o}}function ea(e){const{xScale:t,yScale:n,_scaleRanges:i}=e,s={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!i)return e._scaleRanges=s,!0;const o=i.xmin!==t.min||i.xmax!==t.max||i.ymin!==n.min||i.ymax!==n.max;return Object.assign(i,s),o}const hn=e=>e===0||e===1,Ns=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*Z/n)),Bs=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*Z/n)+1,Ve={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*Q)+1,easeOutSine:e=>Math.sin(e*Q),easeInOutSine:e=>-.5*(Math.cos(F*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>hn(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>hn(e)?e:Ns(e,.075,.3),easeOutElastic:e=>hn(e)?e:Bs(e,.075,.3),easeInOutElastic(e){return hn(e)?e:e<.5?.5*Ns(e*2,.1125,.45):.5+.5*Bs(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-Ve.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?Ve.easeInBounce(e*2)*.5:Ve.easeOutBounce(e*2-1)*.5+.5};function Hi(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function js(e){return Hi(e)?e:new He(e)}function Gn(e){return Hi(e)?e:new He(e).saturate(.5).darken(.1).hexString()}const Mf=["x","y","borderWidth","radius","tension"],Tf=["color","borderColor","backgroundColor"];function Cf(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:Tf},numbers:{type:"number",properties:Mf}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function Pf(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const Vs=new Map;function Of(e,t){t=t||{};const n=e+JSON.stringify(t);let i=Vs.get(n);return i||(i=new Intl.NumberFormat(e,t),Vs.set(n,i)),i}function Qe(e,t,n){return Of(t,n).format(e)}const na={values(e){return H(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const i=this.chart.options.locale;let s,o=e;if(n.length>1){const l=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(l<1e-4||l>1e15)&&(s="scientific"),o=Ef(e,n)}const r=Ft(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),c={notation:s,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(c,this.options.ticks.format),Qe(e,i,c)},logarithmic(e,t,n){if(e===0)return"0";const i=n[t].significand||e/Math.pow(10,Math.floor(Ft(e)));return[1,2,3,5,10,15].includes(i)||t>.8*n.length?na.numeric.call(this,e,t,n):""}};function Ef(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Bn={formatters:na};function zf(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Bn.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const ae=Object.create(null),wi=Object.create(null);function Ze(e,t){if(!t)return e;const n=t.split(".");for(let i=0,s=n.length;i<s;++i){const o=n[i];e=e[o]||(e[o]=Object.create(null))}return e}function Qn(e,t,n){return typeof t=="string"?Ue(Ze(e,t),n):Ue(Ze(e,""),t)}class If{constructor(t,n){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=i=>i.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(i,s)=>Gn(s.backgroundColor),this.hoverBorderColor=(i,s)=>Gn(s.borderColor),this.hoverColor=(i,s)=>Gn(s.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(n)}set(t,n){return Qn(this,t,n)}get(t){return Ze(this,t)}describe(t,n){return Qn(wi,t,n)}override(t,n){return Qn(ae,t,n)}route(t,n,i,s){const o=Ze(this,t),r=Ze(this,i),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const c=this[a],l=r[s];return L(c)?Object.assign({},l,c):z(c,l)},set(c){this[a]=c}}})}apply(t){t.forEach(n=>n(this))}}var U=new If({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[Cf,Pf,zf]);function Af(e){return!e||R(e.size)||R(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function En(e,t,n,i,s){let o=t[s];return o||(o=t[s]=e.measureText(s).width,n.push(s)),o>i&&(i=o),i}function Df(e,t,n,i){i=i||{};let s=i.data=i.data||{},o=i.garbageCollect=i.garbageCollect||[];i.font!==t&&(s=i.data={},o=i.garbageCollect=[],i.font=t),e.save(),e.font=t;let r=0;const a=n.length;let c,l,u,h,d;for(c=0;c<a;c++)if(h=n[c],h!=null&&!H(h))r=En(e,s,o,r,h);else if(H(h))for(l=0,u=h.length;l<u;l++)d=h[l],d!=null&&!H(d)&&(r=En(e,s,o,r,d));e.restore();const f=o.length/2;if(f>n.length){for(c=0;c<f;c++)delete s[o[c]];o.splice(0,f)}return r}function te(e,t,n){const i=e.currentDevicePixelRatio,s=n!==0?Math.max(n/2,.5):0;return Math.round((t-s)*i)/i+s}function Zs(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function ki(e,t,n,i){ia(e,t,n,i,null)}function ia(e,t,n,i,s){let o,r,a,c,l,u,h,d;const f=t.pointStyle,p=t.rotation,g=t.radius;let m=(p||0)*pf;if(f&&typeof f=="object"&&(o=f.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,i),e.rotate(m),e.drawImage(f,-f.width/2,-f.height/2,f.width,f.height),e.restore();return}if(!(isNaN(g)||g<=0)){switch(e.beginPath(),f){default:s?e.ellipse(n,i,s/2,g,0,0,Z):e.arc(n,i,g,0,Z),e.closePath();break;case"triangle":u=s?s/2:g,e.moveTo(n+Math.sin(m)*u,i-Math.cos(m)*g),m+=Rs,e.lineTo(n+Math.sin(m)*u,i-Math.cos(m)*g),m+=Rs,e.lineTo(n+Math.sin(m)*u,i-Math.cos(m)*g),e.closePath();break;case"rectRounded":l=g*.516,c=g-l,r=Math.cos(m+Qt)*c,h=Math.cos(m+Qt)*(s?s/2-l:c),a=Math.sin(m+Qt)*c,d=Math.sin(m+Qt)*(s?s/2-l:c),e.arc(n-h,i-a,l,m-F,m-Q),e.arc(n+d,i-r,l,m-Q,m),e.arc(n+h,i+a,l,m,m+Q),e.arc(n-d,i+r,l,m+Q,m+F),e.closePath();break;case"rect":if(!p){c=Math.SQRT1_2*g,u=s?s/2:c,e.rect(n-u,i-c,2*u,2*c);break}m+=Qt;case"rectRot":h=Math.cos(m)*(s?s/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(s?s/2:g),e.moveTo(n-h,i-a),e.lineTo(n+d,i-r),e.lineTo(n+h,i+a),e.lineTo(n-d,i+r),e.closePath();break;case"crossRot":m+=Qt;case"cross":h=Math.cos(m)*(s?s/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(s?s/2:g),e.moveTo(n-h,i-a),e.lineTo(n+h,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r);break;case"star":h=Math.cos(m)*(s?s/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(s?s/2:g),e.moveTo(n-h,i-a),e.lineTo(n+h,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r),m+=Qt,h=Math.cos(m)*(s?s/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(s?s/2:g),e.moveTo(n-h,i-a),e.lineTo(n+h,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r);break;case"line":r=s?s/2:Math.cos(m)*g,a=Math.sin(m)*g,e.moveTo(n-r,i-a),e.lineTo(n+r,i+a);break;case"dash":e.moveTo(n,i),e.lineTo(n+Math.cos(m)*(s?s/2:g),i+Math.sin(m)*g);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function It(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function jn(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function Vn(e){e.restore()}function Rf(e,t,n,i,s){if(!t)return e.lineTo(n.x,n.y);if(s==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else s==="after"!=!!i?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function Lf(e,t,n,i){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(i?t.cp1x:t.cp2x,i?t.cp1y:t.cp2y,i?n.cp2x:n.cp1x,i?n.cp2y:n.cp1y,n.x,n.y)}function $f(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),R(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function Ff(e,t,n,i,s){if(s.strikethrough||s.underline){const o=e.measureText(i),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,c=n-o.actualBoundingBoxAscent,l=n+o.actualBoundingBoxDescent,u=s.strikethrough?(c+l)/2:l;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=s.decorationWidth||2,e.moveTo(r,u),e.lineTo(a,u),e.stroke()}}function Nf(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function ce(e,t,n,i,s,o={}){const r=H(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let c,l;for(e.save(),e.font=s.string,$f(e,o),c=0;c<r.length;++c)l=r[c],o.backdrop&&Nf(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),R(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(l,n,i,o.maxWidth)),e.fillText(l,n,i,o.maxWidth),Ff(e,n,i,l,o),i+=Number(s.lineHeight);e.restore()}function Xe(e,t){const{x:n,y:i,w:s,h:o,radius:r}=t;e.arc(n+r.topLeft,i+r.topLeft,r.topLeft,1.5*F,F,!0),e.lineTo(n,i+o-r.bottomLeft),e.arc(n+r.bottomLeft,i+o-r.bottomLeft,r.bottomLeft,F,Q,!0),e.lineTo(n+s-r.bottomRight,i+o),e.arc(n+s-r.bottomRight,i+o-r.bottomRight,r.bottomRight,Q,0,!0),e.lineTo(n+s,i+r.topRight),e.arc(n+s-r.topRight,i+r.topRight,r.topRight,0,-Q,!0),e.lineTo(n+r.topLeft,i)}const Bf=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,jf=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Vf(e,t){const n=(""+e).match(Bf);if(!n||n[1]==="normal")return t*1.2;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100;break}return t*e}const Zf=e=>+e||0;function Ui(e,t){const n={},i=L(t),s=i?Object.keys(t):t,o=L(e)?i?r=>z(e[r],e[t[r]]):r=>e[r]:()=>e;for(const r of s)n[r]=Zf(o(r));return n}function sa(e){return Ui(e,{top:"y",right:"x",bottom:"y",left:"x"})}function oe(e){return Ui(e,["topLeft","topRight","bottomLeft","bottomRight"])}function ut(e){const t=sa(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function st(e,t){e=e||{},t=t||U.font;let n=z(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let i=z(e.style,t.style);i&&!(""+i).match(jf)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:z(e.family,t.family),lineHeight:Vf(z(e.lineHeight,t.lineHeight),n),size:n,style:i,weight:z(e.weight,t.weight),string:""};return s.string=Af(s),s}function $e(e,t,n,i){let s,o,r;for(s=0,o=e.length;s<o;++s)if(r=e[s],r!==void 0&&r!==void 0)return r}function Wf(e,t,n){const{min:i,max:s}=e,o=Ur(t,(s-i)/2),r=(a,c)=>n&&a===0?0:a+c;return{min:r(i,-Math.abs(o)),max:r(s,o)}}function Yt(e,t){return Object.assign(Object.create(e),t)}function qi(e,t=[""],n,i,s=()=>e[0]){const o=n||e;typeof i>"u"&&(i=ca("_fallback",e));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:i,_getTarget:s,override:a=>qi([a,...e],t,o,i)};return new Proxy(r,{deleteProperty(a,c){return delete a[c],delete a._keys,delete e[0][c],!0},get(a,c){return ra(a,c,()=>Gf(c,t,e,a))},getOwnPropertyDescriptor(a,c){return Reflect.getOwnPropertyDescriptor(a._scopes[0],c)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,c){return Hs(a).includes(c)},ownKeys(a){return Hs(a)},set(a,c,l){const u=a._storage||(a._storage=s());return a[c]=u[c]=l,delete a._keys,!0}})}function ke(e,t,n,i){const s={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:oa(e,i),setContext:o=>ke(e,o,n,i),override:o=>ke(e.override(o),t,n,i)};return new Proxy(s,{deleteProperty(o,r){return delete o[r],delete e[r],!0},get(o,r,a){return ra(o,r,()=>Uf(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(e,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,r)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(o,r){return Reflect.has(e,r)},ownKeys(){return Reflect.ownKeys(e)},set(o,r,a){return e[r]=a,delete o[r],!0}})}function oa(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:i=t.indexable,_allKeys:s=t.allKeys}=e;return{allKeys:s,scriptable:n,indexable:i,isScriptable:Ht(n)?n:()=>n,isIndexable:Ht(i)?i:()=>i}}const Hf=(e,t)=>e?e+ji(t):t,Yi=(e,t)=>L(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function ra(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const i=n();return e[t]=i,i}function Uf(e,t,n){const{_proxy:i,_context:s,_subProxy:o,_descriptors:r}=e;let a=i[t];return Ht(a)&&r.isScriptable(t)&&(a=qf(t,a,e,n)),H(a)&&a.length&&(a=Yf(t,a,e,r.isIndexable)),Yi(t,a)&&(a=ke(a,s,o&&o[t],r)),a}function qf(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_stack:a}=n;if(a.has(e))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+e);a.add(e);let c=t(o,r||i);return a.delete(e),Yi(e,c)&&(c=Xi(s._scopes,s,e,c)),c}function Yf(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_descriptors:a}=n;if(typeof o.index<"u"&&i(e))return t[o.index%t.length];if(L(t[0])){const c=t,l=s._scopes.filter(u=>u!==c);t=[];for(const u of c){const h=Xi(l,s,e,u);t.push(ke(h,o,r&&r[e],a))}}return t}function aa(e,t,n){return Ht(e)?e(t,n):e}const Xf=(e,t)=>e===!0?t:typeof e=="string"?Wt(t,e):void 0;function Jf(e,t,n,i,s){for(const o of t){const r=Xf(n,o);if(r){e.add(r);const a=aa(r._fallback,n,s);if(typeof a<"u"&&a!==n&&a!==i)return a}else if(r===!1&&typeof i<"u"&&n!==i)return null}return!1}function Xi(e,t,n,i){const s=t._rootScopes,o=aa(t._fallback,n,i),r=[...e,...s],a=new Set;a.add(i);let c=Ws(a,r,n,o||n,i);return c===null||typeof o<"u"&&o!==n&&(c=Ws(a,r,o,c,i),c===null)?!1:qi(Array.from(a),[""],s,o,()=>Kf(t,n,i))}function Ws(e,t,n,i,s){for(;n;)n=Jf(e,t,n,i,s);return n}function Kf(e,t,n){const i=e._getTarget();t in i||(i[t]={});const s=i[t];return H(s)&&L(n)?n:s||{}}function Gf(e,t,n,i){let s;for(const o of t)if(s=ca(Hf(o,e),n),typeof s<"u")return Yi(e,s)?Xi(n,i,e,s):s}function ca(e,t){for(const n of t){if(!n)continue;const i=n[e];if(typeof i<"u")return i}}function Hs(e){let t=e._keys;return t||(t=e._keys=Qf(e._scopes)),t}function Qf(e){const t=new Set;for(const n of e)for(const i of Object.keys(n).filter(s=>!s.startsWith("_")))t.add(i);return Array.from(t)}function la(e,t,n,i){const{iScale:s}=e,{key:o="r"}=this._parsing,r=new Array(i);let a,c,l,u;for(a=0,c=i;a<c;++a)l=a+n,u=t[l],r[a]={r:s.parse(Wt(u,o),l)};return r}const tp=Number.EPSILON||1e-14,Se=(e,t)=>t<e.length&&!e[t].skip&&e[t],ua=e=>e==="x"?"y":"x";function ep(e,t,n,i){const s=e.skip?t:e,o=t,r=n.skip?t:n,a=vi(o,s),c=vi(r,o);let l=a/(a+c),u=c/(a+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;const h=i*l,d=i*u;return{previous:{x:o.x-h*(r.x-s.x),y:o.y-h*(r.y-s.y)},next:{x:o.x+d*(r.x-s.x),y:o.y+d*(r.y-s.y)}}}function np(e,t,n){const i=e.length;let s,o,r,a,c,l=Se(e,0);for(let u=0;u<i-1;++u)if(c=l,l=Se(e,u+1),!(!c||!l)){if(je(t[u],0,tp)){n[u]=n[u+1]=0;continue}s=n[u]/t[u],o=n[u+1]/t[u],a=Math.pow(s,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),n[u]=s*r*t[u],n[u+1]=o*r*t[u])}}function ip(e,t,n="x"){const i=ua(n),s=e.length;let o,r,a,c=Se(e,0);for(let l=0;l<s;++l){if(r=a,a=c,c=Se(e,l+1),!a)continue;const u=a[n],h=a[i];r&&(o=(u-r[n])/3,a[`cp1${n}`]=u-o,a[`cp1${i}`]=h-o*t[l]),c&&(o=(c[n]-u)/3,a[`cp2${n}`]=u+o,a[`cp2${i}`]=h+o*t[l])}}function sp(e,t="x"){const n=ua(t),i=e.length,s=Array(i).fill(0),o=Array(i);let r,a,c,l=Se(e,0);for(r=0;r<i;++r)if(a=c,c=l,l=Se(e,r+1),!!c){if(l){const u=l[t]-c[t];s[r]=u!==0?(l[n]-c[n])/u:0}o[r]=a?l?Mt(s[r-1])!==Mt(s[r])?0:(s[r-1]+s[r])/2:s[r-1]:s[r]}np(e,s,o),ip(e,o,t)}function dn(e,t,n){return Math.max(Math.min(e,n),t)}function op(e,t){let n,i,s,o,r,a=It(e[0],t);for(n=0,i=e.length;n<i;++n)r=o,o=a,a=n<i-1&&It(e[n+1],t),o&&(s=e[n],r&&(s.cp1x=dn(s.cp1x,t.left,t.right),s.cp1y=dn(s.cp1y,t.top,t.bottom)),a&&(s.cp2x=dn(s.cp2x,t.left,t.right),s.cp2y=dn(s.cp2y,t.top,t.bottom)))}function rp(e,t,n,i,s){let o,r,a,c;if(t.spanGaps&&(e=e.filter(l=>!l.skip)),t.cubicInterpolationMode==="monotone")sp(e,s);else{let l=i?e[e.length-1]:e[0];for(o=0,r=e.length;o<r;++o)a=e[o],c=ep(l,a,e[Math.min(o+1,r-(i?0:1))%r],t.tension),a.cp1x=c.previous.x,a.cp1y=c.previous.y,a.cp2x=c.next.x,a.cp2y=c.next.y,l=a}t.capBezierPoints&&op(e,n)}function Ji(){return typeof window<"u"&&typeof document<"u"}function Ki(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function zn(e,t,n){let i;return typeof e=="string"?(i=parseInt(e,10),e.indexOf("%")!==-1&&(i=i/100*t.parentNode[n])):i=e,i}const Zn=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function ap(e,t){return Zn(e).getPropertyValue(t)}const cp=["top","right","bottom","left"];function re(e,t,n){const i={};n=n?"-"+n:"";for(let s=0;s<4;s++){const o=cp[s];i[o]=parseFloat(e[t+"-"+o+n])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const lp=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function up(e,t){const n=e.touches,i=n&&n.length?n[0]:e,{offsetX:s,offsetY:o}=i;let r=!1,a,c;if(lp(s,o,e.target))a=s,c=o;else{const l=t.getBoundingClientRect();a=i.clientX-l.left,c=i.clientY-l.top,r=!0}return{x:a,y:c,box:r}}function ie(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:i}=t,s=Zn(n),o=s.boxSizing==="border-box",r=re(s,"padding"),a=re(s,"border","width"),{x:c,y:l,box:u}=up(e,n),h=r.left+(u&&a.left),d=r.top+(u&&a.top);let{width:f,height:p}=t;return o&&(f-=r.width+a.width,p-=r.height+a.height),{x:Math.round((c-h)/f*n.width/i),y:Math.round((l-d)/p*n.height/i)}}function hp(e,t,n){let i,s;if(t===void 0||n===void 0){const o=e&&Ki(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const r=o.getBoundingClientRect(),a=Zn(o),c=re(a,"border","width"),l=re(a,"padding");t=r.width-l.width-c.width,n=r.height-l.height-c.height,i=zn(a.maxWidth,o,"clientWidth"),s=zn(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:i||On,maxHeight:s||On}}const Nt=e=>Math.round(e*10)/10;function dp(e,t,n,i){const s=Zn(e),o=re(s,"margin"),r=zn(s.maxWidth,e,"clientWidth")||On,a=zn(s.maxHeight,e,"clientHeight")||On,c=hp(e,t,n);let{width:l,height:u}=c;if(s.boxSizing==="content-box"){const d=re(s,"border","width"),f=re(s,"padding");l-=f.width+d.width,u-=f.height+d.height}return l=Math.max(0,l-o.width),u=Math.max(0,i?l/i:u-o.height),l=Nt(Math.min(l,r,c.maxWidth)),u=Nt(Math.min(u,a,c.maxHeight)),l&&!u&&(u=Nt(l/2)),(t!==void 0||n!==void 0)&&i&&c.height&&u>c.height&&(u=c.height,l=Nt(Math.floor(u*i))),{width:l,height:u}}function Us(e,t,n){const i=t||1,s=Nt(e.height*i),o=Nt(e.width*i);e.height=Nt(e.height),e.width=Nt(e.width);const r=e.canvas;return r.style&&(n||!r.style.height&&!r.style.width)&&(r.style.height=`${e.height}px`,r.style.width=`${e.width}px`),e.currentDevicePixelRatio!==i||r.height!==s||r.width!==o?(e.currentDevicePixelRatio=i,r.height=s,r.width=o,e.ctx.setTransform(i,0,0,i,0,0),!0):!1}const fp=(function(){let e=!1;try{const t={get passive(){return e=!0,!1}};Ji()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e})();function qs(e,t){const n=ap(e,t),i=n&&n.match(/^(\d+)(\.\d+)?px$/);return i?+i[1]:void 0}function se(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function pp(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:i==="middle"?n<.5?e.y:t.y:i==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function gp(e,t,n,i){const s={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},r=se(e,s,n),a=se(s,o,n),c=se(o,t,n),l=se(r,a,n),u=se(a,c,n);return se(l,u,n)}const mp=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,i){return n-i},leftForLtr(n,i){return n-i}}},bp=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function xe(e,t,n){return e?mp(t,n):bp()}function ha(e,t){let n,i;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,i=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=i)}function da(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function fa(e){return e==="angle"?{between:Ye,compare:yf,normalize:ct}:{between:Et,compare:(t,n)=>t-n,normalize:t=>t}}function Ys({start:e,end:t,count:n,loop:i,style:s}){return{start:e%n,end:t%n,loop:i&&(t-e+1)%n===0,style:s}}function yp(e,t,n){const{property:i,start:s,end:o}=n,{between:r,normalize:a}=fa(i),c=t.length;let{start:l,end:u,loop:h}=e,d,f;if(h){for(l+=c,u+=c,d=0,f=c;d<f&&r(a(t[l%c][i]),s,o);++d)l--,u--;l%=c,u%=c}return u<l&&(u+=c),{start:l,end:u,loop:h,style:e.style}}function pa(e,t,n){if(!n)return[e];const{property:i,start:s,end:o}=n,r=t.length,{compare:a,between:c,normalize:l}=fa(i),{start:u,end:h,loop:d,style:f}=yp(e,t,n),p=[];let g=!1,m=null,b,y,w;const x=()=>c(s,w,b)&&a(s,w)!==0,_=()=>a(o,b)===0||c(o,w,b),k=()=>g||x(),S=()=>!g||_();for(let M=u,C=u;M<=h;++M)y=t[M%r],!y.skip&&(b=l(y[i]),b!==w&&(g=c(b,s,o),m===null&&k()&&(m=a(b,s)===0?M:C),m!==null&&S()&&(p.push(Ys({start:m,end:M,loop:d,count:r,style:f})),m=null),C=M,w=b));return m!==null&&p.push(Ys({start:m,end:h,loop:d,count:r,style:f})),p}function ga(e,t){const n=[],i=e.segments;for(let s=0;s<i.length;s++){const o=pa(i[s],e.points,t);o.length&&n.push(...o)}return n}function _p(e,t,n,i){let s=0,o=t-1;if(n&&!i)for(;s<t&&!e[s].skip;)s++;for(;s<t&&e[s].skip;)s++;for(s%=t,n&&(o+=s);o>s&&e[o%t].skip;)o--;return o%=t,{start:s,end:o}}function xp(e,t,n,i){const s=e.length,o=[];let r=t,a=e[t],c;for(c=t+1;c<=n;++c){const l=e[c%s];l.skip||l.stop?a.skip||(i=!1,o.push({start:t%s,end:(c-1)%s,loop:i}),t=r=l.stop?c:null):(r=c,a.skip&&(t=c)),a=l}return r!==null&&o.push({start:t%s,end:r%s,loop:i}),o}function vp(e,t){const n=e.points,i=e.options.spanGaps,s=n.length;if(!s)return[];const o=!!e._loop,{start:r,end:a}=_p(n,s,o,i);if(i===!0)return Xs(e,[{start:r,end:a,loop:o}],n,t);const c=a<r?a+s:a,l=!!e._fullLoop&&r===0&&a===s-1;return Xs(e,xp(n,r,c,l),n,t)}function Xs(e,t,n,i){return!i||!i.setContext||!n?t:wp(e,t,n,i)}function wp(e,t,n,i){const s=e._chart.getContext(),o=Js(e.options),{_datasetIndex:r,options:{spanGaps:a}}=e,c=n.length,l=[];let u=o,h=t[0].start,d=h;function f(p,g,m,b){const y=a?-1:1;if(p!==g){for(p+=c;n[p%c].skip;)p-=y;for(;n[g%c].skip;)g+=y;p%c!==g%c&&(l.push({start:p%c,end:g%c,loop:m,style:b}),u=b,h=g%c)}}for(const p of t){h=a?h:p.start;let g=n[h%c],m;for(d=h+1;d<=p.end;d++){const b=n[d%c];m=Js(i.setContext(Yt(s,{type:"segment",p0:g,p1:b,p0DataIndex:(d-1)%c,p1DataIndex:d%c,datasetIndex:r}))),kp(m,u)&&f(h,d-1,p.loop,u),g=b,u=m}h<d-1&&f(h,d-1,p.loop,u)}return l}function Js(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function kp(e,t){if(!t)return!1;const n=[],i=function(s,o){return Hi(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,i)!==JSON.stringify(t,i)}function fn(e,t,n){return e.options.clip?e[n]:t[n]}function Sp(e,t){const{xScale:n,yScale:i}=e;return n&&i?{left:fn(n,t,"left"),right:fn(n,t,"right"),top:fn(i,t,"top"),bottom:fn(i,t,"bottom")}:t}function ma(e,t){const n=t._clip;if(n.disabled)return!1;const i=Sp(t,e.chartArea);return{left:n.left===!1?0:i.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:i.right+(n.right===!0?0:n.right),top:n.top===!1?0:i.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:i.bottom+(n.bottom===!0?0:n.bottom)}}class Mp{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,i,s){const o=n.listeners[s],r=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:r,currentStep:Math.min(i-n.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Gr.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,c;for(;r>=0;--r)c=o[r],c._active?(c._total>i.duration&&(i.duration=c._total),c.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let i=n.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,i)),i}listen(t,n,i){this._getAnims(t).listeners[n].push(i)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((i,s)=>Math.max(i,s._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const i=n.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Ct=new Mp;const Ks="transparent",Tp={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const i=js(e||Ks),s=i.valid&&js(t||Ks);return s&&s.valid?s.mix(i,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class Cp{constructor(t,n,i,s){const o=n[i];s=$e([t.to,s,o,t.from]);const r=$e([t.from,o,s]);this._active=!0,this._fn=t.fn||Tp[t.type||typeof r],this._easing=Ve[t.easing]||Ve.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=i,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,n,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=$e([t.to,n,s,t.from]),this._from=$e([t.from,s,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,i=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let c;if(this._active=o!==a&&(r||n<i),!this._active){this._target[s]=a,this._notify(!0);return}if(n<0){this._target[s]=o;return}c=n/i%2,c=r&&c>1?2-c:c,c=this._easing(Math.min(1,Math.max(0,c))),this._target[s]=this._fn(o,a,c)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,i)=>{t.push({res:n,rej:i})})}_notify(t){const n=t?"res":"rej",i=this._promises||[];for(let s=0;s<i.length;s++)i[s][n]()}}class ba{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!L(t))return;const n=Object.keys(U.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach(s=>{const o=t[s];if(!L(o))return;const r={};for(const a of n)r[a]=o[a];(H(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,n){const i=n.options,s=Op(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&Pp(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,n){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(n),a=Date.now();let c;for(c=r.length-1;c>=0;--c){const l=r[c];if(l.charAt(0)==="$")continue;if(l==="options"){s.push(...this._animateOptions(t,n));continue}const u=n[l];let h=o[l];const d=i.get(l);if(h)if(d&&h.active()){h.update(d,u,a);continue}else h.cancel();if(!d||!d.duration){t[l]=u;continue}o[l]=h=new Cp(d,t,l,u),s.push(h)}return s}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const i=this._createAnimations(t,n);if(i.length)return Ct.add(this._chart,i),!0}}function Pp(e,t){const n=[],i=Object.keys(t);for(let s=0;s<i.length;s++){const o=e[i[s]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function Op(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function Gs(e,t){const n=e&&e.options||{},i=n.reverse,s=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:i?o:s,end:i?s:o}}function Ep(e,t,n){if(n===!1)return!1;const i=Gs(e,n),s=Gs(t,n);return{top:s.end,right:i.end,bottom:s.start,left:i.start}}function zp(e){let t,n,i,s;return L(e)?(t=e.top,n=e.right,i=e.bottom,s=e.left):t=n=i=s=e,{top:t,right:n,bottom:i,left:s,disabled:e===!1}}function ya(e,t){const n=[],i=e._getSortedDatasetMetas(t);let s,o;for(s=0,o=i.length;s<o;++s)n.push(i[s].index);return n}function Qs(e,t,n,i={}){const s=e.keys,o=i.mode==="single";let r,a,c,l;if(t===null)return;let u=!1;for(r=0,a=s.length;r<a;++r){if(c=+s[r],c===n){if(u=!0,i.all)continue;break}l=e.values[c],X(l)&&(o||t===0||Mt(t)===Mt(l))&&(t+=l)}return!u&&!i.all?0:t}function Ip(e,t){const{iScale:n,vScale:i}=t,s=n.axis==="x"?"x":"y",o=i.axis==="x"?"x":"y",r=Object.keys(e),a=new Array(r.length);let c,l,u;for(c=0,l=r.length;c<l;++c)u=r[c],a[c]={[s]:u,[o]:e[u]};return a}function ti(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function Ap(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function Dp(e){const{min:t,max:n,minDefined:i,maxDefined:s}=e.getUserBounds();return{min:i?t:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}function Rp(e,t,n){const i=e[t]||(e[t]={});return i[n]||(i[n]={})}function to(e,t,n,i){for(const s of t.getMatchingVisibleMetas(i).reverse()){const o=e[s.index];if(n&&o>0||!n&&o<0)return s.index}return null}function eo(e,t){const{chart:n,_cachedMeta:i}=e,s=n._stacks||(n._stacks={}),{iScale:o,vScale:r,index:a}=i,c=o.axis,l=r.axis,u=Ap(o,r,i),h=t.length;let d;for(let f=0;f<h;++f){const p=t[f],{[c]:g,[l]:m}=p,b=p._stacks||(p._stacks={});d=b[l]=Rp(s,u,g),d[a]=m,d._top=to(d,r,!0,i.type),d._bottom=to(d,r,!1,i.type);const y=d._visualValues||(d._visualValues={});y[a]=m}}function ei(e,t){const n=e.scales;return Object.keys(n).filter(i=>n[i].axis===t).shift()}function Lp(e,t){return Yt(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function $p(e,t,n){return Yt(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Ee(e,t){const n=e.controller.index,i=e.vScale&&e.vScale.axis;if(i){t=t||e._parsed;for(const s of t){const o=s._stacks;if(!o||o[i]===void 0||o[i][n]===void 0)return;delete o[i][n],o[i]._visualValues!==void 0&&o[i]._visualValues[n]!==void 0&&delete o[i]._visualValues[n]}}}const ni=e=>e==="reset"||e==="none",no=(e,t)=>t?e:Object.assign({},e),Fp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:ya(n,!0),values:null};class Xt{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ti(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&Ee(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,i=this.getDataset(),s=(h,d,f,p)=>h==="x"?d:h==="r"?p:f,o=n.xAxisID=z(i.xAxisID,ei(t,"x")),r=n.yAxisID=z(i.yAxisID,ei(t,"y")),a=n.rAxisID=z(i.rAxisID,ei(t,"r")),c=n.indexAxis,l=n.iAxisID=s(c,o,r,a),u=n.vAxisID=s(c,r,o,a);n.xScale=this.getScaleForId(o),n.yScale=this.getScaleForId(r),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(l),n.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&Fs(this._data,this),t._stacked&&Ee(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),i=this._data;if(L(n)){const s=this._cachedMeta;this._data=Ip(n,s)}else if(i!==n){if(i){Fs(i,this);const s=this._cachedMeta;Ee(s),s._parsed=[]}n&&Object.isExtensible(n)&&wf(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const o=n._stacked;n._stacked=ti(n.vScale,n),n.stack!==i.stack&&(s=!0,Ee(n),n.stack=i.stack),this._resyncElements(t),(s||o!==n._stacked)&&(eo(this,n._parsed),n._stacked=ti(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:r}=i,a=o.axis;let c=t===0&&n===s.length?!0:i._sorted,l=t>0&&i._parsed[t-1],u,h,d;if(this._parsing===!1)i._parsed=s,i._sorted=!0,d=s;else{H(s[t])?d=this.parseArrayData(i,s,t,n):L(s[t])?d=this.parseObjectData(i,s,t,n):d=this.parsePrimitiveData(i,s,t,n);const f=()=>h[a]===null||l&&h[a]<l[a];for(u=0;u<n;++u)i._parsed[u+t]=h=d[u],c&&(f()&&(c=!1),l=h);i._sorted=c}r&&eo(this,d)}parsePrimitiveData(t,n,i,s){const{iScale:o,vScale:r}=t,a=o.axis,c=r.axis,l=o.getLabels(),u=o===r,h=new Array(s);let d,f,p;for(d=0,f=s;d<f;++d)p=d+i,h[d]={[a]:u||o.parse(l[p],p),[c]:r.parse(n[p],p)};return h}parseArrayData(t,n,i,s){const{xScale:o,yScale:r}=t,a=new Array(s);let c,l,u,h;for(c=0,l=s;c<l;++c)u=c+i,h=n[u],a[c]={x:o.parse(h[0],u),y:r.parse(h[1],u)};return a}parseObjectData(t,n,i,s){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:c="y"}=this._parsing,l=new Array(s);let u,h,d,f;for(u=0,h=s;u<h;++u)d=u+i,f=n[d],l[u]={x:o.parse(Wt(f,a),d),y:r.parse(Wt(f,c),d)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,i){const s=this.chart,o=this._cachedMeta,r=n[t.axis],a={keys:ya(s,!0),values:n._stacks[t.axis]._visualValues};return Qs(a,r,o.index,{mode:i})}updateRangeFromParsed(t,n,i,s){const o=i[n.axis];let r=o===null?NaN:o;const a=s&&i._stacks[n.axis];s&&a&&(s.values=a,r=Qs(s,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,n){const i=this._cachedMeta,s=i._parsed,o=i._sorted&&t===i.iScale,r=s.length,a=this._getOtherScale(t),c=Fp(n,i,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:h}=Dp(a);let d,f;function p(){f=s[d];const g=f[a.axis];return!X(f[t.axis])||u>g||h<g}for(d=0;d<r&&!(!p()&&(this.updateRangeFromParsed(l,t,f,c),o));++d);if(o){for(d=r-1;d>=0;--d)if(!p()){this.updateRangeFromParsed(l,t,f,c);break}}return l}getAllParsedValues(t){const n=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=n.length;s<o;++s)r=n[s][t.axis],X(r)&&i.push(r);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,i=n.iScale,s=n.vScale,o=this.getParsed(t);return{label:i?""+i.getLabelForValue(o[i.axis]):"",value:s?""+s.getLabelForValue(o[s.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=zp(z(this.options.clip,Ep(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,i=this._cachedMeta,s=i.data||[],o=n.chartArea,r=[],a=this._drawStart||0,c=this._drawCount||s.length-a,l=this.options.drawActiveElementsOnTop;let u;for(i.dataset&&i.dataset.draw(t,o,a,c),u=a;u<a+c;++u){const h=s[u];h.hidden||(h.active&&l?r.push(h):h.draw(t,o))}for(u=0;u<r.length;++u)r[u].draw(t,o)}getStyle(t,n){const i=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,n,i){const s=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=$p(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=s.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=Lp(this.chart.getContext(),this.index)),o.dataset=s,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=i,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",i){const s=n==="active",o=this._cachedDataOpts,r=t+"-"+n,a=o[r],c=this.enableOptionSharing&&qe(i);if(a)return no(a,c);const l=this.chart.config,u=l.datasetElementScopeKeys(this._type,t),h=s?[`${t}Hover`,"hover",t,""]:[t,""],d=l.getOptionScopes(this.getDataset(),u),f=Object.keys(U.elements[t]),p=()=>this.getContext(i,s,n),g=l.resolveNamedOptions(d,f,p,h);return g.$shared&&(g.$shared=c,o[r]=Object.freeze(no(g,c))),g}_resolveAnimations(t,n,i){const s=this.chart,o=this._cachedDataOpts,r=`animation-${n}`,a=o[r];if(a)return a;let c;if(s.options.animation!==!1){const u=this.chart.config,h=u.datasetAnimationScopeKeys(this._type,n),d=u.getOptionScopes(this.getDataset(),h);c=u.createResolver(d,this.getContext(t,i,n))}const l=new ba(s,c&&c.animations);return c&&c._cacheable&&(o[r]=Object.freeze(l)),l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||ni(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const i=this.resolveDataElementOptions(t,n),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(n,o)||o!==s;return this.updateSharedOptions(o,n,i),{sharedOptions:o,includeOptions:r}}updateElement(t,n,i,s){ni(s)?Object.assign(t,i):this._resolveAnimations(n,s).update(t,i)}updateSharedOptions(t,n,i){t&&!ni(n)&&this._resolveAnimations(void 0,n).update(t,i)}_setStyle(t,n,i,s){t.active=s;const o=this.getStyle(n,s);this._resolveAnimations(n,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,n,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,i=this._cachedMeta.data;for(const[a,c,l]of this._syncList)this[a](c,l);this._syncList=[];const s=i.length,o=n.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o<s&&this._removeElements(o,s-o)}_insertElements(t,n,i=!0){const s=this._cachedMeta,o=s.data,r=t+n;let a;const c=l=>{for(l.length+=n,a=l.length-1;a>=r;a--)l[a]=l[a-n]};for(c(o),a=t;a<r;++a)o[a]=new this.dataElementType;this._parsing&&c(s._parsed),this.parse(t,n),i&&this.updateElements(o,t,n,"reset")}updateElements(t,n,i,s){}_removeElements(t,n){const i=this._cachedMeta;if(this._parsing){const s=i._parsed.splice(t,n);i._stacked&&Ee(i,s)}i.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,i,s]=t;this[n](i,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}function Np(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let i=[];for(let s=0,o=n.length;s<o;s++)i=i.concat(n[s].controller.getAllParsedValues(e));e._cache.$bar=Kr(i.sort((s,o)=>s-o))}return e._cache.$bar}function Bp(e){const t=e.iScale,n=Np(t,e.type);let i=t._length,s,o,r,a;const c=()=>{r===32767||r===-32768||(qe(a)&&(i=Math.min(i,Math.abs(r-a)||i)),a=r)};for(s=0,o=n.length;s<o;++s)r=t.getPixelForValue(n[s]),c();for(a=void 0,s=0,o=t.ticks.length;s<o;++s)r=t.getPixelForTick(s),c();return i}function jp(e,t,n,i){const s=n.barThickness;let o,r;return R(s)?(o=t.min*n.categoryPercentage,r=n.barPercentage):(o=s*i,r=1),{chunk:o/i,ratio:r,start:t.pixels[e]-o/2}}function Vp(e,t,n,i){const s=t.pixels,o=s[e];let r=e>0?s[e-1]:null,a=e<s.length-1?s[e+1]:null;const c=n.categoryPercentage;r===null&&(r=o-(a===null?t.end-t.start:a-o)),a===null&&(a=o+o-r);const l=o-(o-Math.min(r,a))/2*c;return{chunk:Math.abs(a-r)/2*c/i,ratio:n.barPercentage,start:l}}function Zp(e,t,n,i){const s=n.parse(e[0],i),o=n.parse(e[1],i),r=Math.min(s,o),a=Math.max(s,o);let c=r,l=a;Math.abs(r)>Math.abs(a)&&(c=a,l=r),t[n.axis]=l,t._custom={barStart:c,barEnd:l,start:s,end:o,min:r,max:a}}function _a(e,t,n,i){return H(e)?Zp(e,t,n,i):t[n.axis]=n.parse(e,i),t}function io(e,t,n,i){const s=e.iScale,o=e.vScale,r=s.getLabels(),a=s===o,c=[];let l,u,h,d;for(l=n,u=n+i;l<u;++l)d=t[l],h={},h[s.axis]=a||s.parse(r[l],l),c.push(_a(d,h,o,l));return c}function ii(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function Wp(e,t,n){return e!==0?Mt(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function Hp(e){let t,n,i,s,o;return e.horizontal?(t=e.base>e.x,n="left",i="right"):(t=e.base<e.y,n="bottom",i="top"),t?(s="end",o="start"):(s="start",o="end"),{start:n,end:i,reverse:t,top:s,bottom:o}}function Up(e,t,n,i){let s=t.borderSkipped;const o={};if(!s){e.borderSkipped=o;return}if(s===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:r,end:a,reverse:c,top:l,bottom:u}=Hp(e);s==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===i?s=l:(n._bottom||0)===i?s=u:(o[so(u,r,a,c)]=!0,s=l)),o[so(s,r,a,c)]=!0,e.borderSkipped=o}function so(e,t,n,i){return i?(e=qp(e,t,n),e=oo(e,n,t)):e=oo(e,t,n),e}function qp(e,t,n){return e===t?n:e===n?t:e}function oo(e,t,n){return e==="start"?t:e==="end"?n:e}function Yp(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class Xp extends Xt{static id="bar";static defaults={datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}};static overrides={scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}};parsePrimitiveData(t,n,i,s){return io(t,n,i,s)}parseArrayData(t,n,i,s){return io(t,n,i,s)}parseObjectData(t,n,i,s){const{iScale:o,vScale:r}=t,{xAxisKey:a="x",yAxisKey:c="y"}=this._parsing,l=o.axis==="x"?a:c,u=r.axis==="x"?a:c,h=[];let d,f,p,g;for(d=i,f=i+s;d<f;++d)g=n[d],p={},p[o.axis]=o.parse(Wt(g,l),d),h.push(_a(Wt(g,u),p,r,d));return h}updateRangeFromParsed(t,n,i,s){super.updateRangeFromParsed(t,n,i,s);const o=i._custom;o&&n===this._cachedMeta.vScale&&(t.min=Math.min(t.min,o.min),t.max=Math.max(t.max,o.max))}getMaxOverflow(){return 0}getLabelAndValue(t){const n=this._cachedMeta,{iScale:i,vScale:s}=n,o=this.getParsed(t),r=o._custom,a=ii(r)?"["+r.start+", "+r.end+"]":""+s.getLabelForValue(o[s.axis]);return{label:""+i.getLabelForValue(o[i.axis]),value:a}}initialize(){this.enableOptionSharing=!0,super.initialize();const t=this._cachedMeta;t.stack=this.getDataset().stack}update(t){const n=this._cachedMeta;this.updateElements(n.data,0,n.data.length,t)}updateElements(t,n,i,s){const o=s==="reset",{index:r,_cachedMeta:{vScale:a}}=this,c=a.getBasePixel(),l=a.isHorizontal(),u=this._getRuler(),{sharedOptions:h,includeOptions:d}=this._getSharedOptions(n,s);for(let f=n;f<n+i;f++){const p=this.getParsed(f),g=o||R(p[a.axis])?{base:c,head:c}:this._calculateBarValuePixels(f),m=this._calculateBarIndexPixels(f,u),b=(p._stacks||{})[a.axis],y={horizontal:l,base:g.base,enableBorderRadius:!b||ii(p._custom)||r===b._top||r===b._bottom,x:l?g.head:m.center,y:l?m.center:g.head,height:l?m.size:Math.abs(g.size),width:l?Math.abs(g.size):m.size};d&&(y.options=h||this.resolveDataElementOptions(f,t[f].active?"active":s));const w=y.options||t[f].options;Up(y,w,b,r),Yp(y,w,u.ratio),this.updateElement(t[f],f,y,s)}}_getStacks(t,n){const{iScale:i}=this._cachedMeta,s=i.getMatchingVisibleMetas(this._type).filter(u=>u.controller.options.grouped),o=i.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(n),c=a&&a[i.axis],l=u=>{const h=u._parsed.find(f=>f[i.axis]===c),d=h&&h[u.vScale.axis];if(R(d)||isNaN(d))return!0};for(const u of s)if(!(n!==void 0&&l(u))&&((o===!1||r.indexOf(u.stack)===-1||o===void 0&&u.stack===void 0)&&r.push(u.stack),u.index===t))break;return r.length||r.push(void 0),r}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales,n=this.chart.options.indexAxis;return Object.keys(t).filter(i=>t[i].axis===n).shift()}_getAxis(){const t={},n=this.getFirstScaleIdForIndexAxis();for(const i of this.chart.data.datasets)t[z(this.chart.options.indexAxis==="x"?i.xAxisID:i.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,i){const s=this._getStacks(t,i),o=n!==void 0?s.indexOf(n):-1;return o===-1?s.length-1:o}_getRuler(){const t=this.options,n=this._cachedMeta,i=n.iScale,s=[];let o,r;for(o=0,r=n.data.length;o<r;++o)s.push(i.getPixelForValue(this.getParsed(o)[i.axis],o));const a=t.barThickness;return{min:a||Bp(n),pixels:s,start:i._startPixel,end:i._endPixel,stackCount:this._getStackCount(),scale:i,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:i,index:s},options:{base:o,minBarLength:r}}=this,a=o||0,c=this.getParsed(t),l=c._custom,u=ii(l);let h=c[n.axis],d=0,f=i?this.applyStack(n,c,i):h,p,g;f!==h&&(d=f-h,f=h),u&&(h=l.barStart,f=l.barEnd-l.barStart,h!==0&&Mt(h)!==Mt(l.barEnd)&&(d=0),d+=h);const m=!R(o)&&!u?o:d;let b=n.getPixelForValue(m);if(this.chart.getDataVisibility(t)?p=n.getPixelForValue(d+f):p=b,g=p-b,Math.abs(g)<r){g=Wp(g,n,a)*r,h===a&&(b-=g/2);const y=n.getPixelForDecimal(0),w=n.getPixelForDecimal(1),x=Math.min(y,w),_=Math.max(y,w);b=Math.max(Math.min(b,_),x),p=b+g,i&&!u&&(c._stacks[n.axis]._visualValues[s]=n.getValueForPixel(p)-n.getValueForPixel(b))}if(b===n.getPixelForValue(a)){const y=Mt(g)*n.getLineWidthForValue(a)/2;b+=y,g-=y}return{size:g,base:b,head:p,center:p+g/2}}_calculateBarIndexPixels(t,n){const i=n.scale,s=this.options,o=s.skipNull,r=z(s.maxBarThickness,1/0);let a,c;const l=this._getAxisCount();if(n.grouped){const u=o?this._getStackCount(t):n.stackCount,h=s.barThickness==="flex"?Vp(t,n,s,u*l):jp(t,n,s,u*l),d=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,f=this._getAxis().indexOf(z(d,this.getFirstScaleIdForIndexAxis())),p=this._getStackIndex(this.index,this._cachedMeta.stack,o?t:void 0)+f;a=h.start+h.chunk*p+h.chunk/2,c=Math.min(r,h.chunk*h.ratio)}else a=i.getPixelForValue(this.getParsed(t)[i.axis],t),c=Math.min(r,n.min*n.ratio);return{base:a-c/2,head:a+c/2,center:a,size:c}}draw(){const t=this._cachedMeta,n=t.vScale,i=t.data,s=i.length;let o=0;for(;o<s;++o)this.getParsed(o)[n.axis]!==null&&!i[o].hidden&&i[o].draw(this._ctx)}}class Jp extends Xt{static id="bubble";static defaults={datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}};static overrides={scales:{x:{type:"linear"},y:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,i,s){const o=super.parsePrimitiveData(t,n,i,s);for(let r=0;r<o.length;r++)o[r]._custom=this.resolveDataElementOptions(r+i).radius;return o}parseArrayData(t,n,i,s){const o=super.parseArrayData(t,n,i,s);for(let r=0;r<o.length;r++){const a=n[i+r];o[r]._custom=z(a[2],this.resolveDataElementOptions(r+i).radius)}return o}parseObjectData(t,n,i,s){const o=super.parseObjectData(t,n,i,s);for(let r=0;r<o.length;r++){const a=n[i+r];o[r]._custom=z(a&&a.r&&+a.r,this.resolveDataElementOptions(r+i).radius)}return o}getMaxOverflow(){const t=this._cachedMeta.data;let n=0;for(let i=t.length-1;i>=0;--i)n=Math.max(n,t[i].size(this.resolveDataElementOptions(i))/2);return n>0&&n}getLabelAndValue(t){const n=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:o}=n,r=this.getParsed(t),a=s.getLabelForValue(r.x),c=o.getLabelForValue(r.y),l=r._custom;return{label:i[t]||"",value:"("+a+", "+c+(l?", "+l:"")+")"}}update(t){const n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,i,s){const o=s==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:c,includeOptions:l}=this._getSharedOptions(n,s),u=r.axis,h=a.axis;for(let d=n;d<n+i;d++){const f=t[d],p=!o&&this.getParsed(d),g={},m=g[u]=o?r.getPixelForDecimal(.5):r.getPixelForValue(p[u]),b=g[h]=o?a.getBasePixel():a.getPixelForValue(p[h]);g.skip=isNaN(m)||isNaN(b),l&&(g.options=c||this.resolveDataElementOptions(d,f.active?"active":s),o&&(g.options.radius=0)),this.updateElement(f,d,g,s)}}resolveDataElementOptions(t,n){const i=this.getParsed(t);let s=super.resolveDataElementOptions(t,n);s.$shared&&(s=Object.assign({},s,{$shared:!1}));const o=s.radius;return n!=="active"&&(s.radius=0),s.radius+=z(i&&i._custom,o),s}}function Kp(e,t,n){let i=1,s=1,o=0,r=0;if(t<Z){const a=e,c=a+t,l=Math.cos(a),u=Math.sin(a),h=Math.cos(c),d=Math.sin(c),f=(w,x,_)=>Ye(w,a,c,!0)?1:Math.max(x,x*n,_,_*n),p=(w,x,_)=>Ye(w,a,c,!0)?-1:Math.min(x,x*n,_,_*n),g=f(0,l,h),m=f(Q,u,d),b=p(F,l,h),y=p(F+Q,u,d);i=(g-b)/2,s=(m-y)/2,o=-(g+b)/2,r=-(m+y)/2}return{ratioX:i,ratioY:s,offsetX:o,offsetY:r}}class Gi extends Xt{static id="doughnut";static defaults={datasetElementType:!1,dataElementType:"arc",animation:{animateRotate:!0,animateScale:!1},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data,{labels:{pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=t.legend.options;return n.labels.length&&n.datasets.length?n.labels.map((c,l)=>{const h=t.getDatasetMeta(0).controller.getStyle(l);return{text:c,fillStyle:h.backgroundColor,fontColor:o,hidden:!t.getDataVisibility(l),lineDash:h.borderDash,lineDashOffset:h.borderDashOffset,lineJoin:h.borderJoinStyle,lineWidth:h.borderWidth,strokeStyle:h.borderColor,textAlign:s,pointStyle:i,borderRadius:r&&(a||h.borderRadius),index:l}}):[]}},onClick(t,n,i){i.chart.toggleDataVisibility(n.index),i.chart.update()}}}};constructor(t,n){super(t,n),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(t,n){const i=this.getDataset().data,s=this._cachedMeta;if(this._parsing===!1)s._parsed=i;else{let o=c=>+i[c];if(L(i[t])){const{key:c="value"}=this._parsing;o=l=>+Wt(i[l],c)}let r,a;for(r=t,a=t+n;r<a;++r)s._parsed[r]=o(r)}}_getRotation(){return xt(this.options.rotation-90)}_getCircumference(){return xt(this.options.circumference)}_getRotationExtents(){let t=Z,n=-Z;for(let i=0;i<this.chart.data.datasets.length;++i)if(this.chart.isDatasetVisible(i)&&this.chart.getDatasetMeta(i).type===this._type){const s=this.chart.getDatasetMeta(i).controller,o=s._getRotation(),r=s._getCircumference();t=Math.min(t,o),n=Math.max(n,o+r)}return{rotation:t,circumference:n-t}}update(t){const n=this.chart,{chartArea:i}=n,s=this._cachedMeta,o=s.data,r=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(i.width,i.height)-r)/2,0),c=Math.min(af(this.options.cutout,a),1),l=this._getRingWeight(this.index),{circumference:u,rotation:h}=this._getRotationExtents(),{ratioX:d,ratioY:f,offsetX:p,offsetY:g}=Kp(h,u,c),m=(i.width-r)/d,b=(i.height-r)/f,y=Math.max(Math.min(m,b)/2,0),w=Ur(this.options.radius,y),x=Math.max(w*c,0),_=(w-x)/this._getVisibleDatasetWeightTotal();this.offsetX=p*w,this.offsetY=g*w,s.total=this.calculateTotal(),this.outerRadius=w-_*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-_*l,0),this.updateElements(o,0,o.length,t)}_circumference(t,n){const i=this.options,s=this._cachedMeta,o=this._getCircumference();return n&&i.animation.animateRotate||!this.chart.getDataVisibility(t)||s._parsed[t]===null||s.data[t].hidden?0:this.calculateCircumference(s._parsed[t]*o/Z)}updateElements(t,n,i,s){const o=s==="reset",r=this.chart,a=r.chartArea,l=r.options.animation,u=(a.left+a.right)/2,h=(a.top+a.bottom)/2,d=o&&l.animateScale,f=d?0:this.innerRadius,p=d?0:this.outerRadius,{sharedOptions:g,includeOptions:m}=this._getSharedOptions(n,s);let b=this._getRotation(),y;for(y=0;y<n;++y)b+=this._circumference(y,o);for(y=n;y<n+i;++y){const w=this._circumference(y,o),x=t[y],_={x:u+this.offsetX,y:h+this.offsetY,startAngle:b,endAngle:b+w,circumference:w,outerRadius:p,innerRadius:f};m&&(_.options=g||this.resolveDataElementOptions(y,x.active?"active":s)),b+=w,this.updateElement(x,y,_,s)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let i=0,s;for(s=0;s<n.length;s++){const o=t._parsed[s];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(s)&&!n[s].hidden&&(i+=Math.abs(o))}return i}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?Z*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=Qe(n._parsed[t],i.options.locale);return{label:s[t]||"",value:o}}getMaxBorderWidth(t){let n=0;const i=this.chart;let s,o,r,a,c;if(!t){for(s=0,o=i.data.datasets.length;s<o;++s)if(i.isDatasetVisible(s)){r=i.getDatasetMeta(s),t=r.data,a=r.controller;break}}if(!t)return 0;for(s=0,o=t.length;s<o;++s)c=a.resolveDataElementOptions(s),c.borderAlign!=="inner"&&(n=Math.max(n,c.borderWidth||0,c.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let i=0,s=t.length;i<s;++i){const o=this.resolveDataElementOptions(i);n=Math.max(n,o.offset||0,o.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let i=0;i<t;++i)this.chart.isDatasetVisible(i)&&(n+=this._getRingWeight(i));return n}_getRingWeight(t){return Math.max(z(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}class Gp extends Xt{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=n,r=this.chart._animationsDisabled;let{start:a,count:c}=ta(n,s,r);this._drawStart=a,this._drawCount=c,ea(n)&&(a=0,c=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:l},t),this.updateElements(s,a,c,t)}updateElements(t,n,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:c,_dataset:l}=this._cachedMeta,{sharedOptions:u,includeOptions:h}=this._getSharedOptions(n,s),d=r.axis,f=a.axis,{spanGaps:p,segment:g}=this.options,m=we(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||s==="none",y=n+i,w=t.length;let x=n>0&&this.getParsed(n-1);for(let _=0;_<w;++_){const k=t[_],S=b?k:{};if(_<n||_>=y){S.skip=!0;continue}const M=this.getParsed(_),C=R(M[f]),I=S[d]=r.getPixelForValue(M[d],_),A=S[f]=o||C?a.getBasePixel():a.getPixelForValue(c?this.applyStack(a,M,c):M[f],_);S.skip=isNaN(I)||isNaN(A)||C,S.stop=_>0&&Math.abs(M[d]-x[d])>m,g&&(S.parsed=M,S.raw=l.data[_]),h&&(S.options=u||this.resolveDataElementOptions(_,k.active?"active":s)),b||this.updateElement(k,_,S,s),x=M}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,i=n.options&&n.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}class xa extends Xt{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:i,color:s}}=t.legend.options;return n.labels.map((o,r)=>{const c=t.getDatasetMeta(0).controller.getStyle(r);return{text:o,fillStyle:c.backgroundColor,strokeStyle:c.borderColor,fontColor:s,lineWidth:c.borderWidth,pointStyle:i,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,n,i){i.chart.toggleDataVisibility(n.index),i.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}};constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const n=this._cachedMeta,i=this.chart,s=i.data.labels||[],o=Qe(n._parsed[t].r,i.options.locale);return{label:s[t]||"",value:o}}parseObjectData(t,n,i,s){return la.bind(this)(t,n,i,s)}update(t){const n=this._cachedMeta.data;this._updateRadius(),this.updateElements(n,0,n.length,t)}getMinMax(){const t=this._cachedMeta,n={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return t.data.forEach((i,s)=>{const o=this.getParsed(s).r;!isNaN(o)&&this.chart.getDataVisibility(s)&&(o<n.min&&(n.min=o),o>n.max&&(n.max=o))}),n}_updateRadius(){const t=this.chart,n=t.chartArea,i=t.options,s=Math.min(n.right-n.left,n.bottom-n.top),o=Math.max(s/2,0),r=Math.max(i.cutoutPercentage?o/100*i.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,i,s){const o=s==="reset",r=this.chart,c=r.options.animation,l=this._cachedMeta.rScale,u=l.xCenter,h=l.yCenter,d=l.getIndexAngle(0)-.5*F;let f=d,p;const g=360/this.countVisibleElements();for(p=0;p<n;++p)f+=this._computeAngle(p,s,g);for(p=n;p<n+i;p++){const m=t[p];let b=f,y=f+this._computeAngle(p,s,g),w=r.getDataVisibility(p)?l.getDistanceFromCenterForValue(this.getParsed(p).r):0;f=y,o&&(c.animateScale&&(w=0),c.animateRotate&&(b=y=d));const x={x:u,y:h,innerRadius:0,outerRadius:w,startAngle:b,endAngle:y,options:this.resolveDataElementOptions(p,m.active?"active":s)};this.updateElement(m,p,x,s)}}countVisibleElements(){const t=this._cachedMeta;let n=0;return t.data.forEach((i,s)=>{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&n++}),n}_computeAngle(t,n,i){return this.chart.getDataVisibility(t)?xt(this.resolveDataElementOptions(t,n).angle||i):0}}class Qp extends Gi{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class tg extends Xt{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const n=this._cachedMeta.vScale,i=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(i[n.axis])}}parseObjectData(t,n,i,s){return la.bind(this)(t,n,i,s)}update(t){const n=this._cachedMeta,i=n.dataset,s=n.data||[],o=n.iScale.getLabels();if(i.points=s,t!=="resize"){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===s.length,options:r};this.updateElement(i,void 0,a,t)}this.updateElements(s,0,s.length,t)}updateElements(t,n,i,s){const o=this._cachedMeta.rScale,r=s==="reset";for(let a=n;a<n+i;a++){const c=t[a],l=this.resolveDataElementOptions(a,c.active?"active":s),u=o.getPointPositionForValue(a,this.getParsed(a).r),h=r?o.xCenter:u.x,d=r?o.yCenter:u.y,f={x:h,y:d,angle:u.angle,skip:isNaN(h)||isNaN(d),options:l};this.updateElement(c,a,f,s)}}}class eg extends Xt{static id="scatter";static defaults={datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1};static overrides={interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}};getLabelAndValue(t){const n=this._cachedMeta,i=this.chart.data.labels||[],{xScale:s,yScale:o}=n,r=this.getParsed(t),a=s.getLabelForValue(r.x),c=o.getLabelForValue(r.y);return{label:i[t]||"",value:"("+a+", "+c+")"}}update(t){const n=this._cachedMeta,{data:i=[]}=n,s=this.chart._animationsDisabled;let{start:o,count:r}=ta(n,i,s);if(this._drawStart=o,this._drawCount=r,ea(n)&&(o=0,r=i.length),this.options.showLine){this.datasetElementType||this.addElements();const{dataset:a,_dataset:c}=n;a._chart=this.chart,a._datasetIndex=this.index,a._decimated=!!c._decimated,a.points=i;const l=this.resolveDatasetElementOptions(t);l.segment=this.options.segment,this.updateElement(a,void 0,{animated:!s,options:l},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(i,o,r,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:c,_dataset:l}=this._cachedMeta,u=this.resolveDataElementOptions(n,s),h=this.getSharedOptions(u),d=this.includeOptions(s,h),f=r.axis,p=a.axis,{spanGaps:g,segment:m}=this.options,b=we(g)?g:Number.POSITIVE_INFINITY,y=this.chart._animationsDisabled||o||s==="none";let w=n>0&&this.getParsed(n-1);for(let x=n;x<n+i;++x){const _=t[x],k=this.getParsed(x),S=y?_:{},M=R(k[p]),C=S[f]=r.getPixelForValue(k[f],x),I=S[p]=o||M?a.getBasePixel():a.getPixelForValue(c?this.applyStack(a,k,c):k[p],x);S.skip=isNaN(C)||isNaN(I)||M,S.stop=x>0&&Math.abs(k[f]-w[f])>b,m&&(S.parsed=k,S.raw=l.data[x]),d&&(S.options=h||this.resolveDataElementOptions(x,_.active?"active":s)),y||this.updateElement(_,x,S,s),w=k}this.updateSharedOptions(h,s,u)}getMaxOverflow(){const t=this._cachedMeta,n=t.data||[];if(!this.options.showLine){let a=0;for(let c=n.length-1;c>=0;--c)a=Math.max(a,n[c].size(this.resolveDataElementOptions(c))/2);return a>0&&a}const i=t.dataset,s=i.options&&i.options.borderWidth||0;if(!n.length)return s;const o=n[0].size(this.resolveDataElementOptions(0)),r=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(s,o,r)/2}}var ng=Object.freeze({__proto__:null,BarController:Xp,BubbleController:Jp,DoughnutController:Gi,LineController:Gp,PieController:Qp,PolarAreaController:xa,RadarController:tg,ScatterController:eg});function ee(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Qi{static override(t){Object.assign(Qi.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return ee()}parse(){return ee()}format(){return ee()}add(){return ee()}diff(){return ee()}startOf(){return ee()}endOf(){return ee()}}var ig={_date:Qi};function sg(e,t,n,i){const{controller:s,data:o,_sorted:r}=e,a=s._cachedMeta.iScale,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const l=a._reversePixels?xf:zt;if(i){if(s._sharedOptions){const u=o[0],h=typeof u.getRange=="function"&&u.getRange(t);if(h){const d=l(o,t,n-h),f=l(o,t,n+h);return{lo:d.lo,hi:f.hi}}}}else{const u=l(o,t,n);if(c){const{vScale:h}=s._cachedMeta,{_parsed:d}=e,f=d.slice(0,u.lo+1).reverse().findIndex(g=>!R(g[h.axis]));u.lo-=Math.max(0,f);const p=d.slice(u.hi).findIndex(g=>!R(g[h.axis]));u.hi+=Math.max(0,p)}return u}}return{lo:0,hi:o.length-1}}function Wn(e,t,n,i,s){const o=e.getSortedVisibleDatasetMetas(),r=n[t];for(let a=0,c=o.length;a<c;++a){const{index:l,data:u}=o[a],{lo:h,hi:d}=sg(o[a],t,r,s);for(let f=h;f<=d;++f){const p=u[f];p.skip||i(p,l,f)}}}function og(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(i,s){const o=t?Math.abs(i.x-s.x):0,r=n?Math.abs(i.y-s.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function si(e,t,n,i,s){const o=[];return!s&&!e.isPointInArea(t)||Wn(e,n,t,function(a,c,l){!s&&!It(a,e.chartArea,0)||a.inRange(t.x,t.y,i)&&o.push({element:a,datasetIndex:c,index:l})},!0),o}function rg(e,t,n,i){let s=[];function o(r,a,c){const{startAngle:l,endAngle:u}=r.getProps(["startAngle","endAngle"],i),{angle:h}=Xr(r,{x:t.x,y:t.y});Ye(h,l,u)&&s.push({element:r,datasetIndex:a,index:c})}return Wn(e,n,t,o),s}function ag(e,t,n,i,s,o){let r=[];const a=og(n);let c=Number.POSITIVE_INFINITY;function l(u,h,d){const f=u.inRange(t.x,t.y,s);if(i&&!f)return;const p=u.getCenterPoint(s);if(!(!!o||e.isPointInArea(p))&&!f)return;const m=a(t,p);m<c?(r=[{element:u,datasetIndex:h,index:d}],c=m):m===c&&r.push({element:u,datasetIndex:h,index:d})}return Wn(e,n,t,l),r}function oi(e,t,n,i,s,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!i?rg(e,t,n,s):ag(e,t,n,i,s,o)}function ro(e,t,n,i,s){const o=[],r=n==="x"?"inXRange":"inYRange";let a=!1;return Wn(e,n,t,(c,l,u)=>{c[r]&&c[r](t[n],s)&&(o.push({element:c,datasetIndex:l,index:u}),a=a||c.inRange(t.x,t.y,s))}),i&&!a?[]:o}var cg={modes:{index(e,t,n,i){const s=ie(t,e),o=n.axis||"x",r=n.includeInvisible||!1,a=n.intersect?si(e,s,o,i,r):oi(e,s,o,!1,i,r),c=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(l=>{const u=a[0].index,h=l.data[u];h&&!h.skip&&c.push({element:h,datasetIndex:l.index,index:u})}),c):[]},dataset(e,t,n,i){const s=ie(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;let a=n.intersect?si(e,s,o,i,r):oi(e,s,o,!1,i,r);if(a.length>0){const c=a[0].datasetIndex,l=e.getDatasetMeta(c).data;a=[];for(let u=0;u<l.length;++u)a.push({element:l[u],datasetIndex:c,index:u})}return a},point(e,t,n,i){const s=ie(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return si(e,s,o,i,r)},nearest(e,t,n,i){const s=ie(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return oi(e,s,o,n.intersect,i,r)},x(e,t,n,i){const s=ie(t,e);return ro(e,s,"x",n.intersect,i)},y(e,t,n,i){const s=ie(t,e);return ro(e,s,"y",n.intersect,i)}}};const va=["left","top","right","bottom"];function ze(e,t){return e.filter(n=>n.pos===t)}function ao(e,t){return e.filter(n=>va.indexOf(n.pos)===-1&&n.box.axis===t)}function Ie(e,t){return e.sort((n,i)=>{const s=t?i:n,o=t?n:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function lg(e){const t=[];let n,i,s,o,r,a;for(n=0,i=(e||[]).length;n<i;++n)s=e[n],{position:o,options:{stack:r,stackWeight:a=1}}=s,t.push({index:n,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:r&&o+r,stackWeight:a});return t}function ug(e){const t={};for(const n of e){const{stack:i,pos:s,stackWeight:o}=n;if(!i||!va.includes(s))continue;const r=t[i]||(t[i]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function hg(e,t){const n=ug(e),{vBoxMaxWidth:i,hBoxMaxHeight:s}=t;let o,r,a;for(o=0,r=e.length;o<r;++o){a=e[o];const{fullSize:c}=a.box,l=n[a.stack],u=l&&a.stackWeight/l.weight;a.horizontal?(a.width=u?u*i:c&&t.availableWidth,a.height=s):(a.width=i,a.height=u?u*s:c&&t.availableHeight)}return n}function dg(e){const t=lg(e),n=Ie(t.filter(l=>l.box.fullSize),!0),i=Ie(ze(t,"left"),!0),s=Ie(ze(t,"right")),o=Ie(ze(t,"top"),!0),r=Ie(ze(t,"bottom")),a=ao(t,"x"),c=ao(t,"y");return{fullSize:n,leftAndTop:i.concat(o),rightAndBottom:s.concat(c).concat(r).concat(a),chartArea:ze(t,"chartArea"),vertical:i.concat(s).concat(c),horizontal:o.concat(r).concat(a)}}function co(e,t,n,i){return Math.max(e[n],t[n])+Math.max(e[i],t[i])}function wa(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function fg(e,t,n,i){const{pos:s,box:o}=n,r=e.maxPadding;if(!L(s)){n.size&&(e[s]-=n.size);const h=i[n.stack]||{size:0,count:1};h.size=Math.max(h.size,n.horizontal?o.height:o.width),n.size=h.size/h.count,e[s]+=n.size}o.getPadding&&wa(r,o.getPadding());const a=Math.max(0,t.outerWidth-co(r,e,"left","right")),c=Math.max(0,t.outerHeight-co(r,e,"top","bottom")),l=a!==e.w,u=c!==e.h;return e.w=a,e.h=c,n.horizontal?{same:l,other:u}:{same:u,other:l}}function pg(e){const t=e.maxPadding;function n(i){const s=Math.max(t[i]-e[i],0);return e[i]+=s,s}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function gg(e,t){const n=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],n[r])}),o}return i(e?["left","right"]:["top","bottom"])}function Fe(e,t,n,i){const s=[];let o,r,a,c,l,u;for(o=0,r=e.length,l=0;o<r;++o){a=e[o],c=a.box,c.update(a.width||t.w,a.height||t.h,gg(a.horizontal,t));const{same:h,other:d}=fg(t,n,a,i);l|=h&&s.length,u=u||d,c.fullSize||s.push(a)}return l&&Fe(s,t,n,i)||u}function pn(e,t,n,i,s){e.top=n,e.left=t,e.right=t+i,e.bottom=n+s,e.width=i,e.height=s}function lo(e,t,n,i){const s=n.padding;let{x:o,y:r}=t;for(const a of e){const c=a.box,l=i[a.stack]||{placed:0,weight:1},u=a.stackWeight/l.weight||1;if(a.horizontal){const h=t.w*u,d=l.size||c.height;qe(l.start)&&(r=l.start),c.fullSize?pn(c,s.left,r,n.outerWidth-s.right-s.left,d):pn(c,t.left+l.placed,r,h,d),l.start=r,l.placed+=h,r=c.bottom}else{const h=t.h*u,d=l.size||c.width;qe(l.start)&&(o=l.start),c.fullSize?pn(c,o,s.top,d,n.outerHeight-s.bottom-s.top):pn(c,o,t.top+l.placed,d,h),l.start=o,l.placed+=h,o=c.right}}t.x=o,t.y=r}var lt={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,i){if(!e)return;const s=ut(e.options.layout.padding),o=Math.max(t-s.width,0),r=Math.max(n-s.height,0),a=dg(e.boxes),c=a.vertical,l=a.horizontal;B(e.boxes,g=>{typeof g.beforeLayout=="function"&&g.beforeLayout()});const u=c.reduce((g,m)=>m.box.options&&m.box.options.display===!1?g:g+1,0)||1,h=Object.freeze({outerWidth:t,outerHeight:n,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),d=Object.assign({},s);wa(d,ut(i));const f=Object.assign({maxPadding:d,w:o,h:r,x:s.left,y:s.top},s),p=hg(c.concat(l),h);Fe(a.fullSize,f,h,p),Fe(c,f,h,p),Fe(l,f,h,p)&&Fe(c,f,h,p),pg(f),lo(a.leftAndTop,f,h,p),f.x+=f.w,f.y+=f.h,lo(a.rightAndBottom,f,h,p),e.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w},B(a.chartArea,g=>{const m=g.box;Object.assign(m,e.chartArea),m.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})})}};class ka{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,i){}removeEventListener(t,n,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,i,s){return n=Math.max(0,n||t.width),i=i||t.height,{width:n,height:Math.max(0,s?Math.floor(n/s):i)}}isAttached(t){return!0}updateConfig(t){}}class mg extends ka{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const vn="$chartjs",bg={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},uo=e=>e===null||e==="";function yg(e,t){const n=e.style,i=e.getAttribute("height"),s=e.getAttribute("width");if(e[vn]={initial:{height:i,width:s,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",uo(s)){const o=qs(e,"width");o!==void 0&&(e.width=o)}if(uo(i))if(e.style.height==="")e.height=e.width/(t||2);else{const o=qs(e,"height");o!==void 0&&(e.height=o)}return e}const Sa=fp?{passive:!0}:!1;function _g(e,t,n){e&&e.addEventListener(t,n,Sa)}function xg(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,Sa)}function vg(e,t){const n=bg[e.type]||e.type,{x:i,y:s}=ie(e,t);return{type:n,chart:t,native:e,x:i!==void 0?i:null,y:s!==void 0?s:null}}function In(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function wg(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||In(a.addedNodes,i),r=r&&!In(a.removedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}function kg(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||In(a.removedNodes,i),r=r&&!In(a.addedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}const Je=new Map;let ho=0;function Ma(){const e=window.devicePixelRatio;e!==ho&&(ho=e,Je.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function Sg(e,t){Je.size||window.addEventListener("resize",Ma),Je.set(e,t)}function Mg(e){Je.delete(e),Je.size||window.removeEventListener("resize",Ma)}function Tg(e,t,n){const i=e.canvas,s=i&&Ki(i);if(!s)return;const o=Qr((a,c)=>{const l=s.clientWidth;n(a,c),l<s.clientWidth&&n()},window),r=new ResizeObserver(a=>{const c=a[0],l=c.contentRect.width,u=c.contentRect.height;l===0&&u===0||o(l,u)});return r.observe(s),Sg(e,o),r}function ri(e,t,n){n&&n.disconnect(),t==="resize"&&Mg(e)}function Cg(e,t,n){const i=e.canvas,s=Qr(o=>{e.ctx!==null&&n(vg(o,e))},e);return _g(i,t,s),s}class Pg extends ka{acquireContext(t,n){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(yg(t,n),i):null}releaseContext(t){const n=t.canvas;if(!n[vn])return!1;const i=n[vn].initial;["height","width"].forEach(o=>{const r=i[o];R(r)?n.removeAttribute(o):n.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{n.style[o]=s[o]}),n.width=n.width,delete n[vn],!0}addEventListener(t,n,i){this.removeEventListener(t,n);const s=t.$proxies||(t.$proxies={}),r={attach:wg,detach:kg,resize:Tg}[n]||Cg;s[n]=r(t,n,i)}removeEventListener(t,n){const i=t.$proxies||(t.$proxies={}),s=i[n];if(!s)return;({attach:ri,detach:ri,resize:ri}[n]||xg)(t,n,s),i[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,i,s){return dp(t,n,i,s)}isAttached(t){const n=t&&Ki(t);return!!(n&&n.isConnected)}}function Og(e){return!Ji()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?mg:Pg}class Dt{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}hasValue(){return we(this.x)&&we(this.y)}getProps(t,n){const i=this.$animations;if(!n||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}function Eg(e,t){const n=e.options.ticks,i=zg(e),s=Math.min(n.maxTicksLimit||i,i),o=n.major.enabled?Ag(t):[],r=o.length,a=o[0],c=o[r-1],l=[];if(r>s)return Dg(t,l,o,r/s),l;const u=Ig(o,t,s);if(r>0){let h,d;const f=r>1?Math.round((c-a)/(r-1)):null;for(gn(t,l,u,R(f)?0:a-f,a),h=0,d=r-1;h<d;h++)gn(t,l,u,o[h],o[h+1]);return gn(t,l,u,c,R(f)?t.length:c+f),l}return gn(t,l,u),l}function zg(e){const t=e.options.offset,n=e._tickSize(),i=e._length/n+(t?0:1),s=e._maxLength/n;return Math.floor(Math.min(i,s))}function Ig(e,t,n){const i=Rg(e),s=t.length/n;if(!i)return Math.max(s,1);const o=gf(i);for(let r=0,a=o.length-1;r<a;r++){const c=o[r];if(c>s)return c}return Math.max(s,1)}function Ag(e){const t=[];let n,i;for(n=0,i=e.length;n<i;n++)e[n].major&&t.push(n);return t}function Dg(e,t,n,i){let s=0,o=n[0],r;for(i=Math.ceil(i),r=0;r<e.length;r++)r===o&&(t.push(e[r]),s++,o=n[s*i])}function gn(e,t,n,i,s){const o=z(i,0),r=Math.min(z(s,e.length),e.length);let a=0,c,l,u;for(n=Math.ceil(n),s&&(c=s-i,n=c/Math.floor(c/n)),u=o;u<0;)a++,u=Math.round(o+a*n);for(l=Math.max(o,0);l<r;l++)l===u&&(t.push(e[l]),a++,u=Math.round(o+a*n))}function Rg(e){const t=e.length;let n,i;if(t<2)return!1;for(i=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==i)return!1;return i}const Lg=e=>e==="left"?"right":e==="right"?"left":e,fo=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,po=(e,t)=>Math.min(t||e,e);function go(e,t){const n=[],i=e.length/t,s=e.length;let o=0;for(;o<s;o+=i)n.push(e[Math.floor(o)]);return n}function $g(e,t,n){const i=e.ticks.length,s=Math.min(t,i-1),o=e._startPixel,r=e._endPixel,a=1e-6;let c=e.getPixelForTick(s),l;if(!(n&&(i===1?l=Math.max(c-o,r-c):t===0?l=(e.getPixelForTick(1)-c)/2:l=(c-e.getPixelForTick(s-1))/2,c+=s<t?l:-l,c<o-a||c>r+a)))return c}function Fg(e,t){B(e,n=>{const i=n.gc,s=i.length/2;let o;if(s>t){for(o=0;o<s;++o)delete n.data[i[o]];i.splice(0,s)}})}function Ae(e){return e.drawTicks?e.tickLength:0}function mo(e,t){if(!e.display)return 0;const n=st(e.font,t),i=ut(e.padding);return(H(e.text)?e.text.length:1)*n.lineHeight+i.height}function Ng(e,t){return Yt(e,{scale:t,type:"scale"})}function Bg(e,t,n){return Yt(e,{tick:n,index:t,type:"tick"})}function jg(e,t,n){let i=Wi(e);return(n&&t!=="right"||!n&&t==="right")&&(i=Lg(i)),i}function Vg(e,t,n,i){const{top:s,left:o,bottom:r,right:a,chart:c}=e,{chartArea:l,scales:u}=c;let h=0,d,f,p;const g=r-s,m=a-o;if(e.isHorizontal()){if(f=at(i,o,a),L(n)){const b=Object.keys(n)[0],y=n[b];p=u[b].getPixelForValue(y)+g-t}else n==="center"?p=(l.bottom+l.top)/2+g-t:p=fo(e,n,t);d=a-o}else{if(L(n)){const b=Object.keys(n)[0],y=n[b];f=u[b].getPixelForValue(y)-m+t}else n==="center"?f=(l.left+l.right)/2-m+t:f=fo(e,n,t);p=at(i,r,s),h=n==="left"?-Q:Q}return{titleX:f,titleY:p,maxWidth:d,rotation:h}}class ue extends Dt{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:i,_suggestedMax:s}=this;return t=gt(t,Number.POSITIVE_INFINITY),n=gt(n,Number.NEGATIVE_INFINITY),i=gt(i,Number.POSITIVE_INFINITY),s=gt(s,Number.NEGATIVE_INFINITY),{min:gt(t,i),max:gt(n,s),minDefined:X(t),maxDefined:X(n)}}getMinMax(t){let{min:n,max:i,minDefined:s,maxDefined:o}=this.getUserBounds(),r;if(s&&o)return{min:n,max:i};const a=this.getMatchingVisibleMetas();for(let c=0,l=a.length;c<l;++c)r=a[c].controller.getMinMax(this,t),s||(n=Math.min(n,r.min)),o||(i=Math.max(i,r.max));return n=o&&n>i?i:n,i=s&&n>i?n:i,{min:gt(n,gt(i,n)),max:gt(i,gt(n,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){V(this.options.beforeUpdate,[this])}update(t,n,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Wf(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const c=a<this.ticks.length;this._convertTicksToLabels(c?go(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=Eg(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),c&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,i;this.isHorizontal()?(n=this.left,i=this.right):(n=this.top,i=this.bottom,t=!t),this._startPixel=n,this._endPixel=i,this._reversePixels=t,this._length=i-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){V(this.options.afterUpdate,[this])}beforeSetDimensions(){V(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){V(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),V(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){V(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let i,s,o;for(i=0,s=t.length;i<s;i++)o=t[i],o.label=V(n.callback,[o.value,i,t],this)}afterTickToLabelConversion(){V(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){V(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,i=po(this.ticks.length,t.ticks.maxTicksLimit),s=n.minRotation||0,o=n.maxRotation;let r=s,a,c,l;if(!this._isVisible()||!n.display||s>=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const u=this._getLabelSizes(),h=u.widest.width,d=u.highest.height,f=ot(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/i:f/(i-1),h+6>a&&(a=f/(i-(t.offset?.5:1)),c=this.maxHeight-Ae(t.grid)-n.padding-mo(t.title,this.chart.options.font),l=Math.sqrt(h*h+d*d),r=Vi(Math.min(Math.asin(ot((u.highest.height+6)/a,-1,1)),Math.asin(ot(c/l,-1,1))-Math.asin(ot(d/l,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){V(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){V(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const c=mo(s,n.options.font);if(a?(t.width=this.maxWidth,t.height=Ae(o)+c):(t.height=this.maxHeight,t.width=Ae(o)+c),i.display&&this.ticks.length){const{first:l,last:u,widest:h,highest:d}=this._getLabelSizes(),f=i.padding*2,p=xt(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(a){const b=i.mirror?0:m*h.width+g*d.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{const b=i.mirror?0:g*h.width+m*d.height;t.width=Math.min(this.maxWidth,t.width+b+f)}this._calculatePadding(l,u,m,g)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,c=this.labelRotation!==0,l=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,h=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,f=0;c?l?(d=s*t.width,f=i*n.height):(d=i*t.height,f=s*n.width):o==="start"?f=n.width:o==="end"?d=t.width:o!=="inner"&&(d=t.width/2,f=n.width/2),this.paddingLeft=Math.max((d-u+r)*this.width/(this.width-u),0),this.paddingRight=Math.max((f-h+r)*this.width/(this.width-h),0)}else{let u=n.height/2,h=t.height/2;o==="start"?(u=0,h=t.height):o==="end"&&(u=n.height,h=0),this.paddingTop=u+r,this.paddingBottom=h+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){V(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,i;for(n=0,i=t.length;n<i;n++)R(t[n].label)&&(t.splice(n,1),i--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let i=this.ticks;n<i.length&&(i=go(i,n)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,i){const{ctx:s,_longestTextCache:o}=this,r=[],a=[],c=Math.floor(n/po(n,i));let l=0,u=0,h,d,f,p,g,m,b,y,w,x,_;for(h=0;h<n;h+=c){if(p=t[h].label,g=this._resolveTickFontOptions(h),s.font=m=g.string,b=o[m]=o[m]||{data:{},gc:[]},y=g.lineHeight,w=x=0,!R(p)&&!H(p))w=En(s,b.data,b.gc,w,p),x=y;else if(H(p))for(d=0,f=p.length;d<f;++d)_=p[d],!R(_)&&!H(_)&&(w=En(s,b.data,b.gc,w,_),x+=y);r.push(w),a.push(x),l=Math.max(w,l),u=Math.max(x,u)}Fg(o,n);const k=r.indexOf(l),S=a.indexOf(u),M=C=>({width:r[C]||0,height:a[C]||0});return{first:M(0),last:M(n-1),widest:M(k),highest:M(S),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return _f(this._alignToPixels?te(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const i=n[t];return i.$context||(i.$context=Bg(this.getContext(),t,i))}return this.$context||(this.$context=Ng(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=xt(this.labelRotation),i=Math.abs(Math.cos(n)),s=Math.abs(Math.sin(n)),o=this._getLabelSizes(),r=t.autoSkipPadding||0,a=o?o.widest.width+r:0,c=o?o.highest.height+r:0;return this.isHorizontal()?c*i>a*s?a/i:c/s:c*s<a*i?c/i:a/s}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,c=o.offset,l=this.isHorizontal(),h=this.ticks.length+(c?1:0),d=Ae(o),f=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,m=g/2,b=function(W){return te(i,W,g)};let y,w,x,_,k,S,M,C,I,A,D,tt;if(r==="top")y=b(this.bottom),S=this.bottom-d,C=y-m,A=b(t.top)+m,tt=t.bottom;else if(r==="bottom")y=b(this.top),A=t.top,tt=b(t.bottom)-m,S=y+m,C=this.top+d;else if(r==="left")y=b(this.right),k=this.right-d,M=y-m,I=b(t.left)+m,D=t.right;else if(r==="right")y=b(this.left),I=t.left,D=b(t.right)-m,k=y+m,M=this.left+d;else if(n==="x"){if(r==="center")y=b((t.top+t.bottom)/2+.5);else if(L(r)){const W=Object.keys(r)[0],G=r[W];y=b(this.chart.scales[W].getPixelForValue(G))}A=t.top,tt=t.bottom,S=y+m,C=S+d}else if(n==="y"){if(r==="center")y=b((t.left+t.right)/2);else if(L(r)){const W=Object.keys(r)[0],G=r[W];y=b(this.chart.scales[W].getPixelForValue(G))}k=y-m,M=k-d,I=t.left,D=t.right}const $=z(s.ticks.maxTicksLimit,h),N=Math.max(1,Math.ceil(h/$));for(w=0;w<h;w+=N){const W=this.getContext(w),G=o.setContext(W),_t=a.setContext(W),rt=G.lineWidth,de=G.color,en=_t.dash||[],fe=_t.dashOffset,Pe=G.tickWidth,Kt=G.tickColor,Oe=G.tickBorderDash||[],Gt=G.tickBorderDashOffset;x=$g(this,w,c),x!==void 0&&(_=te(i,x,rt),l?k=M=I=D=_:S=C=A=tt=_,f.push({tx1:k,ty1:S,tx2:M,ty2:C,x1:I,y1:A,x2:D,y2:tt,width:rt,color:de,borderDash:en,borderDashOffset:fe,tickWidth:Pe,tickColor:Kt,tickBorderDash:Oe,tickBorderDashOffset:Gt}))}return this._ticksLength=h,this._borderValue=y,f}_computeLabelItems(t){const n=this.axis,i=this.options,{position:s,ticks:o}=i,r=this.isHorizontal(),a=this.ticks,{align:c,crossAlign:l,padding:u,mirror:h}=o,d=Ae(i.grid),f=d+u,p=h?-u:f,g=-xt(this.labelRotation),m=[];let b,y,w,x,_,k,S,M,C,I,A,D,tt="middle";if(s==="top")k=this.bottom-p,S=this._getXAxisLabelAlignment();else if(s==="bottom")k=this.top+p,S=this._getXAxisLabelAlignment();else if(s==="left"){const N=this._getYAxisLabelAlignment(d);S=N.textAlign,_=N.x}else if(s==="right"){const N=this._getYAxisLabelAlignment(d);S=N.textAlign,_=N.x}else if(n==="x"){if(s==="center")k=(t.top+t.bottom)/2+f;else if(L(s)){const N=Object.keys(s)[0],W=s[N];k=this.chart.scales[N].getPixelForValue(W)+f}S=this._getXAxisLabelAlignment()}else if(n==="y"){if(s==="center")_=(t.left+t.right)/2-f;else if(L(s)){const N=Object.keys(s)[0],W=s[N];_=this.chart.scales[N].getPixelForValue(W)}S=this._getYAxisLabelAlignment(d).textAlign}n==="y"&&(c==="start"?tt="top":c==="end"&&(tt="bottom"));const $=this._getLabelSizes();for(b=0,y=a.length;b<y;++b){w=a[b],x=w.label;const N=o.setContext(this.getContext(b));M=this.getPixelForTick(b)+o.labelOffset,C=this._resolveTickFontOptions(b),I=C.lineHeight,A=H(x)?x.length:1;const W=A/2,G=N.color,_t=N.textStrokeColor,rt=N.textStrokeWidth;let de=S;r?(_=M,S==="inner"&&(b===y-1?de=this.options.reverse?"left":"right":b===0?de=this.options.reverse?"right":"left":de="center"),s==="top"?l==="near"||g!==0?D=-A*I+I/2:l==="center"?D=-$.highest.height/2-W*I+I:D=-$.highest.height+I/2:l==="near"||g!==0?D=I/2:l==="center"?D=$.highest.height/2-W*I:D=$.highest.height-A*I,h&&(D*=-1),g!==0&&!N.showLabelBackdrop&&(_+=I/2*Math.sin(g))):(k=M,D=(1-A)*I/2);let en;if(N.showLabelBackdrop){const fe=ut(N.backdropPadding),Pe=$.heights[b],Kt=$.widths[b];let Oe=D-fe.top,Gt=0-fe.left;switch(tt){case"middle":Oe-=Pe/2;break;case"bottom":Oe-=Pe;break}switch(S){case"center":Gt-=Kt/2;break;case"right":Gt-=Kt;break;case"inner":b===y-1?Gt-=Kt:b>0&&(Gt-=Kt/2);break}en={left:Gt,top:Oe,width:Kt+fe.width,height:Pe+fe.height,color:N.backdropColor}}m.push({label:x,font:C,textOffset:D,options:{rotation:g,color:G,strokeColor:_t,strokeWidth:rt,textAlign:de,textBaseline:tt,translation:[_,k],backdrop:en}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-xt(this.labelRotation))return t==="top"?"left":"right";let s="center";return n.align==="start"?s="left":n.align==="end"?s="right":n.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:i,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,c=r.widest.width;let l,u;return n==="left"?s?(u=this.right+o,i==="near"?l="left":i==="center"?(l="center",u+=c/2):(l="right",u+=c)):(u=this.right-a,i==="near"?l="right":i==="center"?(l="center",u-=c/2):(l="left",u=this.left)):n==="right"?s?(u=this.left+o,i==="near"?l="right":i==="center"?(l="center",u-=c/2):(l="left",u-=c)):(u=this.left+a,i==="near"?l="left":i==="center"?(l="center",u+=c/2):(l="right",u=this.right)):l="right",{textAlign:l,x:u}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:i,top:s,width:o,height:r}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(i,s,o,r),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?n.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const n=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(c,l,u)=>{!u.width||!u.color||(i.save(),i.lineWidth=u.width,i.strokeStyle=u.color,i.setLineDash(u.borderDash||[]),i.lineDashOffset=u.borderDashOffset,i.beginPath(),i.moveTo(c.x,c.y),i.lineTo(l.x,l.y),i.stroke(),i.restore())};if(n.display)for(o=0,r=s.length;o<r;++o){const c=s[o];n.drawOnChartArea&&a({x:c.x1,y:c.y1},{x:c.x2,y:c.y2},c),n.drawTicks&&a({x:c.tx1,y:c.ty1},{x:c.tx2,y:c.ty2},{color:c.tickColor,width:c.tickWidth,borderDash:c.tickBorderDash,borderDashOffset:c.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:i,grid:s}}=this,o=i.setContext(this.getContext()),r=i.display?o.width:0;if(!r)return;const a=s.setContext(this.getContext(0)).lineWidth,c=this._borderValue;let l,u,h,d;this.isHorizontal()?(l=te(t,this.left,r)-r/2,u=te(t,this.right,a)+a/2,h=d=c):(h=te(t,this.top,r)-r/2,d=te(t,this.bottom,a)+a/2,l=u=c),n.save(),n.lineWidth=o.width,n.strokeStyle=o.color,n.beginPath(),n.moveTo(l,h),n.lineTo(u,d),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const i=this.ctx,s=this._computeLabelArea();s&&jn(i,s);const o=this.getLabelItems(t);for(const r of o){const a=r.options,c=r.font,l=r.label,u=r.textOffset;ce(i,l,0,u,c,a)}s&&Vn(i)}drawTitle(){const{ctx:t,options:{position:n,title:i,reverse:s}}=this;if(!i.display)return;const o=st(i.font),r=ut(i.padding),a=i.align;let c=o.lineHeight/2;n==="bottom"||n==="center"||L(n)?(c+=r.bottom,H(i.text)&&(c+=o.lineHeight*(i.text.length-1))):c+=r.top;const{titleX:l,titleY:u,maxWidth:h,rotation:d}=Vg(this,c,n,a);ce(t,i.text,0,0,o,{color:i.color,maxWidth:h,rotation:d,textAlign:jg(a,n,s),textBaseline:"middle",translation:[l,u]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,i=z(t.grid&&t.grid.z,-1),s=z(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==ue.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=n.length;o<r;++o){const a=n[o];a[i]===this.id&&(!t||a.type===t)&&s.push(a)}return s}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return st(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class mn{constructor(t,n,i){this.type=t,this.scope=n,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let i;Hg(n)&&(i=this.register(n));const s=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in s||(s[o]=t,Zg(t,r,i),this.override&&U.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const n=this.items,i=t.id,s=this.scope;i in n&&delete n[i],s&&i in U[s]&&(delete U[s][i],this.override&&delete ae[i])}}function Zg(e,t,n){const i=Ue(Object.create(null),[n?U.get(n):{},U.get(t),e.defaults]);U.set(t,i),e.defaultRoutes&&Wg(t,e.defaultRoutes),e.descriptors&&U.describe(t,e.descriptors)}function Wg(e,t){Object.keys(t).forEach(n=>{const i=n.split("."),s=i.pop(),o=[e].concat(i).join("."),r=t[n].split("."),a=r.pop(),c=r.join(".");U.route(o,s,c,a)})}function Hg(e){return"id"in e&&"defaults"in e}class Ug{constructor(){this.controllers=new mn(Xt,"datasets",!0),this.elements=new mn(Dt,"elements"),this.plugins=new mn(Object,"plugins"),this.scales=new mn(ue,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,i){[...n].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):B(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,n,i){const s=ji(t);V(i["before"+s],[],i),n[t](i),V(i["after"+s],[],i)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const i=this._typedRegistries[n];if(i.isForType(t))return i}return this.plugins}_get(t,n,i){const s=n.get(t);if(s===void 0)throw new Error('"'+t+'" is not a registered '+i+".");return s}}var kt=new Ug;class qg{constructor(){this._init=void 0}notify(t,n,i,s){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;const o=s?this._descriptors(t).filter(s):this._descriptors(t),r=this._notify(o,t,n,i);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),r}_notify(t,n,i,s){s=s||{};for(const o of t){const r=o.plugin,a=r[i],c=[n,s,o.options];if(V(a,c,r)===!1&&s.cancelable)return!1}return!0}invalidate(){R(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const i=t&&t.config,s=z(i.options&&i.options.plugins,{}),o=Yg(i);return s===!1&&!n?[]:Jg(t,o,s,n)}_notifyStateChanges(t){const n=this._oldCache||[],i=this._cache,s=(o,r)=>o.filter(a=>!r.some(c=>a.plugin.id===c.plugin.id));this._notify(s(n,i),t,"stop"),this._notify(s(i,n),t,"start")}}function Yg(e){const t={},n=[],i=Object.keys(kt.plugins.items);for(let o=0;o<i.length;o++)n.push(kt.getPlugin(i[o]));const s=e.plugins||[];for(let o=0;o<s.length;o++){const r=s[o];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function Xg(e,t){return!t&&e===!1?null:e===!0?{}:e}function Jg(e,{plugins:t,localIds:n},i,s){const o=[],r=e.getContext();for(const a of t){const c=a.id,l=Xg(i[c],s);l!==null&&o.push({plugin:a,options:Kg(e.config,{plugin:a,local:n[c]},l,r)})}return o}function Kg(e,{plugin:t,local:n},i,s){const o=e.pluginScopeKeys(t),r=e.getOptionScopes(i,o);return n&&t.defaults&&r.push(t.defaults),e.createResolver(r,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Si(e,t){const n=U.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function Gg(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function Qg(e,t){return e===t?"_index_":"_value_"}function bo(e){if(e==="x"||e==="y"||e==="r")return e}function tm(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function Mi(e,...t){if(bo(e))return e;for(const n of t){const i=n.axis||tm(n.position)||e.length>1&&bo(e[0].toLowerCase());if(i)return i}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function yo(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function em(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(i=>i.xAxisID===e||i.yAxisID===e);if(n.length)return yo(e,"x",n[0])||yo(e,"y",n[0])}return{}}function nm(e,t){const n=ae[e.type]||{scales:{}},i=t.scales||{},s=Si(e.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!L(a))return console.error(`Invalid scale configuration for scale: ${r}`);if(a._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const c=Mi(r,a,em(r,e),U.scales[a.type]),l=Qg(c,s),u=n.scales||{};o[r]=Be(Object.create(null),[{axis:c},a,u[c],u[l]])}),e.data.datasets.forEach(r=>{const a=r.type||e.type,c=r.indexAxis||Si(a,t),u=(ae[a]||{}).scales||{};Object.keys(u).forEach(h=>{const d=Gg(h,c),f=r[d+"AxisID"]||d;o[f]=o[f]||Object.create(null),Be(o[f],[{axis:d},i[f],u[h]])})}),Object.keys(o).forEach(r=>{const a=o[r];Be(a,[U.scales[a.type],U.scale])}),o}function Ta(e){const t=e.options||(e.options={});t.plugins=z(t.plugins,{}),t.scales=nm(e,t)}function Ca(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function im(e){return e=e||{},e.data=Ca(e.data),Ta(e),e}const _o=new Map,Pa=new Set;function bn(e,t){let n=_o.get(e);return n||(n=t(),_o.set(e,n),Pa.add(n)),n}const De=(e,t,n)=>{const i=Wt(t,n);i!==void 0&&e.add(i)};class sm{constructor(t){this._config=im(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=Ca(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),Ta(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return bn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return bn(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return bn(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,i=this.type;return bn(`${i}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const i=this._scopeCache;let s=i.get(t);return(!s||n)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,n,i){const{options:s,type:o}=this,r=this._cachedScopes(t,i),a=r.get(n);if(a)return a;const c=new Set;n.forEach(u=>{t&&(c.add(t),u.forEach(h=>De(c,t,h))),u.forEach(h=>De(c,s,h)),u.forEach(h=>De(c,ae[o]||{},h)),u.forEach(h=>De(c,U,h)),u.forEach(h=>De(c,wi,h))});const l=Array.from(c);return l.length===0&&l.push(Object.create(null)),Pa.has(n)&&r.set(n,l),l}chartOptionScopes(){const{options:t,type:n}=this;return[t,ae[n]||{},U.datasets[n]||{},{type:n},U,wi]}resolveNamedOptions(t,n,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=xo(this._resolverCache,t,s);let c=r;if(rm(r,n)){o.$shared=!1,i=Ht(i)?i():i;const l=this.createResolver(t,i,a);c=ke(r,i,l)}for(const l of n)o[l]=c[l];return o}createResolver(t,n,i=[""],s){const{resolver:o}=xo(this._resolverCache,t,i);return L(n)?ke(o,n,void 0,s):o}}function xo(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));const s=n.join();let o=i.get(s);return o||(o={resolver:qi(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const om=e=>L(e)&&Object.getOwnPropertyNames(e).some(t=>Ht(e[t]));function rm(e,t){const{isScriptable:n,isIndexable:i}=oa(e);for(const s of t){const o=n(s),r=i(s),a=(r||o)&&e[s];if(o&&(Ht(a)||om(a))||r&&H(a))return!0}return!1}var am="4.5.1";const cm=["top","bottom","left","right","chartArea"];function vo(e,t){return e==="top"||e==="bottom"||cm.indexOf(e)===-1&&t==="x"}function wo(e,t){return function(n,i){return n[e]===i[e]?n[t]-i[t]:n[e]-i[e]}}function ko(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),V(n&&n.onComplete,[e],t)}function lm(e){const t=e.chart,n=t.options.animation;V(n&&n.onProgress,[e],t)}function Oa(e){return Ji()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const wn={},So=e=>{const t=Oa(e);return Object.values(wn).filter(n=>n.canvas===t).pop()};function um(e,t,n){const i=Object.keys(e);for(const s of i){const o=+s;if(o>=t){const r=e[s];delete e[s],(n>0||o>t)&&(e[o+n]=r)}}}function hm(e,t,n,i){return!n||e.type==="mouseout"?null:i?t:e}class ye{static defaults=U;static instances=wn;static overrides=ae;static registry=kt;static version=am;static getChart=So;static register(...t){kt.add(...t),Mo()}static unregister(...t){kt.remove(...t),Mo()}constructor(t,n){const i=this.config=new sm(n),s=Oa(t),o=So(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||Og(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),c=a&&a.canvas,l=c&&c.height,u=c&&c.width;if(this.id=rf(),this.ctx=a,this.canvas=c,this.width=u,this.height=l,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new qg,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=kf(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],wn[this.id]=this,!a||!c){console.error("Failed to create chart: can't acquire context from the given item");return}Ct.listen(this,"complete",ko),Ct.listen(this,"progress",lm),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:i,height:s,_aspectRatio:o}=this;return R(t)?n&&o?o:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return kt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Us(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Zs(this.canvas,this.ctx),this}stop(){return Ct.stop(this),this}resize(t,n){Ct.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,n,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Us(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),V(i.onResize,[this,r],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};B(n,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,n=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];n&&(o=o.concat(Object.keys(n).map(r=>{const a=n[r],c=Mi(r,a),l=c==="r",u=c==="x";return{options:a,dposition:l?"chartArea":u?"bottom":"left",dtype:l?"radialLinear":u?"category":"linear"}}))),B(o,r=>{const a=r.options,c=a.id,l=Mi(c,a),u=z(a.type,r.dtype);(a.position===void 0||vo(a.position,l)!==vo(r.dposition))&&(a.position=r.dposition),s[c]=!0;let h=null;if(c in i&&i[c].type===u)h=i[c];else{const d=kt.getScale(u);h=new d({id:c,type:u,ctx:this.ctx,chart:this}),i[h.id]=h}h.init(a,t)}),B(s,(r,a)=>{r||delete i[a]}),B(i,r=>{lt.configure(this,r,r.options),lt.addBox(this,r)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>n){for(let s=n;s<i;++s)this._destroyDatasetMeta(s);t.splice(n,i-n)}this._sortedMetasets=t.slice(0).sort(wo("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((i,s)=>{n.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=n.length;i<s;i++){const o=n[i];let r=this.getDatasetMeta(i);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(i),r=this.getDatasetMeta(i)),r.type=a,r.indexAxis=o.indexAxis||Si(a,this.options),r.order=o.order||0,r.index=i,r.label=""+o.label,r.visible=this.isDatasetVisible(i),r.controller)r.controller.updateIndex(i),r.controller.linkScales();else{const c=kt.getController(a),{datasetElementType:l,dataElementType:u}=U.datasets[a];Object.assign(c,{dataElementType:kt.getElement(u),datasetElementType:l&&kt.getElement(l)}),r.controller=new c(this,i),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){B(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const i=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let l=0,u=this.data.datasets.length;l<u;l++){const{controller:h}=this.getDatasetMeta(l),d=!s&&o.indexOf(h)===-1;h.buildOrUpdateElements(d),r=Math.max(+h.getMaxOverflow(),r)}r=this._minPadding=i.layout.autoPadding?r:0,this._updateLayout(r),s||B(o,l=>{l.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(wo("z","_idx"));const{_active:a,_lastEvent:c}=this;c?this._eventHandler(c,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){B(this.scales,t=>{lt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!Ds(n,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of n){const r=i==="_removeElements"?-o:o;um(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=i(0);for(let o=1;o<n;o++)if(!Ds(s,i(o)))return;return Array.from(s).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;lt.update(this,this.width,this.height,t);const n=this.chartArea,i=n.width<=0||n.height<=0;this._layers=[],B(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,i=this.data.datasets.length;n<i;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,i=this.data.datasets.length;n<i;++n)this._updateDataset(n,Ht(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const i=this.getDatasetMeta(t),s={meta:i,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",s)!==!1&&(i.controller._update(n),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(Ct.has(this)?this.attached&&!Ct.running(this)&&Ct.start(this):(this.draw(),ko({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:i,height:s}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(i,s)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,i=[];let s,o;for(s=0,o=n.length;s<o;++s){const r=n[s];(!t||r.visible)&&i.push(r)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,i={meta:t,index:t.index,cancelable:!0},s=ma(this,t);this.notifyPlugins("beforeDatasetDraw",i)!==!1&&(s&&jn(n,s),t.controller.draw(),s&&Vn(n),i.cancelable=!1,this.notifyPlugins("afterDatasetDraw",i))}isPointInArea(t){return It(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,i,s){const o=cg.modes[n];return typeof o=="function"?o(this,t,i,s):[]}getDatasetMeta(t){const n=this.data.datasets[t],i=this._metasets;let s=i.filter(o=>o&&o._dataset===n).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Yt(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!n.hidden}setDatasetVisibility(t,n){const i=this.getDatasetMeta(t);i.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);qe(n)?(o.data[n].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),Ct.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),Zs(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete wn[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,i=(o,r)=>{n.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};B(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,i=(c,l)=>{n.addEventListener(this,c,l),t[c]=l},s=(c,l)=>{t[c]&&(n.removeEventListener(this,c,l),delete t[c])},o=(c,l)=>{this.canvas&&this.resize(c,l)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},n.isAttached(this.canvas)?a():r()}unbindEvents(){B(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},B(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,i){const s=i?"set":"remove";let o,r,a,c;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,c=t.length;a<c;++a){r=t[a];const l=r&&this.getDatasetMeta(r.datasetIndex).controller;l&&l[s+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],i=t.map(({datasetIndex:o,index:r})=>{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Cn(i,n)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,n))}notifyPlugins(t,n,i){return this._plugins.notify(this,t,n,i)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,i){const s=this.options.hover,o=(c,l)=>c.filter(u=>!l.some(h=>u.datasetIndex===h.datasetIndex&&u.index===h.index)),r=o(n,t),a=i?t:o(t,n);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,n){const i={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)return;const o=this._handleEvent(t,n,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,n,i){const{_active:s=[],options:o}=this,r=n,a=this._getActiveElements(t,s,i,r),c=df(t),l=hm(t,this._lastEvent,i,c);i&&(this._lastEvent=null,V(o.onHover,[t,a,this],this),c&&V(o.onClick,[t,a,this],this));const u=!Cn(a,s);return(u||n)&&(this._active=a,this._updateHoverStyles(a,s,n)),this._lastEvent=l,u}_getActiveElements(t,n,i,s){if(t.type==="mouseout")return[];if(!i)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}function Mo(){return B(ye.instances,e=>e._plugins.invalidate())}function dm(e,t,n){const{startAngle:i,x:s,y:o,outerRadius:r,innerRadius:a,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,h=Math.min(l/r,ct(i-n));if(e.beginPath(),e.arc(s,o,r-l/2,i+h/2,n-h/2),a>0){const d=Math.min(l/a,ct(i-n));e.arc(s,o,a+l/2,n-d/2,i+d/2,!0)}else{const d=Math.min(l/2,r*ct(i-n));if(u==="round")e.arc(s,o,d,n-F/2,i+F/2,!0);else if(u==="bevel"){const f=2*d*d,p=-f*Math.cos(n+F/2)+s,g=-f*Math.sin(n+F/2)+o,m=f*Math.cos(i+F/2)+s,b=f*Math.sin(i+F/2)+o;e.lineTo(p,g),e.lineTo(m,b)}}e.closePath(),e.moveTo(0,0),e.rect(0,0,e.canvas.width,e.canvas.height),e.clip("evenodd")}function fm(e,t,n){const{startAngle:i,pixelMargin:s,x:o,y:r,outerRadius:a,innerRadius:c}=t;let l=s/a;e.beginPath(),e.arc(o,r,a,i-l,n+l),c>s?(l=s/c,e.arc(o,r,c,n+l,i-l,!0)):e.arc(o,r,s,n+Q,i-Q),e.closePath(),e.clip()}function pm(e){return Ui(e,["outerStart","outerEnd","innerStart","innerEnd"])}function gm(e,t,n,i){const s=pm(e.options.borderRadius),o=(n-t)/2,r=Math.min(o,i*t/2),a=c=>{const l=(n-Math.min(o,c))*i/2;return ot(c,0,Math.min(o,l))};return{outerStart:a(s.outerStart),outerEnd:a(s.outerEnd),innerStart:ot(s.innerStart,0,r),innerEnd:ot(s.innerEnd,0,r)}}function ge(e,t,n,i){return{x:n+e*Math.cos(t),y:i+e*Math.sin(t)}}function An(e,t,n,i,s,o){const{x:r,y:a,startAngle:c,pixelMargin:l,innerRadius:u}=t,h=Math.max(t.outerRadius+i+n-l,0),d=u>0?u+i+n+l:0;let f=0;const p=s-c;if(i){const N=u>0?u-i:0,W=h>0?h-i:0,G=(N+W)/2,_t=G!==0?p*G/(G+i):p;f=(p-_t)/2}const g=Math.max(.001,p*h-n/F)/h,m=(p-g)/2,b=c+m+f,y=s-m-f,{outerStart:w,outerEnd:x,innerStart:_,innerEnd:k}=gm(t,d,h,y-b),S=h-w,M=h-x,C=b+w/S,I=y-x/M,A=d+_,D=d+k,tt=b+_/A,$=y-k/D;if(e.beginPath(),o){const N=(C+I)/2;if(e.arc(r,a,h,C,N),e.arc(r,a,h,N,I),x>0){const rt=ge(M,I,r,a);e.arc(rt.x,rt.y,x,I,y+Q)}const W=ge(D,y,r,a);if(e.lineTo(W.x,W.y),k>0){const rt=ge(D,$,r,a);e.arc(rt.x,rt.y,k,y+Q,$+Math.PI)}const G=(y-k/d+(b+_/d))/2;if(e.arc(r,a,d,y-k/d,G,!0),e.arc(r,a,d,G,b+_/d,!0),_>0){const rt=ge(A,tt,r,a);e.arc(rt.x,rt.y,_,tt+Math.PI,b-Q)}const _t=ge(S,b,r,a);if(e.lineTo(_t.x,_t.y),w>0){const rt=ge(S,C,r,a);e.arc(rt.x,rt.y,w,b-Q,C)}}else{e.moveTo(r,a);const N=Math.cos(C)*h+r,W=Math.sin(C)*h+a;e.lineTo(N,W);const G=Math.cos(I)*h+r,_t=Math.sin(I)*h+a;e.lineTo(G,_t)}e.closePath()}function mm(e,t,n,i,s){const{fullCircles:o,startAngle:r,circumference:a}=t;let c=t.endAngle;if(o){An(e,t,n,i,c,s);for(let l=0;l<o;++l)e.fill();isNaN(a)||(c=r+(a%Z||Z))}return An(e,t,n,i,c,s),e.fill(),c}function bm(e,t,n,i,s){const{fullCircles:o,startAngle:r,circumference:a,options:c}=t,{borderWidth:l,borderJoinStyle:u,borderDash:h,borderDashOffset:d,borderRadius:f}=c,p=c.borderAlign==="inner";if(!l)return;e.setLineDash(h||[]),e.lineDashOffset=d,p?(e.lineWidth=l*2,e.lineJoin=u||"round"):(e.lineWidth=l,e.lineJoin=u||"bevel");let g=t.endAngle;if(o){An(e,t,n,i,g,s);for(let m=0;m<o;++m)e.stroke();isNaN(a)||(g=r+(a%Z||Z))}p&&fm(e,t,g),c.selfJoin&&g-r>=F&&f===0&&u!=="miter"&&dm(e,t,g),o||(An(e,t,n,i,g,s),e.stroke())}class ym extends Dt{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0,selfJoin:!1};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super(),this.options=void 0,this.circumference=void 0,this.startAngle=void 0,this.endAngle=void 0,this.innerRadius=void 0,this.outerRadius=void 0,this.pixelMargin=0,this.fullCircles=0,t&&Object.assign(this,t)}inRange(t,n,i){const s=this.getProps(["x","y"],i),{angle:o,distance:r}=Xr(s,{x:t,y:n}),{startAngle:a,endAngle:c,innerRadius:l,outerRadius:u,circumference:h}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),d=(this.options.spacing+this.options.borderWidth)/2,f=z(h,c-a),p=Ye(o,a,c)&&a!==c,g=f>=Z||p,m=Et(r,l+d,u+d);return g&&m}getCenterPoint(t){const{x:n,y:i,startAngle:s,endAngle:o,innerRadius:r,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t),{offset:c,spacing:l}=this.options,u=(s+o)/2,h=(r+a+l+c)/2;return{x:n+Math.cos(u)*h,y:i+Math.sin(u)*h}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:n,circumference:i}=this,s=(n.offset||0)/4,o=(n.spacing||0)/2,r=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=i>Z?Math.floor(i/Z):0,i===0||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*s,Math.sin(a)*s);const c=1-Math.sin(Math.min(F,i||0)),l=s*c;t.fillStyle=n.backgroundColor,t.strokeStyle=n.borderColor,mm(t,this,l,o,r),bm(t,this,l,o,r),t.restore()}}function Ea(e,t,n=t){e.lineCap=z(n.borderCapStyle,t.borderCapStyle),e.setLineDash(z(n.borderDash,t.borderDash)),e.lineDashOffset=z(n.borderDashOffset,t.borderDashOffset),e.lineJoin=z(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=z(n.borderWidth,t.borderWidth),e.strokeStyle=z(n.borderColor,t.borderColor)}function _m(e,t,n){e.lineTo(n.x,n.y)}function xm(e){return e.stepped?Rf:e.tension||e.cubicInterpolationMode==="monotone"?Lf:_m}function za(e,t,n={}){const i=e.length,{start:s=0,end:o=i-1}=n,{start:r,end:a}=t,c=Math.max(s,r),l=Math.min(o,a),u=s<r&&o<r||s>a&&o>a;return{count:i,start:c,loop:t.loop,ilen:l<c&&!u?i+l-c:l-c}}function vm(e,t,n,i){const{points:s,options:o}=t,{count:r,start:a,loop:c,ilen:l}=za(s,n,i),u=xm(o);let{move:h=!0,reverse:d}=i||{},f,p,g;for(f=0;f<=l;++f)p=s[(a+(d?l-f:f))%r],!p.skip&&(h?(e.moveTo(p.x,p.y),h=!1):u(e,g,p,d,o.stepped),g=p);return c&&(p=s[(a+(d?l:0))%r],u(e,g,p,d,o.stepped)),!!c}function wm(e,t,n,i){const s=t.points,{count:o,start:r,ilen:a}=za(s,n,i),{move:c=!0,reverse:l}=i||{};let u=0,h=0,d,f,p,g,m,b;const y=x=>(r+(l?a-x:x))%o,w=()=>{g!==m&&(e.lineTo(u,m),e.lineTo(u,g),e.lineTo(u,b))};for(c&&(f=s[y(0)],e.moveTo(f.x,f.y)),d=0;d<=a;++d){if(f=s[y(d)],f.skip)continue;const x=f.x,_=f.y,k=x|0;k===p?(_<g?g=_:_>m&&(m=_),u=(h*u+x)/++h):(w(),e.lineTo(x,_),p=k,h=0,g=m=_),b=_}w()}function Ti(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?wm:vm}function km(e){return e.stepped?pp:e.tension||e.cubicInterpolationMode==="monotone"?gp:se}function Sm(e,t,n,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,n,i)&&s.closePath()),Ea(e,t.options),e.stroke(s)}function Mm(e,t,n,i){const{segments:s,options:o}=t,r=Ti(t);for(const a of s)Ea(e,o,a.style),e.beginPath(),r(e,t,a,{start:n,end:n+i-1})&&e.closePath(),e.stroke()}const Tm=typeof Path2D=="function";function Cm(e,t,n,i){Tm&&!t.options.segment?Sm(e,t,n,i):Mm(e,t,n,i)}class Hn extends Dt{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;rp(this._points,i,t,s,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=vp(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,i=t.length;return i&&n[t[i-1].end]}interpolate(t,n){const i=this.options,s=t[n],o=this.points,r=ga(this,{property:n,start:s,end:s});if(!r.length)return;const a=[],c=km(i);let l,u;for(l=0,u=r.length;l<u;++l){const{start:h,end:d}=r[l],f=o[h],p=o[d];if(f===p){a.push(f);continue}const g=Math.abs((s-f[n])/(p[n]-f[n])),m=c(f,p,g,i.stepped);m[n]=t[n],a.push(m)}return a.length===1?a[0]:a}pathSegment(t,n,i){return Ti(this)(t,this,n,i)}path(t,n,i){const s=this.segments,o=Ti(this);let r=this._loop;n=n||0,i=i||this.points.length-n;for(const a of s)r&=o(t,this,a,{start:n,end:n+i-1});return!!r}draw(t,n,i,s){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),Cm(t,this,i,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function To(e,t,n,i){const s=e.options,{[n]:o}=e.getProps([n],i);return Math.abs(t-o)<s.radius+s.hitRadius}class Pm extends Dt{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,n,i){const s=this.options,{x:o,y:r}=this.getProps(["x","y"],i);return Math.pow(t-o,2)+Math.pow(n-r,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,n){return To(this,t,"x",n)}inYRange(t,n){return To(this,t,"y",n)}getCenterPoint(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}size(t){t=t||this.options||{};let n=t.radius||0;n=Math.max(n,n&&t.hoverRadius||0);const i=n&&t.borderWidth||0;return(n+i)*2}draw(t,n){const i=this.options;this.skip||i.radius<.1||!It(this,n,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,ki(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}function Ia(e,t){const{x:n,y:i,base:s,width:o,height:r}=e.getProps(["x","y","base","width","height"],t);let a,c,l,u,h;return e.horizontal?(h=r/2,a=Math.min(n,s),c=Math.max(n,s),l=i-h,u=i+h):(h=o/2,a=n-h,c=n+h,l=Math.min(i,s),u=Math.max(i,s)),{left:a,top:l,right:c,bottom:u}}function Bt(e,t,n,i){return e?0:ot(t,n,i)}function Om(e,t,n){const i=e.options.borderWidth,s=e.borderSkipped,o=sa(i);return{t:Bt(s.top,o.top,0,n),r:Bt(s.right,o.right,0,t),b:Bt(s.bottom,o.bottom,0,n),l:Bt(s.left,o.left,0,t)}}function Em(e,t,n){const{enableBorderRadius:i}=e.getProps(["enableBorderRadius"]),s=e.options.borderRadius,o=oe(s),r=Math.min(t,n),a=e.borderSkipped,c=i||L(s);return{topLeft:Bt(!c||a.top||a.left,o.topLeft,0,r),topRight:Bt(!c||a.top||a.right,o.topRight,0,r),bottomLeft:Bt(!c||a.bottom||a.left,o.bottomLeft,0,r),bottomRight:Bt(!c||a.bottom||a.right,o.bottomRight,0,r)}}function zm(e){const t=Ia(e),n=t.right-t.left,i=t.bottom-t.top,s=Om(e,n/2,i/2),o=Em(e,n/2,i/2);return{outer:{x:t.left,y:t.top,w:n,h:i,radius:o},inner:{x:t.left+s.l,y:t.top+s.t,w:n-s.l-s.r,h:i-s.t-s.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(s.t,s.l)),topRight:Math.max(0,o.topRight-Math.max(s.t,s.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(s.b,s.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(s.b,s.r))}}}}function ai(e,t,n,i){const s=t===null,o=n===null,a=e&&!(s&&o)&&Ia(e,i);return a&&(s||Et(t,a.left,a.right))&&(o||Et(n,a.top,a.bottom))}function Im(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function Am(e,t){e.rect(t.x,t.y,t.w,t.h)}function ci(e,t,n={}){const i=e.x!==n.x?-t:0,s=e.y!==n.y?-t:0,o=(e.x+e.w!==n.x+n.w?t:0)-i,r=(e.y+e.h!==n.y+n.h?t:0)-s;return{x:e.x+i,y:e.y+s,w:e.w+o,h:e.h+r,radius:e.radius}}class Dm extends Dt{static id="bar";static defaults={borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.horizontal=void 0,this.base=void 0,this.width=void 0,this.height=void 0,this.inflateAmount=void 0,t&&Object.assign(this,t)}draw(t){const{inflateAmount:n,options:{borderColor:i,backgroundColor:s}}=this,{inner:o,outer:r}=zm(this),a=Im(r.radius)?Xe:Am;t.save(),(r.w!==o.w||r.h!==o.h)&&(t.beginPath(),a(t,ci(r,n,o)),t.clip(),a(t,ci(o,-n,r)),t.fillStyle=i,t.fill("evenodd")),t.beginPath(),a(t,ci(o,n)),t.fillStyle=s,t.fill(),t.restore()}inRange(t,n,i){return ai(this,t,n,i)}inXRange(t,n){return ai(this,t,null,n)}inYRange(t,n){return ai(this,null,t,n)}getCenterPoint(t){const{x:n,y:i,base:s,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(n+s)/2:n,y:o?i:(i+s)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}var Rm=Object.freeze({__proto__:null,ArcElement:ym,BarElement:Dm,LineElement:Hn,PointElement:Pm});const Ci=["rgb(54, 162, 235)","rgb(255, 99, 132)","rgb(255, 159, 64)","rgb(255, 205, 86)","rgb(75, 192, 192)","rgb(153, 102, 255)","rgb(201, 203, 207)"],Co=Ci.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function Aa(e){return Ci[e%Ci.length]}function Da(e){return Co[e%Co.length]}function Lm(e,t){return e.borderColor=Aa(t),e.backgroundColor=Da(t),++t}function $m(e,t){return e.backgroundColor=e.data.map(()=>Aa(t++)),t}function Fm(e,t){return e.backgroundColor=e.data.map(()=>Da(t++)),t}function Nm(e){let t=0;return(n,i)=>{const s=e.getDatasetMeta(i).controller;s instanceof Gi?t=$m(n,t):s instanceof xa?t=Fm(n,t):s&&(t=Lm(n,t))}}function Po(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function Bm(e){return e&&(e.borderColor||e.backgroundColor)}function jm(){return U.borderColor!=="rgba(0,0,0,0.1)"||U.backgroundColor!=="rgba(0,0,0,0.1)"}var Vm={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;const{data:{datasets:i},options:s}=e.config,{elements:o}=s,r=Po(i)||Bm(s)||o&&Po(o)||jm();if(!n.forceOverride&&r)return;const a=Nm(e);i.forEach(a)}};function Zm(e,t,n,i,s){const o=s.samples||i;if(o>=n)return e.slice(t,t+n);const r=[],a=(n-2)/(o-2);let c=0;const l=t+n-1;let u=t,h,d,f,p,g;for(r[c++]=e[u],h=0;h<o-2;h++){let m=0,b=0,y;const w=Math.floor((h+1)*a)+1+t,x=Math.min(Math.floor((h+2)*a)+1,n)+t,_=x-w;for(y=w;y<x;y++)m+=e[y].x,b+=e[y].y;m/=_,b/=_;const k=Math.floor(h*a)+1+t,S=Math.min(Math.floor((h+1)*a)+1,n)+t,{x:M,y:C}=e[u];for(f=p=-1,y=k;y<S;y++)p=.5*Math.abs((M-m)*(e[y].y-C)-(M-e[y].x)*(b-C)),p>f&&(f=p,d=e[y],g=y);r[c++]=d,u=g}return r[c++]=e[l],r}function Wm(e,t,n,i){let s=0,o=0,r,a,c,l,u,h,d,f,p,g;const m=[],b=t+n-1,y=e[t].x,x=e[b].x-y;for(r=t;r<t+n;++r){a=e[r],c=(a.x-y)/x*i,l=a.y;const _=c|0;if(_===u)l<p?(p=l,h=r):l>g&&(g=l,d=r),s=(o*s+a.x)/++o;else{const k=r-1;if(!R(h)&&!R(d)){const S=Math.min(h,d),M=Math.max(h,d);S!==f&&S!==k&&m.push({...e[S],x:s}),M!==f&&M!==k&&m.push({...e[M],x:s})}r>0&&k!==f&&m.push(e[k]),m.push(a),u=_,o=0,p=g=l,h=d=f=r}}return m}function Ra(e){if(e._decimated){const t=e._data;delete e._decimated,delete e._data,Object.defineProperty(e,"data",{configurable:!0,enumerable:!0,writable:!0,value:t})}}function Oo(e){e.data.datasets.forEach(t=>{Ra(t)})}function Hm(e,t){const n=t.length;let i=0,s;const{iScale:o}=e,{min:r,max:a,minDefined:c,maxDefined:l}=o.getUserBounds();return c&&(i=ot(zt(t,o.axis,r).lo,0,n-1)),l?s=ot(zt(t,o.axis,a).hi+1,i,n)-i:s=n-i,{start:i,count:s}}var Um={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){Oo(e);return}const i=e.width;e.data.datasets.forEach((s,o)=>{const{_data:r,indexAxis:a}=s,c=e.getDatasetMeta(o),l=r||s.data;if($e([a,e.options.indexAxis])==="y"||!c.controller.supportsDecimation)return;const u=e.scales[c.xAxisID];if(u.type!=="linear"&&u.type!=="time"||e.options.parsing)return;let{start:h,count:d}=Hm(c,l);const f=n.threshold||4*i;if(d<=f){Ra(s);return}R(r)&&(s._data=l,delete s.data,Object.defineProperty(s,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(g){this._data=g}}));let p;switch(n.algorithm){case"lttb":p=Zm(l,h,d,i,n);break;case"min-max":p=Wm(l,h,d,i);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}s._decimated=p})},destroy(e){Oo(e)}};function qm(e,t,n){const i=e.segments,s=e.points,o=t.points,r=[];for(const a of i){let{start:c,end:l}=a;l=Un(c,l,s);const u=Pi(n,s[c],s[l],a.loop);if(!t.segments){r.push({source:a,target:u,start:s[c],end:s[l]});continue}const h=ga(t,u);for(const d of h){const f=Pi(n,o[d.start],o[d.end],d.loop),p=pa(a,s,f);for(const g of p)r.push({source:g,target:d,start:{[n]:Eo(u,f,"start",Math.max)},end:{[n]:Eo(u,f,"end",Math.min)}})}}return r}function Pi(e,t,n,i){if(i)return;let s=t[e],o=n[e];return e==="angle"&&(s=ct(s),o=ct(o)),{property:e,start:s,end:o}}function Ym(e,t){const{x:n=null,y:i=null}=e||{},s=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Un(r,a,s);const c=s[r],l=s[a];i!==null?(o.push({x:c.x,y:i}),o.push({x:l.x,y:i})):n!==null&&(o.push({x:n,y:c.y}),o.push({x:n,y:l.y}))}),o}function Un(e,t,n){for(;t>e;t--){const i=n[t];if(!isNaN(i.x)&&!isNaN(i.y))break}return t}function Eo(e,t,n,i){return e&&t?i(e[n],t[n]):e?e[n]:t?t[n]:0}function La(e,t){let n=[],i=!1;return H(e)?(i=!0,n=e):n=Ym(e,t),n.length?new Hn({points:n,options:{tension:0},_loop:i,_fullLoop:i}):null}function zo(e){return e&&e.fill!==!1}function Xm(e,t,n){let s=e[t].fill;const o=[t];let r;if(!n)return s;for(;s!==!1&&o.indexOf(s)===-1;){if(!X(s))return s;if(r=e[s],!r)return!1;if(r.visible)return s;o.push(s),s=r.fill}return!1}function Jm(e,t,n){const i=tb(e);if(L(i))return isNaN(i.value)?!1:i;let s=parseFloat(i);return X(s)&&Math.floor(s)===s?Km(i[0],t,s,n):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function Km(e,t,n,i){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=i?!1:n}function Gm(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:L(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Qm(e,t,n){let i;return e==="start"?i=n:e==="end"?i=t.options.reverse?t.min:t.max:L(e)?i=e.value:i=t.getBaseValue(),i}function tb(e){const t=e.options,n=t.fill;let i=z(n&&n.target,n);return i===void 0&&(i=!!t.backgroundColor),i===!1||i===null?!1:i===!0?"origin":i}function eb(e){const{scale:t,index:n,line:i}=e,s=[],o=i.segments,r=i.points,a=nb(t,n);a.push(La({x:null,y:t.bottom},i));for(let c=0;c<o.length;c++){const l=o[c];for(let u=l.start;u<=l.end;u++)ib(s,r[u],a)}return new Hn({points:s,options:{}})}function nb(e,t){const n=[],i=e.getMatchingVisibleMetas("line");for(let s=0;s<i.length;s++){const o=i[s];if(o.index===t)break;o.hidden||n.unshift(o.dataset)}return n}function ib(e,t,n){const i=[];for(let s=0;s<n.length;s++){const o=n[s],{first:r,last:a,point:c}=sb(o,t,"x");if(!(!c||r&&a)){if(r)i.unshift(c);else if(e.push(c),!a)break}}e.push(...i)}function sb(e,t,n){const i=e.interpolate(t,n);if(!i)return{};const s=i[n],o=e.segments,r=e.points;let a=!1,c=!1;for(let l=0;l<o.length;l++){const u=o[l],h=r[u.start][n],d=r[u.end][n];if(Et(s,h,d)){a=s===h,c=s===d;break}}return{first:a,last:c,point:i}}class $a{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,i){const{x:s,y:o,radius:r}=this;return n=n||{start:0,end:Z},t.arc(s,o,r,n.end,n.start,!0),!i.bounds}interpolate(t){const{x:n,y:i,radius:s}=this,o=t.angle;return{x:n+Math.cos(o)*s,y:i+Math.sin(o)*s,angle:o}}}function ob(e){const{chart:t,fill:n,line:i}=e;if(X(n))return rb(t,n);if(n==="stack")return eb(e);if(n==="shape")return!0;const s=ab(e);return s instanceof $a?s:La(s,i)}function rb(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function ab(e){return(e.scale||{}).getPointPositionForValue?lb(e):cb(e)}function cb(e){const{scale:t={},fill:n}=e,i=Gm(n,t);if(X(i)){const s=t.isHorizontal();return{x:s?i:null,y:s?null:i}}return null}function lb(e){const{scale:t,fill:n}=e,i=t.options,s=t.getLabels().length,o=i.reverse?t.max:t.min,r=Qm(n,t,o),a=[];if(i.grid.circular){const c=t.getPointPositionForValue(0,o);return new $a({x:c.x,y:c.y,radius:t.getDistanceFromCenterForValue(r)})}for(let c=0;c<s;++c)a.push(t.getPointPositionForValue(c,r));return a}function li(e,t,n){const i=ob(t),{chart:s,index:o,line:r,scale:a,axis:c}=t,l=r.options,u=l.fill,h=l.backgroundColor,{above:d=h,below:f=h}=u||{},p=s.getDatasetMeta(o),g=ma(s,p);i&&r.points.length&&(jn(e,n),ub(e,{line:r,target:i,above:d,below:f,area:n,scale:a,axis:c,clip:g}),Vn(e))}function ub(e,t){const{line:n,target:i,above:s,below:o,area:r,scale:a,clip:c}=t,l=n._loop?"angle":t.axis;e.save();let u=o;o!==s&&(l==="x"?(Io(e,i,r.top),ui(e,{line:n,target:i,color:s,scale:a,property:l,clip:c}),e.restore(),e.save(),Io(e,i,r.bottom)):l==="y"&&(Ao(e,i,r.left),ui(e,{line:n,target:i,color:o,scale:a,property:l,clip:c}),e.restore(),e.save(),Ao(e,i,r.right),u=s)),ui(e,{line:n,target:i,color:u,scale:a,property:l,clip:c}),e.restore()}function Io(e,t,n){const{segments:i,points:s}=t;let o=!0,r=!1;e.beginPath();for(const a of i){const{start:c,end:l}=a,u=s[c],h=s[Un(c,l,s)];o?(e.moveTo(u.x,u.y),o=!1):(e.lineTo(u.x,n),e.lineTo(u.x,u.y)),r=!!t.pathSegment(e,a,{move:r}),r?e.closePath():e.lineTo(h.x,n)}e.lineTo(t.first().x,n),e.closePath(),e.clip()}function Ao(e,t,n){const{segments:i,points:s}=t;let o=!0,r=!1;e.beginPath();for(const a of i){const{start:c,end:l}=a,u=s[c],h=s[Un(c,l,s)];o?(e.moveTo(u.x,u.y),o=!1):(e.lineTo(n,u.y),e.lineTo(u.x,u.y)),r=!!t.pathSegment(e,a,{move:r}),r?e.closePath():e.lineTo(n,h.y)}e.lineTo(n,t.first().y),e.closePath(),e.clip()}function ui(e,t){const{line:n,target:i,property:s,color:o,scale:r,clip:a}=t,c=qm(n,i,s);for(const{source:l,target:u,start:h,end:d}of c){const{style:{backgroundColor:f=o}={}}=l,p=i!==!0;e.save(),e.fillStyle=f,hb(e,r,a,p&&Pi(s,h,d)),e.beginPath();const g=!!n.pathSegment(e,l);let m;if(p){g?e.closePath():Do(e,i,d,s);const b=!!i.pathSegment(e,u,{move:g,reverse:!0});m=g&&b,m||Do(e,i,h,s)}e.closePath(),e.fill(m?"evenodd":"nonzero"),e.restore()}}function hb(e,t,n,i){const s=t.chart.chartArea,{property:o,start:r,end:a}=i||{};if(o==="x"||o==="y"){let c,l,u,h;o==="x"?(c=r,l=s.top,u=a,h=s.bottom):(c=s.left,l=r,u=s.right,h=a),e.beginPath(),n&&(c=Math.max(c,n.left),u=Math.min(u,n.right),l=Math.max(l,n.top),h=Math.min(h,n.bottom)),e.rect(c,l,u-c,h-l),e.clip()}}function Do(e,t,n,i){const s=t.interpolate(n,i);s&&e.lineTo(s.x,s.y)}var db={id:"filler",afterDatasetsUpdate(e,t,n){const i=(e.data.datasets||[]).length,s=[];let o,r,a,c;for(r=0;r<i;++r)o=e.getDatasetMeta(r),a=o.dataset,c=null,a&&a.options&&a instanceof Hn&&(c={visible:e.isDatasetVisible(r),index:r,fill:Jm(a,r,i),chart:e,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=c,s.push(c);for(r=0;r<i;++r)c=s[r],!(!c||c.fill===!1)&&(c.fill=Xm(s,r,n.propagate))},beforeDraw(e,t,n){const i=n.drawTime==="beforeDraw",s=e.getSortedVisibleDatasetMetas(),o=e.chartArea;for(let r=s.length-1;r>=0;--r){const a=s[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),i&&a.fill&&li(e.ctx,a,o))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const i=e.getSortedVisibleDatasetMetas();for(let s=i.length-1;s>=0;--s){const o=i[s].$filler;zo(o)&&li(e.ctx,o,e.chartArea)}},beforeDatasetDraw(e,t,n){const i=t.meta.$filler;!zo(i)||n.drawTime!=="beforeDatasetDraw"||li(e.ctx,i,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Ro=(e,t)=>{let{boxHeight:n=t,boxWidth:i=t}=e;return e.usePointStyle&&(n=Math.min(n,t),i=e.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:n,itemHeight:Math.max(t,n)}},fb=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class Lo extends Dt{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,i){this.maxWidth=t,this.maxHeight=n,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=V(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(i=>t.filter(i,this.chart.data))),t.sort&&(n=n.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,s=st(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:c}=Ro(i,o);let l,u;n.font=s.string,this.isHorizontal()?(l=this.maxWidth,u=this._fitRows(r,o,a,c)+10):(u=this.maxHeight,l=this._fitCols(r,s,a,c)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,c=this.legendHitBoxes=[],l=this.lineWidths=[0],u=s+a;let h=t;o.textAlign="left",o.textBaseline="middle";let d=-1,f=-u;return this.legendItems.forEach((p,g)=>{const m=i+n/2+o.measureText(p.text).width;(g===0||l[l.length-1]+m+2*a>r)&&(h+=u,l[l.length-(g>0?0:1)]=0,f+=u,d++),c[g]={left:0,top:f,row:d,width:m,height:s},l[l.length-1]+=m+a}),h}_fitCols(t,n,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,c=this.legendHitBoxes=[],l=this.columnSizes=[],u=r-t;let h=a,d=0,f=0,p=0,g=0;return this.legendItems.forEach((m,b)=>{const{itemWidth:y,itemHeight:w}=pb(i,n,o,m,s);b>0&&f+w+2*a>u&&(h+=d+a,l.push({width:d,height:f}),p+=d+a,g++,d=f=0),c[b]={left:p,top:f,col:g,width:y,height:w},d=Math.max(d,y),f+=w+a}),h+=d,l.push({width:d,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:i,labels:{padding:s},rtl:o}}=this,r=xe(o,this.left,this.width);if(this.isHorizontal()){let a=0,c=at(i,this.left+s,this.right-this.lineWidths[a]);for(const l of n)a!==l.row&&(a=l.row,c=at(i,this.left+s,this.right-this.lineWidths[a])),l.top+=this.top+t+s,l.left=r.leftForLtr(r.x(c),l.width),c+=l.width+s}else{let a=0,c=at(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const l of n)l.col!==a&&(a=l.col,c=at(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),l.top=c,l.left+=this.left+s,l.left=r.leftForLtr(r.x(l.left),l.width),c+=l.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;jn(t,this),this._draw(),Vn(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=U.color,c=xe(t.rtl,this.left,this.width),l=st(r.font),{padding:u}=r,h=l.size,d=h/2;let f;this.drawTitle(),s.textAlign=c.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=l.string;const{boxWidth:p,boxHeight:g,itemHeight:m}=Ro(r,h),b=function(k,S,M){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;s.save();const C=z(M.lineWidth,1);if(s.fillStyle=z(M.fillStyle,a),s.lineCap=z(M.lineCap,"butt"),s.lineDashOffset=z(M.lineDashOffset,0),s.lineJoin=z(M.lineJoin,"miter"),s.lineWidth=C,s.strokeStyle=z(M.strokeStyle,a),s.setLineDash(z(M.lineDash,[])),r.usePointStyle){const I={radius:g*Math.SQRT2/2,pointStyle:M.pointStyle,rotation:M.rotation,borderWidth:C},A=c.xPlus(k,p/2),D=S+d;ia(s,I,A,D,r.pointStyleWidth&&p)}else{const I=S+Math.max((h-g)/2,0),A=c.leftForLtr(k,p),D=oe(M.borderRadius);s.beginPath(),Object.values(D).some(tt=>tt!==0)?Xe(s,{x:A,y:I,w:p,h:g,radius:D}):s.rect(A,I,p,g),s.fill(),C!==0&&s.stroke()}s.restore()},y=function(k,S,M){ce(s,M.text,k,S+m/2,l,{strikethrough:M.hidden,textAlign:c.textAlign(M.textAlign)})},w=this.isHorizontal(),x=this._computeTitleHeight();w?f={x:at(o,this.left+u,this.right-i[0]),y:this.top+u+x,line:0}:f={x:this.left+u,y:at(o,this.top+x+u,this.bottom-n[0].height),line:0},ha(this.ctx,t.textDirection);const _=m+u;this.legendItems.forEach((k,S)=>{s.strokeStyle=k.fontColor,s.fillStyle=k.fontColor;const M=s.measureText(k.text).width,C=c.textAlign(k.textAlign||(k.textAlign=r.textAlign)),I=p+d+M;let A=f.x,D=f.y;c.setWidth(this.width),w?S>0&&A+I+u>this.right&&(D=f.y+=_,f.line++,A=f.x=at(o,this.left+u,this.right-i[f.line])):S>0&&D+_>this.bottom&&(A=f.x=A+n[f.line].width+u,f.line++,D=f.y=at(o,this.top+x+u,this.bottom-n[f.line].height));const tt=c.x(A);if(b(tt,D,k),A=Sf(C,A+p+d,w?A+I:this.right,t.rtl),y(c.x(A),D,k),w)f.x+=I+u;else if(typeof k.text!="string"){const $=l.lineHeight;f.y+=Fa(k,$)+u}else f.y+=_}),da(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,i=st(n.font),s=ut(n.padding);if(!n.display)return;const o=xe(t.rtl,this.left,this.width),r=this.ctx,a=n.position,c=i.size/2,l=s.top+c;let u,h=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),u=this.top+l,h=at(t.align,h,this.right-d);else{const p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);u=l+at(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}const f=at(a,h,h+d);r.textAlign=o.textAlign(Wi(a)),r.textBaseline="middle",r.strokeStyle=n.color,r.fillStyle=n.color,r.font=i.string,ce(r,n.text,f,u,i)}_computeTitleHeight(){const t=this.options.title,n=st(t.font),i=ut(t.padding);return t.display?n.lineHeight+i.height:0}_getLegendItemAt(t,n){let i,s,o;if(Et(t,this.left,this.right)&&Et(n,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;i<o.length;++i)if(s=o[i],Et(t,s.left,s.left+s.width)&&Et(n,s.top,s.top+s.height))return this.legendItems[i]}return null}handleEvent(t){const n=this.options;if(!bb(t.type,n))return;const i=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const s=this._hoveredItem,o=fb(s,i);s&&!o&&V(n.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!o&&V(n.onHover,[t,i,this],this)}else i&&V(n.onClick,[t,i,this],this)}}function pb(e,t,n,i,s){const o=gb(i,e,t,n),r=mb(s,i,t.lineHeight);return{itemWidth:o,itemHeight:r}}function gb(e,t,n,i){let s=e.text;return s&&typeof s!="string"&&(s=s.reduce((o,r)=>o.length>r.length?o:r)),t+n.size/2+i.measureText(s).width}function mb(e,t,n){let i=e;return typeof t.text!="string"&&(i=Fa(t,n)),i}function Fa(e,t){const n=e.text?e.text.length:0;return t*n}function bb(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var yb={id:"legend",_element:Lo,start(e,t,n){const i=e.legend=new Lo({ctx:e.ctx,options:n,chart:e});lt.configure(e,i,n),lt.addBox(e,i)},stop(e){lt.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const i=e.legend;lt.configure(e,i,n),i.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const i=t.datasetIndex,s=n.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(c=>{const l=c.controller.getStyle(n?0:void 0),u=ut(l.borderWidth);return{text:t[c.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!c.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:l.borderColor,pointStyle:i||l.pointStyle,rotation:l.rotation,textAlign:s||l.textAlign,borderRadius:r&&(a||l.borderRadius),datasetIndex:c.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};class ts extends Dt{constructor(t){super(),this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n){const i=this.options;if(this.left=0,this.top=0,!i.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const s=H(i.text)?i.text.length:1;this._padding=ut(i.padding);const o=s*st(i.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=o:this.width=o}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:n,left:i,bottom:s,right:o,options:r}=this,a=r.align;let c=0,l,u,h;return this.isHorizontal()?(u=at(a,i,o),h=n+t,l=o-i):(r.position==="left"?(u=i+t,h=at(a,s,n),c=F*-.5):(u=o-t,h=at(a,n,s),c=F*.5),l=s-n),{titleX:u,titleY:h,maxWidth:l,rotation:c}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const i=st(n.font),o=i.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:c,rotation:l}=this._drawArgs(o);ce(t,n.text,0,0,i,{color:n.color,maxWidth:c,rotation:l,textAlign:Wi(n.align),textBaseline:"middle",translation:[r,a]})}}function _b(e,t){const n=new ts({ctx:e.ctx,options:t,chart:e});lt.configure(e,n,t),lt.addBox(e,n),e.titleBlock=n}var xb={id:"title",_element:ts,start(e,t,n){_b(e,n)},stop(e){const t=e.titleBlock;lt.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const i=e.titleBlock;lt.configure(e,i,n),i.options=n},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const yn=new WeakMap;var vb={id:"subtitle",start(e,t,n){const i=new ts({ctx:e.ctx,options:n,chart:e});lt.configure(e,i,n),lt.addBox(e,i),yn.set(e,i)},stop(e){lt.removeBox(e,yn.get(e)),yn.delete(e)},beforeUpdate(e,t,n){const i=yn.get(e);lt.configure(e,i,n),i.options=n},defaults:{align:"center",display:!1,font:{weight:"normal"},fullSize:!0,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Ne={average(e){if(!e.length)return!1;let t,n,i=new Set,s=0,o=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const c=a.tooltipPosition();i.add(c.x),s+=c.y,++o}}return o===0||i.size===0?!1:{x:[...i].reduce((a,c)=>a+c)/i.size,y:s/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,i=t.y,s=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=e.length;o<r;++o){const c=e[o].element;if(c&&c.hasValue()){const l=c.getCenterPoint(),u=vi(t,l);u<s&&(s=u,a=c)}}if(a){const c=a.tooltipPosition();n=c.x,i=c.y}return{x:n,y:i}}};function wt(e,t){return t&&(H(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Pt(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
40
+ `)>-1?e.split(`
41
+ `):e}function wb(e,t){const{element:n,datasetIndex:i,index:s}=t,o=e.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:e,label:r,parsed:o.getParsed(s),raw:e.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:n}}function $o(e,t){const n=e.chart.ctx,{body:i,footer:s,title:o}=e,{boxWidth:r,boxHeight:a}=t,c=st(t.bodyFont),l=st(t.titleFont),u=st(t.footerFont),h=o.length,d=s.length,f=i.length,p=ut(t.padding);let g=p.height,m=0,b=i.reduce((x,_)=>x+_.before.length+_.lines.length+_.after.length,0);if(b+=e.beforeBody.length+e.afterBody.length,h&&(g+=h*l.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){const x=t.displayColors?Math.max(a,c.lineHeight):c.lineHeight;g+=f*x+(b-f)*c.lineHeight+(b-1)*t.bodySpacing}d&&(g+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let y=0;const w=function(x){m=Math.max(m,n.measureText(x).width+y)};return n.save(),n.font=l.string,B(e.title,w),n.font=c.string,B(e.beforeBody.concat(e.afterBody),w),y=t.displayColors?r+2+t.boxPadding:0,B(i,x=>{B(x.before,w),B(x.lines,w),B(x.after,w)}),y=0,n.font=u.string,B(e.footer,w),n.restore(),m+=p.width,{width:m,height:g}}function kb(e,t){const{y:n,height:i}=t;return n<i/2?"top":n>e.height-i/2?"bottom":"center"}function Sb(e,t,n,i){const{x:s,width:o}=i,r=n.caretSize+n.caretPadding;if(e==="left"&&s+o+r>t.width||e==="right"&&s-o-r<0)return!0}function Mb(e,t,n,i){const{x:s,width:o}=n,{width:r,chartArea:{left:a,right:c}}=e;let l="center";return i==="center"?l=s<=(a+c)/2?"left":"right":s<=o/2?l="left":s>=r-o/2&&(l="right"),Sb(l,e,t,n)&&(l="center"),l}function Fo(e,t,n){const i=n.yAlign||t.yAlign||kb(e,n);return{xAlign:n.xAlign||t.xAlign||Mb(e,t,n,i),yAlign:i}}function Tb(e,t){let{x:n,width:i}=e;return t==="right"?n-=i:t==="center"&&(n-=i/2),n}function Cb(e,t,n){let{y:i,height:s}=e;return t==="top"?i+=n:t==="bottom"?i-=s+n:i-=s/2,i}function No(e,t,n,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=e,{xAlign:a,yAlign:c}=n,l=s+o,{topLeft:u,topRight:h,bottomLeft:d,bottomRight:f}=oe(r);let p=Tb(t,a);const g=Cb(t,c,l);return c==="center"?a==="left"?p+=l:a==="right"&&(p-=l):a==="left"?p-=Math.max(u,d)+s:a==="right"&&(p+=Math.max(h,f)+s),{x:ot(p,0,i.width-t.width),y:ot(g,0,i.height-t.height)}}function _n(e,t,n){const i=ut(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-i.right:e.x+i.left}function Bo(e){return wt([],Pt(e))}function Pb(e,t,n){return Yt(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function jo(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const Na={beforeTitle:Tt,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,i=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex<i)return n[t.dataIndex]}return""},afterTitle:Tt,beforeBody:Tt,beforeLabel:Tt,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return R(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:Tt,afterBody:Tt,beforeFooter:Tt,footer:Tt,afterFooter:Tt};function dt(e,t,n,i){const s=e[t].call(n,i);return typeof s>"u"?Na[t].call(n,i):s}class Vo extends Dt{static positioners=Ne;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&n.options.animation&&i.animations,o=new ba(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Pb(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:i}=n,s=dt(i,"beforeTitle",this,t),o=dt(i,"title",this,t),r=dt(i,"afterTitle",this,t);let a=[];return a=wt(a,Pt(s)),a=wt(a,Pt(o)),a=wt(a,Pt(r)),a}getBeforeBody(t,n){return Bo(dt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:i}=n,s=[];return B(t,o=>{const r={before:[],lines:[],after:[]},a=jo(i,o);wt(r.before,Pt(dt(a,"beforeLabel",this,o))),wt(r.lines,dt(a,"label",this,o)),wt(r.after,Pt(dt(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,n){return Bo(dt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:i}=n,s=dt(i,"beforeFooter",this,t),o=dt(i,"footer",this,t),r=dt(i,"afterFooter",this,t);let a=[];return a=wt(a,Pt(s)),a=wt(a,Pt(o)),a=wt(a,Pt(r)),a}_createItems(t){const n=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],c,l;for(c=0,l=n.length;c<l;++c)a.push(wb(this.chart,n[c]));return t.filter&&(a=a.filter((u,h,d)=>t.filter(u,h,d,i))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,i))),B(a,u=>{const h=jo(t.callbacks,u);s.push(dt(h,"labelColor",this,u)),o.push(dt(h,"labelPointStyle",this,u)),r.push(dt(h,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,n){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Ne[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const c=this._size=$o(this,i),l=Object.assign({},a,c),u=Fo(this.chart,i,l),h=No(i,l,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:h.x,y:h.y,width:c.width,height:c.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,i,s){const o=this.getCaretPosition(t,i,s);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:c,topRight:l,bottomLeft:u,bottomRight:h}=oe(a),{x:d,y:f}=t,{width:p,height:g}=n;let m,b,y,w,x,_;return o==="center"?(x=f+g/2,s==="left"?(m=d,b=m-r,w=x+r,_=x-r):(m=d+p,b=m+r,w=x-r,_=x+r),y=m):(s==="left"?b=d+Math.max(c,u)+r:s==="right"?b=d+p-Math.max(l,h)-r:b=this.caretX,o==="top"?(w=f,x=w-r,m=b-r,y=b+r):(w=f+g,x=w+r,m=b+r,y=b-r),_=w),{x1:m,x2:b,x3:y,y1:w,y2:x,y3:_}}drawTitle(t,n,i){const s=this.title,o=s.length;let r,a,c;if(o){const l=xe(i.rtl,this.x,this.width);for(t.x=_n(this,i.titleAlign,i),n.textAlign=l.textAlign(i.titleAlign),n.textBaseline="middle",r=st(i.titleFont),a=i.titleSpacing,n.fillStyle=i.titleColor,n.font=r.string,c=0;c<o;++c)n.fillText(s[c],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,c+1===o&&(t.y+=i.titleMarginBottom-a)}}_drawColorBox(t,n,i,s,o){const r=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:c,boxWidth:l}=o,u=st(o.bodyFont),h=_n(this,"left",o),d=s.x(h),f=c<u.lineHeight?(u.lineHeight-c)/2:0,p=n.y+f;if(o.usePointStyle){const g={radius:Math.min(l,c)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},m=s.leftForLtr(d,l)+l/2,b=p+c/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,ki(t,g,m,b),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,ki(t,g,m,b)}else{t.lineWidth=L(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const g=s.leftForLtr(d,l),m=s.leftForLtr(s.xPlus(d,1),l-2),b=oe(r.borderRadius);Object.values(b).some(y=>y!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Xe(t,{x:g,y:p,w:l,h:c,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),Xe(t,{x:m,y:p+1,w:l-2,h:c-2,radius:b}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(g,p,l,c),t.strokeRect(g,p,l,c),t.fillStyle=r.backgroundColor,t.fillRect(m,p+1,l-2,c-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,n,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:c,boxWidth:l,boxPadding:u}=i,h=st(i.bodyFont);let d=h.lineHeight,f=0;const p=xe(i.rtl,this.x,this.width),g=function(M){n.fillText(M,p.x(t.x+f),t.y+d/2),t.y+=d+o},m=p.textAlign(r);let b,y,w,x,_,k,S;for(n.textAlign=r,n.textBaseline="middle",n.font=h.string,t.x=_n(this,m,i),n.fillStyle=i.bodyColor,B(this.beforeBody,g),f=a&&m!=="right"?r==="center"?l/2+u:l+2+u:0,x=0,k=s.length;x<k;++x){for(b=s[x],y=this.labelTextColors[x],n.fillStyle=y,B(b.before,g),w=b.lines,a&&w.length&&(this._drawColorBox(n,t,x,p,i),d=Math.max(h.lineHeight,c)),_=0,S=w.length;_<S;++_)g(w[_]),d=h.lineHeight;B(b.after,g)}f=0,d=h.lineHeight,B(this.afterBody,g),t.y-=o}drawFooter(t,n,i){const s=this.footer,o=s.length;let r,a;if(o){const c=xe(i.rtl,this.x,this.width);for(t.x=_n(this,i.footerAlign,i),t.y+=i.footerMarginTop,n.textAlign=c.textAlign(i.footerAlign),n.textBaseline="middle",r=st(i.footerFont),n.fillStyle=i.footerColor,n.font=r.string,a=0;a<o;++a)n.fillText(s[a],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+i.footerSpacing}}drawBackground(t,n,i,s){const{xAlign:o,yAlign:r}=this,{x:a,y:c}=t,{width:l,height:u}=i,{topLeft:h,topRight:d,bottomLeft:f,bottomRight:p}=oe(s.cornerRadius);n.fillStyle=s.backgroundColor,n.strokeStyle=s.borderColor,n.lineWidth=s.borderWidth,n.beginPath(),n.moveTo(a+h,c),r==="top"&&this.drawCaret(t,n,i,s),n.lineTo(a+l-d,c),n.quadraticCurveTo(a+l,c,a+l,c+d),r==="center"&&o==="right"&&this.drawCaret(t,n,i,s),n.lineTo(a+l,c+u-p),n.quadraticCurveTo(a+l,c+u,a+l-p,c+u),r==="bottom"&&this.drawCaret(t,n,i,s),n.lineTo(a+f,c+u),n.quadraticCurveTo(a,c+u,a,c+u-f),r==="center"&&o==="left"&&this.drawCaret(t,n,i,s),n.lineTo(a,c+h),n.quadraticCurveTo(a,c,a+h,c),n.closePath(),n.fill(),s.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Ne[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=$o(this,t),c=Object.assign({},r,this._size),l=Fo(n,t,c),u=No(t,c,l,n);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=l.xAlign,this.yAlign=l.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(n);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=ut(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,n),ha(t,n.textDirection),o.y+=r.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),da(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const i=this._active,s=t.map(({datasetIndex:a,index:c})=>{const l=this.chart.getDatasetMeta(a);if(!l)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:l.data[c],index:c}}),o=!Cn(i,s),r=this._positionChanged(s,n);(o||r)&&(this._active=s,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,i=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,n,i),a=this._positionChanged(r,t),c=n||!Cn(r,o)||a;return c&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),c}_getActiveElements(t,n,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,n){const{caretX:i,caretY:s,options:o}=this,r=Ne[o.position].call(this,t,n);return r!==!1&&(i!==r.x||s!==r.y)}}var Ob={id:"tooltip",_element:Vo,positioners:Ne,afterInit(e,t,n){n&&(e.tooltip=new Vo({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Na},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]},Eb=Object.freeze({__proto__:null,Colors:Vm,Decimation:Um,Filler:db,Legend:yb,SubTitle:vb,Title:xb,Tooltip:Ob});const zb=(e,t,n,i)=>(typeof t=="string"?(n=e.push(t)-1,i.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Ib(e,t,n,i){const s=e.indexOf(t);if(s===-1)return zb(e,t,n,i);const o=e.lastIndexOf(t);return s!==o?n:s}const Ab=(e,t)=>e===null?null:ot(Math.round(e),0,t);function Zo(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class Db extends ue{static id="category";static defaults={ticks:{callback:Zo}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const i=this.getLabels();for(const{index:s,label:o}of n)i[s]===o&&i.splice(s,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(R(t))return null;const i=this.getLabels();return n=isFinite(n)&&i[n]===t?n:Ib(i,t,z(n,t),this._addedLabels),Ab(n,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(i=0),n||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,n=this.max,i=this.options.offset,s=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let r=t;r<=n;r++)s.push({value:r});return s}getLabelForValue(t){return Zo.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Rb(e,t){const n=[],{bounds:s,step:o,min:r,max:a,precision:c,count:l,maxTicks:u,maxDigits:h,includeBounds:d}=e,f=o||1,p=u-1,{min:g,max:m}=t,b=!R(r),y=!R(a),w=!R(l),x=(m-g)/(h+1);let _=Ls((m-g)/p/f)*f,k,S,M,C;if(_<1e-14&&!b&&!y)return[{value:g},{value:m}];C=Math.ceil(m/_)-Math.floor(g/_),C>p&&(_=Ls(C*_/p/f)*f),R(c)||(k=Math.pow(10,c),_=Math.ceil(_*k)/k),s==="ticks"?(S=Math.floor(g/_)*_,M=Math.ceil(m/_)*_):(S=g,M=m),b&&y&&o&&bf((a-r)/o,_/1e3)?(C=Math.round(Math.min((a-r)/_,u)),_=(a-r)/C,S=r,M=a):w?(S=b?r:S,M=y?a:M,C=l-1,_=(M-S)/C):(C=(M-S)/_,je(C,Math.round(C),_/1e3)?C=Math.round(C):C=Math.ceil(C));const I=Math.max($s(_),$s(S));k=Math.pow(10,R(c)?I:c),S=Math.round(S*k)/k,M=Math.round(M*k)/k;let A=0;for(b&&(d&&S!==r?(n.push({value:r}),S<r&&A++,je(Math.round((S+A*_)*k)/k,r,Wo(r,x,e))&&A++):S<r&&A++);A<C;++A){const D=Math.round((S+A*_)*k)/k;if(y&&D>a)break;n.push({value:D})}return y&&d&&M!==a?n.length&&je(n[n.length-1].value,a,Wo(a,x,e))?n[n.length-1].value=a:n.push({value:a}):(!y||M===a)&&n.push({value:M}),n}function Wo(e,t,{horizontal:n,minRotation:i}){const s=xt(i),o=(n?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+e).length;return Math.min(t/o,r)}class Dn extends ue{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return R(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=c=>s=n?s:c,a=c=>o=i?o:c;if(t){const c=Mt(s),l=Mt(o);c<0&&l<0?a(0):c>0&&l>0&&r(0)}if(s===o){let c=o===0?1:Math.abs(o*.05);a(o+c),t||r(s-c)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${i} would result generating up to ${s} ticks. Limiting to 1000.`),s=1e3)):(s=this.computeTickLimit(),n=n||11),n&&(s=Math.min(n,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},o=this._range||this,r=Rb(s,o);return t.bounds==="ticks"&&Yr(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let n=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-n)/Math.max(t.length-1,1)/2;n-=s,i+=s}this._startValue=n,this._endValue=i,this._valueRange=i-n}getLabelForValue(t){return Qe(t,this.chart.options.locale,this.options.ticks.format)}}class Lb extends Dn{static id="linear";static defaults={ticks:{callback:Bn.formatters.numeric}};determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=X(t)?t:0,this.max=X(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,i=xt(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Ke=e=>Math.floor(Ft(e)),ne=(e,t)=>Math.pow(10,Ke(e)+t);function Ho(e){return e/Math.pow(10,Ke(e))===1}function Uo(e,t,n){const i=Math.pow(10,n),s=Math.floor(e/i);return Math.ceil(t/i)-s}function $b(e,t){const n=t-e;let i=Ke(n);for(;Uo(e,t,i)>10;)i++;for(;Uo(e,t,i)<10;)i--;return Math.min(i,Ke(e))}function Fb(e,{min:t,max:n}){t=gt(e.min,t);const i=[],s=Ke(t);let o=$b(t,n),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),c=s>o?Math.pow(10,s):0,l=Math.round((t-c)*r)/r,u=Math.floor((t-c)/a/10)*a*10;let h=Math.floor((l-u)/Math.pow(10,o)),d=gt(e.min,Math.round((c+u+h*Math.pow(10,o))*r)/r);for(;d<n;)i.push({value:d,major:Ho(d),significand:h}),h>=10?h=h<15?15:20:h++,h>=20&&(o++,h=2,r=o>=0?1:r),d=Math.round((c+u+h*Math.pow(10,o))*r)/r;const f=gt(e.max,d);return i.push({value:f,major:Ho(f),significand:h}),i}class Nb extends ue{static id="logarithmic";static defaults={ticks:{callback:Bn.formatters.logarithmic,major:{enabled:!0}}};constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const i=Dn.prototype.parse.apply(this,[t,n]);if(i===0){this._zero=!0;return}return X(i)&&i>0?i:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=X(t)?Math.max(0,t):null,this.max=X(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!X(this._userMin)&&(this.min=t===ne(this.min,0)?ne(this.min,-1):ne(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let i=this.min,s=this.max;const o=a=>i=t?i:a,r=a=>s=n?s:a;i===s&&(i<=0?(o(1),r(10)):(o(ne(i,-1)),r(ne(s,1)))),i<=0&&o(ne(s,-1)),s<=0&&r(ne(i,1)),this.min=i,this.max=s}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},i=Fb(n,this);return t.bounds==="ticks"&&Yr(i,this,"value"),t.reverse?(i.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),i}getLabelForValue(t){return t===void 0?"0":Qe(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Ft(t),this._valueRange=Ft(this.max)-Ft(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Ft(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}function Oi(e){const t=e.ticks;if(t.display&&e.display){const n=ut(t.backdropPadding);return z(t.font&&t.font.size,U.font.size)+n.height}return 0}function Bb(e,t,n){return n=H(n)?n:[n],{w:Df(e,t.string,n),h:n.length*t.lineHeight}}function qo(e,t,n,i,s){return e===i||e===s?{start:t-n/2,end:t+n/2}:e<i||e>s?{start:t-n,end:t}:{start:t,end:t+n}}function jb(e){const t={l:e.left+e._padding.left,r:e.right-e._padding.right,t:e.top+e._padding.top,b:e.bottom-e._padding.bottom},n=Object.assign({},t),i=[],s=[],o=e._pointLabels.length,r=e.options.pointLabels,a=r.centerPointLabels?F/o:0;for(let c=0;c<o;c++){const l=r.setContext(e.getPointLabelContext(c));s[c]=l.padding;const u=e.getPointPosition(c,e.drawingArea+s[c],a),h=st(l.font),d=Bb(e.ctx,h,e._pointLabels[c]);i[c]=d;const f=ct(e.getIndexAngle(c)+a),p=Math.round(Vi(f)),g=qo(p,u.x,d.w,0,180),m=qo(p,u.y,d.h,90,270);Vb(n,t,f,g,m)}e.setCenterPoint(t.l-n.l,n.r-t.r,t.t-n.t,n.b-t.b),e._pointLabelItems=Hb(e,i,s)}function Vb(e,t,n,i,s){const o=Math.abs(Math.sin(n)),r=Math.abs(Math.cos(n));let a=0,c=0;i.start<t.l?(a=(t.l-i.start)/o,e.l=Math.min(e.l,t.l-a)):i.end>t.r&&(a=(i.end-t.r)/o,e.r=Math.max(e.r,t.r+a)),s.start<t.t?(c=(t.t-s.start)/r,e.t=Math.min(e.t,t.t-c)):s.end>t.b&&(c=(s.end-t.b)/r,e.b=Math.max(e.b,t.b+c))}function Zb(e,t,n){const i=e.drawingArea,{extra:s,additionalAngle:o,padding:r,size:a}=n,c=e.getPointPosition(t,i+s+r,o),l=Math.round(Vi(ct(c.angle+Q))),u=Yb(c.y,a.h,l),h=Ub(l),d=qb(c.x,a.w,h);return{visible:!0,x:c.x,y:u,textAlign:h,left:d,top:u,right:d+a.w,bottom:u+a.h}}function Wb(e,t){if(!t)return!0;const{left:n,top:i,right:s,bottom:o}=e;return!(It({x:n,y:i},t)||It({x:n,y:o},t)||It({x:s,y:i},t)||It({x:s,y:o},t))}function Hb(e,t,n){const i=[],s=e._pointLabels.length,o=e.options,{centerPointLabels:r,display:a}=o.pointLabels,c={extra:Oi(o)/2,additionalAngle:r?F/s:0};let l;for(let u=0;u<s;u++){c.padding=n[u],c.size=t[u];const h=Zb(e,u,c);i.push(h),a==="auto"&&(h.visible=Wb(h,l),h.visible&&(l=h))}return i}function Ub(e){return e===0||e===180?"center":e<180?"left":"right"}function qb(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function Yb(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function Xb(e,t,n){const{left:i,top:s,right:o,bottom:r}=n,{backdropColor:a}=t;if(!R(a)){const c=oe(t.borderRadius),l=ut(t.backdropPadding);e.fillStyle=a;const u=i-l.left,h=s-l.top,d=o-i+l.width,f=r-s+l.height;Object.values(c).some(p=>p!==0)?(e.beginPath(),Xe(e,{x:u,y:h,w:d,h:f,radius:c}),e.fill()):e.fillRect(u,h,d,f)}}function Jb(e,t){const{ctx:n,options:{pointLabels:i}}=e;for(let s=t-1;s>=0;s--){const o=e._pointLabelItems[s];if(!o.visible)continue;const r=i.setContext(e.getPointLabelContext(s));Xb(n,r,o);const a=st(r.font),{x:c,y:l,textAlign:u}=o;ce(n,e._pointLabels[s],c,l+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function Ba(e,t,n,i){const{ctx:s}=e;if(n)s.arc(e.xCenter,e.yCenter,t,0,Z);else{let o=e.getPointPosition(0,t);s.moveTo(o.x,o.y);for(let r=1;r<i;r++)o=e.getPointPosition(r,t),s.lineTo(o.x,o.y)}}function Kb(e,t,n,i,s){const o=e.ctx,r=t.circular,{color:a,lineWidth:c}=t;!r&&!i||!a||!c||n<0||(o.save(),o.strokeStyle=a,o.lineWidth=c,o.setLineDash(s.dash||[]),o.lineDashOffset=s.dashOffset,o.beginPath(),Ba(e,n,r,i),o.closePath(),o.stroke(),o.restore())}function Gb(e,t,n){return Yt(e,{label:n,index:t,type:"pointLabel"})}class Qb extends Dn{static id="radialLinear";static defaults={display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Bn.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}};static defaultRoutes={"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"};static descriptors={angleLines:{_fallback:"grid"}};constructor(t){super(t),this.xCenter=void 0,this.yCenter=void 0,this.drawingArea=void 0,this._pointLabels=[],this._pointLabelItems=[]}setDimensions(){const t=this._padding=ut(Oi(this.options)/2),n=this.width=this.maxWidth-t.width,i=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+i/2+t.top),this.drawingArea=Math.floor(Math.min(n,i)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=X(t)&&!isNaN(t)?t:0,this.max=X(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/Oi(this.options))}generateTickLabels(t){Dn.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,i)=>{const s=V(this.options.pointLabels.callback,[n,i],this);return s||s===0?s:""}).filter((n,i)=>this.chart.getDataVisibility(i))}fit(){const t=this.options;t.display&&t.pointLabels.display?jb(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,i,s){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((i-s)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,i,s))}getIndexAngle(t){const n=Z/(this._pointLabels.length||1),i=this.options.startAngle||0;return ct(t*n+xt(i))}getDistanceFromCenterForValue(t){if(R(t))return NaN;const n=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*n:(t-this.min)*n}getValueForDistanceFromCenter(t){if(R(t))return NaN;const n=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-n:this.min+n}getPointLabelContext(t){const n=this._pointLabels||[];if(t>=0&&t<n.length){const i=n[t];return Gb(this.getContext(),t,i)}}getPointPosition(t,n,i=0){const s=this.getIndexAngle(t)-Q+i;return{x:Math.cos(s)*n+this.xCenter,y:Math.sin(s)*n+this.yCenter,angle:s}}getPointPositionForValue(t,n){return this.getPointPosition(t,this.getDistanceFromCenterForValue(n))}getBasePosition(t){return this.getPointPositionForValue(t||0,this.getBaseValue())}getPointLabelPosition(t){const{left:n,top:i,right:s,bottom:o}=this._pointLabelItems[t];return{left:n,top:i,right:s,bottom:o}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const i=this.ctx;i.save(),i.beginPath(),Ba(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),i.closePath(),i.fillStyle=t,i.fill(),i.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:i,grid:s,border:o}=n,r=this._pointLabels.length;let a,c,l;if(n.pointLabels.display&&Jb(this,r),s.display&&this.ticks.forEach((u,h)=>{if(h!==0||h===0&&this.min<0){c=this.getDistanceFromCenterForValue(u.value);const d=this.getContext(h),f=s.setContext(d),p=o.setContext(d);Kb(this,f,c,r,p)}}),i.display){for(t.save(),a=r-1;a>=0;a--){const u=i.setContext(this.getPointLabelContext(a)),{color:h,lineWidth:d}=u;!d||!h||(t.lineWidth=d,t.strokeStyle=h,t.setLineDash(u.borderDash),t.lineDashOffset=u.borderDashOffset,c=this.getDistanceFromCenterForValue(n.reverse?this.min:this.max),l=this.getPointPosition(a,c),t.beginPath(),t.moveTo(this.xCenter,this.yCenter),t.lineTo(l.x,l.y),t.stroke())}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx,n=this.options,i=n.ticks;if(!i.display)return;const s=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(s),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,c)=>{if(c===0&&this.min>=0&&!n.reverse)return;const l=i.setContext(this.getContext(c)),u=st(l.font);if(o=this.getDistanceFromCenterForValue(this.ticks[c].value),l.showLabelBackdrop){t.font=u.string,r=t.measureText(a.label).width,t.fillStyle=l.backdropColor;const h=ut(l.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}ce(t,a.label,0,-o,u,{color:l.color,strokeColor:l.textStrokeColor,strokeWidth:l.textStrokeWidth})}),t.restore()}drawTitle(){}}const qn={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ft=Object.keys(qn);function Yo(e,t){return e-t}function Xo(e,t){if(R(t))return null;const n=e._adapter,{parser:i,round:s,isoWeekday:o}=e._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),X(r)||(r=typeof i=="string"?n.parse(r,i):n.parse(r)),r===null?null:(s&&(r=s==="week"&&(we(o)||o===!0)?n.startOf(r,"isoWeek",o):n.startOf(r,s)),+r)}function Jo(e,t,n,i){const s=ft.length;for(let o=ft.indexOf(e);o<s-1;++o){const r=qn[ft[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((n-t)/(a*r.size))<=i)return ft[o]}return ft[s-1]}function ty(e,t,n,i,s){for(let o=ft.length-1;o>=ft.indexOf(n);o--){const r=ft[o];if(qn[r].common&&e._adapter.diff(s,i,r)>=t-1)return r}return ft[n?ft.indexOf(n):0]}function ey(e){for(let t=ft.indexOf(e)+1,n=ft.length;t<n;++t)if(qn[ft[t]].common)return ft[t]}function Ko(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:i,hi:s}=Zi(n,t),o=n[i]>=t?n[i]:n[s];e[o]=!0}}function ny(e,t,n,i){const s=e._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,c;for(a=o;a<=r;a=+s.add(a,1,i))c=n[a],c>=0&&(t[c].major=!0);return t}function Go(e,t,n){const i=[],s={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],s[a]=r,i.push({value:a,major:!1});return o===0||!n?i:ny(e,i,s,n)}class Ei extends ue{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const i=t.time||(t.time={}),s=this._adapter=new ig._date(t.adapters.date);s.init(n),Be(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:Xo(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,i=t.time.unit||"day";let{min:s,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function c(l){!r&&!isNaN(l.min)&&(s=Math.min(s,l.min)),!a&&!isNaN(l.max)&&(o=Math.max(o,l.max))}(!r||!a)&&(c(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&c(this.getMinMax(!1))),s=X(s)&&!isNaN(s)?s:+n.startOf(Date.now(),i),o=X(o)&&!isNaN(o)?o:+n.endOf(Date.now(),i)+1,this.min=Math.min(s,o-1),this.max=Math.max(s+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],i=t[t.length-1]),{min:n,max:i}}buildTicks(){const t=this.options,n=t.time,i=t.ticks,s=i.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const o=this.min,r=this.max,a=vf(s,o,r);return this._unit=n.unit||(i.autoSkip?Jo(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):ty(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!i.major.enabled||this._unit==="year"?void 0:ey(this._unit),this.initOffsets(s),t.reverse&&a.reverse(),Go(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?n=1-s:n=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;n=ot(n,0,r),i=ot(i,0,r),this._offsets={start:n,end:i,factor:1/(n+1+i)}}_generate(){const t=this._adapter,n=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||Jo(o.minUnit,n,i,this._getLabelCapacity(n)),a=z(s.ticks.stepSize,1),c=r==="week"?o.isoWeekday:!1,l=we(c)||c===!0,u={};let h=n,d,f;if(l&&(h=+t.startOf(h,"isoWeek",c)),h=+t.startOf(h,l?"day":r),t.diff(i,n,r)>1e5*a)throw new Error(n+" and "+i+" are too far apart with stepSize of "+a+" "+r);const p=s.ticks.source==="data"&&this.getDataTimestamps();for(d=h,f=0;d<i;d=+t.add(d,a,r),f++)Ko(u,d,p);return(d===i||s.bounds==="ticks"||f===1)&&Ko(u,d,p),Object.keys(u).sort(Yo).map(g=>+g)}getLabelForValue(t){const n=this._adapter,i=this.options.time;return i.tooltipFormat?n.format(t,i.tooltipFormat):n.format(t,i.displayFormats.datetime)}format(t,n){const s=this.options.time.displayFormats,o=this._unit,r=n||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,n,i,s){const o=this.options,r=o.ticks.callback;if(r)return V(r,[t,n,i],this);const a=o.time.displayFormats,c=this._unit,l=this._majorUnit,u=c&&a[c],h=l&&a[l],d=i[n],f=l&&h&&d&&d.major;return this._adapter.format(t,s||(f?h:u))}generateTickLabels(t){let n,i,s;for(n=0,i=t.length;n<i;++n)s=t[n],s.label=this._tickFormatFunction(s.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+i)*n.factor)}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,i=this.ctx.measureText(t).width,s=xt(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(s),r=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:i*o+a*r,h:i*r+a*o}}_getLabelCapacity(t){const n=this.options.time,i=n.displayFormats,s=i[n.unit]||i.millisecond,o=this._tickFormatFunction(t,0,Go(this,[t],this._majorUnit),s),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(n=0,i=s.length;n<i;++n)t=t.concat(s[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,i;if(t.length)return t;const s=this.getLabels();for(n=0,i=s.length;n<i;++n)t.push(Xo(this,s[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return Kr(t.sort(Yo))}}function xn(e,t,n){let i=0,s=e.length-1,o,r,a,c;n?(t>=e[i].pos&&t<=e[s].pos&&({lo:i,hi:s}=zt(e,"pos",t)),{pos:o,time:a}=e[i],{pos:r,time:c}=e[s]):(t>=e[i].time&&t<=e[s].time&&({lo:i,hi:s}=zt(e,"time",t)),{time:o,pos:a}=e[i],{time:r,pos:c}=e[s]);const l=r-o;return l?a+(c-a)*(t-o)/l:a}class iy extends Ei{static id="timeseries";static defaults=Ei.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=xn(n,this.min),this._tableRange=xn(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:i}=this,s=[],o=[];let r,a,c,l,u;for(r=0,a=t.length;r<a;++r)l=t[r],l>=n&&l<=i&&s.push(l);if(s.length<2)return[{time:n,pos:0},{time:i,pos:1}];for(r=0,a=s.length;r<a;++r)u=s[r+1],c=s[r-1],l=s[r],Math.round((u+c)/2)!==l&&o.push({time:l,pos:r/(a-1)});return o}_generate(){const t=this.min,n=this.max;let i=super.getDataTimestamps();return(!i.includes(t)||!i.length)&&i.splice(0,0,t),(!i.includes(n)||i.length===1)&&i.push(n),i.sort((s,o)=>s-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),i=this.getLabelTimestamps();return n.length&&i.length?t=this.normalize(n.concat(i)):t=n.length?n:i,t=this._cache.all=t,t}getDecimalForValue(t){return(xn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return xn(this._table,i*this._tableRange+this._minPos,!0)}}var sy=Object.freeze({__proto__:null,CategoryScale:Db,LinearScale:Lb,LogarithmicScale:Nb,RadialLinearScale:Qb,TimeScale:Ei,TimeSeriesScale:iy});const oy=[ng,Rm,Eb,sy];ye.register(...oy);function ry(e){return{gridColor:e?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",textColor:e?"#94a3b8":"#475569"}}function ay(e){const t=document.body.classList.contains("dark"),n=ry(t),i=document.getElementById("memory-chart");if(i){const a={labels:[],datasets:[{label:"Memory Usage (%)",data:[],backgroundColor:"rgba(16, 185, 129, 0.1)",borderColor:"#10b981",borderWidth:2,fill:!0,tension:.4}]},c={responsive:!0,maintainAspectRatio:!1,scales:{x:{grid:{color:n.gridColor},ticks:{display:!1,color:n.textColor,maxRotation:0,autoSkip:!0,maxTicksLimit:10},title:{display:!1,text:"Time",color:n.textColor}},y:{display:!0,beginAtZero:!0,max:100,grid:{color:n.gridColor},border:{display:!0,color:n.gridColor},ticks:{display:!0,color:n.textColor,stepSize:25,callback:function(u){return String(u)+"%"}},title:{display:!1,text:"Memory %",color:n.textColor}}},layout:{padding:0},plugins:{legend:{display:!1},tooltip:{enabled:!0,position:"nearest",intersect:!1}}},l=new ye(i,{type:"line",data:a,options:c});e.charts.memory={data:a,options:c,update:()=>l.update()}}const s=document.getElementById("cpu-chart");if(s){const a={labels:[],datasets:[{label:"CPU Usage (%)",data:[],backgroundColor:"rgba(16, 185, 129, 0.1)",borderColor:"#10b981",borderWidth:2,fill:!0,tension:.4}]},c={responsive:!0,maintainAspectRatio:!1,scales:{x:{grid:{color:n.gridColor},ticks:{display:!1,color:n.textColor,maxRotation:0,autoSkip:!0,maxTicksLimit:10},title:{display:!1,text:"Time",color:n.textColor}},y:{display:!0,beginAtZero:!0,max:100,grid:{color:n.gridColor},border:{display:!0,color:n.gridColor},ticks:{display:!0,color:n.textColor,stepSize:25,callback:function(u){return String(u)+"%"}},title:{display:!1,text:"Cpu %",color:n.textColor}}},layout:{padding:0},plugins:{legend:{display:!1},tooltip:{enabled:!0,position:"nearest",intersect:!1}}},l=new ye(s,{type:"line",data:a,options:c});e.charts.cpu={data:a,options:c,update:()=>l.update()}}const o=document.getElementById("traffic-chart");if(o){const a={labels:[],datasets:[{label:"Requests/s",data:[],borderColor:"#3b82f6",backgroundColor:"rgba(59, 130, 246, 0.1)",fill:!0,tension:.4,yAxisID:"y"},{label:"Avg Response Time (ms)",data:[],borderColor:"#10b981",backgroundColor:"rgba(16, 185, 129, 0.1)",fill:!0,tension:.4,yAxisID:"y1"}]},c={responsive:!0,maintainAspectRatio:!1,scales:{x:{grid:{color:n.gridColor},ticks:{display:!1,color:n.textColor,maxRotation:0,autoSkip:!0,maxTicksLimit:10},title:{display:!0,text:"Time",color:n.textColor}},y:{type:"linear",display:!0,position:"left",grid:{color:n.gridColor},ticks:{color:n.textColor},beginAtZero:!0,title:{display:!0,text:"Requests/s",color:n.textColor}},y1:{type:"linear",display:!0,position:"right",grid:{drawOnChartArea:!1,color:n.gridColor},ticks:{color:"#10b981"},beginAtZero:!0,title:{display:!0,text:"Avg Response Time (ms)",color:"#10b981"}}},plugins:{legend:{labels:{color:n.textColor}}}},l=new ye(o,{type:"line",data:a,options:c});e.charts.traffic={data:a,options:c,update:()=>l.update()}}const r=document.getElementById("pool-chart");if(r){const a={labels:[],datasets:[]},c={responsive:!0,maintainAspectRatio:!1,scales:{x:{grid:{color:n.gridColor},ticks:{display:!1,color:n.textColor,maxRotation:0,autoSkip:!0,maxTicksLimit:10},title:{display:!0,text:"Time",color:n.textColor}},y:{grid:{color:n.gridColor},ticks:{color:n.textColor},beginAtZero:!0,title:{display:!0,text:"Connections",color:n.textColor}}},plugins:{legend:{labels:{color:n.textColor}}}},l=new ye(r,{type:"line",data:a,options:c});e.charts.pool={data:a,options:c,update:()=>l.update()}}}function cy(e,t){e.history.labels=[],e.history.requests=[],e.history.avgResponseTimes=[],e.history.p95ResponseTimes=[],e.history.p99ResponseTimes=[],e.history.cpuUsage=[],e.history.memoryUsage=[],e.history.poolUsage={};const n=e.maxHistoryPoints,i=t.slice(-n),s=(e.status.intervalMs??5e3)/1e3;i.forEach(l=>{const u=new Date(l.timestamp).toLocaleTimeString();e.history.labels.push(u),e.history.requests.push(l.requests/s),e.history.avgResponseTimes.push(l.durationAvg),e.history.p95ResponseTimes??=[],e.history.p95ResponseTimes.push(l.durationP95),e.history.p99ResponseTimes??=[],e.history.p99ResponseTimes.push(l.durationP99);const h=e.status.system?.memory.totalMemory??0;e.history.cpuUsage.push(l.system.cpu),e.history.memoryUsage.push(h>0?l.system.rss/h*100:0),l.pools.forEach(d=>{e.history.poolUsage[d.name]??=[],e.history.poolUsage[d.name]?.push(d.connectionsInUse)})});const o=e.charts.traffic;if(o){o.data.labels=e.history.labels;const l=o.data.datasets[0],u=o.data.datasets[1];l&&(l.data=e.history.requests),u&&(u.data=e.history.avgResponseTimes),o.update()}const r=e.charts.pool;r&&(r.data.labels=e.history.labels,Object.entries(e.history.poolUsage).forEach(([l,u],h)=>{let d=r.data.datasets.find(f=>f.label===l);if(d)d.data=u;else{const f=["#10b981","#f59e0b","#3b82f6","#8b5cf6","#ec4899"],p=f[h%f.length]??"#3b82f6";d={label:l,data:u,borderColor:p,backgroundColor:void 0,fill:void 0,tension:.4},r.data.datasets.push(d)}}),r.update());const a=e.charts.memory;a&&(a.data.labels=e.history.labels,a.data.datasets[0]&&(a.data.datasets[0].data=e.history.memoryUsage),a.update());const c=e.charts.cpu;c&&(c.data.labels=e.history.labels,c.data.datasets[0]&&(c.data.datasets[0].data=e.history.cpuUsage),c.update())}function Qo(e,t,n,i,s){const o=e.maxHistoryPoints;e.history.labels.push(t),e.history.requests.push(n),e.history.avgResponseTimes.push(i);const r=e.status.system?.memory.totalMemory??0,a=e.status.history?.[e.status.history.length-1];a?(e.history.cpuUsage.push(a.system.cpu),e.history.memoryUsage.push(r>0?a.system.rss/r*100:0)):(e.history.cpuUsage.push(0),e.history.memoryUsage.push(0)),e.history.labels.length>o&&(e.history.labels.shift(),e.history.requests.shift(),e.history.avgResponseTimes.shift(),e.history.cpuUsage.shift(),e.history.memoryUsage.shift());const c=e.charts.traffic;c?.data.datasets[0]&&c.data.datasets[1]&&(c.data.labels=e.history.labels,c.data.datasets[0].data=e.history.requests,c.data.datasets[1].data=e.history.avgResponseTimes,c.update());const l=e.charts.memory;l?.data.datasets[0]&&(l.data.labels=e.history.labels,l.data.datasets[0].data=e.history.memoryUsage,l.update());const u=e.charts.cpu;u?.data.datasets[0]&&(u.data.labels=e.history.labels,u.data.datasets[0].data=e.history.cpuUsage,u.update());const h=e.charts.pool;h&&(h.data.labels=e.history.labels,s.forEach((d,f)=>{const p=d.name,g=e.history;let m=g.poolUsage[p];if(!m){m=[],g.poolUsage[p]=m;const b=["#10b981","#f59e0b","#3b82f6","#8b5cf6","#ec4899"],y=b[f%b.length]??"#3b82f6";y&&h.data.datasets.push({label:p,data:m,borderColor:y,backgroundColor:void 0,fill:void 0,tension:.4})}m.push(d.connectionsInUse),m.length>o&&m.shift()}),h.update())}function es(e){if(e<1)return ns(e*1e3);const t=Math.floor(e/(3600*24)),n=Math.floor(e%(3600*24)/3600),i=Math.floor(e%3600/60),s=Math.floor(e%60),o=[];return t>0&&o.push(`${t}d`),n>0&&o.push(`${n}h`),i>0&&o.push(`${i}m`),(s>0||o.length===0)&&o.push(`${s}s`),o.join(" ")}function ns(e){return e===0?"0 ms":e<1?`${(e*1e3).toFixed(0)} μs`:e<1e3?`${e.toFixed(2)} ms`:es(e/1e3)}function ja(e){return e?new Date(e).toLocaleString():"-"}function ly(e,t,n){Object.keys(e).forEach(s=>{const o=e[s],r=t[s],a=n[s];(r===void 0||o<r)&&(t[s]=o),(a===void 0||o>a)&&(n[s]=o)})}function uy(e){return{gridColor:e?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",textColor:e?"#94a3b8":"#475569"}}function hy(e,t){if(!e.options.scales)return;const n=e.options.scales;n.x&&(n.x.grid&&(n.x.grid.color=t.gridColor),n.x.ticks&&(n.x.ticks.color=t.textColor)),n.y?.grid&&(n.y.grid.color=t.gridColor),n.y?.ticks&&(n.y.ticks.color=t.textColor),n.y1?.grid&&(n.y1.grid.color=t.gridColor),n.y1?.ticks&&(n.y1.ticks.color=t.textColor),n.y?.title&&(n.y.title.color=t.textColor),n.y1?.title&&(n.y1.title.color=t.textColor),e.options.plugins?.legend?.labels&&(e.options.plugins.legend.labels.color=t.textColor),e.update()}function dy(e){const t=localStorage.getItem("theme")??"dark",n=document.getElementById("theme-toggle-btn");n&&(document.body.className=t,n.onclick=()=>{const s=document.body.classList.contains("dark")?"light":"dark";document.body.className=s,localStorage.setItem("theme",s);const o=uy(s==="dark");Object.values(e.charts).forEach(r=>{const a=r;a?.options&&hy(a,o)})})}function fy(e){const t=e.connectionsOpen>0?Math.round(e.connectionsInUse/e.connectionsOpen*100):0,n=t>90?"var(--danger)":t>70?"var(--warning)":"var(--success)",i=e.stats??void 0;return`
42
+ <div class="card card-clickable transition-all duration-200" title="Connection pool status for ${e.name}">
43
+ <div class="card-header">
44
+ <span class="material-symbols-rounded">database</span>
45
+ <h3 class="text-lg font-bold text-bright">${e.name}</h3>
46
+ </div>
47
+ <div class="mb-6" title="Utilization: ${t}% of open connections are currently in use">
48
+ <div class="flex justify-between items-baseline mb-2">
49
+ <span class="text-3xl font-bold text-bright">${t}%</span>
50
+ <span class="text-main font-mono">${e.connectionsInUse} / ${e.connectionsOpen}</span>
51
+ </div>
52
+ <div class="progress-bar">
53
+ <div class="progress-bar-fill transition-all duration-300" style="width: ${t}%; background: ${n}"></div>
54
+ </div>
55
+ <small class="description mt-2 block opacity-75">Pool Utilization (Active / Open)</small>
56
+ </div>
57
+
58
+ <div class="stat-row text-sm" title="Total number of connections currently open in the pool">
59
+ <span class="text-xs uppercase font-bold opacity-75">Connections Open</span>
60
+ <span class="font-mono text-accent font-bold">${e.connectionsOpen}</span>
61
+ </div>
62
+ <div class="stat-row text-sm" title="Number of connections currently active and handling requests">
63
+ <span class="text-xs uppercase font-bold opacity-75">Connections In Use</span>
64
+ <span class="font-mono text-accent font-bold">${e.connectionsInUse}</span>
65
+ </div>
66
+
67
+ ${i?`
68
+ <div class="mt-4 pt-4 border-t">
69
+ <div class="stat-row text-sm" title="Cumulative number of requests handled by this pool since server start">
70
+ <span>Total Requests</span>
71
+ <span class="font-mono text-accent font-bold">${i.totalRequests.toLocaleString()}</span>
72
+ </div>
73
+ <div class="stat-row text-sm" title="Number of requests that timed out waiting for a connection">
74
+ <span>Total Timeouts</span>
75
+ <span class="font-mono ${i.totalTimeouts>0?"text-danger":"text-accent"} font-bold">${i.totalTimeouts.toLocaleString()}</span>
76
+ </div>
77
+ </div>
78
+ `:""}
79
+ </div>
80
+ `}function it(e,t,n=!0,i="text-accent",s=""){const o=`${n?"font-mono":""} ${i} font-bold break-all`.trim();return`
81
+ <div class="stat-row text-sm" ${s?`title="${s}"`:""}>
82
+ <span>${e}</span>
83
+ <span class="${o}">${t}</span>
84
+ </div>
85
+ `}function tr(e,t){return`
86
+ <div class="card-header mt-6 mb-2">
87
+ <span class="material-symbols-rounded icon-sm">${t}</span>
88
+ <h3 class="text-xs uppercase tracking-wider font-bold text-accent">${e}</h3>
89
+ </div>
90
+ `}function py(e,t){const n=e.exclusionList?.length?e.exclusionList.join(", "):"(None)",i=typeof e.transactionMode=="string"?e.transactionMode:e.transactionMode?"Custom":"commit";return`
91
+ <div class="card mb-6">
92
+ <div class="flex justify-between items-center mb-4">
93
+ <div class="flex items-center gap-3">
94
+ <span class="badge badge-info">PL/SQL Route #${t+1}</span>
95
+ <code class="text-lg font-bold text-bright">${e.route}</code>
96
+ </div>
97
+ </div>
98
+
99
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
100
+ <div>
101
+ <h4 class="text-xs font-bold text-main uppercase mb-3 opacity-75">Database Connection</h4>
102
+ ${it("Oracle User",e.user??"(Not set)")}
103
+ ${it("Connect String",e.connectString??"(Not set)")}
104
+ ${it("Password",e.password??"(None)")}
105
+ </div>
106
+ <div>
107
+ <h4 class="text-xs font-bold text-main uppercase mb-3 opacity-75">Request Handler</h4>
108
+ ${it("Default Page",e.defaultPage??"index")}
109
+ ${it("Document Table",e.documentTable??"(None)")}
110
+ ${it("Error Style",e.errorStyle??"table")}
111
+ ${it("Transaction Mode",i)}
112
+ </div>
113
+ </div>
114
+
115
+ <div class="mt-4 pt-4 border-t">
116
+ <h4 class="text-xs font-bold text-main uppercase mb-3 opacity-75">Path & Validation</h4>
117
+ ${it("Path Alias",e.pathAlias??"(None)")}
118
+ ${it("Path Alias Proc",e.pathAliasProcedure??"(None)")}
119
+ ${it("Exclusion List",n)}
120
+ ${it("Validation Func",e.requestValidationFunction??"(None)")}
121
+ </div>
122
+ </div>
123
+ `}function gy(e,t){return`
124
+ <div class="card mb-4">
125
+ <div class="flex items-center gap-3 mb-4">
126
+ <span class="badge badge-success">Static Route #${t+1}</span>
127
+ <code class="text-lg font-bold text-bright">${e.route}</code>
128
+ </div>
129
+ ${it("Directory Path",e.directoryPath??"(Not set)")}
130
+ </div>
131
+ `}function my(e){let t='<div class="config-view-content">';if(t+='<div class="card mb-8">',t+='<div class="card-header"><span class="material-symbols-rounded">dns</span><h3>Server Settings</h3></div>',typeof e.port=="number"&&(t+=it("Port",e.port,!0,"text-accent","The TCP port the server is listening on")),t+=it("Admin Route",e.adminRoute??"/admin",!0,"text-accent","The URL path for the administration console"),t+=it("Admin User",e.adminUser??"(Not authenticated)",!0,"text-accent","The username required for admin access"),t+=it("Admin Password",e.adminPassword??"(None)",!0,"text-accent","The password required for admin access"),t+=it("Logger Filename",e.loggerFilename??"(Logging disabled)",!0,"text-accent","The path to the server log file"),typeof e.uploadFileSizeLimit=="number"){const n=e.uploadFileSizeLimit,i=(n/(1024*1024)).toFixed(2);t+=it("Upload Size Limit",`${i} MB (${n.toLocaleString()} bytes)`,!0,"text-accent","Maximum allowed size for file uploads")}else t+=it("Upload Size Limit","No limit",!1,"text-accent","Maximum allowed size for file uploads");return t+="</div>",t+=tr("PL/SQL Routes","database"),e.routePlSql?.length?t+=e.routePlSql.map((n,i)=>py(n,i)).join(""):t+='<div class="empty-state">No PL/SQL routes configured</div>',t+=tr("Static Routes","folder_shared"),e.routeStatic?.length?t+=e.routeStatic.map((n,i)=>gy(n,i)).join(""):t+='<div class="empty-state">No static routes configured</div>',t+="</div>",t}class Va{constructor(t,n){this.elementId=t,this.options=n,this.element=null}render(t){this.element=document.getElementById(this.elementId),this.element&&(this.options.dense?this.element.classList.add("dense-table"):this.element.classList.remove("dense-table"),this.renderHeader(),this.renderBody(t))}renderHeader(){if(!this.element)return;let t=this.element.querySelector("thead");t||(t=document.createElement("thead"),this.element.appendChild(t)),t.innerHTML="";const n=document.createElement("tr");this.options.columns.forEach(i=>{const s=document.createElement("th");s.textContent=i.header,i.headerTitle&&(s.title=i.headerTitle),i.width&&(s.style.width=i.width),i.align&&(s.style.textAlign=i.align),n.appendChild(s)}),t.appendChild(n)}renderBody(t){if(!this.element)return;let n=this.element.querySelector("tbody");n||(n=document.createElement("tbody"),this.element.appendChild(n)),n.innerHTML="",t.forEach(i=>{const s=document.createElement("tr");this.options.onRowClick&&(s.style.cursor="pointer",s.addEventListener("click",()=>{this.options.onRowClick&&this.options.onRowClick(i)}),s.classList.add("table-row-hover")),this.options.columns.forEach(o=>{const r=document.createElement("td");if(o.render)r.innerHTML=o.render(i);else if(o.accessor){const a=o.accessor(i);r.textContent=a!=null?String(a):""}if(o.className){const a=typeof o.className=="function"?o.className(i):o.className;a&&(r.className=a)}o.align&&(r.style.textAlign=o.align),o.cellTitle&&(r.title=o.cellTitle(i)),s.appendChild(r)}),n.appendChild(s)})}}async function Yn(){const e=document.getElementById("error-filter"),t=document.getElementById("error-limit"),n=e?.value??"",i=t?parseInt(t.value):100,s=await bt.getErrorLogs(i,n),o=[{id:"timestamp",header:"Timestamp",headerTitle:"When the error occurred",accessor:c=>new Date(c.timestamp).toLocaleString(),cellTitle:c=>new Date(c.timestamp).toLocaleString()},{id:"method",header:"Method",headerTitle:"HTTP method used",render:c=>`<code>${c.req?.method??"-"}</code>`,cellTitle:c=>`Method: ${c.req?.method??"-"}`},{id:"url",header:"URL",headerTitle:"Requested URL",accessor:c=>c.req?.url??"-",cellTitle:c=>`URL: ${c.req?.url??"-"}`},{id:"message",header:"Message",headerTitle:"Error message summary",accessor:c=>c.message,className:"break-all",cellTitle:c=>`Click for details: ${c.details?.fullMessage??""}`},{id:"action",header:"",width:"40px",align:"center",render:()=>'<span class="material-symbols-rounded">chevron_right</span>',className:"text-center text-accent opacity-70"}];new Va("errors-table",{columns:o,dense:!0,onRowClick:c=>{const l=document.getElementById("error-modal"),u=document.getElementById("error-detail-content");l&&u&&(u.textContent=JSON.stringify(c,null,2),l.style.display="flex")}}).render(s);const a=document.querySelector("#errors-table tbody");a&&a.querySelectorAll("tr").forEach(c=>{c.classList.add("errors-table-row")})}function is(e){const t=document.querySelector("#stats-table tbody"),n=document.getElementById("stats-row-limit"),i=document.getElementById("stats-history-info");if(!t||!e.history)return;const s=n?parseInt(n.value):50,o=[...e.history].reverse(),r=s>0?o.slice(0,s):o;i&&(i.textContent=`Showing latest ${r.length} of ${o.length} data points`),t.innerHTML=r.map(a=>{const c=new Date(a.timestamp).toLocaleTimeString(),l=(a.system.rss/1024/1024).toFixed(1),u=(a.system.heapUsed/1024/1024).toFixed(1);return`
132
+ <tr>
133
+ <td class="font-mono text-xs">${c}</td>
134
+ <td class="text-center font-bold text-bright">${a.requests}</td>
135
+ <td class="text-center font-bold ${a.errors>0?"text-danger":"text-success"}">${a.errors}</td>
136
+ <td class="text-right font-mono">${a.durationMin.toFixed(1)}</td>
137
+ <td class="text-right font-mono text-accent font-bold">${a.durationAvg.toFixed(1)}</td>
138
+ <td class="text-right font-mono text-warning">${a.durationP95.toFixed(1)}</td>
139
+ <td class="text-right font-mono text-danger">${a.durationP99.toFixed(1)}</td>
140
+ <td class="text-right font-mono">${a.durationMax.toFixed(1)}</td>
141
+ <td class="text-right font-mono">${a.system.cpu.toFixed(1)}%</td>
142
+ <td class="text-right font-mono">${l}</td>
143
+ <td class="text-right font-mono">${u}</td>
144
+ </tr>
145
+ `}).join("")}async function Za(){const e=document.getElementById("access-filter"),t=document.getElementById("access-limit"),n=e?.value??"",i=t?parseInt(t.value):100,s=await bt.getAccessLogs(i,n),o=document.getElementById("access-log-view"),r=document.getElementById("access-log-range");if(!o)return;let a=0;Array.isArray(s)?(o.textContent=s.join(`
146
+ `),a=s.length):s&&typeof s=="object"&&"message"in s?(o.textContent=s.message,a=0):(o.textContent="No logs available",a=0),r&&(r.textContent=a>0?`Showing last ${a} log entries`:"No logs available"),o.parentElement&&(o.parentElement.scrollTop=o.parentElement.scrollHeight)}async function Ce(){const e=document.getElementById("trace-filter"),t=document.getElementById("trace-limit"),n=document.getElementById("trace-status-toggle"),i=e?.value??"",s=t?parseInt(t.value):100;try{const{enabled:c}=await bt.getTraceStatus();n&&(n.textContent=c?"Tracing: ON":"Tracing: OFF",n.dataset.enabled=String(c),n.className=`px-4 py-2 rounded-lg text-sm font-bold transition-colors ${c?"bg-success text-black hover:bg-success/80":"bg-white/10 text-white hover:bg-white/20"}`)}catch(c){console.error("Failed to get trace status",c)}const o=await bt.getTraceLogs(s,i),r=[{id:"timestamp",header:"Timestamp",headerTitle:"Time of request",accessor:c=>new Date(c.timestamp).toLocaleString(),className:"font-mono text-xs text-dim"},{id:"source",header:"Source",headerTitle:"Request source (IP/User)",accessor:c=>c.source,className:"text-dim text-xs truncate max-w-[150px]",cellTitle:c=>c.source},{id:"method",header:"Method",headerTitle:"HTTP Method",accessor:c=>c.method,className:"font-mono text-xs"},{id:"url",header:"Request URL",headerTitle:"Request URL",accessor:c=>c.url,className:"text-bright font-mono text-xs truncate max-w-[300px]",cellTitle:c=>c.url},{id:"status",header:"Status",headerTitle:"HTTP Status Code",width:"80px",accessor:c=>c.status,className:c=>`font-bold text-xs uppercase ${c.status==="success"?"text-success":"text-danger"}`},{id:"duration",header:"Duration",headerTitle:"Execution time in ms",align:"right",accessor:c=>ns(c.duration),className:"font-mono text-xs text-dim"},{id:"procedure",header:"Procedure",headerTitle:"Executed PL/SQL procedure",accessor:c=>c.procedure??"-",className:"text-dim text-xs truncate max-w-[200px]",cellTitle:c=>c.procedure??""}];new Va("trace-table",{columns:r,dense:!0,onRowClick:c=>{const l=document.getElementById("trace-modal"),u=document.getElementById("trace-detail-content");l&&u&&(u.textContent=JSON.stringify(c,null,2),l.style.display="flex")}}).render(o)}function Wa(e){const t=document.getElementById("pools-container");!t||!e.pools||(t.innerHTML=e.pools.map(n=>fy(n)).join(""))}function Ha(e){const t=e.status.config;if(!t)return;const n=document.getElementById("config-view");n&&(n.innerHTML=my(t))}function hi(e){if(e===0)return"0 B";const t=1024,n=["B","KB","MB","GB"],i=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,i)).toFixed(2))} ${n[i]}`}function er(e){return ns(e/1e3)}function ss(e,t){const n=document.getElementById("middleware-version");n&&e.version&&(n.textContent=`${e.version} (2/9/2026, 4:41:12 PM)`,n.title="The version of the web_plsql gateway and admin console build time");const i=document.getElementById("node-version");i&&e.system&&(i.textContent=e.system.nodeVersion,i.title="The version of the Node.js runtime");const s=document.getElementById("platform-info");s&&e.system&&(s.textContent=`${e.system.platform} (${e.system.arch})`,s.title="The operating system and architecture");const o=document.getElementById("system-uptime");o&&e.uptime&&(o.textContent=es(e.uptime));const r=document.getElementById("system-start-time");r&&e.startTime&&(r.textContent=ja(e.startTime));const a=document.getElementById("system-status-text");a&&(a.textContent=e.status?.toUpperCase()??"-");const c=document.getElementById("total-requests");c&&e.metrics&&(c.textContent=e.metrics.requestCount.toLocaleString(),c.title="Cumulative number of requests handled by the server");const l=document.getElementById("total-errors");l&&e.metrics&&(l.textContent=e.metrics.errorCount.toLocaleString(),l.title="Cumulative number of failed requests");const u=document.getElementById("active-pools");if(u&&e.pools&&(u.textContent=e.pools.length.toString(),u.title="Number of database connection pools currently active"),e.system){const h=e.system,d={heapUsed:h.memory.heapUsed,heapTotal:h.memory.heapTotal,rss:h.memory.rss,external:h.memory.external,cpuUser:h.cpu.user,cpuSystem:h.cpu.system},f=(y,w,x)=>{const _=d[w],k=h.memory[x],S=document.getElementById(y),M=document.getElementById(`${y}-max`);S&&(S.textContent=hi(_)),M&&typeof k=="number"&&(M.textContent=hi(k))},p=(y,w,x)=>{const _=d[w],k=document.getElementById(y);if(k&&(k.textContent=er(_)),x){const S=h.cpu[x],M=document.getElementById(`${y}-max`);M&&typeof S=="number"&&(M.textContent=er(S))}};f("memory-heap-used","heapUsed","heapUsedMax"),f("memory-heap-total","heapTotal","heapTotalMax"),f("memory-rss","rss","rssMax"),f("memory-external","external","externalMax"),p("cpu-user","cpuUser","userMax"),p("cpu-system","cpuSystem","systemMax");const g=document.getElementById("cpu-percent");if(g&&h.cpu.max!==void 0){const y=h.cpu.max;g.textContent=`${y.toFixed(1)}%`,g.title="Max System CPU usage"}const m=document.getElementById("memory-percent");if(m&&h.memory.totalMemory){const y=h.memory.rss/h.memory.totalMemory*100;m.textContent=`${y.toFixed(1)}%`,m.title=`System Memory Used relative to Total (${hi(h.memory.totalMemory)})`}const b=document.getElementById("cpu-cores-info");b&&h.cpuCores&&(b.textContent=`${h.cpuCores} Cores`)}}async function tn(e,t){const n=e.querySelector(".material-symbols-rounded"),i=n?.textContent;e.disabled=!0,e.classList.add("loading"),n&&(n.textContent="sync",n.classList.add("animate-spin"));try{return await t()}finally{e.disabled=!1,e.classList.remove("loading"),n&&(n.textContent=i??"",n.classList.remove("animate-spin"))}}function he(e,t){const n=document.getElementById(e);return n&&(n.onclick=()=>{tn(n,t)}),n}const by={overview:"dashboard",trace:"bolt",errors:"error",access:"list_alt",pools:"database",stats:"query_stats",config:"settings",system:"terminal"},T={currentView:"overview",status:{},maxHistoryPoints:30,lastRequestCount:0,lastErrorCount:0,lastUpdateTime:Date.now(),lastBucketTimestamp:0,nextRefreshTimeout:null,nextRefreshTime:0,countdownInterval:null,history:{labels:[],requests:[],avgResponseTimes:[],p95ResponseTimes:[],p99ResponseTimes:[],cpuUsage:[],memoryUsage:[],poolUsage:{}},charts:{},metricsMin:{},metricsMax:{}},Jt={REFRESH_INTERVAL:"admin_refresh_interval",HISTORY_DURATION:"admin_history_duration",AUTO_REFRESH:"admin_auto_refresh",THEME:"theme",LAST_VIEW:"admin_last_view"};function Ua(e){console.error("Connection lost:",e);const t=document.getElementById("server-status-dot"),n=document.getElementById("server-status-text");t&&(t.className="dot offline"),n&&(n.textContent="OFFLINE");const i=document.getElementById("btn-pause");i&&(i.style.display="none");const s=document.getElementById("btn-resume");s&&(s.style.display="none");const o=document.querySelector("#system-status .dot"),r=document.getElementById("system-status-text");o&&(o.className="dot offline"),r&&(r.textContent="OFFLINE");const a=document.getElementById("offline-modal");a&&a.style.display!=="flex"&&(a.style.display="flex"),Rn(6e4),qa(6e4)}function qa(e){T.countdownInterval&&clearInterval(T.countdownInterval);const t=Date.now()+e,n=document.getElementById("offline-countdown"),i=document.getElementById("reconnect-text");i&&(i.textContent="Try Reconnect");const s=()=>{if(!n)return;const o=Math.max(0,Math.ceil((t-Date.now())/1e3));n.textContent=`Retrying in ${o}s...`,o<=0&&T.countdownInterval&&(clearInterval(T.countdownInterval),T.countdownInterval=null)};s(),T.countdownInterval=setInterval(s,1e3)}function yy(){T.countdownInterval&&(clearInterval(T.countdownInterval),T.countdownInterval=null);const e=document.getElementById("offline-countdown");e&&(e.textContent="")}async function Rt(){const e=document.getElementById("reconnect-spinner"),t=document.getElementById("reconnect-icon"),n=document.getElementById("reconnect-text");e&&(e.style.display="inline-block"),t&&(t.style.display="none"),n&&(n.textContent="Connecting...");try{const i=Date.now(),s=await bt.getStatus(),o=document.getElementById("offline-modal");if(o?.style.display==="flex"&&o&&(o.style.display="none",yy()),e&&(e.style.display="none"),t&&(t.style.display="inline-block"),n&&(n.textContent="Try Reconnect"),s.history&&T.history.labels.length===0&&cy(T,s.history),T.status=s,!s.metrics||!s.pools)return;const a=s.history?.[s.history.length-1],c=(s.intervalMs??5e3)/1e3,l=a?a.requests/c:0,u=a?a.durationAvg:s.metrics.avgResponseTime;if(T.lastRequestCount=s.metrics.requestCount,T.lastErrorCount=s.metrics.errorCount,T.lastUpdateTime=i,s.system){const $=s.system,N={heapUsed:$.memory.heapUsed,heapTotal:$.memory.heapTotal,rss:$.memory.rss,external:$.memory.external,cpuUser:$.cpu.user,cpuSystem:$.cpu.system};ly(N,T.metricsMin,T.metricsMax)}if(a&&a.timestamp>T.lastBucketTimestamp){T.lastBucketTimestamp=a.timestamp;const $=new Date(a.timestamp).toLocaleTimeString();Qo(T,$,l,u,s.pools)}else if(!a&&T.history.labels.length===0){const $=new Date().toLocaleTimeString();Qo(T,$,0,0,s.pools)}const h=document.getElementById("sidebar-version");h&&(h.textContent=`v${s.version}`);const d=document.getElementById("uptime-val");d&&(d.textContent=es(s.uptime));const f=document.getElementById("start-time-val");f&&(f.textContent=`Started: ${ja(s.startTime)}`);const p=document.getElementById("req-per-sec");p&&(p.textContent=l.toFixed(2));const g=document.getElementById("max-req-per-sec");g&&(g.textContent=s.metrics.maxRequestsPerSecond.toFixed(2));const m=document.getElementById("avg-resp-time");m&&(m.textContent=`${s.metrics.avgResponseTime.toFixed(1)}ms`);const b=document.getElementById("max-resp-time");b&&(b.textContent=`${s.metrics.maxResponseTime.toFixed(1)}ms`);const y=document.getElementById("err-count");y&&(y.textContent=s.metrics.errorCount.toLocaleString());let w=0,x=0;s.pools.forEach($=>{$.cache&&(w+=$.cache.procedureName.hits+$.cache.argument.hits,x+=$.cache.procedureName.misses+$.cache.argument.misses)});const _=w+x,k=_>0?Math.round(w/_*100):0,S=document.getElementById("cache-hit-rate-val");S&&(S.textContent=`${k}%`,S.style.color=k>80?"var(--success)":k>50?"var(--warning)":"var(--danger)");const M=document.getElementById("cache-hits-val");M&&(M.textContent=w.toLocaleString());const C=document.getElementById("cache-misses-val");C&&(C.textContent=x.toLocaleString());const I=document.getElementById("server-status-dot"),A=document.getElementById("server-status-text");I&&(I.className="dot "+s.status),A&&(A.textContent=s.status.toUpperCase());const D=document.getElementById("btn-pause");D&&(D.style.display=s.status==="running"?"flex":"none");const tt=document.getElementById("btn-resume");if(tt&&(tt.style.display=s.status==="paused"?"flex":"none"),T.currentView==="errors"&&await Yn(),T.currentView==="trace"&&await Ce(),T.currentView==="pools"&&Wa(s),T.currentView==="stats"&&is(s),T.currentView==="config"&&Ha(T),T.currentView==="system"&&ss(s,T),Me?.checked&&St){const $=parseInt(St.value);Rn($)}}catch(i){document.getElementById("offline-modal")?.style.display!=="flex"?Ua(i):(Rn(6e4),qa(6e4),e&&(e.style.display="none"),t&&(t.style.display="inline-block"),n&&(n.textContent="Try Reconnect"))}}function Rn(e){T.nextRefreshTimeout&&(clearTimeout(T.nextRefreshTimeout),T.nextRefreshTimeout=null),T.nextRefreshTime=Date.now()+e,T.nextRefreshTimeout=setTimeout(()=>{Rt()},e)}function Ya(){const e=document.getElementById("refresh-interval");if(e){const t=parseInt(e.value);Rn(t)}}function _y(){T.nextRefreshTimeout&&(clearTimeout(T.nextRefreshTimeout),T.nextRefreshTimeout=null)}function Xa(){const e=document.getElementById("chart-history-points");e&&Array.from(e.options).forEach(t=>{const n=parseInt(t.value);let i="";if(n<60)i=`${n}s`;else if(n<3600)i=`${Math.round(n/60)} min`;else{const s=n/3600;i=s===Math.round(s)?`${s} hour${s>1?"s":""}`:`${s.toFixed(1)} hours`}t.textContent=`Last ${i}`})}document.querySelectorAll("nav button").forEach(e=>{const t=e;t.onclick=async()=>{try{const n=t.dataset.view;if(!n)return;T.currentView=n,localStorage.setItem(Jt.LAST_VIEW,n),document.querySelectorAll(".view").forEach(o=>{const r=o;r.style.display="none"});const i=document.getElementById("view-"+n);i&&(i.style.display="block"),document.querySelectorAll("nav button").forEach(o=>o.classList.remove("active")),t.classList.add("active");const s=document.getElementById("view-title");if(s){const r=Array.from(t.childNodes).filter(c=>c.nodeType===Node.TEXT_NODE).map(c=>c.textContent?.trim()).join(""),a=by[n]||"chevron_right";s.innerHTML=`<span class="material-symbols-rounded">${a}</span>${r}`}n==="errors"&&await Yn(),n==="trace"&&await Ce(),n==="pools"&&Wa(T.status),n==="stats"&&is(T.status),n==="config"&&Ha(T),n==="system"&&ss(T.status,T)}catch(n){Ua(n)}}});const Me=document.getElementById("auto-refresh-toggle");Me&&(Me.onchange=e=>{const t=e.target;localStorage.setItem(Jt.AUTO_REFRESH,String(t.checked)),t.checked?Ya():_y()});const St=document.getElementById("refresh-interval");St&&(St.onchange=()=>{localStorage.setItem(Jt.REFRESH_INTERVAL,St.value);const e=parseInt(St.value),t=parseInt(At?.value??"60");T.maxHistoryPoints=Math.max(1,Math.floor(t/(e/1e3))),T.history.labels=[],T.history.requests=[],T.history.avgResponseTimes=[],T.history.cpuUsage=[],T.history.memoryUsage=[],T.history.poolUsage={},Xa(),ss(T.status),Rt()});const At=document.getElementById("chart-history-points");At&&(At.onchange=()=>{localStorage.setItem(Jt.HISTORY_DURATION,At.value);const e=document.getElementById("refresh-interval");if(!e)return;const t=parseInt(e.value),n=parseInt(At.value);T.maxHistoryPoints=Math.max(1,Math.floor(n/(t/1e3))),T.history.labels=[],T.history.requests=[],T.history.avgResponseTimes=[],T.history.cpuUsage=[],T.history.memoryUsage=[],T.history.poolUsage={},Rt()});const di=document.getElementById("manual-refresh");di&&(di.onclick=()=>{tn(di,Rt)});const nr=document.getElementById("error-filter");nr&&(nr.onkeydown=e=>{e.key==="Enter"&&Yn()});he("error-load-btn",Yn);he("trace-load-btn",Ce);he("access-load-btn",Za);const ir=document.getElementById("trace-filter");ir&&(ir.onkeydown=e=>{e.key==="Enter"&&Ce()});const fi=document.getElementById("trace-clear-btn");fi&&(fi.onclick=async()=>{confirm("Are you sure you want to clear all traces?")&&await tn(fi,async()=>{await bt.clearTraces(),await Ce()})});const pi=document.getElementById("trace-status-toggle");pi&&(pi.onclick=async()=>{await tn(pi,async()=>{const{enabled:e}=await bt.getTraceStatus();await bt.toggleTrace(!e),await Ce()})});const sr=document.getElementById("access-filter");sr&&(sr.onkeydown=e=>{e.key==="Enter"&&Za()});const or=document.getElementById("stats-row-limit");or&&(or.onchange=()=>{is(T.status)});he("btn-pause",async()=>{confirm("Are you sure you want to pause the server?")&&(await bt.post("api/server/pause"),await Rt())});he("btn-resume",async()=>{await bt.post("api/server/resume"),await Rt()});he("btn-stop",async()=>{confirm("Are you sure you want to STOP the server? This action cannot be undone from the web interface.")&&(await bt.post("api/server/stop"),alert("Server stop requested. The interface will now become unresponsive."))});he("btn-clear-all-cache",async()=>{confirm("Are you sure you want to clear ALL caches?")&&(await bt.post("api/cache/clear"),await Rt())});const gi=document.getElementById("btn-reconnect");gi&&(gi.onclick=()=>{tn(gi,Rt)});window.addEventListener("keydown",e=>{if(e.key==="Escape"){const t=document.getElementById("error-modal");t&&(t.style.display="none");const n=document.getElementById("trace-modal");n&&(n.style.display="none")}});const rr=localStorage.getItem(Jt.REFRESH_INTERVAL);rr&&St&&(St.value=rr);const ar=localStorage.getItem(Jt.HISTORY_DURATION);ar&&At&&(At.value=ar);const cr=localStorage.getItem(Jt.AUTO_REFRESH);cr!==null&&Me&&(Me.checked=cr==="true");dy(T);ay(T);Xa();if(St&&At){const e=parseInt(St.value),t=parseInt(At.value);T.maxHistoryPoints=Math.max(1,Math.floor(t/(e/1e3)))}const lr=localStorage.getItem(Jt.LAST_VIEW);if(lr){const e=document.querySelector(`nav button[data-view="${lr}"]`);e&&e.click()}Rt().then(()=>{Me?.checked&&Ya()}).catch(console.error);