@modelcontextprotocol/server-customer-segmentation 1.3.2 → 1.4.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.
- package/dist/index.js +180 -108
- package/dist/mcp-app.html +17 -17
- package/dist/server.js +287 -89
- package/package.json +2 -2
package/dist/mcp-app.html
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<meta name="color-scheme" content="light dark">
|
|
7
7
|
<title>Customer Segmentation Explorer</title>
|
|
8
|
-
<script type="module" crossorigin>var bl=Object.defineProperty;var _l=(e,t,n)=>t in e?bl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var T=(e,t,n)=>_l(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function w(e,t,n){function s(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 i=(n==null?void 0:n.Parent)??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function r(a){var c;const l=n!=null&&n.Parent?new o:this;s(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const u of l._zod.deferred)u();return l}return Object.defineProperty(r,"init",{value:s}),Object.defineProperty(r,Symbol.hasInstance,{value:a=>{var c,l;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(l=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(r,"name",{value:e}),r}class Ee extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ha extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const da={};function se(e){return da}function fa(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,i])=>t.indexOf(+s)===-1).map(([s,i])=>i)}function Gs(e,t){return typeof t=="bigint"?t.toString():t}function vs(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function xi(e){return e==null}function vi(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function yl(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let i=(s.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(s)){const c=s.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const o=n>i?n:i,r=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return r%a/10**o}const po=Symbol("evaluating");function V(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==po)return s===void 0&&(s=po,s=n()),s},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Pe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ae(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function go(e){return JSON.stringify(e)}function xl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const pa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vl=vs(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function $e(e){if(dn(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(dn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ga(e){return $e(e)?{...e}:Array.isArray(e)?[...e]:e}const kl=new Set(["string","number","symbol"]);function Ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(s._zod.parent=e),s}function R(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 wl(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Sl={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 Ml(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=ae(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 Pe(this,"shape",r),r},checks:[]});return ce(e,o)}function Pl(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=ae(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 Pe(this,"shape",r),r},checks:[]});return ce(e,o)}function Tl(e,t){if(!$e(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 i=ae(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Pe(this,"shape",o),o}});return ce(e,i)}function Cl(e,t){if(!$e(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ae(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Pe(this,"shape",s),s}});return ce(e,n)}function zl(e,t){const n=ae(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Pe(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return ce(e,n)}function Ol(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=ae(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 Pe(this,"shape",c),c},checks:[]});return ce(t,r)}function Rl(e,t,n){const s=ae(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};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:i[r]}))}else for(const r in i)o[r]=new e({type:"nonoptional",innerType:i[r]});return Pe(this,"shape",o),o}});return ce(t,s)}function Ae(e,t=0){var n;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((n=e.issues[s])==null?void 0:n.continue)!==!0)return!0;return!1}function Ie(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function En(e){return typeof e=="string"?e:e==null?void 0:e.message}function ie(e,t,n){var i,o,r,a,c,l;const s={...e,path:e.path??[]};if(!e.message){const u=En((r=(o=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:o.error)==null?void 0:r.call(o,e))??En((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??En((c=n.customError)==null?void 0:c.call(n,e))??En((l=n.localeError)==null?void 0:l.call(n,e))??"Invalid input";s.message=u}return delete s.inst,delete s.continue,t!=null&&t.reportInput||delete s.input,s}function ki(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function fn(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const ma=(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,Gs,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ba=w("$ZodError",ma),_a=w("$ZodError",ma,{Parent:Error});function Al(e,t=n=>n.message){const n={},s=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):s.push(t(i));return{formErrors:s,fieldErrors:n}}function Il(e,t=n=>n.message){const n={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(r=>s({issues:r}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({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 s(e),n}const wi=e=>(t,n,s,i)=>{const o=s?Object.assign(s,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new Ee;if(r.issues.length){const a=new((i==null?void 0:i.Err)??e)(r.issues.map(c=>ie(c,o,se())));throw pa(a,i==null?void 0:i.callee),a}return r.value},Si=e=>async(t,n,s,i)=>{const o=s?Object.assign(s,{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((i==null?void 0:i.Err)??e)(r.issues.map(c=>ie(c,o,se())));throw pa(a,i==null?void 0:i.callee),a}return r.value},ks=e=>(t,n,s)=>{const i=s?{...s,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new Ee;return o.issues.length?{success:!1,error:new(e??ba)(o.issues.map(r=>ie(r,i,se())))}:{success:!0,data:o.value}},ya=ks(_a),ws=e=>async(t,n,s)=>{const i=s?Object.assign(s,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(r=>ie(r,i,se())))}:{success:!0,data:o.value}},Dl=ws(_a),El=e=>(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return wi(e)(t,n,i)},Ll=e=>(t,n,s)=>wi(e)(t,n,s),$l=e=>async(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Si(e)(t,n,i)},Nl=e=>async(t,n,s)=>Si(e)(t,n,s),Fl=e=>(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ks(e)(t,n,i)},jl=e=>(t,n,s)=>ks(e)(t,n,s),Bl=e=>async(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ws(e)(t,n,i)},Hl=e=>async(t,n,s)=>ws(e)(t,n,s),Zl=/^[cC][^\s-]{8,}$/,Vl=/^[0-9a-z]+$/,Wl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ql=/^[0-9a-vA-V]{20}$/,Ul=/^[A-Za-z0-9]{27}$/,Yl=/^[a-zA-Z0-9_-]{21}$/,Jl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Xl=/^([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})$/,mo=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)$/,Kl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Ql(){return new RegExp(Gl,"u")}const tu=/^(?:(?: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])$/,eu=/^(([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}|:))$/,nu=/^((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])$/,su=/^(([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])$/,iu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xa=/^[A-Za-z0-9_-]*$/,ou=/^\+[1-9]\d{6,14}$/,va="(?:(?:\\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])))",ru=new RegExp(`^${va}$`);function ka(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 au(e){return new RegExp(`^${ka(e)}$`)}function cu(e){const t=ka({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${va}T(?:${s})$`)}const lu=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},uu=/^-?\d+$/,wa=/^-?\d+(?:\.\d+)?$/,hu=/^(?:true|false)$/i,du=/^null$/i,fu=/^undefined$/i,pu=/^[^A-Z]*$/,gu=/^[^a-z]*$/,Pt=w("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Sa={number:"number",bigint:"bigint",object:"date"},Ma=w("$ZodCheckLessThan",(e,t)=>{Pt.init(e,t);const n=Sa[typeof t.value];e._zod.onattach.push(s=>{const i=s._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pa=w("$ZodCheckGreaterThan",(e,t)=>{Pt.init(e,t);const n=Sa[typeof t.value];e._zod.onattach.push(s=>{const i=s._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mu=w("$ZodCheckMultipleOf",(e,t)=>{Pt.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.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):yl(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})}}),bu=w("$ZodCheckNumberFormat",(e,t)=>{var r;Pt.init(e,t),t.format=t.format||"float64";const n=(r=t.format)==null?void 0:r.includes("int"),s=n?"int":"number",[i,o]=Sl[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=o,n&&(c.pattern=uu)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),c>o&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),_u=w("$ZodCheckMaxLength",(e,t)=>{var n;Pt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!xi(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const i=s.value;if(i.length<=t.maximum)return;const r=ki(i);s.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),yu=w("$ZodCheckMinLength",(e,t)=>{var n;Pt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!xi(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const i=s.value;if(i.length>=t.minimum)return;const r=ki(i);s.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),xu=w("$ZodCheckLengthEquals",(e,t)=>{var n;Pt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!xi(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=s=>{const i=s.value,o=i.length;if(o===t.length)return;const r=ki(i),a=o>t.length;s.issues.push({origin:r,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Ss=w("$ZodCheckStringFormat",(e,t)=>{var n,s;Pt.init(e,t),e._zod.onattach.push(i=>{const o=i._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=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),vu=w("$ZodCheckRegex",(e,t)=>{Ss.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})}}),ku=w("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pu),Ss.init(e,t)}),wu=w("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=gu),Ss.init(e,t)}),Su=w("$ZodCheckIncludes",(e,t)=>{Pt.init(e,t);const n=Ne(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(s)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Mu=w("$ZodCheckStartsWith",(e,t)=>{Pt.init(e,t);const n=new RegExp(`^${Ne(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),Pu=w("$ZodCheckEndsWith",(e,t)=>{Pt.init(e,t);const n=new RegExp(`.*${Ne(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),Tu=w("$ZodCheckOverwrite",(e,t)=>{Pt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Cu{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 s=t.split(`
|
|
8
|
+
<script type="module" crossorigin>var ml=Object.defineProperty;var bl=(e,t,n)=>t in e?ml(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var P=(e,t,n)=>bl(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))s(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&s(r)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function s(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function w(e,t,n){function s(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 i=(n==null?void 0:n.Parent)??Object;class o extends i{}Object.defineProperty(o,"name",{value:e});function r(a){var c;const l=n!=null&&n.Parent?new o:this;s(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const u of l._zod.deferred)u();return l}return Object.defineProperty(r,"init",{value:s}),Object.defineProperty(r,Symbol.hasInstance,{value:a=>{var c,l;return n!=null&&n.Parent&&a instanceof n.Parent?!0:(l=(c=a==null?void 0:a._zod)==null?void 0:c.traits)==null?void 0:l.has(e)}}),Object.defineProperty(r,"name",{value:e}),r}class De extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class ha extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const da={};function se(e){return da}function fa(e){const t=Object.values(e).filter(s=>typeof s=="number");return Object.entries(e).filter(([s,i])=>t.indexOf(+s)===-1).map(([s,i])=>i)}function Gs(e,t){return typeof t=="bigint"?t.toString():t}function vs(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function xi(e){return e==null}function vi(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function _l(e,t){const n=(e.toString().split(".")[1]||"").length,s=t.toString();let i=(s.split(".")[1]||"").length;if(i===0&&/\d?e-\d?/.test(s)){const c=s.match(/\d?e-(\d?)/);c!=null&&c[1]&&(i=Number.parseInt(c[1]))}const o=n>i?n:i,r=Number.parseInt(e.toFixed(o).replace(".","")),a=Number.parseInt(t.toFixed(o).replace(".",""));return r%a/10**o}const po=Symbol("evaluating");function V(e,t,n){let s;Object.defineProperty(e,t,{get(){if(s!==po)return s===void 0&&(s=po,s=n()),s},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function Pe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ae(...e){const t={};for(const n of e){const s=Object.getOwnPropertyDescriptors(n);Object.assign(t,s)}return Object.defineProperties({},t)}function go(e){return JSON.stringify(e)}function yl(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const pa="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function dn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const xl=vs(()=>{var e;if(typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)!=null&&e.includes("Cloudflare")))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function $e(e){if(dn(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(dn(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function ga(e){return $e(e)?{...e}:Array.isArray(e)?[...e]:e}const vl=new Set(["string","number","symbol"]);function Ne(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(e,t,n){const s=new e._zod.constr(t??e._zod.def);return(!t||n!=null&&n.parent)&&(s._zod.parent=e),s}function R(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if((t==null?void 0:t.message)!==void 0){if((t==null?void 0: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 kl(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const wl={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 Sl(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const o=ae(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 Pe(this,"shape",r),r},checks:[]});return ce(e,o)}function Ml(e,t){const n=e._zod.def,s=n.checks;if(s&&s.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const o=ae(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 Pe(this,"shape",r),r},checks:[]});return ce(e,o)}function Pl(e,t){if(!$e(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 i=ae(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return Pe(this,"shape",o),o}});return ce(e,i)}function Tl(e,t){if(!$e(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ae(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return Pe(this,"shape",s),s}});return ce(e,n)}function Cl(e,t){const n=ae(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t._zod.def.shape};return Pe(this,"shape",s),s},get catchall(){return t._zod.def.catchall},checks:[]});return ce(e,n)}function zl(e,t,n){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const r=ae(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 Pe(this,"shape",c),c},checks:[]});return ce(t,r)}function Ol(e,t,n){const s=ae(t._zod.def,{get shape(){const i=t._zod.def.shape,o={...i};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:i[r]}))}else for(const r in i)o[r]=new e({type:"nonoptional",innerType:i[r]});return Pe(this,"shape",o),o}});return ce(t,s)}function Ae(e,t=0){var n;if(e.aborted===!0)return!0;for(let s=t;s<e.issues.length;s++)if(((n=e.issues[s])==null?void 0:n.continue)!==!0)return!0;return!1}function Ie(e,t){return t.map(n=>{var s;return(s=n).path??(s.path=[]),n.path.unshift(e),n})}function Dn(e){return typeof e=="string"?e:e==null?void 0:e.message}function ie(e,t,n){var i,o,r,a,c,l;const s={...e,path:e.path??[]};if(!e.message){const u=Dn((r=(o=(i=e.inst)==null?void 0:i._zod.def)==null?void 0:o.error)==null?void 0:r.call(o,e))??Dn((a=t==null?void 0:t.error)==null?void 0:a.call(t,e))??Dn((c=n.customError)==null?void 0:c.call(n,e))??Dn((l=n.localeError)==null?void 0:l.call(n,e))??"Invalid input";s.message=u}return delete s.inst,delete s.continue,t!=null&&t.reportInput||delete s.input,s}function ki(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function fn(...e){const[t,n,s]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:s}:{...t}}const ma=(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,Gs,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ba=w("$ZodError",ma),_a=w("$ZodError",ma,{Parent:Error});function Rl(e,t=n=>n.message){const n={},s=[];for(const i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):s.push(t(i));return{formErrors:s,fieldErrors:n}}function Al(e,t=n=>n.message){const n={_errors:[]},s=i=>{for(const o of i.issues)if(o.code==="invalid_union"&&o.errors.length)o.errors.map(r=>s({issues:r}));else if(o.code==="invalid_key")s({issues:o.issues});else if(o.code==="invalid_element")s({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 s(e),n}const wi=e=>(t,n,s,i)=>{const o=s?Object.assign(s,{async:!1}):{async:!1},r=t._zod.run({value:n,issues:[]},o);if(r instanceof Promise)throw new De;if(r.issues.length){const a=new((i==null?void 0:i.Err)??e)(r.issues.map(c=>ie(c,o,se())));throw pa(a,i==null?void 0:i.callee),a}return r.value},Si=e=>async(t,n,s,i)=>{const o=s?Object.assign(s,{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((i==null?void 0:i.Err)??e)(r.issues.map(c=>ie(c,o,se())));throw pa(a,i==null?void 0:i.callee),a}return r.value},ks=e=>(t,n,s)=>{const i=s?{...s,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new De;return o.issues.length?{success:!1,error:new(e??ba)(o.issues.map(r=>ie(r,i,se())))}:{success:!0,data:o.value}},ya=ks(_a),ws=e=>async(t,n,s)=>{const i=s?Object.assign(s,{async:!0}):{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(r=>ie(r,i,se())))}:{success:!0,data:o.value}},Il=ws(_a),El=e=>(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return wi(e)(t,n,i)},Dl=e=>(t,n,s)=>wi(e)(t,n,s),Ll=e=>async(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return Si(e)(t,n,i)},$l=e=>async(t,n,s)=>Si(e)(t,n,s),Nl=e=>(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ks(e)(t,n,i)},Fl=e=>(t,n,s)=>ks(e)(t,n,s),Hl=e=>async(t,n,s)=>{const i=s?Object.assign(s,{direction:"backward"}):{direction:"backward"};return ws(e)(t,n,i)},jl=e=>async(t,n,s)=>ws(e)(t,n,s),Bl=/^[cC][^\s-]{8,}$/,Zl=/^[0-9a-z]+$/,Vl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Wl=/^[0-9a-vA-V]{20}$/,ql=/^[A-Za-z0-9]{27}$/,Ul=/^[a-zA-Z0-9_-]{21}$/,Yl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Jl=/^([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})$/,mo=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)$/,Kl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Xl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Gl(){return new RegExp(Xl,"u")}const Ql=/^(?:(?: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])$/,tu=/^(([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}|:))$/,eu=/^((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])$/,nu=/^(([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])$/,su=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xa=/^[A-Za-z0-9_-]*$/,iu=/^\+[1-9]\d{6,14}$/,va="(?:(?:\\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])))",ou=new RegExp(`^${va}$`);function ka(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 ru(e){return new RegExp(`^${ka(e)}$`)}function au(e){const t=ka({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const s=`${t}(?:${n.join("|")})`;return new RegExp(`^${va}T(?:${s})$`)}const cu=e=>{const t=e?`[\\s\\S]{${(e==null?void 0:e.minimum)??0},${(e==null?void 0:e.maximum)??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},lu=/^-?\d+$/,wa=/^-?\d+(?:\.\d+)?$/,uu=/^(?:true|false)$/i,hu=/^null$/i,du=/^undefined$/i,fu=/^[^A-Z]*$/,pu=/^[^a-z]*$/,Pt=w("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Sa={number:"number",bigint:"bigint",object:"date"},Ma=w("$ZodCheckLessThan",(e,t)=>{Pt.init(e,t);const n=Sa[typeof t.value];e._zod.onattach.push(s=>{const i=s._zod.bag,o=(t.inclusive?i.maximum:i.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<o&&(t.inclusive?i.maximum=t.value:i.exclusiveMaximum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value<=t.value:s.value<t.value)||s.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Pa=w("$ZodCheckGreaterThan",(e,t)=>{Pt.init(e,t);const n=Sa[typeof t.value];e._zod.onattach.push(s=>{const i=s._zod.bag,o=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>o&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=s=>{(t.inclusive?s.value>=t.value:s.value>t.value)||s.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:s.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),gu=w("$ZodCheckMultipleOf",(e,t)=>{Pt.init(e,t),e._zod.onattach.push(n=>{var s;(s=n._zod.bag).multipleOf??(s.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):_l(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})}}),mu=w("$ZodCheckNumberFormat",(e,t)=>{var r;Pt.init(e,t),t.format=t.format||"float64";const n=(r=t.format)==null?void 0:r.includes("int"),s=n?"int":"number",[i,o]=wl[t.format];e._zod.onattach.push(a=>{const c=a._zod.bag;c.format=t.format,c.minimum=i,c.maximum=o,n&&(c.pattern=lu)}),e._zod.check=a=>{const c=a.value;if(n){if(!Number.isInteger(c)){a.issues.push({expected:s,format:t.format,code:"invalid_type",continue:!1,input:c,inst:e});return}if(!Number.isSafeInteger(c)){c>0?a.issues.push({input:c,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort}):a.issues.push({input:c,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:s,inclusive:!0,continue:!t.abort});return}}c<i&&a.issues.push({origin:"number",input:c,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),c>o&&a.issues.push({origin:"number",input:c,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),bu=w("$ZodCheckMaxLength",(e,t)=>{var n;Pt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!xi(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<i&&(s._zod.bag.maximum=t.maximum)}),e._zod.check=s=>{const i=s.value;if(i.length<=t.maximum)return;const r=ki(i);s.issues.push({origin:r,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),_u=w("$ZodCheckMinLength",(e,t)=>{var n;Pt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!xi(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(s._zod.bag.minimum=t.minimum)}),e._zod.check=s=>{const i=s.value;if(i.length>=t.minimum)return;const r=ki(i);s.issues.push({origin:r,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),yu=w("$ZodCheckLengthEquals",(e,t)=>{var n;Pt.init(e,t),(n=e._zod.def).when??(n.when=s=>{const i=s.value;return!xi(i)&&i.length!==void 0}),e._zod.onattach.push(s=>{const i=s._zod.bag;i.minimum=t.length,i.maximum=t.length,i.length=t.length}),e._zod.check=s=>{const i=s.value,o=i.length;if(o===t.length)return;const r=ki(i),a=o>t.length;s.issues.push({origin:r,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:s.value,inst:e,continue:!t.abort})}}),Ss=w("$ZodCheckStringFormat",(e,t)=>{var n,s;Pt.init(e,t),e._zod.onattach.push(i=>{const o=i._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=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(s=e._zod).check??(s.check=()=>{})}),xu=w("$ZodCheckRegex",(e,t)=>{Ss.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})}}),vu=w("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fu),Ss.init(e,t)}),ku=w("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pu),Ss.init(e,t)}),wu=w("$ZodCheckIncludes",(e,t)=>{Pt.init(e,t);const n=Ne(t.includes),s=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=s,e._zod.onattach.push(i=>{const o=i._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(s)}),e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Su=w("$ZodCheckStartsWith",(e,t)=>{Pt.init(e,t);const n=new RegExp(`^${Ne(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=s=>{s.value.startsWith(t.prefix)||s.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:s.value,inst:e,continue:!t.abort})}}),Mu=w("$ZodCheckEndsWith",(e,t)=>{Pt.init(e,t);const n=new RegExp(`.*${Ne(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(s=>{const i=s._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=s=>{s.value.endsWith(t.suffix)||s.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:s.value,inst:e,continue:!t.abort})}}),Pu=w("$ZodCheckOverwrite",(e,t)=>{Pt.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Tu{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 s=t.split(`
|
|
9
9
|
`).filter(r=>r),i=Math.min(...s.map(r=>r.length-r.trimStart().length)),o=s.map(r=>r.slice(i)).map(r=>" ".repeat(this.indent*2)+r);for(const r of o)this.content.push(r)}compile(){const t=Function,n=this==null?void 0:this.args,i=[...((this==null?void 0:this.content)??[""]).map(o=>` ${o}`)];return new t(...n,i.join(`
|
|
10
|
-
`))}}const zu={major:4,minor:3,patch:5},Q=w("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zu;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const o of s)for(const r of o._zod.onattach)r(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,c,l)=>{let u=Ae(a),h;for(const d of c){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&(l==null?void 0:l.async)===!1)throw new Ee;if(h||p instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=Ae(a,f)))});else{if(a.issues.length===f)continue;u||(u=Ae(a,f))}}return h?h.then(()=>a):a},r=(a,c,l)=>{if(Ae(a))return a.aborted=!0,a;const u=o(c,s,l);if(u instanceof Promise){if(l.async===!1)throw new Ee;return u.then(h=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(h=>r(h,a,c)):r(u,a,c)}const l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Ee;return l.then(u=>o(u,s,c))}return o(l,s,c)}}V(e,"~standard",()=>({validate:o=>{var r;try{const a=ya(e,o);return a.success?{value:a.data}:{issues:(r=a.error)==null?void 0:r.issues}}catch{return Dl(e,o).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),Mi=w("$ZodString",(e,t)=>{var n;Q.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??lu(e._zod.bag),e._zod.parse=(s,i)=>{if(t.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:e}),s}}),it=w("$ZodStringFormat",(e,t)=>{Ss.init(e,t),Mi.init(e,t)}),Ou=w("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Xl),it.init(e,t)}),Ru=w("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mo(s))}else t.pattern??(t.pattern=mo());it.init(e,t)}),Au=w("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Kl),it.init(e,t)}),Iu=w("$ZodURL",(e,t)=>{it.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),i=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Du=w("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Ql()),it.init(e,t)}),Eu=w("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Yl),it.init(e,t)}),Lu=w("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Zl),it.init(e,t)}),$u=w("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Vl),it.init(e,t)}),Nu=w("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Wl),it.init(e,t)}),Fu=w("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ql),it.init(e,t)}),ju=w("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ul),it.init(e,t)}),Bu=w("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cu(t)),it.init(e,t)}),Hu=w("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ru),it.init(e,t)}),Zu=w("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=au(t)),it.init(e,t)}),Vu=w("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jl),it.init(e,t)}),Wu=w("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=tu),it.init(e,t),e._zod.bag.format="ipv4"}),qu=w("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=eu),it.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})}}}),Uu=w("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=nu),it.init(e,t)}),Yu=w("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=su),it.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[i,o]=s;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://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ta(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ju=w("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=iu),it.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ta(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Xu(e){if(!xa.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ta(n)}const Ku=w("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xa),it.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Xu(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Gu=w("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ou),it.init(e,t)});function Qu(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const i=JSON.parse(atob(s));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const th=w("$ZodJWT",(e,t)=>{it.init(e,t),e._zod.check=n=>{Qu(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ca=w("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??wa,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),eh=w("$ZodNumberFormat",(e,t)=>{bu.init(e,t),Ca.init(e,t)}),nh=w("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=hu,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),sh=w("$ZodUndefined",(e,t)=>{Q.init(e,t),e._zod.pattern=fu,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,s)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),ih=w("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=du,e._zod.values=new Set([null]),e._zod.parse=(n,s)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),oh=w("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=n=>n}),rh=w("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function bo(e,t,n){e.issues.length&&t.issues.push(...Ie(n,e.issues)),t.value[n]=e.value}const ah=w("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let r=0;r<i.length;r++){const a=i[r],c=t.element._zod.run({value:a,issues:[]},s);c instanceof Promise?o.push(c.then(l=>bo(l,n,r))):bo(c,n,r)}return o.length?Promise.all(o).then(()=>n):n}});function cs(e,t,n,s,i){if(e.issues.length){if(i&&!(n in s))return;t.issues.push(...Ie(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function za(e){var s,i,o,r;const t=Object.keys(e.shape);for(const a of t)if(!((r=(o=(i=(s=e.shape)==null?void 0:s[a])==null?void 0:i._zod)==null?void 0:o.traits)!=null&&r.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=wl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Oa(e,t,n,s,i,o){const r=[],a=i.keySet,c=i.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:[]},s);d instanceof Promise?e.push(d.then(f=>cs(f,n,h,t,u))):cs(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 ch=w("$ZodObject",(e,t)=>{Q.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const s=vs(()=>za(t));V(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 i=dn,o=t.catchall;let r;e._zod.parse=(a,c)=>{r??(r=s.value);const l=a.value;if(!i(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=>cs(m,a,d,l,p))):cs(g,a,d,l,p)}return o?Oa(u,l,a,c,s.value,e):u.length?Promise.all(u).then(()=>a):a}}),lh=w("$ZodObjectJIT",(e,t)=>{ch.init(e,t);const n=e._zod.parse,s=vs(()=>za(t)),i=d=>{var M;const f=new Cu(["shape","payload","ctx"]),p=s.value,g=S=>{const k=go(S);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};f.write("const input = payload.value;");const m=Object.create(null);let b=0;for(const S of p.keys)m[S]=`key_${b++}`;f.write("const newResult = {};");for(const S of p.keys){const k=m[S],C=go(S),P=d[S],z=((M=P==null?void 0:P._zod)==null?void 0:M.optout)==="optional";f.write(`const ${k} = ${g(S)};`),z?f.write(`
|
|
10
|
+
`))}}const Cu={major:4,minor:3,patch:5},Q=w("$ZodType",(e,t)=>{var i;var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Cu;const s=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&s.unshift(e);for(const o of s)for(const r of o._zod.onattach)r(e);if(s.length===0)(n=e._zod).deferred??(n.deferred=[]),(i=e._zod.deferred)==null||i.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,c,l)=>{let u=Ae(a),h;for(const d of c){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&(l==null?void 0:l.async)===!1)throw new De;if(h||p instanceof Promise)h=(h??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=Ae(a,f)))});else{if(a.issues.length===f)continue;u||(u=Ae(a,f))}}return h?h.then(()=>a):a},r=(a,c,l)=>{if(Ae(a))return a.aborted=!0,a;const u=o(c,s,l);if(u instanceof Promise){if(l.async===!1)throw new De;return u.then(h=>e._zod.parse(h,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(h=>r(h,a,c)):r(u,a,c)}const l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new De;return l.then(u=>o(u,s,c))}return o(l,s,c)}}V(e,"~standard",()=>({validate:o=>{var r;try{const a=ya(e,o);return a.success?{value:a.data}:{issues:(r=a.error)==null?void 0:r.issues}}catch{return Il(e,o).then(c=>{var l;return c.success?{value:c.data}:{issues:(l=c.error)==null?void 0:l.issues}})}},vendor:"zod",version:1}))}),Mi=w("$ZodString",(e,t)=>{var n;Q.init(e,t),e._zod.pattern=[...((n=e==null?void 0:e._zod.bag)==null?void 0:n.patterns)??[]].pop()??cu(e._zod.bag),e._zod.parse=(s,i)=>{if(t.coerce)try{s.value=String(s.value)}catch{}return typeof s.value=="string"||s.issues.push({expected:"string",code:"invalid_type",input:s.value,inst:e}),s}}),it=w("$ZodStringFormat",(e,t)=>{Ss.init(e,t),Mi.init(e,t)}),zu=w("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Jl),it.init(e,t)}),Ou=w("$ZodUUID",(e,t)=>{if(t.version){const s={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(s===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=mo(s))}else t.pattern??(t.pattern=mo());it.init(e,t)}),Ru=w("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Kl),it.init(e,t)}),Au=w("$ZodURL",(e,t)=>{it.init(e,t),e._zod.check=n=>{try{const s=n.value.trim(),i=new URL(s);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.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(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.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=i.href:n.value=s;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Iu=w("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Gl()),it.init(e,t)}),Eu=w("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ul),it.init(e,t)}),Du=w("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bl),it.init(e,t)}),Lu=w("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Zl),it.init(e,t)}),$u=w("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Vl),it.init(e,t)}),Nu=w("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Wl),it.init(e,t)}),Fu=w("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ql),it.init(e,t)}),Hu=w("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=au(t)),it.init(e,t)}),ju=w("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ou),it.init(e,t)}),Bu=w("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ru(t)),it.init(e,t)}),Zu=w("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Yl),it.init(e,t)}),Vu=w("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ql),it.init(e,t),e._zod.bag.format="ipv4"}),Wu=w("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=tu),it.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})}}}),qu=w("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eu),it.init(e,t)}),Uu=w("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=nu),it.init(e,t),e._zod.check=n=>{const s=n.value.split("/");try{if(s.length!==2)throw new Error;const[i,o]=s;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://[${i}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Ta(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Yu=w("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=su),it.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Ta(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Ju(e){if(!xa.test(e))return!1;const t=e.replace(/[-_]/g,s=>s==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ta(n)}const Ku=w("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xa),it.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Ju(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Xu=w("$ZodE164",(e,t)=>{t.pattern??(t.pattern=iu),it.init(e,t)});function Gu(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[s]=n;if(!s)return!1;const i=JSON.parse(atob(s));return!("typ"in i&&(i==null?void 0:i.typ)!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const Qu=w("$ZodJWT",(e,t)=>{it.init(e,t),e._zod.check=n=>{Gu(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Ca=w("$ZodNumber",(e,t)=>{Q.init(e,t),e._zod.pattern=e._zod.bag.pattern??wa,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),th=w("$ZodNumberFormat",(e,t)=>{mu.init(e,t),Ca.init(e,t)}),eh=w("$ZodBoolean",(e,t)=>{Q.init(e,t),e._zod.pattern=uu,e._zod.parse=(n,s)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),nh=w("$ZodUndefined",(e,t)=>{Q.init(e,t),e._zod.pattern=du,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(n,s)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),sh=w("$ZodNull",(e,t)=>{Q.init(e,t),e._zod.pattern=hu,e._zod.values=new Set([null]),e._zod.parse=(n,s)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),ih=w("$ZodUnknown",(e,t)=>{Q.init(e,t),e._zod.parse=n=>n}),oh=w("$ZodNever",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function bo(e,t,n){e.issues.length&&t.issues.push(...Ie(n,e.issues)),t.value[n]=e.value}const rh=w("$ZodArray",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{const i=n.value;if(!Array.isArray(i))return n.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),n;n.value=Array(i.length);const o=[];for(let r=0;r<i.length;r++){const a=i[r],c=t.element._zod.run({value:a,issues:[]},s);c instanceof Promise?o.push(c.then(l=>bo(l,n,r))):bo(c,n,r)}return o.length?Promise.all(o).then(()=>n):n}});function cs(e,t,n,s,i){if(e.issues.length){if(i&&!(n in s))return;t.issues.push(...Ie(n,e.issues))}e.value===void 0?n in s&&(t.value[n]=void 0):t.value[n]=e.value}function za(e){var s,i,o,r;const t=Object.keys(e.shape);for(const a of t)if(!((r=(o=(i=(s=e.shape)==null?void 0:s[a])==null?void 0:i._zod)==null?void 0:o.traits)!=null&&r.has("$ZodType")))throw new Error(`Invalid element at key "${a}": expected a Zod schema`);const n=kl(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Oa(e,t,n,s,i,o){const r=[],a=i.keySet,c=i.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:[]},s);d instanceof Promise?e.push(d.then(f=>cs(f,n,h,t,u))):cs(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 ah=w("$ZodObject",(e,t)=>{Q.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!(n!=null&&n.get)){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const s=vs(()=>za(t));V(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 i=dn,o=t.catchall;let r;e._zod.parse=(a,c)=>{r??(r=s.value);const l=a.value;if(!i(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=>cs(m,a,d,l,p))):cs(g,a,d,l,p)}return o?Oa(u,l,a,c,s.value,e):u.length?Promise.all(u).then(()=>a):a}}),ch=w("$ZodObjectJIT",(e,t)=>{ah.init(e,t);const n=e._zod.parse,s=vs(()=>za(t)),i=d=>{var M;const f=new Tu(["shape","payload","ctx"]),p=s.value,g=S=>{const k=go(S);return`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`};f.write("const input = payload.value;");const m=Object.create(null);let b=0;for(const S of p.keys)m[S]=`key_${b++}`;f.write("const newResult = {};");for(const S of p.keys){const k=m[S],C=go(S),T=d[S],z=((M=T==null?void 0:T._zod)==null?void 0:M.optout)==="optional";f.write(`const ${k} = ${g(S)};`),z?f.write(`
|
|
11
11
|
if (${k}.issues.length) {
|
|
12
12
|
if (${C} in input) {
|
|
13
13
|
payload.issues = payload.issues.concat(${k}.issues.map(iss => ({
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
newResult[${C}] = ${k}.value;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");const x=f.compile();return(S,k)=>x(d,S,k)};let o;const r=dn,a=!da.jitless,l=a&&vl.value,u=t.catchall;let h;e._zod.parse=(d,f)=>{h??(h=s.value);const p=d.value;return r(p)?a&&l&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(o||(o=i(t.shape)),d=o(d,f),u?Oa([],p,d,f,h,e):d):n(d,f):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function _o(e,t,n,s){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!Ae(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(r=>ie(r,s,se())))}),t)}const Ra=w("$ZodUnion",(e,t)=>{Q.init(e,t),V(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),V(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),V(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),V(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>vi(o.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return s(i,o);let r=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:i.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=>_o(c,i,e,o)):_o(a,i,e,o)}}),uh=w("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ra.init(e,t);const n=e._zod.parse;V(e._zod,"propValues",()=>{const i={};for(const o of t.options){const r=o._zod.propValues;if(!r||Object.keys(r).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[a,c]of Object.entries(r)){i[a]||(i[a]=new Set);for(const l of c)i[a].add(l)}}return i});const s=vs(()=>{var r;const i=t.options,o=new Map;for(const a of i){const c=(r=a._zod.propValues)==null?void 0:r[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of c){if(o.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);o.set(l,a)}}return o});e._zod.parse=(i,o)=>{const r=i.value;if(!dn(r))return i.issues.push({code:"invalid_type",expected:"object",input:r,inst:e}),i;const a=s.value.get(r==null?void 0:r[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:r,path:[t.discriminator],inst:e}),i)}}),hh=w("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},s),r=t.right._zod.run({value:i,issues:[]},s);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then(([c,l])=>yo(n,c,l)):yo(n,o,r)}});function Qs(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($e(e)&&$e(t)){const n=Object.keys(t),s=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of s){const r=Qs(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};i[o]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const i=e[s],o=t[s],r=Qs(i,o);if(!r.valid)return{valid:!1,mergeErrorPath:[s,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function yo(e,t,n){const s=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)s.has(c)||s.set(c,{}),s.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)s.has(c)||s.set(c,{}),s.get(c).r=!0;else e.issues.push(a);const o=[...s].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&i&&e.issues.push({...i,keys:o}),Ae(e))return e;const r=Qs(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 dh=w("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{const i=n.value;if(!$e(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,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:i[l],issues:[]},s);u instanceof Promise?o.push(u.then(h=>{h.issues.length&&n.issues.push(...Ie(l,h.issues)),n.value[l]=h.value})):(u.issues.length&&n.issues.push(...Ie(l,u.issues)),n.value[l]=u.value)}let c;for(const l in i)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},s);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&wa.test(a)&&c.issues.length&&c.issues.some(h=>h.code==="invalid_type"&&h.expected==="number")){const h=t.keyType._zod.run({value:Number(a),issues:[]},s);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]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>ie(h,s,se())),input:a,path:[a],inst:e});continue}const u=t.valueType._zod.run({value:i[a],issues:[]},s);u instanceof Promise?o.push(u.then(h=>{h.issues.length&&n.issues.push(...Ie(a,h.issues)),n.value[c.value]=h.value})):(u.issues.length&&n.issues.push(...Ie(a,u.issues)),n.value[c.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}}),fh=w("$ZodEnum",(e,t)=>{Q.init(e,t);const n=fa(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(i=>kl.has(typeof i)).map(i=>typeof i=="string"?Ne(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const r=i.value;return s.has(r)||i.issues.push({code:"invalid_value",values:n,input:r,inst:e}),i}}),ph=w("$ZodLiteral",(e,t)=>{if(Q.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?Ne(s):s?Ne(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),s}}),gh=w("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new ha(e.constructor.name);const i=t.transform(n.value,n);if(s.async)return(i instanceof Promise?i:Promise.resolve(i)).then(r=>(n.value=r,n));if(i instanceof Promise)throw new Ee;return n.value=i,n}});function xo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Aa=w("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${vi(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>xo(o,n.value)):xo(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),mh=w("$ZodExactOptional",(e,t)=>{Aa.init(e,t),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),bh=w("$ZodNullable",(e,t)=>{Q.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${vi(n.source)}|null)$`):void 0}),V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),_h=w("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>vo(o,t)):vo(i,t)}});function vo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const yh=w("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),xh=w("$ZodNonOptional",(e,t)=>{Q.init(e,t),V(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>ko(o,e)):ko(i,e)}});function ko(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 vh=w("$ZodCatch",(e,t)=>{Q.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(r=>ie(r,s,se()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>ie(o,s,se()))},input:n.value}),n.issues=[]),n)}}),kh=w("$ZodPipe",(e,t)=>{Q.init(e,t),V(e._zod,"values",()=>t.in._zod.values),V(e._zod,"optin",()=>t.in._zod.optin),V(e._zod,"optout",()=>t.out._zod.optout),V(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const o=t.out._zod.run(n,s);return o instanceof Promise?o.then(r=>Ln(r,t.in,s)):Ln(o,t.in,s)}const i=t.in._zod.run(n,s);return i instanceof Promise?i.then(o=>Ln(o,t.out,s)):Ln(i,t.out,s)}});function Ln(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const wh=w("$ZodReadonly",(e,t)=>{Q.init(e,t),V(e._zod,"propValues",()=>t.innerType._zod.propValues),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"optin",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optin}),V(e._zod,"optout",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optout}),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(wo):wo(i)}});function wo(e){return e.value=Object.freeze(e.value),e}const Sh=w("$ZodCustom",(e,t)=>{Pt.init(e,t),Q.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,i=t.fn(s);if(i instanceof Promise)return i.then(o=>So(o,n,s,e));So(i,n,s,e)}});function So(e,t,n,s){if(!e){const i={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(i.params=s._zod.def.params),t.issues.push(fn(i))}}var Mo;class Mh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.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 s={...this.get(n)??{}};delete s.id;const i={...s,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ph(){return new Mh}(Mo=globalThis).__zod_globalRegistry??(Mo.__zod_globalRegistry=Ph());const Qe=globalThis.__zod_globalRegistry;function Th(e,t){return new e({type:"string",...R(t)})}function Ch(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...R(t)})}function Po(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...R(t)})}function zh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...R(t)})}function Oh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(t)})}function Rh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(t)})}function Ah(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(t)})}function Ih(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...R(t)})}function Dh(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...R(t)})}function Eh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(t)})}function Lh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...R(t)})}function $h(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(t)})}function Nh(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...R(t)})}function Fh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...R(t)})}function jh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(t)})}function Bh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(t)})}function Hh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(t)})}function Zh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(t)})}function Vh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(t)})}function Wh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...R(t)})}function qh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...R(t)})}function Uh(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...R(t)})}function Yh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...R(t)})}function Jh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(t)})}function Xh(e,t){return new e({type:"string",format:"date",check:"string_format",...R(t)})}function Kh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...R(t)})}function Gh(e,t){return new e({type:"string",format:"duration",check:"string_format",...R(t)})}function Qh(e,t){return new e({type:"number",checks:[],...R(t)})}function td(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...R(t)})}function ed(e,t){return new e({type:"boolean",...R(t)})}function nd(e,t){return new e({type:"undefined",...R(t)})}function sd(e,t){return new e({type:"null",...R(t)})}function id(e){return new e({type:"unknown"})}function od(e,t){return new e({type:"never",...R(t)})}function To(e,t){return new Ma({check:"less_than",...R(t),value:e,inclusive:!1})}function Ls(e,t){return new Ma({check:"less_than",...R(t),value:e,inclusive:!0})}function Co(e,t){return new Pa({check:"greater_than",...R(t),value:e,inclusive:!1})}function $s(e,t){return new Pa({check:"greater_than",...R(t),value:e,inclusive:!0})}function zo(e,t){return new mu({check:"multiple_of",...R(t),value:e})}function Ia(e,t){return new _u({check:"max_length",...R(t),maximum:e})}function ls(e,t){return new yu({check:"min_length",...R(t),minimum:e})}function Da(e,t){return new xu({check:"length_equals",...R(t),length:e})}function rd(e,t){return new vu({check:"string_format",format:"regex",...R(t),pattern:e})}function ad(e){return new ku({check:"string_format",format:"lowercase",...R(e)})}function cd(e){return new wu({check:"string_format",format:"uppercase",...R(e)})}function ld(e,t){return new Su({check:"string_format",format:"includes",...R(t),includes:e})}function ud(e,t){return new Mu({check:"string_format",format:"starts_with",...R(t),prefix:e})}function hd(e,t){return new Pu({check:"string_format",format:"ends_with",...R(t),suffix:e})}function Ve(e){return new Tu({check:"overwrite",tx:e})}function dd(e){return Ve(t=>t.normalize(e))}function fd(){return Ve(e=>e.trim())}function pd(){return Ve(e=>e.toLowerCase())}function gd(){return Ve(e=>e.toUpperCase())}function md(){return Ve(e=>xl(e))}function bd(e,t,n){return new e({type:"array",element:t,...R(n)})}function _d(e,t,n){const s=R(n);return s.abort??(s.abort=!0),new e({type:"custom",check:"custom",fn:t,...s})}function yd(e,t,n){return new e({type:"custom",check:"custom",fn:t,...R(n)})}function xd(e){const t=vd(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(fn(s,n.value,t._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(fn(i))}},e(n.value,n)));return t}function vd(e,t){const n=new Pt({check:"custom",...R(t)});return n._zod.check=e,n}function Ea(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Qe,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function ut(e,t,n={path:[],schemaPath:[]}){var u,h;var s;const i=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=(h=(u=e._zod).toJSONSchema)==null?void 0:h.call(u);if(a)r.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const p=r.schema,g=t.processors[i.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);g(e,t,p,d)}const f=e._zod.parent;f&&(r.ref||(r.ref=f),ut(f,t,d),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&kt(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((s=r.schema).default??(s.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function La(e,t){var r,a,c,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const u of e.seen.entries()){const h=(r=e.metadataRegistry.get(u[0]))==null?void 0:r.id;if(h){const d=s.get(h);if(d&&d!==u[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(h,u[0])}}const i=u=>{var g;const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=(g=e.external.registry.get(u[0]))==null?void 0:g.id,b=e.external.uri??(M=>M);if(m)return{ref:b(m)};const x=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=x,{defId:x,ref:`${b("__shared")}#/${h}/${x}`}}if(u[1]===n)return{ref:"#"};const f=`#/${h}/`,p=u[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:f+p}},o=u=>{if(u[1].schema.$ref)return;const h=u[1],{ref:d,defId:f}=i(u);h.def={...h.schema},f&&(h.defId=f);const p=h.schema;for(const g in p)delete p[g];p.$ref=d};if(e.cycles==="throw")for(const u of e.seen.entries()){const h=u[1];if(h.cycle)throw new Error(`Cycle detected: #/${(a=h.cycle)==null?void 0:a.join("/")}/<root>
|
|
44
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");const x=f.compile();return(S,k)=>x(d,S,k)};let o;const r=dn,a=!da.jitless,l=a&&xl.value,u=t.catchall;let h;e._zod.parse=(d,f)=>{h??(h=s.value);const p=d.value;return r(p)?a&&l&&(f==null?void 0:f.async)===!1&&f.jitless!==!0?(o||(o=i(t.shape)),d=o(d,f),u?Oa([],p,d,f,h,e):d):n(d,f):(d.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),d)}});function _o(e,t,n,s){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!Ae(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(r=>ie(r,s,se())))}),t)}const Ra=w("$ZodUnion",(e,t)=>{Q.init(e,t),V(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),V(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),V(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),V(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){const i=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>vi(o.source)).join("|")})$`)}});const n=t.options.length===1,s=t.options[0]._zod.run;e._zod.parse=(i,o)=>{if(n)return s(i,o);let r=!1;const a=[];for(const c of t.options){const l=c._zod.run({value:i.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=>_o(c,i,e,o)):_o(a,i,e,o)}}),lh=w("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ra.init(e,t);const n=e._zod.parse;V(e._zod,"propValues",()=>{const i={};for(const o of t.options){const r=o._zod.propValues;if(!r||Object.keys(r).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(o)}"`);for(const[a,c]of Object.entries(r)){i[a]||(i[a]=new Set);for(const l of c)i[a].add(l)}}return i});const s=vs(()=>{var r;const i=t.options,o=new Map;for(const a of i){const c=(r=a._zod.propValues)==null?void 0:r[t.discriminator];if(!c||c.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of c){if(o.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);o.set(l,a)}}return o});e._zod.parse=(i,o)=>{const r=i.value;if(!dn(r))return i.issues.push({code:"invalid_type",expected:"object",input:r,inst:e}),i;const a=s.value.get(r==null?void 0:r[t.discriminator]);return a?a._zod.run(i,o):t.unionFallback?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:r,path:[t.discriminator],inst:e}),i)}}),uh=w("$ZodIntersection",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},s),r=t.right._zod.run({value:i,issues:[]},s);return o instanceof Promise||r instanceof Promise?Promise.all([o,r]).then(([c,l])=>yo(n,c,l)):yo(n,o,r)}});function Qs(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($e(e)&&$e(t)){const n=Object.keys(t),s=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};for(const o of s){const r=Qs(e[o],t[o]);if(!r.valid)return{valid:!1,mergeErrorPath:[o,...r.mergeErrorPath]};i[o]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let s=0;s<e.length;s++){const i=e[s],o=t[s],r=Qs(i,o);if(!r.valid)return{valid:!1,mergeErrorPath:[s,...r.mergeErrorPath]};n.push(r.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function yo(e,t,n){const s=new Map;let i;for(const a of t.issues)if(a.code==="unrecognized_keys"){i??(i=a);for(const c of a.keys)s.has(c)||s.set(c,{}),s.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)s.has(c)||s.set(c,{}),s.get(c).r=!0;else e.issues.push(a);const o=[...s].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(o.length&&i&&e.issues.push({...i,keys:o}),Ae(e))return e;const r=Qs(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 hh=w("$ZodRecord",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{const i=n.value;if(!$e(i))return n.issues.push({expected:"record",code:"invalid_type",input:i,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:i[l],issues:[]},s);u instanceof Promise?o.push(u.then(h=>{h.issues.length&&n.issues.push(...Ie(l,h.issues)),n.value[l]=h.value})):(u.issues.length&&n.issues.push(...Ie(l,u.issues)),n.value[l]=u.value)}let c;for(const l in i)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(i)){if(a==="__proto__")continue;let c=t.keyType._zod.run({value:a,issues:[]},s);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&wa.test(a)&&c.issues.length&&c.issues.some(h=>h.code==="invalid_type"&&h.expected==="number")){const h=t.keyType._zod.run({value:Number(a),issues:[]},s);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]=i[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(h=>ie(h,s,se())),input:a,path:[a],inst:e});continue}const u=t.valueType._zod.run({value:i[a],issues:[]},s);u instanceof Promise?o.push(u.then(h=>{h.issues.length&&n.issues.push(...Ie(a,h.issues)),n.value[c.value]=h.value})):(u.issues.length&&n.issues.push(...Ie(a,u.issues)),n.value[c.value]=u.value)}}return o.length?Promise.all(o).then(()=>n):n}}),dh=w("$ZodEnum",(e,t)=>{Q.init(e,t);const n=fa(t.entries),s=new Set(n);e._zod.values=s,e._zod.pattern=new RegExp(`^(${n.filter(i=>vl.has(typeof i)).map(i=>typeof i=="string"?Ne(i):i.toString()).join("|")})$`),e._zod.parse=(i,o)=>{const r=i.value;return s.has(r)||i.issues.push({code:"invalid_value",values:n,input:r,inst:e}),i}}),fh=w("$ZodLiteral",(e,t)=>{if(Q.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(s=>typeof s=="string"?Ne(s):s?Ne(s.toString()):String(s)).join("|")})$`),e._zod.parse=(s,i)=>{const o=s.value;return n.has(o)||s.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),s}}),ph=w("$ZodTransform",(e,t)=>{Q.init(e,t),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new ha(e.constructor.name);const i=t.transform(n.value,n);if(s.async)return(i instanceof Promise?i:Promise.resolve(i)).then(r=>(n.value=r,n));if(i instanceof Promise)throw new De;return n.value=i,n}});function xo(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Aa=w("$ZodOptional",(e,t)=>{Q.init(e,t),e._zod.optin="optional",e._zod.optout="optional",V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${vi(n.source)})?$`):void 0}),e._zod.parse=(n,s)=>{if(t.innerType._zod.optin==="optional"){const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>xo(o,n.value)):xo(i,n.value)}return n.value===void 0?n:t.innerType._zod.run(n,s)}}),gh=w("$ZodExactOptional",(e,t)=>{Aa.init(e,t),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,s)=>t.innerType._zod.run(n,s)}),mh=w("$ZodNullable",(e,t)=>{Q.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${vi(n.source)}|null)$`):void 0}),V(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,s)=>n.value===null?n:t.innerType._zod.run(n,s)}),bh=w("$ZodDefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);if(n.value===void 0)return n.value=t.defaultValue,n;const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>vo(o,t)):vo(i,t)}});function vo(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const _h=w("$ZodPrefault",(e,t)=>{Q.init(e,t),e._zod.optin="optional",V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>(s.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,s))}),yh=w("$ZodNonOptional",(e,t)=>{Q.init(e,t),V(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(s=>s!==void 0)):void 0}),e._zod.parse=(n,s)=>{const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>ko(o,e)):ko(i,e)}});function ko(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 xh=w("$ZodCatch",(e,t)=>{Q.init(e,t),V(e._zod,"optin",()=>t.innerType._zod.optin),V(e._zod,"optout",()=>t.innerType._zod.optout),V(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(o=>(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(r=>ie(r,s,se()))},input:n.value}),n.issues=[]),n)):(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(o=>ie(o,s,se()))},input:n.value}),n.issues=[]),n)}}),vh=w("$ZodPipe",(e,t)=>{Q.init(e,t),V(e._zod,"values",()=>t.in._zod.values),V(e._zod,"optin",()=>t.in._zod.optin),V(e._zod,"optout",()=>t.out._zod.optout),V(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,s)=>{if(s.direction==="backward"){const o=t.out._zod.run(n,s);return o instanceof Promise?o.then(r=>Ln(r,t.in,s)):Ln(o,t.in,s)}const i=t.in._zod.run(n,s);return i instanceof Promise?i.then(o=>Ln(o,t.out,s)):Ln(i,t.out,s)}});function Ln(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const kh=w("$ZodReadonly",(e,t)=>{Q.init(e,t),V(e._zod,"propValues",()=>t.innerType._zod.propValues),V(e._zod,"values",()=>t.innerType._zod.values),V(e._zod,"optin",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optin}),V(e._zod,"optout",()=>{var n,s;return(s=(n=t.innerType)==null?void 0:n._zod)==null?void 0:s.optout}),e._zod.parse=(n,s)=>{if(s.direction==="backward")return t.innerType._zod.run(n,s);const i=t.innerType._zod.run(n,s);return i instanceof Promise?i.then(wo):wo(i)}});function wo(e){return e.value=Object.freeze(e.value),e}const wh=w("$ZodCustom",(e,t)=>{Pt.init(e,t),Q.init(e,t),e._zod.parse=(n,s)=>n,e._zod.check=n=>{const s=n.value,i=t.fn(s);if(i instanceof Promise)return i.then(o=>So(o,n,s,e));So(i,n,s,e)}});function So(e,t,n,s){if(!e){const i={code:"custom",input:n,inst:s,path:[...s._zod.def.path??[]],continue:!s._zod.def.abort};s._zod.def.params&&(i.params=s._zod.def.params),t.issues.push(fn(i))}}var Mo;class Sh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const s=n[0];return this._map.set(t,s),s&&typeof s=="object"&&"id"in s&&this._idmap.set(s.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 s={...this.get(n)??{}};delete s.id;const i={...s,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Mh(){return new Sh}(Mo=globalThis).__zod_globalRegistry??(Mo.__zod_globalRegistry=Mh());const Qe=globalThis.__zod_globalRegistry;function Ph(e,t){return new e({type:"string",...R(t)})}function Th(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...R(t)})}function Po(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...R(t)})}function Ch(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...R(t)})}function zh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...R(t)})}function Oh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...R(t)})}function Rh(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...R(t)})}function Ah(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...R(t)})}function Ih(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...R(t)})}function Eh(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...R(t)})}function Dh(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...R(t)})}function Lh(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...R(t)})}function $h(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...R(t)})}function Nh(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...R(t)})}function Fh(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...R(t)})}function Hh(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...R(t)})}function jh(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...R(t)})}function Bh(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...R(t)})}function Zh(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...R(t)})}function Vh(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...R(t)})}function Wh(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...R(t)})}function qh(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...R(t)})}function Uh(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...R(t)})}function Yh(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...R(t)})}function Jh(e,t){return new e({type:"string",format:"date",check:"string_format",...R(t)})}function Kh(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...R(t)})}function Xh(e,t){return new e({type:"string",format:"duration",check:"string_format",...R(t)})}function Gh(e,t){return new e({type:"number",checks:[],...R(t)})}function Qh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...R(t)})}function td(e,t){return new e({type:"boolean",...R(t)})}function ed(e,t){return new e({type:"undefined",...R(t)})}function nd(e,t){return new e({type:"null",...R(t)})}function sd(e){return new e({type:"unknown"})}function id(e,t){return new e({type:"never",...R(t)})}function To(e,t){return new Ma({check:"less_than",...R(t),value:e,inclusive:!1})}function Ls(e,t){return new Ma({check:"less_than",...R(t),value:e,inclusive:!0})}function Co(e,t){return new Pa({check:"greater_than",...R(t),value:e,inclusive:!1})}function $s(e,t){return new Pa({check:"greater_than",...R(t),value:e,inclusive:!0})}function zo(e,t){return new gu({check:"multiple_of",...R(t),value:e})}function Ia(e,t){return new bu({check:"max_length",...R(t),maximum:e})}function ls(e,t){return new _u({check:"min_length",...R(t),minimum:e})}function Ea(e,t){return new yu({check:"length_equals",...R(t),length:e})}function od(e,t){return new xu({check:"string_format",format:"regex",...R(t),pattern:e})}function rd(e){return new vu({check:"string_format",format:"lowercase",...R(e)})}function ad(e){return new ku({check:"string_format",format:"uppercase",...R(e)})}function cd(e,t){return new wu({check:"string_format",format:"includes",...R(t),includes:e})}function ld(e,t){return new Su({check:"string_format",format:"starts_with",...R(t),prefix:e})}function ud(e,t){return new Mu({check:"string_format",format:"ends_with",...R(t),suffix:e})}function Ve(e){return new Pu({check:"overwrite",tx:e})}function hd(e){return Ve(t=>t.normalize(e))}function dd(){return Ve(e=>e.trim())}function fd(){return Ve(e=>e.toLowerCase())}function pd(){return Ve(e=>e.toUpperCase())}function gd(){return Ve(e=>yl(e))}function md(e,t,n){return new e({type:"array",element:t,...R(n)})}function bd(e,t,n){const s=R(n);return s.abort??(s.abort=!0),new e({type:"custom",check:"custom",fn:t,...s})}function _d(e,t,n){return new e({type:"custom",check:"custom",fn:t,...R(n)})}function yd(e){const t=xd(n=>(n.addIssue=s=>{if(typeof s=="string")n.issues.push(fn(s,n.value,t._zod.def));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=t),i.continue??(i.continue=!t._zod.def.abort),n.issues.push(fn(i))}},e(n.value,n)));return t}function xd(e,t){const n=new Pt({check:"custom",...R(t)});return n._zod.check=e,n}function Da(e){let t=(e==null?void 0:e.target)??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:(e==null?void 0:e.metadata)??Qe,target:t,unrepresentable:(e==null?void 0:e.unrepresentable)??"throw",override:(e==null?void 0:e.override)??(()=>{}),io:(e==null?void 0:e.io)??"output",counter:0,seen:new Map,cycles:(e==null?void 0:e.cycles)??"ref",reused:(e==null?void 0:e.reused)??"inline",external:(e==null?void 0:e.external)??void 0}}function ut(e,t,n={path:[],schemaPath:[]}){var u,h;var s;const i=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=(h=(u=e._zod).toJSONSchema)==null?void 0:h.call(u);if(a)r.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,r.schema,d);else{const p=r.schema,g=t.processors[i.type];if(!g)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);g(e,t,p,d)}const f=e._zod.parent;f&&(r.ref||(r.ref=f),ut(f,t,d),t.seen.get(f).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(r.schema,c),t.io==="input"&&kt(e)&&(delete r.schema.examples,delete r.schema.default),t.io==="input"&&r.schema._prefault&&((s=r.schema).default??(s.default=r.schema._prefault)),delete r.schema._prefault,t.seen.get(e).schema}function La(e,t){var r,a,c,l;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=new Map;for(const u of e.seen.entries()){const h=(r=e.metadataRegistry.get(u[0]))==null?void 0:r.id;if(h){const d=s.get(h);if(d&&d!==u[0])throw new Error(`Duplicate schema id "${h}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);s.set(h,u[0])}}const i=u=>{var g;const h=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const m=(g=e.external.registry.get(u[0]))==null?void 0:g.id,b=e.external.uri??(M=>M);if(m)return{ref:b(m)};const x=u[1].defId??u[1].schema.id??`schema${e.counter++}`;return u[1].defId=x,{defId:x,ref:`${b("__shared")}#/${h}/${x}`}}if(u[1]===n)return{ref:"#"};const f=`#/${h}/`,p=u[1].schema.id??`__schema${e.counter++}`;return{defId:p,ref:f+p}},o=u=>{if(u[1].schema.$ref)return;const h=u[1],{ref:d,defId:f}=i(u);h.def={...h.schema},f&&(h.defId=f);const p=h.schema;for(const g in p)delete p[g];p.$ref=d};if(e.cycles==="throw")for(const u of e.seen.entries()){const h=u[1];if(h.cycle)throw new Error(`Cycle detected: #/${(a=h.cycle)==null?void 0:a.join("/")}/<root>
|
|
45
45
|
|
|
46
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const h=u[1];if(t===u[0]){o(u);continue}if(e.external){const f=(c=e.external.registry.get(u[0]))==null?void 0:c.id;if(t!==u[0]&&f){o(u);continue}}if((l=e.metadataRegistry.get(u[0]))==null?void 0:l.id){o(u);continue}if(h.cycle){o(u);continue}if(h.count>1&&e.reused==="ref"){o(u);continue}}}function $a(e,t){var r,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=l=>{const u=e.seen.get(l);if(u.ref===null)return;const h=u.def??u.schema,d={...h},f=u.ref;if(u.ref=null,f){s(f);const g=e.seen.get(f),m=g.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(h.allOf=h.allOf??[],h.allOf.push(m)):Object.assign(h,m),Object.assign(h,d),l._zod.parent===f)for(const x in h)x==="$ref"||x==="allOf"||x in d||delete h[x];if(m.$ref)for(const x in h)x==="$ref"||x==="allOf"||x in g.def&&JSON.stringify(h[x])===JSON.stringify(g.def[x])&&delete h[x]}const p=l._zod.parent;if(p&&p!==f){s(p);const g=e.seen.get(p);if(g!=null&&g.schema.$ref&&(h.$ref=g.schema.$ref,g.def))for(const m in h)m==="$ref"||m==="allOf"||m in g.def&&JSON.stringify(h[m])===JSON.stringify(g.def[m])&&delete h[m]}e.override({zodSchema:l,jsonSchema:h,path:u.path??[]})};for(const l of[...e.seen.entries()].reverse())s(l[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(r=e.external)!=null&&r.uri){const l=(a=e.external.registry.get(t))==null?void 0:a.id;if(!l)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(l)}Object.assign(i,n.def??n.schema);const o=((c=e.external)==null?void 0:c.defs)??{};for(const l of e.seen.entries()){const u=l[1];u.def&&u.defId&&(o[u.defId]=u.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const l=JSON.parse(JSON.stringify(i));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:us(t,"input",e.processors),output:us(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function kt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return kt(s.element,n);if(s.type==="set")return kt(s.valueType,n);if(s.type==="lazy")return kt(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return kt(s.innerType,n);if(s.type==="intersection")return kt(s.left,n)||kt(s.right,n);if(s.type==="record"||s.type==="map")return kt(s.keyType,n)||kt(s.valueType,n);if(s.type==="pipe")return kt(s.in,n)||kt(s.out,n);if(s.type==="object"){for(const i in s.shape)if(kt(s.shape[i],n))return!0;return!1}if(s.type==="union"){for(const i of s.options)if(kt(i,n))return!0;return!1}if(s.type==="tuple"){for(const i of s.items)if(kt(i,n))return!0;return!!(s.rest&&kt(s.rest,n))}return!1}const kd=(e,t={})=>n=>{const s=Ea({...n,processors:t});return ut(e,s),La(s,e),$a(s,e)},us=(e,t,n={})=>s=>{const{libraryOptions:i,target:o}=s??{},r=Ea({...i??{},target:o,io:t,processors:n});return ut(e,r),La(r,e),$a(r,e)},wd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Sd=(e,t,n,s)=>{const i=n;i.type="string";const{minimum:o,maximum:r,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof r=="number"&&(i.maxLength=r),a&&(i.format=wd[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){const u=[...c];u.length===1?i.pattern=u[0].source:u.length>1&&(i.allOf=[...u.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Md=(e,t,n,s)=>{const i=n,{minimum:o,maximum:r,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof o=="number"&&(i.minimum=o,typeof u=="number"&&t.target!=="draft-04"&&(u>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof r=="number"&&(i.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},Pd=(e,t,n,s)=>{n.type="boolean"},Td=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Cd=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},zd=(e,t,n,s)=>{n.not={}},Od=(e,t,n,s)=>{},Rd=(e,t,n,s)=>{const i=e._zod.def,o=fa(i.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},Ad=(e,t,n,s)=>{const i=e._zod.def,o=[];for(const r of i.values)if(r===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof r=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(r))}else o.push(r);if(o.length!==0)if(o.length===1){const r=o[0];n.type=r===null?"null":typeof r,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[r]:n.const=r}else o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),o.every(r=>typeof r=="boolean")&&(n.type="boolean"),o.every(r=>r===null)&&(n.type="null"),n.enum=o},Id=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Dd=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ed=(e,t,n,s)=>{const i=n,o=e._zod.def,{minimum:r,maximum:a}=e._zod.bag;typeof r=="number"&&(i.minItems=r),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ut(o.element,t,{...s,path:[...s.path,"items"]})},Ld=(e,t,n,s)=>{var l;const i=n,o=e._zod.def;i.type="object",i.properties={};const r=o.shape;for(const u in r)i.properties[u]=ut(r[u],t,{...s,path:[...s.path,"properties",u]});const a=new Set(Object.keys(r)),c=new Set([...a].filter(u=>{const h=o.shape[u]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((l=o.catchall)==null?void 0:l._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=ut(o.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},$d=(e,t,n,s)=>{const i=e._zod.def,o=i.inclusive===!1,r=i.options.map((a,c)=>ut(a,t,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},Nd=(e,t,n,s)=>{const i=e._zod.def,o=ut(i.left,t,{...s,path:[...s.path,"allOf",0]}),r=ut(i.right,t,{...s,path:[...s.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},Fd=(e,t,n,s)=>{const i=n,o=e._zod.def;i.type="object";const r=o.keyType,a=r._zod.bag,c=a==null?void 0:a.patterns;if(o.mode==="loose"&&c&&c.size>0){const u=ut(o.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});i.patternProperties={};for(const h of c)i.patternProperties[h.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=ut(o.keyType,t,{...s,path:[...s.path,"propertyNames"]})),i.additionalProperties=ut(o.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const l=r._zod.values;if(l){const u=[...l].filter(h=>typeof h=="string"||typeof h=="number");u.length>0&&(i.required=u)}},jd=(e,t,n,s)=>{const i=e._zod.def,o=ut(i.innerType,t,s),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Bd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType},Hd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Zd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Vd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType;let r;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Wd=(e,t,n,s)=>{const i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ut(o,t,s);const r=t.seen.get(e);r.ref=o},qd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Na=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType};function Pi(e){return!!e._zod}function Fa(e,t){return Pi(e)?ya(e,t):e.safeParse(t)}function Ud(e){var n,s;if(!e)return;let t;if(Pi(e)?t=(s=(n=e._zod)==null?void 0:n.def)==null?void 0:s.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Yd(e){var i;if(Pi(e)){const r=(i=e._zod)==null?void 0:i.def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const s=e.value;if(s!==void 0)return s}const Jd=w("ZodISODateTime",(e,t)=>{Bu.init(e,t),ot.init(e,t)});function ja(e){return Jh(Jd,e)}const Xd=w("ZodISODate",(e,t)=>{Hu.init(e,t),ot.init(e,t)});function Kd(e){return Xh(Xd,e)}const Gd=w("ZodISOTime",(e,t)=>{Zu.init(e,t),ot.init(e,t)});function Qd(e){return Kh(Gd,e)}const tf=w("ZodISODuration",(e,t)=>{Vu.init(e,t),ot.init(e,t)});function ef(e){return Gh(tf,e)}const nf=(e,t)=>{ba.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Il(e,n)},flatten:{value:n=>Al(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Gs,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Gs,2)}},isEmpty:{get(){return e.issues.length===0}}})},At=w("ZodError",nf,{Parent:Error}),sf=wi(At),of=Si(At),rf=ks(At),af=ws(At),cf=El(At),lf=Ll(At),uf=$l(At),hf=Nl(At),df=Fl(At),ff=jl(At),pf=Bl(At),gf=Hl(At),tt=w("ZodType",(e,t)=>(Q.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:us(e,"input"),output:us(e,"output")}}),e.toJSONSchema=kd(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ae(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>ce(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>sf(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>rf(e,n,s),e.parseAsync=async(n,s)=>of(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>af(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>cf(e,n,s),e.decode=(n,s)=>lf(e,n,s),e.encodeAsync=async(n,s)=>uf(e,n,s),e.decodeAsync=async(n,s)=>hf(e,n,s),e.safeEncode=(n,s)=>df(e,n,s),e.safeDecode=(n,s)=>ff(e,n,s),e.safeEncodeAsync=async(n,s)=>pf(e,n,s),e.safeDecodeAsync=async(n,s)=>gf(e,n,s),e.refine=(n,s)=>e.check(ap(n,s)),e.superRefine=n=>e.check(cp(n)),e.overwrite=n=>e.check(Ve(n)),e.optional=()=>at(e),e.exactOptional=()=>Yf(e),e.nullable=()=>Ao(e),e.nullish=()=>at(Ao(e)),e.nonoptional=n=>tp(e,n),e.array=()=>I(e),e.or=n=>F([e,n]),e.and=n=>Ti(e,n),e.transform=n=>ni(e,Ua(n)),e.default=n=>Kf(e,n),e.prefault=n=>Qf(e,n),e.catch=n=>np(e,n),e.pipe=n=>ni(e,n),e.readonly=()=>op(e),e.describe=n=>{const s=e.clone();return Qe.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){var n;return(n=Qe.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Qe.get(e);const s=e.clone();return Qe.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Ba=w("_ZodString",(e,t)=>{Mi.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(s,i,o)=>Sd(e,s,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(rd(...s)),e.includes=(...s)=>e.check(ld(...s)),e.startsWith=(...s)=>e.check(ud(...s)),e.endsWith=(...s)=>e.check(hd(...s)),e.min=(...s)=>e.check(ls(...s)),e.max=(...s)=>e.check(Ia(...s)),e.length=(...s)=>e.check(Da(...s)),e.nonempty=(...s)=>e.check(ls(1,...s)),e.lowercase=s=>e.check(ad(s)),e.uppercase=s=>e.check(cd(s)),e.trim=()=>e.check(fd()),e.normalize=(...s)=>e.check(dd(...s)),e.toLowerCase=()=>e.check(pd()),e.toUpperCase=()=>e.check(gd()),e.slugify=()=>e.check(md())}),mf=w("ZodString",(e,t)=>{Mi.init(e,t),Ba.init(e,t),e.email=n=>e.check(Ch(bf,n)),e.url=n=>e.check(Ih(_f,n)),e.jwt=n=>e.check(Yh(If,n)),e.emoji=n=>e.check(Dh(yf,n)),e.guid=n=>e.check(Po(Oo,n)),e.uuid=n=>e.check(zh($n,n)),e.uuidv4=n=>e.check(Oh($n,n)),e.uuidv6=n=>e.check(Rh($n,n)),e.uuidv7=n=>e.check(Ah($n,n)),e.nanoid=n=>e.check(Eh(xf,n)),e.guid=n=>e.check(Po(Oo,n)),e.cuid=n=>e.check(Lh(vf,n)),e.cuid2=n=>e.check($h(kf,n)),e.ulid=n=>e.check(Nh(wf,n)),e.base64=n=>e.check(Wh(Of,n)),e.base64url=n=>e.check(qh(Rf,n)),e.xid=n=>e.check(Fh(Sf,n)),e.ksuid=n=>e.check(jh(Mf,n)),e.ipv4=n=>e.check(Bh(Pf,n)),e.ipv6=n=>e.check(Hh(Tf,n)),e.cidrv4=n=>e.check(Zh(Cf,n)),e.cidrv6=n=>e.check(Vh(zf,n)),e.e164=n=>e.check(Uh(Af,n)),e.datetime=n=>e.check(ja(n)),e.date=n=>e.check(Kd(n)),e.time=n=>e.check(Qd(n)),e.duration=n=>e.check(ef(n))});function y(e){return Th(mf,e)}const ot=w("ZodStringFormat",(e,t)=>{it.init(e,t),Ba.init(e,t)}),bf=w("ZodEmail",(e,t)=>{Au.init(e,t),ot.init(e,t)}),Oo=w("ZodGUID",(e,t)=>{Ou.init(e,t),ot.init(e,t)}),$n=w("ZodUUID",(e,t)=>{Ru.init(e,t),ot.init(e,t)}),_f=w("ZodURL",(e,t)=>{Iu.init(e,t),ot.init(e,t)}),yf=w("ZodEmoji",(e,t)=>{Du.init(e,t),ot.init(e,t)}),xf=w("ZodNanoID",(e,t)=>{Eu.init(e,t),ot.init(e,t)}),vf=w("ZodCUID",(e,t)=>{Lu.init(e,t),ot.init(e,t)}),kf=w("ZodCUID2",(e,t)=>{$u.init(e,t),ot.init(e,t)}),wf=w("ZodULID",(e,t)=>{Nu.init(e,t),ot.init(e,t)}),Sf=w("ZodXID",(e,t)=>{Fu.init(e,t),ot.init(e,t)}),Mf=w("ZodKSUID",(e,t)=>{ju.init(e,t),ot.init(e,t)}),Pf=w("ZodIPv4",(e,t)=>{Wu.init(e,t),ot.init(e,t)}),Tf=w("ZodIPv6",(e,t)=>{qu.init(e,t),ot.init(e,t)}),Cf=w("ZodCIDRv4",(e,t)=>{Uu.init(e,t),ot.init(e,t)}),zf=w("ZodCIDRv6",(e,t)=>{Yu.init(e,t),ot.init(e,t)}),Of=w("ZodBase64",(e,t)=>{Ju.init(e,t),ot.init(e,t)}),Rf=w("ZodBase64URL",(e,t)=>{Ku.init(e,t),ot.init(e,t)}),Af=w("ZodE164",(e,t)=>{Gu.init(e,t),ot.init(e,t)}),If=w("ZodJWT",(e,t)=>{th.init(e,t),ot.init(e,t)}),Ha=w("ZodNumber",(e,t)=>{Ca.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(s,i,o)=>Md(e,s,i),e.gt=(s,i)=>e.check(Co(s,i)),e.gte=(s,i)=>e.check($s(s,i)),e.min=(s,i)=>e.check($s(s,i)),e.lt=(s,i)=>e.check(To(s,i)),e.lte=(s,i)=>e.check(Ls(s,i)),e.max=(s,i)=>e.check(Ls(s,i)),e.int=s=>e.check(Ro(s)),e.safe=s=>e.check(Ro(s)),e.positive=s=>e.check(Co(0,s)),e.nonnegative=s=>e.check($s(0,s)),e.negative=s=>e.check(To(0,s)),e.nonpositive=s=>e.check(Ls(0,s)),e.multipleOf=(s,i)=>e.check(zo(s,i)),e.step=(s,i)=>e.check(zo(s,i)),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 $(e){return Qh(Ha,e)}const Df=w("ZodNumberFormat",(e,t)=>{eh.init(e,t),Ha.init(e,t)});function Ro(e){return td(Df,e)}const Ef=w("ZodBoolean",(e,t)=>{nh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Pd(e,n,s)});function K(e){return ed(Ef,e)}const Lf=w("ZodUndefined",(e,t)=>{sh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Cd(e,n)});function ti(e){return nd(Lf,e)}const $f=w("ZodNull",(e,t)=>{ih.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Td(e,n,s)});function Za(e){return sd($f,e)}const Nf=w("ZodUnknown",(e,t)=>{oh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Od()});function J(){return id(Nf)}const Ff=w("ZodNever",(e,t)=>{rh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>zd(e,n,s)});function jf(e){return od(Ff,e)}const Bf=w("ZodArray",(e,t)=>{ah.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Ed(e,n,s,i),e.element=t.element,e.min=(n,s)=>e.check(ls(n,s)),e.nonempty=n=>e.check(ls(1,n)),e.max=(n,s)=>e.check(Ia(n,s)),e.length=(n,s)=>e.check(Da(n,s)),e.unwrap=()=>e.element});function I(e,t){return bd(Bf,e,t)}const Va=w("ZodObject",(e,t)=>{lh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Ld(e,n,s,i),V(e,"shape",()=>t.shape),e.keyof=()=>zt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:J()}),e.loose=()=>e.clone({...e._zod.def,catchall:J()}),e.strict=()=>e.clone({...e._zod.def,catchall:jf()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Tl(e,n),e.safeExtend=n=>Cl(e,n),e.merge=n=>zl(e,n),e.pick=n=>Ml(e,n),e.omit=n=>Pl(e,n),e.partial=(...n)=>Ol(Ya,e,n[0]),e.required=(...n)=>Rl(Ja,e,n[0])});function v(e,t){const n={type:"object",shape:e??{},...R(t)};return new Va(n)}function Mt(e,t){return new Va({type:"object",shape:e,catchall:J(),...R(t)})}const Wa=w("ZodUnion",(e,t)=>{Ra.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>$d(e,n,s,i),e.options=t.options});function F(e,t){return new Wa({type:"union",options:e,...R(t)})}const Hf=w("ZodDiscriminatedUnion",(e,t)=>{Wa.init(e,t),uh.init(e,t)});function qa(e,t,n){return new Hf({type:"union",options:t,discriminator:e,...R(n)})}const Zf=w("ZodIntersection",(e,t)=>{hh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Nd(e,n,s,i)});function Ti(e,t){return new Zf({type:"intersection",left:e,right:t})}const Vf=w("ZodRecord",(e,t)=>{dh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Fd(e,n,s,i),e.keyType=t.keyType,e.valueType=t.valueType});function Y(e,t,n){return new Vf({type:"record",keyType:e,valueType:t,...R(n)})}const ei=w("ZodEnum",(e,t)=>{fh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(s,i,o)=>Rd(e,s,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,i)=>{const o={};for(const r of s)if(n.has(r))o[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new ei({...t,checks:[],...R(i),entries:o})},e.exclude=(s,i)=>{const o={...t.entries};for(const r of s)if(n.has(r))delete o[r];else throw new Error(`Key ${r} not found in enum`);return new ei({...t,checks:[],...R(i),entries:o})}});function zt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new ei({type:"enum",entries:n,...R(t)})}const Wf=w("ZodLiteral",(e,t)=>{ph.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Ad(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function _(e,t){return new Wf({type:"literal",values:Array.isArray(e)?e:[e],...R(t)})}const qf=w("ZodTransform",(e,t)=>{gh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Dd(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new ha(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(fn(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(fn(r))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function Ua(e){return new qf({type:"transform",transform:e})}const Ya=w("ZodOptional",(e,t)=>{Aa.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Na(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function at(e){return new Ya({type:"optional",innerType:e})}const Uf=w("ZodExactOptional",(e,t)=>{mh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Na(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Yf(e){return new Uf({type:"optional",innerType:e})}const Jf=w("ZodNullable",(e,t)=>{bh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>jd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Ao(e){return new Jf({type:"nullable",innerType:e})}const Xf=w("ZodDefault",(e,t)=>{_h.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Hd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kf(e,t){return new Xf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ga(t)}})}const Gf=w("ZodPrefault",(e,t)=>{yh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Zd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Qf(e,t){return new Gf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ga(t)}})}const Ja=w("ZodNonOptional",(e,t)=>{xh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Bd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function tp(e,t){return new Ja({type:"nonoptional",innerType:e,...R(t)})}const ep=w("ZodCatch",(e,t)=>{vh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Vd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function np(e,t){return new ep({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const sp=w("ZodPipe",(e,t)=>{kh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Wd(e,n,s,i),e.in=t.in,e.out=t.out});function ni(e,t){return new sp({type:"pipe",in:e,out:t})}const ip=w("ZodReadonly",(e,t)=>{wh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>qd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function op(e){return new ip({type:"readonly",innerType:e})}const Xa=w("ZodCustom",(e,t)=>{Sh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Id(e,n)});function rp(e,t){return _d(Xa,e??(()=>!0),t)}function ap(e,t={}){return yd(Xa,e,t)}function cp(e){return xd(e)}function Ka(e,t){return ni(Ua(e),t)}const be="io.modelcontextprotocol/related-task",Ms="2.0",pt=rp(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Ga=F([y(),$().int()]),Qa=y();Mt({ttl:F([$(),Za()]).optional(),pollInterval:$().optional()});const lp=v({ttl:$().optional()}),up=v({taskId:y()}),Ci=Mt({progressToken:Ga.optional(),[be]:up.optional()}),Ot=v({_meta:Ci.optional()}),wn=Ot.extend({task:lp.optional()}),hp=e=>wn.safeParse(e).success,gt=v({method:y(),params:Ot.loose().optional()}),It=v({_meta:Ci.optional()}),Dt=v({method:y(),params:It.loose().optional()}),mt=Mt({_meta:Ci.optional()}),Sn=F([y(),$().int()]),tc=v({jsonrpc:_(Ms),id:Sn,...gt.shape}).strict(),Io=e=>tc.safeParse(e).success,ec=v({jsonrpc:_(Ms),...Dt.shape}).strict(),dp=e=>ec.safeParse(e).success,zi=v({jsonrpc:_(Ms),id:Sn,result:mt}).strict(),Nn=e=>zi.safeParse(e).success;var U;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(U||(U={}));const Oi=v({jsonrpc:_(Ms),id:Sn.optional(),error:v({code:$().int(),message:y(),data:J().optional()})}).strict(),fp=e=>Oi.safeParse(e).success,pp=F([tc,ec,zi,Oi]);F([zi,Oi]);const Ri=mt.strict(),gp=It.extend({requestId:Sn.optional(),reason:y().optional()}),Ai=Dt.extend({method:_("notifications/cancelled"),params:gp}),mp=v({src:y(),mimeType:y().optional(),sizes:I(y()).optional(),theme:zt(["light","dark"]).optional()}),Mn=v({icons:I(mp).optional()}),Fe=v({name:y(),title:y().optional()}),Ps=Fe.extend({...Fe.shape,...Mn.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),bp=Ti(v({applyDefaults:K().optional()}),Y(y(),J())),_p=Ka(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ti(v({form:bp.optional(),url:pt.optional()}),Y(y(),J()).optional())),yp=Mt({list:pt.optional(),cancel:pt.optional(),requests:Mt({sampling:Mt({createMessage:pt.optional()}).optional(),elicitation:Mt({create:pt.optional()}).optional()}).optional()}),xp=Mt({list:pt.optional(),cancel:pt.optional(),requests:Mt({tools:Mt({call:pt.optional()}).optional()}).optional()}),vp=v({experimental:Y(y(),pt).optional(),sampling:v({context:pt.optional(),tools:pt.optional()}).optional(),elicitation:_p.optional(),roots:v({listChanged:K().optional()}).optional(),tasks:yp.optional()}),kp=Ot.extend({protocolVersion:y(),capabilities:vp,clientInfo:Ps}),wp=gt.extend({method:_("initialize"),params:kp}),Sp=v({experimental:Y(y(),pt).optional(),logging:pt.optional(),completions:pt.optional(),prompts:v({listChanged:K().optional()}).optional(),resources:v({subscribe:K().optional(),listChanged:K().optional()}).optional(),tools:v({listChanged:K().optional()}).optional(),tasks:xp.optional()}),Mp=mt.extend({protocolVersion:y(),capabilities:Sp,serverInfo:Ps,instructions:y().optional()}),Pp=Dt.extend({method:_("notifications/initialized"),params:It.optional()}),Ts=gt.extend({method:_("ping"),params:Ot.optional()}),Tp=v({progress:$(),total:at($()),message:at(y())}),Cp=v({...It.shape,...Tp.shape,progressToken:Ga}),Ii=Dt.extend({method:_("notifications/progress"),params:Cp}),zp=Ot.extend({cursor:Qa.optional()}),Pn=gt.extend({params:zp.optional()}),Tn=mt.extend({nextCursor:Qa.optional()}),Op=zt(["working","input_required","completed","failed","cancelled"]),Cn=v({taskId:y(),status:Op,ttl:F([$(),Za()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:at($()),statusMessage:at(y())}),Di=mt.extend({task:Cn}),Rp=It.merge(Cn),hs=Dt.extend({method:_("notifications/tasks/status"),params:Rp}),Ei=gt.extend({method:_("tasks/get"),params:Ot.extend({taskId:y()})}),Li=mt.merge(Cn),$i=gt.extend({method:_("tasks/result"),params:Ot.extend({taskId:y()})});mt.loose();const Ni=Pn.extend({method:_("tasks/list")}),Fi=Tn.extend({tasks:I(Cn)}),ji=gt.extend({method:_("tasks/cancel"),params:Ot.extend({taskId:y()})}),Ap=mt.merge(Cn),nc=v({uri:y(),mimeType:at(y()),_meta:Y(y(),J()).optional()}),sc=nc.extend({text:y()}),Bi=y().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ic=nc.extend({blob:Bi}),zn=zt(["user","assistant"]),We=v({audience:I(zn).optional(),priority:$().min(0).max(1).optional(),lastModified:ja({offset:!0}).optional()}),oc=v({...Fe.shape,...Mn.shape,uri:y(),description:at(y()),mimeType:at(y()),annotations:We.optional(),_meta:at(Mt({}))}),Ip=v({...Fe.shape,...Mn.shape,uriTemplate:y(),description:at(y()),mimeType:at(y()),annotations:We.optional(),_meta:at(Mt({}))}),Dp=Pn.extend({method:_("resources/list")}),rc=Tn.extend({resources:I(oc)}),Ep=Pn.extend({method:_("resources/templates/list")}),Lp=Tn.extend({resourceTemplates:I(Ip)}),Hi=Ot.extend({uri:y()}),$p=Hi,Np=gt.extend({method:_("resources/read"),params:$p}),ac=mt.extend({contents:I(F([sc,ic]))}),Fp=Dt.extend({method:_("notifications/resources/list_changed"),params:It.optional()}),jp=Hi,Bp=gt.extend({method:_("resources/subscribe"),params:jp}),Hp=Hi,Zp=gt.extend({method:_("resources/unsubscribe"),params:Hp}),Vp=It.extend({uri:y()}),Wp=Dt.extend({method:_("notifications/resources/updated"),params:Vp}),qp=v({name:y(),description:at(y()),required:at(K())}),Up=v({...Fe.shape,...Mn.shape,description:at(y()),arguments:at(I(qp)),_meta:at(Mt({}))}),Yp=Pn.extend({method:_("prompts/list")}),Jp=Tn.extend({prompts:I(Up)}),Xp=Ot.extend({name:y(),arguments:Y(y(),y()).optional()}),Kp=gt.extend({method:_("prompts/get"),params:Xp}),Zi=v({type:_("text"),text:y(),annotations:We.optional(),_meta:Y(y(),J()).optional()}),Vi=v({type:_("image"),data:Bi,mimeType:y(),annotations:We.optional(),_meta:Y(y(),J()).optional()}),Wi=v({type:_("audio"),data:Bi,mimeType:y(),annotations:We.optional(),_meta:Y(y(),J()).optional()}),Gp=v({type:_("tool_use"),name:y(),id:y(),input:Y(y(),J()),_meta:Y(y(),J()).optional()}),cc=v({type:_("resource"),resource:F([sc,ic]),annotations:We.optional(),_meta:Y(y(),J()).optional()}),lc=oc.extend({type:_("resource_link")}),On=F([Zi,Vi,Wi,lc,cc]),Qp=v({role:zn,content:On}),tg=mt.extend({description:y().optional(),messages:I(Qp)}),eg=Dt.extend({method:_("notifications/prompts/list_changed"),params:It.optional()}),ng=v({title:y().optional(),readOnlyHint:K().optional(),destructiveHint:K().optional(),idempotentHint:K().optional(),openWorldHint:K().optional()}),sg=v({taskSupport:zt(["required","optional","forbidden"]).optional()}),qi=v({...Fe.shape,...Mn.shape,description:y().optional(),inputSchema:v({type:_("object"),properties:Y(y(),pt).optional(),required:I(y()).optional()}).catchall(J()),outputSchema:v({type:_("object"),properties:Y(y(),pt).optional(),required:I(y()).optional()}).catchall(J()).optional(),annotations:ng.optional(),execution:sg.optional(),_meta:Y(y(),J()).optional()}),uc=Pn.extend({method:_("tools/list")}),ig=Tn.extend({tools:I(qi)}),Cs=mt.extend({content:I(On).default([]),structuredContent:Y(y(),J()).optional(),isError:K().optional()});Cs.or(mt.extend({toolResult:J()}));const og=wn.extend({name:y(),arguments:Y(y(),J()).optional()}),hc=gt.extend({method:_("tools/call"),params:og}),rg=Dt.extend({method:_("notifications/tools/list_changed"),params:It.optional()});v({autoRefresh:K().default(!0),debounceMs:$().int().nonnegative().default(300)});const dc=zt(["debug","info","notice","warning","error","critical","alert","emergency"]),ag=Ot.extend({level:dc}),cg=gt.extend({method:_("logging/setLevel"),params:ag}),lg=It.extend({level:dc,logger:y().optional(),data:J()}),ug=Dt.extend({method:_("notifications/message"),params:lg}),hg=v({name:y().optional()}),dg=v({hints:I(hg).optional(),costPriority:$().min(0).max(1).optional(),speedPriority:$().min(0).max(1).optional(),intelligencePriority:$().min(0).max(1).optional()}),fg=v({mode:zt(["auto","required","none"]).optional()}),pg=v({type:_("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:I(On).default([]),structuredContent:v({}).loose().optional(),isError:K().optional(),_meta:Y(y(),J()).optional()}),gg=qa("type",[Zi,Vi,Wi]),ds=qa("type",[Zi,Vi,Wi,Gp,pg]),mg=v({role:zn,content:F([ds,I(ds)]),_meta:Y(y(),J()).optional()}),bg=wn.extend({messages:I(mg),modelPreferences:dg.optional(),systemPrompt:y().optional(),includeContext:zt(["none","thisServer","allServers"]).optional(),temperature:$().optional(),maxTokens:$().int(),stopSequences:I(y()).optional(),metadata:pt.optional(),tools:I(qi).optional(),toolChoice:fg.optional()}),_g=gt.extend({method:_("sampling/createMessage"),params:bg}),yg=mt.extend({model:y(),stopReason:at(zt(["endTurn","stopSequence","maxTokens"]).or(y())),role:zn,content:gg}),xg=mt.extend({model:y(),stopReason:at(zt(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:zn,content:F([ds,I(ds)])}),vg=v({type:_("boolean"),title:y().optional(),description:y().optional(),default:K().optional()}),kg=v({type:_("string"),title:y().optional(),description:y().optional(),minLength:$().optional(),maxLength:$().optional(),format:zt(["email","uri","date","date-time"]).optional(),default:y().optional()}),wg=v({type:zt(["number","integer"]),title:y().optional(),description:y().optional(),minimum:$().optional(),maximum:$().optional(),default:$().optional()}),Sg=v({type:_("string"),title:y().optional(),description:y().optional(),enum:I(y()),default:y().optional()}),Mg=v({type:_("string"),title:y().optional(),description:y().optional(),oneOf:I(v({const:y(),title:y()})),default:y().optional()}),Pg=v({type:_("string"),title:y().optional(),description:y().optional(),enum:I(y()),enumNames:I(y()).optional(),default:y().optional()}),Tg=F([Sg,Mg]),Cg=v({type:_("array"),title:y().optional(),description:y().optional(),minItems:$().optional(),maxItems:$().optional(),items:v({type:_("string"),enum:I(y())}),default:I(y()).optional()}),zg=v({type:_("array"),title:y().optional(),description:y().optional(),minItems:$().optional(),maxItems:$().optional(),items:v({anyOf:I(v({const:y(),title:y()}))}),default:I(y()).optional()}),Og=F([Cg,zg]),Rg=F([Pg,Tg,Og]),Ag=F([Rg,vg,kg,wg]),Ig=wn.extend({mode:_("form").optional(),message:y(),requestedSchema:v({type:_("object"),properties:Y(y(),Ag),required:I(y()).optional()})}),Dg=wn.extend({mode:_("url"),message:y(),elicitationId:y(),url:y().url()}),Eg=F([Ig,Dg]),Lg=gt.extend({method:_("elicitation/create"),params:Eg}),$g=It.extend({elicitationId:y()}),Ng=Dt.extend({method:_("notifications/elicitation/complete"),params:$g}),Fg=mt.extend({action:zt(["accept","decline","cancel"]),content:Ka(e=>e===null?void 0:e,Y(y(),F([y(),$(),K(),I(y())])).optional())}),jg=v({type:_("ref/resource"),uri:y()}),Bg=v({type:_("ref/prompt"),name:y()}),Hg=Ot.extend({ref:F([Bg,jg]),argument:v({name:y(),value:y()}),context:v({arguments:Y(y(),y()).optional()}).optional()}),Zg=gt.extend({method:_("completion/complete"),params:Hg}),Vg=mt.extend({completion:Mt({values:I(y()).max(100),total:at($().int()),hasMore:at(K())})}),Wg=v({uri:y().startsWith("file://"),name:y().optional(),_meta:Y(y(),J()).optional()}),qg=gt.extend({method:_("roots/list"),params:Ot.optional()}),Ug=mt.extend({roots:I(Wg)}),Yg=Dt.extend({method:_("notifications/roots/list_changed"),params:It.optional()});F([Ts,wp,Zg,cg,Kp,Yp,Dp,Ep,Np,Bp,Zp,hc,uc,Ei,$i,Ni,ji]);F([Ai,Ii,Pp,Yg,hs]);F([Ri,yg,xg,Fg,Ug,Li,Fi,Di]);F([Ts,_g,Lg,qg,Ei,$i,Ni,ji]);F([Ai,Ii,ug,Wp,Fp,rg,eg,hs,Ng]);F([Ri,Mp,Vg,tg,Jp,rc,Lp,ac,Cs,ig,Li,Fi,Di]);class H extends Error{constructor(t,n,s){super(`MCP error ${t}: ${n}`),this.code=t,this.data=s,this.name="McpError"}static fromError(t,n,s){if(t===U.UrlElicitationRequired&&s){const i=s;if(i.elicitations)return new Jg(i.elicitations,n)}return new H(t,n,s)}}class Jg extends H{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(U.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function de(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Do(e){const t=Ud(e),n=t==null?void 0:t.method;if(!n)throw new Error("Schema is missing a method literal");const s=Yd(n);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Eo(e,t){const n=Fa(e,t);if(!n.success)throw n.error;return n.data}const Xg=6e4;class Kg{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ai,n=>{this._oncancel(n)}),this.setNotificationHandler(Ii,n=>{this._onprogress(n)}),this.setRequestHandler(Ts,n=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ei,async(n,s)=>{const i=await this._taskStore.getTask(n.params.taskId,s.sessionId);if(!i)throw new H(U.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler($i,async(n,s)=>{const i=async()=>{var a;const o=n.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,u=l.id,h=this._requestResolvers.get(u);if(h)if(this._requestResolvers.delete(u),c.type==="response")h(l);else{const d=l,f=new H(d.error.code,d.error.message,d.error.data);h(f)}else{const d=c.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await((a=this._transport)==null?void 0:a.send(c.message,{relatedRequestId:s.requestId}))}}const r=await this._taskStore.getTask(o,s.sessionId);if(!r)throw new H(U.InvalidParams,`Task not found: ${o}`);if(!de(r.status))return await this._waitForTaskUpdate(o,s.signal),await i();if(de(r.status)){const c=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[be]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Ni,async(n,s)=>{var i;try{const{tasks:o,nextCursor:r}=await this._taskStore.listTasks((i=n.params)==null?void 0:i.cursor,s.sessionId);return{tasks:o,nextCursor:r,_meta:{}}}catch(o){throw new H(U.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ji,async(n,s)=>{try{const i=await this._taskStore.getTask(n.params.taskId,s.sessionId);if(!i)throw new H(U.InvalidParams,`Task not found: ${n.params.taskId}`);if(de(i.status))throw new H(U.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(n.params.taskId);const o=await this._taskStore.getTask(n.params.taskId,s.sessionId);if(!o)throw new H(U.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof H?i:new H(U.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}_setupTimeout(t,n,s,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,n),startTime:Date.now(),timeout:n,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const s=Date.now()-n.startTime;if(n.maxTotalTimeout&&s>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),H.fromError(U.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:s});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var o,r,a;this._transport=t;const n=(o=this.transport)==null?void 0:o.onclose;this._transport.onclose=()=>{n==null||n(),this._onclose()};const s=(r=this.transport)==null?void 0:r.onerror;this._transport.onerror=c=>{s==null||s(c),this._onerror(c)};const i=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(c,l)=>{i==null||i(c,l),Nn(c)||fp(c)?this._onresponse(c):Io(c)?this._onrequest(c,l):dp(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var s;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const n=H.fromError(U.ConnectionClosed,"Connection closed");this._transport=void 0,(s=this.onclose)==null||s.call(this);for(const i of t.values())i(n)}_onerror(t){var n;(n=this.onerror)==null||n.call(this,t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(t,n){var u,h,d,f;const s=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=(d=(h=(u=t.params)==null?void 0:u._meta)==null?void 0:h[be])==null?void 0:d.taskId;if(s===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:U.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:p,timestamp:Date.now()},i==null?void 0:i.sessionId).catch(g=>this._onerror(new Error(`Failed to enqueue error response: ${g}`))):i==null||i.send(p).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)));return}const r=new AbortController;this._requestHandlerAbortControllers.set(t.id,r);const a=hp(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,i==null?void 0:i.sessionId):void 0,l={signal:r.signal,sessionId:i==null?void 0:i.sessionId,_meta:(f=t.params)==null?void 0:f._meta,sendNotification:async p=>{const g={relatedRequestId:t.id};o&&(g.relatedTask={taskId:o}),await this.notification(p,g)},sendRequest:async(p,g,m)=>{var M;const b={...m,relatedRequestId:t.id};o&&!b.relatedTask&&(b.relatedTask={taskId:o});const x=((M=b.relatedTask)==null?void 0:M.taskId)??o;return x&&c&&await c.updateTaskStatus(x,"input_required"),await this.request(p,g,b)},authInfo:n==null?void 0:n.authInfo,requestId:t.id,requestInfo:n==null?void 0:n.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:n==null?void 0:n.closeSSEStream,closeStandaloneSSEStream:n==null?void 0:n.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>s(t,l)).then(async p=>{if(r.signal.aborted)return;const g={result:p,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:g,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(g))},async p=>{if(r.signal.aborted)return;const g={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(p.code)?p.code:U.InternalError,message:p.message??"Internal error",...p.data!==void 0&&{data:p.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:g,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(g))}).catch(p=>this._onerror(new Error(`Failed to send response: ${p}`))).finally(()=>{this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...s}=t.params,i=Number(n),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const r=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&r&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),r(c);return}o(s)}_onresponse(t){const n=Number(t.id),s=this._requestResolvers.get(n);if(s){if(this._requestResolvers.delete(n),Nn(t))s(t);else{const r=new H(t.error.code,t.error.message,t.error.data);s(r)}return}const i=this._responseHandlers.get(n);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let o=!1;if(Nn(t)&&t.result&&typeof t.result=="object"){const r=t.result;if(r.task&&typeof r.task=="object"){const a=r.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,n))}}if(o||this._progressHandlers.delete(n),Nn(t))i(t);else{const r=H.fromError(t.error.code,t.error.message,t.error.data);i(r)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,n,s){var r,a;const{task:i}=s??{};if(!i){try{yield{type:"result",result:await this.request(t,n,s)}}catch(c){yield{type:"error",error:c instanceof H?c:new H(U.InternalError,String(c))}}return}let o;try{const c=await this.request(t,Di,s);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new H(U.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:l},de(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,s)}:l.status==="failed"?yield{type:"error",error:new H(U.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new H(U.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,s)};return}const u=l.pollInterval??((r=this._options)==null?void 0:r.defaultTaskPollInterval)??1e3;await new Promise(h=>setTimeout(h,u)),(a=s==null?void 0:s.signal)==null||a.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof H?c:new H(U.InternalError,String(c))}}}request(t,n,s){const{relatedRequestId:i,resumptionToken:o,onresumptiontoken:r,task:a,relatedTask:c}=s??{};return new Promise((l,u)=>{var x,M,S,k,C;const h=P=>{u(P)};if(!this._transport){h(new Error("Not connected"));return}if(((x=this._options)==null?void 0:x.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(P){h(P);return}(M=s==null?void 0:s.signal)==null||M.throwIfAborted();const d=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:d};s!=null&&s.onprogress&&(this._progressHandlers.set(d,s.onprogress),f.params={...t.params,_meta:{...((S=t.params)==null?void 0:S._meta)||{},progressToken:d}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...((k=f.params)==null?void 0:k._meta)||{},[be]:c}});const p=P=>{var O;this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),(O=this._transport)==null||O.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(P)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:r}).catch(E=>this._onerror(new Error(`Failed to send cancellation: ${E}`)));const z=P instanceof H?P:new H(U.RequestTimeout,String(P));u(z)};this._responseHandlers.set(d,P=>{var z;if(!((z=s==null?void 0:s.signal)!=null&&z.aborted)){if(P instanceof Error)return u(P);try{const O=Fa(n,P.result);O.success?l(O.data):u(O.error)}catch(O){u(O)}}}),(C=s==null?void 0:s.signal)==null||C.addEventListener("abort",()=>{var P;p((P=s==null?void 0:s.signal)==null?void 0:P.reason)});const g=(s==null?void 0:s.timeout)??Xg,m=()=>p(H.fromError(U.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(d,g,s==null?void 0:s.maxTotalTimeout,m,(s==null?void 0:s.resetTimeoutOnProgress)??!1);const b=c==null?void 0:c.taskId;if(b){const P=z=>{const O=this._responseHandlers.get(d);O?O(z):this._onerror(new Error(`Response handler missing for side-channeled request ${d}`))};this._requestResolvers.set(d,P),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(d),u(z)})}else this._transport.send(f,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:r}).catch(P=>{this._cleanupTimeout(d),u(P)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Li,n)}async getTaskResult(t,n,s){return this.request({method:"tasks/result",params:t},n,s)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Fi,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Ap,n)}async notification(t,n){var a,c,l,u;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const s=(a=n==null?void 0:n.relatedTask)==null?void 0:a.taskId;if(s){const h={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[be]:n.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:h,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(n!=null&&n.relatedRequestId)&&!(n!=null&&n.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var d,f;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let h={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(h={...h,params:{...h.params,_meta:{...((d=h.params)==null?void 0:d._meta)||{},[be]:n.relatedTask}}}),(f=this._transport)==null||f.send(h,n).catch(p=>this._onerror(p))});return}let r={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(r={...r,params:{...r.params,_meta:{...((u=r.params)==null?void 0:u._meta)||{},[be]:n.relatedTask}}}),await this._transport.send(r,n)}setRequestHandler(t,n){const s=Do(t);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(i,o)=>{const r=Eo(t,i);return Promise.resolve(n(r,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const s=Do(t);this._notificationHandlers.set(s,i=>{const o=Eo(t,i);return Promise.resolve(n(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,s){var o;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const i=(o=this._options)==null?void 0:o.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,s,i)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(t,n);for(const i of s)if(i.type==="request"&&Io(i.message)){const o=i.message.id,r=this._requestResolvers.get(o);r?(r(new H(U.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){var i,o;let s=((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;try{const r=await((o=this._taskStore)==null?void 0:o.getTask(t));r!=null&&r.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,a)=>{if(n.aborted){a(new H(U.InvalidRequest,"Request cancelled"));return}const c=setTimeout(r,s);n.addEventListener("abort",()=>{clearTimeout(c),a(new H(U.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await s.createTask(i,t.id,{method:t.method,params:t.params},n)},getTask:async i=>{const o=await s.getTask(i,n);if(!o)throw new H(U.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,r)=>{await s.storeTaskResult(i,o,r,n);const a=await s.getTask(i,n);if(a){const c=hs.parse({method:"notifications/tasks/status",params:a});await this.notification(c),de(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>s.getTaskResult(i,n),updateTaskStatus:async(i,o,r)=>{const a=await s.getTask(i,n);if(!a)throw new H(U.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(de(a.status))throw new H(U.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(i,o,r,n);const c=await s.getTask(i,n);if(c){const l=hs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),de(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>s.listTasks(i,n)}}}var Gg="2026-01-26",Qg="ui/notifications/tool-input-partial";class tm{constructor(t=window.parent,n){T(this,"eventTarget");T(this,"eventSource");T(this,"messageListener");T(this,"onclose");T(this,"onerror");T(this,"onmessage");T(this,"sessionId");T(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=n,this.messageListener=s=>{var o,r,a;if(n&&s.source!==this.eventSource){console.debug("Ignoring message from unknown source",s);return}let i=pp.safeParse(s.data);i.success?(console.debug("Parsed message",i.data),(o=this.onmessage)==null||o.call(this,i.data)):((r=s.data)==null?void 0:r.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,s):(console.error("Failed to parse message",i.error.message,s),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==Qg&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){var t;window.removeEventListener("message",this.messageListener),(t=this.onclose)==null||t.call(this)}}var em=F([_("light"),_("dark")]).describe("Color theme preference for the host environment."),pn=F([_("inline"),_("fullscreen"),_("pip")]).describe("Display mode for UI presentation."),nm=F([_("--color-background-primary"),_("--color-background-secondary"),_("--color-background-tertiary"),_("--color-background-inverse"),_("--color-background-ghost"),_("--color-background-info"),_("--color-background-danger"),_("--color-background-success"),_("--color-background-warning"),_("--color-background-disabled"),_("--color-text-primary"),_("--color-text-secondary"),_("--color-text-tertiary"),_("--color-text-inverse"),_("--color-text-ghost"),_("--color-text-info"),_("--color-text-danger"),_("--color-text-success"),_("--color-text-warning"),_("--color-text-disabled"),_("--color-border-primary"),_("--color-border-secondary"),_("--color-border-tertiary"),_("--color-border-inverse"),_("--color-border-ghost"),_("--color-border-info"),_("--color-border-danger"),_("--color-border-success"),_("--color-border-warning"),_("--color-border-disabled"),_("--color-ring-primary"),_("--color-ring-secondary"),_("--color-ring-inverse"),_("--color-ring-info"),_("--color-ring-danger"),_("--color-ring-success"),_("--color-ring-warning"),_("--font-sans"),_("--font-mono"),_("--font-weight-normal"),_("--font-weight-medium"),_("--font-weight-semibold"),_("--font-weight-bold"),_("--font-text-xs-size"),_("--font-text-sm-size"),_("--font-text-md-size"),_("--font-text-lg-size"),_("--font-heading-xs-size"),_("--font-heading-sm-size"),_("--font-heading-md-size"),_("--font-heading-lg-size"),_("--font-heading-xl-size"),_("--font-heading-2xl-size"),_("--font-heading-3xl-size"),_("--font-text-xs-line-height"),_("--font-text-sm-line-height"),_("--font-text-md-line-height"),_("--font-text-lg-line-height"),_("--font-heading-xs-line-height"),_("--font-heading-sm-line-height"),_("--font-heading-md-line-height"),_("--font-heading-lg-line-height"),_("--font-heading-xl-line-height"),_("--font-heading-2xl-line-height"),_("--font-heading-3xl-line-height"),_("--border-radius-xs"),_("--border-radius-sm"),_("--border-radius-md"),_("--border-radius-lg"),_("--border-radius-xl"),_("--border-radius-full"),_("--border-width-regular"),_("--shadow-hairline"),_("--shadow-sm"),_("--shadow-md"),_("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),sm=Y(nm.describe(`Style variables for theming MCP apps.
|
|
46
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const u of e.seen.entries()){const h=u[1];if(t===u[0]){o(u);continue}if(e.external){const f=(c=e.external.registry.get(u[0]))==null?void 0:c.id;if(t!==u[0]&&f){o(u);continue}}if((l=e.metadataRegistry.get(u[0]))==null?void 0:l.id){o(u);continue}if(h.cycle){o(u);continue}if(h.count>1&&e.reused==="ref"){o(u);continue}}}function $a(e,t){var r,a,c;const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const s=l=>{const u=e.seen.get(l);if(u.ref===null)return;const h=u.def??u.schema,d={...h},f=u.ref;if(u.ref=null,f){s(f);const g=e.seen.get(f),m=g.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(h.allOf=h.allOf??[],h.allOf.push(m)):Object.assign(h,m),Object.assign(h,d),l._zod.parent===f)for(const x in h)x==="$ref"||x==="allOf"||x in d||delete h[x];if(m.$ref)for(const x in h)x==="$ref"||x==="allOf"||x in g.def&&JSON.stringify(h[x])===JSON.stringify(g.def[x])&&delete h[x]}const p=l._zod.parent;if(p&&p!==f){s(p);const g=e.seen.get(p);if(g!=null&&g.schema.$ref&&(h.$ref=g.schema.$ref,g.def))for(const m in h)m==="$ref"||m==="allOf"||m in g.def&&JSON.stringify(h[m])===JSON.stringify(g.def[m])&&delete h[m]}e.override({zodSchema:l,jsonSchema:h,path:u.path??[]})};for(const l of[...e.seen.entries()].reverse())s(l[0]);const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$schema="http://json-schema.org/draft-04/schema#":e.target,(r=e.external)!=null&&r.uri){const l=(a=e.external.registry.get(t))==null?void 0:a.id;if(!l)throw new Error("Schema is missing an `id` property");i.$id=e.external.uri(l)}Object.assign(i,n.def??n.schema);const o=((c=e.external)==null?void 0:c.defs)??{};for(const l of e.seen.entries()){const u=l[1];u.def&&u.defId&&(o[u.defId]=u.def)}e.external||Object.keys(o).length>0&&(e.target==="draft-2020-12"?i.$defs=o:i.definitions=o);try{const l=JSON.parse(JSON.stringify(i));return Object.defineProperty(l,"~standard",{value:{...t["~standard"],jsonSchema:{input:us(t,"input",e.processors),output:us(t,"output",e.processors)}},enumerable:!1,writable:!1}),l}catch{throw new Error("Error converting schema to JSON.")}}function kt(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const s=e._zod.def;if(s.type==="transform")return!0;if(s.type==="array")return kt(s.element,n);if(s.type==="set")return kt(s.valueType,n);if(s.type==="lazy")return kt(s.getter(),n);if(s.type==="promise"||s.type==="optional"||s.type==="nonoptional"||s.type==="nullable"||s.type==="readonly"||s.type==="default"||s.type==="prefault")return kt(s.innerType,n);if(s.type==="intersection")return kt(s.left,n)||kt(s.right,n);if(s.type==="record"||s.type==="map")return kt(s.keyType,n)||kt(s.valueType,n);if(s.type==="pipe")return kt(s.in,n)||kt(s.out,n);if(s.type==="object"){for(const i in s.shape)if(kt(s.shape[i],n))return!0;return!1}if(s.type==="union"){for(const i of s.options)if(kt(i,n))return!0;return!1}if(s.type==="tuple"){for(const i of s.items)if(kt(i,n))return!0;return!!(s.rest&&kt(s.rest,n))}return!1}const vd=(e,t={})=>n=>{const s=Da({...n,processors:t});return ut(e,s),La(s,e),$a(s,e)},us=(e,t,n={})=>s=>{const{libraryOptions:i,target:o}=s??{},r=Da({...i??{},target:o,io:t,processors:n});return ut(e,r),La(r,e),$a(r,e)},kd={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},wd=(e,t,n,s)=>{const i=n;i.type="string";const{minimum:o,maximum:r,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof o=="number"&&(i.minLength=o),typeof r=="number"&&(i.maxLength=r),a&&(i.format=kd[a]??a,i.format===""&&delete i.format,a==="time"&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){const u=[...c];u.length===1?i.pattern=u[0].source:u.length>1&&(i.allOf=[...u.map(h=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:h.source}))])}},Sd=(e,t,n,s)=>{const i=n,{minimum:o,maximum:r,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof a=="string"&&a.includes("int")?i.type="integer":i.type="number",typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof o=="number"&&(i.minimum=o,typeof u=="number"&&t.target!=="draft-04"&&(u>=o?delete i.minimum:delete i.exclusiveMinimum)),typeof l=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof r=="number"&&(i.maximum=r,typeof l=="number"&&t.target!=="draft-04"&&(l<=r?delete i.maximum:delete i.exclusiveMaximum)),typeof c=="number"&&(i.multipleOf=c)},Md=(e,t,n,s)=>{n.type="boolean"},Pd=(e,t,n,s)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Td=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},Cd=(e,t,n,s)=>{n.not={}},zd=(e,t,n,s)=>{},Od=(e,t,n,s)=>{const i=e._zod.def,o=fa(i.entries);o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),n.enum=o},Rd=(e,t,n,s)=>{const i=e._zod.def,o=[];for(const r of i.values)if(r===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof r=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");o.push(Number(r))}else o.push(r);if(o.length!==0)if(o.length===1){const r=o[0];n.type=r===null?"null":typeof r,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[r]:n.const=r}else o.every(r=>typeof r=="number")&&(n.type="number"),o.every(r=>typeof r=="string")&&(n.type="string"),o.every(r=>typeof r=="boolean")&&(n.type="boolean"),o.every(r=>r===null)&&(n.type="null"),n.enum=o},Ad=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Id=(e,t,n,s)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ed=(e,t,n,s)=>{const i=n,o=e._zod.def,{minimum:r,maximum:a}=e._zod.bag;typeof r=="number"&&(i.minItems=r),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=ut(o.element,t,{...s,path:[...s.path,"items"]})},Dd=(e,t,n,s)=>{var l;const i=n,o=e._zod.def;i.type="object",i.properties={};const r=o.shape;for(const u in r)i.properties[u]=ut(r[u],t,{...s,path:[...s.path,"properties",u]});const a=new Set(Object.keys(r)),c=new Set([...a].filter(u=>{const h=o.shape[u]._zod;return t.io==="input"?h.optin===void 0:h.optout===void 0}));c.size>0&&(i.required=Array.from(c)),((l=o.catchall)==null?void 0:l._zod.def.type)==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=ut(o.catchall,t,{...s,path:[...s.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},Ld=(e,t,n,s)=>{const i=e._zod.def,o=i.inclusive===!1,r=i.options.map((a,c)=>ut(a,t,{...s,path:[...s.path,o?"oneOf":"anyOf",c]}));o?n.oneOf=r:n.anyOf=r},$d=(e,t,n,s)=>{const i=e._zod.def,o=ut(i.left,t,{...s,path:[...s.path,"allOf",0]}),r=ut(i.right,t,{...s,path:[...s.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},Nd=(e,t,n,s)=>{const i=n,o=e._zod.def;i.type="object";const r=o.keyType,a=r._zod.bag,c=a==null?void 0:a.patterns;if(o.mode==="loose"&&c&&c.size>0){const u=ut(o.valueType,t,{...s,path:[...s.path,"patternProperties","*"]});i.patternProperties={};for(const h of c)i.patternProperties[h.source]=u}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(i.propertyNames=ut(o.keyType,t,{...s,path:[...s.path,"propertyNames"]})),i.additionalProperties=ut(o.valueType,t,{...s,path:[...s.path,"additionalProperties"]});const l=r._zod.values;if(l){const u=[...l].filter(h=>typeof h=="string"||typeof h=="number");u.length>0&&(i.required=u)}},Fd=(e,t,n,s)=>{const i=e._zod.def,o=ut(i.innerType,t,s),r=t.seen.get(e);t.target==="openapi-3.0"?(r.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Hd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType},jd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Bd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Zd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType;let r;try{r=i.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=r},Vd=(e,t,n,s)=>{const i=e._zod.def,o=t.io==="input"?i.in._zod.def.type==="transform"?i.out:i.in:i.out;ut(o,t,s);const r=t.seen.get(e);r.ref=o},Wd=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Na=(e,t,n,s)=>{const i=e._zod.def;ut(i.innerType,t,s);const o=t.seen.get(e);o.ref=i.innerType},qd=w("ZodISODateTime",(e,t)=>{Hu.init(e,t),rt.init(e,t)});function Fa(e){return Yh(qd,e)}const Ud=w("ZodISODate",(e,t)=>{ju.init(e,t),rt.init(e,t)});function Yd(e){return Jh(Ud,e)}const Jd=w("ZodISOTime",(e,t)=>{Bu.init(e,t),rt.init(e,t)});function Kd(e){return Kh(Jd,e)}const Xd=w("ZodISODuration",(e,t)=>{Zu.init(e,t),rt.init(e,t)});function Gd(e){return Xh(Xd,e)}const Qd=(e,t)=>{ba.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Al(e,n)},flatten:{value:n=>Rl(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Gs,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Gs,2)}},isEmpty:{get(){return e.issues.length===0}}})},At=w("ZodError",Qd,{Parent:Error}),tf=wi(At),ef=Si(At),nf=ks(At),sf=ws(At),of=El(At),rf=Dl(At),af=Ll(At),cf=$l(At),lf=Nl(At),uf=Fl(At),hf=Hl(At),df=jl(At),tt=w("ZodType",(e,t)=>(Q.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:us(e,"input"),output:us(e,"output")}}),e.toJSONSchema=vd(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(ae(t,{checks:[...t.checks??[],...n.map(s=>typeof s=="function"?{_zod:{check:s,def:{check:"custom"},onattach:[]}}:s)]}),{parent:!0}),e.with=e.check,e.clone=(n,s)=>ce(e,n,s),e.brand=()=>e,e.register=((n,s)=>(n.add(e,s),e)),e.parse=(n,s)=>tf(e,n,s,{callee:e.parse}),e.safeParse=(n,s)=>nf(e,n,s),e.parseAsync=async(n,s)=>ef(e,n,s,{callee:e.parseAsync}),e.safeParseAsync=async(n,s)=>sf(e,n,s),e.spa=e.safeParseAsync,e.encode=(n,s)=>of(e,n,s),e.decode=(n,s)=>rf(e,n,s),e.encodeAsync=async(n,s)=>af(e,n,s),e.decodeAsync=async(n,s)=>cf(e,n,s),e.safeEncode=(n,s)=>lf(e,n,s),e.safeDecode=(n,s)=>uf(e,n,s),e.safeEncodeAsync=async(n,s)=>hf(e,n,s),e.safeDecodeAsync=async(n,s)=>df(e,n,s),e.refine=(n,s)=>e.check(op(n,s)),e.superRefine=n=>e.check(rp(n)),e.overwrite=n=>e.check(Ve(n)),e.optional=()=>ot(e),e.exactOptional=()=>qf(e),e.nullable=()=>Ao(e),e.nullish=()=>ot(Ao(e)),e.nonoptional=n=>Gf(e,n),e.array=()=>I(e),e.or=n=>H([e,n]),e.and=n=>Pi(e,n),e.transform=n=>ni(e,Wa(n)),e.default=n=>Jf(e,n),e.prefault=n=>Xf(e,n),e.catch=n=>tp(e,n),e.pipe=n=>ni(e,n),e.readonly=()=>sp(e),e.describe=n=>{const s=e.clone();return Qe.add(s,{description:n}),s},Object.defineProperty(e,"description",{get(){var n;return(n=Qe.get(e))==null?void 0:n.description},configurable:!0}),e.meta=(...n)=>{if(n.length===0)return Qe.get(e);const s=e.clone();return Qe.add(s,n[0]),s},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=n=>n(e),e)),Ha=w("_ZodString",(e,t)=>{Mi.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(s,i,o)=>wd(e,s,i);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...s)=>e.check(od(...s)),e.includes=(...s)=>e.check(cd(...s)),e.startsWith=(...s)=>e.check(ld(...s)),e.endsWith=(...s)=>e.check(ud(...s)),e.min=(...s)=>e.check(ls(...s)),e.max=(...s)=>e.check(Ia(...s)),e.length=(...s)=>e.check(Ea(...s)),e.nonempty=(...s)=>e.check(ls(1,...s)),e.lowercase=s=>e.check(rd(s)),e.uppercase=s=>e.check(ad(s)),e.trim=()=>e.check(dd()),e.normalize=(...s)=>e.check(hd(...s)),e.toLowerCase=()=>e.check(fd()),e.toUpperCase=()=>e.check(pd()),e.slugify=()=>e.check(gd())}),ff=w("ZodString",(e,t)=>{Mi.init(e,t),Ha.init(e,t),e.email=n=>e.check(Th(pf,n)),e.url=n=>e.check(Ah(gf,n)),e.jwt=n=>e.check(Uh(Of,n)),e.emoji=n=>e.check(Ih(mf,n)),e.guid=n=>e.check(Po(Oo,n)),e.uuid=n=>e.check(Ch($n,n)),e.uuidv4=n=>e.check(zh($n,n)),e.uuidv6=n=>e.check(Oh($n,n)),e.uuidv7=n=>e.check(Rh($n,n)),e.nanoid=n=>e.check(Eh(bf,n)),e.guid=n=>e.check(Po(Oo,n)),e.cuid=n=>e.check(Dh(_f,n)),e.cuid2=n=>e.check(Lh(yf,n)),e.ulid=n=>e.check($h(xf,n)),e.base64=n=>e.check(Vh(Tf,n)),e.base64url=n=>e.check(Wh(Cf,n)),e.xid=n=>e.check(Nh(vf,n)),e.ksuid=n=>e.check(Fh(kf,n)),e.ipv4=n=>e.check(Hh(wf,n)),e.ipv6=n=>e.check(jh(Sf,n)),e.cidrv4=n=>e.check(Bh(Mf,n)),e.cidrv6=n=>e.check(Zh(Pf,n)),e.e164=n=>e.check(qh(zf,n)),e.datetime=n=>e.check(Fa(n)),e.date=n=>e.check(Yd(n)),e.time=n=>e.check(Kd(n)),e.duration=n=>e.check(Gd(n))});function y(e){return Ph(ff,e)}const rt=w("ZodStringFormat",(e,t)=>{it.init(e,t),Ha.init(e,t)}),pf=w("ZodEmail",(e,t)=>{Ru.init(e,t),rt.init(e,t)}),Oo=w("ZodGUID",(e,t)=>{zu.init(e,t),rt.init(e,t)}),$n=w("ZodUUID",(e,t)=>{Ou.init(e,t),rt.init(e,t)}),gf=w("ZodURL",(e,t)=>{Au.init(e,t),rt.init(e,t)}),mf=w("ZodEmoji",(e,t)=>{Iu.init(e,t),rt.init(e,t)}),bf=w("ZodNanoID",(e,t)=>{Eu.init(e,t),rt.init(e,t)}),_f=w("ZodCUID",(e,t)=>{Du.init(e,t),rt.init(e,t)}),yf=w("ZodCUID2",(e,t)=>{Lu.init(e,t),rt.init(e,t)}),xf=w("ZodULID",(e,t)=>{$u.init(e,t),rt.init(e,t)}),vf=w("ZodXID",(e,t)=>{Nu.init(e,t),rt.init(e,t)}),kf=w("ZodKSUID",(e,t)=>{Fu.init(e,t),rt.init(e,t)}),wf=w("ZodIPv4",(e,t)=>{Vu.init(e,t),rt.init(e,t)}),Sf=w("ZodIPv6",(e,t)=>{Wu.init(e,t),rt.init(e,t)}),Mf=w("ZodCIDRv4",(e,t)=>{qu.init(e,t),rt.init(e,t)}),Pf=w("ZodCIDRv6",(e,t)=>{Uu.init(e,t),rt.init(e,t)}),Tf=w("ZodBase64",(e,t)=>{Yu.init(e,t),rt.init(e,t)}),Cf=w("ZodBase64URL",(e,t)=>{Ku.init(e,t),rt.init(e,t)}),zf=w("ZodE164",(e,t)=>{Xu.init(e,t),rt.init(e,t)}),Of=w("ZodJWT",(e,t)=>{Qu.init(e,t),rt.init(e,t)}),ja=w("ZodNumber",(e,t)=>{Ca.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(s,i,o)=>Sd(e,s,i),e.gt=(s,i)=>e.check(Co(s,i)),e.gte=(s,i)=>e.check($s(s,i)),e.min=(s,i)=>e.check($s(s,i)),e.lt=(s,i)=>e.check(To(s,i)),e.lte=(s,i)=>e.check(Ls(s,i)),e.max=(s,i)=>e.check(Ls(s,i)),e.int=s=>e.check(Ro(s)),e.safe=s=>e.check(Ro(s)),e.positive=s=>e.check(Co(0,s)),e.nonnegative=s=>e.check($s(0,s)),e.negative=s=>e.check(To(0,s)),e.nonpositive=s=>e.check(Ls(0,s)),e.multipleOf=(s,i)=>e.check(zo(s,i)),e.step=(s,i)=>e.check(zo(s,i)),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 $(e){return Gh(ja,e)}const Rf=w("ZodNumberFormat",(e,t)=>{th.init(e,t),ja.init(e,t)});function Ro(e){return Qh(Rf,e)}const Af=w("ZodBoolean",(e,t)=>{eh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Md(e,n,s)});function X(e){return td(Af,e)}const If=w("ZodUndefined",(e,t)=>{nh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Td(e,n)});function ti(e){return ed(If,e)}const Ef=w("ZodNull",(e,t)=>{sh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Pd(e,n,s)});function Df(e){return nd(Ef,e)}const Lf=w("ZodUnknown",(e,t)=>{ih.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>zd()});function J(){return sd(Lf)}const $f=w("ZodNever",(e,t)=>{oh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Cd(e,n,s)});function Nf(e){return id($f,e)}const Ff=w("ZodArray",(e,t)=>{rh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Ed(e,n,s,i),e.element=t.element,e.min=(n,s)=>e.check(ls(n,s)),e.nonempty=n=>e.check(ls(1,n)),e.max=(n,s)=>e.check(Ia(n,s)),e.length=(n,s)=>e.check(Ea(n,s)),e.unwrap=()=>e.element});function I(e,t){return md(Ff,e,t)}const Ba=w("ZodObject",(e,t)=>{ch.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Dd(e,n,s,i),V(e,"shape",()=>t.shape),e.keyof=()=>zt(Object.keys(e._zod.def.shape)),e.catchall=n=>e.clone({...e._zod.def,catchall:n}),e.passthrough=()=>e.clone({...e._zod.def,catchall:J()}),e.loose=()=>e.clone({...e._zod.def,catchall:J()}),e.strict=()=>e.clone({...e._zod.def,catchall:Nf()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=n=>Pl(e,n),e.safeExtend=n=>Tl(e,n),e.merge=n=>Cl(e,n),e.pick=n=>Sl(e,n),e.omit=n=>Ml(e,n),e.partial=(...n)=>zl(qa,e,n[0]),e.required=(...n)=>Ol(Ua,e,n[0])});function v(e,t){const n={type:"object",shape:e??{},...R(t)};return new Ba(n)}function Mt(e,t){return new Ba({type:"object",shape:e,catchall:J(),...R(t)})}const Za=w("ZodUnion",(e,t)=>{Ra.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Ld(e,n,s,i),e.options=t.options});function H(e,t){return new Za({type:"union",options:e,...R(t)})}const Hf=w("ZodDiscriminatedUnion",(e,t)=>{Za.init(e,t),lh.init(e,t)});function Va(e,t,n){return new Hf({type:"union",options:t,discriminator:e,...R(n)})}const jf=w("ZodIntersection",(e,t)=>{uh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>$d(e,n,s,i)});function Pi(e,t){return new jf({type:"intersection",left:e,right:t})}const Bf=w("ZodRecord",(e,t)=>{hh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Nd(e,n,s,i),e.keyType=t.keyType,e.valueType=t.valueType});function W(e,t,n){return new Bf({type:"record",keyType:e,valueType:t,...R(n)})}const ei=w("ZodEnum",(e,t)=>{dh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(s,i,o)=>Od(e,s,i),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(s,i)=>{const o={};for(const r of s)if(n.has(r))o[r]=t.entries[r];else throw new Error(`Key ${r} not found in enum`);return new ei({...t,checks:[],...R(i),entries:o})},e.exclude=(s,i)=>{const o={...t.entries};for(const r of s)if(n.has(r))delete o[r];else throw new Error(`Key ${r} not found in enum`);return new ei({...t,checks:[],...R(i),entries:o})}});function zt(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(s=>[s,s])):e;return new ei({type:"enum",entries:n,...R(t)})}const Zf=w("ZodLiteral",(e,t)=>{fh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Rd(e,n,s),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function _(e,t){return new Zf({type:"literal",values:Array.isArray(e)?e:[e],...R(t)})}const Vf=w("ZodTransform",(e,t)=>{ph.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Id(e,n),e._zod.parse=(n,s)=>{if(s.direction==="backward")throw new ha(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(fn(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(fn(r))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function Wa(e){return new Vf({type:"transform",transform:e})}const qa=w("ZodOptional",(e,t)=>{Aa.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Na(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function ot(e){return new qa({type:"optional",innerType:e})}const Wf=w("ZodExactOptional",(e,t)=>{gh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Na(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function qf(e){return new Wf({type:"optional",innerType:e})}const Uf=w("ZodNullable",(e,t)=>{mh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Fd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Ao(e){return new Uf({type:"nullable",innerType:e})}const Yf=w("ZodDefault",(e,t)=>{bh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>jd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Jf(e,t){return new Yf({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():ga(t)}})}const Kf=w("ZodPrefault",(e,t)=>{_h.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Bd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Xf(e,t){return new Kf({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():ga(t)}})}const Ua=w("ZodNonOptional",(e,t)=>{yh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Hd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function Gf(e,t){return new Ua({type:"nonoptional",innerType:e,...R(t)})}const Qf=w("ZodCatch",(e,t)=>{xh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Zd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function tp(e,t){return new Qf({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const ep=w("ZodPipe",(e,t)=>{vh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Vd(e,n,s,i),e.in=t.in,e.out=t.out});function ni(e,t){return new ep({type:"pipe",in:e,out:t})}const np=w("ZodReadonly",(e,t)=>{kh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Wd(e,n,s,i),e.unwrap=()=>e._zod.def.innerType});function sp(e){return new np({type:"readonly",innerType:e})}const Ya=w("ZodCustom",(e,t)=>{wh.init(e,t),tt.init(e,t),e._zod.processJSONSchema=(n,s,i)=>Ad(e,n)});function ip(e,t){return bd(Ya,e??(()=>!0),t)}function op(e,t={}){return _d(Ya,e,t)}function rp(e){return yd(e)}function Ja(e,t){return ni(Wa(e),t)}const be="io.modelcontextprotocol/related-task",Ms="2.0",ht=ip(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Ka=H([y(),$().int()]),Xa=y();Mt({ttl:$().optional(),pollInterval:$().optional()});const ap=v({ttl:$().optional()}),cp=v({taskId:y()}),Ti=Mt({progressToken:Ka.optional(),[be]:cp.optional()}),Ot=v({_meta:Ti.optional()}),wn=Ot.extend({task:ap.optional()}),lp=e=>wn.safeParse(e).success,gt=v({method:y(),params:Ot.loose().optional()}),It=v({_meta:Ti.optional()}),Et=v({method:y(),params:It.loose().optional()}),mt=Mt({_meta:Ti.optional()}),Sn=H([y(),$().int()]),Ga=v({jsonrpc:_(Ms),id:Sn,...gt.shape}).strict(),Io=e=>Ga.safeParse(e).success,Qa=v({jsonrpc:_(Ms),...Et.shape}).strict(),up=e=>Qa.safeParse(e).success,Ci=v({jsonrpc:_(Ms),id:Sn,result:mt}).strict(),Nn=e=>Ci.safeParse(e).success;var q;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(q||(q={}));const zi=v({jsonrpc:_(Ms),id:Sn.optional(),error:v({code:$().int(),message:y(),data:J().optional()})}).strict(),hp=e=>zi.safeParse(e).success,dp=H([Ga,Qa,Ci,zi]);H([Ci,zi]);const Oi=mt.strict(),fp=It.extend({requestId:Sn.optional(),reason:y().optional()}),Ri=Et.extend({method:_("notifications/cancelled"),params:fp}),pp=v({src:y(),mimeType:y().optional(),sizes:I(y()).optional(),theme:zt(["light","dark"]).optional()}),Mn=v({icons:I(pp).optional()}),Fe=v({name:y(),title:y().optional()}),Ps=Fe.extend({...Fe.shape,...Mn.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),gp=Pi(v({applyDefaults:X().optional()}),W(y(),J())),mp=Ja(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Pi(v({form:gp.optional(),url:ht.optional()}),W(y(),J()).optional())),bp=Mt({list:ht.optional(),cancel:ht.optional(),requests:Mt({sampling:Mt({createMessage:ht.optional()}).optional(),elicitation:Mt({create:ht.optional()}).optional()}).optional()}),_p=Mt({list:ht.optional(),cancel:ht.optional(),requests:Mt({tools:Mt({call:ht.optional()}).optional()}).optional()}),yp=v({experimental:W(y(),ht).optional(),sampling:v({context:ht.optional(),tools:ht.optional()}).optional(),elicitation:mp.optional(),roots:v({listChanged:X().optional()}).optional(),tasks:bp.optional(),extensions:W(y(),ht).optional()}),xp=Ot.extend({protocolVersion:y(),capabilities:yp,clientInfo:Ps}),vp=gt.extend({method:_("initialize"),params:xp}),kp=v({experimental:W(y(),ht).optional(),logging:ht.optional(),completions:ht.optional(),prompts:v({listChanged:X().optional()}).optional(),resources:v({subscribe:X().optional(),listChanged:X().optional()}).optional(),tools:v({listChanged:X().optional()}).optional(),tasks:_p.optional(),extensions:W(y(),ht).optional()}),wp=mt.extend({protocolVersion:y(),capabilities:kp,serverInfo:Ps,instructions:y().optional()}),Sp=Et.extend({method:_("notifications/initialized"),params:It.optional()}),Ts=gt.extend({method:_("ping"),params:Ot.optional()}),Mp=v({progress:$(),total:ot($()),message:ot(y())}),Pp=v({...It.shape,...Mp.shape,progressToken:Ka}),Ai=Et.extend({method:_("notifications/progress"),params:Pp}),Tp=Ot.extend({cursor:Xa.optional()}),Pn=gt.extend({params:Tp.optional()}),Tn=mt.extend({nextCursor:Xa.optional()}),Cp=zt(["working","input_required","completed","failed","cancelled"]),Cn=v({taskId:y(),status:Cp,ttl:H([$(),Df()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:ot($()),statusMessage:ot(y())}),Ii=mt.extend({task:Cn}),zp=It.merge(Cn),hs=Et.extend({method:_("notifications/tasks/status"),params:zp}),Ei=gt.extend({method:_("tasks/get"),params:Ot.extend({taskId:y()})}),Di=mt.merge(Cn),Li=gt.extend({method:_("tasks/result"),params:Ot.extend({taskId:y()})});mt.loose();const $i=Pn.extend({method:_("tasks/list")}),Ni=Tn.extend({tasks:I(Cn)}),Fi=gt.extend({method:_("tasks/cancel"),params:Ot.extend({taskId:y()})}),Op=mt.merge(Cn),tc=v({uri:y(),mimeType:ot(y()),_meta:W(y(),J()).optional()}),ec=tc.extend({text:y()}),Hi=y().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),nc=tc.extend({blob:Hi}),zn=zt(["user","assistant"]),We=v({audience:I(zn).optional(),priority:$().min(0).max(1).optional(),lastModified:Fa({offset:!0}).optional()}),sc=v({...Fe.shape,...Mn.shape,uri:y(),description:ot(y()),mimeType:ot(y()),size:ot($()),annotations:We.optional(),_meta:ot(Mt({}))}),Rp=v({...Fe.shape,...Mn.shape,uriTemplate:y(),description:ot(y()),mimeType:ot(y()),annotations:We.optional(),_meta:ot(Mt({}))}),Ap=Pn.extend({method:_("resources/list")}),ic=Tn.extend({resources:I(sc)}),Ip=Pn.extend({method:_("resources/templates/list")}),Ep=Tn.extend({resourceTemplates:I(Rp)}),ji=Ot.extend({uri:y()}),Dp=ji,Lp=gt.extend({method:_("resources/read"),params:Dp}),oc=mt.extend({contents:I(H([ec,nc]))}),$p=Et.extend({method:_("notifications/resources/list_changed"),params:It.optional()}),Np=ji,Fp=gt.extend({method:_("resources/subscribe"),params:Np}),Hp=ji,jp=gt.extend({method:_("resources/unsubscribe"),params:Hp}),Bp=It.extend({uri:y()}),Zp=Et.extend({method:_("notifications/resources/updated"),params:Bp}),Vp=v({name:y(),description:ot(y()),required:ot(X())}),Wp=v({...Fe.shape,...Mn.shape,description:ot(y()),arguments:ot(I(Vp)),_meta:ot(Mt({}))}),qp=Pn.extend({method:_("prompts/list")}),Up=Tn.extend({prompts:I(Wp)}),Yp=Ot.extend({name:y(),arguments:W(y(),y()).optional()}),Jp=gt.extend({method:_("prompts/get"),params:Yp}),Bi=v({type:_("text"),text:y(),annotations:We.optional(),_meta:W(y(),J()).optional()}),Zi=v({type:_("image"),data:Hi,mimeType:y(),annotations:We.optional(),_meta:W(y(),J()).optional()}),Vi=v({type:_("audio"),data:Hi,mimeType:y(),annotations:We.optional(),_meta:W(y(),J()).optional()}),Kp=v({type:_("tool_use"),name:y(),id:y(),input:W(y(),J()),_meta:W(y(),J()).optional()}),rc=v({type:_("resource"),resource:H([ec,nc]),annotations:We.optional(),_meta:W(y(),J()).optional()}),ac=sc.extend({type:_("resource_link")}),On=H([Bi,Zi,Vi,ac,rc]),Xp=v({role:zn,content:On}),Gp=mt.extend({description:y().optional(),messages:I(Xp)}),Qp=Et.extend({method:_("notifications/prompts/list_changed"),params:It.optional()}),tg=v({title:y().optional(),readOnlyHint:X().optional(),destructiveHint:X().optional(),idempotentHint:X().optional(),openWorldHint:X().optional()}),eg=v({taskSupport:zt(["required","optional","forbidden"]).optional()}),Wi=v({...Fe.shape,...Mn.shape,description:y().optional(),inputSchema:v({type:_("object"),properties:W(y(),ht).optional(),required:I(y()).optional()}).catchall(J()),outputSchema:v({type:_("object"),properties:W(y(),ht).optional(),required:I(y()).optional()}).catchall(J()).optional(),annotations:tg.optional(),execution:eg.optional(),_meta:W(y(),J()).optional()}),cc=Pn.extend({method:_("tools/list")}),ng=Tn.extend({tools:I(Wi)}),Cs=mt.extend({content:I(On).default([]),structuredContent:W(y(),J()).optional(),isError:X().optional()});Cs.or(mt.extend({toolResult:J()}));const sg=wn.extend({name:y(),arguments:W(y(),J()).optional()}),lc=gt.extend({method:_("tools/call"),params:sg}),ig=Et.extend({method:_("notifications/tools/list_changed"),params:It.optional()});v({autoRefresh:X().default(!0),debounceMs:$().int().nonnegative().default(300)});const uc=zt(["debug","info","notice","warning","error","critical","alert","emergency"]),og=Ot.extend({level:uc}),rg=gt.extend({method:_("logging/setLevel"),params:og}),ag=It.extend({level:uc,logger:y().optional(),data:J()}),cg=Et.extend({method:_("notifications/message"),params:ag}),lg=v({name:y().optional()}),ug=v({hints:I(lg).optional(),costPriority:$().min(0).max(1).optional(),speedPriority:$().min(0).max(1).optional(),intelligencePriority:$().min(0).max(1).optional()}),hg=v({mode:zt(["auto","required","none"]).optional()}),dg=v({type:_("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:I(On).default([]),structuredContent:v({}).loose().optional(),isError:X().optional(),_meta:W(y(),J()).optional()}),fg=Va("type",[Bi,Zi,Vi]),ds=Va("type",[Bi,Zi,Vi,Kp,dg]),pg=v({role:zn,content:H([ds,I(ds)]),_meta:W(y(),J()).optional()}),gg=wn.extend({messages:I(pg),modelPreferences:ug.optional(),systemPrompt:y().optional(),includeContext:zt(["none","thisServer","allServers"]).optional(),temperature:$().optional(),maxTokens:$().int(),stopSequences:I(y()).optional(),metadata:ht.optional(),tools:I(Wi).optional(),toolChoice:hg.optional()}),mg=gt.extend({method:_("sampling/createMessage"),params:gg}),bg=mt.extend({model:y(),stopReason:ot(zt(["endTurn","stopSequence","maxTokens"]).or(y())),role:zn,content:fg}),_g=mt.extend({model:y(),stopReason:ot(zt(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:zn,content:H([ds,I(ds)])}),yg=v({type:_("boolean"),title:y().optional(),description:y().optional(),default:X().optional()}),xg=v({type:_("string"),title:y().optional(),description:y().optional(),minLength:$().optional(),maxLength:$().optional(),format:zt(["email","uri","date","date-time"]).optional(),default:y().optional()}),vg=v({type:zt(["number","integer"]),title:y().optional(),description:y().optional(),minimum:$().optional(),maximum:$().optional(),default:$().optional()}),kg=v({type:_("string"),title:y().optional(),description:y().optional(),enum:I(y()),default:y().optional()}),wg=v({type:_("string"),title:y().optional(),description:y().optional(),oneOf:I(v({const:y(),title:y()})),default:y().optional()}),Sg=v({type:_("string"),title:y().optional(),description:y().optional(),enum:I(y()),enumNames:I(y()).optional(),default:y().optional()}),Mg=H([kg,wg]),Pg=v({type:_("array"),title:y().optional(),description:y().optional(),minItems:$().optional(),maxItems:$().optional(),items:v({type:_("string"),enum:I(y())}),default:I(y()).optional()}),Tg=v({type:_("array"),title:y().optional(),description:y().optional(),minItems:$().optional(),maxItems:$().optional(),items:v({anyOf:I(v({const:y(),title:y()}))}),default:I(y()).optional()}),Cg=H([Pg,Tg]),zg=H([Sg,Mg,Cg]),Og=H([zg,yg,xg,vg]),Rg=wn.extend({mode:_("form").optional(),message:y(),requestedSchema:v({type:_("object"),properties:W(y(),Og),required:I(y()).optional()})}),Ag=wn.extend({mode:_("url"),message:y(),elicitationId:y(),url:y().url()}),Ig=H([Rg,Ag]),Eg=gt.extend({method:_("elicitation/create"),params:Ig}),Dg=It.extend({elicitationId:y()}),Lg=Et.extend({method:_("notifications/elicitation/complete"),params:Dg}),$g=mt.extend({action:zt(["accept","decline","cancel"]),content:Ja(e=>e===null?void 0:e,W(y(),H([y(),$(),X(),I(y())])).optional())}),Ng=v({type:_("ref/resource"),uri:y()}),Fg=v({type:_("ref/prompt"),name:y()}),Hg=Ot.extend({ref:H([Fg,Ng]),argument:v({name:y(),value:y()}),context:v({arguments:W(y(),y()).optional()}).optional()}),jg=gt.extend({method:_("completion/complete"),params:Hg}),Bg=mt.extend({completion:Mt({values:I(y()).max(100),total:ot($().int()),hasMore:ot(X())})}),Zg=v({uri:y().startsWith("file://"),name:y().optional(),_meta:W(y(),J()).optional()}),Vg=gt.extend({method:_("roots/list"),params:Ot.optional()}),Wg=mt.extend({roots:I(Zg)}),qg=Et.extend({method:_("notifications/roots/list_changed"),params:It.optional()});H([Ts,vp,jg,rg,Jp,qp,Ap,Ip,Lp,Fp,jp,lc,cc,Ei,Li,$i,Fi]);H([Ri,Ai,Sp,qg,hs]);H([Oi,bg,_g,$g,Wg,Di,Ni,Ii]);H([Ts,mg,Eg,Vg,Ei,Li,$i,Fi]);H([Ri,Ai,cg,Zp,$p,ig,Qp,hs,Lg]);H([Oi,wp,Bg,Gp,Up,ic,Ep,oc,Cs,ng,Di,Ni,Ii]);class B extends Error{constructor(t,n,s){super(`MCP error ${t}: ${n}`),this.code=t,this.data=s,this.name="McpError"}static fromError(t,n,s){if(t===q.UrlElicitationRequired&&s){const i=s;if(i.elicitations)return new Ug(i.elicitations,n)}return new B(t,n,s)}}class Ug extends B{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(q.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){var t;return((t=this.data)==null?void 0:t.elicitations)??[]}}function qi(e){return!!e._zod}function hc(e,t){return qi(e)?ya(e,t):e.safeParse(t)}function Yg(e){var n,s;if(!e)return;let t;if(qi(e)?t=(s=(n=e._zod)==null?void 0:n.def)==null?void 0:s.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Jg(e){var i;if(qi(e)){const r=(i=e._zod)==null?void 0:i.def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const s=e.value;if(s!==void 0)return s}function de(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Eo(e){const t=Yg(e),n=t==null?void 0:t.method;if(!n)throw new Error("Schema is missing a method literal");const s=Jg(n);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Do(e,t){const n=hc(e,t);if(!n.success)throw n.error;return n.data}const Kg=6e4;class Xg{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ri,n=>{this._oncancel(n)}),this.setNotificationHandler(Ai,n=>{this._onprogress(n)}),this.setRequestHandler(Ts,n=>({})),this._taskStore=t==null?void 0:t.taskStore,this._taskMessageQueue=t==null?void 0:t.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ei,async(n,s)=>{const i=await this._taskStore.getTask(n.params.taskId,s.sessionId);if(!i)throw new B(q.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Li,async(n,s)=>{const i=async()=>{var a;const o=n.params.taskId;if(this._taskMessageQueue){let c;for(;c=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(c.type==="response"||c.type==="error"){const l=c.message,u=l.id,h=this._requestResolvers.get(u);if(h)if(this._requestResolvers.delete(u),c.type==="response")h(l);else{const d=l,f=new B(d.error.code,d.error.message,d.error.data);h(f)}else{const d=c.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await((a=this._transport)==null?void 0:a.send(c.message,{relatedRequestId:s.requestId}))}}const r=await this._taskStore.getTask(o,s.sessionId);if(!r)throw new B(q.InvalidParams,`Task not found: ${o}`);if(!de(r.status))return await this._waitForTaskUpdate(o,s.signal),await i();if(de(r.status)){const c=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...c,_meta:{...c._meta,[be]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler($i,async(n,s)=>{var i;try{const{tasks:o,nextCursor:r}=await this._taskStore.listTasks((i=n.params)==null?void 0:i.cursor,s.sessionId);return{tasks:o,nextCursor:r,_meta:{}}}catch(o){throw new B(q.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Fi,async(n,s)=>{try{const i=await this._taskStore.getTask(n.params.taskId,s.sessionId);if(!i)throw new B(q.InvalidParams,`Task not found: ${n.params.taskId}`);if(de(i.status))throw new B(q.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(n.params.taskId);const o=await this._taskStore.getTask(n.params.taskId,s.sessionId);if(!o)throw new B(q.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof B?i:new B(q.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;const n=this._requestHandlerAbortControllers.get(t.params.requestId);n==null||n.abort(t.params.reason)}_setupTimeout(t,n,s,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,n),startTime:Date.now(),timeout:n,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:i})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const s=Date.now()-n.startTime;if(n.maxTotalTimeout&&s>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),B.fromError(q.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:s});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){var o,r,a;if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=(o=this.transport)==null?void 0:o.onclose;this._transport.onclose=()=>{n==null||n(),this._onclose()};const s=(r=this.transport)==null?void 0:r.onerror;this._transport.onerror=c=>{s==null||s(c),this._onerror(c)};const i=(a=this._transport)==null?void 0:a.onmessage;this._transport.onmessage=(c,l)=>{i==null||i(c,l),Nn(c)||hp(c)?this._onresponse(c):Io(c)?this._onrequest(c,l):up(c)?this._onnotification(c):this._onerror(new Error(`Unknown message type: ${JSON.stringify(c)}`))},await this._transport.start()}_onclose(){var s;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const i of this._timeoutInfo.values())clearTimeout(i.timeoutId);this._timeoutInfo.clear();for(const i of this._requestHandlerAbortControllers.values())i.abort();this._requestHandlerAbortControllers.clear();const n=B.fromError(q.ConnectionClosed,"Connection closed");this._transport=void 0,(s=this.onclose)==null||s.call(this);for(const i of t.values())i(n)}_onerror(t){var n;(n=this.onerror)==null||n.call(this,t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(t,n){var u,h,d,f;const s=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,i=this._transport,o=(d=(h=(u=t.params)==null?void 0:u._meta)==null?void 0:h[be])==null?void 0:d.taskId;if(s===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:q.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:p,timestamp:Date.now()},i==null?void 0:i.sessionId).catch(g=>this._onerror(new Error(`Failed to enqueue error response: ${g}`))):i==null||i.send(p).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)));return}const r=new AbortController;this._requestHandlerAbortControllers.set(t.id,r);const a=lp(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,i==null?void 0:i.sessionId):void 0,l={signal:r.signal,sessionId:i==null?void 0:i.sessionId,_meta:(f=t.params)==null?void 0:f._meta,sendNotification:async p=>{if(r.signal.aborted)return;const g={relatedRequestId:t.id};o&&(g.relatedTask={taskId:o}),await this.notification(p,g)},sendRequest:async(p,g,m)=>{var M;if(r.signal.aborted)throw new B(q.ConnectionClosed,"Request was cancelled");const b={...m,relatedRequestId:t.id};o&&!b.relatedTask&&(b.relatedTask={taskId:o});const x=((M=b.relatedTask)==null?void 0:M.taskId)??o;return x&&c&&await c.updateTaskStatus(x,"input_required"),await this.request(p,g,b)},authInfo:n==null?void 0:n.authInfo,requestId:t.id,requestInfo:n==null?void 0:n.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a==null?void 0:a.ttl,closeSSEStream:n==null?void 0:n.closeSSEStream,closeStandaloneSSEStream:n==null?void 0:n.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>s(t,l)).then(async p=>{if(r.signal.aborted)return;const g={result:p,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:g,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(g))},async p=>{if(r.signal.aborted)return;const g={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(p.code)?p.code:q.InternalError,message:p.message??"Internal error",...p.data!==void 0&&{data:p.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:g,timestamp:Date.now()},i==null?void 0:i.sessionId):await(i==null?void 0:i.send(g))}).catch(p=>this._onerror(new Error(`Failed to send response: ${p}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===r&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...s}=t.params,i=Number(n),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const r=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&r&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(c){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),r(c);return}o(s)}_onresponse(t){const n=Number(t.id),s=this._requestResolvers.get(n);if(s){if(this._requestResolvers.delete(n),Nn(t))s(t);else{const r=new B(t.error.code,t.error.message,t.error.data);s(r)}return}const i=this._responseHandlers.get(n);if(i===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let o=!1;if(Nn(t)&&t.result&&typeof t.result=="object"){const r=t.result;if(r.task&&typeof r.task=="object"){const a=r.task;typeof a.taskId=="string"&&(o=!0,this._taskProgressTokens.set(a.taskId,n))}}if(o||this._progressHandlers.delete(n),Nn(t))i(t);else{const r=B.fromError(t.error.code,t.error.message,t.error.data);i(r)}}get transport(){return this._transport}async close(){var t;await((t=this._transport)==null?void 0:t.close())}async*requestStream(t,n,s){var r,a;const{task:i}=s??{};if(!i){try{yield{type:"result",result:await this.request(t,n,s)}}catch(c){yield{type:"error",error:c instanceof B?c:new B(q.InternalError,String(c))}}return}let o;try{const c=await this.request(t,Ii,s);if(c.task)o=c.task.taskId,yield{type:"taskCreated",task:c.task};else throw new B(q.InternalError,"Task creation did not return a task");for(;;){const l=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:l},de(l.status)){l.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,s)}:l.status==="failed"?yield{type:"error",error:new B(q.InternalError,`Task ${o} failed`)}:l.status==="cancelled"&&(yield{type:"error",error:new B(q.InternalError,`Task ${o} was cancelled`)});return}if(l.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,s)};return}const u=l.pollInterval??((r=this._options)==null?void 0:r.defaultTaskPollInterval)??1e3;await new Promise(h=>setTimeout(h,u)),(a=s==null?void 0:s.signal)==null||a.throwIfAborted()}}catch(c){yield{type:"error",error:c instanceof B?c:new B(q.InternalError,String(c))}}}request(t,n,s){const{relatedRequestId:i,resumptionToken:o,onresumptiontoken:r,task:a,relatedTask:c}=s??{};return new Promise((l,u)=>{var x,M,S,k,C;const h=T=>{u(T)};if(!this._transport){h(new Error("Not connected"));return}if(((x=this._options)==null?void 0:x.enforceStrictCapabilities)===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(T){h(T);return}(M=s==null?void 0:s.signal)==null||M.throwIfAborted();const d=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:d};s!=null&&s.onprogress&&(this._progressHandlers.set(d,s.onprogress),f.params={...t.params,_meta:{...((S=t.params)==null?void 0:S._meta)||{},progressToken:d}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...((k=f.params)==null?void 0:k._meta)||{},[be]:c}});const p=T=>{var O;this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),(O=this._transport)==null||O.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:d,reason:String(T)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:r}).catch(D=>this._onerror(new Error(`Failed to send cancellation: ${D}`)));const z=T instanceof B?T:new B(q.RequestTimeout,String(T));u(z)};this._responseHandlers.set(d,T=>{var z;if(!((z=s==null?void 0:s.signal)!=null&&z.aborted)){if(T instanceof Error)return u(T);try{const O=hc(n,T.result);O.success?l(O.data):u(O.error)}catch(O){u(O)}}}),(C=s==null?void 0:s.signal)==null||C.addEventListener("abort",()=>{var T;p((T=s==null?void 0:s.signal)==null?void 0:T.reason)});const g=(s==null?void 0:s.timeout)??Kg,m=()=>p(B.fromError(q.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(d,g,s==null?void 0:s.maxTotalTimeout,m,(s==null?void 0:s.resetTimeoutOnProgress)??!1);const b=c==null?void 0:c.taskId;if(b){const T=z=>{const O=this._responseHandlers.get(d);O?O(z):this._onerror(new Error(`Response handler missing for side-channeled request ${d}`))};this._requestResolvers.set(d,T),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(d),u(z)})}else this._transport.send(f,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:r}).catch(T=>{this._cleanupTimeout(d),u(T)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Di,n)}async getTaskResult(t,n,s){return this.request({method:"tasks/result",params:t},n,s)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Ni,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Op,n)}async notification(t,n){var a,c,l,u;if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const s=(a=n==null?void 0:n.relatedTask)==null?void 0:a.taskId;if(s){const h={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...((c=t.params)==null?void 0:c._meta)||{},[be]:n.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:h,timestamp:Date.now()});return}if((((l=this._options)==null?void 0:l.debouncedNotificationMethods)??[]).includes(t.method)&&!t.params&&!(n!=null&&n.relatedRequestId)&&!(n!=null&&n.relatedTask)){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{var d,f;if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let h={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(h={...h,params:{...h.params,_meta:{...((d=h.params)==null?void 0:d._meta)||{},[be]:n.relatedTask}}}),(f=this._transport)==null||f.send(h,n).catch(p=>this._onerror(p))});return}let r={...t,jsonrpc:"2.0"};n!=null&&n.relatedTask&&(r={...r,params:{...r.params,_meta:{...((u=r.params)==null?void 0:u._meta)||{},[be]:n.relatedTask}}}),await this._transport.send(r,n)}setRequestHandler(t,n){const s=Eo(t);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(i,o)=>{const r=Do(t,i);return Promise.resolve(n(r,o))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const s=Eo(t);this._notificationHandlers.set(s,i=>{const o=Do(t,i);return Promise.resolve(n(o))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,s){var o;if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const i=(o=this._options)==null?void 0:o.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,s,i)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const s=await this._taskMessageQueue.dequeueAll(t,n);for(const i of s)if(i.type==="request"&&Io(i.message)){const o=i.message.id,r=this._requestResolvers.get(o);r?(r(new B(q.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n){var i,o;let s=((i=this._options)==null?void 0:i.defaultTaskPollInterval)??1e3;try{const r=await((o=this._taskStore)==null?void 0:o.getTask(t));r!=null&&r.pollInterval&&(s=r.pollInterval)}catch{}return new Promise((r,a)=>{if(n.aborted){a(new B(q.InvalidRequest,"Request cancelled"));return}const c=setTimeout(r,s);n.addEventListener("abort",()=>{clearTimeout(c),a(new B(q.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await s.createTask(i,t.id,{method:t.method,params:t.params},n)},getTask:async i=>{const o=await s.getTask(i,n);if(!o)throw new B(q.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,r)=>{await s.storeTaskResult(i,o,r,n);const a=await s.getTask(i,n);if(a){const c=hs.parse({method:"notifications/tasks/status",params:a});await this.notification(c),de(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>s.getTaskResult(i,n),updateTaskStatus:async(i,o,r)=>{const a=await s.getTask(i,n);if(!a)throw new B(q.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(de(a.status))throw new B(q.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(i,o,r,n);const c=await s.getTask(i,n);if(c){const l=hs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),de(c.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>s.listTasks(i,n)}}}class Gg extends Xg{constructor(){super(...arguments);P(this,"_registeredMethods",new Set);P(this,"_eventSlots",new Map);P(this,"setRequestHandler",(n,s)=>{this._assertMethodNotRegistered(n,"setRequestHandler"),super.setRequestHandler(n,s)});P(this,"setNotificationHandler",(n,s)=>{this._assertMethodNotRegistered(n,"setNotificationHandler"),super.setNotificationHandler(n,s)});P(this,"replaceRequestHandler",(n,s)=>{let i=n.shape.method.value;this._registeredMethods.add(i),super.setRequestHandler(n,s)})}onEventDispatch(n,s){}_ensureEventSlot(n){let s=this._eventSlots.get(n);if(!s){let i=this.eventSchemas[n];if(!i)throw Error(`Unknown event: ${String(n)}`);s={listeners:[]},this._eventSlots.set(n,s);let o=i.shape.method.value;this._registeredMethods.add(o);let r=s;super.setNotificationHandler(i,a=>{var l;let c=a.params;this.onEventDispatch(n,c),(l=r.onHandler)==null||l.call(r,c);for(let u of[...r.listeners])u(c)})}return s}setEventHandler(n,s){let i=this._ensureEventSlot(n);i.onHandler&&s&&console.warn(`[MCP Apps] on${String(n)} handler replaced. Use addEventListener("${String(n)}", …) to add multiple listeners without replacing.`),i.onHandler=s}getEventHandler(n){var s;return(s=this._eventSlots.get(n))==null?void 0:s.onHandler}addEventListener(n,s){this._ensureEventSlot(n).listeners.push(s)}removeEventListener(n,s){let i=this._eventSlots.get(n);if(!i)return;let o=i.listeners.indexOf(s);o!==-1&&i.listeners.splice(o,1)}warnIfRequestHandlerReplaced(n,s,i){s&&i&&console.warn(`[MCP Apps] ${n} handler replaced. Previous handler will no longer be called.`)}_assertMethodNotRegistered(n,s){let i=n.shape.method.value;if(this._registeredMethods.has(i))throw Error(`Handler for "${i}" already registered (via ${s}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(i)}}var Qg="2026-01-26",tm="ui/notifications/tool-input-partial";class em{constructor(t=window.parent,n){P(this,"eventTarget");P(this,"eventSource");P(this,"messageListener");P(this,"onclose");P(this,"onerror");P(this,"onmessage");P(this,"sessionId");P(this,"setProtocolVersion");this.eventTarget=t,this.eventSource=n,this.messageListener=s=>{var o,r,a;if(n&&s.source!==this.eventSource){console.debug("Ignoring message from unknown source",s);return}let i=dp.safeParse(s.data);i.success?(console.debug("Parsed message",i.data),(o=this.onmessage)==null||o.call(this,i.data)):((r=s.data)==null?void 0:r.jsonrpc)!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,s):(console.error("Failed to parse message",i.error.message,s),(a=this.onerror)==null||a.call(this,Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==tm&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){var t;window.removeEventListener("message",this.messageListener),(t=this.onclose)==null||t.call(this)}}var nm=H([_("light"),_("dark")]).describe("Color theme preference for the host environment."),pn=H([_("inline"),_("fullscreen"),_("pip")]).describe("Display mode for UI presentation."),sm=H([_("--color-background-primary"),_("--color-background-secondary"),_("--color-background-tertiary"),_("--color-background-inverse"),_("--color-background-ghost"),_("--color-background-info"),_("--color-background-danger"),_("--color-background-success"),_("--color-background-warning"),_("--color-background-disabled"),_("--color-text-primary"),_("--color-text-secondary"),_("--color-text-tertiary"),_("--color-text-inverse"),_("--color-text-ghost"),_("--color-text-info"),_("--color-text-danger"),_("--color-text-success"),_("--color-text-warning"),_("--color-text-disabled"),_("--color-border-primary"),_("--color-border-secondary"),_("--color-border-tertiary"),_("--color-border-inverse"),_("--color-border-ghost"),_("--color-border-info"),_("--color-border-danger"),_("--color-border-success"),_("--color-border-warning"),_("--color-border-disabled"),_("--color-ring-primary"),_("--color-ring-secondary"),_("--color-ring-inverse"),_("--color-ring-info"),_("--color-ring-danger"),_("--color-ring-success"),_("--color-ring-warning"),_("--font-sans"),_("--font-mono"),_("--font-weight-normal"),_("--font-weight-medium"),_("--font-weight-semibold"),_("--font-weight-bold"),_("--font-text-xs-size"),_("--font-text-sm-size"),_("--font-text-md-size"),_("--font-text-lg-size"),_("--font-heading-xs-size"),_("--font-heading-sm-size"),_("--font-heading-md-size"),_("--font-heading-lg-size"),_("--font-heading-xl-size"),_("--font-heading-2xl-size"),_("--font-heading-3xl-size"),_("--font-text-xs-line-height"),_("--font-text-sm-line-height"),_("--font-text-md-line-height"),_("--font-text-lg-line-height"),_("--font-heading-xs-line-height"),_("--font-heading-sm-line-height"),_("--font-heading-md-line-height"),_("--font-heading-lg-line-height"),_("--font-heading-xl-line-height"),_("--font-heading-2xl-line-height"),_("--font-heading-3xl-line-height"),_("--border-radius-xs"),_("--border-radius-sm"),_("--border-radius-md"),_("--border-radius-lg"),_("--border-radius-xl"),_("--border-radius-full"),_("--border-width-regular"),_("--shadow-hairline"),_("--shadow-sm"),_("--shadow-md"),_("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),im=W(sm.describe(`Style variables for theming MCP apps.
|
|
47
47
|
|
|
48
48
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
49
49
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
50
50
|
|
|
51
51
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
52
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),
|
|
52
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),H([y(),ti()]).describe(`Style variables for theming MCP apps.
|
|
53
53
|
|
|
54
54
|
Individual style keys are optional - hosts may provide any subset of these values.
|
|
55
55
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
@@ -61,10 +61,10 @@ Individual style keys are optional - hosts may provide any subset of these value
|
|
|
61
61
|
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
62
62
|
|
|
63
63
|
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
64
|
-
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);v({method:_("ui/open-link"),params:v({url:y().describe("URL to open in the host's browser")})});var
|
|
64
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);v({method:_("ui/open-link"),params:v({url:y().describe("URL to open in the host's browser")})});var om=v({isError:X().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),rm=v({isError:X().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),am=v({isError:X().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();v({method:_("ui/notifications/sandbox-proxy-ready"),params:v({})});var Ui=v({connectDomains:I(y()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
65
65
|
|
|
66
66
|
- Maps to CSP \`connect-src\` directive
|
|
67
|
-
- Empty or omitted → no network connections (secure default)`),resourceDomains:I(y()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:I(y()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:I(y()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Yi=v({camera:v({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:v({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:v({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:v({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});v({method:_("ui/notifications/size-changed"),params:v({width:$().optional().describe("New width in pixels."),height:$().optional().describe("New height in pixels.")})});var
|
|
67
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:I(y()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:I(y()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:I(y()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),Yi=v({camera:v({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:v({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:v({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:v({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});v({method:_("ui/notifications/size-changed"),params:v({width:$().optional().describe("New width in pixels."),height:$().optional().describe("New height in pixels.")})});var cm=v({method:_("ui/notifications/tool-input"),params:v({arguments:W(y(),J().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),lm=v({method:_("ui/notifications/tool-input-partial"),params:v({arguments:W(y(),J().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),um=v({method:_("ui/notifications/tool-cancelled"),params:v({reason:y().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),hm=v({fonts:y().optional()}),dm=v({variables:im.optional().describe("CSS variables for theming the app."),css:hm.optional().describe("CSS blocks that apps can inject.")}),fm=v({method:_("ui/resource-teardown"),params:v({})});W(y(),J());var Lo=v({text:v({}).optional().describe("Host supports text content blocks."),image:v({}).optional().describe("Host supports image content blocks."),audio:v({}).optional().describe("Host supports audio content blocks."),resource:v({}).optional().describe("Host supports resource content blocks."),resourceLink:v({}).optional().describe("Host supports resource link content blocks."),structuredContent:v({}).optional().describe("Host supports structured content.")});v({method:_("ui/notifications/request-teardown"),params:v({}).optional()});var pm=v({experimental:v({}).optional().describe("Experimental features (structure TBD)."),openLinks:v({}).optional().describe("Host supports opening external URLs."),downloadFile:v({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:v({listChanged:X().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:v({listChanged:X().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:v({}).optional().describe("Host accepts log messages."),sandbox:v({permissions:Yi.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Ui.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Lo.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Lo.optional().describe("Host supports receiving content messages (ui/message) from the view.")}),gm=v({experimental:v({}).optional().describe("Experimental features (structure TBD)."),tools:v({listChanged:X().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:I(pn).optional().describe("Display modes the app supports.")});v({method:_("ui/notifications/initialized"),params:v({}).optional()});v({csp:Ui.optional().describe("Content Security Policy configuration for UI resources."),permissions:Yi.optional().describe("Sandbox permissions requested by the UI resource."),domain:y().optional().describe(`Dedicated origin for view sandbox.
|
|
68
68
|
|
|
69
69
|
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
70
70
|
|
|
@@ -72,45 +72,45 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
|
|
|
72
72
|
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
73
73
|
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
74
74
|
|
|
75
|
-
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:
|
|
75
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:X().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
76
76
|
|
|
77
77
|
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
78
78
|
|
|
79
79
|
- \`true\`: request visible border + background
|
|
80
80
|
- \`false\`: request no visible border + background
|
|
81
|
-
- omitted: host decides border`)});v({method:_("ui/request-display-mode"),params:v({mode:pn.describe("The display mode being requested.")})});var
|
|
81
|
+
- omitted: host decides border`)});v({method:_("ui/request-display-mode"),params:v({mode:pn.describe("The display mode being requested.")})});var mm=v({mode:pn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),bm=H([_("model"),_("app")]).describe("Tool visibility scope - who can access the tool.");v({resourceUri:y().optional(),visibility:I(bm).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
82
82
|
- "model": Tool visible to and callable by the agent
|
|
83
|
-
- "app": Tool callable by the app from this server only`)});v({mimeTypes:I(y()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});v({method:_("ui/download-file"),params:v({contents:I(
|
|
84
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:y().optional().describe("User's language and region preference in BCP 47 format."),timeZone:y().optional().describe("User's timezone in IANA format."),userAgent:y().optional().describe("Host application identifier."),platform:
|
|
83
|
+
- "app": Tool callable by the app from this server only`)});v({mimeTypes:I(y()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});v({method:_("ui/download-file"),params:v({contents:I(H([rc,ac])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});v({method:_("ui/message"),params:v({role:_("user").describe('Message role, currently only "user" is supported.'),content:I(On).describe("Message content blocks (text, image, etc.).")})});v({method:_("ui/notifications/sandbox-resource-ready"),params:v({html:y().describe("HTML content to load into the inner iframe."),sandbox:y().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Ui.optional().describe("CSP configuration from resource metadata."),permissions:Yi.optional().describe("Sandbox permissions from resource metadata.")})});var _m=v({method:_("ui/notifications/tool-result"),params:Cs.describe("Standard MCP tool execution result.")}),dc=v({toolInfo:v({id:Sn.optional().describe("JSON-RPC id of the tools/call request."),tool:Wi.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:nm.optional().describe("Current color theme preference."),styles:dm.optional().describe("Style configuration for theming the app."),displayMode:pn.optional().describe("How the UI is currently displayed."),availableDisplayModes:I(pn).optional().describe("Display modes the host supports."),containerDimensions:H([v({height:$().describe("Fixed container height in pixels.")}),v({maxHeight:H([$(),ti()]).optional().describe("Maximum container height in pixels.")})]).and(H([v({width:$().describe("Fixed container width in pixels.")}),v({maxWidth:H([$(),ti()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
84
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:y().optional().describe("User's language and region preference in BCP 47 format."),timeZone:y().optional().describe("User's timezone in IANA format."),userAgent:y().optional().describe("Host application identifier."),platform:H([_("web"),_("desktop"),_("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:v({touch:X().optional().describe("Whether the device supports touch input."),hover:X().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:v({top:$().describe("Top safe area inset in pixels."),right:$().describe("Right safe area inset in pixels."),bottom:$().describe("Bottom safe area inset in pixels."),left:$().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),ym=v({method:_("ui/notifications/host-context-changed"),params:dc.describe("Partial context update containing only changed fields.")});v({method:_("ui/update-model-context"),params:v({content:I(On).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:W(y(),J().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});v({method:_("ui/initialize"),params:v({appInfo:Ps.describe("App identification (name and version)."),appCapabilities:gm.describe("Features and capabilities this app provides."),protocolVersion:y().describe("Protocol version this app supports.")})});var xm=v({protocolVersion:y().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Ps.describe("Host application identification and version."),hostCapabilities:pm.describe("Features and capabilities provided by the host."),hostContext:dc.describe("Rich context about the host environment.")}).passthrough();function Ji(e){let t=document.documentElement;t.setAttribute("data-theme",e),t.style.colorScheme=e}function vm(e,t=document.documentElement){for(let[n,s]of Object.entries(e))s!==void 0&&t.style.setProperty(n,s)}function km(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}class wm extends Gg{constructor(n,s={},i={autoResize:!0}){super(i);P(this,"_appInfo");P(this,"_capabilities");P(this,"options");P(this,"_hostCapabilities");P(this,"_hostInfo");P(this,"_hostContext");P(this,"eventSchemas",{toolinput:cm,toolinputpartial:lm,toolresult:_m,toolcancelled:um,hostcontextchanged:ym});P(this,"_onteardown");P(this,"_oncalltool");P(this,"_onlisttools");P(this,"sendOpenLink",this.openLink);this._appInfo=n,this._capabilities=s,this.options=i,this.setRequestHandler(Ts,o=>(console.log("Received ping:",o.params),{})),this.setEventHandler("hostcontextchanged",void 0)}onEventDispatch(n,s){n==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...s})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(n){this.setEventHandler("toolinput",n)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(n){this.setEventHandler("toolinputpartial",n)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(n){this.setEventHandler("toolresult",n)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(n){this.setEventHandler("toolcancelled",n)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(n){this.setEventHandler("hostcontextchanged",n)}get onteardown(){return this._onteardown}set onteardown(n){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,n),this._onteardown=n,this.replaceRequestHandler(fm,(s,i)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(s.params,i)})}get oncalltool(){return this._oncalltool}set oncalltool(n){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,n),this._oncalltool=n,this.replaceRequestHandler(lc,(s,i)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(s.params,i)})}get onlisttools(){return this._onlisttools}set onlisttools(n){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,n),this._onlisttools=n,this.replaceRequestHandler(cc,(s,i)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(s.params,i)})}assertCapabilityForMethod(n){}assertRequestHandlerCapability(n){switch(n){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${n})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${n} registered`)}}assertNotificationCapability(n){}assertTaskCapability(n){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(n){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(n,s){if(typeof n=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${n}"). Did you mean: callServerTool({ name: "${n}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:n},Cs,s)}async readServerResource(n,s){return await this.request({method:"resources/read",params:n},oc,s)}async listServerResources(n,s){return await this.request({method:"resources/list",params:n},ic,s)}sendMessage(n,s){return this.request({method:"ui/message",params:n},am,s)}sendLog(n){return this.notification({method:"notifications/message",params:n})}updateModelContext(n,s){return this.request({method:"ui/update-model-context",params:n},Oi,s)}openLink(n,s){return this.request({method:"ui/open-link",params:n},om,s)}downloadFile(n,s){return this.request({method:"ui/download-file",params:n},rm,s)}requestTeardown(n={}){return this.notification({method:"ui/notifications/request-teardown",params:n})}requestDisplayMode(n,s){return this.request({method:"ui/request-display-mode",params:n},mm,s)}sendSizeChanged(n){return this.notification({method:"ui/notifications/size-changed",params:n})}setupSizeChangedNotifications(){let n=!1,s=0,i=0,o=()=>{n||(n=!0,requestAnimationFrame(()=>{n=!1;let a=document.documentElement,c=a.style.height;a.style.height="max-content";let l=Math.ceil(a.getBoundingClientRect().height);a.style.height=c;let u=Math.ceil(window.innerWidth);(u!==s||l!==i)&&(s=u,i=l,this.sendSizeChanged({width:u,height:l}))}))};o();let r=new ResizeObserver(o);return r.observe(document.documentElement),r.observe(document.body),()=>r.disconnect()}async connect(n=new em(window.parent,window.parent),s){var i;if(this.transport)throw Error("App is already connected. Call close() before connecting again.");await super.connect(n);try{let o=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Qg}},xm,s);if(o===void 0)throw Error(`Server sent invalid initialize result: ${o}`);this._hostCapabilities=o.hostCapabilities,this._hostInfo=o.hostInfo,this._hostContext=o.hostContext,await this.notification({method:"ui/notifications/initialized"}),(i=this.options)!=null&&i.autoResize&&this.setupSizeChangedNotifications()}catch(o){throw this.close(),o}}}/*!
|
|
85
85
|
* @kurkle/color v0.3.4
|
|
86
86
|
* https://github.com/kurkle/color#readme
|
|
87
87
|
* (c) 2024 Jukka Kurkela
|
|
88
88
|
* Released under the MIT License
|
|
89
|
-
*/function Rn(e){return e+.5|0}const
|
|
89
|
+
*/function Rn(e){return e+.5|0}const Xt=(e,t,n)=>Math.max(Math.min(e,n),t);function tn(e){return Xt(Rn(e*2.55),0,255)}function ne(e){return Xt(Rn(e*255),0,255)}function Wt(e){return Xt(Rn(e/2.55)/100,0,1)}function $o(e){return Xt(Rn(e*100),0,100)}const Rt={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},si=[..."0123456789ABCDEF"],Sm=e=>si[e&15],Mm=e=>si[(e&240)>>4]+si[e&15],Fn=e=>(e&240)>>4===(e&15),Pm=e=>Fn(e.r)&&Fn(e.g)&&Fn(e.b)&&Fn(e.a);function Tm(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&Rt[e[1]]*17,g:255&Rt[e[2]]*17,b:255&Rt[e[3]]*17,a:t===5?Rt[e[4]]*17:255}:(t===7||t===9)&&(n={r:Rt[e[1]]<<4|Rt[e[2]],g:Rt[e[3]]<<4|Rt[e[4]],b:Rt[e[5]]<<4|Rt[e[6]],a:t===9?Rt[e[7]]<<4|Rt[e[8]]:255})),n}const Cm=(e,t)=>e<255?t(e):"";function zm(e){var t=Pm(e)?Sm:Mm;return e?"#"+t(e.r)+t(e.g)+t(e.b)+Cm(e.a,t):void 0}const Om=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function fc(e,t,n){const s=t*Math.min(n,1-n),i=(o,r=(o+e/30)%12)=>n-s*Math.max(Math.min(r-3,9-r,1),-1);return[i(0),i(8),i(4)]}function Rm(e,t,n){const s=(i,o=(i+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[s(5),s(3),s(1)]}function Am(e,t,n){const s=fc(e,1,.5);let i;for(t+n>1&&(i=1/(t+n),t*=i,n*=i),i=0;i<3;i++)s[i]*=1-t-n,s[i]+=t;return s}function Im(e,t,n,s,i){return e===i?(t-n)/s+(t<n?6:0):t===i?(n-e)/s+2:(e-t)/s+4}function Ki(e){const n=e.r/255,s=e.g/255,i=e.b/255,o=Math.max(n,s,i),r=Math.min(n,s,i),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=Im(n,s,i,u,o),c=c*60+.5),[c|0,l||0,a]}function Xi(e,t,n,s){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,s)).map(ne)}function Gi(e,t,n){return Xi(fc,e,t,n)}function Em(e,t,n){return Xi(Am,e,t,n)}function Dm(e,t,n){return Xi(Rm,e,t,n)}function pc(e){return(e%360+360)%360}function Lm(e){const t=Om.exec(e);let n=255,s;if(!t)return;t[5]!==s&&(n=t[6]?tn(+t[5]):ne(+t[5]));const i=pc(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?s=Em(i,o,r):t[1]==="hsv"?s=Dm(i,o,r):s=Gi(i,o,r),{r:s[0],g:s[1],b:s[2],a:n}}function $m(e,t){var n=Ki(e);n[0]=pc(n[0]+t),n=Gi(n),e.r=n[0],e.g=n[1],e.b=n[2]}function Nm(e){if(!e)return;const t=Ki(e),n=t[0],s=$o(t[1]),i=$o(t[2]);return e.a<255?`hsla(${n}, ${s}%, ${i}%, ${Wt(e.a)})`:`hsl(${n}, ${s}%, ${i}%)`}const No={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"},Fo={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 Fm(){const e={},t=Object.keys(Fo),n=Object.keys(No);let s,i,o,r,a;for(s=0;s<t.length;s++){for(r=a=t[s],i=0;i<n.length;i++)o=n[i],a=a.replace(o,No[o]);o=parseInt(Fo[r],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}let Hn;function Hm(e){Hn||(Hn=Fm(),Hn.transparent=[0,0,0,0]);const t=Hn[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const jm=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function Bm(e){const t=jm.exec(e);let n=255,s,i,o;if(t){if(t[7]!==s){const r=+t[7];n=t[8]?tn(r):Xt(r*255,0,255)}return s=+t[1],i=+t[3],o=+t[5],s=255&(t[2]?tn(s):Xt(s,0,255)),i=255&(t[4]?tn(i):Xt(i,0,255)),o=255&(t[6]?tn(o):Xt(o,0,255)),{r:s,g:i,b:o,a:n}}}function Zm(e){return e&&(e.a<255?`rgba(${e.r}, ${e.g}, ${e.b}, ${Wt(e.a)})`:`rgb(${e.r}, ${e.g}, ${e.b})`)}const Ns=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,Oe=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function Vm(e,t,n){const s=Oe(Wt(e.r)),i=Oe(Wt(e.g)),o=Oe(Wt(e.b));return{r:ne(Ns(s+n*(Oe(Wt(t.r))-s))),g:ne(Ns(i+n*(Oe(Wt(t.g))-i))),b:ne(Ns(o+n*(Oe(Wt(t.b))-o))),a:e.a+n*(t.a-e.a)}}function jn(e,t,n){if(e){let s=Ki(e);s[t]=Math.max(0,Math.min(s[t]+s[t]*n,t===0?360:1)),s=Gi(s),e.r=s[0],e.g=s[1],e.b=s[2]}}function gc(e,t){return e&&Object.assign(t||{},e)}function Ho(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=ne(e[3]))):(t=gc(e,{r:0,g:0,b:0,a:1}),t.a=ne(t.a)),t}function Wm(e){return e.charAt(0)==="r"?Bm(e):Lm(e)}class gn{constructor(t){if(t instanceof gn)return t;const n=typeof t;let s;n==="object"?s=Ho(t):n==="string"&&(s=Tm(t)||Hm(t)||Wm(t)),this._rgb=s,this._valid=!!s}get valid(){return this._valid}get rgb(){var t=gc(this._rgb);return t&&(t.a=Wt(t.a)),t}set rgb(t){this._rgb=Ho(t)}rgbString(){return this._valid?Zm(this._rgb):void 0}hexString(){return this._valid?zm(this._rgb):void 0}hslString(){return this._valid?Nm(this._rgb):void 0}mix(t,n){if(t){const s=this.rgb,i=t.rgb;let o;const r=n===o?.5:n,a=2*r-1,c=s.a-i.a,l=((a*c===-1?a:(a+c)/(1+a*c))+1)/2;o=1-l,s.r=255&l*s.r+o*i.r+.5,s.g=255&l*s.g+o*i.g+.5,s.b=255&l*s.b+o*i.b+.5,s.a=r*s.a+(1-r)*i.a,this.rgb=s}return this}interpolate(t,n){return t&&(this._rgb=Vm(this._rgb,t._rgb,n)),this}clone(){return new gn(this.rgb)}alpha(t){return this._rgb.a=ne(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=Rn(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 jn(this._rgb,2,t),this}darken(t){return jn(this._rgb,2,-t),this}saturate(t){return jn(this._rgb,1,t),this}desaturate(t){return jn(this._rgb,1,-t),this}rotate(t){return $m(this._rgb,t),this}}/*!
|
|
90
90
|
* Chart.js v4.5.1
|
|
91
91
|
* https://www.chartjs.org
|
|
92
92
|
* (c) 2025 Chart.js Contributors
|
|
93
93
|
* Released under the MIT License
|
|
94
|
-
*/function Ht(){}const Wm=(()=>{let e=0;return()=>e++})();function N(e){return e==null}function nt(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 j(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function rt(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function Ct(e,t){return rt(e)?e:t}function D(e,t){return typeof e>"u"?t:e}const qm=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100:+e/t,bc=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function X(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function W(e,t,n,s){let i,o,r;if(nt(e))for(o=e.length,i=0;i<o;i++)t.call(n,e[i],i);else if(j(e))for(r=Object.keys(e),o=r.length,i=0;i<o;i++)t.call(n,e[r[i]],r[i])}function fs(e,t){let n,s,i,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,s=e.length;n<s;++n)if(i=e[n],o=t[n],i.datasetIndex!==o.datasetIndex||i.index!==o.index)return!1;return!0}function ps(e){if(nt(e))return e.map(ps);if(j(e)){const t=Object.create(null),n=Object.keys(e),s=n.length;let i=0;for(;i<s;++i)t[n[i]]=ps(e[n[i]]);return t}return e}function _c(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function Um(e,t,n,s){if(!_c(e))return;const i=t[e],o=n[e];j(i)&&j(o)?mn(i,o,s):t[e]=ps(o)}function mn(e,t,n){const s=nt(t)?t:[t],i=s.length;if(!j(e))return e;n=n||{};const o=n.merger||Um;let r;for(let a=0;a<i;++a){if(r=s[a],!j(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 an(e,t){return mn(e,t,{merger:Ym})}function Ym(e,t,n){if(!_c(e))return;const s=t[e],i=n[e];j(s)&&j(i)?an(s,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=ps(i))}const Bo={"":e=>e,x:e=>e.x,y:e=>e.y};function Jm(e){const t=e.split("."),n=[];let s="";for(const i of t)s+=i,s.endsWith("\\")?s=s.slice(0,-1)+".":(n.push(s),s="");return n}function Xm(e){const t=Jm(e);return n=>{for(const s of t){if(s==="")break;n=n&&n[s]}return n}}function oe(e,t){return(Bo[t]||(Bo[t]=Xm(t)))(e)}function Qi(e){return e.charAt(0).toUpperCase()+e.slice(1)}const bn=e=>typeof e<"u",re=e=>typeof e=="function",Ho=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function Km(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const Z=Math.PI,G=2*Z,Gm=G+Z,gs=Number.POSITIVE_INFINITY,Qm=Z/180,lt=Z/2,fe=Z/4,Zo=Z*2/3,Gt=Math.log10,Bt=Math.sign;function cn(e,t,n){return Math.abs(e-t)<n}function Vo(e){const t=Math.round(e);e=cn(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Gt(e))),s=e/n;return(s<=1?1:s<=2?2:s<=5?5:10)*n}function tb(e){const t=[],n=Math.sqrt(e);let s;for(s=1;s<n;s++)e%s===0&&(t.push(s),t.push(e/s));return n===(n|0)&&t.push(n),t.sort((i,o)=>i-o).pop(),t}function eb(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function je(e){return!eb(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function nb(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function yc(e,t,n){let s,i,o;for(s=0,i=e.length;s<i;s++)o=e[s][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function Lt(e){return e*(Z/180)}function to(e){return e*(180/Z)}function Wo(e){if(!rt(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function xc(e,t){const n=t.x-e.x,s=t.y-e.y,i=Math.sqrt(n*n+s*s);let o=Math.atan2(s,n);return o<-.5*Z&&(o+=G),{angle:o,distance:i}}function ii(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function sb(e,t){return(e-t+Gm)%G-Z}function yt(e){return(e%G+G)%G}function _n(e,t,n,s){const i=yt(e),o=yt(t),r=yt(n),a=yt(o-i),c=yt(r-i),l=yt(i-o),u=yt(i-r);return i===o||i===r||s&&o===r||a>c&&l<u}function dt(e,t,n){return Math.max(t,Math.min(n,e))}function ib(e){return dt(e,-32768,32767)}function Ut(e,t,n,s=1e-6){return e>=Math.min(t,n)-s&&e<=Math.max(t,n)+s}function eo(e,t,n){n=n||(r=>e[r]<t);let s=e.length-1,i=0,o;for(;s-i>1;)o=i+s>>1,n(o)?i=o:s=o;return{lo:i,hi:s}}const Yt=(e,t,n,s)=>eo(e,n,s?i=>{const o=e[i][t];return o<n||o===n&&e[i+1][t]===n}:i=>e[i][t]<n),ob=(e,t,n)=>eo(e,n,s=>e[s][t]>=n);function rb(e,t,n){let s=0,i=e.length;for(;s<i&&e[s]<t;)s++;for(;i>s&&e[i-1]>n;)i--;return s>0||i<e.length?e.slice(s,i):e}const vc=["push","pop","shift","splice","unshift"];function ab(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),vc.forEach(n=>{const s="_onData"+Qi(n),i=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const r=i.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[s]=="function"&&a[s](...o)}),r}})})}function qo(e,t){const n=e._chartjs;if(!n)return;const s=n.listeners,i=s.indexOf(t);i!==-1&&s.splice(i,1),!(s.length>0)&&(vc.forEach(o=>{delete e[o]}),delete e._chartjs)}function kc(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const wc=(function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame})();function Sc(e,t){let n=[],s=!1;return function(...i){n=i,s||(s=!0,wc.call(window,()=>{s=!1,e.apply(t,n)}))}}function cb(e,t){let n;return function(...s){return t?(clearTimeout(n),n=setTimeout(e,t,s)):e.apply(this,s),t}}const no=e=>e==="start"?"left":e==="end"?"right":"center",_t=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,lb=(e,t,n,s)=>e===(s?"left":"right")?n:e==="center"?(t+n)/2:t;function Mc(e,t,n){const s=t.length;let i=0,o=s;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(i=Math.min(Yt(c,u,h).lo,n?s:Yt(t,u,r.getPixelForValue(h)).lo),l){const g=c.slice(0,i+1).reverse().findIndex(m=>!N(m[a.axis]));i-=Math.max(0,g)}i=dt(i,0,s-1)}if(p){let g=Math.max(Yt(c,r.axis,d,!0).hi+1,n?0:Yt(t,u,r.getPixelForValue(d),!0).hi+1);if(l){const m=c.slice(g-1).findIndex(b=>!N(b[a.axis]));g+=Math.max(0,m)}o=dt(g,i,s)-i}else o=s-i}return{start:i,count:o}}function Pc(e){const{xScale:t,yScale:n,_scaleRanges:s}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!s)return e._scaleRanges=i,!0;const o=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==n.min||s.ymax!==n.max;return Object.assign(s,i),o}const Hn=e=>e===0||e===1,Uo=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*G/n)),Yo=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*G/n)+1,ln={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*lt)+1,easeOutSine:e=>Math.sin(e*lt),easeInOutSine:e=>-.5*(Math.cos(Z*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:Uo(e,.075,.3),easeOutElastic:e=>Hn(e)?e:Yo(e,.075,.3),easeInOutElastic(e){return Hn(e)?e:e<.5?.5*Uo(e*2,.1125,.45):.5+.5*Yo(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-ln.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?ln.easeInBounce(e*2)*.5:ln.easeOutBounce(e*2-1)*.5+.5};function so(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Jo(e){return so(e)?e:new gn(e)}function Fs(e){return so(e)?e:new gn(e).saturate(.5).darken(.1).hexString()}const ub=["x","y","borderWidth","radius","tension"],hb=["color","borderColor","backgroundColor"];function db(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:hb},numbers:{type:"number",properties:ub}}),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 fb(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const Xo=new Map;function pb(e,t){t=t||{};const n=e+JSON.stringify(t);let s=Xo.get(n);return s||(s=new Intl.NumberFormat(e,t),Xo.set(n,s)),s}function An(e,t,n){return pb(t,n).format(e)}const Tc={values(e){return nt(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const s=this.chart.options.locale;let i,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)&&(i="scientific"),o=gb(e,n)}const r=Gt(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),c={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(c,this.options.ticks.format),An(e,s,c)},logarithmic(e,t,n){if(e===0)return"0";const s=n[t].significand||e/Math.pow(10,Math.floor(Gt(e)));return[1,2,3,5,10,15].includes(s)||t>.8*n.length?Tc.numeric.call(this,e,t,n):""}};function gb(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 zs={formatters:Tc};function mb(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:zs.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 Se=Object.create(null),oi=Object.create(null);function un(e,t){if(!t)return e;const n=t.split(".");for(let s=0,i=n.length;s<i;++s){const o=n[s];e=e[o]||(e[o]=Object.create(null))}return e}function js(e,t,n){return typeof t=="string"?mn(un(e,t),n):mn(un(e,""),t)}class bb{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=s=>s.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=(s,i)=>Fs(i.backgroundColor),this.hoverBorderColor=(s,i)=>Fs(i.borderColor),this.hoverColor=(s,i)=>Fs(i.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 js(this,t,n)}get(t){return un(this,t)}describe(t,n){return js(oi,t,n)}override(t,n){return js(Se,t,n)}route(t,n,s,i){const o=un(this,t),r=un(this,s),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const c=this[a],l=r[i];return j(c)?Object.assign({},l,c):D(c,l)},set(c){this[a]=c}}})}apply(t){t.forEach(n=>n(this))}}var st=new bb({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[db,fb,mb]);function _b(e){return!e||N(e.size)||N(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function ms(e,t,n,s,i){let o=t[i];return o||(o=t[i]=e.measureText(i).width,n.push(i)),o>s&&(s=o),s}function yb(e,t,n,s){s=s||{};let i=s.data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(i=s.data={},o=s.garbageCollect=[],s.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&&!nt(h))r=ms(e,i,o,r,h);else if(nt(h))for(l=0,u=h.length;l<u;l++)d=h[l],d!=null&&!nt(d)&&(r=ms(e,i,o,r,d));e.restore();const f=o.length/2;if(f>n.length){for(c=0;c<f;c++)delete i[o[c]];o.splice(0,f)}return r}function pe(e,t,n){const s=e.currentDevicePixelRatio,i=n!==0?Math.max(n/2,.5):0;return Math.round((t-i)*s)/s+i}function Ko(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function ri(e,t,n,s){Cc(e,t,n,s,null)}function Cc(e,t,n,s,i){let o,r,a,c,l,u,h,d;const f=t.pointStyle,p=t.rotation,g=t.radius;let m=(p||0)*Qm;if(f&&typeof f=="object"&&(o=f.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,s),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:i?e.ellipse(n,s,i/2,g,0,0,G):e.arc(n,s,g,0,G),e.closePath();break;case"triangle":u=i?i/2:g,e.moveTo(n+Math.sin(m)*u,s-Math.cos(m)*g),m+=Zo,e.lineTo(n+Math.sin(m)*u,s-Math.cos(m)*g),m+=Zo,e.lineTo(n+Math.sin(m)*u,s-Math.cos(m)*g),e.closePath();break;case"rectRounded":l=g*.516,c=g-l,r=Math.cos(m+fe)*c,h=Math.cos(m+fe)*(i?i/2-l:c),a=Math.sin(m+fe)*c,d=Math.sin(m+fe)*(i?i/2-l:c),e.arc(n-h,s-a,l,m-Z,m-lt),e.arc(n+d,s-r,l,m-lt,m),e.arc(n+h,s+a,l,m,m+lt),e.arc(n-d,s+r,l,m+lt,m+Z),e.closePath();break;case"rect":if(!p){c=Math.SQRT1_2*g,u=i?i/2:c,e.rect(n-u,s-c,2*u,2*c);break}m+=fe;case"rectRot":h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+d,s-r),e.lineTo(n+h,s+a),e.lineTo(n-d,s+r),e.closePath();break;case"crossRot":m+=fe;case"cross":h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+h,s+a),e.moveTo(n+d,s-r),e.lineTo(n-d,s+r);break;case"star":h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+h,s+a),e.moveTo(n+d,s-r),e.lineTo(n-d,s+r),m+=fe,h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+h,s+a),e.moveTo(n+d,s-r),e.lineTo(n-d,s+r);break;case"line":r=i?i/2:Math.cos(m)*g,a=Math.sin(m)*g,e.moveTo(n-r,s-a),e.lineTo(n+r,s+a);break;case"dash":e.moveTo(n,s),e.lineTo(n+Math.cos(m)*(i?i/2:g),s+Math.sin(m)*g);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function Jt(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 Os(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function Rs(e){e.restore()}function xb(e,t,n,s,i){if(!t)return e.lineTo(n.x,n.y);if(i==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else i==="after"!=!!s?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function vb(e,t,n,s){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(s?t.cp1x:t.cp2x,s?t.cp1y:t.cp2y,s?n.cp2x:n.cp1x,s?n.cp2y:n.cp1y,n.x,n.y)}function kb(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),N(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 wb(e,t,n,s,i){if(i.strikethrough||i.underline){const o=e.measureText(s),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,c=n-o.actualBoundingBoxAscent,l=n+o.actualBoundingBoxDescent,u=i.strikethrough?(c+l)/2:l;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(r,u),e.lineTo(a,u),e.stroke()}}function Sb(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Me(e,t,n,s,i,o={}){const r=nt(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let c,l;for(e.save(),e.font=i.string,kb(e,o),c=0;c<r.length;++c)l=r[c],o.backdrop&&Sb(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),N(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(l,n,s,o.maxWidth)),e.fillText(l,n,s,o.maxWidth),wb(e,n,s,l,o),s+=Number(i.lineHeight);e.restore()}function yn(e,t){const{x:n,y:s,w:i,h:o,radius:r}=t;e.arc(n+r.topLeft,s+r.topLeft,r.topLeft,1.5*Z,Z,!0),e.lineTo(n,s+o-r.bottomLeft),e.arc(n+r.bottomLeft,s+o-r.bottomLeft,r.bottomLeft,Z,lt,!0),e.lineTo(n+i-r.bottomRight,s+o),e.arc(n+i-r.bottomRight,s+o-r.bottomRight,r.bottomRight,lt,0,!0),e.lineTo(n+i,s+r.topRight),e.arc(n+i-r.topRight,s+r.topRight,r.topRight,0,-lt,!0),e.lineTo(n+r.topLeft,s)}const Mb=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Pb=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Tb(e,t){const n=(""+e).match(Mb);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 Cb=e=>+e||0;function io(e,t){const n={},s=j(t),i=s?Object.keys(t):t,o=j(e)?s?r=>D(e[r],e[t[r]]):r=>e[r]:()=>e;for(const r of i)n[r]=Cb(o(r));return n}function zc(e){return io(e,{top:"y",right:"x",bottom:"y",left:"x"})}function ke(e){return io(e,["topLeft","topRight","bottomLeft","bottomRight"])}function vt(e){const t=zc(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function ht(e,t){e=e||{},t=t||st.font;let n=D(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let s=D(e.style,t.style);s&&!(""+s).match(Pb)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const i={family:D(e.family,t.family),lineHeight:Tb(D(e.lineHeight,t.lineHeight),n),size:n,style:s,weight:D(e.weight,t.weight),string:""};return i.string=_b(i),i}function en(e,t,n,s){let i,o,r;for(i=0,o=e.length;i<o;++i)if(r=e[i],r!==void 0&&r!==void 0)return r}function zb(e,t,n){const{min:s,max:i}=e,o=bc(t,(i-s)/2),r=(a,c)=>n&&a===0?0:a+c;return{min:r(s,-Math.abs(o)),max:r(i,o)}}function le(e,t){return Object.assign(Object.create(e),t)}function oo(e,t=[""],n,s,i=()=>e[0]){const o=n||e;typeof s>"u"&&(s=Ic("_fallback",e));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:s,_getTarget:i,override:a=>oo([a,...e],t,o,s)};return new Proxy(r,{deleteProperty(a,c){return delete a[c],delete a._keys,delete e[0][c],!0},get(a,c){return Rc(a,c,()=>$b(c,t,e,a))},getOwnPropertyDescriptor(a,c){return Reflect.getOwnPropertyDescriptor(a._scopes[0],c)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,c){return Qo(a).includes(c)},ownKeys(a){return Qo(a)},set(a,c,l){const u=a._storage||(a._storage=i());return a[c]=u[c]=l,delete a._keys,!0}})}function Be(e,t,n,s){const i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:Oc(e,s),setContext:o=>Be(e,o,n,s),override:o=>Be(e.override(o),t,n,s)};return new Proxy(i,{deleteProperty(o,r){return delete o[r],delete e[r],!0},get(o,r,a){return Rc(o,r,()=>Rb(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 Oc(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:s=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:s,isScriptable:re(n)?n:()=>n,isIndexable:re(s)?s:()=>s}}const Ob=(e,t)=>e?e+Qi(t):t,ro=(e,t)=>j(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function Rc(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const s=n();return e[t]=s,s}function Rb(e,t,n){const{_proxy:s,_context:i,_subProxy:o,_descriptors:r}=e;let a=s[t];return re(a)&&r.isScriptable(t)&&(a=Ab(t,a,e,n)),nt(a)&&a.length&&(a=Ib(t,a,e,r.isIndexable)),ro(t,a)&&(a=Be(a,i,o&&o[t],r)),a}function Ab(e,t,n,s){const{_proxy:i,_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||s);return a.delete(e),ro(e,c)&&(c=ao(i._scopes,i,e,c)),c}function Ib(e,t,n,s){const{_proxy:i,_context:o,_subProxy:r,_descriptors:a}=n;if(typeof o.index<"u"&&s(e))return t[o.index%t.length];if(j(t[0])){const c=t,l=i._scopes.filter(u=>u!==c);t=[];for(const u of c){const h=ao(l,i,e,u);t.push(Be(h,o,r&&r[e],a))}}return t}function Ac(e,t,n){return re(e)?e(t,n):e}const Db=(e,t)=>e===!0?t:typeof e=="string"?oe(t,e):void 0;function Eb(e,t,n,s,i){for(const o of t){const r=Db(n,o);if(r){e.add(r);const a=Ac(r._fallback,n,i);if(typeof a<"u"&&a!==n&&a!==s)return a}else if(r===!1&&typeof s<"u"&&n!==s)return null}return!1}function ao(e,t,n,s){const i=t._rootScopes,o=Ac(t._fallback,n,s),r=[...e,...i],a=new Set;a.add(s);let c=Go(a,r,n,o||n,s);return c===null||typeof o<"u"&&o!==n&&(c=Go(a,r,o,c,s),c===null)?!1:oo(Array.from(a),[""],i,o,()=>Lb(t,n,s))}function Go(e,t,n,s,i){for(;n;)n=Eb(e,t,n,s,i);return n}function Lb(e,t,n){const s=e._getTarget();t in s||(s[t]={});const i=s[t];return nt(i)&&j(n)?n:i||{}}function $b(e,t,n,s){let i;for(const o of t)if(i=Ic(Ob(o,e),n),typeof i<"u")return ro(e,i)?ao(n,s,e,i):i}function Ic(e,t){for(const n of t){if(!n)continue;const s=n[e];if(typeof s<"u")return s}}function Qo(e){let t=e._keys;return t||(t=e._keys=Nb(e._scopes)),t}function Nb(e){const t=new Set;for(const n of e)for(const s of Object.keys(n).filter(i=>!i.startsWith("_")))t.add(s);return Array.from(t)}function Dc(e,t,n,s){const{iScale:i}=e,{key:o="r"}=this._parsing,r=new Array(s);let a,c,l,u;for(a=0,c=s;a<c;++a)l=a+n,u=t[l],r[a]={r:i.parse(oe(u,o),l)};return r}const Fb=Number.EPSILON||1e-14,He=(e,t)=>t<e.length&&!e[t].skip&&e[t],Ec=e=>e==="x"?"y":"x";function jb(e,t,n,s){const i=e.skip?t:e,o=t,r=n.skip?t:n,a=ii(o,i),c=ii(r,o);let l=a/(a+c),u=c/(a+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;const h=s*l,d=s*u;return{previous:{x:o.x-h*(r.x-i.x),y:o.y-h*(r.y-i.y)},next:{x:o.x+d*(r.x-i.x),y:o.y+d*(r.y-i.y)}}}function Bb(e,t,n){const s=e.length;let i,o,r,a,c,l=He(e,0);for(let u=0;u<s-1;++u)if(c=l,l=He(e,u+1),!(!c||!l)){if(cn(t[u],0,Fb)){n[u]=n[u+1]=0;continue}i=n[u]/t[u],o=n[u+1]/t[u],a=Math.pow(i,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),n[u]=i*r*t[u],n[u+1]=o*r*t[u])}}function Hb(e,t,n="x"){const s=Ec(n),i=e.length;let o,r,a,c=He(e,0);for(let l=0;l<i;++l){if(r=a,a=c,c=He(e,l+1),!a)continue;const u=a[n],h=a[s];r&&(o=(u-r[n])/3,a[`cp1${n}`]=u-o,a[`cp1${s}`]=h-o*t[l]),c&&(o=(c[n]-u)/3,a[`cp2${n}`]=u+o,a[`cp2${s}`]=h+o*t[l])}}function Zb(e,t="x"){const n=Ec(t),s=e.length,i=Array(s).fill(0),o=Array(s);let r,a,c,l=He(e,0);for(r=0;r<s;++r)if(a=c,c=l,l=He(e,r+1),!!c){if(l){const u=l[t]-c[t];i[r]=u!==0?(l[n]-c[n])/u:0}o[r]=a?l?Bt(i[r-1])!==Bt(i[r])?0:(i[r-1]+i[r])/2:i[r-1]:i[r]}Bb(e,i,o),Hb(e,o,t)}function Zn(e,t,n){return Math.max(Math.min(e,n),t)}function Vb(e,t){let n,s,i,o,r,a=Jt(e[0],t);for(n=0,s=e.length;n<s;++n)r=o,o=a,a=n<s-1&&Jt(e[n+1],t),o&&(i=e[n],r&&(i.cp1x=Zn(i.cp1x,t.left,t.right),i.cp1y=Zn(i.cp1y,t.top,t.bottom)),a&&(i.cp2x=Zn(i.cp2x,t.left,t.right),i.cp2y=Zn(i.cp2y,t.top,t.bottom)))}function Wb(e,t,n,s,i){let o,r,a,c;if(t.spanGaps&&(e=e.filter(l=>!l.skip)),t.cubicInterpolationMode==="monotone")Zb(e,i);else{let l=s?e[e.length-1]:e[0];for(o=0,r=e.length;o<r;++o)a=e[o],c=jb(l,a,e[Math.min(o+1,r-(s?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&&Vb(e,n)}function co(){return typeof window<"u"&&typeof document<"u"}function lo(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function bs(e,t,n){let s;return typeof e=="string"?(s=parseInt(e,10),e.indexOf("%")!==-1&&(s=s/100*t.parentNode[n])):s=e,s}const As=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function qb(e,t){return As(e).getPropertyValue(t)}const Ub=["top","right","bottom","left"];function we(e,t,n){const s={};n=n?"-"+n:"";for(let i=0;i<4;i++){const o=Ub[i];s[o]=parseFloat(e[t+"-"+o+n])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const Yb=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Jb(e,t){const n=e.touches,s=n&&n.length?n[0]:e,{offsetX:i,offsetY:o}=s;let r=!1,a,c;if(Yb(i,o,e.target))a=i,c=o;else{const l=t.getBoundingClientRect();a=s.clientX-l.left,c=s.clientY-l.top,r=!0}return{x:a,y:c,box:r}}function _e(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:s}=t,i=As(n),o=i.boxSizing==="border-box",r=we(i,"padding"),a=we(i,"border","width"),{x:c,y:l,box:u}=Jb(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/s),y:Math.round((l-d)/p*n.height/s)}}function Xb(e,t,n){let s,i;if(t===void 0||n===void 0){const o=e&&lo(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const r=o.getBoundingClientRect(),a=As(o),c=we(a,"border","width"),l=we(a,"padding");t=r.width-l.width-c.width,n=r.height-l.height-c.height,s=bs(a.maxWidth,o,"clientWidth"),i=bs(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:s||gs,maxHeight:i||gs}}const Qt=e=>Math.round(e*10)/10;function Kb(e,t,n,s){const i=As(e),o=we(i,"margin"),r=bs(i.maxWidth,e,"clientWidth")||gs,a=bs(i.maxHeight,e,"clientHeight")||gs,c=Xb(e,t,n);let{width:l,height:u}=c;if(i.boxSizing==="content-box"){const d=we(i,"border","width"),f=we(i,"padding");l-=f.width+d.width,u-=f.height+d.height}return l=Math.max(0,l-o.width),u=Math.max(0,s?l/s:u-o.height),l=Qt(Math.min(l,r,c.maxWidth)),u=Qt(Math.min(u,a,c.maxHeight)),l&&!u&&(u=Qt(l/2)),(t!==void 0||n!==void 0)&&s&&c.height&&u>c.height&&(u=c.height,l=Qt(Math.floor(u*s))),{width:l,height:u}}function tr(e,t,n){const s=t||1,i=Qt(e.height*s),o=Qt(e.width*s);e.height=Qt(e.height),e.width=Qt(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!==s||r.height!==i||r.width!==o?(e.currentDevicePixelRatio=s,r.height=i,r.width=o,e.ctx.setTransform(s,0,0,s,0,0),!0):!1}const Gb=(function(){let e=!1;try{const t={get passive(){return e=!0,!1}};co()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e})();function er(e,t){const n=qb(e,t),s=n&&n.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function ye(e,t,n,s){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function Qb(e,t,n,s){return{x:e.x+n*(t.x-e.x),y:s==="middle"?n<.5?e.y:t.y:s==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function t_(e,t,n,s){const i={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},r=ye(e,i,n),a=ye(i,o,n),c=ye(o,t,n),l=ye(r,a,n),u=ye(a,c,n);return ye(l,u,n)}const e_=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,s){return n-s},leftForLtr(n,s){return n-s}}},n_=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Le(e,t,n){return e?e_(t,n):n_()}function Lc(e,t){let n,s;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,s=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=s)}function $c(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function Nc(e){return e==="angle"?{between:_n,compare:sb,normalize:yt}:{between:Ut,compare:(t,n)=>t-n,normalize:t=>t}}function nr({start:e,end:t,count:n,loop:s,style:i}){return{start:e%n,end:t%n,loop:s&&(t-e+1)%n===0,style:i}}function s_(e,t,n){const{property:s,start:i,end:o}=n,{between:r,normalize:a}=Nc(s),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][s]),i,o);++d)l--,u--;l%=c,u%=c}return u<l&&(u+=c),{start:l,end:u,loop:h,style:e.style}}function Fc(e,t,n){if(!n)return[e];const{property:s,start:i,end:o}=n,r=t.length,{compare:a,between:c,normalize:l}=Nc(s),{start:u,end:h,loop:d,style:f}=s_(e,t,n),p=[];let g=!1,m=null,b,x,M;const S=()=>c(i,M,b)&&a(i,M)!==0,k=()=>a(o,b)===0||c(o,M,b),C=()=>g||S(),P=()=>!g||k();for(let z=u,O=u;z<=h;++z)x=t[z%r],!x.skip&&(b=l(x[s]),b!==M&&(g=c(b,i,o),m===null&&C()&&(m=a(b,i)===0?z:O),m!==null&&P()&&(p.push(nr({start:m,end:z,loop:d,count:r,style:f})),m=null),O=z,M=b));return m!==null&&p.push(nr({start:m,end:h,loop:d,count:r,style:f})),p}function jc(e,t){const n=[],s=e.segments;for(let i=0;i<s.length;i++){const o=Fc(s[i],e.points,t);o.length&&n.push(...o)}return n}function i_(e,t,n,s){let i=0,o=t-1;if(n&&!s)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(o+=i);o>i&&e[o%t].skip;)o--;return o%=t,{start:i,end:o}}function o_(e,t,n,s){const i=e.length,o=[];let r=t,a=e[t],c;for(c=t+1;c<=n;++c){const l=e[c%i];l.skip||l.stop?a.skip||(s=!1,o.push({start:t%i,end:(c-1)%i,loop:s}),t=r=l.stop?c:null):(r=c,a.skip&&(t=c)),a=l}return r!==null&&o.push({start:t%i,end:r%i,loop:s}),o}function r_(e,t){const n=e.points,s=e.options.spanGaps,i=n.length;if(!i)return[];const o=!!e._loop,{start:r,end:a}=i_(n,i,o,s);if(s===!0)return sr(e,[{start:r,end:a,loop:o}],n,t);const c=a<r?a+i:a,l=!!e._fullLoop&&r===0&&a===i-1;return sr(e,o_(n,r,c,l),n,t)}function sr(e,t,n,s){return!s||!s.setContext||!n?t:a_(e,t,n,s)}function a_(e,t,n,s){const i=e._chart.getContext(),o=ir(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 x=a?-1:1;if(p!==g){for(p+=c;n[p%c].skip;)p-=x;for(;n[g%c].skip;)g+=x;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=ir(s.setContext(le(i,{type:"segment",p0:g,p1:b,p0DataIndex:(d-1)%c,p1DataIndex:d%c,datasetIndex:r}))),c_(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 ir(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function c_(e,t){if(!t)return!1;const n=[],s=function(i,o){return so(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,s)!==JSON.stringify(t,s)}function Vn(e,t,n){return e.options.clip?e[n]:t[n]}function l_(e,t){const{xScale:n,yScale:s}=e;return n&&s?{left:Vn(n,t,"left"),right:Vn(n,t,"right"),top:Vn(s,t,"top"),bottom:Vn(s,t,"bottom")}:t}function Bc(e,t){const n=t._clip;if(n.disabled)return!1;const s=l_(t,e.chartArea);return{left:n.left===!1?0:s.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:s.right+(n.right===!0?0:n.right),top:n.top===!1?0:s.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:s.bottom+(n.bottom===!0?0:n.bottom)}}/*!
|
|
94
|
+
*/function Bt(){}const qm=(()=>{let e=0;return()=>e++})();function N(e){return e==null}function nt(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 F(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function at(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function Ct(e,t){return at(e)?e:t}function E(e,t){return typeof e>"u"?t:e}const Um=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100:+e/t,mc=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function K(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function U(e,t,n,s){let i,o,r;if(nt(e))for(o=e.length,i=0;i<o;i++)t.call(n,e[i],i);else if(F(e))for(r=Object.keys(e),o=r.length,i=0;i<o;i++)t.call(n,e[r[i]],r[i])}function fs(e,t){let n,s,i,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,s=e.length;n<s;++n)if(i=e[n],o=t[n],i.datasetIndex!==o.datasetIndex||i.index!==o.index)return!1;return!0}function ps(e){if(nt(e))return e.map(ps);if(F(e)){const t=Object.create(null),n=Object.keys(e),s=n.length;let i=0;for(;i<s;++i)t[n[i]]=ps(e[n[i]]);return t}return e}function bc(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function Ym(e,t,n,s){if(!bc(e))return;const i=t[e],o=n[e];F(i)&&F(o)?mn(i,o,s):t[e]=ps(o)}function mn(e,t,n){const s=nt(t)?t:[t],i=s.length;if(!F(e))return e;n=n||{};const o=n.merger||Ym;let r;for(let a=0;a<i;++a){if(r=s[a],!F(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 an(e,t){return mn(e,t,{merger:Jm})}function Jm(e,t,n){if(!bc(e))return;const s=t[e],i=n[e];F(s)&&F(i)?an(s,i):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=ps(i))}const jo={"":e=>e,x:e=>e.x,y:e=>e.y};function Km(e){const t=e.split("."),n=[];let s="";for(const i of t)s+=i,s.endsWith("\\")?s=s.slice(0,-1)+".":(n.push(s),s="");return n}function Xm(e){const t=Km(e);return n=>{for(const s of t){if(s==="")break;n=n&&n[s]}return n}}function oe(e,t){return(jo[t]||(jo[t]=Xm(t)))(e)}function Qi(e){return e.charAt(0).toUpperCase()+e.slice(1)}const bn=e=>typeof e<"u",re=e=>typeof e=="function",Bo=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function Gm(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const Z=Math.PI,G=2*Z,Qm=G+Z,gs=Number.POSITIVE_INFINITY,tb=Z/180,lt=Z/2,fe=Z/4,Zo=Z*2/3,Gt=Math.log10,jt=Math.sign;function cn(e,t,n){return Math.abs(e-t)<n}function Vo(e){const t=Math.round(e);e=cn(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Gt(e))),s=e/n;return(s<=1?1:s<=2?2:s<=5?5:10)*n}function eb(e){const t=[],n=Math.sqrt(e);let s;for(s=1;s<n;s++)e%s===0&&(t.push(s),t.push(e/s));return n===(n|0)&&t.push(n),t.sort((i,o)=>i-o).pop(),t}function nb(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function He(e){return!nb(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function sb(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function _c(e,t,n){let s,i,o;for(s=0,i=e.length;s<i;s++)o=e[s][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function Lt(e){return e*(Z/180)}function to(e){return e*(180/Z)}function Wo(e){if(!at(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function yc(e,t){const n=t.x-e.x,s=t.y-e.y,i=Math.sqrt(n*n+s*s);let o=Math.atan2(s,n);return o<-.5*Z&&(o+=G),{angle:o,distance:i}}function ii(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function ib(e,t){return(e-t+Qm)%G-Z}function yt(e){return(e%G+G)%G}function _n(e,t,n,s){const i=yt(e),o=yt(t),r=yt(n),a=yt(o-i),c=yt(r-i),l=yt(i-o),u=yt(i-r);return i===o||i===r||s&&o===r||a>c&&l<u}function ft(e,t,n){return Math.max(t,Math.min(n,e))}function ob(e){return ft(e,-32768,32767)}function Ut(e,t,n,s=1e-6){return e>=Math.min(t,n)-s&&e<=Math.max(t,n)+s}function eo(e,t,n){n=n||(r=>e[r]<t);let s=e.length-1,i=0,o;for(;s-i>1;)o=i+s>>1,n(o)?i=o:s=o;return{lo:i,hi:s}}const Yt=(e,t,n,s)=>eo(e,n,s?i=>{const o=e[i][t];return o<n||o===n&&e[i+1][t]===n}:i=>e[i][t]<n),rb=(e,t,n)=>eo(e,n,s=>e[s][t]>=n);function ab(e,t,n){let s=0,i=e.length;for(;s<i&&e[s]<t;)s++;for(;i>s&&e[i-1]>n;)i--;return s>0||i<e.length?e.slice(s,i):e}const xc=["push","pop","shift","splice","unshift"];function cb(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),xc.forEach(n=>{const s="_onData"+Qi(n),i=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const r=i.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[s]=="function"&&a[s](...o)}),r}})})}function qo(e,t){const n=e._chartjs;if(!n)return;const s=n.listeners,i=s.indexOf(t);i!==-1&&s.splice(i,1),!(s.length>0)&&(xc.forEach(o=>{delete e[o]}),delete e._chartjs)}function vc(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const kc=(function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame})();function wc(e,t){let n=[],s=!1;return function(...i){n=i,s||(s=!0,kc.call(window,()=>{s=!1,e.apply(t,n)}))}}function lb(e,t){let n;return function(...s){return t?(clearTimeout(n),n=setTimeout(e,t,s)):e.apply(this,s),t}}const no=e=>e==="start"?"left":e==="end"?"right":"center",_t=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,ub=(e,t,n,s)=>e===(s?"left":"right")?n:e==="center"?(t+n)/2:t;function Sc(e,t,n){const s=t.length;let i=0,o=s;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(i=Math.min(Yt(c,u,h).lo,n?s:Yt(t,u,r.getPixelForValue(h)).lo),l){const g=c.slice(0,i+1).reverse().findIndex(m=>!N(m[a.axis]));i-=Math.max(0,g)}i=ft(i,0,s-1)}if(p){let g=Math.max(Yt(c,r.axis,d,!0).hi+1,n?0:Yt(t,u,r.getPixelForValue(d),!0).hi+1);if(l){const m=c.slice(g-1).findIndex(b=>!N(b[a.axis]));g+=Math.max(0,m)}o=ft(g,i,s)-i}else o=s-i}return{start:i,count:o}}function Mc(e){const{xScale:t,yScale:n,_scaleRanges:s}=e,i={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!s)return e._scaleRanges=i,!0;const o=s.xmin!==t.min||s.xmax!==t.max||s.ymin!==n.min||s.ymax!==n.max;return Object.assign(s,i),o}const Bn=e=>e===0||e===1,Uo=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*G/n)),Yo=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*G/n)+1,ln={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*lt)+1,easeOutSine:e=>Math.sin(e*lt),easeInOutSine:e=>-.5*(Math.cos(Z*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=>Bn(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=>Bn(e)?e:Uo(e,.075,.3),easeOutElastic:e=>Bn(e)?e:Yo(e,.075,.3),easeInOutElastic(e){return Bn(e)?e:e<.5?.5*Uo(e*2,.1125,.45):.5+.5*Yo(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-ln.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?ln.easeInBounce(e*2)*.5:ln.easeOutBounce(e*2-1)*.5+.5};function so(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function Jo(e){return so(e)?e:new gn(e)}function Fs(e){return so(e)?e:new gn(e).saturate(.5).darken(.1).hexString()}const hb=["x","y","borderWidth","radius","tension"],db=["color","borderColor","backgroundColor"];function fb(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:db},numbers:{type:"number",properties:hb}}),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 pb(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const Ko=new Map;function gb(e,t){t=t||{};const n=e+JSON.stringify(t);let s=Ko.get(n);return s||(s=new Intl.NumberFormat(e,t),Ko.set(n,s)),s}function An(e,t,n){return gb(t,n).format(e)}const Pc={values(e){return nt(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const s=this.chart.options.locale;let i,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)&&(i="scientific"),o=mb(e,n)}const r=Gt(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),c={notation:i,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(c,this.options.ticks.format),An(e,s,c)},logarithmic(e,t,n){if(e===0)return"0";const s=n[t].significand||e/Math.pow(10,Math.floor(Gt(e)));return[1,2,3,5,10,15].includes(s)||t>.8*n.length?Pc.numeric.call(this,e,t,n):""}};function mb(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 zs={formatters:Pc};function bb(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:zs.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 Se=Object.create(null),oi=Object.create(null);function un(e,t){if(!t)return e;const n=t.split(".");for(let s=0,i=n.length;s<i;++s){const o=n[s];e=e[o]||(e[o]=Object.create(null))}return e}function Hs(e,t,n){return typeof t=="string"?mn(un(e,t),n):mn(un(e,""),t)}class _b{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=s=>s.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=(s,i)=>Fs(i.backgroundColor),this.hoverBorderColor=(s,i)=>Fs(i.borderColor),this.hoverColor=(s,i)=>Fs(i.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 Hs(this,t,n)}get(t){return un(this,t)}describe(t,n){return Hs(oi,t,n)}override(t,n){return Hs(Se,t,n)}route(t,n,s,i){const o=un(this,t),r=un(this,s),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const c=this[a],l=r[i];return F(c)?Object.assign({},l,c):E(c,l)},set(c){this[a]=c}}})}apply(t){t.forEach(n=>n(this))}}var st=new _b({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[fb,pb,bb]);function yb(e){return!e||N(e.size)||N(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function ms(e,t,n,s,i){let o=t[i];return o||(o=t[i]=e.measureText(i).width,n.push(i)),o>s&&(s=o),s}function xb(e,t,n,s){s=s||{};let i=s.data=s.data||{},o=s.garbageCollect=s.garbageCollect||[];s.font!==t&&(i=s.data={},o=s.garbageCollect=[],s.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&&!nt(h))r=ms(e,i,o,r,h);else if(nt(h))for(l=0,u=h.length;l<u;l++)d=h[l],d!=null&&!nt(d)&&(r=ms(e,i,o,r,d));e.restore();const f=o.length/2;if(f>n.length){for(c=0;c<f;c++)delete i[o[c]];o.splice(0,f)}return r}function pe(e,t,n){const s=e.currentDevicePixelRatio,i=n!==0?Math.max(n/2,.5):0;return Math.round((t-i)*s)/s+i}function Xo(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function ri(e,t,n,s){Tc(e,t,n,s,null)}function Tc(e,t,n,s,i){let o,r,a,c,l,u,h,d;const f=t.pointStyle,p=t.rotation,g=t.radius;let m=(p||0)*tb;if(f&&typeof f=="object"&&(o=f.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,s),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:i?e.ellipse(n,s,i/2,g,0,0,G):e.arc(n,s,g,0,G),e.closePath();break;case"triangle":u=i?i/2:g,e.moveTo(n+Math.sin(m)*u,s-Math.cos(m)*g),m+=Zo,e.lineTo(n+Math.sin(m)*u,s-Math.cos(m)*g),m+=Zo,e.lineTo(n+Math.sin(m)*u,s-Math.cos(m)*g),e.closePath();break;case"rectRounded":l=g*.516,c=g-l,r=Math.cos(m+fe)*c,h=Math.cos(m+fe)*(i?i/2-l:c),a=Math.sin(m+fe)*c,d=Math.sin(m+fe)*(i?i/2-l:c),e.arc(n-h,s-a,l,m-Z,m-lt),e.arc(n+d,s-r,l,m-lt,m),e.arc(n+h,s+a,l,m,m+lt),e.arc(n-d,s+r,l,m+lt,m+Z),e.closePath();break;case"rect":if(!p){c=Math.SQRT1_2*g,u=i?i/2:c,e.rect(n-u,s-c,2*u,2*c);break}m+=fe;case"rectRot":h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+d,s-r),e.lineTo(n+h,s+a),e.lineTo(n-d,s+r),e.closePath();break;case"crossRot":m+=fe;case"cross":h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+h,s+a),e.moveTo(n+d,s-r),e.lineTo(n-d,s+r);break;case"star":h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+h,s+a),e.moveTo(n+d,s-r),e.lineTo(n-d,s+r),m+=fe,h=Math.cos(m)*(i?i/2:g),r=Math.cos(m)*g,a=Math.sin(m)*g,d=Math.sin(m)*(i?i/2:g),e.moveTo(n-h,s-a),e.lineTo(n+h,s+a),e.moveTo(n+d,s-r),e.lineTo(n-d,s+r);break;case"line":r=i?i/2:Math.cos(m)*g,a=Math.sin(m)*g,e.moveTo(n-r,s-a),e.lineTo(n+r,s+a);break;case"dash":e.moveTo(n,s),e.lineTo(n+Math.cos(m)*(i?i/2:g),s+Math.sin(m)*g);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function Jt(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 Os(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function Rs(e){e.restore()}function vb(e,t,n,s,i){if(!t)return e.lineTo(n.x,n.y);if(i==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else i==="after"!=!!s?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function kb(e,t,n,s){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(s?t.cp1x:t.cp2x,s?t.cp1y:t.cp2y,s?n.cp2x:n.cp1x,s?n.cp2y:n.cp1y,n.x,n.y)}function wb(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),N(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 Sb(e,t,n,s,i){if(i.strikethrough||i.underline){const o=e.measureText(s),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,c=n-o.actualBoundingBoxAscent,l=n+o.actualBoundingBoxDescent,u=i.strikethrough?(c+l)/2:l;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=i.decorationWidth||2,e.moveTo(r,u),e.lineTo(a,u),e.stroke()}}function Mb(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Me(e,t,n,s,i,o={}){const r=nt(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let c,l;for(e.save(),e.font=i.string,wb(e,o),c=0;c<r.length;++c)l=r[c],o.backdrop&&Mb(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),N(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(l,n,s,o.maxWidth)),e.fillText(l,n,s,o.maxWidth),Sb(e,n,s,l,o),s+=Number(i.lineHeight);e.restore()}function yn(e,t){const{x:n,y:s,w:i,h:o,radius:r}=t;e.arc(n+r.topLeft,s+r.topLeft,r.topLeft,1.5*Z,Z,!0),e.lineTo(n,s+o-r.bottomLeft),e.arc(n+r.bottomLeft,s+o-r.bottomLeft,r.bottomLeft,Z,lt,!0),e.lineTo(n+i-r.bottomRight,s+o),e.arc(n+i-r.bottomRight,s+o-r.bottomRight,r.bottomRight,lt,0,!0),e.lineTo(n+i,s+r.topRight),e.arc(n+i-r.topRight,s+r.topRight,r.topRight,0,-lt,!0),e.lineTo(n+r.topLeft,s)}const Pb=/^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/,Tb=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function Cb(e,t){const n=(""+e).match(Pb);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 zb=e=>+e||0;function io(e,t){const n={},s=F(t),i=s?Object.keys(t):t,o=F(e)?s?r=>E(e[r],e[t[r]]):r=>e[r]:()=>e;for(const r of i)n[r]=zb(o(r));return n}function Cc(e){return io(e,{top:"y",right:"x",bottom:"y",left:"x"})}function ke(e){return io(e,["topLeft","topRight","bottomLeft","bottomRight"])}function vt(e){const t=Cc(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function dt(e,t){e=e||{},t=t||st.font;let n=E(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let s=E(e.style,t.style);s&&!(""+s).match(Tb)&&(console.warn('Invalid font style specified: "'+s+'"'),s=void 0);const i={family:E(e.family,t.family),lineHeight:Cb(E(e.lineHeight,t.lineHeight),n),size:n,style:s,weight:E(e.weight,t.weight),string:""};return i.string=yb(i),i}function en(e,t,n,s){let i,o,r;for(i=0,o=e.length;i<o;++i)if(r=e[i],r!==void 0&&r!==void 0)return r}function Ob(e,t,n){const{min:s,max:i}=e,o=mc(t,(i-s)/2),r=(a,c)=>n&&a===0?0:a+c;return{min:r(s,-Math.abs(o)),max:r(i,o)}}function le(e,t){return Object.assign(Object.create(e),t)}function oo(e,t=[""],n,s,i=()=>e[0]){const o=n||e;typeof s>"u"&&(s=Ac("_fallback",e));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:s,_getTarget:i,override:a=>oo([a,...e],t,o,s)};return new Proxy(r,{deleteProperty(a,c){return delete a[c],delete a._keys,delete e[0][c],!0},get(a,c){return Oc(a,c,()=>Nb(c,t,e,a))},getOwnPropertyDescriptor(a,c){return Reflect.getOwnPropertyDescriptor(a._scopes[0],c)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,c){return Qo(a).includes(c)},ownKeys(a){return Qo(a)},set(a,c,l){const u=a._storage||(a._storage=i());return a[c]=u[c]=l,delete a._keys,!0}})}function je(e,t,n,s){const i={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:zc(e,s),setContext:o=>je(e,o,n,s),override:o=>je(e.override(o),t,n,s)};return new Proxy(i,{deleteProperty(o,r){return delete o[r],delete e[r],!0},get(o,r,a){return Oc(o,r,()=>Ab(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 zc(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:s=t.indexable,_allKeys:i=t.allKeys}=e;return{allKeys:i,scriptable:n,indexable:s,isScriptable:re(n)?n:()=>n,isIndexable:re(s)?s:()=>s}}const Rb=(e,t)=>e?e+Qi(t):t,ro=(e,t)=>F(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function Oc(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const s=n();return e[t]=s,s}function Ab(e,t,n){const{_proxy:s,_context:i,_subProxy:o,_descriptors:r}=e;let a=s[t];return re(a)&&r.isScriptable(t)&&(a=Ib(t,a,e,n)),nt(a)&&a.length&&(a=Eb(t,a,e,r.isIndexable)),ro(t,a)&&(a=je(a,i,o&&o[t],r)),a}function Ib(e,t,n,s){const{_proxy:i,_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||s);return a.delete(e),ro(e,c)&&(c=ao(i._scopes,i,e,c)),c}function Eb(e,t,n,s){const{_proxy:i,_context:o,_subProxy:r,_descriptors:a}=n;if(typeof o.index<"u"&&s(e))return t[o.index%t.length];if(F(t[0])){const c=t,l=i._scopes.filter(u=>u!==c);t=[];for(const u of c){const h=ao(l,i,e,u);t.push(je(h,o,r&&r[e],a))}}return t}function Rc(e,t,n){return re(e)?e(t,n):e}const Db=(e,t)=>e===!0?t:typeof e=="string"?oe(t,e):void 0;function Lb(e,t,n,s,i){for(const o of t){const r=Db(n,o);if(r){e.add(r);const a=Rc(r._fallback,n,i);if(typeof a<"u"&&a!==n&&a!==s)return a}else if(r===!1&&typeof s<"u"&&n!==s)return null}return!1}function ao(e,t,n,s){const i=t._rootScopes,o=Rc(t._fallback,n,s),r=[...e,...i],a=new Set;a.add(s);let c=Go(a,r,n,o||n,s);return c===null||typeof o<"u"&&o!==n&&(c=Go(a,r,o,c,s),c===null)?!1:oo(Array.from(a),[""],i,o,()=>$b(t,n,s))}function Go(e,t,n,s,i){for(;n;)n=Lb(e,t,n,s,i);return n}function $b(e,t,n){const s=e._getTarget();t in s||(s[t]={});const i=s[t];return nt(i)&&F(n)?n:i||{}}function Nb(e,t,n,s){let i;for(const o of t)if(i=Ac(Rb(o,e),n),typeof i<"u")return ro(e,i)?ao(n,s,e,i):i}function Ac(e,t){for(const n of t){if(!n)continue;const s=n[e];if(typeof s<"u")return s}}function Qo(e){let t=e._keys;return t||(t=e._keys=Fb(e._scopes)),t}function Fb(e){const t=new Set;for(const n of e)for(const s of Object.keys(n).filter(i=>!i.startsWith("_")))t.add(s);return Array.from(t)}function Ic(e,t,n,s){const{iScale:i}=e,{key:o="r"}=this._parsing,r=new Array(s);let a,c,l,u;for(a=0,c=s;a<c;++a)l=a+n,u=t[l],r[a]={r:i.parse(oe(u,o),l)};return r}const Hb=Number.EPSILON||1e-14,Be=(e,t)=>t<e.length&&!e[t].skip&&e[t],Ec=e=>e==="x"?"y":"x";function jb(e,t,n,s){const i=e.skip?t:e,o=t,r=n.skip?t:n,a=ii(o,i),c=ii(r,o);let l=a/(a+c),u=c/(a+c);l=isNaN(l)?0:l,u=isNaN(u)?0:u;const h=s*l,d=s*u;return{previous:{x:o.x-h*(r.x-i.x),y:o.y-h*(r.y-i.y)},next:{x:o.x+d*(r.x-i.x),y:o.y+d*(r.y-i.y)}}}function Bb(e,t,n){const s=e.length;let i,o,r,a,c,l=Be(e,0);for(let u=0;u<s-1;++u)if(c=l,l=Be(e,u+1),!(!c||!l)){if(cn(t[u],0,Hb)){n[u]=n[u+1]=0;continue}i=n[u]/t[u],o=n[u+1]/t[u],a=Math.pow(i,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),n[u]=i*r*t[u],n[u+1]=o*r*t[u])}}function Zb(e,t,n="x"){const s=Ec(n),i=e.length;let o,r,a,c=Be(e,0);for(let l=0;l<i;++l){if(r=a,a=c,c=Be(e,l+1),!a)continue;const u=a[n],h=a[s];r&&(o=(u-r[n])/3,a[`cp1${n}`]=u-o,a[`cp1${s}`]=h-o*t[l]),c&&(o=(c[n]-u)/3,a[`cp2${n}`]=u+o,a[`cp2${s}`]=h+o*t[l])}}function Vb(e,t="x"){const n=Ec(t),s=e.length,i=Array(s).fill(0),o=Array(s);let r,a,c,l=Be(e,0);for(r=0;r<s;++r)if(a=c,c=l,l=Be(e,r+1),!!c){if(l){const u=l[t]-c[t];i[r]=u!==0?(l[n]-c[n])/u:0}o[r]=a?l?jt(i[r-1])!==jt(i[r])?0:(i[r-1]+i[r])/2:i[r-1]:i[r]}Bb(e,i,o),Zb(e,o,t)}function Zn(e,t,n){return Math.max(Math.min(e,n),t)}function Wb(e,t){let n,s,i,o,r,a=Jt(e[0],t);for(n=0,s=e.length;n<s;++n)r=o,o=a,a=n<s-1&&Jt(e[n+1],t),o&&(i=e[n],r&&(i.cp1x=Zn(i.cp1x,t.left,t.right),i.cp1y=Zn(i.cp1y,t.top,t.bottom)),a&&(i.cp2x=Zn(i.cp2x,t.left,t.right),i.cp2y=Zn(i.cp2y,t.top,t.bottom)))}function qb(e,t,n,s,i){let o,r,a,c;if(t.spanGaps&&(e=e.filter(l=>!l.skip)),t.cubicInterpolationMode==="monotone")Vb(e,i);else{let l=s?e[e.length-1]:e[0];for(o=0,r=e.length;o<r;++o)a=e[o],c=jb(l,a,e[Math.min(o+1,r-(s?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&&Wb(e,n)}function co(){return typeof window<"u"&&typeof document<"u"}function lo(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function bs(e,t,n){let s;return typeof e=="string"?(s=parseInt(e,10),e.indexOf("%")!==-1&&(s=s/100*t.parentNode[n])):s=e,s}const As=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function Ub(e,t){return As(e).getPropertyValue(t)}const Yb=["top","right","bottom","left"];function we(e,t,n){const s={};n=n?"-"+n:"";for(let i=0;i<4;i++){const o=Yb[i];s[o]=parseFloat(e[t+"-"+o+n])||0}return s.width=s.left+s.right,s.height=s.top+s.bottom,s}const Jb=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Kb(e,t){const n=e.touches,s=n&&n.length?n[0]:e,{offsetX:i,offsetY:o}=s;let r=!1,a,c;if(Jb(i,o,e.target))a=i,c=o;else{const l=t.getBoundingClientRect();a=s.clientX-l.left,c=s.clientY-l.top,r=!0}return{x:a,y:c,box:r}}function _e(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:s}=t,i=As(n),o=i.boxSizing==="border-box",r=we(i,"padding"),a=we(i,"border","width"),{x:c,y:l,box:u}=Kb(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/s),y:Math.round((l-d)/p*n.height/s)}}function Xb(e,t,n){let s,i;if(t===void 0||n===void 0){const o=e&&lo(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const r=o.getBoundingClientRect(),a=As(o),c=we(a,"border","width"),l=we(a,"padding");t=r.width-l.width-c.width,n=r.height-l.height-c.height,s=bs(a.maxWidth,o,"clientWidth"),i=bs(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:s||gs,maxHeight:i||gs}}const Qt=e=>Math.round(e*10)/10;function Gb(e,t,n,s){const i=As(e),o=we(i,"margin"),r=bs(i.maxWidth,e,"clientWidth")||gs,a=bs(i.maxHeight,e,"clientHeight")||gs,c=Xb(e,t,n);let{width:l,height:u}=c;if(i.boxSizing==="content-box"){const d=we(i,"border","width"),f=we(i,"padding");l-=f.width+d.width,u-=f.height+d.height}return l=Math.max(0,l-o.width),u=Math.max(0,s?l/s:u-o.height),l=Qt(Math.min(l,r,c.maxWidth)),u=Qt(Math.min(u,a,c.maxHeight)),l&&!u&&(u=Qt(l/2)),(t!==void 0||n!==void 0)&&s&&c.height&&u>c.height&&(u=c.height,l=Qt(Math.floor(u*s))),{width:l,height:u}}function tr(e,t,n){const s=t||1,i=Qt(e.height*s),o=Qt(e.width*s);e.height=Qt(e.height),e.width=Qt(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!==s||r.height!==i||r.width!==o?(e.currentDevicePixelRatio=s,r.height=i,r.width=o,e.ctx.setTransform(s,0,0,s,0,0),!0):!1}const Qb=(function(){let e=!1;try{const t={get passive(){return e=!0,!1}};co()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e})();function er(e,t){const n=Ub(e,t),s=n&&n.match(/^(\d+)(\.\d+)?px$/);return s?+s[1]:void 0}function ye(e,t,n,s){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function t_(e,t,n,s){return{x:e.x+n*(t.x-e.x),y:s==="middle"?n<.5?e.y:t.y:s==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function e_(e,t,n,s){const i={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},r=ye(e,i,n),a=ye(i,o,n),c=ye(o,t,n),l=ye(r,a,n),u=ye(a,c,n);return ye(l,u,n)}const n_=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,s){return n-s},leftForLtr(n,s){return n-s}}},s_=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Le(e,t,n){return e?n_(t,n):s_()}function Dc(e,t){let n,s;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,s=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=s)}function Lc(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function $c(e){return e==="angle"?{between:_n,compare:ib,normalize:yt}:{between:Ut,compare:(t,n)=>t-n,normalize:t=>t}}function nr({start:e,end:t,count:n,loop:s,style:i}){return{start:e%n,end:t%n,loop:s&&(t-e+1)%n===0,style:i}}function i_(e,t,n){const{property:s,start:i,end:o}=n,{between:r,normalize:a}=$c(s),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][s]),i,o);++d)l--,u--;l%=c,u%=c}return u<l&&(u+=c),{start:l,end:u,loop:h,style:e.style}}function Nc(e,t,n){if(!n)return[e];const{property:s,start:i,end:o}=n,r=t.length,{compare:a,between:c,normalize:l}=$c(s),{start:u,end:h,loop:d,style:f}=i_(e,t,n),p=[];let g=!1,m=null,b,x,M;const S=()=>c(i,M,b)&&a(i,M)!==0,k=()=>a(o,b)===0||c(o,M,b),C=()=>g||S(),T=()=>!g||k();for(let z=u,O=u;z<=h;++z)x=t[z%r],!x.skip&&(b=l(x[s]),b!==M&&(g=c(b,i,o),m===null&&C()&&(m=a(b,i)===0?z:O),m!==null&&T()&&(p.push(nr({start:m,end:z,loop:d,count:r,style:f})),m=null),O=z,M=b));return m!==null&&p.push(nr({start:m,end:h,loop:d,count:r,style:f})),p}function Fc(e,t){const n=[],s=e.segments;for(let i=0;i<s.length;i++){const o=Nc(s[i],e.points,t);o.length&&n.push(...o)}return n}function o_(e,t,n,s){let i=0,o=t-1;if(n&&!s)for(;i<t&&!e[i].skip;)i++;for(;i<t&&e[i].skip;)i++;for(i%=t,n&&(o+=i);o>i&&e[o%t].skip;)o--;return o%=t,{start:i,end:o}}function r_(e,t,n,s){const i=e.length,o=[];let r=t,a=e[t],c;for(c=t+1;c<=n;++c){const l=e[c%i];l.skip||l.stop?a.skip||(s=!1,o.push({start:t%i,end:(c-1)%i,loop:s}),t=r=l.stop?c:null):(r=c,a.skip&&(t=c)),a=l}return r!==null&&o.push({start:t%i,end:r%i,loop:s}),o}function a_(e,t){const n=e.points,s=e.options.spanGaps,i=n.length;if(!i)return[];const o=!!e._loop,{start:r,end:a}=o_(n,i,o,s);if(s===!0)return sr(e,[{start:r,end:a,loop:o}],n,t);const c=a<r?a+i:a,l=!!e._fullLoop&&r===0&&a===i-1;return sr(e,r_(n,r,c,l),n,t)}function sr(e,t,n,s){return!s||!s.setContext||!n?t:c_(e,t,n,s)}function c_(e,t,n,s){const i=e._chart.getContext(),o=ir(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 x=a?-1:1;if(p!==g){for(p+=c;n[p%c].skip;)p-=x;for(;n[g%c].skip;)g+=x;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=ir(s.setContext(le(i,{type:"segment",p0:g,p1:b,p0DataIndex:(d-1)%c,p1DataIndex:d%c,datasetIndex:r}))),l_(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 ir(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function l_(e,t){if(!t)return!1;const n=[],s=function(i,o){return so(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,s)!==JSON.stringify(t,s)}function Vn(e,t,n){return e.options.clip?e[n]:t[n]}function u_(e,t){const{xScale:n,yScale:s}=e;return n&&s?{left:Vn(n,t,"left"),right:Vn(n,t,"right"),top:Vn(s,t,"top"),bottom:Vn(s,t,"bottom")}:t}function Hc(e,t){const n=t._clip;if(n.disabled)return!1;const s=u_(t,e.chartArea);return{left:n.left===!1?0:s.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:s.right+(n.right===!0?0:n.right),top:n.top===!1?0:s.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:s.bottom+(n.bottom===!0?0:n.bottom)}}/*!
|
|
95
95
|
* Chart.js v4.5.1
|
|
96
96
|
* https://www.chartjs.org
|
|
97
97
|
* (c) 2025 Chart.js Contributors
|
|
98
98
|
* Released under the MIT License
|
|
99
|
-
*/class u_{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,s,i){const o=n.listeners[i],r=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:r,currentStep:Math.min(s-n.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=wc.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((s,i)=>{if(!s.running||!s.items.length)return;const o=s.items;let r=o.length-1,a=!1,c;for(;r>=0;--r)c=o[r],c._active?(c._total>s.duration&&(s.duration=c._total),c.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,s,t,"progress")),o.length||(s.running=!1,this._notify(i,s,t,"complete"),s.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let s=n.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,s)),s}listen(t,n,s){this._getAnims(t).listeners[n].push(s)}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((s,i)=>Math.max(s,i._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 s=n.items;let i=s.length-1;for(;i>=0;--i)s[i].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Zt=new u_;const or="transparent",h_={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const s=Jo(e||or),i=s.valid&&Jo(t||or);return i&&i.valid?i.mix(s,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class d_{constructor(t,n,s,i){const o=n[s];i=en([t.to,i,o,t.from]);const r=en([t.from,o,i]);this._active=!0,this._fn=t.fn||h_[t.type||typeof r],this._easing=ln[t.easing]||ln.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=s,this._from=r,this._to=i,this._promises=void 0}active(){return this._active}update(t,n,s){if(this._active){this._notify(!1);const i=this._target[this._prop],o=s-this._start,r=this._duration-o;this._start=s,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=en([t.to,n,i,t.from]),this._from=en([t.from,i,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,s=this._duration,i=this._prop,o=this._from,r=this._loop,a=this._to;let c;if(this._active=o!==a&&(r||n<s),!this._active){this._target[i]=a,this._notify(!0);return}if(n<0){this._target[i]=o;return}c=n/s%2,c=r&&c>1?2-c:c,c=this._easing(Math.min(1,Math.max(0,c))),this._target[i]=this._fn(o,a,c)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,s)=>{t.push({res:n,rej:s})})}_notify(t){const n=t?"res":"rej",s=this._promises||[];for(let i=0;i<s.length;i++)s[i][n]()}}class Hc{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!j(t))return;const n=Object.keys(st.animation),s=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const o=t[i];if(!j(o))return;const r={};for(const a of n)r[a]=o[a];(nt(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!s.has(a))&&s.set(a,r)})})}_animateOptions(t,n){const s=n.options,i=p_(t,s);if(!i)return[];const o=this._createAnimations(i,s);return s.$shared&&f_(t.options.$animations,s).then(()=>{t.options=s},()=>{}),o}_createAnimations(t,n){const s=this._properties,i=[],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"){i.push(...this._animateOptions(t,n));continue}const u=n[l];let h=o[l];const d=s.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 d_(d,t,l,u),i.push(h)}return i}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const s=this._createAnimations(t,n);if(s.length)return Zt.add(this._chart,s),!0}}function f_(e,t){const n=[],s=Object.keys(t);for(let i=0;i<s.length;i++){const o=e[s[i]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function p_(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 rr(e,t){const n=e&&e.options||{},s=n.reverse,i=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:s?o:i,end:s?i:o}}function g_(e,t,n){if(n===!1)return!1;const s=rr(e,n),i=rr(t,n);return{top:i.end,right:s.end,bottom:i.start,left:s.start}}function m_(e){let t,n,s,i;return j(e)?(t=e.top,n=e.right,s=e.bottom,i=e.left):t=n=s=i=e,{top:t,right:n,bottom:s,left:i,disabled:e===!1}}function Zc(e,t){const n=[],s=e._getSortedDatasetMetas(t);let i,o;for(i=0,o=s.length;i<o;++i)n.push(s[i].index);return n}function ar(e,t,n,s={}){const i=e.keys,o=s.mode==="single";let r,a,c,l;if(t===null)return;let u=!1;for(r=0,a=i.length;r<a;++r){if(c=+i[r],c===n){if(u=!0,s.all)continue;break}l=e.values[c],rt(l)&&(o||t===0||Bt(t)===Bt(l))&&(t+=l)}return!u&&!s.all?0:t}function b_(e,t){const{iScale:n,vScale:s}=t,i=n.axis==="x"?"x":"y",o=s.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]={[i]:u,[o]:e[u]};return a}function Bs(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function __(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function y_(e){const{min:t,max:n,minDefined:s,maxDefined:i}=e.getUserBounds();return{min:s?t:Number.NEGATIVE_INFINITY,max:i?n:Number.POSITIVE_INFINITY}}function x_(e,t,n){const s=e[t]||(e[t]={});return s[n]||(s[n]={})}function cr(e,t,n,s){for(const i of t.getMatchingVisibleMetas(s).reverse()){const o=e[i.index];if(n&&o>0||!n&&o<0)return i.index}return null}function lr(e,t){const{chart:n,_cachedMeta:s}=e,i=n._stacks||(n._stacks={}),{iScale:o,vScale:r,index:a}=s,c=o.axis,l=r.axis,u=__(o,r,s),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]=x_(i,u,g),d[a]=m,d._top=cr(d,r,!0,s.type),d._bottom=cr(d,r,!1,s.type);const x=d._visualValues||(d._visualValues={});x[a]=m}}function Hs(e,t){const n=e.scales;return Object.keys(n).filter(s=>n[s].axis===t).shift()}function v_(e,t){return le(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function k_(e,t,n){return le(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Ye(e,t){const n=e.controller.index,s=e.vScale&&e.vScale.axis;if(s){t=t||e._parsed;for(const i of t){const o=i._stacks;if(!o||o[s]===void 0||o[s][n]===void 0)return;delete o[s][n],o[s]._visualValues!==void 0&&o[s]._visualValues[n]!==void 0&&delete o[s]._visualValues[n]}}}const Zs=e=>e==="reset"||e==="none",ur=(e,t)=>t?e:Object.assign({},e),w_=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Zc(n,!0),values:null};class $t{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=Bs(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&&Ye(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,s=this.getDataset(),i=(h,d,f,p)=>h==="x"?d:h==="r"?p:f,o=n.xAxisID=D(s.xAxisID,Hs(t,"x")),r=n.yAxisID=D(s.yAxisID,Hs(t,"y")),a=n.rAxisID=D(s.rAxisID,Hs(t,"r")),c=n.indexAxis,l=n.iAxisID=i(c,o,r,a),u=n.vAxisID=i(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&&qo(this._data,this),t._stacked&&Ye(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),s=this._data;if(j(n)){const i=this._cachedMeta;this._data=b_(n,i)}else if(s!==n){if(s){qo(s,this);const i=this._cachedMeta;Ye(i),i._parsed=[]}n&&Object.isExtensible(n)&&ab(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,s=this.getDataset();let i=!1;this._dataCheck();const o=n._stacked;n._stacked=Bs(n.vScale,n),n.stack!==s.stack&&(i=!0,Ye(n),n.stack=s.stack),this._resyncElements(t),(i||o!==n._stacked)&&(lr(this,n._parsed),n._stacked=Bs(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),s=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(s,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:s,_data:i}=this,{iScale:o,_stacked:r}=s,a=o.axis;let c=t===0&&n===i.length?!0:s._sorted,l=t>0&&s._parsed[t-1],u,h,d;if(this._parsing===!1)s._parsed=i,s._sorted=!0,d=i;else{nt(i[t])?d=this.parseArrayData(s,i,t,n):j(i[t])?d=this.parseObjectData(s,i,t,n):d=this.parsePrimitiveData(s,i,t,n);const f=()=>h[a]===null||l&&h[a]<l[a];for(u=0;u<n;++u)s._parsed[u+t]=h=d[u],c&&(f()&&(c=!1),l=h);s._sorted=c}r&&lr(this,d)}parsePrimitiveData(t,n,s,i){const{iScale:o,vScale:r}=t,a=o.axis,c=r.axis,l=o.getLabels(),u=o===r,h=new Array(i);let d,f,p;for(d=0,f=i;d<f;++d)p=d+s,h[d]={[a]:u||o.parse(l[p],p),[c]:r.parse(n[p],p)};return h}parseArrayData(t,n,s,i){const{xScale:o,yScale:r}=t,a=new Array(i);let c,l,u,h;for(c=0,l=i;c<l;++c)u=c+s,h=n[u],a[c]={x:o.parse(h[0],u),y:r.parse(h[1],u)};return a}parseObjectData(t,n,s,i){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:c="y"}=this._parsing,l=new Array(i);let u,h,d,f;for(u=0,h=i;u<h;++u)d=u+s,f=n[d],l[u]={x:o.parse(oe(f,a),d),y:r.parse(oe(f,c),d)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,s){const i=this.chart,o=this._cachedMeta,r=n[t.axis],a={keys:Zc(i,!0),values:n._stacks[t.axis]._visualValues};return ar(a,r,o.index,{mode:s})}updateRangeFromParsed(t,n,s,i){const o=s[n.axis];let r=o===null?NaN:o;const a=i&&s._stacks[n.axis];i&&a&&(i.values=a,r=ar(i,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,n){const s=this._cachedMeta,i=s._parsed,o=s._sorted&&t===s.iScale,r=i.length,a=this._getOtherScale(t),c=w_(n,s,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:h}=y_(a);let d,f;function p(){f=i[d];const g=f[a.axis];return!rt(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,s=[];let i,o,r;for(i=0,o=n.length;i<o;++i)r=n[i][t.axis],rt(r)&&s.push(r);return s}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,s=n.iScale,i=n.vScale,o=this.getParsed(t);return{label:s?""+s.getLabelForValue(o[s.axis]):"",value:i?""+i.getLabelForValue(o[i.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=m_(D(this.options.clip,g_(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,s=this._cachedMeta,i=s.data||[],o=n.chartArea,r=[],a=this._drawStart||0,c=this._drawCount||i.length-a,l=this.options.drawActiveElementsOnTop;let u;for(s.dataset&&s.dataset.draw(t,o,a,c),u=a;u<a+c;++u){const h=i[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 s=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(s):this.resolveDataElementOptions(t||0,s)}getContext(t,n,s){const i=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=k_(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=i.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=v_(this.chart.getContext(),this.index)),o.dataset=i,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=s,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",s){const i=n==="active",o=this._cachedDataOpts,r=t+"-"+n,a=o[r],c=this.enableOptionSharing&&bn(s);if(a)return ur(a,c);const l=this.chart.config,u=l.datasetElementScopeKeys(this._type,t),h=i?[`${t}Hover`,"hover",t,""]:[t,""],d=l.getOptionScopes(this.getDataset(),u),f=Object.keys(st.elements[t]),p=()=>this.getContext(s,i,n),g=l.resolveNamedOptions(d,f,p,h);return g.$shared&&(g.$shared=c,o[r]=Object.freeze(ur(g,c))),g}_resolveAnimations(t,n,s){const i=this.chart,o=this._cachedDataOpts,r=`animation-${n}`,a=o[r];if(a)return a;let c;if(i.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,s,n))}const l=new Hc(i,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||Zs(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const s=this.resolveDataElementOptions(t,n),i=this._sharedOptions,o=this.getSharedOptions(s),r=this.includeOptions(n,o)||o!==i;return this.updateSharedOptions(o,n,s),{sharedOptions:o,includeOptions:r}}updateElement(t,n,s,i){Zs(i)?Object.assign(t,s):this._resolveAnimations(n,i).update(t,s)}updateSharedOptions(t,n,s){t&&!Zs(n)&&this._resolveAnimations(void 0,n).update(t,s)}_setStyle(t,n,s,i){t.active=i;const o=this.getStyle(n,i);this._resolveAnimations(n,s,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,n,s){this._setStyle(t,s,"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,s=this._cachedMeta.data;for(const[a,c,l]of this._syncList)this[a](c,l);this._syncList=[];const i=s.length,o=n.length,r=Math.min(o,i);r&&this.parse(0,r),o>i?this._insertElements(i,o-i,t):o<i&&this._removeElements(o,i-o)}_insertElements(t,n,s=!0){const i=this._cachedMeta,o=i.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(i._parsed),this.parse(t,n),s&&this.updateElements(o,t,n,"reset")}updateElements(t,n,s,i){}_removeElements(t,n){const s=this._cachedMeta;if(this._parsing){const i=s._parsed.splice(t,n);s._stacked&&Ye(s,i)}s.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,s,i]=t;this[n](s,i)}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 s=arguments.length-2;s&&this._sync(["_insertElements",t,s])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}T($t,"defaults",{}),T($t,"datasetElementType",null),T($t,"dataElementType",null);function S_(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let s=[];for(let i=0,o=n.length;i<o;i++)s=s.concat(n[i].controller.getAllParsedValues(e));e._cache.$bar=kc(s.sort((i,o)=>i-o))}return e._cache.$bar}function M_(e){const t=e.iScale,n=S_(t,e.type);let s=t._length,i,o,r,a;const c=()=>{r===32767||r===-32768||(bn(a)&&(s=Math.min(s,Math.abs(r-a)||s)),a=r)};for(i=0,o=n.length;i<o;++i)r=t.getPixelForValue(n[i]),c();for(a=void 0,i=0,o=t.ticks.length;i<o;++i)r=t.getPixelForTick(i),c();return s}function P_(e,t,n,s){const i=n.barThickness;let o,r;return N(i)?(o=t.min*n.categoryPercentage,r=n.barPercentage):(o=i*s,r=1),{chunk:o/s,ratio:r,start:t.pixels[e]-o/2}}function T_(e,t,n,s){const i=t.pixels,o=i[e];let r=e>0?i[e-1]:null,a=e<i.length-1?i[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/s,ratio:n.barPercentage,start:l}}function C_(e,t,n,s){const i=n.parse(e[0],s),o=n.parse(e[1],s),r=Math.min(i,o),a=Math.max(i,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:i,end:o,min:r,max:a}}function Vc(e,t,n,s){return nt(e)?C_(e,t,n,s):t[n.axis]=n.parse(e,s),t}function hr(e,t,n,s){const i=e.iScale,o=e.vScale,r=i.getLabels(),a=i===o,c=[];let l,u,h,d;for(l=n,u=n+s;l<u;++l)d=t[l],h={},h[i.axis]=a||i.parse(r[l],l),c.push(Vc(d,h,o,l));return c}function Vs(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function z_(e,t,n){return e!==0?Bt(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function O_(e){let t,n,s,i,o;return e.horizontal?(t=e.base>e.x,n="left",s="right"):(t=e.base<e.y,n="bottom",s="top"),t?(i="end",o="start"):(i="start",o="end"),{start:n,end:s,reverse:t,top:i,bottom:o}}function R_(e,t,n,s){let i=t.borderSkipped;const o={};if(!i){e.borderSkipped=o;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:r,end:a,reverse:c,top:l,bottom:u}=O_(e);i==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===s?i=l:(n._bottom||0)===s?i=u:(o[dr(u,r,a,c)]=!0,i=l)),o[dr(i,r,a,c)]=!0,e.borderSkipped=o}function dr(e,t,n,s){return s?(e=A_(e,t,n),e=fr(e,n,t)):e=fr(e,t,n),e}function A_(e,t,n){return e===t?n:e===n?t:e}function fr(e,t,n){return e==="start"?t:e==="end"?n:e}function I_(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class Qn extends $t{parsePrimitiveData(t,n,s,i){return hr(t,n,s,i)}parseArrayData(t,n,s,i){return hr(t,n,s,i)}parseObjectData(t,n,s,i){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=s,f=s+i;d<f;++d)g=n[d],p={},p[o.axis]=o.parse(oe(g,l),d),h.push(Vc(oe(g,u),p,r,d));return h}updateRangeFromParsed(t,n,s,i){super.updateRangeFromParsed(t,n,s,i);const o=s._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:s,vScale:i}=n,o=this.getParsed(t),r=o._custom,a=Vs(r)?"["+r.start+", "+r.end+"]":""+i.getLabelForValue(o[i.axis]);return{label:""+s.getLabelForValue(o[s.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,s,i){const o=i==="reset",{index:r,_cachedMeta:{vScale:a}}=this,c=a.getBasePixel(),l=a.isHorizontal(),u=this._getRuler(),{sharedOptions:h,includeOptions:d}=this._getSharedOptions(n,i);for(let f=n;f<n+s;f++){const p=this.getParsed(f),g=o||N(p[a.axis])?{base:c,head:c}:this._calculateBarValuePixels(f),m=this._calculateBarIndexPixels(f,u),b=(p._stacks||{})[a.axis],x={horizontal:l,base:g.base,enableBorderRadius:!b||Vs(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&&(x.options=h||this.resolveDataElementOptions(f,t[f].active?"active":i));const M=x.options||t[f].options;R_(x,M,b,r),I_(x,M,u.ratio),this.updateElement(t[f],f,x,i)}}_getStacks(t,n){const{iScale:s}=this._cachedMeta,i=s.getMatchingVisibleMetas(this._type).filter(u=>u.controller.options.grouped),o=s.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(n),c=a&&a[s.axis],l=u=>{const h=u._parsed.find(f=>f[s.axis]===c),d=h&&h[u.vScale.axis];if(N(d)||isNaN(d))return!0};for(const u of i)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(s=>t[s].axis===n).shift()}_getAxis(){const t={},n=this.getFirstScaleIdForIndexAxis();for(const s of this.chart.data.datasets)t[D(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,s){const i=this._getStacks(t,s),o=n!==void 0?i.indexOf(n):-1;return o===-1?i.length-1:o}_getRuler(){const t=this.options,n=this._cachedMeta,s=n.iScale,i=[];let o,r;for(o=0,r=n.data.length;o<r;++o)i.push(s.getPixelForValue(this.getParsed(o)[s.axis],o));const a=t.barThickness;return{min:a||M_(n),pixels:i,start:s._startPixel,end:s._endPixel,stackCount:this._getStackCount(),scale:s,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:s,index:i},options:{base:o,minBarLength:r}}=this,a=o||0,c=this.getParsed(t),l=c._custom,u=Vs(l);let h=c[n.axis],d=0,f=s?this.applyStack(n,c,s):h,p,g;f!==h&&(d=f-h,f=h),u&&(h=l.barStart,f=l.barEnd-l.barStart,h!==0&&Bt(h)!==Bt(l.barEnd)&&(d=0),d+=h);const m=!N(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=z_(g,n,a)*r,h===a&&(b-=g/2);const x=n.getPixelForDecimal(0),M=n.getPixelForDecimal(1),S=Math.min(x,M),k=Math.max(x,M);b=Math.max(Math.min(b,k),S),p=b+g,s&&!u&&(c._stacks[n.axis]._visualValues[i]=n.getValueForPixel(p)-n.getValueForPixel(b))}if(b===n.getPixelForValue(a)){const x=Bt(g)*n.getLineWidthForValue(a)/2;b+=x,g-=x}return{size:g,base:b,head:p,center:p+g/2}}_calculateBarIndexPixels(t,n){const s=n.scale,i=this.options,o=i.skipNull,r=D(i.maxBarThickness,1/0);let a,c;const l=this._getAxisCount();if(n.grouped){const u=o?this._getStackCount(t):n.stackCount,h=i.barThickness==="flex"?T_(t,n,i,u*l):P_(t,n,i,u*l),d=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,f=this._getAxis().indexOf(D(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=s.getPixelForValue(this.getParsed(t)[s.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,s=t.data,i=s.length;let o=0;for(;o<i;++o)this.getParsed(o)[n.axis]!==null&&!s[o].hidden&&s[o].draw(this._ctx)}}T(Qn,"id","bar"),T(Qn,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),T(Qn,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});class ts extends $t{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,s,i){const o=super.parsePrimitiveData(t,n,s,i);for(let r=0;r<o.length;r++)o[r]._custom=this.resolveDataElementOptions(r+s).radius;return o}parseArrayData(t,n,s,i){const o=super.parseArrayData(t,n,s,i);for(let r=0;r<o.length;r++){const a=n[s+r];o[r]._custom=D(a[2],this.resolveDataElementOptions(r+s).radius)}return o}parseObjectData(t,n,s,i){const o=super.parseObjectData(t,n,s,i);for(let r=0;r<o.length;r++){const a=n[s+r];o[r]._custom=D(a&&a.r&&+a.r,this.resolveDataElementOptions(r+s).radius)}return o}getMaxOverflow(){const t=this._cachedMeta.data;let n=0;for(let s=t.length-1;s>=0;--s)n=Math.max(n,t[s].size(this.resolveDataElementOptions(s))/2);return n>0&&n}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:i,yScale:o}=n,r=this.getParsed(t),a=i.getLabelForValue(r.x),c=o.getLabelForValue(r.y),l=r._custom;return{label:s[t]||"",value:"("+a+", "+c+(l?", "+l:"")+")"}}update(t){const n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,s,i){const o=i==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:c,includeOptions:l}=this._getSharedOptions(n,i),u=r.axis,h=a.axis;for(let d=n;d<n+s;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":i),o&&(g.options.radius=0)),this.updateElement(f,d,g,i)}}resolveDataElementOptions(t,n){const s=this.getParsed(t);let i=super.resolveDataElementOptions(t,n);i.$shared&&(i=Object.assign({},i,{$shared:!1}));const o=i.radius;return n!=="active"&&(i.radius=0),i.radius+=D(s&&s._custom,o),i}}T(ts,"id","bubble"),T(ts,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),T(ts,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});function D_(e,t,n){let s=1,i=1,o=0,r=0;if(t<G){const a=e,c=a+t,l=Math.cos(a),u=Math.sin(a),h=Math.cos(c),d=Math.sin(c),f=(M,S,k)=>_n(M,a,c,!0)?1:Math.max(S,S*n,k,k*n),p=(M,S,k)=>_n(M,a,c,!0)?-1:Math.min(S,S*n,k,k*n),g=f(0,l,h),m=f(lt,u,d),b=p(Z,l,h),x=p(Z+lt,u,d);s=(g-b)/2,i=(m-x)/2,o=-(g+b)/2,r=-(m+x)/2}return{ratioX:s,ratioY:i,offsetX:o,offsetY:r}}class xe extends $t{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 s=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=s;else{let o=c=>+s[c];if(j(s[t])){const{key:c="value"}=this._parsing;o=l=>+oe(s[l],c)}let r,a;for(r=t,a=t+n;r<a;++r)i._parsed[r]=o(r)}}_getRotation(){return Lt(this.options.rotation-90)}_getCircumference(){return Lt(this.options.circumference)}_getRotationExtents(){let t=G,n=-G;for(let s=0;s<this.chart.data.datasets.length;++s)if(this.chart.isDatasetVisible(s)&&this.chart.getDatasetMeta(s).type===this._type){const i=this.chart.getDatasetMeta(s).controller,o=i._getRotation(),r=i._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:s}=n,i=this._cachedMeta,o=i.data,r=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(s.width,s.height)-r)/2,0),c=Math.min(qm(this.options.cutout,a),1),l=this._getRingWeight(this.index),{circumference:u,rotation:h}=this._getRotationExtents(),{ratioX:d,ratioY:f,offsetX:p,offsetY:g}=D_(h,u,c),m=(s.width-r)/d,b=(s.height-r)/f,x=Math.max(Math.min(m,b)/2,0),M=bc(this.options.radius,x),S=Math.max(M*c,0),k=(M-S)/this._getVisibleDatasetWeightTotal();this.offsetX=p*M,this.offsetY=g*M,i.total=this.calculateTotal(),this.outerRadius=M-k*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-k*l,0),this.updateElements(o,0,o.length,t)}_circumference(t,n){const s=this.options,i=this._cachedMeta,o=this._getCircumference();return n&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*o/G)}updateElements(t,n,s,i){const o=i==="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,i);let b=this._getRotation(),x;for(x=0;x<n;++x)b+=this._circumference(x,o);for(x=n;x<n+s;++x){const M=this._circumference(x,o),S=t[x],k={x:u+this.offsetX,y:h+this.offsetY,startAngle:b,endAngle:b+M,circumference:M,outerRadius:p,innerRadius:f};m&&(k.options=g||this.resolveDataElementOptions(x,S.active?"active":i)),b+=M,this.updateElement(S,x,k,i)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let s=0,i;for(i=0;i<n.length;i++){const o=t._parsed[i];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(i)&&!n[i].hidden&&(s+=Math.abs(o))}return s}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?G*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart,i=s.data.labels||[],o=An(n._parsed[t],s.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let n=0;const s=this.chart;let i,o,r,a,c;if(!t){for(i=0,o=s.data.datasets.length;i<o;++i)if(s.isDatasetVisible(i)){r=s.getDatasetMeta(i),t=r.data,a=r.controller;break}}if(!t)return 0;for(i=0,o=t.length;i<o;++i)c=a.resolveDataElementOptions(i),c.borderAlign!=="inner"&&(n=Math.max(n,c.borderWidth||0,c.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let s=0,i=t.length;s<i;++s){const o=this.resolveDataElementOptions(s);n=Math.max(n,o.offset||0,o.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let s=0;s<t;++s)this.chart.isDatasetVisible(s)&&(n+=this._getRingWeight(s));return n}_getRingWeight(t){return Math.max(D(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}T(xe,"id","doughnut"),T(xe,"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"}),T(xe,"descriptors",{_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),T(xe,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data,{labels:{pointStyle:s,textAlign:i,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:i,pointStyle:s,borderRadius:r&&(a||h.borderRadius),index:l}}):[]}},onClick(t,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}}});class es extends $t{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:s,data:i=[],_dataset:o}=n,r=this.chart._animationsDisabled;let{start:a,count:c}=Mc(n,i,r);this._drawStart=a,this._drawCount=c,Pc(n)&&(a=0,c=i.length),s._chart=this.chart,s._datasetIndex=this.index,s._decimated=!!o._decimated,s.points=i;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(s,void 0,{animated:!r,options:l},t),this.updateElements(i,a,c,t)}updateElements(t,n,s,i){const o=i==="reset",{iScale:r,vScale:a,_stacked:c,_dataset:l}=this._cachedMeta,{sharedOptions:u,includeOptions:h}=this._getSharedOptions(n,i),d=r.axis,f=a.axis,{spanGaps:p,segment:g}=this.options,m=je(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||i==="none",x=n+s,M=t.length;let S=n>0&&this.getParsed(n-1);for(let k=0;k<M;++k){const C=t[k],P=b?C:{};if(k<n||k>=x){P.skip=!0;continue}const z=this.getParsed(k),O=N(z[f]),E=P[d]=r.getPixelForValue(z[d],k),L=P[f]=o||O?a.getBasePixel():a.getPixelForValue(c?this.applyStack(a,z,c):z[f],k);P.skip=isNaN(E)||isNaN(L)||O,P.stop=k>0&&Math.abs(z[d]-S[d])>m,g&&(P.parsed=z,P.raw=l.data[k]),h&&(P.options=u||this.resolveDataElementOptions(k,C.active?"active":i)),b||this.updateElement(C,k,P,i),S=z}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,s=n.options&&n.options.borderWidth||0,i=t.data||[];if(!i.length)return s;const o=i[0].size(this.resolveDataElementOptions(0)),r=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(s,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}T(es,"id","line"),T(es,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),T(es,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class hn extends $t{constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart,i=s.data.labels||[],o=An(n._parsed[t].r,s.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,n,s,i){return Dc.bind(this)(t,n,s,i)}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((s,i)=>{const o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(o<n.min&&(n.min=o),o>n.max&&(n.max=o))}),n}_updateRadius(){const t=this.chart,n=t.chartArea,s=t.options,i=Math.min(n.right-n.left,n.bottom-n.top),o=Math.max(i/2,0),r=Math.max(s.cutoutPercentage?o/100*s.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,s,i){const o=i==="reset",r=this.chart,c=r.options.animation,l=this._cachedMeta.rScale,u=l.xCenter,h=l.yCenter,d=l.getIndexAngle(0)-.5*Z;let f=d,p;const g=360/this.countVisibleElements();for(p=0;p<n;++p)f+=this._computeAngle(p,i,g);for(p=n;p<n+s;p++){const m=t[p];let b=f,x=f+this._computeAngle(p,i,g),M=r.getDataVisibility(p)?l.getDistanceFromCenterForValue(this.getParsed(p).r):0;f=x,o&&(c.animateScale&&(M=0),c.animateRotate&&(b=x=d));const S={x:u,y:h,innerRadius:0,outerRadius:M,startAngle:b,endAngle:x,options:this.resolveDataElementOptions(p,m.active?"active":i)};this.updateElement(m,p,S,i)}}countVisibleElements(){const t=this._cachedMeta;let n=0;return t.data.forEach((s,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&n++}),n}_computeAngle(t,n,s){return this.chart.getDataVisibility(t)?Lt(this.resolveDataElementOptions(t,n).angle||s):0}}T(hn,"id","polarArea"),T(hn,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),T(hn,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:s,color:i}}=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:i,lineWidth:c.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class ai extends xe{}T(ai,"id","pie"),T(ai,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class ns extends $t{getLabelAndValue(t){const n=this._cachedMeta.vScale,s=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(s[n.axis])}}parseObjectData(t,n,s,i){return Dc.bind(this)(t,n,s,i)}update(t){const n=this._cachedMeta,s=n.dataset,i=n.data||[],o=n.iScale.getLabels();if(s.points=i,t!=="resize"){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===i.length,options:r};this.updateElement(s,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,n,s,i){const o=this._cachedMeta.rScale,r=i==="reset";for(let a=n;a<n+s;a++){const c=t[a],l=this.resolveDataElementOptions(a,c.active?"active":i),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,i)}}}T(ns,"id","radar"),T(ns,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),T(ns,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});class ss extends $t{getLabelAndValue(t){const n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:i,yScale:o}=n,r=this.getParsed(t),a=i.getLabelForValue(r.x),c=o.getLabelForValue(r.y);return{label:s[t]||"",value:"("+a+", "+c+")"}}update(t){const n=this._cachedMeta,{data:s=[]}=n,i=this.chart._animationsDisabled;let{start:o,count:r}=Mc(n,s,i);if(this._drawStart=o,this._drawCount=r,Pc(n)&&(o=0,r=s.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=s;const l=this.resolveDatasetElementOptions(t);l.segment=this.options.segment,this.updateElement(a,void 0,{animated:!i,options:l},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(s,o,r,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,s,i){const o=i==="reset",{iScale:r,vScale:a,_stacked:c,_dataset:l}=this._cachedMeta,u=this.resolveDataElementOptions(n,i),h=this.getSharedOptions(u),d=this.includeOptions(i,h),f=r.axis,p=a.axis,{spanGaps:g,segment:m}=this.options,b=je(g)?g:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||o||i==="none";let M=n>0&&this.getParsed(n-1);for(let S=n;S<n+s;++S){const k=t[S],C=this.getParsed(S),P=x?k:{},z=N(C[p]),O=P[f]=r.getPixelForValue(C[f],S),E=P[p]=o||z?a.getBasePixel():a.getPixelForValue(c?this.applyStack(a,C,c):C[p],S);P.skip=isNaN(O)||isNaN(E)||z,P.stop=S>0&&Math.abs(C[f]-M[f])>b,m&&(P.parsed=C,P.raw=l.data[S]),d&&(P.options=h||this.resolveDataElementOptions(S,k.active?"active":i)),x||this.updateElement(k,S,P,i),M=C}this.updateSharedOptions(h,i,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 s=t.dataset,i=s.options&&s.options.borderWidth||0;if(!n.length)return i;const o=n[0].size(this.resolveDataElementOptions(0)),r=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,o,r)/2}}T(ss,"id","scatter"),T(ss,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),T(ss,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var E_=Object.freeze({__proto__:null,BarController:Qn,BubbleController:ts,DoughnutController:xe,LineController:es,PieController:ai,PolarAreaController:hn,RadarController:ns,ScatterController:ss});function ge(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class uo{constructor(t){T(this,"options");this.options=t||{}}static override(t){Object.assign(uo.prototype,t)}init(){}formats(){return ge()}parse(){return ge()}format(){return ge()}add(){return ge()}diff(){return ge()}startOf(){return ge()}endOf(){return ge()}}var L_={_date:uo};function $_(e,t,n,s){const{controller:i,data:o,_sorted:r}=e,a=i._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?ob:Yt;if(s){if(i._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}=i._cachedMeta,{_parsed:d}=e,f=d.slice(0,u.lo+1).reverse().findIndex(g=>!N(g[h.axis]));u.lo-=Math.max(0,f);const p=d.slice(u.hi).findIndex(g=>!N(g[h.axis]));u.hi+=Math.max(0,p)}return u}}return{lo:0,hi:o.length-1}}function Is(e,t,n,s,i){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}=$_(o[a],t,r,i);for(let f=h;f<=d;++f){const p=u[f];p.skip||s(p,l,f)}}}function N_(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(s,i){const o=t?Math.abs(s.x-i.x):0,r=n?Math.abs(s.y-i.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function Ws(e,t,n,s,i){const o=[];return!i&&!e.isPointInArea(t)||Is(e,n,t,function(a,c,l){!i&&!Jt(a,e.chartArea,0)||a.inRange(t.x,t.y,s)&&o.push({element:a,datasetIndex:c,index:l})},!0),o}function F_(e,t,n,s){let i=[];function o(r,a,c){const{startAngle:l,endAngle:u}=r.getProps(["startAngle","endAngle"],s),{angle:h}=xc(r,{x:t.x,y:t.y});_n(h,l,u)&&i.push({element:r,datasetIndex:a,index:c})}return Is(e,n,t,o),i}function j_(e,t,n,s,i,o){let r=[];const a=N_(n);let c=Number.POSITIVE_INFINITY;function l(u,h,d){const f=u.inRange(t.x,t.y,i);if(s&&!f)return;const p=u.getCenterPoint(i);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 Is(e,n,t,l),r}function qs(e,t,n,s,i,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!s?F_(e,t,n,i):j_(e,t,n,s,i,o)}function pr(e,t,n,s,i){const o=[],r=n==="x"?"inXRange":"inYRange";let a=!1;return Is(e,n,t,(c,l,u)=>{c[r]&&c[r](t[n],i)&&(o.push({element:c,datasetIndex:l,index:u}),a=a||c.inRange(t.x,t.y,i))}),s&&!a?[]:o}var B_={modes:{index(e,t,n,s){const i=_e(t,e),o=n.axis||"x",r=n.includeInvisible||!1,a=n.intersect?Ws(e,i,o,s,r):qs(e,i,o,!1,s,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,s){const i=_e(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;let a=n.intersect?Ws(e,i,o,s,r):qs(e,i,o,!1,s,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,s){const i=_e(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return Ws(e,i,o,s,r)},nearest(e,t,n,s){const i=_e(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return qs(e,i,o,n.intersect,s,r)},x(e,t,n,s){const i=_e(t,e);return pr(e,i,"x",n.intersect,s)},y(e,t,n,s){const i=_e(t,e);return pr(e,i,"y",n.intersect,s)}}};const Wc=["left","top","right","bottom"];function Je(e,t){return e.filter(n=>n.pos===t)}function gr(e,t){return e.filter(n=>Wc.indexOf(n.pos)===-1&&n.box.axis===t)}function Xe(e,t){return e.sort((n,s)=>{const i=t?s:n,o=t?n:s;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function H_(e){const t=[];let n,s,i,o,r,a;for(n=0,s=(e||[]).length;n<s;++n)i=e[n],{position:o,options:{stack:r,stackWeight:a=1}}=i,t.push({index:n,box:i,pos:o,horizontal:i.isHorizontal(),weight:i.weight,stack:r&&o+r,stackWeight:a});return t}function Z_(e){const t={};for(const n of e){const{stack:s,pos:i,stackWeight:o}=n;if(!s||!Wc.includes(i))continue;const r=t[s]||(t[s]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function V_(e,t){const n=Z_(e),{vBoxMaxWidth:s,hBoxMaxHeight:i}=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*s:c&&t.availableWidth,a.height=i):(a.width=s,a.height=u?u*i:c&&t.availableHeight)}return n}function W_(e){const t=H_(e),n=Xe(t.filter(l=>l.box.fullSize),!0),s=Xe(Je(t,"left"),!0),i=Xe(Je(t,"right")),o=Xe(Je(t,"top"),!0),r=Xe(Je(t,"bottom")),a=gr(t,"x"),c=gr(t,"y");return{fullSize:n,leftAndTop:s.concat(o),rightAndBottom:i.concat(c).concat(r).concat(a),chartArea:Je(t,"chartArea"),vertical:s.concat(i).concat(c),horizontal:o.concat(r).concat(a)}}function mr(e,t,n,s){return Math.max(e[n],t[n])+Math.max(e[s],t[s])}function qc(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 q_(e,t,n,s){const{pos:i,box:o}=n,r=e.maxPadding;if(!j(i)){n.size&&(e[i]-=n.size);const h=s[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[i]+=n.size}o.getPadding&&qc(r,o.getPadding());const a=Math.max(0,t.outerWidth-mr(r,e,"left","right")),c=Math.max(0,t.outerHeight-mr(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 U_(e){const t=e.maxPadding;function n(s){const i=Math.max(t[s]-e[s],0);return e[s]+=i,i}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function Y_(e,t){const n=t.maxPadding;function s(i){const o={left:0,top:0,right:0,bottom:0};return i.forEach(r=>{o[r]=Math.max(t[r],n[r])}),o}return s(e?["left","right"]:["top","bottom"])}function nn(e,t,n,s){const i=[];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,Y_(a.horizontal,t));const{same:h,other:d}=q_(t,n,a,s);l|=h&&i.length,u=u||d,c.fullSize||i.push(a)}return l&&nn(i,t,n,s)||u}function Wn(e,t,n,s,i){e.top=n,e.left=t,e.right=t+s,e.bottom=n+i,e.width=s,e.height=i}function br(e,t,n,s){const i=n.padding;let{x:o,y:r}=t;for(const a of e){const c=a.box,l=s[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;bn(l.start)&&(r=l.start),c.fullSize?Wn(c,i.left,r,n.outerWidth-i.right-i.left,d):Wn(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;bn(l.start)&&(o=l.start),c.fullSize?Wn(c,o,i.top,d,n.outerHeight-i.bottom-i.top):Wn(c,o,t.top+l.placed,d,h),l.start=o,l.placed+=h,o=c.right}}t.x=o,t.y=r}var xt={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,s){if(!e)return;const i=vt(e.options.layout.padding),o=Math.max(t-i.width,0),r=Math.max(n-i.height,0),a=W_(e.boxes),c=a.vertical,l=a.horizontal;W(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:i,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),d=Object.assign({},i);qc(d,vt(s));const f=Object.assign({maxPadding:d,w:o,h:r,x:i.left,y:i.top},i),p=V_(c.concat(l),h);nn(a.fullSize,f,h,p),nn(c,f,h,p),nn(l,f,h,p)&&nn(c,f,h,p),U_(f),br(a.leftAndTop,f,h,p),f.x+=f.w,f.y+=f.h,br(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},W(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 Uc{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,s){}removeEventListener(t,n,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,s,i){return n=Math.max(0,n||t.width),s=s||t.height,{width:n,height:Math.max(0,i?Math.floor(n/i):s)}}isAttached(t){return!0}updateConfig(t){}}class J_ extends Uc{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const is="$chartjs",X_={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},_r=e=>e===null||e==="";function K_(e,t){const n=e.style,s=e.getAttribute("height"),i=e.getAttribute("width");if(e[is]={initial:{height:s,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",_r(i)){const o=er(e,"width");o!==void 0&&(e.width=o)}if(_r(s))if(e.style.height==="")e.height=e.width/(t||2);else{const o=er(e,"height");o!==void 0&&(e.height=o)}return e}const Yc=Gb?{passive:!0}:!1;function G_(e,t,n){e&&e.addEventListener(t,n,Yc)}function Q_(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,Yc)}function ty(e,t){const n=X_[e.type]||e.type,{x:s,y:i}=_e(e,t);return{type:n,chart:t,native:e,x:s!==void 0?s:null,y:i!==void 0?i:null}}function _s(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function ey(e,t,n){const s=e.canvas,i=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||_s(a.addedNodes,s),r=r&&!_s(a.removedNodes,s);r&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function ny(e,t,n){const s=e.canvas,i=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||_s(a.removedNodes,s),r=r&&!_s(a.addedNodes,s);r&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}const xn=new Map;let yr=0;function Jc(){const e=window.devicePixelRatio;e!==yr&&(yr=e,xn.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function sy(e,t){xn.size||window.addEventListener("resize",Jc),xn.set(e,t)}function iy(e){xn.delete(e),xn.size||window.removeEventListener("resize",Jc)}function oy(e,t,n){const s=e.canvas,i=s&&lo(s);if(!i)return;const o=Sc((a,c)=>{const l=i.clientWidth;n(a,c),l<i.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(i),sy(e,o),r}function Us(e,t,n){n&&n.disconnect(),t==="resize"&&iy(e)}function ry(e,t,n){const s=e.canvas,i=Sc(o=>{e.ctx!==null&&n(ty(o,e))},e);return G_(s,t,i),i}class ay extends Uc{acquireContext(t,n){const s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?(K_(t,n),s):null}releaseContext(t){const n=t.canvas;if(!n[is])return!1;const s=n[is].initial;["height","width"].forEach(o=>{const r=s[o];N(r)?n.removeAttribute(o):n.setAttribute(o,r)});const i=s.style||{};return Object.keys(i).forEach(o=>{n.style[o]=i[o]}),n.width=n.width,delete n[is],!0}addEventListener(t,n,s){this.removeEventListener(t,n);const i=t.$proxies||(t.$proxies={}),r={attach:ey,detach:ny,resize:oy}[n]||ry;i[n]=r(t,n,s)}removeEventListener(t,n){const s=t.$proxies||(t.$proxies={}),i=s[n];if(!i)return;({attach:Us,detach:Us,resize:Us}[n]||Q_)(t,n,i),s[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,s,i){return Kb(t,n,s,i)}isAttached(t){const n=t&&lo(t);return!!(n&&n.isConnected)}}function cy(e){return!co()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?J_:ay}class Nt{constructor(){T(this,"x");T(this,"y");T(this,"active",!1);T(this,"options");T(this,"$animations")}tooltipPosition(t){const{x:n,y:s}=this.getProps(["x","y"],t);return{x:n,y:s}}hasValue(){return je(this.x)&&je(this.y)}getProps(t,n){const s=this.$animations;if(!n||!s)return this;const i={};return t.forEach(o=>{i[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),i}}T(Nt,"defaults",{}),T(Nt,"defaultRoutes");function ly(e,t){const n=e.options.ticks,s=uy(e),i=Math.min(n.maxTicksLimit||s,s),o=n.major.enabled?dy(t):[],r=o.length,a=o[0],c=o[r-1],l=[];if(r>i)return fy(t,l,o,r/i),l;const u=hy(o,t,i);if(r>0){let h,d;const f=r>1?Math.round((c-a)/(r-1)):null;for(qn(t,l,u,N(f)?0:a-f,a),h=0,d=r-1;h<d;h++)qn(t,l,u,o[h],o[h+1]);return qn(t,l,u,c,N(f)?t.length:c+f),l}return qn(t,l,u),l}function uy(e){const t=e.options.offset,n=e._tickSize(),s=e._length/n+(t?0:1),i=e._maxLength/n;return Math.floor(Math.min(s,i))}function hy(e,t,n){const s=py(e),i=t.length/n;if(!s)return Math.max(i,1);const o=tb(s);for(let r=0,a=o.length-1;r<a;r++){const c=o[r];if(c>i)return c}return Math.max(i,1)}function dy(e){const t=[];let n,s;for(n=0,s=e.length;n<s;n++)e[n].major&&t.push(n);return t}function fy(e,t,n,s){let i=0,o=n[0],r;for(s=Math.ceil(s),r=0;r<e.length;r++)r===o&&(t.push(e[r]),i++,o=n[i*s])}function qn(e,t,n,s,i){const o=D(s,0),r=Math.min(D(i,e.length),e.length);let a=0,c,l,u;for(n=Math.ceil(n),i&&(c=i-s,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 py(e){const t=e.length;let n,s;if(t<2)return!1;for(s=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==s)return!1;return s}const gy=e=>e==="left"?"right":e==="right"?"left":e,xr=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,vr=(e,t)=>Math.min(t||e,e);function kr(e,t){const n=[],s=e.length/t,i=e.length;let o=0;for(;o<i;o+=s)n.push(e[Math.floor(o)]);return n}function my(e,t,n){const s=e.ticks.length,i=Math.min(t,s-1),o=e._startPixel,r=e._endPixel,a=1e-6;let c=e.getPixelForTick(i),l;if(!(n&&(s===1?l=Math.max(c-o,r-c):t===0?l=(e.getPixelForTick(1)-c)/2:l=(c-e.getPixelForTick(i-1))/2,c+=i<t?l:-l,c<o-a||c>r+a)))return c}function by(e,t){W(e,n=>{const s=n.gc,i=s.length/2;let o;if(i>t){for(o=0;o<i;++o)delete n.data[s[o]];s.splice(0,i)}})}function Ke(e){return e.drawTicks?e.tickLength:0}function wr(e,t){if(!e.display)return 0;const n=ht(e.font,t),s=vt(e.padding);return(nt(e.text)?e.text.length:1)*n.lineHeight+s.height}function _y(e,t){return le(e,{scale:t,type:"scale"})}function yy(e,t,n){return le(e,{tick:n,index:t,type:"tick"})}function xy(e,t,n){let s=no(e);return(n&&t!=="right"||!n&&t==="right")&&(s=gy(s)),s}function vy(e,t,n,s){const{top:i,left:o,bottom:r,right:a,chart:c}=e,{chartArea:l,scales:u}=c;let h=0,d,f,p;const g=r-i,m=a-o;if(e.isHorizontal()){if(f=_t(s,o,a),j(n)){const b=Object.keys(n)[0],x=n[b];p=u[b].getPixelForValue(x)+g-t}else n==="center"?p=(l.bottom+l.top)/2+g-t:p=xr(e,n,t);d=a-o}else{if(j(n)){const b=Object.keys(n)[0],x=n[b];f=u[b].getPixelForValue(x)-m+t}else n==="center"?f=(l.left+l.right)/2-m+t:f=xr(e,n,t);p=_t(s,r,i),h=n==="left"?-lt:lt}return{titleX:f,titleY:p,maxWidth:d,rotation:h}}class Te extends Nt{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:s,_suggestedMax:i}=this;return t=Ct(t,Number.POSITIVE_INFINITY),n=Ct(n,Number.NEGATIVE_INFINITY),s=Ct(s,Number.POSITIVE_INFINITY),i=Ct(i,Number.NEGATIVE_INFINITY),{min:Ct(t,s),max:Ct(n,i),minDefined:rt(t),maxDefined:rt(n)}}getMinMax(t){let{min:n,max:s,minDefined:i,maxDefined:o}=this.getUserBounds(),r;if(i&&o)return{min:n,max:s};const a=this.getMatchingVisibleMetas();for(let c=0,l=a.length;c<l;++c)r=a[c].controller.getMinMax(this,t),i||(n=Math.min(n,r.min)),o||(s=Math.max(s,r.max));return n=o&&n>s?s:n,s=i&&n>s?n:s,{min:Ct(n,Ct(s,n)),max:Ct(s,Ct(n,s))}}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(){X(this.options.beforeUpdate,[this])}update(t,n,s){const{beginAtZero:i,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=zb(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const c=a<this.ticks.length;this._convertTicksToLabels(c?kr(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=ly(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,s;this.isHorizontal()?(n=this.left,s=this.right):(n=this.top,s=this.bottom,t=!t),this._startPixel=n,this._endPixel=s,this._reversePixels=t,this._length=s-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){X(this.options.afterUpdate,[this])}beforeSetDimensions(){X(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(){X(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),X(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){X(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let s,i,o;for(s=0,i=t.length;s<i;s++)o=t[s],o.label=X(n.callback,[o.value,s,t],this)}afterTickToLabelConversion(){X(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){X(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,s=vr(this.ticks.length,t.ticks.maxTicksLimit),i=n.minRotation||0,o=n.maxRotation;let r=i,a,c,l;if(!this._isVisible()||!n.display||i>=o||s<=1||!this.isHorizontal()){this.labelRotation=i;return}const u=this._getLabelSizes(),h=u.widest.width,d=u.highest.height,f=dt(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/s:f/(s-1),h+6>a&&(a=f/(s-(t.offset?.5:1)),c=this.maxHeight-Ke(t.grid)-n.padding-wr(t.title,this.chart.options.font),l=Math.sqrt(h*h+d*d),r=to(Math.min(Math.asin(dt((u.highest.height+6)/a,-1,1)),Math.asin(dt(c/l,-1,1))-Math.asin(dt(d/l,-1,1)))),r=Math.max(i,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){X(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){X(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:s,title:i,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const c=wr(i,n.options.font);if(a?(t.width=this.maxWidth,t.height=Ke(o)+c):(t.height=this.maxHeight,t.width=Ke(o)+c),s.display&&this.ticks.length){const{first:l,last:u,widest:h,highest:d}=this._getLabelSizes(),f=s.padding*2,p=Lt(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(a){const b=s.mirror?0:m*h.width+g*d.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{const b=s.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,s,i){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=i*t.width,f=s*n.height):(d=s*t.height,f=i*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(){X(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,s;for(n=0,s=t.length;n<s;n++)N(t[n].label)&&(t.splice(n,1),s--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let s=this.ticks;n<s.length&&(s=kr(s,n)),this._labelSizes=t=this._computeLabelSizes(s,s.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,s){const{ctx:i,_longestTextCache:o}=this,r=[],a=[],c=Math.floor(n/vr(n,s));let l=0,u=0,h,d,f,p,g,m,b,x,M,S,k;for(h=0;h<n;h+=c){if(p=t[h].label,g=this._resolveTickFontOptions(h),i.font=m=g.string,b=o[m]=o[m]||{data:{},gc:[]},x=g.lineHeight,M=S=0,!N(p)&&!nt(p))M=ms(i,b.data,b.gc,M,p),S=x;else if(nt(p))for(d=0,f=p.length;d<f;++d)k=p[d],!N(k)&&!nt(k)&&(M=ms(i,b.data,b.gc,M,k),S+=x);r.push(M),a.push(S),l=Math.max(M,l),u=Math.max(S,u)}by(o,n);const C=r.indexOf(l),P=a.indexOf(u),z=O=>({width:r[O]||0,height:a[O]||0});return{first:z(0),last:z(n-1),widest:z(C),highest:z(P),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 ib(this._alignToPixels?pe(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 s=n[t];return s.$context||(s.$context=yy(this.getContext(),t,s))}return this.$context||(this.$context=_y(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=Lt(this.labelRotation),s=Math.abs(Math.cos(n)),i=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*s>a*i?a/s:c/i:c*i<a*s?c/s:a/i}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,s=this.chart,i=this.options,{grid:o,position:r,border:a}=i,c=o.offset,l=this.isHorizontal(),h=this.ticks.length+(c?1:0),d=Ke(o),f=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,m=g/2,b=function(et){return pe(s,et,g)};let x,M,S,k,C,P,z,O,E,L,B,ft;if(r==="top")x=b(this.bottom),P=this.bottom-d,O=x-m,L=b(t.top)+m,ft=t.bottom;else if(r==="bottom")x=b(this.top),L=t.top,ft=b(t.bottom)-m,P=x+m,O=this.top+d;else if(r==="left")x=b(this.right),C=this.right-d,z=x-m,E=b(t.left)+m,B=t.right;else if(r==="right")x=b(this.left),E=t.left,B=b(t.right)-m,C=x+m,z=this.left+d;else if(n==="x"){if(r==="center")x=b((t.top+t.bottom)/2+.5);else if(j(r)){const et=Object.keys(r)[0],ct=r[et];x=b(this.chart.scales[et].getPixelForValue(ct))}L=t.top,ft=t.bottom,P=x+m,O=P+d}else if(n==="y"){if(r==="center")x=b((t.left+t.right)/2);else if(j(r)){const et=Object.keys(r)[0],ct=r[et];x=b(this.chart.scales[et].getPixelForValue(ct))}C=x-m,z=C-d,E=t.left,B=t.right}const Tt=D(i.ticks.maxTicksLimit,h),q=Math.max(1,Math.ceil(h/Tt));for(M=0;M<h;M+=q){const et=this.getContext(M),ct=o.setContext(et),Et=a.setContext(et),bt=ct.lineWidth,Ce=ct.color,Dn=Et.dash||[],ze=Et.dashOffset,qe=ct.tickWidth,ue=ct.tickColor,Ue=ct.tickBorderDash||[],he=ct.tickBorderDashOffset;S=my(this,M,c),S!==void 0&&(k=pe(s,S,bt),l?C=z=E=B=k:P=O=L=ft=k,f.push({tx1:C,ty1:P,tx2:z,ty2:O,x1:E,y1:L,x2:B,y2:ft,width:bt,color:Ce,borderDash:Dn,borderDashOffset:ze,tickWidth:qe,tickColor:ue,tickBorderDash:Ue,tickBorderDashOffset:he}))}return this._ticksLength=h,this._borderValue=x,f}_computeLabelItems(t){const n=this.axis,s=this.options,{position:i,ticks:o}=s,r=this.isHorizontal(),a=this.ticks,{align:c,crossAlign:l,padding:u,mirror:h}=o,d=Ke(s.grid),f=d+u,p=h?-u:f,g=-Lt(this.labelRotation),m=[];let b,x,M,S,k,C,P,z,O,E,L,B,ft="middle";if(i==="top")C=this.bottom-p,P=this._getXAxisLabelAlignment();else if(i==="bottom")C=this.top+p,P=this._getXAxisLabelAlignment();else if(i==="left"){const q=this._getYAxisLabelAlignment(d);P=q.textAlign,k=q.x}else if(i==="right"){const q=this._getYAxisLabelAlignment(d);P=q.textAlign,k=q.x}else if(n==="x"){if(i==="center")C=(t.top+t.bottom)/2+f;else if(j(i)){const q=Object.keys(i)[0],et=i[q];C=this.chart.scales[q].getPixelForValue(et)+f}P=this._getXAxisLabelAlignment()}else if(n==="y"){if(i==="center")k=(t.left+t.right)/2-f;else if(j(i)){const q=Object.keys(i)[0],et=i[q];k=this.chart.scales[q].getPixelForValue(et)}P=this._getYAxisLabelAlignment(d).textAlign}n==="y"&&(c==="start"?ft="top":c==="end"&&(ft="bottom"));const Tt=this._getLabelSizes();for(b=0,x=a.length;b<x;++b){M=a[b],S=M.label;const q=o.setContext(this.getContext(b));z=this.getPixelForTick(b)+o.labelOffset,O=this._resolveTickFontOptions(b),E=O.lineHeight,L=nt(S)?S.length:1;const et=L/2,ct=q.color,Et=q.textStrokeColor,bt=q.textStrokeWidth;let Ce=P;r?(k=z,P==="inner"&&(b===x-1?Ce=this.options.reverse?"left":"right":b===0?Ce=this.options.reverse?"right":"left":Ce="center"),i==="top"?l==="near"||g!==0?B=-L*E+E/2:l==="center"?B=-Tt.highest.height/2-et*E+E:B=-Tt.highest.height+E/2:l==="near"||g!==0?B=E/2:l==="center"?B=Tt.highest.height/2-et*E:B=Tt.highest.height-L*E,h&&(B*=-1),g!==0&&!q.showLabelBackdrop&&(k+=E/2*Math.sin(g))):(C=z,B=(1-L)*E/2);let Dn;if(q.showLabelBackdrop){const ze=vt(q.backdropPadding),qe=Tt.heights[b],ue=Tt.widths[b];let Ue=B-ze.top,he=0-ze.left;switch(ft){case"middle":Ue-=qe/2;break;case"bottom":Ue-=qe;break}switch(P){case"center":he-=ue/2;break;case"right":he-=ue;break;case"inner":b===x-1?he-=ue:b>0&&(he-=ue/2);break}Dn={left:he,top:Ue,width:ue+ze.width,height:qe+ze.height,color:q.backdropColor}}m.push({label:S,font:O,textOffset:B,options:{rotation:g,color:ct,strokeColor:Et,strokeWidth:bt,textAlign:Ce,textBaseline:ft,translation:[k,C],backdrop:Dn}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-Lt(this.labelRotation))return t==="top"?"left":"right";let i="center";return n.align==="start"?i="left":n.align==="end"?i="right":n.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:s,mirror:i,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,c=r.widest.width;let l,u;return n==="left"?i?(u=this.right+o,s==="near"?l="left":s==="center"?(l="center",u+=c/2):(l="right",u+=c)):(u=this.right-a,s==="near"?l="right":s==="center"?(l="center",u-=c/2):(l="left",u=this.left)):n==="right"?i?(u=this.left+o,s==="near"?l="right":s==="center"?(l="center",u-=c/2):(l="left",u-=c)):(u=this.left+a,s==="near"?l="left":s==="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:s,top:i,width:o,height:r}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(s,i,o,r),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const i=this.ticks.findIndex(o=>o.value===t);return i>=0?n.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){const n=this.options.grid,s=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(c,l,u)=>{!u.width||!u.color||(s.save(),s.lineWidth=u.width,s.strokeStyle=u.color,s.setLineDash(u.borderDash||[]),s.lineDashOffset=u.borderDashOffset,s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(l.x,l.y),s.stroke(),s.restore())};if(n.display)for(o=0,r=i.length;o<r;++o){const c=i[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:s,grid:i}}=this,o=s.setContext(this.getContext()),r=s.display?o.width:0;if(!r)return;const a=i.setContext(this.getContext(0)).lineWidth,c=this._borderValue;let l,u,h,d;this.isHorizontal()?(l=pe(t,this.left,r)-r/2,u=pe(t,this.right,a)+a/2,h=d=c):(h=pe(t,this.top,r)-r/2,d=pe(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 s=this.ctx,i=this._computeLabelArea();i&&Os(s,i);const o=this.getLabelItems(t);for(const r of o){const a=r.options,c=r.font,l=r.label,u=r.textOffset;Me(s,l,0,u,c,a)}i&&Rs(s)}drawTitle(){const{ctx:t,options:{position:n,title:s,reverse:i}}=this;if(!s.display)return;const o=ht(s.font),r=vt(s.padding),a=s.align;let c=o.lineHeight/2;n==="bottom"||n==="center"||j(n)?(c+=r.bottom,nt(s.text)&&(c+=o.lineHeight*(s.text.length-1))):c+=r.top;const{titleX:l,titleY:u,maxWidth:h,rotation:d}=vy(this,c,n,a);Me(t,s.text,0,0,o,{color:s.color,maxWidth:h,rotation:d,textAlign:xy(a,n,i),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,s=D(t.grid&&t.grid.z,-1),i=D(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==Te.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:s,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",i=[];let o,r;for(o=0,r=n.length;o<r;++o){const a=n[o];a[s]===this.id&&(!t||a.type===t)&&i.push(a)}return i}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return ht(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Un{constructor(t,n,s){this.type=t,this.scope=n,this.override=s,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 s;Sy(n)&&(s=this.register(n));const i=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in i||(i[o]=t,ky(t,r,s),this.override&&st.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const n=this.items,s=t.id,i=this.scope;s in n&&delete n[s],i&&s in st[i]&&(delete st[i][s],this.override&&delete Se[s])}}function ky(e,t,n){const s=mn(Object.create(null),[n?st.get(n):{},st.get(t),e.defaults]);st.set(t,s),e.defaultRoutes&&wy(t,e.defaultRoutes),e.descriptors&&st.describe(t,e.descriptors)}function wy(e,t){Object.keys(t).forEach(n=>{const s=n.split("."),i=s.pop(),o=[e].concat(s).join("."),r=t[n].split("."),a=r.pop(),c=r.join(".");st.route(o,i,c,a)})}function Sy(e){return"id"in e&&"defaults"in e}class My{constructor(){this.controllers=new Un($t,"datasets",!0),this.elements=new Un(Nt,"elements"),this.plugins=new Un(Object,"plugins"),this.scales=new Un(Te,"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,s){[...n].forEach(i=>{const o=s||this._getRegistryForType(i);s||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):W(i,r=>{const a=s||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,n,s){const i=Qi(t);X(s["before"+i],[],s),n[t](s),X(s["after"+i],[],s)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const s=this._typedRegistries[n];if(s.isForType(t))return s}return this.plugins}_get(t,n,s){const i=n.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+s+".");return i}}var jt=new My;class Py{constructor(){this._init=void 0}notify(t,n,s,i){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;const o=i?this._descriptors(t).filter(i):this._descriptors(t),r=this._notify(o,t,n,s);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),r}_notify(t,n,s,i){i=i||{};for(const o of t){const r=o.plugin,a=r[s],c=[n,i,o.options];if(X(a,c,r)===!1&&i.cancelable)return!1}return!0}invalidate(){N(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 s=t&&t.config,i=D(s.options&&s.options.plugins,{}),o=Ty(s);return i===!1&&!n?[]:zy(t,o,i,n)}_notifyStateChanges(t){const n=this._oldCache||[],s=this._cache,i=(o,r)=>o.filter(a=>!r.some(c=>a.plugin.id===c.plugin.id));this._notify(i(n,s),t,"stop"),this._notify(i(s,n),t,"start")}}function Ty(e){const t={},n=[],s=Object.keys(jt.plugins.items);for(let o=0;o<s.length;o++)n.push(jt.getPlugin(s[o]));const i=e.plugins||[];for(let o=0;o<i.length;o++){const r=i[o];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function Cy(e,t){return!t&&e===!1?null:e===!0?{}:e}function zy(e,{plugins:t,localIds:n},s,i){const o=[],r=e.getContext();for(const a of t){const c=a.id,l=Cy(s[c],i);l!==null&&o.push({plugin:a,options:Oy(e.config,{plugin:a,local:n[c]},l,r)})}return o}function Oy(e,{plugin:t,local:n},s,i){const o=e.pluginScopeKeys(t),r=e.getOptionScopes(s,o);return n&&t.defaults&&r.push(t.defaults),e.createResolver(r,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function ci(e,t){const n=st.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function Ry(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function Ay(e,t){return e===t?"_index_":"_value_"}function Sr(e){if(e==="x"||e==="y"||e==="r")return e}function Iy(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function li(e,...t){if(Sr(e))return e;for(const n of t){const s=n.axis||Iy(n.position)||e.length>1&&Sr(e[0].toLowerCase());if(s)return s}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Mr(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function Dy(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(s=>s.xAxisID===e||s.yAxisID===e);if(n.length)return Mr(e,"x",n[0])||Mr(e,"y",n[0])}return{}}function Ey(e,t){const n=Se[e.type]||{scales:{}},s=t.scales||{},i=ci(e.type,t),o=Object.create(null);return Object.keys(s).forEach(r=>{const a=s[r];if(!j(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=li(r,a,Dy(r,e),st.scales[a.type]),l=Ay(c,i),u=n.scales||{};o[r]=an(Object.create(null),[{axis:c},a,u[c],u[l]])}),e.data.datasets.forEach(r=>{const a=r.type||e.type,c=r.indexAxis||ci(a,t),u=(Se[a]||{}).scales||{};Object.keys(u).forEach(h=>{const d=Ry(h,c),f=r[d+"AxisID"]||d;o[f]=o[f]||Object.create(null),an(o[f],[{axis:d},s[f],u[h]])})}),Object.keys(o).forEach(r=>{const a=o[r];an(a,[st.scales[a.type],st.scale])}),o}function Xc(e){const t=e.options||(e.options={});t.plugins=D(t.plugins,{}),t.scales=Ey(e,t)}function Kc(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function Ly(e){return e=e||{},e.data=Kc(e.data),Xc(e),e}const Pr=new Map,Gc=new Set;function Yn(e,t){let n=Pr.get(e);return n||(n=t(),Pr.set(e,n),Gc.add(n)),n}const Ge=(e,t,n)=>{const s=oe(t,n);s!==void 0&&e.add(s)};class $y{constructor(t){this._config=Ly(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=Kc(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(),Xc(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Yn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return Yn(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return Yn(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,s=this.type;return Yn(`${s}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const s=this._scopeCache;let i=s.get(t);return(!i||n)&&(i=new Map,s.set(t,i)),i}getOptionScopes(t,n,s){const{options:i,type:o}=this,r=this._cachedScopes(t,s),a=r.get(n);if(a)return a;const c=new Set;n.forEach(u=>{t&&(c.add(t),u.forEach(h=>Ge(c,t,h))),u.forEach(h=>Ge(c,i,h)),u.forEach(h=>Ge(c,Se[o]||{},h)),u.forEach(h=>Ge(c,st,h)),u.forEach(h=>Ge(c,oi,h))});const l=Array.from(c);return l.length===0&&l.push(Object.create(null)),Gc.has(n)&&r.set(n,l),l}chartOptionScopes(){const{options:t,type:n}=this;return[t,Se[n]||{},st.datasets[n]||{},{type:n},st,oi]}resolveNamedOptions(t,n,s,i=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Tr(this._resolverCache,t,i);let c=r;if(Fy(r,n)){o.$shared=!1,s=re(s)?s():s;const l=this.createResolver(t,s,a);c=Be(r,s,l)}for(const l of n)o[l]=c[l];return o}createResolver(t,n,s=[""],i){const{resolver:o}=Tr(this._resolverCache,t,s);return j(n)?Be(o,n,void 0,i):o}}function Tr(e,t,n){let s=e.get(t);s||(s=new Map,e.set(t,s));const i=n.join();let o=s.get(i);return o||(o={resolver:oo(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},s.set(i,o)),o}const Ny=e=>j(e)&&Object.getOwnPropertyNames(e).some(t=>re(e[t]));function Fy(e,t){const{isScriptable:n,isIndexable:s}=Oc(e);for(const i of t){const o=n(i),r=s(i),a=(r||o)&&e[i];if(o&&(re(a)||Ny(a))||r&&nt(a))return!0}return!1}var jy="4.5.1";const By=["top","bottom","left","right","chartArea"];function Cr(e,t){return e==="top"||e==="bottom"||By.indexOf(e)===-1&&t==="x"}function zr(e,t){return function(n,s){return n[e]===s[e]?n[t]-s[t]:n[e]-s[e]}}function Or(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),X(n&&n.onComplete,[e],t)}function Hy(e){const t=e.chart,n=t.options.animation;X(n&&n.onProgress,[e],t)}function Qc(e){return co()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const os={},Rr=e=>{const t=Qc(e);return Object.values(os).filter(n=>n.canvas===t).pop()};function Zy(e,t,n){const s=Object.keys(e);for(const i of s){const o=+i;if(o>=t){const r=e[i];delete e[i],(n>0||o>t)&&(e[o+n]=r)}}}function Vy(e,t,n,s){return!n||e.type==="mouseout"?null:s?t:e}class qt{static register(...t){jt.add(...t),Ar()}static unregister(...t){jt.remove(...t),Ar()}constructor(t,n){const s=this.config=new $y(n),i=Qc(t),o=Rr(i);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=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||cy(i)),this.platform.updateConfig(s);const a=this.platform.acquireContext(i,r.aspectRatio),c=a&&a.canvas,l=c&&c.height,u=c&&c.width;if(this.id=Wm(),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 Py,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=cb(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],os[this.id]=this,!a||!c){console.error("Failed to create chart: can't acquire context from the given item");return}Zt.listen(this,"complete",Or),Zt.listen(this,"progress",Hy),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:s,height:i,_aspectRatio:o}=this;return N(t)?n&&o?o:i?s/i: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 jt}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():tr(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Ko(this.canvas,this.ctx),this}stop(){return Zt.stop(this),this}resize(t,n){Zt.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const s=this.options,i=this.canvas,o=s.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(i,t,n,o),a=s.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,tr(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),X(s.onResize,[this,r],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};W(n,(s,i)=>{s.id=i})}buildOrUpdateScales(){const t=this.options,n=t.scales,s=this.scales,i=Object.keys(s).reduce((r,a)=>(r[a]=!1,r),{});let o=[];n&&(o=o.concat(Object.keys(n).map(r=>{const a=n[r],c=li(r,a),l=c==="r",u=c==="x";return{options:a,dposition:l?"chartArea":u?"bottom":"left",dtype:l?"radialLinear":u?"category":"linear"}}))),W(o,r=>{const a=r.options,c=a.id,l=li(c,a),u=D(a.type,r.dtype);(a.position===void 0||Cr(a.position,l)!==Cr(r.dposition))&&(a.position=r.dposition),i[c]=!0;let h=null;if(c in s&&s[c].type===u)h=s[c];else{const d=jt.getScale(u);h=new d({id:c,type:u,ctx:this.ctx,chart:this}),s[h.id]=h}h.init(a,t)}),W(i,(r,a)=>{r||delete s[a]}),W(s,r=>{xt.configure(this,r,r.options),xt.addBox(this,r)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,s=t.length;if(t.sort((i,o)=>i.index-o.index),s>n){for(let i=n;i<s;++i)this._destroyDatasetMeta(i);t.splice(n,s-n)}this._sortedMetasets=t.slice(0).sort(zr("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((s,i)=>{n.filter(o=>o===s._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let s,i;for(this._removeUnreferencedMetasets(),s=0,i=n.length;s<i;s++){const o=n[s];let r=this.getDatasetMeta(s);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(s),r=this.getDatasetMeta(s)),r.type=a,r.indexAxis=o.indexAxis||ci(a,this.options),r.order=o.order||0,r.index=s,r.label=""+o.label,r.visible=this.isDatasetVisible(s),r.controller)r.controller.updateIndex(s),r.controller.linkScales();else{const c=jt.getController(a),{datasetElementType:l,dataElementType:u}=st.datasets[a];Object.assign(c,{dataElementType:jt.getElement(u),datasetElementType:l&&jt.getElement(l)}),r.controller=new c(this,s),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){W(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 s=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!s.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=!i&&o.indexOf(h)===-1;h.buildOrUpdateElements(d),r=Math.max(+h.getMaxOverflow(),r)}r=this._minPadding=s.layout.autoPadding?r:0,this._updateLayout(r),i||W(o,l=>{l.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(zr("z","_idx"));const{_active:a,_lastEvent:c}=this;c?this._eventHandler(c,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){W(this.scales,t=>{xt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),s=new Set(t.events);(!Ho(n,s)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:s,start:i,count:o}of n){const r=s==="_removeElements"?-o:o;Zy(t,i,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,s=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),i=s(0);for(let o=1;o<n;o++)if(!Ho(i,s(o)))return;return Array.from(i).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;xt.update(this,this.width,this.height,t);const n=this.chartArea,s=n.width<=0||n.height<=0;this._layers=[],W(this.boxes,i=>{s&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,s=this.data.datasets.length;n<s;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,s=this.data.datasets.length;n<s;++n)this._updateDataset(n,re(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const s=this.getDatasetMeta(t),i={meta:s,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(s.controller._update(n),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(Zt.has(this)?this.attached&&!Zt.running(this)&&Zt.start(this):(this.draw(),Or({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:s,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(s,i)}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,s=[];let i,o;for(i=0,o=n.length;i<o;++i){const r=n[i];(!t||r.visible)&&s.push(r)}return s}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,s={meta:t,index:t.index,cancelable:!0},i=Bc(this,t);this.notifyPlugins("beforeDatasetDraw",s)!==!1&&(i&&Os(n,i),t.controller.draw(),i&&Rs(n),s.cancelable=!1,this.notifyPlugins("afterDatasetDraw",s))}isPointInArea(t){return Jt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,s,i){const o=B_.modes[n];return typeof o=="function"?o(this,t,s,i):[]}getDatasetMeta(t){const n=this.data.datasets[t],s=this._metasets;let i=s.filter(o=>o&&o._dataset===n).pop();return i||(i={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},s.push(i)),i}getContext(){return this.$context||(this.$context=le(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!n.hidden}setDatasetVisibility(t,n){const s=this.getDatasetMeta(t);s.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,s){const i=s?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,i);bn(n)?(o.data[n].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),r.update(o,{visible:s}),this.update(a=>a.datasetIndex===t?i: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(),Zt.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(),Ko(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete os[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,s=(o,r)=>{n.addEventListener(this,o,r),t[o]=r},i=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};W(this.options.events,o=>s(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,s=(c,l)=>{n.addEventListener(this,c,l),t[c]=l},i=(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=()=>{i("attach",a),this.attached=!0,this.resize(),s("resize",o),s("detach",r)};r=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),s("attach",a)},n.isAttached(this.canvas)?a():r()}unbindEvents(){W(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},W(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,s){const i=s?"set":"remove";let o,r,a,c;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,c=t.length;a<c;++a){r=t[a];const l=r&&this.getDatasetMeta(r.datasetIndex).controller;l&&l[i+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],s=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}});!fs(s,n)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,n))}notifyPlugins(t,n,s){return this._plugins.notify(this,t,n,s)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,s){const i=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=s?t:o(t,n);r.length&&this.updateHoverStyle(r,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,n){const s={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},i=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,i)===!1)return;const o=this._handleEvent(t,n,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,i),(o||s.changed)&&this.render(),this}_handleEvent(t,n,s){const{_active:i=[],options:o}=this,r=n,a=this._getActiveElements(t,i,s,r),c=Km(t),l=Vy(t,this._lastEvent,s,c);s&&(this._lastEvent=null,X(o.onHover,[t,a,this],this),c&&X(o.onClick,[t,a,this],this));const u=!fs(a,i);return(u||n)&&(this._active=a,this._updateHoverStyles(a,i,n)),this._lastEvent=l,u}_getActiveElements(t,n,s,i){if(t.type==="mouseout")return[];if(!s)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}}T(qt,"defaults",st),T(qt,"instances",os),T(qt,"overrides",Se),T(qt,"registry",jt),T(qt,"version",jy),T(qt,"getChart",Rr);function Ar(){return W(qt.instances,e=>e._plugins.invalidate())}function Wy(e,t,n){const{startAngle:s,x:i,y:o,outerRadius:r,innerRadius:a,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,h=Math.min(l/r,yt(s-n));if(e.beginPath(),e.arc(i,o,r-l/2,s+h/2,n-h/2),a>0){const d=Math.min(l/a,yt(s-n));e.arc(i,o,a+l/2,n-d/2,s+d/2,!0)}else{const d=Math.min(l/2,r*yt(s-n));if(u==="round")e.arc(i,o,d,n-Z/2,s+Z/2,!0);else if(u==="bevel"){const f=2*d*d,p=-f*Math.cos(n+Z/2)+i,g=-f*Math.sin(n+Z/2)+o,m=f*Math.cos(s+Z/2)+i,b=f*Math.sin(s+Z/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 qy(e,t,n){const{startAngle:s,pixelMargin:i,x:o,y:r,outerRadius:a,innerRadius:c}=t;let l=i/a;e.beginPath(),e.arc(o,r,a,s-l,n+l),c>i?(l=i/c,e.arc(o,r,c,n+l,s-l,!0)):e.arc(o,r,i,n+lt,s-lt),e.closePath(),e.clip()}function Uy(e){return io(e,["outerStart","outerEnd","innerStart","innerEnd"])}function Yy(e,t,n,s){const i=Uy(e.options.borderRadius),o=(n-t)/2,r=Math.min(o,s*t/2),a=c=>{const l=(n-Math.min(o,c))*s/2;return dt(c,0,Math.min(o,l))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:dt(i.innerStart,0,r),innerEnd:dt(i.innerEnd,0,r)}}function Re(e,t,n,s){return{x:n+e*Math.cos(t),y:s+e*Math.sin(t)}}function ys(e,t,n,s,i,o){const{x:r,y:a,startAngle:c,pixelMargin:l,innerRadius:u}=t,h=Math.max(t.outerRadius+s+n-l,0),d=u>0?u+s+n+l:0;let f=0;const p=i-c;if(s){const q=u>0?u-s:0,et=h>0?h-s:0,ct=(q+et)/2,Et=ct!==0?p*ct/(ct+s):p;f=(p-Et)/2}const g=Math.max(.001,p*h-n/Z)/h,m=(p-g)/2,b=c+m+f,x=i-m-f,{outerStart:M,outerEnd:S,innerStart:k,innerEnd:C}=Yy(t,d,h,x-b),P=h-M,z=h-S,O=b+M/P,E=x-S/z,L=d+k,B=d+C,ft=b+k/L,Tt=x-C/B;if(e.beginPath(),o){const q=(O+E)/2;if(e.arc(r,a,h,O,q),e.arc(r,a,h,q,E),S>0){const bt=Re(z,E,r,a);e.arc(bt.x,bt.y,S,E,x+lt)}const et=Re(B,x,r,a);if(e.lineTo(et.x,et.y),C>0){const bt=Re(B,Tt,r,a);e.arc(bt.x,bt.y,C,x+lt,Tt+Math.PI)}const ct=(x-C/d+(b+k/d))/2;if(e.arc(r,a,d,x-C/d,ct,!0),e.arc(r,a,d,ct,b+k/d,!0),k>0){const bt=Re(L,ft,r,a);e.arc(bt.x,bt.y,k,ft+Math.PI,b-lt)}const Et=Re(P,b,r,a);if(e.lineTo(Et.x,Et.y),M>0){const bt=Re(P,O,r,a);e.arc(bt.x,bt.y,M,b-lt,O)}}else{e.moveTo(r,a);const q=Math.cos(O)*h+r,et=Math.sin(O)*h+a;e.lineTo(q,et);const ct=Math.cos(E)*h+r,Et=Math.sin(E)*h+a;e.lineTo(ct,Et)}e.closePath()}function Jy(e,t,n,s,i){const{fullCircles:o,startAngle:r,circumference:a}=t;let c=t.endAngle;if(o){ys(e,t,n,s,c,i);for(let l=0;l<o;++l)e.fill();isNaN(a)||(c=r+(a%G||G))}return ys(e,t,n,s,c,i),e.fill(),c}function Xy(e,t,n,s,i){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){ys(e,t,n,s,g,i);for(let m=0;m<o;++m)e.stroke();isNaN(a)||(g=r+(a%G||G))}p&&qy(e,t,g),c.selfJoin&&g-r>=Z&&f===0&&u!=="miter"&&Wy(e,t,g),o||(ys(e,t,n,s,g,i),e.stroke())}class sn extends Nt{constructor(n){super();T(this,"circumference");T(this,"endAngle");T(this,"fullCircles");T(this,"innerRadius");T(this,"outerRadius");T(this,"pixelMargin");T(this,"startAngle");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,n&&Object.assign(this,n)}inRange(n,s,i){const o=this.getProps(["x","y"],i),{angle:r,distance:a}=xc(o,{x:n,y:s}),{startAngle:c,endAngle:l,innerRadius:u,outerRadius:h,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),f=(this.options.spacing+this.options.borderWidth)/2,p=D(d,l-c),g=_n(r,c,l)&&c!==l,m=p>=G||g,b=Ut(a,u+f,h+f);return m&&b}getCenterPoint(n){const{x:s,y:i,startAngle:o,endAngle:r,innerRadius:a,outerRadius:c}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],n),{offset:l,spacing:u}=this.options,h=(o+r)/2,d=(a+c+u+l)/2;return{x:s+Math.cos(h)*d,y:i+Math.sin(h)*d}}tooltipPosition(n){return this.getCenterPoint(n)}draw(n){const{options:s,circumference:i}=this,o=(s.offset||0)/4,r=(s.spacing||0)/2,a=s.circular;if(this.pixelMargin=s.borderAlign==="inner"?.33:0,this.fullCircles=i>G?Math.floor(i/G):0,i===0||this.innerRadius<0||this.outerRadius<0)return;n.save();const c=(this.startAngle+this.endAngle)/2;n.translate(Math.cos(c)*o,Math.sin(c)*o);const l=1-Math.sin(Math.min(Z,i||0)),u=o*l;n.fillStyle=s.backgroundColor,n.strokeStyle=s.borderColor,Jy(n,this,u,r,a),Xy(n,this,u,r,a),n.restore()}}T(sn,"id","arc"),T(sn,"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}),T(sn,"defaultRoutes",{backgroundColor:"backgroundColor"}),T(sn,"descriptors",{_scriptable:!0,_indexable:n=>n!=="borderDash"});function tl(e,t,n=t){e.lineCap=D(n.borderCapStyle,t.borderCapStyle),e.setLineDash(D(n.borderDash,t.borderDash)),e.lineDashOffset=D(n.borderDashOffset,t.borderDashOffset),e.lineJoin=D(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=D(n.borderWidth,t.borderWidth),e.strokeStyle=D(n.borderColor,t.borderColor)}function Ky(e,t,n){e.lineTo(n.x,n.y)}function Gy(e){return e.stepped?xb:e.tension||e.cubicInterpolationMode==="monotone"?vb:Ky}function el(e,t,n={}){const s=e.length,{start:i=0,end:o=s-1}=n,{start:r,end:a}=t,c=Math.max(i,r),l=Math.min(o,a),u=i<r&&o<r||i>a&&o>a;return{count:s,start:c,loop:t.loop,ilen:l<c&&!u?s+l-c:l-c}}function Qy(e,t,n,s){const{points:i,options:o}=t,{count:r,start:a,loop:c,ilen:l}=el(i,n,s),u=Gy(o);let{move:h=!0,reverse:d}=s||{},f,p,g;for(f=0;f<=l;++f)p=i[(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=i[(a+(d?l:0))%r],u(e,g,p,d,o.stepped)),!!c}function tx(e,t,n,s){const i=t.points,{count:o,start:r,ilen:a}=el(i,n,s),{move:c=!0,reverse:l}=s||{};let u=0,h=0,d,f,p,g,m,b;const x=S=>(r+(l?a-S:S))%o,M=()=>{g!==m&&(e.lineTo(u,m),e.lineTo(u,g),e.lineTo(u,b))};for(c&&(f=i[x(0)],e.moveTo(f.x,f.y)),d=0;d<=a;++d){if(f=i[x(d)],f.skip)continue;const S=f.x,k=f.y,C=S|0;C===p?(k<g?g=k:k>m&&(m=k),u=(h*u+S)/++h):(M(),e.lineTo(S,k),p=C,h=0,g=m=k),b=k}M()}function ui(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?tx:Qy}function ex(e){return e.stepped?Qb:e.tension||e.cubicInterpolationMode==="monotone"?t_:ye}function nx(e,t,n,s){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,s)&&i.closePath()),tl(e,t.options),e.stroke(i)}function sx(e,t,n,s){const{segments:i,options:o}=t,r=ui(t);for(const a of i)tl(e,o,a.style),e.beginPath(),r(e,t,a,{start:n,end:n+s-1})&&e.closePath(),e.stroke()}const ix=typeof Path2D=="function";function ox(e,t,n,s){ix&&!t.options.segment?nx(e,t,n,s):sx(e,t,n,s)}class te extends Nt{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 s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){const i=s.spanGaps?this._loop:this._fullLoop;Wb(this._points,s,t,i,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=r_(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,s=t.length;return s&&n[t[s-1].end]}interpolate(t,n){const s=this.options,i=t[n],o=this.points,r=jc(this,{property:n,start:i,end:i});if(!r.length)return;const a=[],c=ex(s);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((i-f[n])/(p[n]-f[n])),m=c(f,p,g,s.stepped);m[n]=t[n],a.push(m)}return a.length===1?a[0]:a}pathSegment(t,n,s){return ui(this)(t,this,n,s)}path(t,n,s){const i=this.segments,o=ui(this);let r=this._loop;n=n||0,s=s||this.points.length-n;for(const a of i)r&=o(t,this,a,{start:n,end:n+s-1});return!!r}draw(t,n,s,i){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),ox(t,this,s,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}T(te,"id","line"),T(te,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),T(te,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),T(te,"descriptors",{_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"});function Ir(e,t,n,s){const i=e.options,{[n]:o}=e.getProps([n],s);return Math.abs(t-o)<i.radius+i.hitRadius}class rs extends Nt{constructor(n){super();T(this,"parsed");T(this,"skip");T(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,n&&Object.assign(this,n)}inRange(n,s,i){const o=this.options,{x:r,y:a}=this.getProps(["x","y"],i);return Math.pow(n-r,2)+Math.pow(s-a,2)<Math.pow(o.hitRadius+o.radius,2)}inXRange(n,s){return Ir(this,n,"x",s)}inYRange(n,s){return Ir(this,n,"y",s)}getCenterPoint(n){const{x:s,y:i}=this.getProps(["x","y"],n);return{x:s,y:i}}size(n){n=n||this.options||{};let s=n.radius||0;s=Math.max(s,s&&n.hoverRadius||0);const i=s&&n.borderWidth||0;return(s+i)*2}draw(n,s){const i=this.options;this.skip||i.radius<.1||!Jt(this,s,this.size(i)/2)||(n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.fillStyle=i.backgroundColor,ri(n,i,this.x,this.y))}getRange(){const n=this.options||{};return n.radius+n.hitRadius}}T(rs,"id","point"),T(rs,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),T(rs,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});function nl(e,t){const{x:n,y:s,base:i,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,i),c=Math.max(n,i),l=s-h,u=s+h):(h=o/2,a=n-h,c=n+h,l=Math.min(s,i),u=Math.max(s,i)),{left:a,top:l,right:c,bottom:u}}function ee(e,t,n,s){return e?0:dt(t,n,s)}function rx(e,t,n){const s=e.options.borderWidth,i=e.borderSkipped,o=zc(s);return{t:ee(i.top,o.top,0,n),r:ee(i.right,o.right,0,t),b:ee(i.bottom,o.bottom,0,n),l:ee(i.left,o.left,0,t)}}function ax(e,t,n){const{enableBorderRadius:s}=e.getProps(["enableBorderRadius"]),i=e.options.borderRadius,o=ke(i),r=Math.min(t,n),a=e.borderSkipped,c=s||j(i);return{topLeft:ee(!c||a.top||a.left,o.topLeft,0,r),topRight:ee(!c||a.top||a.right,o.topRight,0,r),bottomLeft:ee(!c||a.bottom||a.left,o.bottomLeft,0,r),bottomRight:ee(!c||a.bottom||a.right,o.bottomRight,0,r)}}function cx(e){const t=nl(e),n=t.right-t.left,s=t.bottom-t.top,i=rx(e,n/2,s/2),o=ax(e,n/2,s/2);return{outer:{x:t.left,y:t.top,w:n,h:s,radius:o},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:s-i.t-i.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,o.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(i.b,i.r))}}}}function Ys(e,t,n,s){const i=t===null,o=n===null,a=e&&!(i&&o)&&nl(e,s);return a&&(i||Ut(t,a.left,a.right))&&(o||Ut(n,a.top,a.bottom))}function lx(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function ux(e,t){e.rect(t.x,t.y,t.w,t.h)}function Js(e,t,n={}){const s=e.x!==n.x?-t:0,i=e.y!==n.y?-t:0,o=(e.x+e.w!==n.x+n.w?t:0)-s,r=(e.y+e.h!==n.y+n.h?t:0)-i;return{x:e.x+s,y:e.y+i,w:e.w+o,h:e.h+r,radius:e.radius}}class as extends Nt{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:s,backgroundColor:i}}=this,{inner:o,outer:r}=cx(this),a=lx(r.radius)?yn:ux;t.save(),(r.w!==o.w||r.h!==o.h)&&(t.beginPath(),a(t,Js(r,n,o)),t.clip(),a(t,Js(o,-n,r)),t.fillStyle=s,t.fill("evenodd")),t.beginPath(),a(t,Js(o,n)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,n,s){return Ys(this,t,n,s)}inXRange(t,n){return Ys(this,t,null,n)}inYRange(t,n){return Ys(this,null,t,n)}getCenterPoint(t){const{x:n,y:s,base:i,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(n+i)/2:n,y:o?s:(s+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}T(as,"id","bar"),T(as,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0}),T(as,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});var hx=Object.freeze({__proto__:null,ArcElement:sn,BarElement:as,LineElement:te,PointElement:rs});const hi=["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)"],Dr=hi.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function sl(e){return hi[e%hi.length]}function il(e){return Dr[e%Dr.length]}function dx(e,t){return e.borderColor=sl(t),e.backgroundColor=il(t),++t}function fx(e,t){return e.backgroundColor=e.data.map(()=>sl(t++)),t}function px(e,t){return e.backgroundColor=e.data.map(()=>il(t++)),t}function gx(e){let t=0;return(n,s)=>{const i=e.getDatasetMeta(s).controller;i instanceof xe?t=fx(n,t):i instanceof hn?t=px(n,t):i&&(t=dx(n,t))}}function Er(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function mx(e){return e&&(e.borderColor||e.backgroundColor)}function bx(){return st.borderColor!=="rgba(0,0,0,0.1)"||st.backgroundColor!=="rgba(0,0,0,0.1)"}var _x={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;const{data:{datasets:s},options:i}=e.config,{elements:o}=i,r=Er(s)||mx(i)||o&&Er(o)||bx();if(!n.forceOverride&&r)return;const a=gx(e);s.forEach(a)}};function yx(e,t,n,s,i){const o=i.samples||s;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,x;const M=Math.floor((h+1)*a)+1+t,S=Math.min(Math.floor((h+2)*a)+1,n)+t,k=S-M;for(x=M;x<S;x++)m+=e[x].x,b+=e[x].y;m/=k,b/=k;const C=Math.floor(h*a)+1+t,P=Math.min(Math.floor((h+1)*a)+1,n)+t,{x:z,y:O}=e[u];for(f=p=-1,x=C;x<P;x++)p=.5*Math.abs((z-m)*(e[x].y-O)-(z-e[x].x)*(b-O)),p>f&&(f=p,d=e[x],g=x);r[c++]=d,u=g}return r[c++]=e[l],r}function xx(e,t,n,s){let i=0,o=0,r,a,c,l,u,h,d,f,p,g;const m=[],b=t+n-1,x=e[t].x,S=e[b].x-x;for(r=t;r<t+n;++r){a=e[r],c=(a.x-x)/S*s,l=a.y;const k=c|0;if(k===u)l<p?(p=l,h=r):l>g&&(g=l,d=r),i=(o*i+a.x)/++o;else{const C=r-1;if(!N(h)&&!N(d)){const P=Math.min(h,d),z=Math.max(h,d);P!==f&&P!==C&&m.push({...e[P],x:i}),z!==f&&z!==C&&m.push({...e[z],x:i})}r>0&&C!==f&&m.push(e[C]),m.push(a),u=k,o=0,p=g=l,h=d=f=r}}return m}function ol(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 Lr(e){e.data.datasets.forEach(t=>{ol(t)})}function vx(e,t){const n=t.length;let s=0,i;const{iScale:o}=e,{min:r,max:a,minDefined:c,maxDefined:l}=o.getUserBounds();return c&&(s=dt(Yt(t,o.axis,r).lo,0,n-1)),l?i=dt(Yt(t,o.axis,a).hi+1,s,n)-s:i=n-s,{start:s,count:i}}var kx={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){Lr(e);return}const s=e.width;e.data.datasets.forEach((i,o)=>{const{_data:r,indexAxis:a}=i,c=e.getDatasetMeta(o),l=r||i.data;if(en([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}=vx(c,l);const f=n.threshold||4*s;if(d<=f){ol(i);return}N(r)&&(i._data=l,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(g){this._data=g}}));let p;switch(n.algorithm){case"lttb":p=yx(l,h,d,s,n);break;case"min-max":p=xx(l,h,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}i._decimated=p})},destroy(e){Lr(e)}};function wx(e,t,n){const s=e.segments,i=e.points,o=t.points,r=[];for(const a of s){let{start:c,end:l}=a;l=Ds(c,l,i);const u=di(n,i[c],i[l],a.loop);if(!t.segments){r.push({source:a,target:u,start:i[c],end:i[l]});continue}const h=jc(t,u);for(const d of h){const f=di(n,o[d.start],o[d.end],d.loop),p=Fc(a,i,f);for(const g of p)r.push({source:g,target:d,start:{[n]:$r(u,f,"start",Math.max)},end:{[n]:$r(u,f,"end",Math.min)}})}}return r}function di(e,t,n,s){if(s)return;let i=t[e],o=n[e];return e==="angle"&&(i=yt(i),o=yt(o)),{property:e,start:i,end:o}}function Sx(e,t){const{x:n=null,y:s=null}=e||{},i=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Ds(r,a,i);const c=i[r],l=i[a];s!==null?(o.push({x:c.x,y:s}),o.push({x:l.x,y:s})):n!==null&&(o.push({x:n,y:c.y}),o.push({x:n,y:l.y}))}),o}function Ds(e,t,n){for(;t>e;t--){const s=n[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function $r(e,t,n,s){return e&&t?s(e[n],t[n]):e?e[n]:t?t[n]:0}function rl(e,t){let n=[],s=!1;return nt(e)?(s=!0,n=e):n=Sx(e,t),n.length?new te({points:n,options:{tension:0},_loop:s,_fullLoop:s}):null}function Nr(e){return e&&e.fill!==!1}function Mx(e,t,n){let i=e[t].fill;const o=[t];let r;if(!n)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!rt(i))return i;if(r=e[i],!r)return!1;if(r.visible)return i;o.push(i),i=r.fill}return!1}function Px(e,t,n){const s=Ox(e);if(j(s))return isNaN(s.value)?!1:s;let i=parseFloat(s);return rt(i)&&Math.floor(i)===i?Tx(s[0],t,i,n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function Tx(e,t,n,s){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=s?!1:n}function Cx(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:j(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function zx(e,t,n){let s;return e==="start"?s=n:e==="end"?s=t.options.reverse?t.min:t.max:j(e)?s=e.value:s=t.getBaseValue(),s}function Ox(e){const t=e.options,n=t.fill;let s=D(n&&n.target,n);return s===void 0&&(s=!!t.backgroundColor),s===!1||s===null?!1:s===!0?"origin":s}function Rx(e){const{scale:t,index:n,line:s}=e,i=[],o=s.segments,r=s.points,a=Ax(t,n);a.push(rl({x:null,y:t.bottom},s));for(let c=0;c<o.length;c++){const l=o[c];for(let u=l.start;u<=l.end;u++)Ix(i,r[u],a)}return new te({points:i,options:{}})}function Ax(e,t){const n=[],s=e.getMatchingVisibleMetas("line");for(let i=0;i<s.length;i++){const o=s[i];if(o.index===t)break;o.hidden||n.unshift(o.dataset)}return n}function Ix(e,t,n){const s=[];for(let i=0;i<n.length;i++){const o=n[i],{first:r,last:a,point:c}=Dx(o,t,"x");if(!(!c||r&&a)){if(r)s.unshift(c);else if(e.push(c),!a)break}}e.push(...s)}function Dx(e,t,n){const s=e.interpolate(t,n);if(!s)return{};const i=s[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(Ut(i,h,d)){a=i===h,c=i===d;break}}return{first:a,last:c,point:s}}class al{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,s){const{x:i,y:o,radius:r}=this;return n=n||{start:0,end:G},t.arc(i,o,r,n.end,n.start,!0),!s.bounds}interpolate(t){const{x:n,y:s,radius:i}=this,o=t.angle;return{x:n+Math.cos(o)*i,y:s+Math.sin(o)*i,angle:o}}}function Ex(e){const{chart:t,fill:n,line:s}=e;if(rt(n))return Lx(t,n);if(n==="stack")return Rx(e);if(n==="shape")return!0;const i=$x(e);return i instanceof al?i:rl(i,s)}function Lx(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function $x(e){return(e.scale||{}).getPointPositionForValue?Fx(e):Nx(e)}function Nx(e){const{scale:t={},fill:n}=e,s=Cx(n,t);if(rt(s)){const i=t.isHorizontal();return{x:i?s:null,y:i?null:s}}return null}function Fx(e){const{scale:t,fill:n}=e,s=t.options,i=t.getLabels().length,o=s.reverse?t.max:t.min,r=zx(n,t,o),a=[];if(s.grid.circular){const c=t.getPointPositionForValue(0,o);return new al({x:c.x,y:c.y,radius:t.getDistanceFromCenterForValue(r)})}for(let c=0;c<i;++c)a.push(t.getPointPositionForValue(c,r));return a}function Xs(e,t,n){const s=Ex(t),{chart:i,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=i.getDatasetMeta(o),g=Bc(i,p);s&&r.points.length&&(Os(e,n),jx(e,{line:r,target:s,above:d,below:f,area:n,scale:a,axis:c,clip:g}),Rs(e))}function jx(e,t){const{line:n,target:s,above:i,below:o,area:r,scale:a,clip:c}=t,l=n._loop?"angle":t.axis;e.save();let u=o;o!==i&&(l==="x"?(Fr(e,s,r.top),Ks(e,{line:n,target:s,color:i,scale:a,property:l,clip:c}),e.restore(),e.save(),Fr(e,s,r.bottom)):l==="y"&&(jr(e,s,r.left),Ks(e,{line:n,target:s,color:o,scale:a,property:l,clip:c}),e.restore(),e.save(),jr(e,s,r.right),u=i)),Ks(e,{line:n,target:s,color:u,scale:a,property:l,clip:c}),e.restore()}function Fr(e,t,n){const{segments:s,points:i}=t;let o=!0,r=!1;e.beginPath();for(const a of s){const{start:c,end:l}=a,u=i[c],h=i[Ds(c,l,i)];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 jr(e,t,n){const{segments:s,points:i}=t;let o=!0,r=!1;e.beginPath();for(const a of s){const{start:c,end:l}=a,u=i[c],h=i[Ds(c,l,i)];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 Ks(e,t){const{line:n,target:s,property:i,color:o,scale:r,clip:a}=t,c=wx(n,s,i);for(const{source:l,target:u,start:h,end:d}of c){const{style:{backgroundColor:f=o}={}}=l,p=s!==!0;e.save(),e.fillStyle=f,Bx(e,r,a,p&&di(i,h,d)),e.beginPath();const g=!!n.pathSegment(e,l);let m;if(p){g?e.closePath():Br(e,s,d,i);const b=!!s.pathSegment(e,u,{move:g,reverse:!0});m=g&&b,m||Br(e,s,h,i)}e.closePath(),e.fill(m?"evenodd":"nonzero"),e.restore()}}function Bx(e,t,n,s){const i=t.chart.chartArea,{property:o,start:r,end:a}=s||{};if(o==="x"||o==="y"){let c,l,u,h;o==="x"?(c=r,l=i.top,u=a,h=i.bottom):(c=i.left,l=r,u=i.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 Br(e,t,n,s){const i=t.interpolate(n,s);i&&e.lineTo(i.x,i.y)}var Hx={id:"filler",afterDatasetsUpdate(e,t,n){const s=(e.data.datasets||[]).length,i=[];let o,r,a,c;for(r=0;r<s;++r)o=e.getDatasetMeta(r),a=o.dataset,c=null,a&&a.options&&a instanceof te&&(c={visible:e.isDatasetVisible(r),index:r,fill:Px(a,r,s),chart:e,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=c,i.push(c);for(r=0;r<s;++r)c=i[r],!(!c||c.fill===!1)&&(c.fill=Mx(i,r,n.propagate))},beforeDraw(e,t,n){const s=n.drawTime==="beforeDraw",i=e.getSortedVisibleDatasetMetas(),o=e.chartArea;for(let r=i.length-1;r>=0;--r){const a=i[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),s&&a.fill&&Xs(e.ctx,a,o))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const s=e.getSortedVisibleDatasetMetas();for(let i=s.length-1;i>=0;--i){const o=s[i].$filler;Nr(o)&&Xs(e.ctx,o,e.chartArea)}},beforeDatasetDraw(e,t,n){const s=t.meta.$filler;!Nr(s)||n.drawTime!=="beforeDatasetDraw"||Xs(e.ctx,s,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Hr=(e,t)=>{let{boxHeight:n=t,boxWidth:s=t}=e;return e.usePointStyle&&(n=Math.min(n,t),s=e.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:n,itemHeight:Math.max(t,n)}},Zx=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class Zr extends Nt{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,s){this.maxWidth=t,this.maxHeight=n,this._margins=s,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=X(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(s=>t.filter(s,this.chart.data))),t.sort&&(n=n.sort((s,i)=>t.sort(s,i,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 s=t.labels,i=ht(s.font),o=i.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:c}=Hr(s,o);let l,u;n.font=i.string,this.isHorizontal()?(l=this.maxWidth,u=this._fitRows(r,o,a,c)+10):(u=this.maxHeight,l=this._fitCols(r,i,a,c)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,s,i){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,c=this.legendHitBoxes=[],l=this.lineWidths=[0],u=i+a;let h=t;o.textAlign="left",o.textBaseline="middle";let d=-1,f=-u;return this.legendItems.forEach((p,g)=>{const m=s+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:i},l[l.length-1]+=m+a}),h}_fitCols(t,n,s,i){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:x,itemHeight:M}=Vx(s,n,o,m,i);b>0&&f+M+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:x,height:M},d=Math.max(d,x),f+=M+a}),h+=d,l.push({width:d,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:s,labels:{padding:i},rtl:o}}=this,r=Le(o,this.left,this.width);if(this.isHorizontal()){let a=0,c=_t(s,this.left+i,this.right-this.lineWidths[a]);for(const l of n)a!==l.row&&(a=l.row,c=_t(s,this.left+i,this.right-this.lineWidths[a])),l.top+=this.top+t+i,l.left=r.leftForLtr(r.x(c),l.width),c+=l.width+i}else{let a=0,c=_t(s,this.top+t+i,this.bottom-this.columnSizes[a].height);for(const l of n)l.col!==a&&(a=l.col,c=_t(s,this.top+t+i,this.bottom-this.columnSizes[a].height)),l.top=c,l.left+=this.left+i,l.left=r.leftForLtr(r.x(l.left),l.width),c+=l.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;Os(t,this),this._draw(),Rs(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:s,ctx:i}=this,{align:o,labels:r}=t,a=st.color,c=Le(t.rtl,this.left,this.width),l=ht(r.font),{padding:u}=r,h=l.size,d=h/2;let f;this.drawTitle(),i.textAlign=c.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=l.string;const{boxWidth:p,boxHeight:g,itemHeight:m}=Hr(r,h),b=function(C,P,z){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;i.save();const O=D(z.lineWidth,1);if(i.fillStyle=D(z.fillStyle,a),i.lineCap=D(z.lineCap,"butt"),i.lineDashOffset=D(z.lineDashOffset,0),i.lineJoin=D(z.lineJoin,"miter"),i.lineWidth=O,i.strokeStyle=D(z.strokeStyle,a),i.setLineDash(D(z.lineDash,[])),r.usePointStyle){const E={radius:g*Math.SQRT2/2,pointStyle:z.pointStyle,rotation:z.rotation,borderWidth:O},L=c.xPlus(C,p/2),B=P+d;Cc(i,E,L,B,r.pointStyleWidth&&p)}else{const E=P+Math.max((h-g)/2,0),L=c.leftForLtr(C,p),B=ke(z.borderRadius);i.beginPath(),Object.values(B).some(ft=>ft!==0)?yn(i,{x:L,y:E,w:p,h:g,radius:B}):i.rect(L,E,p,g),i.fill(),O!==0&&i.stroke()}i.restore()},x=function(C,P,z){Me(i,z.text,C,P+m/2,l,{strikethrough:z.hidden,textAlign:c.textAlign(z.textAlign)})},M=this.isHorizontal(),S=this._computeTitleHeight();M?f={x:_t(o,this.left+u,this.right-s[0]),y:this.top+u+S,line:0}:f={x:this.left+u,y:_t(o,this.top+S+u,this.bottom-n[0].height),line:0},Lc(this.ctx,t.textDirection);const k=m+u;this.legendItems.forEach((C,P)=>{i.strokeStyle=C.fontColor,i.fillStyle=C.fontColor;const z=i.measureText(C.text).width,O=c.textAlign(C.textAlign||(C.textAlign=r.textAlign)),E=p+d+z;let L=f.x,B=f.y;c.setWidth(this.width),M?P>0&&L+E+u>this.right&&(B=f.y+=k,f.line++,L=f.x=_t(o,this.left+u,this.right-s[f.line])):P>0&&B+k>this.bottom&&(L=f.x=L+n[f.line].width+u,f.line++,B=f.y=_t(o,this.top+S+u,this.bottom-n[f.line].height));const ft=c.x(L);if(b(ft,B,C),L=lb(O,L+p+d,M?L+E:this.right,t.rtl),x(c.x(L),B,C),M)f.x+=E+u;else if(typeof C.text!="string"){const Tt=l.lineHeight;f.y+=cl(C,Tt)+u}else f.y+=k}),$c(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,s=ht(n.font),i=vt(n.padding);if(!n.display)return;const o=Le(t.rtl,this.left,this.width),r=this.ctx,a=n.position,c=s.size/2,l=i.top+c;let u,h=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),u=this.top+l,h=_t(t.align,h,this.right-d);else{const p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);u=l+_t(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}const f=_t(a,h,h+d);r.textAlign=o.textAlign(no(a)),r.textBaseline="middle",r.strokeStyle=n.color,r.fillStyle=n.color,r.font=s.string,Me(r,n.text,f,u,s)}_computeTitleHeight(){const t=this.options.title,n=ht(t.font),s=vt(t.padding);return t.display?n.lineHeight+s.height:0}_getLegendItemAt(t,n){let s,i,o;if(Ut(t,this.left,this.right)&&Ut(n,this.top,this.bottom)){for(o=this.legendHitBoxes,s=0;s<o.length;++s)if(i=o[s],Ut(t,i.left,i.left+i.width)&&Ut(n,i.top,i.top+i.height))return this.legendItems[s]}return null}handleEvent(t){const n=this.options;if(!Ux(t.type,n))return;const s=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const i=this._hoveredItem,o=Zx(i,s);i&&!o&&X(n.onLeave,[t,i,this],this),this._hoveredItem=s,s&&!o&&X(n.onHover,[t,s,this],this)}else s&&X(n.onClick,[t,s,this],this)}}function Vx(e,t,n,s,i){const o=Wx(s,e,t,n),r=qx(i,s,t.lineHeight);return{itemWidth:o,itemHeight:r}}function Wx(e,t,n,s){let i=e.text;return i&&typeof i!="string"&&(i=i.reduce((o,r)=>o.length>r.length?o:r)),t+n.size/2+s.measureText(i).width}function qx(e,t,n){let s=e;return typeof t.text!="string"&&(s=cl(t,n)),s}function cl(e,t){const n=e.text?e.text.length:0;return t*n}function Ux(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var Yx={id:"legend",_element:Zr,start(e,t,n){const s=e.legend=new Zr({ctx:e.ctx,options:n,chart:e});xt.configure(e,s,n),xt.addBox(e,s)},stop(e){xt.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const s=e.legend;xt.configure(e,s,n),s.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 s=t.datasetIndex,i=n.chart;i.isDatasetVisible(s)?(i.hide(s),t.hidden=!0):(i.show(s),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:s,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(c=>{const l=c.controller.getStyle(n?0:void 0),u=vt(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:s||l.pointStyle,rotation:l.rotation,textAlign:i||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 ho extends Nt{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 s=this.options;if(this.left=0,this.top=0,!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const i=nt(s.text)?s.text.length:1;this._padding=vt(s.padding);const o=i*ht(s.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:s,bottom:i,right:o,options:r}=this,a=r.align;let c=0,l,u,h;return this.isHorizontal()?(u=_t(a,s,o),h=n+t,l=o-s):(r.position==="left"?(u=s+t,h=_t(a,i,n),c=Z*-.5):(u=o-t,h=_t(a,n,i),c=Z*.5),l=i-n),{titleX:u,titleY:h,maxWidth:l,rotation:c}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const s=ht(n.font),o=s.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:c,rotation:l}=this._drawArgs(o);Me(t,n.text,0,0,s,{color:n.color,maxWidth:c,rotation:l,textAlign:no(n.align),textBaseline:"middle",translation:[r,a]})}}function Jx(e,t){const n=new ho({ctx:e.ctx,options:t,chart:e});xt.configure(e,n,t),xt.addBox(e,n),e.titleBlock=n}var Xx={id:"title",_element:ho,start(e,t,n){Jx(e,n)},stop(e){const t=e.titleBlock;xt.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const s=e.titleBlock;xt.configure(e,s,n),s.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 Jn=new WeakMap;var Kx={id:"subtitle",start(e,t,n){const s=new ho({ctx:e.ctx,options:n,chart:e});xt.configure(e,s,n),xt.addBox(e,s),Jn.set(e,s)},stop(e){xt.removeBox(e,Jn.get(e)),Jn.delete(e)},beforeUpdate(e,t,n){const s=Jn.get(e);xt.configure(e,s,n),s.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 on={average(e){if(!e.length)return!1;let t,n,s=new Set,i=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();s.add(c.x),i+=c.y,++o}}return o===0||s.size===0?!1:{x:[...s].reduce((a,c)=>a+c)/s.size,y:i/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,s=t.y,i=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=ii(t,l);u<i&&(i=u,a=c)}}if(a){const c=a.tooltipPosition();n=c.x,s=c.y}return{x:n,y:s}}};function Ft(e,t){return t&&(nt(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Vt(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
|
|
99
|
+
*/class h_{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,s,i){const o=n.listeners[i],r=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:r,currentStep:Math.min(s-n.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=kc.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((s,i)=>{if(!s.running||!s.items.length)return;const o=s.items;let r=o.length-1,a=!1,c;for(;r>=0;--r)c=o[r],c._active?(c._total>s.duration&&(s.duration=c._total),c.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(i.draw(),this._notify(i,s,t,"progress")),o.length||(s.running=!1,this._notify(i,s,t,"complete"),s.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let s=n.get(t);return s||(s={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,s)),s}listen(t,n,s){this._getAnims(t).listeners[n].push(s)}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((s,i)=>Math.max(s,i._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 s=n.items;let i=s.length-1;for(;i>=0;--i)s[i].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Zt=new h_;const or="transparent",d_={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const s=Jo(e||or),i=s.valid&&Jo(t||or);return i&&i.valid?i.mix(s,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class f_{constructor(t,n,s,i){const o=n[s];i=en([t.to,i,o,t.from]);const r=en([t.from,o,i]);this._active=!0,this._fn=t.fn||d_[t.type||typeof r],this._easing=ln[t.easing]||ln.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=s,this._from=r,this._to=i,this._promises=void 0}active(){return this._active}update(t,n,s){if(this._active){this._notify(!1);const i=this._target[this._prop],o=s-this._start,r=this._duration-o;this._start=s,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=en([t.to,n,i,t.from]),this._from=en([t.from,i,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,s=this._duration,i=this._prop,o=this._from,r=this._loop,a=this._to;let c;if(this._active=o!==a&&(r||n<s),!this._active){this._target[i]=a,this._notify(!0);return}if(n<0){this._target[i]=o;return}c=n/s%2,c=r&&c>1?2-c:c,c=this._easing(Math.min(1,Math.max(0,c))),this._target[i]=this._fn(o,a,c)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,s)=>{t.push({res:n,rej:s})})}_notify(t){const n=t?"res":"rej",s=this._promises||[];for(let i=0;i<s.length;i++)s[i][n]()}}class jc{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!F(t))return;const n=Object.keys(st.animation),s=this._properties;Object.getOwnPropertyNames(t).forEach(i=>{const o=t[i];if(!F(o))return;const r={};for(const a of n)r[a]=o[a];(nt(o.properties)&&o.properties||[i]).forEach(a=>{(a===i||!s.has(a))&&s.set(a,r)})})}_animateOptions(t,n){const s=n.options,i=g_(t,s);if(!i)return[];const o=this._createAnimations(i,s);return s.$shared&&p_(t.options.$animations,s).then(()=>{t.options=s},()=>{}),o}_createAnimations(t,n){const s=this._properties,i=[],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"){i.push(...this._animateOptions(t,n));continue}const u=n[l];let h=o[l];const d=s.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 f_(d,t,l,u),i.push(h)}return i}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const s=this._createAnimations(t,n);if(s.length)return Zt.add(this._chart,s),!0}}function p_(e,t){const n=[],s=Object.keys(t);for(let i=0;i<s.length;i++){const o=e[s[i]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function g_(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 rr(e,t){const n=e&&e.options||{},s=n.reverse,i=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:s?o:i,end:s?i:o}}function m_(e,t,n){if(n===!1)return!1;const s=rr(e,n),i=rr(t,n);return{top:i.end,right:s.end,bottom:i.start,left:s.start}}function b_(e){let t,n,s,i;return F(e)?(t=e.top,n=e.right,s=e.bottom,i=e.left):t=n=s=i=e,{top:t,right:n,bottom:s,left:i,disabled:e===!1}}function Bc(e,t){const n=[],s=e._getSortedDatasetMetas(t);let i,o;for(i=0,o=s.length;i<o;++i)n.push(s[i].index);return n}function ar(e,t,n,s={}){const i=e.keys,o=s.mode==="single";let r,a,c,l;if(t===null)return;let u=!1;for(r=0,a=i.length;r<a;++r){if(c=+i[r],c===n){if(u=!0,s.all)continue;break}l=e.values[c],at(l)&&(o||t===0||jt(t)===jt(l))&&(t+=l)}return!u&&!s.all?0:t}function __(e,t){const{iScale:n,vScale:s}=t,i=n.axis==="x"?"x":"y",o=s.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]={[i]:u,[o]:e[u]};return a}function js(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function y_(e,t,n){return`${e.id}.${t.id}.${n.stack||n.type}`}function x_(e){const{min:t,max:n,minDefined:s,maxDefined:i}=e.getUserBounds();return{min:s?t:Number.NEGATIVE_INFINITY,max:i?n:Number.POSITIVE_INFINITY}}function v_(e,t,n){const s=e[t]||(e[t]={});return s[n]||(s[n]={})}function cr(e,t,n,s){for(const i of t.getMatchingVisibleMetas(s).reverse()){const o=e[i.index];if(n&&o>0||!n&&o<0)return i.index}return null}function lr(e,t){const{chart:n,_cachedMeta:s}=e,i=n._stacks||(n._stacks={}),{iScale:o,vScale:r,index:a}=s,c=o.axis,l=r.axis,u=y_(o,r,s),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]=v_(i,u,g),d[a]=m,d._top=cr(d,r,!0,s.type),d._bottom=cr(d,r,!1,s.type);const x=d._visualValues||(d._visualValues={});x[a]=m}}function Bs(e,t){const n=e.scales;return Object.keys(n).filter(s=>n[s].axis===t).shift()}function k_(e,t){return le(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function w_(e,t,n){return le(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function Ye(e,t){const n=e.controller.index,s=e.vScale&&e.vScale.axis;if(s){t=t||e._parsed;for(const i of t){const o=i._stacks;if(!o||o[s]===void 0||o[s][n]===void 0)return;delete o[s][n],o[s]._visualValues!==void 0&&o[s]._visualValues[n]!==void 0&&delete o[s]._visualValues[n]}}}const Zs=e=>e==="reset"||e==="none",ur=(e,t)=>t?e:Object.assign({},e),S_=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Bc(n,!0),values:null};class $t{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=js(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&&Ye(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,s=this.getDataset(),i=(h,d,f,p)=>h==="x"?d:h==="r"?p:f,o=n.xAxisID=E(s.xAxisID,Bs(t,"x")),r=n.yAxisID=E(s.yAxisID,Bs(t,"y")),a=n.rAxisID=E(s.rAxisID,Bs(t,"r")),c=n.indexAxis,l=n.iAxisID=i(c,o,r,a),u=n.vAxisID=i(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&&qo(this._data,this),t._stacked&&Ye(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),s=this._data;if(F(n)){const i=this._cachedMeta;this._data=__(n,i)}else if(s!==n){if(s){qo(s,this);const i=this._cachedMeta;Ye(i),i._parsed=[]}n&&Object.isExtensible(n)&&cb(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,s=this.getDataset();let i=!1;this._dataCheck();const o=n._stacked;n._stacked=js(n.vScale,n),n.stack!==s.stack&&(i=!0,Ye(n),n.stack=s.stack),this._resyncElements(t),(i||o!==n._stacked)&&(lr(this,n._parsed),n._stacked=js(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),s=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(s,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:s,_data:i}=this,{iScale:o,_stacked:r}=s,a=o.axis;let c=t===0&&n===i.length?!0:s._sorted,l=t>0&&s._parsed[t-1],u,h,d;if(this._parsing===!1)s._parsed=i,s._sorted=!0,d=i;else{nt(i[t])?d=this.parseArrayData(s,i,t,n):F(i[t])?d=this.parseObjectData(s,i,t,n):d=this.parsePrimitiveData(s,i,t,n);const f=()=>h[a]===null||l&&h[a]<l[a];for(u=0;u<n;++u)s._parsed[u+t]=h=d[u],c&&(f()&&(c=!1),l=h);s._sorted=c}r&&lr(this,d)}parsePrimitiveData(t,n,s,i){const{iScale:o,vScale:r}=t,a=o.axis,c=r.axis,l=o.getLabels(),u=o===r,h=new Array(i);let d,f,p;for(d=0,f=i;d<f;++d)p=d+s,h[d]={[a]:u||o.parse(l[p],p),[c]:r.parse(n[p],p)};return h}parseArrayData(t,n,s,i){const{xScale:o,yScale:r}=t,a=new Array(i);let c,l,u,h;for(c=0,l=i;c<l;++c)u=c+s,h=n[u],a[c]={x:o.parse(h[0],u),y:r.parse(h[1],u)};return a}parseObjectData(t,n,s,i){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:c="y"}=this._parsing,l=new Array(i);let u,h,d,f;for(u=0,h=i;u<h;++u)d=u+s,f=n[d],l[u]={x:o.parse(oe(f,a),d),y:r.parse(oe(f,c),d)};return l}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,s){const i=this.chart,o=this._cachedMeta,r=n[t.axis],a={keys:Bc(i,!0),values:n._stacks[t.axis]._visualValues};return ar(a,r,o.index,{mode:s})}updateRangeFromParsed(t,n,s,i){const o=s[n.axis];let r=o===null?NaN:o;const a=i&&s._stacks[n.axis];i&&a&&(i.values=a,r=ar(i,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,n){const s=this._cachedMeta,i=s._parsed,o=s._sorted&&t===s.iScale,r=i.length,a=this._getOtherScale(t),c=S_(n,s,this.chart),l={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:h}=x_(a);let d,f;function p(){f=i[d];const g=f[a.axis];return!at(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,s=[];let i,o,r;for(i=0,o=n.length;i<o;++i)r=n[i][t.axis],at(r)&&s.push(r);return s}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,s=n.iScale,i=n.vScale,o=this.getParsed(t);return{label:s?""+s.getLabelForValue(o[s.axis]):"",value:i?""+i.getLabelForValue(o[i.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=b_(E(this.options.clip,m_(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,s=this._cachedMeta,i=s.data||[],o=n.chartArea,r=[],a=this._drawStart||0,c=this._drawCount||i.length-a,l=this.options.drawActiveElementsOnTop;let u;for(s.dataset&&s.dataset.draw(t,o,a,c),u=a;u<a+c;++u){const h=i[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 s=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(s):this.resolveDataElementOptions(t||0,s)}getContext(t,n,s){const i=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=w_(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=i.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=k_(this.chart.getContext(),this.index)),o.dataset=i,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=s,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",s){const i=n==="active",o=this._cachedDataOpts,r=t+"-"+n,a=o[r],c=this.enableOptionSharing&&bn(s);if(a)return ur(a,c);const l=this.chart.config,u=l.datasetElementScopeKeys(this._type,t),h=i?[`${t}Hover`,"hover",t,""]:[t,""],d=l.getOptionScopes(this.getDataset(),u),f=Object.keys(st.elements[t]),p=()=>this.getContext(s,i,n),g=l.resolveNamedOptions(d,f,p,h);return g.$shared&&(g.$shared=c,o[r]=Object.freeze(ur(g,c))),g}_resolveAnimations(t,n,s){const i=this.chart,o=this._cachedDataOpts,r=`animation-${n}`,a=o[r];if(a)return a;let c;if(i.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,s,n))}const l=new jc(i,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||Zs(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const s=this.resolveDataElementOptions(t,n),i=this._sharedOptions,o=this.getSharedOptions(s),r=this.includeOptions(n,o)||o!==i;return this.updateSharedOptions(o,n,s),{sharedOptions:o,includeOptions:r}}updateElement(t,n,s,i){Zs(i)?Object.assign(t,s):this._resolveAnimations(n,i).update(t,s)}updateSharedOptions(t,n,s){t&&!Zs(n)&&this._resolveAnimations(void 0,n).update(t,s)}_setStyle(t,n,s,i){t.active=i;const o=this.getStyle(n,i);this._resolveAnimations(n,s,i).update(t,{options:!i&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,s){this._setStyle(t,s,"active",!1)}setHoverStyle(t,n,s){this._setStyle(t,s,"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,s=this._cachedMeta.data;for(const[a,c,l]of this._syncList)this[a](c,l);this._syncList=[];const i=s.length,o=n.length,r=Math.min(o,i);r&&this.parse(0,r),o>i?this._insertElements(i,o-i,t):o<i&&this._removeElements(o,i-o)}_insertElements(t,n,s=!0){const i=this._cachedMeta,o=i.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(i._parsed),this.parse(t,n),s&&this.updateElements(o,t,n,"reset")}updateElements(t,n,s,i){}_removeElements(t,n){const s=this._cachedMeta;if(this._parsing){const i=s._parsed.splice(t,n);s._stacked&&Ye(s,i)}s.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,s,i]=t;this[n](s,i)}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 s=arguments.length-2;s&&this._sync(["_insertElements",t,s])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}P($t,"defaults",{}),P($t,"datasetElementType",null),P($t,"dataElementType",null);function M_(e,t){if(!e._cache.$bar){const n=e.getMatchingVisibleMetas(t);let s=[];for(let i=0,o=n.length;i<o;i++)s=s.concat(n[i].controller.getAllParsedValues(e));e._cache.$bar=vc(s.sort((i,o)=>i-o))}return e._cache.$bar}function P_(e){const t=e.iScale,n=M_(t,e.type);let s=t._length,i,o,r,a;const c=()=>{r===32767||r===-32768||(bn(a)&&(s=Math.min(s,Math.abs(r-a)||s)),a=r)};for(i=0,o=n.length;i<o;++i)r=t.getPixelForValue(n[i]),c();for(a=void 0,i=0,o=t.ticks.length;i<o;++i)r=t.getPixelForTick(i),c();return s}function T_(e,t,n,s){const i=n.barThickness;let o,r;return N(i)?(o=t.min*n.categoryPercentage,r=n.barPercentage):(o=i*s,r=1),{chunk:o/s,ratio:r,start:t.pixels[e]-o/2}}function C_(e,t,n,s){const i=t.pixels,o=i[e];let r=e>0?i[e-1]:null,a=e<i.length-1?i[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/s,ratio:n.barPercentage,start:l}}function z_(e,t,n,s){const i=n.parse(e[0],s),o=n.parse(e[1],s),r=Math.min(i,o),a=Math.max(i,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:i,end:o,min:r,max:a}}function Zc(e,t,n,s){return nt(e)?z_(e,t,n,s):t[n.axis]=n.parse(e,s),t}function hr(e,t,n,s){const i=e.iScale,o=e.vScale,r=i.getLabels(),a=i===o,c=[];let l,u,h,d;for(l=n,u=n+s;l<u;++l)d=t[l],h={},h[i.axis]=a||i.parse(r[l],l),c.push(Zc(d,h,o,l));return c}function Vs(e){return e&&e.barStart!==void 0&&e.barEnd!==void 0}function O_(e,t,n){return e!==0?jt(e):(t.isHorizontal()?1:-1)*(t.min>=n?1:-1)}function R_(e){let t,n,s,i,o;return e.horizontal?(t=e.base>e.x,n="left",s="right"):(t=e.base<e.y,n="bottom",s="top"),t?(i="end",o="start"):(i="start",o="end"),{start:n,end:s,reverse:t,top:i,bottom:o}}function A_(e,t,n,s){let i=t.borderSkipped;const o={};if(!i){e.borderSkipped=o;return}if(i===!0){e.borderSkipped={top:!0,right:!0,bottom:!0,left:!0};return}const{start:r,end:a,reverse:c,top:l,bottom:u}=R_(e);i==="middle"&&n&&(e.enableBorderRadius=!0,(n._top||0)===s?i=l:(n._bottom||0)===s?i=u:(o[dr(u,r,a,c)]=!0,i=l)),o[dr(i,r,a,c)]=!0,e.borderSkipped=o}function dr(e,t,n,s){return s?(e=I_(e,t,n),e=fr(e,n,t)):e=fr(e,t,n),e}function I_(e,t,n){return e===t?n:e===n?t:e}function fr(e,t,n){return e==="start"?t:e==="end"?n:e}function E_(e,{inflateAmount:t},n){e.inflateAmount=t==="auto"?n===1?.33:0:t}class Qn extends $t{parsePrimitiveData(t,n,s,i){return hr(t,n,s,i)}parseArrayData(t,n,s,i){return hr(t,n,s,i)}parseObjectData(t,n,s,i){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=s,f=s+i;d<f;++d)g=n[d],p={},p[o.axis]=o.parse(oe(g,l),d),h.push(Zc(oe(g,u),p,r,d));return h}updateRangeFromParsed(t,n,s,i){super.updateRangeFromParsed(t,n,s,i);const o=s._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:s,vScale:i}=n,o=this.getParsed(t),r=o._custom,a=Vs(r)?"["+r.start+", "+r.end+"]":""+i.getLabelForValue(o[i.axis]);return{label:""+s.getLabelForValue(o[s.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,s,i){const o=i==="reset",{index:r,_cachedMeta:{vScale:a}}=this,c=a.getBasePixel(),l=a.isHorizontal(),u=this._getRuler(),{sharedOptions:h,includeOptions:d}=this._getSharedOptions(n,i);for(let f=n;f<n+s;f++){const p=this.getParsed(f),g=o||N(p[a.axis])?{base:c,head:c}:this._calculateBarValuePixels(f),m=this._calculateBarIndexPixels(f,u),b=(p._stacks||{})[a.axis],x={horizontal:l,base:g.base,enableBorderRadius:!b||Vs(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&&(x.options=h||this.resolveDataElementOptions(f,t[f].active?"active":i));const M=x.options||t[f].options;A_(x,M,b,r),E_(x,M,u.ratio),this.updateElement(t[f],f,x,i)}}_getStacks(t,n){const{iScale:s}=this._cachedMeta,i=s.getMatchingVisibleMetas(this._type).filter(u=>u.controller.options.grouped),o=s.options.stacked,r=[],a=this._cachedMeta.controller.getParsed(n),c=a&&a[s.axis],l=u=>{const h=u._parsed.find(f=>f[s.axis]===c),d=h&&h[u.vScale.axis];if(N(d)||isNaN(d))return!0};for(const u of i)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(s=>t[s].axis===n).shift()}_getAxis(){const t={},n=this.getFirstScaleIdForIndexAxis();for(const s of this.chart.data.datasets)t[E(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,n)]=!0;return Object.keys(t)}_getStackIndex(t,n,s){const i=this._getStacks(t,s),o=n!==void 0?i.indexOf(n):-1;return o===-1?i.length-1:o}_getRuler(){const t=this.options,n=this._cachedMeta,s=n.iScale,i=[];let o,r;for(o=0,r=n.data.length;o<r;++o)i.push(s.getPixelForValue(this.getParsed(o)[s.axis],o));const a=t.barThickness;return{min:a||P_(n),pixels:i,start:s._startPixel,end:s._endPixel,stackCount:this._getStackCount(),scale:s,grouped:t.grouped,ratio:a?1:t.categoryPercentage*t.barPercentage}}_calculateBarValuePixels(t){const{_cachedMeta:{vScale:n,_stacked:s,index:i},options:{base:o,minBarLength:r}}=this,a=o||0,c=this.getParsed(t),l=c._custom,u=Vs(l);let h=c[n.axis],d=0,f=s?this.applyStack(n,c,s):h,p,g;f!==h&&(d=f-h,f=h),u&&(h=l.barStart,f=l.barEnd-l.barStart,h!==0&&jt(h)!==jt(l.barEnd)&&(d=0),d+=h);const m=!N(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=O_(g,n,a)*r,h===a&&(b-=g/2);const x=n.getPixelForDecimal(0),M=n.getPixelForDecimal(1),S=Math.min(x,M),k=Math.max(x,M);b=Math.max(Math.min(b,k),S),p=b+g,s&&!u&&(c._stacks[n.axis]._visualValues[i]=n.getValueForPixel(p)-n.getValueForPixel(b))}if(b===n.getPixelForValue(a)){const x=jt(g)*n.getLineWidthForValue(a)/2;b+=x,g-=x}return{size:g,base:b,head:p,center:p+g/2}}_calculateBarIndexPixels(t,n){const s=n.scale,i=this.options,o=i.skipNull,r=E(i.maxBarThickness,1/0);let a,c;const l=this._getAxisCount();if(n.grouped){const u=o?this._getStackCount(t):n.stackCount,h=i.barThickness==="flex"?C_(t,n,i,u*l):T_(t,n,i,u*l),d=this.chart.options.indexAxis==="x"?this.getDataset().xAxisID:this.getDataset().yAxisID,f=this._getAxis().indexOf(E(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=s.getPixelForValue(this.getParsed(t)[s.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,s=t.data,i=s.length;let o=0;for(;o<i;++o)this.getParsed(o)[n.axis]!==null&&!s[o].hidden&&s[o].draw(this._ctx)}}P(Qn,"id","bar"),P(Qn,"defaults",{datasetElementType:!1,dataElementType:"bar",categoryPercentage:.8,barPercentage:.9,grouped:!0,animations:{numbers:{type:"number",properties:["x","y","base","width","height"]}}}),P(Qn,"overrides",{scales:{_index_:{type:"category",offset:!0,grid:{offset:!0}},_value_:{type:"linear",beginAtZero:!0}}});class ts extends $t{initialize(){this.enableOptionSharing=!0,super.initialize()}parsePrimitiveData(t,n,s,i){const o=super.parsePrimitiveData(t,n,s,i);for(let r=0;r<o.length;r++)o[r]._custom=this.resolveDataElementOptions(r+s).radius;return o}parseArrayData(t,n,s,i){const o=super.parseArrayData(t,n,s,i);for(let r=0;r<o.length;r++){const a=n[s+r];o[r]._custom=E(a[2],this.resolveDataElementOptions(r+s).radius)}return o}parseObjectData(t,n,s,i){const o=super.parseObjectData(t,n,s,i);for(let r=0;r<o.length;r++){const a=n[s+r];o[r]._custom=E(a&&a.r&&+a.r,this.resolveDataElementOptions(r+s).radius)}return o}getMaxOverflow(){const t=this._cachedMeta.data;let n=0;for(let s=t.length-1;s>=0;--s)n=Math.max(n,t[s].size(this.resolveDataElementOptions(s))/2);return n>0&&n}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:i,yScale:o}=n,r=this.getParsed(t),a=i.getLabelForValue(r.x),c=o.getLabelForValue(r.y),l=r._custom;return{label:s[t]||"",value:"("+a+", "+c+(l?", "+l:"")+")"}}update(t){const n=this._cachedMeta.data;this.updateElements(n,0,n.length,t)}updateElements(t,n,s,i){const o=i==="reset",{iScale:r,vScale:a}=this._cachedMeta,{sharedOptions:c,includeOptions:l}=this._getSharedOptions(n,i),u=r.axis,h=a.axis;for(let d=n;d<n+s;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":i),o&&(g.options.radius=0)),this.updateElement(f,d,g,i)}}resolveDataElementOptions(t,n){const s=this.getParsed(t);let i=super.resolveDataElementOptions(t,n);i.$shared&&(i=Object.assign({},i,{$shared:!1}));const o=i.radius;return n!=="active"&&(i.radius=0),i.radius+=E(s&&s._custom,o),i}}P(ts,"id","bubble"),P(ts,"defaults",{datasetElementType:!1,dataElementType:"point",animations:{numbers:{type:"number",properties:["x","y","borderWidth","radius"]}}}),P(ts,"overrides",{scales:{x:{type:"linear"},y:{type:"linear"}}});function D_(e,t,n){let s=1,i=1,o=0,r=0;if(t<G){const a=e,c=a+t,l=Math.cos(a),u=Math.sin(a),h=Math.cos(c),d=Math.sin(c),f=(M,S,k)=>_n(M,a,c,!0)?1:Math.max(S,S*n,k,k*n),p=(M,S,k)=>_n(M,a,c,!0)?-1:Math.min(S,S*n,k,k*n),g=f(0,l,h),m=f(lt,u,d),b=p(Z,l,h),x=p(Z+lt,u,d);s=(g-b)/2,i=(m-x)/2,o=-(g+b)/2,r=-(m+x)/2}return{ratioX:s,ratioY:i,offsetX:o,offsetY:r}}class xe extends $t{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 s=this.getDataset().data,i=this._cachedMeta;if(this._parsing===!1)i._parsed=s;else{let o=c=>+s[c];if(F(s[t])){const{key:c="value"}=this._parsing;o=l=>+oe(s[l],c)}let r,a;for(r=t,a=t+n;r<a;++r)i._parsed[r]=o(r)}}_getRotation(){return Lt(this.options.rotation-90)}_getCircumference(){return Lt(this.options.circumference)}_getRotationExtents(){let t=G,n=-G;for(let s=0;s<this.chart.data.datasets.length;++s)if(this.chart.isDatasetVisible(s)&&this.chart.getDatasetMeta(s).type===this._type){const i=this.chart.getDatasetMeta(s).controller,o=i._getRotation(),r=i._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:s}=n,i=this._cachedMeta,o=i.data,r=this.getMaxBorderWidth()+this.getMaxOffset(o)+this.options.spacing,a=Math.max((Math.min(s.width,s.height)-r)/2,0),c=Math.min(Um(this.options.cutout,a),1),l=this._getRingWeight(this.index),{circumference:u,rotation:h}=this._getRotationExtents(),{ratioX:d,ratioY:f,offsetX:p,offsetY:g}=D_(h,u,c),m=(s.width-r)/d,b=(s.height-r)/f,x=Math.max(Math.min(m,b)/2,0),M=mc(this.options.radius,x),S=Math.max(M*c,0),k=(M-S)/this._getVisibleDatasetWeightTotal();this.offsetX=p*M,this.offsetY=g*M,i.total=this.calculateTotal(),this.outerRadius=M-k*this._getRingWeightOffset(this.index),this.innerRadius=Math.max(this.outerRadius-k*l,0),this.updateElements(o,0,o.length,t)}_circumference(t,n){const s=this.options,i=this._cachedMeta,o=this._getCircumference();return n&&s.animation.animateRotate||!this.chart.getDataVisibility(t)||i._parsed[t]===null||i.data[t].hidden?0:this.calculateCircumference(i._parsed[t]*o/G)}updateElements(t,n,s,i){const o=i==="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,i);let b=this._getRotation(),x;for(x=0;x<n;++x)b+=this._circumference(x,o);for(x=n;x<n+s;++x){const M=this._circumference(x,o),S=t[x],k={x:u+this.offsetX,y:h+this.offsetY,startAngle:b,endAngle:b+M,circumference:M,outerRadius:p,innerRadius:f};m&&(k.options=g||this.resolveDataElementOptions(x,S.active?"active":i)),b+=M,this.updateElement(S,x,k,i)}}calculateTotal(){const t=this._cachedMeta,n=t.data;let s=0,i;for(i=0;i<n.length;i++){const o=t._parsed[i];o!==null&&!isNaN(o)&&this.chart.getDataVisibility(i)&&!n[i].hidden&&(s+=Math.abs(o))}return s}calculateCircumference(t){const n=this._cachedMeta.total;return n>0&&!isNaN(t)?G*(Math.abs(t)/n):0}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart,i=s.data.labels||[],o=An(n._parsed[t],s.options.locale);return{label:i[t]||"",value:o}}getMaxBorderWidth(t){let n=0;const s=this.chart;let i,o,r,a,c;if(!t){for(i=0,o=s.data.datasets.length;i<o;++i)if(s.isDatasetVisible(i)){r=s.getDatasetMeta(i),t=r.data,a=r.controller;break}}if(!t)return 0;for(i=0,o=t.length;i<o;++i)c=a.resolveDataElementOptions(i),c.borderAlign!=="inner"&&(n=Math.max(n,c.borderWidth||0,c.hoverBorderWidth||0));return n}getMaxOffset(t){let n=0;for(let s=0,i=t.length;s<i;++s){const o=this.resolveDataElementOptions(s);n=Math.max(n,o.offset||0,o.hoverOffset||0)}return n}_getRingWeightOffset(t){let n=0;for(let s=0;s<t;++s)this.chart.isDatasetVisible(s)&&(n+=this._getRingWeight(s));return n}_getRingWeight(t){return Math.max(E(this.chart.data.datasets[t].weight,1),0)}_getVisibleDatasetWeightTotal(){return this._getRingWeightOffset(this.chart.data.datasets.length)||1}}P(xe,"id","doughnut"),P(xe,"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"}),P(xe,"descriptors",{_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")}),P(xe,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data,{labels:{pointStyle:s,textAlign:i,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:i,pointStyle:s,borderRadius:r&&(a||h.borderRadius),index:l}}):[]}},onClick(t,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}}});class es extends $t{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:s,data:i=[],_dataset:o}=n,r=this.chart._animationsDisabled;let{start:a,count:c}=Sc(n,i,r);this._drawStart=a,this._drawCount=c,Mc(n)&&(a=0,c=i.length),s._chart=this.chart,s._datasetIndex=this.index,s._decimated=!!o._decimated,s.points=i;const l=this.resolveDatasetElementOptions(t);this.options.showLine||(l.borderWidth=0),l.segment=this.options.segment,this.updateElement(s,void 0,{animated:!r,options:l},t),this.updateElements(i,a,c,t)}updateElements(t,n,s,i){const o=i==="reset",{iScale:r,vScale:a,_stacked:c,_dataset:l}=this._cachedMeta,{sharedOptions:u,includeOptions:h}=this._getSharedOptions(n,i),d=r.axis,f=a.axis,{spanGaps:p,segment:g}=this.options,m=He(p)?p:Number.POSITIVE_INFINITY,b=this.chart._animationsDisabled||o||i==="none",x=n+s,M=t.length;let S=n>0&&this.getParsed(n-1);for(let k=0;k<M;++k){const C=t[k],T=b?C:{};if(k<n||k>=x){T.skip=!0;continue}const z=this.getParsed(k),O=N(z[f]),D=T[d]=r.getPixelForValue(z[d],k),L=T[f]=o||O?a.getBasePixel():a.getPixelForValue(c?this.applyStack(a,z,c):z[f],k);T.skip=isNaN(D)||isNaN(L)||O,T.stop=k>0&&Math.abs(z[d]-S[d])>m,g&&(T.parsed=z,T.raw=l.data[k]),h&&(T.options=u||this.resolveDataElementOptions(k,C.active?"active":i)),b||this.updateElement(C,k,T,i),S=z}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,s=n.options&&n.options.borderWidth||0,i=t.data||[];if(!i.length)return s;const o=i[0].size(this.resolveDataElementOptions(0)),r=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(s,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}P(es,"id","line"),P(es,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),P(es,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class hn extends $t{constructor(t,n){super(t,n),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(t){const n=this._cachedMeta,s=this.chart,i=s.data.labels||[],o=An(n._parsed[t].r,s.options.locale);return{label:i[t]||"",value:o}}parseObjectData(t,n,s,i){return Ic.bind(this)(t,n,s,i)}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((s,i)=>{const o=this.getParsed(i).r;!isNaN(o)&&this.chart.getDataVisibility(i)&&(o<n.min&&(n.min=o),o>n.max&&(n.max=o))}),n}_updateRadius(){const t=this.chart,n=t.chartArea,s=t.options,i=Math.min(n.right-n.left,n.bottom-n.top),o=Math.max(i/2,0),r=Math.max(s.cutoutPercentage?o/100*s.cutoutPercentage:1,0),a=(o-r)/t.getVisibleDatasetCount();this.outerRadius=o-a*this.index,this.innerRadius=this.outerRadius-a}updateElements(t,n,s,i){const o=i==="reset",r=this.chart,c=r.options.animation,l=this._cachedMeta.rScale,u=l.xCenter,h=l.yCenter,d=l.getIndexAngle(0)-.5*Z;let f=d,p;const g=360/this.countVisibleElements();for(p=0;p<n;++p)f+=this._computeAngle(p,i,g);for(p=n;p<n+s;p++){const m=t[p];let b=f,x=f+this._computeAngle(p,i,g),M=r.getDataVisibility(p)?l.getDistanceFromCenterForValue(this.getParsed(p).r):0;f=x,o&&(c.animateScale&&(M=0),c.animateRotate&&(b=x=d));const S={x:u,y:h,innerRadius:0,outerRadius:M,startAngle:b,endAngle:x,options:this.resolveDataElementOptions(p,m.active?"active":i)};this.updateElement(m,p,S,i)}}countVisibleElements(){const t=this._cachedMeta;let n=0;return t.data.forEach((s,i)=>{!isNaN(this.getParsed(i).r)&&this.chart.getDataVisibility(i)&&n++}),n}_computeAngle(t,n,s){return this.chart.getDataVisibility(t)?Lt(this.resolveDataElementOptions(t,n).angle||s):0}}P(hn,"id","polarArea"),P(hn,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),P(hn,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const n=t.data;if(n.labels.length&&n.datasets.length){const{labels:{pointStyle:s,color:i}}=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:i,lineWidth:c.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(r),index:r}})}return[]}},onClick(t,n,s){s.chart.toggleDataVisibility(n.index),s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class ai extends xe{}P(ai,"id","pie"),P(ai,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});class ns extends $t{getLabelAndValue(t){const n=this._cachedMeta.vScale,s=this.getParsed(t);return{label:n.getLabels()[t],value:""+n.getLabelForValue(s[n.axis])}}parseObjectData(t,n,s,i){return Ic.bind(this)(t,n,s,i)}update(t){const n=this._cachedMeta,s=n.dataset,i=n.data||[],o=n.iScale.getLabels();if(s.points=i,t!=="resize"){const r=this.resolveDatasetElementOptions(t);this.options.showLine||(r.borderWidth=0);const a={_loop:!0,_fullLoop:o.length===i.length,options:r};this.updateElement(s,void 0,a,t)}this.updateElements(i,0,i.length,t)}updateElements(t,n,s,i){const o=this._cachedMeta.rScale,r=i==="reset";for(let a=n;a<n+s;a++){const c=t[a],l=this.resolveDataElementOptions(a,c.active?"active":i),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,i)}}}P(ns,"id","radar"),P(ns,"defaults",{datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:!0,elements:{line:{fill:"start"}}}),P(ns,"overrides",{aspectRatio:1,scales:{r:{type:"radialLinear"}}});class ss extends $t{getLabelAndValue(t){const n=this._cachedMeta,s=this.chart.data.labels||[],{xScale:i,yScale:o}=n,r=this.getParsed(t),a=i.getLabelForValue(r.x),c=o.getLabelForValue(r.y);return{label:s[t]||"",value:"("+a+", "+c+")"}}update(t){const n=this._cachedMeta,{data:s=[]}=n,i=this.chart._animationsDisabled;let{start:o,count:r}=Sc(n,s,i);if(this._drawStart=o,this._drawCount=r,Mc(n)&&(o=0,r=s.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=s;const l=this.resolveDatasetElementOptions(t);l.segment=this.options.segment,this.updateElement(a,void 0,{animated:!i,options:l},t)}else this.datasetElementType&&(delete n.dataset,this.datasetElementType=!1);this.updateElements(s,o,r,t)}addElements(){const{showLine:t}=this.options;!this.datasetElementType&&t&&(this.datasetElementType=this.chart.registry.getElement("line")),super.addElements()}updateElements(t,n,s,i){const o=i==="reset",{iScale:r,vScale:a,_stacked:c,_dataset:l}=this._cachedMeta,u=this.resolveDataElementOptions(n,i),h=this.getSharedOptions(u),d=this.includeOptions(i,h),f=r.axis,p=a.axis,{spanGaps:g,segment:m}=this.options,b=He(g)?g:Number.POSITIVE_INFINITY,x=this.chart._animationsDisabled||o||i==="none";let M=n>0&&this.getParsed(n-1);for(let S=n;S<n+s;++S){const k=t[S],C=this.getParsed(S),T=x?k:{},z=N(C[p]),O=T[f]=r.getPixelForValue(C[f],S),D=T[p]=o||z?a.getBasePixel():a.getPixelForValue(c?this.applyStack(a,C,c):C[p],S);T.skip=isNaN(O)||isNaN(D)||z,T.stop=S>0&&Math.abs(C[f]-M[f])>b,m&&(T.parsed=C,T.raw=l.data[S]),d&&(T.options=h||this.resolveDataElementOptions(S,k.active?"active":i)),x||this.updateElement(k,S,T,i),M=C}this.updateSharedOptions(h,i,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 s=t.dataset,i=s.options&&s.options.borderWidth||0;if(!n.length)return i;const o=n[0].size(this.resolveDataElementOptions(0)),r=n[n.length-1].size(this.resolveDataElementOptions(n.length-1));return Math.max(i,o,r)/2}}P(ss,"id","scatter"),P(ss,"defaults",{datasetElementType:!1,dataElementType:"point",showLine:!1,fill:!1}),P(ss,"overrides",{interaction:{mode:"point"},scales:{x:{type:"linear"},y:{type:"linear"}}});var L_=Object.freeze({__proto__:null,BarController:Qn,BubbleController:ts,DoughnutController:xe,LineController:es,PieController:ai,PolarAreaController:hn,RadarController:ns,ScatterController:ss});function ge(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class uo{constructor(t){P(this,"options");this.options=t||{}}static override(t){Object.assign(uo.prototype,t)}init(){}formats(){return ge()}parse(){return ge()}format(){return ge()}add(){return ge()}diff(){return ge()}startOf(){return ge()}endOf(){return ge()}}var $_={_date:uo};function N_(e,t,n,s){const{controller:i,data:o,_sorted:r}=e,a=i._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?rb:Yt;if(s){if(i._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}=i._cachedMeta,{_parsed:d}=e,f=d.slice(0,u.lo+1).reverse().findIndex(g=>!N(g[h.axis]));u.lo-=Math.max(0,f);const p=d.slice(u.hi).findIndex(g=>!N(g[h.axis]));u.hi+=Math.max(0,p)}return u}}return{lo:0,hi:o.length-1}}function Is(e,t,n,s,i){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}=N_(o[a],t,r,i);for(let f=h;f<=d;++f){const p=u[f];p.skip||s(p,l,f)}}}function F_(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(s,i){const o=t?Math.abs(s.x-i.x):0,r=n?Math.abs(s.y-i.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function Ws(e,t,n,s,i){const o=[];return!i&&!e.isPointInArea(t)||Is(e,n,t,function(a,c,l){!i&&!Jt(a,e.chartArea,0)||a.inRange(t.x,t.y,s)&&o.push({element:a,datasetIndex:c,index:l})},!0),o}function H_(e,t,n,s){let i=[];function o(r,a,c){const{startAngle:l,endAngle:u}=r.getProps(["startAngle","endAngle"],s),{angle:h}=yc(r,{x:t.x,y:t.y});_n(h,l,u)&&i.push({element:r,datasetIndex:a,index:c})}return Is(e,n,t,o),i}function j_(e,t,n,s,i,o){let r=[];const a=F_(n);let c=Number.POSITIVE_INFINITY;function l(u,h,d){const f=u.inRange(t.x,t.y,i);if(s&&!f)return;const p=u.getCenterPoint(i);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 Is(e,n,t,l),r}function qs(e,t,n,s,i,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!s?H_(e,t,n,i):j_(e,t,n,s,i,o)}function pr(e,t,n,s,i){const o=[],r=n==="x"?"inXRange":"inYRange";let a=!1;return Is(e,n,t,(c,l,u)=>{c[r]&&c[r](t[n],i)&&(o.push({element:c,datasetIndex:l,index:u}),a=a||c.inRange(t.x,t.y,i))}),s&&!a?[]:o}var B_={modes:{index(e,t,n,s){const i=_e(t,e),o=n.axis||"x",r=n.includeInvisible||!1,a=n.intersect?Ws(e,i,o,s,r):qs(e,i,o,!1,s,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,s){const i=_e(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;let a=n.intersect?Ws(e,i,o,s,r):qs(e,i,o,!1,s,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,s){const i=_e(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return Ws(e,i,o,s,r)},nearest(e,t,n,s){const i=_e(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return qs(e,i,o,n.intersect,s,r)},x(e,t,n,s){const i=_e(t,e);return pr(e,i,"x",n.intersect,s)},y(e,t,n,s){const i=_e(t,e);return pr(e,i,"y",n.intersect,s)}}};const Vc=["left","top","right","bottom"];function Je(e,t){return e.filter(n=>n.pos===t)}function gr(e,t){return e.filter(n=>Vc.indexOf(n.pos)===-1&&n.box.axis===t)}function Ke(e,t){return e.sort((n,s)=>{const i=t?s:n,o=t?n:s;return i.weight===o.weight?i.index-o.index:i.weight-o.weight})}function Z_(e){const t=[];let n,s,i,o,r,a;for(n=0,s=(e||[]).length;n<s;++n)i=e[n],{position:o,options:{stack:r,stackWeight:a=1}}=i,t.push({index:n,box:i,pos:o,horizontal:i.isHorizontal(),weight:i.weight,stack:r&&o+r,stackWeight:a});return t}function V_(e){const t={};for(const n of e){const{stack:s,pos:i,stackWeight:o}=n;if(!s||!Vc.includes(i))continue;const r=t[s]||(t[s]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function W_(e,t){const n=V_(e),{vBoxMaxWidth:s,hBoxMaxHeight:i}=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*s:c&&t.availableWidth,a.height=i):(a.width=s,a.height=u?u*i:c&&t.availableHeight)}return n}function q_(e){const t=Z_(e),n=Ke(t.filter(l=>l.box.fullSize),!0),s=Ke(Je(t,"left"),!0),i=Ke(Je(t,"right")),o=Ke(Je(t,"top"),!0),r=Ke(Je(t,"bottom")),a=gr(t,"x"),c=gr(t,"y");return{fullSize:n,leftAndTop:s.concat(o),rightAndBottom:i.concat(c).concat(r).concat(a),chartArea:Je(t,"chartArea"),vertical:s.concat(i).concat(c),horizontal:o.concat(r).concat(a)}}function mr(e,t,n,s){return Math.max(e[n],t[n])+Math.max(e[s],t[s])}function Wc(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 U_(e,t,n,s){const{pos:i,box:o}=n,r=e.maxPadding;if(!F(i)){n.size&&(e[i]-=n.size);const h=s[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[i]+=n.size}o.getPadding&&Wc(r,o.getPadding());const a=Math.max(0,t.outerWidth-mr(r,e,"left","right")),c=Math.max(0,t.outerHeight-mr(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 Y_(e){const t=e.maxPadding;function n(s){const i=Math.max(t[s]-e[s],0);return e[s]+=i,i}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function J_(e,t){const n=t.maxPadding;function s(i){const o={left:0,top:0,right:0,bottom:0};return i.forEach(r=>{o[r]=Math.max(t[r],n[r])}),o}return s(e?["left","right"]:["top","bottom"])}function nn(e,t,n,s){const i=[];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,J_(a.horizontal,t));const{same:h,other:d}=U_(t,n,a,s);l|=h&&i.length,u=u||d,c.fullSize||i.push(a)}return l&&nn(i,t,n,s)||u}function Wn(e,t,n,s,i){e.top=n,e.left=t,e.right=t+s,e.bottom=n+i,e.width=s,e.height=i}function br(e,t,n,s){const i=n.padding;let{x:o,y:r}=t;for(const a of e){const c=a.box,l=s[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;bn(l.start)&&(r=l.start),c.fullSize?Wn(c,i.left,r,n.outerWidth-i.right-i.left,d):Wn(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;bn(l.start)&&(o=l.start),c.fullSize?Wn(c,o,i.top,d,n.outerHeight-i.bottom-i.top):Wn(c,o,t.top+l.placed,d,h),l.start=o,l.placed+=h,o=c.right}}t.x=o,t.y=r}var xt={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,s){if(!e)return;const i=vt(e.options.layout.padding),o=Math.max(t-i.width,0),r=Math.max(n-i.height,0),a=q_(e.boxes),c=a.vertical,l=a.horizontal;U(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:i,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),d=Object.assign({},i);Wc(d,vt(s));const f=Object.assign({maxPadding:d,w:o,h:r,x:i.left,y:i.top},i),p=W_(c.concat(l),h);nn(a.fullSize,f,h,p),nn(c,f,h,p),nn(l,f,h,p)&&nn(c,f,h,p),Y_(f),br(a.leftAndTop,f,h,p),f.x+=f.w,f.y+=f.h,br(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},U(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 qc{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,s){}removeEventListener(t,n,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,s,i){return n=Math.max(0,n||t.width),s=s||t.height,{width:n,height:Math.max(0,i?Math.floor(n/i):s)}}isAttached(t){return!0}updateConfig(t){}}class K_ extends qc{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const is="$chartjs",X_={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},_r=e=>e===null||e==="";function G_(e,t){const n=e.style,s=e.getAttribute("height"),i=e.getAttribute("width");if(e[is]={initial:{height:s,width:i,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",_r(i)){const o=er(e,"width");o!==void 0&&(e.width=o)}if(_r(s))if(e.style.height==="")e.height=e.width/(t||2);else{const o=er(e,"height");o!==void 0&&(e.height=o)}return e}const Uc=Qb?{passive:!0}:!1;function Q_(e,t,n){e&&e.addEventListener(t,n,Uc)}function ty(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,Uc)}function ey(e,t){const n=X_[e.type]||e.type,{x:s,y:i}=_e(e,t);return{type:n,chart:t,native:e,x:s!==void 0?s:null,y:i!==void 0?i:null}}function _s(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function ny(e,t,n){const s=e.canvas,i=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||_s(a.addedNodes,s),r=r&&!_s(a.removedNodes,s);r&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}function sy(e,t,n){const s=e.canvas,i=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||_s(a.removedNodes,s),r=r&&!_s(a.addedNodes,s);r&&n()});return i.observe(document,{childList:!0,subtree:!0}),i}const xn=new Map;let yr=0;function Yc(){const e=window.devicePixelRatio;e!==yr&&(yr=e,xn.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function iy(e,t){xn.size||window.addEventListener("resize",Yc),xn.set(e,t)}function oy(e){xn.delete(e),xn.size||window.removeEventListener("resize",Yc)}function ry(e,t,n){const s=e.canvas,i=s&&lo(s);if(!i)return;const o=wc((a,c)=>{const l=i.clientWidth;n(a,c),l<i.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(i),iy(e,o),r}function Us(e,t,n){n&&n.disconnect(),t==="resize"&&oy(e)}function ay(e,t,n){const s=e.canvas,i=wc(o=>{e.ctx!==null&&n(ey(o,e))},e);return Q_(s,t,i),i}class cy extends qc{acquireContext(t,n){const s=t&&t.getContext&&t.getContext("2d");return s&&s.canvas===t?(G_(t,n),s):null}releaseContext(t){const n=t.canvas;if(!n[is])return!1;const s=n[is].initial;["height","width"].forEach(o=>{const r=s[o];N(r)?n.removeAttribute(o):n.setAttribute(o,r)});const i=s.style||{};return Object.keys(i).forEach(o=>{n.style[o]=i[o]}),n.width=n.width,delete n[is],!0}addEventListener(t,n,s){this.removeEventListener(t,n);const i=t.$proxies||(t.$proxies={}),r={attach:ny,detach:sy,resize:ry}[n]||ay;i[n]=r(t,n,s)}removeEventListener(t,n){const s=t.$proxies||(t.$proxies={}),i=s[n];if(!i)return;({attach:Us,detach:Us,resize:Us}[n]||ty)(t,n,i),s[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,s,i){return Gb(t,n,s,i)}isAttached(t){const n=t&&lo(t);return!!(n&&n.isConnected)}}function ly(e){return!co()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?K_:cy}class Nt{constructor(){P(this,"x");P(this,"y");P(this,"active",!1);P(this,"options");P(this,"$animations")}tooltipPosition(t){const{x:n,y:s}=this.getProps(["x","y"],t);return{x:n,y:s}}hasValue(){return He(this.x)&&He(this.y)}getProps(t,n){const s=this.$animations;if(!n||!s)return this;const i={};return t.forEach(o=>{i[o]=s[o]&&s[o].active()?s[o]._to:this[o]}),i}}P(Nt,"defaults",{}),P(Nt,"defaultRoutes");function uy(e,t){const n=e.options.ticks,s=hy(e),i=Math.min(n.maxTicksLimit||s,s),o=n.major.enabled?fy(t):[],r=o.length,a=o[0],c=o[r-1],l=[];if(r>i)return py(t,l,o,r/i),l;const u=dy(o,t,i);if(r>0){let h,d;const f=r>1?Math.round((c-a)/(r-1)):null;for(qn(t,l,u,N(f)?0:a-f,a),h=0,d=r-1;h<d;h++)qn(t,l,u,o[h],o[h+1]);return qn(t,l,u,c,N(f)?t.length:c+f),l}return qn(t,l,u),l}function hy(e){const t=e.options.offset,n=e._tickSize(),s=e._length/n+(t?0:1),i=e._maxLength/n;return Math.floor(Math.min(s,i))}function dy(e,t,n){const s=gy(e),i=t.length/n;if(!s)return Math.max(i,1);const o=eb(s);for(let r=0,a=o.length-1;r<a;r++){const c=o[r];if(c>i)return c}return Math.max(i,1)}function fy(e){const t=[];let n,s;for(n=0,s=e.length;n<s;n++)e[n].major&&t.push(n);return t}function py(e,t,n,s){let i=0,o=n[0],r;for(s=Math.ceil(s),r=0;r<e.length;r++)r===o&&(t.push(e[r]),i++,o=n[i*s])}function qn(e,t,n,s,i){const o=E(s,0),r=Math.min(E(i,e.length),e.length);let a=0,c,l,u;for(n=Math.ceil(n),i&&(c=i-s,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 gy(e){const t=e.length;let n,s;if(t<2)return!1;for(s=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==s)return!1;return s}const my=e=>e==="left"?"right":e==="right"?"left":e,xr=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,vr=(e,t)=>Math.min(t||e,e);function kr(e,t){const n=[],s=e.length/t,i=e.length;let o=0;for(;o<i;o+=s)n.push(e[Math.floor(o)]);return n}function by(e,t,n){const s=e.ticks.length,i=Math.min(t,s-1),o=e._startPixel,r=e._endPixel,a=1e-6;let c=e.getPixelForTick(i),l;if(!(n&&(s===1?l=Math.max(c-o,r-c):t===0?l=(e.getPixelForTick(1)-c)/2:l=(c-e.getPixelForTick(i-1))/2,c+=i<t?l:-l,c<o-a||c>r+a)))return c}function _y(e,t){U(e,n=>{const s=n.gc,i=s.length/2;let o;if(i>t){for(o=0;o<i;++o)delete n.data[s[o]];s.splice(0,i)}})}function Xe(e){return e.drawTicks?e.tickLength:0}function wr(e,t){if(!e.display)return 0;const n=dt(e.font,t),s=vt(e.padding);return(nt(e.text)?e.text.length:1)*n.lineHeight+s.height}function yy(e,t){return le(e,{scale:t,type:"scale"})}function xy(e,t,n){return le(e,{tick:n,index:t,type:"tick"})}function vy(e,t,n){let s=no(e);return(n&&t!=="right"||!n&&t==="right")&&(s=my(s)),s}function ky(e,t,n,s){const{top:i,left:o,bottom:r,right:a,chart:c}=e,{chartArea:l,scales:u}=c;let h=0,d,f,p;const g=r-i,m=a-o;if(e.isHorizontal()){if(f=_t(s,o,a),F(n)){const b=Object.keys(n)[0],x=n[b];p=u[b].getPixelForValue(x)+g-t}else n==="center"?p=(l.bottom+l.top)/2+g-t:p=xr(e,n,t);d=a-o}else{if(F(n)){const b=Object.keys(n)[0],x=n[b];f=u[b].getPixelForValue(x)-m+t}else n==="center"?f=(l.left+l.right)/2-m+t:f=xr(e,n,t);p=_t(s,r,i),h=n==="left"?-lt:lt}return{titleX:f,titleY:p,maxWidth:d,rotation:h}}class Te extends Nt{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:s,_suggestedMax:i}=this;return t=Ct(t,Number.POSITIVE_INFINITY),n=Ct(n,Number.NEGATIVE_INFINITY),s=Ct(s,Number.POSITIVE_INFINITY),i=Ct(i,Number.NEGATIVE_INFINITY),{min:Ct(t,s),max:Ct(n,i),minDefined:at(t),maxDefined:at(n)}}getMinMax(t){let{min:n,max:s,minDefined:i,maxDefined:o}=this.getUserBounds(),r;if(i&&o)return{min:n,max:s};const a=this.getMatchingVisibleMetas();for(let c=0,l=a.length;c<l;++c)r=a[c].controller.getMinMax(this,t),i||(n=Math.min(n,r.min)),o||(s=Math.max(s,r.max));return n=o&&n>s?s:n,s=i&&n>s?n:s,{min:Ct(n,Ct(s,n)),max:Ct(s,Ct(n,s))}}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(){K(this.options.beforeUpdate,[this])}update(t,n,s){const{beginAtZero:i,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=Ob(this,o,i),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const c=a<this.ticks.length;this._convertTicksToLabels(c?kr(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=uy(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,s;this.isHorizontal()?(n=this.left,s=this.right):(n=this.top,s=this.bottom,t=!t),this._startPixel=n,this._endPixel=s,this._reversePixels=t,this._length=s-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){K(this.options.afterUpdate,[this])}beforeSetDimensions(){K(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(){K(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),K(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){K(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let s,i,o;for(s=0,i=t.length;s<i;s++)o=t[s],o.label=K(n.callback,[o.value,s,t],this)}afterTickToLabelConversion(){K(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){K(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,s=vr(this.ticks.length,t.ticks.maxTicksLimit),i=n.minRotation||0,o=n.maxRotation;let r=i,a,c,l;if(!this._isVisible()||!n.display||i>=o||s<=1||!this.isHorizontal()){this.labelRotation=i;return}const u=this._getLabelSizes(),h=u.widest.width,d=u.highest.height,f=ft(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/s:f/(s-1),h+6>a&&(a=f/(s-(t.offset?.5:1)),c=this.maxHeight-Xe(t.grid)-n.padding-wr(t.title,this.chart.options.font),l=Math.sqrt(h*h+d*d),r=to(Math.min(Math.asin(ft((u.highest.height+6)/a,-1,1)),Math.asin(ft(c/l,-1,1))-Math.asin(ft(d/l,-1,1)))),r=Math.max(i,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){K(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){K(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:s,title:i,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const c=wr(i,n.options.font);if(a?(t.width=this.maxWidth,t.height=Xe(o)+c):(t.height=this.maxHeight,t.width=Xe(o)+c),s.display&&this.ticks.length){const{first:l,last:u,widest:h,highest:d}=this._getLabelSizes(),f=s.padding*2,p=Lt(this.labelRotation),g=Math.cos(p),m=Math.sin(p);if(a){const b=s.mirror?0:m*h.width+g*d.height;t.height=Math.min(this.maxHeight,t.height+b+f)}else{const b=s.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,s,i){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=i*t.width,f=s*n.height):(d=s*t.height,f=i*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(){K(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,s;for(n=0,s=t.length;n<s;n++)N(t[n].label)&&(t.splice(n,1),s--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let s=this.ticks;n<s.length&&(s=kr(s,n)),this._labelSizes=t=this._computeLabelSizes(s,s.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,s){const{ctx:i,_longestTextCache:o}=this,r=[],a=[],c=Math.floor(n/vr(n,s));let l=0,u=0,h,d,f,p,g,m,b,x,M,S,k;for(h=0;h<n;h+=c){if(p=t[h].label,g=this._resolveTickFontOptions(h),i.font=m=g.string,b=o[m]=o[m]||{data:{},gc:[]},x=g.lineHeight,M=S=0,!N(p)&&!nt(p))M=ms(i,b.data,b.gc,M,p),S=x;else if(nt(p))for(d=0,f=p.length;d<f;++d)k=p[d],!N(k)&&!nt(k)&&(M=ms(i,b.data,b.gc,M,k),S+=x);r.push(M),a.push(S),l=Math.max(M,l),u=Math.max(S,u)}_y(o,n);const C=r.indexOf(l),T=a.indexOf(u),z=O=>({width:r[O]||0,height:a[O]||0});return{first:z(0),last:z(n-1),widest:z(C),highest:z(T),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 ob(this._alignToPixels?pe(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 s=n[t];return s.$context||(s.$context=xy(this.getContext(),t,s))}return this.$context||(this.$context=yy(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=Lt(this.labelRotation),s=Math.abs(Math.cos(n)),i=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*s>a*i?a/s:c/i:c*i<a*s?c/s:a/i}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,s=this.chart,i=this.options,{grid:o,position:r,border:a}=i,c=o.offset,l=this.isHorizontal(),h=this.ticks.length+(c?1:0),d=Xe(o),f=[],p=a.setContext(this.getContext()),g=p.display?p.width:0,m=g/2,b=function(et){return pe(s,et,g)};let x,M,S,k,C,T,z,O,D,L,j,pt;if(r==="top")x=b(this.bottom),T=this.bottom-d,O=x-m,L=b(t.top)+m,pt=t.bottom;else if(r==="bottom")x=b(this.top),L=t.top,pt=b(t.bottom)-m,T=x+m,O=this.top+d;else if(r==="left")x=b(this.right),C=this.right-d,z=x-m,D=b(t.left)+m,j=t.right;else if(r==="right")x=b(this.left),D=t.left,j=b(t.right)-m,C=x+m,z=this.left+d;else if(n==="x"){if(r==="center")x=b((t.top+t.bottom)/2+.5);else if(F(r)){const et=Object.keys(r)[0],ct=r[et];x=b(this.chart.scales[et].getPixelForValue(ct))}L=t.top,pt=t.bottom,T=x+m,O=T+d}else if(n==="y"){if(r==="center")x=b((t.left+t.right)/2);else if(F(r)){const et=Object.keys(r)[0],ct=r[et];x=b(this.chart.scales[et].getPixelForValue(ct))}C=x-m,z=C-d,D=t.left,j=t.right}const Tt=E(i.ticks.maxTicksLimit,h),Y=Math.max(1,Math.ceil(h/Tt));for(M=0;M<h;M+=Y){const et=this.getContext(M),ct=o.setContext(et),Dt=a.setContext(et),bt=ct.lineWidth,Ce=ct.color,En=Dt.dash||[],ze=Dt.dashOffset,qe=ct.tickWidth,ue=ct.tickColor,Ue=ct.tickBorderDash||[],he=ct.tickBorderDashOffset;S=by(this,M,c),S!==void 0&&(k=pe(s,S,bt),l?C=z=D=j=k:T=O=L=pt=k,f.push({tx1:C,ty1:T,tx2:z,ty2:O,x1:D,y1:L,x2:j,y2:pt,width:bt,color:Ce,borderDash:En,borderDashOffset:ze,tickWidth:qe,tickColor:ue,tickBorderDash:Ue,tickBorderDashOffset:he}))}return this._ticksLength=h,this._borderValue=x,f}_computeLabelItems(t){const n=this.axis,s=this.options,{position:i,ticks:o}=s,r=this.isHorizontal(),a=this.ticks,{align:c,crossAlign:l,padding:u,mirror:h}=o,d=Xe(s.grid),f=d+u,p=h?-u:f,g=-Lt(this.labelRotation),m=[];let b,x,M,S,k,C,T,z,O,D,L,j,pt="middle";if(i==="top")C=this.bottom-p,T=this._getXAxisLabelAlignment();else if(i==="bottom")C=this.top+p,T=this._getXAxisLabelAlignment();else if(i==="left"){const Y=this._getYAxisLabelAlignment(d);T=Y.textAlign,k=Y.x}else if(i==="right"){const Y=this._getYAxisLabelAlignment(d);T=Y.textAlign,k=Y.x}else if(n==="x"){if(i==="center")C=(t.top+t.bottom)/2+f;else if(F(i)){const Y=Object.keys(i)[0],et=i[Y];C=this.chart.scales[Y].getPixelForValue(et)+f}T=this._getXAxisLabelAlignment()}else if(n==="y"){if(i==="center")k=(t.left+t.right)/2-f;else if(F(i)){const Y=Object.keys(i)[0],et=i[Y];k=this.chart.scales[Y].getPixelForValue(et)}T=this._getYAxisLabelAlignment(d).textAlign}n==="y"&&(c==="start"?pt="top":c==="end"&&(pt="bottom"));const Tt=this._getLabelSizes();for(b=0,x=a.length;b<x;++b){M=a[b],S=M.label;const Y=o.setContext(this.getContext(b));z=this.getPixelForTick(b)+o.labelOffset,O=this._resolveTickFontOptions(b),D=O.lineHeight,L=nt(S)?S.length:1;const et=L/2,ct=Y.color,Dt=Y.textStrokeColor,bt=Y.textStrokeWidth;let Ce=T;r?(k=z,T==="inner"&&(b===x-1?Ce=this.options.reverse?"left":"right":b===0?Ce=this.options.reverse?"right":"left":Ce="center"),i==="top"?l==="near"||g!==0?j=-L*D+D/2:l==="center"?j=-Tt.highest.height/2-et*D+D:j=-Tt.highest.height+D/2:l==="near"||g!==0?j=D/2:l==="center"?j=Tt.highest.height/2-et*D:j=Tt.highest.height-L*D,h&&(j*=-1),g!==0&&!Y.showLabelBackdrop&&(k+=D/2*Math.sin(g))):(C=z,j=(1-L)*D/2);let En;if(Y.showLabelBackdrop){const ze=vt(Y.backdropPadding),qe=Tt.heights[b],ue=Tt.widths[b];let Ue=j-ze.top,he=0-ze.left;switch(pt){case"middle":Ue-=qe/2;break;case"bottom":Ue-=qe;break}switch(T){case"center":he-=ue/2;break;case"right":he-=ue;break;case"inner":b===x-1?he-=ue:b>0&&(he-=ue/2);break}En={left:he,top:Ue,width:ue+ze.width,height:qe+ze.height,color:Y.backdropColor}}m.push({label:S,font:O,textOffset:j,options:{rotation:g,color:ct,strokeColor:Dt,strokeWidth:bt,textAlign:Ce,textBaseline:pt,translation:[k,C],backdrop:En}})}return m}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-Lt(this.labelRotation))return t==="top"?"left":"right";let i="center";return n.align==="start"?i="left":n.align==="end"?i="right":n.align==="inner"&&(i="inner"),i}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:s,mirror:i,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,c=r.widest.width;let l,u;return n==="left"?i?(u=this.right+o,s==="near"?l="left":s==="center"?(l="center",u+=c/2):(l="right",u+=c)):(u=this.right-a,s==="near"?l="right":s==="center"?(l="center",u-=c/2):(l="left",u=this.left)):n==="right"?i?(u=this.left+o,s==="near"?l="right":s==="center"?(l="center",u-=c/2):(l="left",u-=c)):(u=this.left+a,s==="near"?l="left":s==="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:s,top:i,width:o,height:r}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(s,i,o,r),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const i=this.ticks.findIndex(o=>o.value===t);return i>=0?n.setContext(this.getContext(i)).lineWidth:0}drawGrid(t){const n=this.options.grid,s=this.ctx,i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(c,l,u)=>{!u.width||!u.color||(s.save(),s.lineWidth=u.width,s.strokeStyle=u.color,s.setLineDash(u.borderDash||[]),s.lineDashOffset=u.borderDashOffset,s.beginPath(),s.moveTo(c.x,c.y),s.lineTo(l.x,l.y),s.stroke(),s.restore())};if(n.display)for(o=0,r=i.length;o<r;++o){const c=i[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:s,grid:i}}=this,o=s.setContext(this.getContext()),r=s.display?o.width:0;if(!r)return;const a=i.setContext(this.getContext(0)).lineWidth,c=this._borderValue;let l,u,h,d;this.isHorizontal()?(l=pe(t,this.left,r)-r/2,u=pe(t,this.right,a)+a/2,h=d=c):(h=pe(t,this.top,r)-r/2,d=pe(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 s=this.ctx,i=this._computeLabelArea();i&&Os(s,i);const o=this.getLabelItems(t);for(const r of o){const a=r.options,c=r.font,l=r.label,u=r.textOffset;Me(s,l,0,u,c,a)}i&&Rs(s)}drawTitle(){const{ctx:t,options:{position:n,title:s,reverse:i}}=this;if(!s.display)return;const o=dt(s.font),r=vt(s.padding),a=s.align;let c=o.lineHeight/2;n==="bottom"||n==="center"||F(n)?(c+=r.bottom,nt(s.text)&&(c+=o.lineHeight*(s.text.length-1))):c+=r.top;const{titleX:l,titleY:u,maxWidth:h,rotation:d}=ky(this,c,n,a);Me(t,s.text,0,0,o,{color:s.color,maxWidth:h,rotation:d,textAlign:vy(a,n,i),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,s=E(t.grid&&t.grid.z,-1),i=E(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==Te.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:s,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),s=this.axis+"AxisID",i=[];let o,r;for(o=0,r=n.length;o<r;++o){const a=n[o];a[s]===this.id&&(!t||a.type===t)&&i.push(a)}return i}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return dt(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class Un{constructor(t,n,s){this.type=t,this.scope=n,this.override=s,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 s;My(n)&&(s=this.register(n));const i=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in i||(i[o]=t,wy(t,r,s),this.override&&st.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const n=this.items,s=t.id,i=this.scope;s in n&&delete n[s],i&&s in st[i]&&(delete st[i][s],this.override&&delete Se[s])}}function wy(e,t,n){const s=mn(Object.create(null),[n?st.get(n):{},st.get(t),e.defaults]);st.set(t,s),e.defaultRoutes&&Sy(t,e.defaultRoutes),e.descriptors&&st.describe(t,e.descriptors)}function Sy(e,t){Object.keys(t).forEach(n=>{const s=n.split("."),i=s.pop(),o=[e].concat(s).join("."),r=t[n].split("."),a=r.pop(),c=r.join(".");st.route(o,i,c,a)})}function My(e){return"id"in e&&"defaults"in e}class Py{constructor(){this.controllers=new Un($t,"datasets",!0),this.elements=new Un(Nt,"elements"),this.plugins=new Un(Object,"plugins"),this.scales=new Un(Te,"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,s){[...n].forEach(i=>{const o=s||this._getRegistryForType(i);s||o.isForType(i)||o===this.plugins&&i.id?this._exec(t,o,i):U(i,r=>{const a=s||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,n,s){const i=Qi(t);K(s["before"+i],[],s),n[t](s),K(s["after"+i],[],s)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const s=this._typedRegistries[n];if(s.isForType(t))return s}return this.plugins}_get(t,n,s){const i=n.get(t);if(i===void 0)throw new Error('"'+t+'" is not a registered '+s+".");return i}}var Ht=new Py;class Ty{constructor(){this._init=void 0}notify(t,n,s,i){if(n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install")),this._init===void 0)return;const o=i?this._descriptors(t).filter(i):this._descriptors(t),r=this._notify(o,t,n,s);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall"),this._init=void 0),r}_notify(t,n,s,i){i=i||{};for(const o of t){const r=o.plugin,a=r[s],c=[n,i,o.options];if(K(a,c,r)===!1&&i.cancelable)return!1}return!0}invalidate(){N(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 s=t&&t.config,i=E(s.options&&s.options.plugins,{}),o=Cy(s);return i===!1&&!n?[]:Oy(t,o,i,n)}_notifyStateChanges(t){const n=this._oldCache||[],s=this._cache,i=(o,r)=>o.filter(a=>!r.some(c=>a.plugin.id===c.plugin.id));this._notify(i(n,s),t,"stop"),this._notify(i(s,n),t,"start")}}function Cy(e){const t={},n=[],s=Object.keys(Ht.plugins.items);for(let o=0;o<s.length;o++)n.push(Ht.getPlugin(s[o]));const i=e.plugins||[];for(let o=0;o<i.length;o++){const r=i[o];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function zy(e,t){return!t&&e===!1?null:e===!0?{}:e}function Oy(e,{plugins:t,localIds:n},s,i){const o=[],r=e.getContext();for(const a of t){const c=a.id,l=zy(s[c],i);l!==null&&o.push({plugin:a,options:Ry(e.config,{plugin:a,local:n[c]},l,r)})}return o}function Ry(e,{plugin:t,local:n},s,i){const o=e.pluginScopeKeys(t),r=e.getOptionScopes(s,o);return n&&t.defaults&&r.push(t.defaults),e.createResolver(r,i,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function ci(e,t){const n=st.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function Ay(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function Iy(e,t){return e===t?"_index_":"_value_"}function Sr(e){if(e==="x"||e==="y"||e==="r")return e}function Ey(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function li(e,...t){if(Sr(e))return e;for(const n of t){const s=n.axis||Ey(n.position)||e.length>1&&Sr(e[0].toLowerCase());if(s)return s}throw new Error(`Cannot determine type of '${e}' axis. Please provide 'axis' or 'position' option.`)}function Mr(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function Dy(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(s=>s.xAxisID===e||s.yAxisID===e);if(n.length)return Mr(e,"x",n[0])||Mr(e,"y",n[0])}return{}}function Ly(e,t){const n=Se[e.type]||{scales:{}},s=t.scales||{},i=ci(e.type,t),o=Object.create(null);return Object.keys(s).forEach(r=>{const a=s[r];if(!F(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=li(r,a,Dy(r,e),st.scales[a.type]),l=Iy(c,i),u=n.scales||{};o[r]=an(Object.create(null),[{axis:c},a,u[c],u[l]])}),e.data.datasets.forEach(r=>{const a=r.type||e.type,c=r.indexAxis||ci(a,t),u=(Se[a]||{}).scales||{};Object.keys(u).forEach(h=>{const d=Ay(h,c),f=r[d+"AxisID"]||d;o[f]=o[f]||Object.create(null),an(o[f],[{axis:d},s[f],u[h]])})}),Object.keys(o).forEach(r=>{const a=o[r];an(a,[st.scales[a.type],st.scale])}),o}function Jc(e){const t=e.options||(e.options={});t.plugins=E(t.plugins,{}),t.scales=Ly(e,t)}function Kc(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function $y(e){return e=e||{},e.data=Kc(e.data),Jc(e),e}const Pr=new Map,Xc=new Set;function Yn(e,t){let n=Pr.get(e);return n||(n=t(),Pr.set(e,n),Xc.add(n)),n}const Ge=(e,t,n)=>{const s=oe(t,n);s!==void 0&&e.add(s)};class Ny{constructor(t){this._config=$y(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=Kc(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(),Jc(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return Yn(t,()=>[[`datasets.${t}`,""]])}datasetAnimationScopeKeys(t,n){return Yn(`${t}.transition.${n}`,()=>[[`datasets.${t}.transitions.${n}`,`transitions.${n}`],[`datasets.${t}`,""]])}datasetElementScopeKeys(t,n){return Yn(`${t}-${n}`,()=>[[`datasets.${t}.elements.${n}`,`datasets.${t}`,`elements.${n}`,""]])}pluginScopeKeys(t){const n=t.id,s=this.type;return Yn(`${s}-plugin-${n}`,()=>[[`plugins.${n}`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const s=this._scopeCache;let i=s.get(t);return(!i||n)&&(i=new Map,s.set(t,i)),i}getOptionScopes(t,n,s){const{options:i,type:o}=this,r=this._cachedScopes(t,s),a=r.get(n);if(a)return a;const c=new Set;n.forEach(u=>{t&&(c.add(t),u.forEach(h=>Ge(c,t,h))),u.forEach(h=>Ge(c,i,h)),u.forEach(h=>Ge(c,Se[o]||{},h)),u.forEach(h=>Ge(c,st,h)),u.forEach(h=>Ge(c,oi,h))});const l=Array.from(c);return l.length===0&&l.push(Object.create(null)),Xc.has(n)&&r.set(n,l),l}chartOptionScopes(){const{options:t,type:n}=this;return[t,Se[n]||{},st.datasets[n]||{},{type:n},st,oi]}resolveNamedOptions(t,n,s,i=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Tr(this._resolverCache,t,i);let c=r;if(Hy(r,n)){o.$shared=!1,s=re(s)?s():s;const l=this.createResolver(t,s,a);c=je(r,s,l)}for(const l of n)o[l]=c[l];return o}createResolver(t,n,s=[""],i){const{resolver:o}=Tr(this._resolverCache,t,s);return F(n)?je(o,n,void 0,i):o}}function Tr(e,t,n){let s=e.get(t);s||(s=new Map,e.set(t,s));const i=n.join();let o=s.get(i);return o||(o={resolver:oo(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},s.set(i,o)),o}const Fy=e=>F(e)&&Object.getOwnPropertyNames(e).some(t=>re(e[t]));function Hy(e,t){const{isScriptable:n,isIndexable:s}=zc(e);for(const i of t){const o=n(i),r=s(i),a=(r||o)&&e[i];if(o&&(re(a)||Fy(a))||r&&nt(a))return!0}return!1}var jy="4.5.1";const By=["top","bottom","left","right","chartArea"];function Cr(e,t){return e==="top"||e==="bottom"||By.indexOf(e)===-1&&t==="x"}function zr(e,t){return function(n,s){return n[e]===s[e]?n[t]-s[t]:n[e]-s[e]}}function Or(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),K(n&&n.onComplete,[e],t)}function Zy(e){const t=e.chart,n=t.options.animation;K(n&&n.onProgress,[e],t)}function Gc(e){return co()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const os={},Rr=e=>{const t=Gc(e);return Object.values(os).filter(n=>n.canvas===t).pop()};function Vy(e,t,n){const s=Object.keys(e);for(const i of s){const o=+i;if(o>=t){const r=e[i];delete e[i],(n>0||o>t)&&(e[o+n]=r)}}}function Wy(e,t,n,s){return!n||e.type==="mouseout"?null:s?t:e}class qt{static register(...t){Ht.add(...t),Ar()}static unregister(...t){Ht.remove(...t),Ar()}constructor(t,n){const s=this.config=new Ny(n),i=Gc(t),o=Rr(i);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=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||ly(i)),this.platform.updateConfig(s);const a=this.platform.acquireContext(i,r.aspectRatio),c=a&&a.canvas,l=c&&c.height,u=c&&c.width;if(this.id=qm(),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 Ty,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=lb(h=>this.update(h),r.resizeDelay||0),this._dataChanges=[],os[this.id]=this,!a||!c){console.error("Failed to create chart: can't acquire context from the given item");return}Zt.listen(this,"complete",Or),Zt.listen(this,"progress",Zy),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:s,height:i,_aspectRatio:o}=this;return N(t)?n&&o?o:i?s/i: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 Ht}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():tr(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Xo(this.canvas,this.ctx),this}stop(){return Zt.stop(this),this}resize(t,n){Zt.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const s=this.options,i=this.canvas,o=s.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(i,t,n,o),a=s.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,tr(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),K(s.onResize,[this,r],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};U(n,(s,i)=>{s.id=i})}buildOrUpdateScales(){const t=this.options,n=t.scales,s=this.scales,i=Object.keys(s).reduce((r,a)=>(r[a]=!1,r),{});let o=[];n&&(o=o.concat(Object.keys(n).map(r=>{const a=n[r],c=li(r,a),l=c==="r",u=c==="x";return{options:a,dposition:l?"chartArea":u?"bottom":"left",dtype:l?"radialLinear":u?"category":"linear"}}))),U(o,r=>{const a=r.options,c=a.id,l=li(c,a),u=E(a.type,r.dtype);(a.position===void 0||Cr(a.position,l)!==Cr(r.dposition))&&(a.position=r.dposition),i[c]=!0;let h=null;if(c in s&&s[c].type===u)h=s[c];else{const d=Ht.getScale(u);h=new d({id:c,type:u,ctx:this.ctx,chart:this}),s[h.id]=h}h.init(a,t)}),U(i,(r,a)=>{r||delete s[a]}),U(s,r=>{xt.configure(this,r,r.options),xt.addBox(this,r)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,s=t.length;if(t.sort((i,o)=>i.index-o.index),s>n){for(let i=n;i<s;++i)this._destroyDatasetMeta(i);t.splice(n,s-n)}this._sortedMetasets=t.slice(0).sort(zr("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((s,i)=>{n.filter(o=>o===s._dataset).length===0&&this._destroyDatasetMeta(i)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let s,i;for(this._removeUnreferencedMetasets(),s=0,i=n.length;s<i;s++){const o=n[s];let r=this.getDatasetMeta(s);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(s),r=this.getDatasetMeta(s)),r.type=a,r.indexAxis=o.indexAxis||ci(a,this.options),r.order=o.order||0,r.index=s,r.label=""+o.label,r.visible=this.isDatasetVisible(s),r.controller)r.controller.updateIndex(s),r.controller.linkScales();else{const c=Ht.getController(a),{datasetElementType:l,dataElementType:u}=st.datasets[a];Object.assign(c,{dataElementType:Ht.getElement(u),datasetElementType:l&&Ht.getElement(l)}),r.controller=new c(this,s),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){U(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 s=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),i=this._animationsDisabled=!s.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=!i&&o.indexOf(h)===-1;h.buildOrUpdateElements(d),r=Math.max(+h.getMaxOverflow(),r)}r=this._minPadding=s.layout.autoPadding?r:0,this._updateLayout(r),i||U(o,l=>{l.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(zr("z","_idx"));const{_active:a,_lastEvent:c}=this;c?this._eventHandler(c,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){U(this.scales,t=>{xt.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),s=new Set(t.events);(!Bo(n,s)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:s,start:i,count:o}of n){const r=s==="_removeElements"?-o:o;Vy(t,i,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,s=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),i=s(0);for(let o=1;o<n;o++)if(!Bo(i,s(o)))return;return Array.from(i).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;xt.update(this,this.width,this.height,t);const n=this.chartArea,s=n.width<=0||n.height<=0;this._layers=[],U(this.boxes,i=>{s&&i.position==="chartArea"||(i.configure&&i.configure(),this._layers.push(...i._layers()))},this),this._layers.forEach((i,o)=>{i._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,s=this.data.datasets.length;n<s;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,s=this.data.datasets.length;n<s;++n)this._updateDataset(n,re(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const s=this.getDatasetMeta(t),i={meta:s,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",i)!==!1&&(s.controller._update(n),i.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",i))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&(Zt.has(this)?this.attached&&!Zt.running(this)&&Zt.start(this):(this.draw(),Or({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:s,height:i}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(s,i)}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,s=[];let i,o;for(i=0,o=n.length;i<o;++i){const r=n[i];(!t||r.visible)&&s.push(r)}return s}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,s={meta:t,index:t.index,cancelable:!0},i=Hc(this,t);this.notifyPlugins("beforeDatasetDraw",s)!==!1&&(i&&Os(n,i),t.controller.draw(),i&&Rs(n),s.cancelable=!1,this.notifyPlugins("afterDatasetDraw",s))}isPointInArea(t){return Jt(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,s,i){const o=B_.modes[n];return typeof o=="function"?o(this,t,s,i):[]}getDatasetMeta(t){const n=this.data.datasets[t],s=this._metasets;let i=s.filter(o=>o&&o._dataset===n).pop();return i||(i={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},s.push(i)),i}getContext(){return this.$context||(this.$context=le(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const s=this.getDatasetMeta(t);return typeof s.hidden=="boolean"?!s.hidden:!n.hidden}setDatasetVisibility(t,n){const s=this.getDatasetMeta(t);s.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,s){const i=s?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,i);bn(n)?(o.data[n].hidden=!s,this.update()):(this.setDatasetVisibility(t,s),r.update(o,{visible:s}),this.update(a=>a.datasetIndex===t?i: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(),Zt.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(),Xo(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete os[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,s=(o,r)=>{n.addEventListener(this,o,r),t[o]=r},i=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};U(this.options.events,o=>s(o,i))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,s=(c,l)=>{n.addEventListener(this,c,l),t[c]=l},i=(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=()=>{i("attach",a),this.attached=!0,this.resize(),s("resize",o),s("detach",r)};r=()=>{this.attached=!1,i("resize",o),this._stop(),this._resize(0,0),s("attach",a)},n.isAttached(this.canvas)?a():r()}unbindEvents(){U(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},U(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,s){const i=s?"set":"remove";let o,r,a,c;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+i+"DatasetHoverStyle"]()),a=0,c=t.length;a<c;++a){r=t[a];const l=r&&this.getDatasetMeta(r.datasetIndex).controller;l&&l[i+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],s=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}});!fs(s,n)&&(this._active=s,this._lastEvent=null,this._updateHoverStyles(s,n))}notifyPlugins(t,n,s){return this._plugins.notify(this,t,n,s)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,s){const i=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=s?t:o(t,n);r.length&&this.updateHoverStyle(r,i.mode,!1),a.length&&i.mode&&this.updateHoverStyle(a,i.mode,!0)}_eventHandler(t,n){const s={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},i=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,i)===!1)return;const o=this._handleEvent(t,n,s.inChartArea);return s.cancelable=!1,this.notifyPlugins("afterEvent",s,i),(o||s.changed)&&this.render(),this}_handleEvent(t,n,s){const{_active:i=[],options:o}=this,r=n,a=this._getActiveElements(t,i,s,r),c=Gm(t),l=Wy(t,this._lastEvent,s,c);s&&(this._lastEvent=null,K(o.onHover,[t,a,this],this),c&&K(o.onClick,[t,a,this],this));const u=!fs(a,i);return(u||n)&&(this._active=a,this._updateHoverStyles(a,i,n)),this._lastEvent=l,u}_getActiveElements(t,n,s,i){if(t.type==="mouseout")return[];if(!s)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,i)}}P(qt,"defaults",st),P(qt,"instances",os),P(qt,"overrides",Se),P(qt,"registry",Ht),P(qt,"version",jy),P(qt,"getChart",Rr);function Ar(){return U(qt.instances,e=>e._plugins.invalidate())}function qy(e,t,n){const{startAngle:s,x:i,y:o,outerRadius:r,innerRadius:a,options:c}=t,{borderWidth:l,borderJoinStyle:u}=c,h=Math.min(l/r,yt(s-n));if(e.beginPath(),e.arc(i,o,r-l/2,s+h/2,n-h/2),a>0){const d=Math.min(l/a,yt(s-n));e.arc(i,o,a+l/2,n-d/2,s+d/2,!0)}else{const d=Math.min(l/2,r*yt(s-n));if(u==="round")e.arc(i,o,d,n-Z/2,s+Z/2,!0);else if(u==="bevel"){const f=2*d*d,p=-f*Math.cos(n+Z/2)+i,g=-f*Math.sin(n+Z/2)+o,m=f*Math.cos(s+Z/2)+i,b=f*Math.sin(s+Z/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 Uy(e,t,n){const{startAngle:s,pixelMargin:i,x:o,y:r,outerRadius:a,innerRadius:c}=t;let l=i/a;e.beginPath(),e.arc(o,r,a,s-l,n+l),c>i?(l=i/c,e.arc(o,r,c,n+l,s-l,!0)):e.arc(o,r,i,n+lt,s-lt),e.closePath(),e.clip()}function Yy(e){return io(e,["outerStart","outerEnd","innerStart","innerEnd"])}function Jy(e,t,n,s){const i=Yy(e.options.borderRadius),o=(n-t)/2,r=Math.min(o,s*t/2),a=c=>{const l=(n-Math.min(o,c))*s/2;return ft(c,0,Math.min(o,l))};return{outerStart:a(i.outerStart),outerEnd:a(i.outerEnd),innerStart:ft(i.innerStart,0,r),innerEnd:ft(i.innerEnd,0,r)}}function Re(e,t,n,s){return{x:n+e*Math.cos(t),y:s+e*Math.sin(t)}}function ys(e,t,n,s,i,o){const{x:r,y:a,startAngle:c,pixelMargin:l,innerRadius:u}=t,h=Math.max(t.outerRadius+s+n-l,0),d=u>0?u+s+n+l:0;let f=0;const p=i-c;if(s){const Y=u>0?u-s:0,et=h>0?h-s:0,ct=(Y+et)/2,Dt=ct!==0?p*ct/(ct+s):p;f=(p-Dt)/2}const g=Math.max(.001,p*h-n/Z)/h,m=(p-g)/2,b=c+m+f,x=i-m-f,{outerStart:M,outerEnd:S,innerStart:k,innerEnd:C}=Jy(t,d,h,x-b),T=h-M,z=h-S,O=b+M/T,D=x-S/z,L=d+k,j=d+C,pt=b+k/L,Tt=x-C/j;if(e.beginPath(),o){const Y=(O+D)/2;if(e.arc(r,a,h,O,Y),e.arc(r,a,h,Y,D),S>0){const bt=Re(z,D,r,a);e.arc(bt.x,bt.y,S,D,x+lt)}const et=Re(j,x,r,a);if(e.lineTo(et.x,et.y),C>0){const bt=Re(j,Tt,r,a);e.arc(bt.x,bt.y,C,x+lt,Tt+Math.PI)}const ct=(x-C/d+(b+k/d))/2;if(e.arc(r,a,d,x-C/d,ct,!0),e.arc(r,a,d,ct,b+k/d,!0),k>0){const bt=Re(L,pt,r,a);e.arc(bt.x,bt.y,k,pt+Math.PI,b-lt)}const Dt=Re(T,b,r,a);if(e.lineTo(Dt.x,Dt.y),M>0){const bt=Re(T,O,r,a);e.arc(bt.x,bt.y,M,b-lt,O)}}else{e.moveTo(r,a);const Y=Math.cos(O)*h+r,et=Math.sin(O)*h+a;e.lineTo(Y,et);const ct=Math.cos(D)*h+r,Dt=Math.sin(D)*h+a;e.lineTo(ct,Dt)}e.closePath()}function Ky(e,t,n,s,i){const{fullCircles:o,startAngle:r,circumference:a}=t;let c=t.endAngle;if(o){ys(e,t,n,s,c,i);for(let l=0;l<o;++l)e.fill();isNaN(a)||(c=r+(a%G||G))}return ys(e,t,n,s,c,i),e.fill(),c}function Xy(e,t,n,s,i){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){ys(e,t,n,s,g,i);for(let m=0;m<o;++m)e.stroke();isNaN(a)||(g=r+(a%G||G))}p&&Uy(e,t,g),c.selfJoin&&g-r>=Z&&f===0&&u!=="miter"&&qy(e,t,g),o||(ys(e,t,n,s,g,i),e.stroke())}class sn extends Nt{constructor(n){super();P(this,"circumference");P(this,"endAngle");P(this,"fullCircles");P(this,"innerRadius");P(this,"outerRadius");P(this,"pixelMargin");P(this,"startAngle");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,n&&Object.assign(this,n)}inRange(n,s,i){const o=this.getProps(["x","y"],i),{angle:r,distance:a}=yc(o,{x:n,y:s}),{startAngle:c,endAngle:l,innerRadius:u,outerRadius:h,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],i),f=(this.options.spacing+this.options.borderWidth)/2,p=E(d,l-c),g=_n(r,c,l)&&c!==l,m=p>=G||g,b=Ut(a,u+f,h+f);return m&&b}getCenterPoint(n){const{x:s,y:i,startAngle:o,endAngle:r,innerRadius:a,outerRadius:c}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],n),{offset:l,spacing:u}=this.options,h=(o+r)/2,d=(a+c+u+l)/2;return{x:s+Math.cos(h)*d,y:i+Math.sin(h)*d}}tooltipPosition(n){return this.getCenterPoint(n)}draw(n){const{options:s,circumference:i}=this,o=(s.offset||0)/4,r=(s.spacing||0)/2,a=s.circular;if(this.pixelMargin=s.borderAlign==="inner"?.33:0,this.fullCircles=i>G?Math.floor(i/G):0,i===0||this.innerRadius<0||this.outerRadius<0)return;n.save();const c=(this.startAngle+this.endAngle)/2;n.translate(Math.cos(c)*o,Math.sin(c)*o);const l=1-Math.sin(Math.min(Z,i||0)),u=o*l;n.fillStyle=s.backgroundColor,n.strokeStyle=s.borderColor,Ky(n,this,u,r,a),Xy(n,this,u,r,a),n.restore()}}P(sn,"id","arc"),P(sn,"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}),P(sn,"defaultRoutes",{backgroundColor:"backgroundColor"}),P(sn,"descriptors",{_scriptable:!0,_indexable:n=>n!=="borderDash"});function Qc(e,t,n=t){e.lineCap=E(n.borderCapStyle,t.borderCapStyle),e.setLineDash(E(n.borderDash,t.borderDash)),e.lineDashOffset=E(n.borderDashOffset,t.borderDashOffset),e.lineJoin=E(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=E(n.borderWidth,t.borderWidth),e.strokeStyle=E(n.borderColor,t.borderColor)}function Gy(e,t,n){e.lineTo(n.x,n.y)}function Qy(e){return e.stepped?vb:e.tension||e.cubicInterpolationMode==="monotone"?kb:Gy}function tl(e,t,n={}){const s=e.length,{start:i=0,end:o=s-1}=n,{start:r,end:a}=t,c=Math.max(i,r),l=Math.min(o,a),u=i<r&&o<r||i>a&&o>a;return{count:s,start:c,loop:t.loop,ilen:l<c&&!u?s+l-c:l-c}}function tx(e,t,n,s){const{points:i,options:o}=t,{count:r,start:a,loop:c,ilen:l}=tl(i,n,s),u=Qy(o);let{move:h=!0,reverse:d}=s||{},f,p,g;for(f=0;f<=l;++f)p=i[(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=i[(a+(d?l:0))%r],u(e,g,p,d,o.stepped)),!!c}function ex(e,t,n,s){const i=t.points,{count:o,start:r,ilen:a}=tl(i,n,s),{move:c=!0,reverse:l}=s||{};let u=0,h=0,d,f,p,g,m,b;const x=S=>(r+(l?a-S:S))%o,M=()=>{g!==m&&(e.lineTo(u,m),e.lineTo(u,g),e.lineTo(u,b))};for(c&&(f=i[x(0)],e.moveTo(f.x,f.y)),d=0;d<=a;++d){if(f=i[x(d)],f.skip)continue;const S=f.x,k=f.y,C=S|0;C===p?(k<g?g=k:k>m&&(m=k),u=(h*u+S)/++h):(M(),e.lineTo(S,k),p=C,h=0,g=m=k),b=k}M()}function ui(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?ex:tx}function nx(e){return e.stepped?t_:e.tension||e.cubicInterpolationMode==="monotone"?e_:ye}function sx(e,t,n,s){let i=t._path;i||(i=t._path=new Path2D,t.path(i,n,s)&&i.closePath()),Qc(e,t.options),e.stroke(i)}function ix(e,t,n,s){const{segments:i,options:o}=t,r=ui(t);for(const a of i)Qc(e,o,a.style),e.beginPath(),r(e,t,a,{start:n,end:n+s-1})&&e.closePath(),e.stroke()}const ox=typeof Path2D=="function";function rx(e,t,n,s){ox&&!t.options.segment?sx(e,t,n,s):ix(e,t,n,s)}class te extends Nt{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 s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){const i=s.spanGaps?this._loop:this._fullLoop;qb(this._points,s,t,i,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=a_(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,s=t.length;return s&&n[t[s-1].end]}interpolate(t,n){const s=this.options,i=t[n],o=this.points,r=Fc(this,{property:n,start:i,end:i});if(!r.length)return;const a=[],c=nx(s);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((i-f[n])/(p[n]-f[n])),m=c(f,p,g,s.stepped);m[n]=t[n],a.push(m)}return a.length===1?a[0]:a}pathSegment(t,n,s){return ui(this)(t,this,n,s)}path(t,n,s){const i=this.segments,o=ui(this);let r=this._loop;n=n||0,s=s||this.points.length-n;for(const a of i)r&=o(t,this,a,{start:n,end:n+s-1});return!!r}draw(t,n,s,i){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),rx(t,this,s,i),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}P(te,"id","line"),P(te,"defaults",{borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0}),P(te,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"}),P(te,"descriptors",{_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"});function Ir(e,t,n,s){const i=e.options,{[n]:o}=e.getProps([n],s);return Math.abs(t-o)<i.radius+i.hitRadius}class rs extends Nt{constructor(n){super();P(this,"parsed");P(this,"skip");P(this,"stop");this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,n&&Object.assign(this,n)}inRange(n,s,i){const o=this.options,{x:r,y:a}=this.getProps(["x","y"],i);return Math.pow(n-r,2)+Math.pow(s-a,2)<Math.pow(o.hitRadius+o.radius,2)}inXRange(n,s){return Ir(this,n,"x",s)}inYRange(n,s){return Ir(this,n,"y",s)}getCenterPoint(n){const{x:s,y:i}=this.getProps(["x","y"],n);return{x:s,y:i}}size(n){n=n||this.options||{};let s=n.radius||0;s=Math.max(s,s&&n.hoverRadius||0);const i=s&&n.borderWidth||0;return(s+i)*2}draw(n,s){const i=this.options;this.skip||i.radius<.1||!Jt(this,s,this.size(i)/2)||(n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.fillStyle=i.backgroundColor,ri(n,i,this.x,this.y))}getRange(){const n=this.options||{};return n.radius+n.hitRadius}}P(rs,"id","point"),P(rs,"defaults",{borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0}),P(rs,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});function el(e,t){const{x:n,y:s,base:i,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,i),c=Math.max(n,i),l=s-h,u=s+h):(h=o/2,a=n-h,c=n+h,l=Math.min(s,i),u=Math.max(s,i)),{left:a,top:l,right:c,bottom:u}}function ee(e,t,n,s){return e?0:ft(t,n,s)}function ax(e,t,n){const s=e.options.borderWidth,i=e.borderSkipped,o=Cc(s);return{t:ee(i.top,o.top,0,n),r:ee(i.right,o.right,0,t),b:ee(i.bottom,o.bottom,0,n),l:ee(i.left,o.left,0,t)}}function cx(e,t,n){const{enableBorderRadius:s}=e.getProps(["enableBorderRadius"]),i=e.options.borderRadius,o=ke(i),r=Math.min(t,n),a=e.borderSkipped,c=s||F(i);return{topLeft:ee(!c||a.top||a.left,o.topLeft,0,r),topRight:ee(!c||a.top||a.right,o.topRight,0,r),bottomLeft:ee(!c||a.bottom||a.left,o.bottomLeft,0,r),bottomRight:ee(!c||a.bottom||a.right,o.bottomRight,0,r)}}function lx(e){const t=el(e),n=t.right-t.left,s=t.bottom-t.top,i=ax(e,n/2,s/2),o=cx(e,n/2,s/2);return{outer:{x:t.left,y:t.top,w:n,h:s,radius:o},inner:{x:t.left+i.l,y:t.top+i.t,w:n-i.l-i.r,h:s-i.t-i.b,radius:{topLeft:Math.max(0,o.topLeft-Math.max(i.t,i.l)),topRight:Math.max(0,o.topRight-Math.max(i.t,i.r)),bottomLeft:Math.max(0,o.bottomLeft-Math.max(i.b,i.l)),bottomRight:Math.max(0,o.bottomRight-Math.max(i.b,i.r))}}}}function Ys(e,t,n,s){const i=t===null,o=n===null,a=e&&!(i&&o)&&el(e,s);return a&&(i||Ut(t,a.left,a.right))&&(o||Ut(n,a.top,a.bottom))}function ux(e){return e.topLeft||e.topRight||e.bottomLeft||e.bottomRight}function hx(e,t){e.rect(t.x,t.y,t.w,t.h)}function Js(e,t,n={}){const s=e.x!==n.x?-t:0,i=e.y!==n.y?-t:0,o=(e.x+e.w!==n.x+n.w?t:0)-s,r=(e.y+e.h!==n.y+n.h?t:0)-i;return{x:e.x+s,y:e.y+i,w:e.w+o,h:e.h+r,radius:e.radius}}class as extends Nt{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:s,backgroundColor:i}}=this,{inner:o,outer:r}=lx(this),a=ux(r.radius)?yn:hx;t.save(),(r.w!==o.w||r.h!==o.h)&&(t.beginPath(),a(t,Js(r,n,o)),t.clip(),a(t,Js(o,-n,r)),t.fillStyle=s,t.fill("evenodd")),t.beginPath(),a(t,Js(o,n)),t.fillStyle=i,t.fill(),t.restore()}inRange(t,n,s){return Ys(this,t,n,s)}inXRange(t,n){return Ys(this,t,null,n)}inYRange(t,n){return Ys(this,null,t,n)}getCenterPoint(t){const{x:n,y:s,base:i,horizontal:o}=this.getProps(["x","y","base","horizontal"],t);return{x:o?(n+i)/2:n,y:o?s:(s+i)/2}}getRange(t){return t==="x"?this.width/2:this.height/2}}P(as,"id","bar"),P(as,"defaults",{borderSkipped:"start",borderWidth:0,borderRadius:0,inflateAmount:"auto",pointStyle:void 0}),P(as,"defaultRoutes",{backgroundColor:"backgroundColor",borderColor:"borderColor"});var dx=Object.freeze({__proto__:null,ArcElement:sn,BarElement:as,LineElement:te,PointElement:rs});const hi=["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)"],Er=hi.map(e=>e.replace("rgb(","rgba(").replace(")",", 0.5)"));function nl(e){return hi[e%hi.length]}function sl(e){return Er[e%Er.length]}function fx(e,t){return e.borderColor=nl(t),e.backgroundColor=sl(t),++t}function px(e,t){return e.backgroundColor=e.data.map(()=>nl(t++)),t}function gx(e,t){return e.backgroundColor=e.data.map(()=>sl(t++)),t}function mx(e){let t=0;return(n,s)=>{const i=e.getDatasetMeta(s).controller;i instanceof xe?t=px(n,t):i instanceof hn?t=gx(n,t):i&&(t=fx(n,t))}}function Dr(e){let t;for(t in e)if(e[t].borderColor||e[t].backgroundColor)return!0;return!1}function bx(e){return e&&(e.borderColor||e.backgroundColor)}function _x(){return st.borderColor!=="rgba(0,0,0,0.1)"||st.backgroundColor!=="rgba(0,0,0,0.1)"}var yx={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(e,t,n){if(!n.enabled)return;const{data:{datasets:s},options:i}=e.config,{elements:o}=i,r=Dr(s)||bx(i)||o&&Dr(o)||_x();if(!n.forceOverride&&r)return;const a=mx(e);s.forEach(a)}};function xx(e,t,n,s,i){const o=i.samples||s;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,x;const M=Math.floor((h+1)*a)+1+t,S=Math.min(Math.floor((h+2)*a)+1,n)+t,k=S-M;for(x=M;x<S;x++)m+=e[x].x,b+=e[x].y;m/=k,b/=k;const C=Math.floor(h*a)+1+t,T=Math.min(Math.floor((h+1)*a)+1,n)+t,{x:z,y:O}=e[u];for(f=p=-1,x=C;x<T;x++)p=.5*Math.abs((z-m)*(e[x].y-O)-(z-e[x].x)*(b-O)),p>f&&(f=p,d=e[x],g=x);r[c++]=d,u=g}return r[c++]=e[l],r}function vx(e,t,n,s){let i=0,o=0,r,a,c,l,u,h,d,f,p,g;const m=[],b=t+n-1,x=e[t].x,S=e[b].x-x;for(r=t;r<t+n;++r){a=e[r],c=(a.x-x)/S*s,l=a.y;const k=c|0;if(k===u)l<p?(p=l,h=r):l>g&&(g=l,d=r),i=(o*i+a.x)/++o;else{const C=r-1;if(!N(h)&&!N(d)){const T=Math.min(h,d),z=Math.max(h,d);T!==f&&T!==C&&m.push({...e[T],x:i}),z!==f&&z!==C&&m.push({...e[z],x:i})}r>0&&C!==f&&m.push(e[C]),m.push(a),u=k,o=0,p=g=l,h=d=f=r}}return m}function il(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 Lr(e){e.data.datasets.forEach(t=>{il(t)})}function kx(e,t){const n=t.length;let s=0,i;const{iScale:o}=e,{min:r,max:a,minDefined:c,maxDefined:l}=o.getUserBounds();return c&&(s=ft(Yt(t,o.axis,r).lo,0,n-1)),l?i=ft(Yt(t,o.axis,a).hi+1,s,n)-s:i=n-s,{start:s,count:i}}var wx={id:"decimation",defaults:{algorithm:"min-max",enabled:!1},beforeElementsUpdate:(e,t,n)=>{if(!n.enabled){Lr(e);return}const s=e.width;e.data.datasets.forEach((i,o)=>{const{_data:r,indexAxis:a}=i,c=e.getDatasetMeta(o),l=r||i.data;if(en([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}=kx(c,l);const f=n.threshold||4*s;if(d<=f){il(i);return}N(r)&&(i._data=l,delete i.data,Object.defineProperty(i,"data",{configurable:!0,enumerable:!0,get:function(){return this._decimated},set:function(g){this._data=g}}));let p;switch(n.algorithm){case"lttb":p=xx(l,h,d,s,n);break;case"min-max":p=vx(l,h,d,s);break;default:throw new Error(`Unsupported decimation algorithm '${n.algorithm}'`)}i._decimated=p})},destroy(e){Lr(e)}};function Sx(e,t,n){const s=e.segments,i=e.points,o=t.points,r=[];for(const a of s){let{start:c,end:l}=a;l=Es(c,l,i);const u=di(n,i[c],i[l],a.loop);if(!t.segments){r.push({source:a,target:u,start:i[c],end:i[l]});continue}const h=Fc(t,u);for(const d of h){const f=di(n,o[d.start],o[d.end],d.loop),p=Nc(a,i,f);for(const g of p)r.push({source:g,target:d,start:{[n]:$r(u,f,"start",Math.max)},end:{[n]:$r(u,f,"end",Math.min)}})}}return r}function di(e,t,n,s){if(s)return;let i=t[e],o=n[e];return e==="angle"&&(i=yt(i),o=yt(o)),{property:e,start:i,end:o}}function Mx(e,t){const{x:n=null,y:s=null}=e||{},i=t.points,o=[];return t.segments.forEach(({start:r,end:a})=>{a=Es(r,a,i);const c=i[r],l=i[a];s!==null?(o.push({x:c.x,y:s}),o.push({x:l.x,y:s})):n!==null&&(o.push({x:n,y:c.y}),o.push({x:n,y:l.y}))}),o}function Es(e,t,n){for(;t>e;t--){const s=n[t];if(!isNaN(s.x)&&!isNaN(s.y))break}return t}function $r(e,t,n,s){return e&&t?s(e[n],t[n]):e?e[n]:t?t[n]:0}function ol(e,t){let n=[],s=!1;return nt(e)?(s=!0,n=e):n=Mx(e,t),n.length?new te({points:n,options:{tension:0},_loop:s,_fullLoop:s}):null}function Nr(e){return e&&e.fill!==!1}function Px(e,t,n){let i=e[t].fill;const o=[t];let r;if(!n)return i;for(;i!==!1&&o.indexOf(i)===-1;){if(!at(i))return i;if(r=e[i],!r)return!1;if(r.visible)return i;o.push(i),i=r.fill}return!1}function Tx(e,t,n){const s=Rx(e);if(F(s))return isNaN(s.value)?!1:s;let i=parseFloat(s);return at(i)&&Math.floor(i)===i?Cx(s[0],t,i,n):["origin","start","end","stack","shape"].indexOf(s)>=0&&s}function Cx(e,t,n,s){return(e==="-"||e==="+")&&(n=t+n),n===t||n<0||n>=s?!1:n}function zx(e,t){let n=null;return e==="start"?n=t.bottom:e==="end"?n=t.top:F(e)?n=t.getPixelForValue(e.value):t.getBasePixel&&(n=t.getBasePixel()),n}function Ox(e,t,n){let s;return e==="start"?s=n:e==="end"?s=t.options.reverse?t.min:t.max:F(e)?s=e.value:s=t.getBaseValue(),s}function Rx(e){const t=e.options,n=t.fill;let s=E(n&&n.target,n);return s===void 0&&(s=!!t.backgroundColor),s===!1||s===null?!1:s===!0?"origin":s}function Ax(e){const{scale:t,index:n,line:s}=e,i=[],o=s.segments,r=s.points,a=Ix(t,n);a.push(ol({x:null,y:t.bottom},s));for(let c=0;c<o.length;c++){const l=o[c];for(let u=l.start;u<=l.end;u++)Ex(i,r[u],a)}return new te({points:i,options:{}})}function Ix(e,t){const n=[],s=e.getMatchingVisibleMetas("line");for(let i=0;i<s.length;i++){const o=s[i];if(o.index===t)break;o.hidden||n.unshift(o.dataset)}return n}function Ex(e,t,n){const s=[];for(let i=0;i<n.length;i++){const o=n[i],{first:r,last:a,point:c}=Dx(o,t,"x");if(!(!c||r&&a)){if(r)s.unshift(c);else if(e.push(c),!a)break}}e.push(...s)}function Dx(e,t,n){const s=e.interpolate(t,n);if(!s)return{};const i=s[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(Ut(i,h,d)){a=i===h,c=i===d;break}}return{first:a,last:c,point:s}}class rl{constructor(t){this.x=t.x,this.y=t.y,this.radius=t.radius}pathSegment(t,n,s){const{x:i,y:o,radius:r}=this;return n=n||{start:0,end:G},t.arc(i,o,r,n.end,n.start,!0),!s.bounds}interpolate(t){const{x:n,y:s,radius:i}=this,o=t.angle;return{x:n+Math.cos(o)*i,y:s+Math.sin(o)*i,angle:o}}}function Lx(e){const{chart:t,fill:n,line:s}=e;if(at(n))return $x(t,n);if(n==="stack")return Ax(e);if(n==="shape")return!0;const i=Nx(e);return i instanceof rl?i:ol(i,s)}function $x(e,t){const n=e.getDatasetMeta(t);return n&&e.isDatasetVisible(t)?n.dataset:null}function Nx(e){return(e.scale||{}).getPointPositionForValue?Hx(e):Fx(e)}function Fx(e){const{scale:t={},fill:n}=e,s=zx(n,t);if(at(s)){const i=t.isHorizontal();return{x:i?s:null,y:i?null:s}}return null}function Hx(e){const{scale:t,fill:n}=e,s=t.options,i=t.getLabels().length,o=s.reverse?t.max:t.min,r=Ox(n,t,o),a=[];if(s.grid.circular){const c=t.getPointPositionForValue(0,o);return new rl({x:c.x,y:c.y,radius:t.getDistanceFromCenterForValue(r)})}for(let c=0;c<i;++c)a.push(t.getPointPositionForValue(c,r));return a}function Ks(e,t,n){const s=Lx(t),{chart:i,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=i.getDatasetMeta(o),g=Hc(i,p);s&&r.points.length&&(Os(e,n),jx(e,{line:r,target:s,above:d,below:f,area:n,scale:a,axis:c,clip:g}),Rs(e))}function jx(e,t){const{line:n,target:s,above:i,below:o,area:r,scale:a,clip:c}=t,l=n._loop?"angle":t.axis;e.save();let u=o;o!==i&&(l==="x"?(Fr(e,s,r.top),Xs(e,{line:n,target:s,color:i,scale:a,property:l,clip:c}),e.restore(),e.save(),Fr(e,s,r.bottom)):l==="y"&&(Hr(e,s,r.left),Xs(e,{line:n,target:s,color:o,scale:a,property:l,clip:c}),e.restore(),e.save(),Hr(e,s,r.right),u=i)),Xs(e,{line:n,target:s,color:u,scale:a,property:l,clip:c}),e.restore()}function Fr(e,t,n){const{segments:s,points:i}=t;let o=!0,r=!1;e.beginPath();for(const a of s){const{start:c,end:l}=a,u=i[c],h=i[Es(c,l,i)];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 Hr(e,t,n){const{segments:s,points:i}=t;let o=!0,r=!1;e.beginPath();for(const a of s){const{start:c,end:l}=a,u=i[c],h=i[Es(c,l,i)];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 Xs(e,t){const{line:n,target:s,property:i,color:o,scale:r,clip:a}=t,c=Sx(n,s,i);for(const{source:l,target:u,start:h,end:d}of c){const{style:{backgroundColor:f=o}={}}=l,p=s!==!0;e.save(),e.fillStyle=f,Bx(e,r,a,p&&di(i,h,d)),e.beginPath();const g=!!n.pathSegment(e,l);let m;if(p){g?e.closePath():jr(e,s,d,i);const b=!!s.pathSegment(e,u,{move:g,reverse:!0});m=g&&b,m||jr(e,s,h,i)}e.closePath(),e.fill(m?"evenodd":"nonzero"),e.restore()}}function Bx(e,t,n,s){const i=t.chart.chartArea,{property:o,start:r,end:a}=s||{};if(o==="x"||o==="y"){let c,l,u,h;o==="x"?(c=r,l=i.top,u=a,h=i.bottom):(c=i.left,l=r,u=i.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 jr(e,t,n,s){const i=t.interpolate(n,s);i&&e.lineTo(i.x,i.y)}var Zx={id:"filler",afterDatasetsUpdate(e,t,n){const s=(e.data.datasets||[]).length,i=[];let o,r,a,c;for(r=0;r<s;++r)o=e.getDatasetMeta(r),a=o.dataset,c=null,a&&a.options&&a instanceof te&&(c={visible:e.isDatasetVisible(r),index:r,fill:Tx(a,r,s),chart:e,axis:o.controller.options.indexAxis,scale:o.vScale,line:a}),o.$filler=c,i.push(c);for(r=0;r<s;++r)c=i[r],!(!c||c.fill===!1)&&(c.fill=Px(i,r,n.propagate))},beforeDraw(e,t,n){const s=n.drawTime==="beforeDraw",i=e.getSortedVisibleDatasetMetas(),o=e.chartArea;for(let r=i.length-1;r>=0;--r){const a=i[r].$filler;a&&(a.line.updateControlPoints(o,a.axis),s&&a.fill&&Ks(e.ctx,a,o))}},beforeDatasetsDraw(e,t,n){if(n.drawTime!=="beforeDatasetsDraw")return;const s=e.getSortedVisibleDatasetMetas();for(let i=s.length-1;i>=0;--i){const o=s[i].$filler;Nr(o)&&Ks(e.ctx,o,e.chartArea)}},beforeDatasetDraw(e,t,n){const s=t.meta.$filler;!Nr(s)||n.drawTime!=="beforeDatasetDraw"||Ks(e.ctx,s,e.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const Br=(e,t)=>{let{boxHeight:n=t,boxWidth:s=t}=e;return e.usePointStyle&&(n=Math.min(n,t),s=e.pointStyleWidth||Math.min(s,t)),{boxWidth:s,boxHeight:n,itemHeight:Math.max(t,n)}},Vx=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class Zr extends Nt{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,s){this.maxWidth=t,this.maxHeight=n,this._margins=s,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=K(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(s=>t.filter(s,this.chart.data))),t.sort&&(n=n.sort((s,i)=>t.sort(s,i,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 s=t.labels,i=dt(s.font),o=i.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:c}=Br(s,o);let l,u;n.font=i.string,this.isHorizontal()?(l=this.maxWidth,u=this._fitRows(r,o,a,c)+10):(u=this.maxHeight,l=this._fitCols(r,i,a,c)+10),this.width=Math.min(l,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,s,i){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,c=this.legendHitBoxes=[],l=this.lineWidths=[0],u=i+a;let h=t;o.textAlign="left",o.textBaseline="middle";let d=-1,f=-u;return this.legendItems.forEach((p,g)=>{const m=s+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:i},l[l.length-1]+=m+a}),h}_fitCols(t,n,s,i){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:x,itemHeight:M}=Wx(s,n,o,m,i);b>0&&f+M+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:x,height:M},d=Math.max(d,x),f+=M+a}),h+=d,l.push({width:d,height:f}),h}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:s,labels:{padding:i},rtl:o}}=this,r=Le(o,this.left,this.width);if(this.isHorizontal()){let a=0,c=_t(s,this.left+i,this.right-this.lineWidths[a]);for(const l of n)a!==l.row&&(a=l.row,c=_t(s,this.left+i,this.right-this.lineWidths[a])),l.top+=this.top+t+i,l.left=r.leftForLtr(r.x(c),l.width),c+=l.width+i}else{let a=0,c=_t(s,this.top+t+i,this.bottom-this.columnSizes[a].height);for(const l of n)l.col!==a&&(a=l.col,c=_t(s,this.top+t+i,this.bottom-this.columnSizes[a].height)),l.top=c,l.left+=this.left+i,l.left=r.leftForLtr(r.x(l.left),l.width),c+=l.height+i}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;Os(t,this),this._draw(),Rs(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:s,ctx:i}=this,{align:o,labels:r}=t,a=st.color,c=Le(t.rtl,this.left,this.width),l=dt(r.font),{padding:u}=r,h=l.size,d=h/2;let f;this.drawTitle(),i.textAlign=c.textAlign("left"),i.textBaseline="middle",i.lineWidth=.5,i.font=l.string;const{boxWidth:p,boxHeight:g,itemHeight:m}=Br(r,h),b=function(C,T,z){if(isNaN(p)||p<=0||isNaN(g)||g<0)return;i.save();const O=E(z.lineWidth,1);if(i.fillStyle=E(z.fillStyle,a),i.lineCap=E(z.lineCap,"butt"),i.lineDashOffset=E(z.lineDashOffset,0),i.lineJoin=E(z.lineJoin,"miter"),i.lineWidth=O,i.strokeStyle=E(z.strokeStyle,a),i.setLineDash(E(z.lineDash,[])),r.usePointStyle){const D={radius:g*Math.SQRT2/2,pointStyle:z.pointStyle,rotation:z.rotation,borderWidth:O},L=c.xPlus(C,p/2),j=T+d;Tc(i,D,L,j,r.pointStyleWidth&&p)}else{const D=T+Math.max((h-g)/2,0),L=c.leftForLtr(C,p),j=ke(z.borderRadius);i.beginPath(),Object.values(j).some(pt=>pt!==0)?yn(i,{x:L,y:D,w:p,h:g,radius:j}):i.rect(L,D,p,g),i.fill(),O!==0&&i.stroke()}i.restore()},x=function(C,T,z){Me(i,z.text,C,T+m/2,l,{strikethrough:z.hidden,textAlign:c.textAlign(z.textAlign)})},M=this.isHorizontal(),S=this._computeTitleHeight();M?f={x:_t(o,this.left+u,this.right-s[0]),y:this.top+u+S,line:0}:f={x:this.left+u,y:_t(o,this.top+S+u,this.bottom-n[0].height),line:0},Dc(this.ctx,t.textDirection);const k=m+u;this.legendItems.forEach((C,T)=>{i.strokeStyle=C.fontColor,i.fillStyle=C.fontColor;const z=i.measureText(C.text).width,O=c.textAlign(C.textAlign||(C.textAlign=r.textAlign)),D=p+d+z;let L=f.x,j=f.y;c.setWidth(this.width),M?T>0&&L+D+u>this.right&&(j=f.y+=k,f.line++,L=f.x=_t(o,this.left+u,this.right-s[f.line])):T>0&&j+k>this.bottom&&(L=f.x=L+n[f.line].width+u,f.line++,j=f.y=_t(o,this.top+S+u,this.bottom-n[f.line].height));const pt=c.x(L);if(b(pt,j,C),L=ub(O,L+p+d,M?L+D:this.right,t.rtl),x(c.x(L),j,C),M)f.x+=D+u;else if(typeof C.text!="string"){const Tt=l.lineHeight;f.y+=al(C,Tt)+u}else f.y+=k}),Lc(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,s=dt(n.font),i=vt(n.padding);if(!n.display)return;const o=Le(t.rtl,this.left,this.width),r=this.ctx,a=n.position,c=s.size/2,l=i.top+c;let u,h=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),u=this.top+l,h=_t(t.align,h,this.right-d);else{const p=this.columnSizes.reduce((g,m)=>Math.max(g,m.height),0);u=l+_t(t.align,this.top,this.bottom-p-t.labels.padding-this._computeTitleHeight())}const f=_t(a,h,h+d);r.textAlign=o.textAlign(no(a)),r.textBaseline="middle",r.strokeStyle=n.color,r.fillStyle=n.color,r.font=s.string,Me(r,n.text,f,u,s)}_computeTitleHeight(){const t=this.options.title,n=dt(t.font),s=vt(t.padding);return t.display?n.lineHeight+s.height:0}_getLegendItemAt(t,n){let s,i,o;if(Ut(t,this.left,this.right)&&Ut(n,this.top,this.bottom)){for(o=this.legendHitBoxes,s=0;s<o.length;++s)if(i=o[s],Ut(t,i.left,i.left+i.width)&&Ut(n,i.top,i.top+i.height))return this.legendItems[s]}return null}handleEvent(t){const n=this.options;if(!Yx(t.type,n))return;const s=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const i=this._hoveredItem,o=Vx(i,s);i&&!o&&K(n.onLeave,[t,i,this],this),this._hoveredItem=s,s&&!o&&K(n.onHover,[t,s,this],this)}else s&&K(n.onClick,[t,s,this],this)}}function Wx(e,t,n,s,i){const o=qx(s,e,t,n),r=Ux(i,s,t.lineHeight);return{itemWidth:o,itemHeight:r}}function qx(e,t,n,s){let i=e.text;return i&&typeof i!="string"&&(i=i.reduce((o,r)=>o.length>r.length?o:r)),t+n.size/2+s.measureText(i).width}function Ux(e,t,n){let s=e;return typeof t.text!="string"&&(s=al(t,n)),s}function al(e,t){const n=e.text?e.text.length:0;return t*n}function Yx(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var Jx={id:"legend",_element:Zr,start(e,t,n){const s=e.legend=new Zr({ctx:e.ctx,options:n,chart:e});xt.configure(e,s,n),xt.addBox(e,s)},stop(e){xt.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const s=e.legend;xt.configure(e,s,n),s.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 s=t.datasetIndex,i=n.chart;i.isDatasetVisible(s)?(i.hide(s),t.hidden=!0):(i.show(s),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:s,textAlign:i,color:o,useBorderRadius:r,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(c=>{const l=c.controller.getStyle(n?0:void 0),u=vt(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:s||l.pointStyle,rotation:l.rotation,textAlign:i||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 ho extends Nt{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 s=this.options;if(this.left=0,this.top=0,!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t,this.height=this.bottom=n;const i=nt(s.text)?s.text.length:1;this._padding=vt(s.padding);const o=i*dt(s.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:s,bottom:i,right:o,options:r}=this,a=r.align;let c=0,l,u,h;return this.isHorizontal()?(u=_t(a,s,o),h=n+t,l=o-s):(r.position==="left"?(u=s+t,h=_t(a,i,n),c=Z*-.5):(u=o-t,h=_t(a,n,i),c=Z*.5),l=i-n),{titleX:u,titleY:h,maxWidth:l,rotation:c}}draw(){const t=this.ctx,n=this.options;if(!n.display)return;const s=dt(n.font),o=s.lineHeight/2+this._padding.top,{titleX:r,titleY:a,maxWidth:c,rotation:l}=this._drawArgs(o);Me(t,n.text,0,0,s,{color:n.color,maxWidth:c,rotation:l,textAlign:no(n.align),textBaseline:"middle",translation:[r,a]})}}function Kx(e,t){const n=new ho({ctx:e.ctx,options:t,chart:e});xt.configure(e,n,t),xt.addBox(e,n),e.titleBlock=n}var Xx={id:"title",_element:ho,start(e,t,n){Kx(e,n)},stop(e){const t=e.titleBlock;xt.removeBox(e,t),delete e.titleBlock},beforeUpdate(e,t,n){const s=e.titleBlock;xt.configure(e,s,n),s.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 Jn=new WeakMap;var Gx={id:"subtitle",start(e,t,n){const s=new ho({ctx:e.ctx,options:n,chart:e});xt.configure(e,s,n),xt.addBox(e,s),Jn.set(e,s)},stop(e){xt.removeBox(e,Jn.get(e)),Jn.delete(e)},beforeUpdate(e,t,n){const s=Jn.get(e);xt.configure(e,s,n),s.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 on={average(e){if(!e.length)return!1;let t,n,s=new Set,i=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();s.add(c.x),i+=c.y,++o}}return o===0||s.size===0?!1:{x:[...s].reduce((a,c)=>a+c)/s.size,y:i/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,s=t.y,i=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=ii(t,l);u<i&&(i=u,a=c)}}if(a){const c=a.tooltipPosition();n=c.x,s=c.y}return{x:n,y:s}}};function Ft(e,t){return t&&(nt(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Vt(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(`
|
|
100
100
|
`)>-1?e.split(`
|
|
101
|
-
`):e}function Gx(e,t){const{element:n,datasetIndex:s,index:i}=t,o=e.getDatasetMeta(s).controller,{label:r,value:a}=o.getLabelAndValue(i);return{chart:e,label:r,parsed:o.getParsed(i),raw:e.data.datasets[s].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:s,element:n}}function Vr(e,t){const n=e.chart.ctx,{body:s,footer:i,title:o}=e,{boxWidth:r,boxHeight:a}=t,c=ht(t.bodyFont),l=ht(t.titleFont),u=ht(t.footerFont),h=o.length,d=i.length,f=s.length,p=vt(t.padding);let g=p.height,m=0,b=s.reduce((S,k)=>S+k.before.length+k.lines.length+k.after.length,0);if(b+=e.beforeBody.length+e.afterBody.length,h&&(g+=h*l.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){const S=t.displayColors?Math.max(a,c.lineHeight):c.lineHeight;g+=f*S+(b-f)*c.lineHeight+(b-1)*t.bodySpacing}d&&(g+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let x=0;const M=function(S){m=Math.max(m,n.measureText(S).width+x)};return n.save(),n.font=l.string,W(e.title,M),n.font=c.string,W(e.beforeBody.concat(e.afterBody),M),x=t.displayColors?r+2+t.boxPadding:0,W(s,S=>{W(S.before,M),W(S.lines,M),W(S.after,M)}),x=0,n.font=u.string,W(e.footer,M),n.restore(),m+=p.width,{width:m,height:g}}function Qx(e,t){const{y:n,height:s}=t;return n<s/2?"top":n>e.height-s/2?"bottom":"center"}function t0(e,t,n,s){const{x:i,width:o}=s,r=n.caretSize+n.caretPadding;if(e==="left"&&i+o+r>t.width||e==="right"&&i-o-r<0)return!0}function e0(e,t,n,s){const{x:i,width:o}=n,{width:r,chartArea:{left:a,right:c}}=e;let l="center";return s==="center"?l=i<=(a+c)/2?"left":"right":i<=o/2?l="left":i>=r-o/2&&(l="right"),t0(l,e,t,n)&&(l="center"),l}function Wr(e,t,n){const s=n.yAlign||t.yAlign||Qx(e,n);return{xAlign:n.xAlign||t.xAlign||e0(e,t,n,s),yAlign:s}}function n0(e,t){let{x:n,width:s}=e;return t==="right"?n-=s:t==="center"&&(n-=s/2),n}function s0(e,t,n){let{y:s,height:i}=e;return t==="top"?s+=n:t==="bottom"?s-=i+n:s-=i/2,s}function qr(e,t,n,s){const{caretSize:i,caretPadding:o,cornerRadius:r}=e,{xAlign:a,yAlign:c}=n,l=i+o,{topLeft:u,topRight:h,bottomLeft:d,bottomRight:f}=ke(r);let p=n0(t,a);const g=s0(t,c,l);return c==="center"?a==="left"?p+=l:a==="right"&&(p-=l):a==="left"?p-=Math.max(u,d)+i:a==="right"&&(p+=Math.max(h,f)+i),{x:dt(p,0,s.width-t.width),y:dt(g,0,s.height-t.height)}}function Xn(e,t,n){const s=vt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-s.right:e.x+s.left}function Ur(e){return Ft([],Vt(e))}function i0(e,t,n){return le(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function Yr(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const ll={beforeTitle:Ht,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,s=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex<s)return n[t.dataIndex]}return""},afterTitle:Ht,beforeBody:Ht,beforeLabel:Ht,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 N(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:Ht,afterBody:Ht,beforeFooter:Ht,footer:Ht,afterFooter:Ht};function wt(e,t,n,s){const i=e[t].call(n,s);return typeof i>"u"?ll[t].call(n,s):i}class fi extends Nt{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,s=this.options.setContext(this.getContext()),i=s.enabled&&n.options.animation&&s.animations,o=new Hc(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=i0(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:s}=n,i=wt(s,"beforeTitle",this,t),o=wt(s,"title",this,t),r=wt(s,"afterTitle",this,t);let a=[];return a=Ft(a,Vt(i)),a=Ft(a,Vt(o)),a=Ft(a,Vt(r)),a}getBeforeBody(t,n){return Ur(wt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:s}=n,i=[];return W(t,o=>{const r={before:[],lines:[],after:[]},a=Yr(s,o);Ft(r.before,Vt(wt(a,"beforeLabel",this,o))),Ft(r.lines,wt(a,"label",this,o)),Ft(r.after,Vt(wt(a,"afterLabel",this,o))),i.push(r)}),i}getAfterBody(t,n){return Ur(wt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:s}=n,i=wt(s,"beforeFooter",this,t),o=wt(s,"footer",this,t),r=wt(s,"afterFooter",this,t);let a=[];return a=Ft(a,Vt(i)),a=Ft(a,Vt(o)),a=Ft(a,Vt(r)),a}_createItems(t){const n=this._active,s=this.chart.data,i=[],o=[],r=[];let a=[],c,l;for(c=0,l=n.length;c<l;++c)a.push(Gx(this.chart,n[c]));return t.filter&&(a=a.filter((u,h,d)=>t.filter(u,h,d,s))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,s))),W(a,u=>{const h=Yr(t.callbacks,u);i.push(wt(h,"labelColor",this,u)),o.push(wt(h,"labelPointStyle",this,u)),r.push(wt(h,"labelTextColor",this,u))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,n){const s=this.options.setContext(this.getContext()),i=this._active;let o,r=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{const a=on[s.position].call(this,i,this._eventPosition);r=this._createItems(s),this.title=this.getTitle(r,s),this.beforeBody=this.getBeforeBody(r,s),this.body=this.getBody(r,s),this.afterBody=this.getAfterBody(r,s),this.footer=this.getFooter(r,s);const c=this._size=Vr(this,s),l=Object.assign({},a,c),u=Wr(this.chart,s,l),h=qr(s,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&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,s,i){const o=this.getCaretPosition(t,s,i);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,s){const{xAlign:i,yAlign:o}=this,{caretSize:r,cornerRadius:a}=s,{topLeft:c,topRight:l,bottomLeft:u,bottomRight:h}=ke(a),{x:d,y:f}=t,{width:p,height:g}=n;let m,b,x,M,S,k;return o==="center"?(S=f+g/2,i==="left"?(m=d,b=m-r,M=S+r,k=S-r):(m=d+p,b=m+r,M=S-r,k=S+r),x=m):(i==="left"?b=d+Math.max(c,u)+r:i==="right"?b=d+p-Math.max(l,h)-r:b=this.caretX,o==="top"?(M=f,S=M-r,m=b-r,x=b+r):(M=f+g,S=M+r,m=b+r,x=b-r),k=M),{x1:m,x2:b,x3:x,y1:M,y2:S,y3:k}}drawTitle(t,n,s){const i=this.title,o=i.length;let r,a,c;if(o){const l=Le(s.rtl,this.x,this.width);for(t.x=Xn(this,s.titleAlign,s),n.textAlign=l.textAlign(s.titleAlign),n.textBaseline="middle",r=ht(s.titleFont),a=s.titleSpacing,n.fillStyle=s.titleColor,n.font=r.string,c=0;c<o;++c)n.fillText(i[c],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,c+1===o&&(t.y+=s.titleMarginBottom-a)}}_drawColorBox(t,n,s,i,o){const r=this.labelColors[s],a=this.labelPointStyles[s],{boxHeight:c,boxWidth:l}=o,u=ht(o.bodyFont),h=Xn(this,"left",o),d=i.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=i.leftForLtr(d,l)+l/2,b=p+c/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,ri(t,g,m,b),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,ri(t,g,m,b)}else{t.lineWidth=j(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=i.leftForLtr(d,l),m=i.leftForLtr(i.xPlus(d,1),l-2),b=ke(r.borderRadius);Object.values(b).some(x=>x!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,yn(t,{x:g,y:p,w:l,h:c,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),yn(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[s]}drawBody(t,n,s){const{body:i}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:c,boxWidth:l,boxPadding:u}=s,h=ht(s.bodyFont);let d=h.lineHeight,f=0;const p=Le(s.rtl,this.x,this.width),g=function(z){n.fillText(z,p.x(t.x+f),t.y+d/2),t.y+=d+o},m=p.textAlign(r);let b,x,M,S,k,C,P;for(n.textAlign=r,n.textBaseline="middle",n.font=h.string,t.x=Xn(this,m,s),n.fillStyle=s.bodyColor,W(this.beforeBody,g),f=a&&m!=="right"?r==="center"?l/2+u:l+2+u:0,S=0,C=i.length;S<C;++S){for(b=i[S],x=this.labelTextColors[S],n.fillStyle=x,W(b.before,g),M=b.lines,a&&M.length&&(this._drawColorBox(n,t,S,p,s),d=Math.max(h.lineHeight,c)),k=0,P=M.length;k<P;++k)g(M[k]),d=h.lineHeight;W(b.after,g)}f=0,d=h.lineHeight,W(this.afterBody,g),t.y-=o}drawFooter(t,n,s){const i=this.footer,o=i.length;let r,a;if(o){const c=Le(s.rtl,this.x,this.width);for(t.x=Xn(this,s.footerAlign,s),t.y+=s.footerMarginTop,n.textAlign=c.textAlign(s.footerAlign),n.textBaseline="middle",r=ht(s.footerFont),n.fillStyle=s.footerColor,n.font=r.string,a=0;a<o;++a)n.fillText(i[a],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+s.footerSpacing}}drawBackground(t,n,s,i){const{xAlign:o,yAlign:r}=this,{x:a,y:c}=t,{width:l,height:u}=s,{topLeft:h,topRight:d,bottomLeft:f,bottomRight:p}=ke(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+h,c),r==="top"&&this.drawCaret(t,n,s,i),n.lineTo(a+l-d,c),n.quadraticCurveTo(a+l,c,a+l,c+d),r==="center"&&o==="right"&&this.drawCaret(t,n,s,i),n.lineTo(a+l,c+u-p),n.quadraticCurveTo(a+l,c+u,a+l-p,c+u),r==="bottom"&&this.drawCaret(t,n,s,i),n.lineTo(a+f,c+u),n.quadraticCurveTo(a,c+u,a,c+u-f),r==="center"&&o==="left"&&this.drawCaret(t,n,s,i),n.lineTo(a,c+h),n.quadraticCurveTo(a,c,a+h,c),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,s=this.$animations,i=s&&s.x,o=s&&s.y;if(i||o){const r=on[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=Vr(this,t),c=Object.assign({},r,this._size),l=Wr(n,t,c),u=qr(t,c,l,n);(i._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 s=this.opacity;if(!s)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;const r=vt(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=s,this.drawBackground(o,t,i,n),Lc(t,n.textDirection),o.y+=r.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),$c(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const s=this._active,i=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=!fs(s,i),r=this._positionChanged(i,n);(o||r)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,s=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,o=this._active||[],r=this._getActiveElements(t,o,n,s),a=this._positionChanged(r,t),c=n||!fs(r,o)||a;return c&&(this._active=r,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),c}_getActiveElements(t,n,s,i){const o=this.options;if(t.type==="mouseout")return[];if(!i)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,s);return o.reverse&&r.reverse(),r}_positionChanged(t,n){const{caretX:s,caretY:i,options:o}=this,r=on[o.position].call(this,t,n);return r!==!1&&(s!==r.x||i!==r.y)}}T(fi,"positioners",on);var o0={id:"tooltip",_element:fi,positioners:on,afterInit(e,t,n){n&&(e.tooltip=new fi({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:ll},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"]},r0=Object.freeze({__proto__:null,Colors:_x,Decimation:kx,Filler:Hx,Legend:Yx,SubTitle:Kx,Title:Xx,Tooltip:o0});const a0=(e,t,n,s)=>(typeof t=="string"?(n=e.push(t)-1,s.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function c0(e,t,n,s){const i=e.indexOf(t);if(i===-1)return a0(e,t,n,s);const o=e.lastIndexOf(t);return i!==o?n:i}const l0=(e,t)=>e===null?null:dt(Math.round(e),0,t);function Jr(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class pi extends Te{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const s=this.getLabels();for(const{index:i,label:o}of n)s[i]===o&&s.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(N(t))return null;const s=this.getLabels();return n=isFinite(n)&&s[n]===t?n:c0(s,t,D(n,t),this._addedLabels),l0(n,s.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:s,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(s=0),n||(i=this.getLabels().length-1)),this.min=s,this.max=i}buildTicks(){const t=this.min,n=this.max,s=this.options.offset,i=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(s?0:1),1),this._startValue=this.min-(s?.5:0);for(let r=t;r<=n;r++)i.push({value:r});return i}getLabelForValue(t){return Jr.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}}T(pi,"id","category"),T(pi,"defaults",{ticks:{callback:Jr}});function u0(e,t){const n=[],{bounds:i,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=!N(r),x=!N(a),M=!N(l),S=(m-g)/(h+1);let k=Vo((m-g)/p/f)*f,C,P,z,O;if(k<1e-14&&!b&&!x)return[{value:g},{value:m}];O=Math.ceil(m/k)-Math.floor(g/k),O>p&&(k=Vo(O*k/p/f)*f),N(c)||(C=Math.pow(10,c),k=Math.ceil(k*C)/C),i==="ticks"?(P=Math.floor(g/k)*k,z=Math.ceil(m/k)*k):(P=g,z=m),b&&x&&o&&nb((a-r)/o,k/1e3)?(O=Math.round(Math.min((a-r)/k,u)),k=(a-r)/O,P=r,z=a):M?(P=b?r:P,z=x?a:z,O=l-1,k=(z-P)/O):(O=(z-P)/k,cn(O,Math.round(O),k/1e3)?O=Math.round(O):O=Math.ceil(O));const E=Math.max(Wo(k),Wo(P));C=Math.pow(10,N(c)?E:c),P=Math.round(P*C)/C,z=Math.round(z*C)/C;let L=0;for(b&&(d&&P!==r?(n.push({value:r}),P<r&&L++,cn(Math.round((P+L*k)*C)/C,r,Xr(r,S,e))&&L++):P<r&&L++);L<O;++L){const B=Math.round((P+L*k)*C)/C;if(x&&B>a)break;n.push({value:B})}return x&&d&&z!==a?n.length&&cn(n[n.length-1].value,a,Xr(a,S,e))?n[n.length-1].value=a:n.push({value:a}):(!x||z===a)&&n.push({value:z}),n}function Xr(e,t,{horizontal:n,minRotation:s}){const i=Lt(s),o=(n?Math.sin(i):Math.cos(i))||.001,r=.75*t*(""+e).length;return Math.min(t/o,r)}class xs extends Te{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 N(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:s}=this.getUserBounds();let{min:i,max:o}=this;const r=c=>i=n?i:c,a=c=>o=s?o:c;if(t){const c=Bt(i),l=Bt(o);c<0&&l<0?a(0):c>0&&l>0&&r(0)}if(i===o){let c=o===0?1:Math.abs(o*.05);a(o+c),t||r(i-c)}this.min=i,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:s}=t,i;return s?(i=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const i={maxTicks:s,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=u0(i,o);return t.bounds==="ticks"&&yc(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,s=this.max;if(super.configure(),this.options.offset&&t.length){const i=(s-n)/Math.max(t.length-1,1)/2;n-=i,s+=i}this._startValue=n,this._endValue=s,this._valueRange=s-n}getLabelForValue(t){return An(t,this.chart.options.locale,this.options.ticks.format)}}class gi extends xs{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=rt(t)?t:0,this.max=rt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,s=Lt(this.options.ticks.minRotation),i=(t?Math.sin(s):Math.cos(s))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}T(gi,"id","linear"),T(gi,"defaults",{ticks:{callback:zs.formatters.numeric}});const vn=e=>Math.floor(Gt(e)),me=(e,t)=>Math.pow(10,vn(e)+t);function Kr(e){return e/Math.pow(10,vn(e))===1}function Gr(e,t,n){const s=Math.pow(10,n),i=Math.floor(e/s);return Math.ceil(t/s)-i}function h0(e,t){const n=t-e;let s=vn(n);for(;Gr(e,t,s)>10;)s++;for(;Gr(e,t,s)<10;)s--;return Math.min(s,vn(e))}function d0(e,{min:t,max:n}){t=Ct(e.min,t);const s=[],i=vn(t);let o=h0(t,n),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),c=i>o?Math.pow(10,i):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=Ct(e.min,Math.round((c+u+h*Math.pow(10,o))*r)/r);for(;d<n;)s.push({value:d,major:Kr(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=Ct(e.max,d);return s.push({value:f,major:Kr(f),significand:h}),s}class mi extends Te{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const s=xs.prototype.parse.apply(this,[t,n]);if(s===0){this._zero=!0;return}return rt(s)&&s>0?s:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=rt(t)?Math.max(0,t):null,this.max=rt(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!rt(this._userMin)&&(this.min=t===me(this.min,0)?me(this.min,-1):me(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let s=this.min,i=this.max;const o=a=>s=t?s:a,r=a=>i=n?i:a;s===i&&(s<=0?(o(1),r(10)):(o(me(s,-1)),r(me(i,1)))),s<=0&&o(me(i,-1)),i<=0&&r(me(s,1)),this.min=s,this.max=i}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},s=d0(n,this);return t.bounds==="ticks"&&yc(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}getLabelForValue(t){return t===void 0?"0":An(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Gt(t),this._valueRange=Gt(this.max)-Gt(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Gt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}T(mi,"id","logarithmic"),T(mi,"defaults",{ticks:{callback:zs.formatters.logarithmic,major:{enabled:!0}}});function bi(e){const t=e.ticks;if(t.display&&e.display){const n=vt(t.backdropPadding);return D(t.font&&t.font.size,st.font.size)+n.height}return 0}function f0(e,t,n){return n=nt(n)?n:[n],{w:yb(e,t.string,n),h:n.length*t.lineHeight}}function Qr(e,t,n,s,i){return e===s||e===i?{start:t-n/2,end:t+n/2}:e<s||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function p0(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),s=[],i=[],o=e._pointLabels.length,r=e.options.pointLabels,a=r.centerPointLabels?Z/o:0;for(let c=0;c<o;c++){const l=r.setContext(e.getPointLabelContext(c));i[c]=l.padding;const u=e.getPointPosition(c,e.drawingArea+i[c],a),h=ht(l.font),d=f0(e.ctx,h,e._pointLabels[c]);s[c]=d;const f=yt(e.getIndexAngle(c)+a),p=Math.round(to(f)),g=Qr(p,u.x,d.w,0,180),m=Qr(p,u.y,d.h,90,270);g0(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=_0(e,s,i)}function g0(e,t,n,s,i){const o=Math.abs(Math.sin(n)),r=Math.abs(Math.cos(n));let a=0,c=0;s.start<t.l?(a=(t.l-s.start)/o,e.l=Math.min(e.l,t.l-a)):s.end>t.r&&(a=(s.end-t.r)/o,e.r=Math.max(e.r,t.r+a)),i.start<t.t?(c=(t.t-i.start)/r,e.t=Math.min(e.t,t.t-c)):i.end>t.b&&(c=(i.end-t.b)/r,e.b=Math.max(e.b,t.b+c))}function m0(e,t,n){const s=e.drawingArea,{extra:i,additionalAngle:o,padding:r,size:a}=n,c=e.getPointPosition(t,s+i+r,o),l=Math.round(to(yt(c.angle+lt))),u=v0(c.y,a.h,l),h=y0(l),d=x0(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 b0(e,t){if(!t)return!0;const{left:n,top:s,right:i,bottom:o}=e;return!(Jt({x:n,y:s},t)||Jt({x:n,y:o},t)||Jt({x:i,y:s},t)||Jt({x:i,y:o},t))}function _0(e,t,n){const s=[],i=e._pointLabels.length,o=e.options,{centerPointLabels:r,display:a}=o.pointLabels,c={extra:bi(o)/2,additionalAngle:r?Z/i:0};let l;for(let u=0;u<i;u++){c.padding=n[u],c.size=t[u];const h=m0(e,u,c);s.push(h),a==="auto"&&(h.visible=b0(h,l),h.visible&&(l=h))}return s}function y0(e){return e===0||e===180?"center":e<180?"left":"right"}function x0(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function v0(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function k0(e,t,n){const{left:s,top:i,right:o,bottom:r}=n,{backdropColor:a}=t;if(!N(a)){const c=ke(t.borderRadius),l=vt(t.backdropPadding);e.fillStyle=a;const u=s-l.left,h=i-l.top,d=o-s+l.width,f=r-i+l.height;Object.values(c).some(p=>p!==0)?(e.beginPath(),yn(e,{x:u,y:h,w:d,h:f,radius:c}),e.fill()):e.fillRect(u,h,d,f)}}function w0(e,t){const{ctx:n,options:{pointLabels:s}}=e;for(let i=t-1;i>=0;i--){const o=e._pointLabelItems[i];if(!o.visible)continue;const r=s.setContext(e.getPointLabelContext(i));k0(n,r,o);const a=ht(r.font),{x:c,y:l,textAlign:u}=o;Me(n,e._pointLabels[i],c,l+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function ul(e,t,n,s){const{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,G);else{let o=e.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let r=1;r<s;r++)o=e.getPointPosition(r,t),i.lineTo(o.x,o.y)}}function S0(e,t,n,s,i){const o=e.ctx,r=t.circular,{color:a,lineWidth:c}=t;!r&&!s||!a||!c||n<0||(o.save(),o.strokeStyle=a,o.lineWidth=c,o.setLineDash(i.dash||[]),o.lineDashOffset=i.dashOffset,o.beginPath(),ul(e,n,r,s),o.closePath(),o.stroke(),o.restore())}function M0(e,t,n){return le(e,{label:n,index:t,type:"pointLabel"})}class rn extends xs{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=vt(bi(this.options)/2),n=this.width=this.maxWidth-t.width,s=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+s/2+t.top),this.drawingArea=Math.floor(Math.min(n,s)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=rt(t)&&!isNaN(t)?t:0,this.max=rt(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/bi(this.options))}generateTickLabels(t){xs.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,s)=>{const i=X(this.options.pointLabels.callback,[n,s],this);return i||i===0?i:""}).filter((n,s)=>this.chart.getDataVisibility(s))}fit(){const t=this.options;t.display&&t.pointLabels.display?p0(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,s,i){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((s-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,s,i))}getIndexAngle(t){const n=G/(this._pointLabels.length||1),s=this.options.startAngle||0;return yt(t*n+Lt(s))}getDistanceFromCenterForValue(t){if(N(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(N(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 s=n[t];return M0(this.getContext(),t,s)}}getPointPosition(t,n,s=0){const i=this.getIndexAngle(t)-lt+s;return{x:Math.cos(i)*n+this.xCenter,y:Math.sin(i)*n+this.yCenter,angle:i}}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:s,right:i,bottom:o}=this._pointLabelItems[t];return{left:n,top:s,right:i,bottom:o}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const s=this.ctx;s.save(),s.beginPath(),ul(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),s.closePath(),s.fillStyle=t,s.fill(),s.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:s,grid:i,border:o}=n,r=this._pointLabels.length;let a,c,l;if(n.pointLabels.display&&w0(this,r),i.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=i.setContext(d),p=o.setContext(d);S0(this,f,c,r,p)}}),s.display){for(t.save(),a=r-1;a>=0;a--){const u=s.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,s=n.ticks;if(!s.display)return;const i=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,c)=>{if(c===0&&this.min>=0&&!n.reverse)return;const l=s.setContext(this.getContext(c)),u=ht(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=vt(l.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}Me(t,a.label,0,-o,u,{color:l.color,strokeColor:l.textStrokeColor,strokeWidth:l.textStrokeWidth})}),t.restore()}drawTitle(){}}T(rn,"id","radialLinear"),T(rn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:zs.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),T(rn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),T(rn,"descriptors",{angleLines:{_fallback:"grid"}});const Es={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}},St=Object.keys(Es);function ta(e,t){return e-t}function ea(e,t){if(N(t))return null;const n=e._adapter,{parser:s,round:i,isoWeekday:o}=e._parseOpts;let r=t;return typeof s=="function"&&(r=s(r)),rt(r)||(r=typeof s=="string"?n.parse(r,s):n.parse(r)),r===null?null:(i&&(r=i==="week"&&(je(o)||o===!0)?n.startOf(r,"isoWeek",o):n.startOf(r,i)),+r)}function na(e,t,n,s){const i=St.length;for(let o=St.indexOf(e);o<i-1;++o){const r=Es[St[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((n-t)/(a*r.size))<=s)return St[o]}return St[i-1]}function P0(e,t,n,s,i){for(let o=St.length-1;o>=St.indexOf(n);o--){const r=St[o];if(Es[r].common&&e._adapter.diff(i,s,r)>=t-1)return r}return St[n?St.indexOf(n):0]}function T0(e){for(let t=St.indexOf(e)+1,n=St.length;t<n;++t)if(Es[St[t]].common)return St[t]}function sa(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:s,hi:i}=eo(n,t),o=n[s]>=t?n[s]:n[i];e[o]=!0}}function C0(e,t,n,s){const i=e._adapter,o=+i.startOf(t[0].value,s),r=t[t.length-1].value;let a,c;for(a=o;a<=r;a=+i.add(a,1,s))c=n[a],c>=0&&(t[c].major=!0);return t}function ia(e,t,n){const s=[],i={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],i[a]=r,s.push({value:a,major:!1});return o===0||!n?s:C0(e,s,i,n)}class kn extends Te{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 s=t.time||(t.time={}),i=this._adapter=new L_._date(t.adapters.date);i.init(n),an(s.displayFormats,i.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:ea(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,s=t.time.unit||"day";let{min:i,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function c(l){!r&&!isNaN(l.min)&&(i=Math.min(i,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))),i=rt(i)&&!isNaN(i)?i:+n.startOf(Date.now(),s),o=rt(o)&&!isNaN(o)?o:+n.endOf(Date.now(),s)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],s=t[t.length-1]),{min:n,max:s}}buildTicks(){const t=this.options,n=t.time,s=t.ticks,i=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const o=this.min,r=this.max,a=rb(i,o,r);return this._unit=n.unit||(s.autoSkip?na(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):P0(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!s.major.enabled||this._unit==="year"?void 0:T0(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),ia(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,s=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?s=o:s=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;n=dt(n,0,r),s=dt(s,0,r),this._offsets={start:n,end:s,factor:1/(n+1+s)}}_generate(){const t=this._adapter,n=this.min,s=this.max,i=this.options,o=i.time,r=o.unit||na(o.minUnit,n,s,this._getLabelCapacity(n)),a=D(i.ticks.stepSize,1),c=r==="week"?o.isoWeekday:!1,l=je(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(s,n,r)>1e5*a)throw new Error(n+" and "+s+" are too far apart with stepSize of "+a+" "+r);const p=i.ticks.source==="data"&&this.getDataTimestamps();for(d=h,f=0;d<s;d=+t.add(d,a,r),f++)sa(u,d,p);return(d===s||i.bounds==="ticks"||f===1)&&sa(u,d,p),Object.keys(u).sort(ta).map(g=>+g)}getLabelForValue(t){const n=this._adapter,s=this.options.time;return s.tooltipFormat?n.format(t,s.tooltipFormat):n.format(t,s.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,o=this._unit,r=n||i[o];return this._adapter.format(t,r)}_tickFormatFunction(t,n,s,i){const o=this.options,r=o.ticks.callback;if(r)return X(r,[t,n,s],this);const a=o.time.displayFormats,c=this._unit,l=this._majorUnit,u=c&&a[c],h=l&&a[l],d=s[n],f=l&&h&&d&&d.major;return this._adapter.format(t,i||(f?h:u))}generateTickLabels(t){let n,s,i;for(n=0,s=t.length;n<s;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,s=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+s)*n.factor)}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+s*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,s=this.ctx.measureText(t).width,i=Lt(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(i),r=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:s*o+a*r,h:s*r+a*o}}_getLabelCapacity(t){const n=this.options.time,s=n.displayFormats,i=s[n.unit]||s.millisecond,o=this._tickFormatFunction(t,0,ia(this,[t],this._majorUnit),i),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,s;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,s=i.length;n<s;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,s;if(t.length)return t;const i=this.getLabels();for(n=0,s=i.length;n<s;++n)t.push(ea(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return kc(t.sort(ta))}}T(kn,"id","time"),T(kn,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function Kn(e,t,n){let s=0,i=e.length-1,o,r,a,c;n?(t>=e[s].pos&&t<=e[i].pos&&({lo:s,hi:i}=Yt(e,"pos",t)),{pos:o,time:a}=e[s],{pos:r,time:c}=e[i]):(t>=e[s].time&&t<=e[i].time&&({lo:s,hi:i}=Yt(e,"time",t)),{time:o,pos:a}=e[s],{time:r,pos:c}=e[i]);const l=r-o;return l?a+(c-a)*(t-o)/l:a}class _i extends kn{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=Kn(n,this.min),this._tableRange=Kn(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:s}=this,i=[],o=[];let r,a,c,l,u;for(r=0,a=t.length;r<a;++r)l=t[r],l>=n&&l<=s&&i.push(l);if(i.length<2)return[{time:n,pos:0},{time:s,pos:1}];for(r=0,a=i.length;r<a;++r)u=i[r+1],c=i[r-1],l=i[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 s=super.getDataTimestamps();return(!s.includes(t)||!s.length)&&s.splice(0,0,t),(!s.includes(n)||s.length===1)&&s.push(n),s.sort((i,o)=>i-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),s=this.getLabelTimestamps();return n.length&&s.length?t=this.normalize(n.concat(s)):t=n.length?n:s,t=this._cache.all=t,t}getDecimalForValue(t){return(Kn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return Kn(this._table,s*this._tableRange+this._minPos,!0)}}T(_i,"id","timeseries"),T(_i,"defaults",kn.defaults);var z0=Object.freeze({__proto__:null,CategoryScale:pi,LinearScale:gi,LogarithmicScale:mi,RadialLinearScale:rn,TimeScale:kn,TimeSeriesScale:_i});const O0=[E_,hx,r0,z0],R0={Enterprise:"#1e40af","Mid-Market":"#0d9488",SMB:"#059669",Startup:"#6366f1"},De={annualRevenue:"Annual Revenue",employeeCount:"Employees",accountAge:"Account Age (mo)",engagementScore:"Engagement",supportTickets:"Support Tickets",nps:"NPS"};qt.register(...O0);const yi={info:console.log.bind(console,"[APP]"),error:console.error.bind(console,"[APP]")},Gn=document.querySelector(".main"),oa=document.getElementById("x-axis"),ra=document.getElementById("y-axis"),aa=document.getElementById("size-metric"),A0=document.getElementById("scatter-chart"),ca=document.getElementById("legend"),hl=document.getElementById("detail-panel"),A={customers:[],segments:[],chart:null,xAxis:"annualRevenue",yAxis:"engagementScore",sizeMetric:"off",hiddenSegments:new Set,selectedCustomer:null};function ve(e,t){switch(t){case"annualRevenue":return e>=1e6?`$${(e/1e6).toFixed(1)}M`:`$${(e/1e3).toFixed(0)}K`;case"employeeCount":return e.toLocaleString();case"accountAge":return`${e}mo`;case"engagementScore":return`${e}`;case"supportTickets":return`${e}`;case"nps":return e>=0?`+${e}`:`${e}`;default:return`${e}`}}function I0(e,t){const n=e.map(s=>s[t]);return{min:Math.min(...n),max:Math.max(...n)}}function D0(e,t,n){return n===t?12:6+(e-t)/(n-t)*24}function E0(){return A.customers.filter(e=>!A.hiddenSegments.has(e.segment))}function dl(){const e=E0(),t=[...new Set(e.map(s=>s.segment))];let n=null;return A.sizeMetric!=="off"&&(n=I0(A.customers,A.sizeMetric)),t.map(s=>{const i=e.filter(r=>r.segment===s),o=R0[s]||"#888888";return{label:s,data:i.map(r=>({x:r[A.xAxis],y:r[A.yAxis],r:n&&A.sizeMetric!=="off"?D0(r[A.sizeMetric],n.min,n.max):8,customer:r})),backgroundColor:o+"aa",borderColor:o,borderWidth:1,hoverBackgroundColor:o,hoverBorderColor:"#ffffff",hoverBorderWidth:2}})}let Xt=null;function la(e,t){return e?e.includes("light-dark(")?(Xt||(Xt=document.createElement("div"),Xt.style.position="absolute",Xt.style.visibility="hidden",Xt.style.pointerEvents="none",document.body.appendChild(Xt)),Xt.style.color=e,getComputedStyle(Xt).color||t):e:t}function fl(){const e=getComputedStyle(document.documentElement),t=e.getPropertyValue("--color-text-secondary").trim(),n=e.getPropertyValue("--color-border-primary").trim();return{textColor:la(t,"#6b7280"),gridColor:la(n,"#e5e7eb")}}function fo(){const{textColor:e,gridColor:t}=fl();return new qt(A0,{type:"bubble",data:{datasets:dl()},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:300},interaction:{intersect:!0,mode:"nearest"},plugins:{legend:{display:!1},tooltip:{enabled:!0,callbacks:{label:n=>{const i=n.raw.customer;return[i.name,`${De[A.xAxis]}: ${ve(i[A.xAxis],A.xAxis)}`,`${De[A.yAxis]}: ${ve(i[A.yAxis],A.yAxis)}`]}}}},scales:{x:{title:{display:!0,text:De[A.xAxis],color:e,font:{size:11,weight:"bold"}},ticks:{color:e,font:{size:10},callback:n=>ve(n,A.xAxis)},grid:{color:t}},y:{title:{display:!0,text:De[A.yAxis],color:e,font:{size:11,weight:"bold"}},ticks:{color:e,font:{size:10},callback:n=>ve(n,A.yAxis)},grid:{color:t}}},onClick:(n,s)=>{if(s.length>0){const i=s[0],r=A.chart.data.datasets[i.datasetIndex].data[i.index];A.selectedCustomer=r.customer,ua(r.customer)}},onHover:(n,s)=>{if(s.length>0&&!A.selectedCustomer){const i=s[0],r=A.chart.data.datasets[i.datasetIndex].data[i.index];ua(r.customer)}else s.length===0&&!A.selectedCustomer&&gl()}}})}function In(){if(!A.chart)return;const{textColor:e,gridColor:t}=fl();A.chart.data.datasets=dl();const n=A.chart.options.scales;n.x.title.text=De[A.xAxis],n.y.title.text=De[A.yAxis],n.x.title.color=e,n.y.title.color=e,n.x.ticks.color=e,n.y.ticks.color=e,n.x.ticks.callback=s=>ve(s,A.xAxis),n.y.ticks.callback=s=>ve(s,A.yAxis),n.x.grid.color=t,n.y.grid.color=t,A.chart.update()}function pl(){const e=new Map;for(const t of A.customers)e.set(t.segment,(e.get(t.segment)||0)+1);ca.innerHTML=A.segments.map(t=>{const n=e.get(t.name)||0;return`
|
|
101
|
+
`):e}function Qx(e,t){const{element:n,datasetIndex:s,index:i}=t,o=e.getDatasetMeta(s).controller,{label:r,value:a}=o.getLabelAndValue(i);return{chart:e,label:r,parsed:o.getParsed(i),raw:e.data.datasets[s].data[i],formattedValue:a,dataset:o.getDataset(),dataIndex:i,datasetIndex:s,element:n}}function Vr(e,t){const n=e.chart.ctx,{body:s,footer:i,title:o}=e,{boxWidth:r,boxHeight:a}=t,c=dt(t.bodyFont),l=dt(t.titleFont),u=dt(t.footerFont),h=o.length,d=i.length,f=s.length,p=vt(t.padding);let g=p.height,m=0,b=s.reduce((S,k)=>S+k.before.length+k.lines.length+k.after.length,0);if(b+=e.beforeBody.length+e.afterBody.length,h&&(g+=h*l.lineHeight+(h-1)*t.titleSpacing+t.titleMarginBottom),b){const S=t.displayColors?Math.max(a,c.lineHeight):c.lineHeight;g+=f*S+(b-f)*c.lineHeight+(b-1)*t.bodySpacing}d&&(g+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let x=0;const M=function(S){m=Math.max(m,n.measureText(S).width+x)};return n.save(),n.font=l.string,U(e.title,M),n.font=c.string,U(e.beforeBody.concat(e.afterBody),M),x=t.displayColors?r+2+t.boxPadding:0,U(s,S=>{U(S.before,M),U(S.lines,M),U(S.after,M)}),x=0,n.font=u.string,U(e.footer,M),n.restore(),m+=p.width,{width:m,height:g}}function t0(e,t){const{y:n,height:s}=t;return n<s/2?"top":n>e.height-s/2?"bottom":"center"}function e0(e,t,n,s){const{x:i,width:o}=s,r=n.caretSize+n.caretPadding;if(e==="left"&&i+o+r>t.width||e==="right"&&i-o-r<0)return!0}function n0(e,t,n,s){const{x:i,width:o}=n,{width:r,chartArea:{left:a,right:c}}=e;let l="center";return s==="center"?l=i<=(a+c)/2?"left":"right":i<=o/2?l="left":i>=r-o/2&&(l="right"),e0(l,e,t,n)&&(l="center"),l}function Wr(e,t,n){const s=n.yAlign||t.yAlign||t0(e,n);return{xAlign:n.xAlign||t.xAlign||n0(e,t,n,s),yAlign:s}}function s0(e,t){let{x:n,width:s}=e;return t==="right"?n-=s:t==="center"&&(n-=s/2),n}function i0(e,t,n){let{y:s,height:i}=e;return t==="top"?s+=n:t==="bottom"?s-=i+n:s-=i/2,s}function qr(e,t,n,s){const{caretSize:i,caretPadding:o,cornerRadius:r}=e,{xAlign:a,yAlign:c}=n,l=i+o,{topLeft:u,topRight:h,bottomLeft:d,bottomRight:f}=ke(r);let p=s0(t,a);const g=i0(t,c,l);return c==="center"?a==="left"?p+=l:a==="right"&&(p-=l):a==="left"?p-=Math.max(u,d)+i:a==="right"&&(p+=Math.max(h,f)+i),{x:ft(p,0,s.width-t.width),y:ft(g,0,s.height-t.height)}}function Kn(e,t,n){const s=vt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-s.right:e.x+s.left}function Ur(e){return Ft([],Vt(e))}function o0(e,t,n){return le(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function Yr(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const cl={beforeTitle:Bt,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,s=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(s>0&&t.dataIndex<s)return n[t.dataIndex]}return""},afterTitle:Bt,beforeBody:Bt,beforeLabel:Bt,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 N(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:Bt,afterBody:Bt,beforeFooter:Bt,footer:Bt,afterFooter:Bt};function wt(e,t,n,s){const i=e[t].call(n,s);return typeof i>"u"?cl[t].call(n,s):i}class fi extends Nt{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,s=this.options.setContext(this.getContext()),i=s.enabled&&n.options.animation&&s.animations,o=new jc(this.chart,i);return i._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=o0(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:s}=n,i=wt(s,"beforeTitle",this,t),o=wt(s,"title",this,t),r=wt(s,"afterTitle",this,t);let a=[];return a=Ft(a,Vt(i)),a=Ft(a,Vt(o)),a=Ft(a,Vt(r)),a}getBeforeBody(t,n){return Ur(wt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:s}=n,i=[];return U(t,o=>{const r={before:[],lines:[],after:[]},a=Yr(s,o);Ft(r.before,Vt(wt(a,"beforeLabel",this,o))),Ft(r.lines,wt(a,"label",this,o)),Ft(r.after,Vt(wt(a,"afterLabel",this,o))),i.push(r)}),i}getAfterBody(t,n){return Ur(wt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:s}=n,i=wt(s,"beforeFooter",this,t),o=wt(s,"footer",this,t),r=wt(s,"afterFooter",this,t);let a=[];return a=Ft(a,Vt(i)),a=Ft(a,Vt(o)),a=Ft(a,Vt(r)),a}_createItems(t){const n=this._active,s=this.chart.data,i=[],o=[],r=[];let a=[],c,l;for(c=0,l=n.length;c<l;++c)a.push(Qx(this.chart,n[c]));return t.filter&&(a=a.filter((u,h,d)=>t.filter(u,h,d,s))),t.itemSort&&(a=a.sort((u,h)=>t.itemSort(u,h,s))),U(a,u=>{const h=Yr(t.callbacks,u);i.push(wt(h,"labelColor",this,u)),o.push(wt(h,"labelPointStyle",this,u)),r.push(wt(h,"labelTextColor",this,u))}),this.labelColors=i,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,n){const s=this.options.setContext(this.getContext()),i=this._active;let o,r=[];if(!i.length)this.opacity!==0&&(o={opacity:0});else{const a=on[s.position].call(this,i,this._eventPosition);r=this._createItems(s),this.title=this.getTitle(r,s),this.beforeBody=this.getBeforeBody(r,s),this.body=this.getBody(r,s),this.afterBody=this.getAfterBody(r,s),this.footer=this.getFooter(r,s);const c=this._size=Vr(this,s),l=Object.assign({},a,c),u=Wr(this.chart,s,l),h=qr(s,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&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,s,i){const o=this.getCaretPosition(t,s,i);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,s){const{xAlign:i,yAlign:o}=this,{caretSize:r,cornerRadius:a}=s,{topLeft:c,topRight:l,bottomLeft:u,bottomRight:h}=ke(a),{x:d,y:f}=t,{width:p,height:g}=n;let m,b,x,M,S,k;return o==="center"?(S=f+g/2,i==="left"?(m=d,b=m-r,M=S+r,k=S-r):(m=d+p,b=m+r,M=S-r,k=S+r),x=m):(i==="left"?b=d+Math.max(c,u)+r:i==="right"?b=d+p-Math.max(l,h)-r:b=this.caretX,o==="top"?(M=f,S=M-r,m=b-r,x=b+r):(M=f+g,S=M+r,m=b+r,x=b-r),k=M),{x1:m,x2:b,x3:x,y1:M,y2:S,y3:k}}drawTitle(t,n,s){const i=this.title,o=i.length;let r,a,c;if(o){const l=Le(s.rtl,this.x,this.width);for(t.x=Kn(this,s.titleAlign,s),n.textAlign=l.textAlign(s.titleAlign),n.textBaseline="middle",r=dt(s.titleFont),a=s.titleSpacing,n.fillStyle=s.titleColor,n.font=r.string,c=0;c<o;++c)n.fillText(i[c],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,c+1===o&&(t.y+=s.titleMarginBottom-a)}}_drawColorBox(t,n,s,i,o){const r=this.labelColors[s],a=this.labelPointStyles[s],{boxHeight:c,boxWidth:l}=o,u=dt(o.bodyFont),h=Kn(this,"left",o),d=i.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=i.leftForLtr(d,l)+l/2,b=p+c/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,ri(t,g,m,b),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,ri(t,g,m,b)}else{t.lineWidth=F(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=i.leftForLtr(d,l),m=i.leftForLtr(i.xPlus(d,1),l-2),b=ke(r.borderRadius);Object.values(b).some(x=>x!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,yn(t,{x:g,y:p,w:l,h:c,radius:b}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),yn(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[s]}drawBody(t,n,s){const{body:i}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:c,boxWidth:l,boxPadding:u}=s,h=dt(s.bodyFont);let d=h.lineHeight,f=0;const p=Le(s.rtl,this.x,this.width),g=function(z){n.fillText(z,p.x(t.x+f),t.y+d/2),t.y+=d+o},m=p.textAlign(r);let b,x,M,S,k,C,T;for(n.textAlign=r,n.textBaseline="middle",n.font=h.string,t.x=Kn(this,m,s),n.fillStyle=s.bodyColor,U(this.beforeBody,g),f=a&&m!=="right"?r==="center"?l/2+u:l+2+u:0,S=0,C=i.length;S<C;++S){for(b=i[S],x=this.labelTextColors[S],n.fillStyle=x,U(b.before,g),M=b.lines,a&&M.length&&(this._drawColorBox(n,t,S,p,s),d=Math.max(h.lineHeight,c)),k=0,T=M.length;k<T;++k)g(M[k]),d=h.lineHeight;U(b.after,g)}f=0,d=h.lineHeight,U(this.afterBody,g),t.y-=o}drawFooter(t,n,s){const i=this.footer,o=i.length;let r,a;if(o){const c=Le(s.rtl,this.x,this.width);for(t.x=Kn(this,s.footerAlign,s),t.y+=s.footerMarginTop,n.textAlign=c.textAlign(s.footerAlign),n.textBaseline="middle",r=dt(s.footerFont),n.fillStyle=s.footerColor,n.font=r.string,a=0;a<o;++a)n.fillText(i[a],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+s.footerSpacing}}drawBackground(t,n,s,i){const{xAlign:o,yAlign:r}=this,{x:a,y:c}=t,{width:l,height:u}=s,{topLeft:h,topRight:d,bottomLeft:f,bottomRight:p}=ke(i.cornerRadius);n.fillStyle=i.backgroundColor,n.strokeStyle=i.borderColor,n.lineWidth=i.borderWidth,n.beginPath(),n.moveTo(a+h,c),r==="top"&&this.drawCaret(t,n,s,i),n.lineTo(a+l-d,c),n.quadraticCurveTo(a+l,c,a+l,c+d),r==="center"&&o==="right"&&this.drawCaret(t,n,s,i),n.lineTo(a+l,c+u-p),n.quadraticCurveTo(a+l,c+u,a+l-p,c+u),r==="bottom"&&this.drawCaret(t,n,s,i),n.lineTo(a+f,c+u),n.quadraticCurveTo(a,c+u,a,c+u-f),r==="center"&&o==="left"&&this.drawCaret(t,n,s,i),n.lineTo(a,c+h),n.quadraticCurveTo(a,c,a+h,c),n.closePath(),n.fill(),i.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,s=this.$animations,i=s&&s.x,o=s&&s.y;if(i||o){const r=on[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=Vr(this,t),c=Object.assign({},r,this._size),l=Wr(n,t,c),u=qr(t,c,l,n);(i._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 s=this.opacity;if(!s)return;this._updateAnimationTarget(n);const i={width:this.width,height:this.height},o={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;const r=vt(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=s,this.drawBackground(o,t,i,n),Dc(t,n.textDirection),o.y+=r.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),Lc(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const s=this._active,i=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=!fs(s,i),r=this._positionChanged(i,n);(o||r)&&(this._active=i,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,s=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const i=this.options,o=this._active||[],r=this._getActiveElements(t,o,n,s),a=this._positionChanged(r,t),c=n||!fs(r,o)||a;return c&&(this._active=r,(i.enabled||i.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),c}_getActiveElements(t,n,s,i){const o=this.options;if(t.type==="mouseout")return[];if(!i)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,s);return o.reverse&&r.reverse(),r}_positionChanged(t,n){const{caretX:s,caretY:i,options:o}=this,r=on[o.position].call(this,t,n);return r!==!1&&(s!==r.x||i!==r.y)}}P(fi,"positioners",on);var r0={id:"tooltip",_element:fi,positioners:on,afterInit(e,t,n){n&&(e.tooltip=new fi({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:cl},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"]},a0=Object.freeze({__proto__:null,Colors:yx,Decimation:wx,Filler:Zx,Legend:Jx,SubTitle:Gx,Title:Xx,Tooltip:r0});const c0=(e,t,n,s)=>(typeof t=="string"?(n=e.push(t)-1,s.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function l0(e,t,n,s){const i=e.indexOf(t);if(i===-1)return c0(e,t,n,s);const o=e.lastIndexOf(t);return i!==o?n:i}const u0=(e,t)=>e===null?null:ft(Math.round(e),0,t);function Jr(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class pi extends Te{constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const s=this.getLabels();for(const{index:i,label:o}of n)s[i]===o&&s.splice(i,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(N(t))return null;const s=this.getLabels();return n=isFinite(n)&&s[n]===t?n:l0(s,t,E(n,t),this._addedLabels),u0(n,s.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:s,max:i}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(s=0),n||(i=this.getLabels().length-1)),this.min=s,this.max=i}buildTicks(){const t=this.min,n=this.max,s=this.options.offset,i=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(s?0:1),1),this._startValue=this.min-(s?.5:0);for(let r=t;r<=n;r++)i.push({value:r});return i}getLabelForValue(t){return Jr.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}}P(pi,"id","category"),P(pi,"defaults",{ticks:{callback:Jr}});function h0(e,t){const n=[],{bounds:i,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=!N(r),x=!N(a),M=!N(l),S=(m-g)/(h+1);let k=Vo((m-g)/p/f)*f,C,T,z,O;if(k<1e-14&&!b&&!x)return[{value:g},{value:m}];O=Math.ceil(m/k)-Math.floor(g/k),O>p&&(k=Vo(O*k/p/f)*f),N(c)||(C=Math.pow(10,c),k=Math.ceil(k*C)/C),i==="ticks"?(T=Math.floor(g/k)*k,z=Math.ceil(m/k)*k):(T=g,z=m),b&&x&&o&&sb((a-r)/o,k/1e3)?(O=Math.round(Math.min((a-r)/k,u)),k=(a-r)/O,T=r,z=a):M?(T=b?r:T,z=x?a:z,O=l-1,k=(z-T)/O):(O=(z-T)/k,cn(O,Math.round(O),k/1e3)?O=Math.round(O):O=Math.ceil(O));const D=Math.max(Wo(k),Wo(T));C=Math.pow(10,N(c)?D:c),T=Math.round(T*C)/C,z=Math.round(z*C)/C;let L=0;for(b&&(d&&T!==r?(n.push({value:r}),T<r&&L++,cn(Math.round((T+L*k)*C)/C,r,Kr(r,S,e))&&L++):T<r&&L++);L<O;++L){const j=Math.round((T+L*k)*C)/C;if(x&&j>a)break;n.push({value:j})}return x&&d&&z!==a?n.length&&cn(n[n.length-1].value,a,Kr(a,S,e))?n[n.length-1].value=a:n.push({value:a}):(!x||z===a)&&n.push({value:z}),n}function Kr(e,t,{horizontal:n,minRotation:s}){const i=Lt(s),o=(n?Math.sin(i):Math.cos(i))||.001,r=.75*t*(""+e).length;return Math.min(t/o,r)}class xs extends Te{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 N(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:s}=this.getUserBounds();let{min:i,max:o}=this;const r=c=>i=n?i:c,a=c=>o=s?o:c;if(t){const c=jt(i),l=jt(o);c<0&&l<0?a(0):c>0&&l>0&&r(0)}if(i===o){let c=o===0?1:Math.abs(o*.05);a(o+c),t||r(i-c)}this.min=i,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:s}=t,i;return s?(i=Math.ceil(this.max/s)-Math.floor(this.min/s)+1,i>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${i} ticks. Limiting to 1000.`),i=1e3)):(i=this.computeTickLimit(),n=n||11),n&&(i=Math.min(n,i)),i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const i={maxTicks:s,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=h0(i,o);return t.bounds==="ticks"&&_c(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,s=this.max;if(super.configure(),this.options.offset&&t.length){const i=(s-n)/Math.max(t.length-1,1)/2;n-=i,s+=i}this._startValue=n,this._endValue=s,this._valueRange=s-n}getLabelForValue(t){return An(t,this.chart.options.locale,this.options.ticks.format)}}class gi extends xs{determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=at(t)?t:0,this.max=at(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,s=Lt(this.options.ticks.minRotation),i=(t?Math.sin(s):Math.cos(s))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}P(gi,"id","linear"),P(gi,"defaults",{ticks:{callback:zs.formatters.numeric}});const vn=e=>Math.floor(Gt(e)),me=(e,t)=>Math.pow(10,vn(e)+t);function Xr(e){return e/Math.pow(10,vn(e))===1}function Gr(e,t,n){const s=Math.pow(10,n),i=Math.floor(e/s);return Math.ceil(t/s)-i}function d0(e,t){const n=t-e;let s=vn(n);for(;Gr(e,t,s)>10;)s++;for(;Gr(e,t,s)<10;)s--;return Math.min(s,vn(e))}function f0(e,{min:t,max:n}){t=Ct(e.min,t);const s=[],i=vn(t);let o=d0(t,n),r=o<0?Math.pow(10,Math.abs(o)):1;const a=Math.pow(10,o),c=i>o?Math.pow(10,i):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=Ct(e.min,Math.round((c+u+h*Math.pow(10,o))*r)/r);for(;d<n;)s.push({value:d,major:Xr(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=Ct(e.max,d);return s.push({value:f,major:Xr(f),significand:h}),s}class mi extends Te{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(t,n){const s=xs.prototype.parse.apply(this,[t,n]);if(s===0){this._zero=!0;return}return at(s)&&s>0?s:null}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=at(t)?Math.max(0,t):null,this.max=at(n)?Math.max(0,n):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!at(this._userMin)&&(this.min=t===me(this.min,0)?me(this.min,-1):me(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let s=this.min,i=this.max;const o=a=>s=t?s:a,r=a=>i=n?i:a;s===i&&(s<=0?(o(1),r(10)):(o(me(s,-1)),r(me(i,1)))),s<=0&&o(me(i,-1)),i<=0&&r(me(s,1)),this.min=s,this.max=i}buildTicks(){const t=this.options,n={min:this._userMin,max:this._userMax},s=f0(n,this);return t.bounds==="ticks"&&_c(s,this,"value"),t.reverse?(s.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),s}getLabelForValue(t){return t===void 0?"0":An(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure(),this._startValue=Gt(t),this._valueRange=Gt(this.max)-Gt(t)}getPixelForValue(t){return(t===void 0||t===0)&&(t=this.min),t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Gt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const n=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+n*this._valueRange)}}P(mi,"id","logarithmic"),P(mi,"defaults",{ticks:{callback:zs.formatters.logarithmic,major:{enabled:!0}}});function bi(e){const t=e.ticks;if(t.display&&e.display){const n=vt(t.backdropPadding);return E(t.font&&t.font.size,st.font.size)+n.height}return 0}function p0(e,t,n){return n=nt(n)?n:[n],{w:xb(e,t.string,n),h:n.length*t.lineHeight}}function Qr(e,t,n,s,i){return e===s||e===i?{start:t-n/2,end:t+n/2}:e<s||e>i?{start:t-n,end:t}:{start:t,end:t+n}}function g0(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),s=[],i=[],o=e._pointLabels.length,r=e.options.pointLabels,a=r.centerPointLabels?Z/o:0;for(let c=0;c<o;c++){const l=r.setContext(e.getPointLabelContext(c));i[c]=l.padding;const u=e.getPointPosition(c,e.drawingArea+i[c],a),h=dt(l.font),d=p0(e.ctx,h,e._pointLabels[c]);s[c]=d;const f=yt(e.getIndexAngle(c)+a),p=Math.round(to(f)),g=Qr(p,u.x,d.w,0,180),m=Qr(p,u.y,d.h,90,270);m0(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=y0(e,s,i)}function m0(e,t,n,s,i){const o=Math.abs(Math.sin(n)),r=Math.abs(Math.cos(n));let a=0,c=0;s.start<t.l?(a=(t.l-s.start)/o,e.l=Math.min(e.l,t.l-a)):s.end>t.r&&(a=(s.end-t.r)/o,e.r=Math.max(e.r,t.r+a)),i.start<t.t?(c=(t.t-i.start)/r,e.t=Math.min(e.t,t.t-c)):i.end>t.b&&(c=(i.end-t.b)/r,e.b=Math.max(e.b,t.b+c))}function b0(e,t,n){const s=e.drawingArea,{extra:i,additionalAngle:o,padding:r,size:a}=n,c=e.getPointPosition(t,s+i+r,o),l=Math.round(to(yt(c.angle+lt))),u=k0(c.y,a.h,l),h=x0(l),d=v0(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 _0(e,t){if(!t)return!0;const{left:n,top:s,right:i,bottom:o}=e;return!(Jt({x:n,y:s},t)||Jt({x:n,y:o},t)||Jt({x:i,y:s},t)||Jt({x:i,y:o},t))}function y0(e,t,n){const s=[],i=e._pointLabels.length,o=e.options,{centerPointLabels:r,display:a}=o.pointLabels,c={extra:bi(o)/2,additionalAngle:r?Z/i:0};let l;for(let u=0;u<i;u++){c.padding=n[u],c.size=t[u];const h=b0(e,u,c);s.push(h),a==="auto"&&(h.visible=_0(h,l),h.visible&&(l=h))}return s}function x0(e){return e===0||e===180?"center":e<180?"left":"right"}function v0(e,t,n){return n==="right"?e-=t:n==="center"&&(e-=t/2),e}function k0(e,t,n){return n===90||n===270?e-=t/2:(n>270||n<90)&&(e-=t),e}function w0(e,t,n){const{left:s,top:i,right:o,bottom:r}=n,{backdropColor:a}=t;if(!N(a)){const c=ke(t.borderRadius),l=vt(t.backdropPadding);e.fillStyle=a;const u=s-l.left,h=i-l.top,d=o-s+l.width,f=r-i+l.height;Object.values(c).some(p=>p!==0)?(e.beginPath(),yn(e,{x:u,y:h,w:d,h:f,radius:c}),e.fill()):e.fillRect(u,h,d,f)}}function S0(e,t){const{ctx:n,options:{pointLabels:s}}=e;for(let i=t-1;i>=0;i--){const o=e._pointLabelItems[i];if(!o.visible)continue;const r=s.setContext(e.getPointLabelContext(i));w0(n,r,o);const a=dt(r.font),{x:c,y:l,textAlign:u}=o;Me(n,e._pointLabels[i],c,l+a.lineHeight/2,a,{color:r.color,textAlign:u,textBaseline:"middle"})}}function ll(e,t,n,s){const{ctx:i}=e;if(n)i.arc(e.xCenter,e.yCenter,t,0,G);else{let o=e.getPointPosition(0,t);i.moveTo(o.x,o.y);for(let r=1;r<s;r++)o=e.getPointPosition(r,t),i.lineTo(o.x,o.y)}}function M0(e,t,n,s,i){const o=e.ctx,r=t.circular,{color:a,lineWidth:c}=t;!r&&!s||!a||!c||n<0||(o.save(),o.strokeStyle=a,o.lineWidth=c,o.setLineDash(i.dash||[]),o.lineDashOffset=i.dashOffset,o.beginPath(),ll(e,n,r,s),o.closePath(),o.stroke(),o.restore())}function P0(e,t,n){return le(e,{label:n,index:t,type:"pointLabel"})}class rn extends xs{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=vt(bi(this.options)/2),n=this.width=this.maxWidth-t.width,s=this.height=this.maxHeight-t.height;this.xCenter=Math.floor(this.left+n/2+t.left),this.yCenter=Math.floor(this.top+s/2+t.top),this.drawingArea=Math.floor(Math.min(n,s)/2)}determineDataLimits(){const{min:t,max:n}=this.getMinMax(!1);this.min=at(t)&&!isNaN(t)?t:0,this.max=at(n)&&!isNaN(n)?n:0,this.handleTickRangeOptions()}computeTickLimit(){return Math.ceil(this.drawingArea/bi(this.options))}generateTickLabels(t){xs.prototype.generateTickLabels.call(this,t),this._pointLabels=this.getLabels().map((n,s)=>{const i=K(this.options.pointLabels.callback,[n,s],this);return i||i===0?i:""}).filter((n,s)=>this.chart.getDataVisibility(s))}fit(){const t=this.options;t.display&&t.pointLabels.display?g0(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,n,s,i){this.xCenter+=Math.floor((t-n)/2),this.yCenter+=Math.floor((s-i)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,n,s,i))}getIndexAngle(t){const n=G/(this._pointLabels.length||1),s=this.options.startAngle||0;return yt(t*n+Lt(s))}getDistanceFromCenterForValue(t){if(N(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(N(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 s=n[t];return P0(this.getContext(),t,s)}}getPointPosition(t,n,s=0){const i=this.getIndexAngle(t)-lt+s;return{x:Math.cos(i)*n+this.xCenter,y:Math.sin(i)*n+this.yCenter,angle:i}}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:s,right:i,bottom:o}=this._pointLabelItems[t];return{left:n,top:s,right:i,bottom:o}}drawBackground(){const{backgroundColor:t,grid:{circular:n}}=this.options;if(t){const s=this.ctx;s.save(),s.beginPath(),ll(this,this.getDistanceFromCenterForValue(this._endValue),n,this._pointLabels.length),s.closePath(),s.fillStyle=t,s.fill(),s.restore()}}drawGrid(){const t=this.ctx,n=this.options,{angleLines:s,grid:i,border:o}=n,r=this._pointLabels.length;let a,c,l;if(n.pointLabels.display&&S0(this,r),i.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=i.setContext(d),p=o.setContext(d);M0(this,f,c,r,p)}}),s.display){for(t.save(),a=r-1;a>=0;a--){const u=s.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,s=n.ticks;if(!s.display)return;const i=this.getIndexAngle(0);let o,r;t.save(),t.translate(this.xCenter,this.yCenter),t.rotate(i),t.textAlign="center",t.textBaseline="middle",this.ticks.forEach((a,c)=>{if(c===0&&this.min>=0&&!n.reverse)return;const l=s.setContext(this.getContext(c)),u=dt(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=vt(l.backdropPadding);t.fillRect(-r/2-h.left,-o-u.size/2-h.top,r+h.width,u.size+h.height)}Me(t,a.label,0,-o,u,{color:l.color,strokeColor:l.textStrokeColor,strokeWidth:l.textStrokeWidth})}),t.restore()}drawTitle(){}}P(rn,"id","radialLinear"),P(rn,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:zs.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(t){return t},padding:5,centerPointLabels:!1}}),P(rn,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),P(rn,"descriptors",{angleLines:{_fallback:"grid"}});const Ds={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}},St=Object.keys(Ds);function ta(e,t){return e-t}function ea(e,t){if(N(t))return null;const n=e._adapter,{parser:s,round:i,isoWeekday:o}=e._parseOpts;let r=t;return typeof s=="function"&&(r=s(r)),at(r)||(r=typeof s=="string"?n.parse(r,s):n.parse(r)),r===null?null:(i&&(r=i==="week"&&(He(o)||o===!0)?n.startOf(r,"isoWeek",o):n.startOf(r,i)),+r)}function na(e,t,n,s){const i=St.length;for(let o=St.indexOf(e);o<i-1;++o){const r=Ds[St[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((n-t)/(a*r.size))<=s)return St[o]}return St[i-1]}function T0(e,t,n,s,i){for(let o=St.length-1;o>=St.indexOf(n);o--){const r=St[o];if(Ds[r].common&&e._adapter.diff(i,s,r)>=t-1)return r}return St[n?St.indexOf(n):0]}function C0(e){for(let t=St.indexOf(e)+1,n=St.length;t<n;++t)if(Ds[St[t]].common)return St[t]}function sa(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:s,hi:i}=eo(n,t),o=n[s]>=t?n[s]:n[i];e[o]=!0}}function z0(e,t,n,s){const i=e._adapter,o=+i.startOf(t[0].value,s),r=t[t.length-1].value;let a,c;for(a=o;a<=r;a=+i.add(a,1,s))c=n[a],c>=0&&(t[c].major=!0);return t}function ia(e,t,n){const s=[],i={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],i[a]=r,s.push({value:a,major:!1});return o===0||!n?s:z0(e,s,i,n)}class kn extends Te{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 s=t.time||(t.time={}),i=this._adapter=new $_._date(t.adapters.date);i.init(n),an(s.displayFormats,i.formats()),this._parseOpts={parser:s.parser,round:s.round,isoWeekday:s.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:ea(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,s=t.time.unit||"day";let{min:i,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function c(l){!r&&!isNaN(l.min)&&(i=Math.min(i,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))),i=at(i)&&!isNaN(i)?i:+n.startOf(Date.now(),s),o=at(o)&&!isNaN(o)?o:+n.endOf(Date.now(),s)+1,this.min=Math.min(i,o-1),this.max=Math.max(i+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],s=t[t.length-1]),{min:n,max:s}}buildTicks(){const t=this.options,n=t.time,s=t.ticks,i=s.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&i.length&&(this.min=this._userMin||i[0],this.max=this._userMax||i[i.length-1]);const o=this.min,r=this.max,a=ab(i,o,r);return this._unit=n.unit||(s.autoSkip?na(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):T0(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!s.major.enabled||this._unit==="year"?void 0:C0(this._unit),this.initOffsets(i),t.reverse&&a.reverse(),ia(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,s=0,i,o;this.options.offset&&t.length&&(i=this.getDecimalForValue(t[0]),t.length===1?n=1-i:n=(this.getDecimalForValue(t[1])-i)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?s=o:s=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;n=ft(n,0,r),s=ft(s,0,r),this._offsets={start:n,end:s,factor:1/(n+1+s)}}_generate(){const t=this._adapter,n=this.min,s=this.max,i=this.options,o=i.time,r=o.unit||na(o.minUnit,n,s,this._getLabelCapacity(n)),a=E(i.ticks.stepSize,1),c=r==="week"?o.isoWeekday:!1,l=He(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(s,n,r)>1e5*a)throw new Error(n+" and "+s+" are too far apart with stepSize of "+a+" "+r);const p=i.ticks.source==="data"&&this.getDataTimestamps();for(d=h,f=0;d<s;d=+t.add(d,a,r),f++)sa(u,d,p);return(d===s||i.bounds==="ticks"||f===1)&&sa(u,d,p),Object.keys(u).sort(ta).map(g=>+g)}getLabelForValue(t){const n=this._adapter,s=this.options.time;return s.tooltipFormat?n.format(t,s.tooltipFormat):n.format(t,s.displayFormats.datetime)}format(t,n){const i=this.options.time.displayFormats,o=this._unit,r=n||i[o];return this._adapter.format(t,r)}_tickFormatFunction(t,n,s,i){const o=this.options,r=o.ticks.callback;if(r)return K(r,[t,n,s],this);const a=o.time.displayFormats,c=this._unit,l=this._majorUnit,u=c&&a[c],h=l&&a[l],d=s[n],f=l&&h&&d&&d.major;return this._adapter.format(t,i||(f?h:u))}generateTickLabels(t){let n,s,i;for(n=0,s=t.length;n<s;++n)i=t[n],i.label=this._tickFormatFunction(i.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,s=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+s)*n.factor)}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+s*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,s=this.ctx.measureText(t).width,i=Lt(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(i),r=Math.sin(i),a=this._resolveTickFontOptions(0).size;return{w:s*o+a*r,h:s*r+a*o}}_getLabelCapacity(t){const n=this.options.time,s=n.displayFormats,i=s[n.unit]||s.millisecond,o=this._tickFormatFunction(t,0,ia(this,[t],this._majorUnit),i),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,s;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(n=0,s=i.length;n<s;++n)t=t.concat(i[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,s;if(t.length)return t;const i=this.getLabels();for(n=0,s=i.length;n<s;++n)t.push(ea(this,i[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return vc(t.sort(ta))}}P(kn,"id","time"),P(kn,"defaults",{bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}});function Xn(e,t,n){let s=0,i=e.length-1,o,r,a,c;n?(t>=e[s].pos&&t<=e[i].pos&&({lo:s,hi:i}=Yt(e,"pos",t)),{pos:o,time:a}=e[s],{pos:r,time:c}=e[i]):(t>=e[s].time&&t<=e[i].time&&({lo:s,hi:i}=Yt(e,"time",t)),{time:o,pos:a}=e[s],{time:r,pos:c}=e[i]);const l=r-o;return l?a+(c-a)*(t-o)/l:a}class _i extends kn{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:s}=this,i=[],o=[];let r,a,c,l,u;for(r=0,a=t.length;r<a;++r)l=t[r],l>=n&&l<=s&&i.push(l);if(i.length<2)return[{time:n,pos:0},{time:s,pos:1}];for(r=0,a=i.length;r<a;++r)u=i[r+1],c=i[r-1],l=i[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 s=super.getDataTimestamps();return(!s.includes(t)||!s.length)&&s.splice(0,0,t),(!s.includes(n)||s.length===1)&&s.push(n),s.sort((i,o)=>i-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),s=this.getLabelTimestamps();return n.length&&s.length?t=this.normalize(n.concat(s)):t=n.length?n:s,t=this._cache.all=t,t}getDecimalForValue(t){return(Xn(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,s=this.getDecimalForPixel(t)/n.factor-n.end;return Xn(this._table,s*this._tableRange+this._minPos,!0)}}P(_i,"id","timeseries"),P(_i,"defaults",kn.defaults);var O0=Object.freeze({__proto__:null,CategoryScale:pi,LinearScale:gi,LogarithmicScale:mi,RadialLinearScale:rn,TimeScale:kn,TimeSeriesScale:_i});const R0=[L_,dx,a0,O0],A0={Enterprise:"#1e40af","Mid-Market":"#0d9488",SMB:"#059669",Startup:"#6366f1"},Ee={annualRevenue:"Annual Revenue",employeeCount:"Employees",accountAge:"Account Age (mo)",engagementScore:"Engagement",supportTickets:"Support Tickets",nps:"NPS"};qt.register(...R0);const yi={info:console.log.bind(console,"[APP]"),error:console.error.bind(console,"[APP]")},Gn=document.querySelector(".main"),oa=document.getElementById("x-axis"),ra=document.getElementById("y-axis"),aa=document.getElementById("size-metric"),I0=document.getElementById("scatter-chart"),ca=document.getElementById("legend"),ul=document.getElementById("detail-panel"),A={customers:[],segments:[],chart:null,xAxis:"annualRevenue",yAxis:"engagementScore",sizeMetric:"off",hiddenSegments:new Set,selectedCustomer:null};function ve(e,t){switch(t){case"annualRevenue":return e>=1e6?`$${(e/1e6).toFixed(1)}M`:`$${(e/1e3).toFixed(0)}K`;case"employeeCount":return e.toLocaleString();case"accountAge":return`${e}mo`;case"engagementScore":return`${e}`;case"supportTickets":return`${e}`;case"nps":return e>=0?`+${e}`:`${e}`;default:return`${e}`}}function E0(e,t){const n=e.map(s=>s[t]);return{min:Math.min(...n),max:Math.max(...n)}}function D0(e,t,n){return n===t?12:6+(e-t)/(n-t)*24}function L0(){return A.customers.filter(e=>!A.hiddenSegments.has(e.segment))}function hl(){const e=L0(),t=[...new Set(e.map(s=>s.segment))];let n=null;return A.sizeMetric!=="off"&&(n=E0(A.customers,A.sizeMetric)),t.map(s=>{const i=e.filter(r=>r.segment===s),o=A0[s]||"#888888";return{label:s,data:i.map(r=>({x:r[A.xAxis],y:r[A.yAxis],r:n&&A.sizeMetric!=="off"?D0(r[A.sizeMetric],n.min,n.max):8,customer:r})),backgroundColor:o+"aa",borderColor:o,borderWidth:1,hoverBackgroundColor:o,hoverBorderColor:"#ffffff",hoverBorderWidth:2}})}let Kt=null;function la(e,t){return e?e.includes("light-dark(")?(Kt||(Kt=document.createElement("div"),Kt.style.position="absolute",Kt.style.visibility="hidden",Kt.style.pointerEvents="none",document.body.appendChild(Kt)),Kt.style.color=e,getComputedStyle(Kt).color||t):e:t}function dl(){const e=getComputedStyle(document.documentElement),t=e.getPropertyValue("--color-text-secondary").trim(),n=e.getPropertyValue("--color-border-primary").trim();return{textColor:la(t,"#6b7280"),gridColor:la(n,"#e5e7eb")}}function fo(){const{textColor:e,gridColor:t}=dl();return new qt(I0,{type:"bubble",data:{datasets:hl()},options:{responsive:!0,maintainAspectRatio:!1,animation:{duration:300},interaction:{intersect:!0,mode:"nearest"},plugins:{legend:{display:!1},tooltip:{enabled:!0,callbacks:{label:n=>{const i=n.raw.customer;return[i.name,`${Ee[A.xAxis]}: ${ve(i[A.xAxis],A.xAxis)}`,`${Ee[A.yAxis]}: ${ve(i[A.yAxis],A.yAxis)}`]}}}},scales:{x:{title:{display:!0,text:Ee[A.xAxis],color:e,font:{size:11,weight:"bold"}},ticks:{color:e,font:{size:10},callback:n=>ve(n,A.xAxis)},grid:{color:t}},y:{title:{display:!0,text:Ee[A.yAxis],color:e,font:{size:11,weight:"bold"}},ticks:{color:e,font:{size:10},callback:n=>ve(n,A.yAxis)},grid:{color:t}}},onClick:(n,s)=>{if(s.length>0){const i=s[0],r=A.chart.data.datasets[i.datasetIndex].data[i.index];A.selectedCustomer=r.customer,ua(r.customer)}},onHover:(n,s)=>{if(s.length>0&&!A.selectedCustomer){const i=s[0],r=A.chart.data.datasets[i.datasetIndex].data[i.index];ua(r.customer)}else s.length===0&&!A.selectedCustomer&&pl()}}})}function In(){if(!A.chart)return;const{textColor:e,gridColor:t}=dl();A.chart.data.datasets=hl();const n=A.chart.options.scales;n.x.title.text=Ee[A.xAxis],n.y.title.text=Ee[A.yAxis],n.x.title.color=e,n.y.title.color=e,n.x.ticks.color=e,n.y.ticks.color=e,n.x.ticks.callback=s=>ve(s,A.xAxis),n.y.ticks.callback=s=>ve(s,A.yAxis),n.x.grid.color=t,n.y.grid.color=t,A.chart.update()}function fl(){const e=new Map;for(const t of A.customers)e.set(t.segment,(e.get(t.segment)||0)+1);ca.innerHTML=A.segments.map(t=>{const n=e.get(t.name)||0;return`
|
|
102
102
|
<div class="legend-item ${A.hiddenSegments.has(t.name)?"hidden":""}" data-segment="${t.name}">
|
|
103
103
|
<span class="legend-dot" style="background: ${t.color}"></span>
|
|
104
104
|
<span class="legend-label">${t.name}</span>
|
|
105
105
|
<span class="legend-count">(${n})</span>
|
|
106
106
|
</div>
|
|
107
|
-
`}).join(""),ca.querySelectorAll(".legend-item").forEach(t=>{t.addEventListener("click",()=>{const n=t.getAttribute("data-segment");A.hiddenSegments.has(n)?A.hiddenSegments.delete(n):A.hiddenSegments.add(n),
|
|
107
|
+
`}).join(""),ca.querySelectorAll(".legend-item").forEach(t=>{t.addEventListener("click",()=>{const n=t.getAttribute("data-segment");A.hiddenSegments.has(n)?A.hiddenSegments.delete(n):A.hiddenSegments.add(n),fl(),In()})})}function ua(e){const t=e.segment.toLowerCase().replace("-","-");ul.innerHTML=`
|
|
108
108
|
<span class="detail-name">${e.name}</span>
|
|
109
109
|
<span class="detail-segment ${t}">${e.segment}</span>
|
|
110
110
|
<span class="detail-metric"><strong>${ve(e.annualRevenue,"annualRevenue")}</strong> rev</span>
|
|
111
111
|
<span class="detail-metric"><strong>${e.engagementScore}</strong> engagement</span>
|
|
112
112
|
<span class="detail-metric"><strong>${e.nps>=0?"+":""}${e.nps}</strong> NPS</span>
|
|
113
|
-
`}function
|
|
113
|
+
`}function pl(){ul.innerHTML='<span class="detail-placeholder">Hover over a point to see details</span>'}const Ze=new wm({name:"Customer Segmentation",version:"1.0.0"});async function $0(){try{const t=(await Ze.callServerTool({name:"get-customer-data",arguments:{}})).content.filter(s=>s.type==="text").map(s=>s.text).join(""),n=JSON.parse(t);A.customers=n.customers,A.segments=n.segments,A.chart?In():A.chart=fo(),fl(),yi.info(`Loaded ${n.customers.length} customers`)}catch(e){yi.error("Failed to fetch data:",e)}}oa.addEventListener("change",()=>{A.xAxis=oa.value,In()});ra.addEventListener("change",()=>{A.yAxis=ra.value,In()});aa.addEventListener("change",()=>{A.sizeMetric=aa.value,In()});document.addEventListener("click",e=>{e.target.closest(".chart-section")||(A.selectedCustomer=null,pl())});window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",e=>{var t;(t=Ze.getHostContext())!=null&&t.theme||(Ji(e.matches?"dark":"light"),A.chart&&(A.chart.destroy(),A.chart=fo()))});const N0=window.matchMedia("(prefers-color-scheme: dark)").matches;Ji(N0?"dark":"light");Ze.onerror=yi.error;function gl(e){var t,n,s,i;e.theme&&Ji(e.theme),(t=e.styles)!=null&&t.variables&&vm(e.styles.variables),(s=(n=e.styles)==null?void 0:n.css)!=null&&s.fonts&&km(e.styles.css.fonts),e.safeAreaInsets&&(Gn.style.paddingTop=`${e.safeAreaInsets.top}px`,Gn.style.paddingRight=`${e.safeAreaInsets.right}px`,Gn.style.paddingBottom=`${e.safeAreaInsets.bottom}px`,Gn.style.paddingLeft=`${e.safeAreaInsets.left}px`),A.chart&&(e.theme||(i=e.styles)!=null&&i.variables)&&(A.chart.destroy(),A.chart=fo())}Ze.onhostcontextchanged=gl;Ze.connect().then(()=>{const e=Ze.getHostContext();e&&gl(e)});setTimeout($0,100);</script>
|
|
114
114
|
<style rel="stylesheet" crossorigin>*{box-sizing:border-box}html,body{font-family:system-ui,-apple-system,sans-serif;font-size:1rem}code{font-size:1em}:root{color-scheme:light dark;--font-sans: system-ui, -apple-system, sans-serif;--color-background-primary: light-dark(#ffffff, #111827);--color-background-secondary: light-dark(#f9fafb, #1f2937);--color-background-tertiary: light-dark(#f3f4f6, #374151);--color-text-primary: light-dark(#1f2937, #f9fafb);--color-text-secondary: light-dark(#6b7280, #9ca3af);--color-text-tertiary: light-dark(#9ca3af, #6b7280);--color-border-primary: light-dark(#e5e7eb, #374151);--color-border-secondary: light-dark(#d1d5db, #4b5563);--color-ring-info: light-dark(#2563eb, #3b82f6);--border-radius-sm: 6px;--border-radius-md: 8px;--border-radius-full: 9999px;--border-width-regular: 1px;--shadow-sm: 0 1px 3px rgba(0, 0, 0, .1);--color-enterprise: light-dark(#1e40af, #3b82f6);--color-midmarket: light-dark(#0d9488, #14b8a6);--color-smb: light-dark(#059669, #10b981);--color-startup: light-dark(#6366f1, #818cf8)}html,body{margin:0;padding:0;font-family:var(--font-sans);color:var(--color-text-primary);overflow:hidden}.main{border-radius:var(--border-radius-md);background:var(--color-background-primary);width:100%;height:600px;margin:0 auto;padding:12px;display:flex;flex-direction:column;gap:8px;overflow:hidden}.header{display:flex;justify-content:space-between;align-items:center;gap:12px;height:36px;flex-shrink:0}.title{margin:0;font-size:1.125rem;font-weight:600;flex-shrink:0}.header-controls{display:flex;align-items:center;gap:8px}.controls-section{display:flex;align-items:center;gap:16px;height:32px;flex-shrink:0}.select-label{display:flex;align-items:center;gap:6px;font-size:.8125rem;font-weight:500;color:var(--color-text-secondary)}.select{padding:4px 8px;font-size:.8125rem;border:var(--border-width-regular) solid var(--color-border-primary);border-radius:var(--border-radius-sm);background:var(--color-background-secondary);color:var(--color-text-primary);cursor:pointer}.select:focus{outline:2px solid var(--color-ring-info);outline-offset:1px}.chart-section{flex:1;min-height:0;background:var(--color-background-secondary);border-radius:var(--border-radius-md);padding:8px;border:var(--border-width-regular) solid var(--color-border-primary)}.chart-container{position:relative;width:100%;height:100%}.legend-section{height:32px;flex-shrink:0}.legend{display:flex;align-items:center;justify-content:center;gap:16px;height:100%}.legend-item{display:flex;align-items:center;gap:6px;font-size:.75rem;cursor:pointer;padding:4px 10px;border-radius:var(--border-radius-full);border:var(--border-width-regular) solid var(--color-border-primary);background:var(--color-background-secondary);transition:all .15s ease}.legend-item:hover{border-color:var(--color-text-secondary);box-shadow:var(--shadow-sm)}.legend-item.hidden{opacity:.5;background:transparent}.legend-item.hidden .legend-label{text-decoration:line-through}.legend-dot{width:10px;height:10px;border-radius:50%}.legend-label{font-weight:500}.legend-count{color:var(--color-text-secondary)}.detail-section{height:40px;flex-shrink:0}.detail-panel{display:flex;align-items:center;justify-content:center;gap:16px;height:100%;background:var(--color-background-secondary);border-radius:var(--border-radius-sm);padding:0 12px;border:var(--border-width-regular) solid var(--color-border-primary);font-size:.8125rem}.detail-placeholder{color:var(--color-text-secondary)}.detail-name{font-weight:600}.detail-segment{padding:2px 8px;border-radius:var(--border-radius-sm);font-size:.75rem;font-weight:500;color:#fff}.detail-segment.enterprise{background:var(--color-enterprise)}.detail-segment.mid-market{background:var(--color-midmarket)}.detail-segment.smb{background:var(--color-smb)}.detail-segment.startup{background:var(--color-startup)}.detail-metric{color:var(--color-text-secondary)}.detail-metric strong{color:var(--color-text-primary);font-weight:600}</style>
|
|
115
115
|
</head>
|
|
116
116
|
<body>
|