1import{j as o,R as X,r as p,a_ as St,C as Nn,a2 as Nr,M as Er}from"./CZzrexQa.production.bundle.min.js";import{l as En,aE as Ir,ao as Rr}from"./b2Mkg01q.production.bundle.min.js";import{oY as Mr,u as Or,a as Dr,oZ as Ar}from"./DeceMiF-.production.bundle.min.js";import{S as $r}from"./D0x1Z4HE.production.bundle.min.js";import{T as Lr}from"./Y4Ob0Is8.production.bundle.min.js";import{u as Br}from"./9eHdvLN4.production.bundle.min.js";import{O as Pr,k as In,t as Fr,R as Zr}from"./CUZmxn9S.production.bundle.min.js";import{P as zr}from"./CHClG9UV.production.bundle.min.js";import{ah as Vr,j as Hr,aW as Ur,a as Jr}from"./C_cH1u9D.production.bundle.min.js";import{C as L}from"./BnY2Z5Cw.production.bundle.min.js";import{l as Wr}from"./DbuQJihJ.production.bundle.min.js";import{c as le}from"./DGYQp8fe.production.bundle.min.js";import{_ as qr}from"./DGAisTA8.production.bundle.min.js";import{b as Xr,E as Gr,S as Yr,i as Kr,z as Qr}from"./3wIbuO__.production.bundle.min.js";import{T as ea}from"./oN3AJijl.production.bundle.min.js";import{u as Rn}from"./DvLd3evF.production.bundle.min.js";import{A as ta}from"./Ci_hGDFV.production.bundle.min.js";import{T as He}from"./kkIr59yR.production.bundle.min.js";import{F as sa}from"./B0uEge7d.production.bundle.min.js";import"./D4lvmK5r.production.bundle.min.js";import"./DwmhJbxl.production.bundle.min.js";import"./YCM_kEyP.production.bundle.min.js";import"./D-90pMQ7.production.bundle.min.js";import"./DQegFpUo.production.bundle.min.js";import"./BmBjCq8D.production.bundle.min.js";import"./Dsqj8S3w.production.bundle.min.js";import"./CNsPFEJO.production.bundle.min.js";import"./DtpVAsok.production.bundle.min.js";import"./2mZBARql.production.bundle.min.js";import"./vhNSgALD.production.bundle.min.js";import"./CiD4UJCU.production.bundle.min.js";import"./DWUNlcjA.production.bundle.min.js";import"./CJIgguc4.production.bundle.min.js";import"./7LcJfZNO.production.bundle.min.js";import"./D8sKcCdJ.production.bundle.min.js";import"./tkddr5kZ.production.bundle.min.js";import"./Bm1LOIPR.production.bundle.min.js";import"./CXT9N8xZ.production.bundle.min.js";import"./zzLyrqbE.production.bundle.min.js";import"./DFn2u8qh.production.bundle.min.js";import"./C_Ln3svq.production.bundle.min.js";import"./E6csxmgU.production.bundle.min.js";import"./CpVN2k6O.production.bundle.min.js";import"./B7Fri_dM.production.bundle.min.js";import"./CLBsRoPD.production.bundle.min.js";import"./Ch78CD0x.production.bundle.min.js";import"./D1TNtnEv.production.bundle.min.js";import"./DnQqxH0F.production.bundle.min.js";import"./Gi6I4Gst.production.bundle.min.js";import"./C4B-KCzX.production.bundle.min.js";const zs=s=>typeof s>"u"||s===null;function na(s,e){return e!==void 0?s(e):s}function ra(s,e){return typeof s=="object"&&s!==null&&e in s}function aa(s){if(ra(s,"toString")&&typeof s.toString=="function"){const e=s.toString();return typeof e=="string"?e:JSON.stringify(s)}else return JSON.stringify(s)}const at={Just:"Just",Nothing:"Nothing"};let Wt;class ks{constructor(e){if(zs(e))return Wt||(this.repr=[at.Nothing],Wt=this),Wt;this.repr=[at.Just,e]}static of(e){return new q(e)}static just(e){if(zs(e))throw new Error(`attempted to call "just" with ${e}`);return new q(e)}static nothing(e){return new ks}get variant(){return this.repr[0]}get value(){if(this.repr[0]===at.Nothing)throw new Error("Cannot get the value of `Nothing`");return this.repr[1]}get isJust(){return this.repr[0]===at.Just}get isNothing(){return this.repr[0]===at.Nothing}map(e){return this.repr[0]==="Just"?q.just(e(this.repr[1])):this}mapOr(e,t){return this.repr[0]==="Just"?t(this.repr[1]):e}mapOrElse(e,t){return this.repr[0]==="Just"?t(this.repr[1]):e()}match(e){return this.repr[0]==="Just"?e.Just(this.repr[1]):e.Nothing()}or(e){return this.repr[0]==="Just"?this:e}orElse(e){return this.repr[0]==="Just"?this:e()}and(e){return this.repr[0]==="Just"?e:this}andThen(e){return this.repr[0]==="Just"?e(this.repr[1]):this}unwrapOr(e){return this.repr[0]==="Just"?this.repr[1]:e}unwrapOrElse(e){return this.repr[0]==="Just"?this.repr[1]:e()}toString(){return this.repr[0]==="Just"?`Just(${aa(this.repr[1])})`:"Nothing"}toJSON(){const e=this.repr[0];if(e==="Just"){let t=ia(this.repr[1])?this.repr[1].toJSON():this.repr[1];return{variant:e,value:t}}else return{variant:e}}equals(e){return this.repr[0]===e.repr[0]&&this.repr[1]===e.repr[1]}ap(e){return e.andThen(t=>this.map(n=>n(t)))}get(e){return this.andThen(oa(e))}}function ia(s){return s instanceof q}function oa(s,e){return na(n=>q.of(n[s]),e)}const q=ks;var F;(function(s){s.assertEqual=r=>{};function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(l=>typeof r[r[l]]!="number"),i={};for(const l of a)i[l]=r[l];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a}
vendor: 5,194 bytes, line 1
1)(F||(F={}));var Vs;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Vs||(Vs={}));const C=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Oe=s=>{switch(typeof s){case"undefined":return C.undefined;case"string":return C.string;case"number":return Number.isNaN(s)?C.nan:C.number;case"boolean":return C.boolean;case"function":return C.function;case"bigint":return C.bigint;case"symbol":return C.symbol;case"object":return Array.isArray(s)?C.array:s===null?C.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?C.promise:typeof Map<"u"&&s instanceof Map?C.map:typeof Set<"u"&&s instanceof Set?C.set:typeof Date<"u"&&s instanceof Date?C.date:C.object;default:return C.unknown}},_=F.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ne extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let l=n,c=0;for(;c<i.path.length;){const d=i.path[c];c===i.path.length-1?(l[d]=l[d]||{_errors:[]},l[d]._errors.push(t(i))):l[d]=l[d]||{_errors:[]},l=l[d],c++}}};return r(this),n}static assert(e){if(!(e instanceof Ne))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];t[a]=t[a]||[],t[a].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Ne.create=s=>new Ne(s);const rs=(s,e)=>{let t;switch(s.code){case _.invalid_type:s.received===C.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,F.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${F.joinValues(s.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${F.joinValues(s.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${F.joinValues(s.options)}, received '${s.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:F.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case _.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case _.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;
vendor: 7,511 bytes, line 1
1case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,F.assertNever(s)}return{message:t}};let la=rs;function ca(){return la}const da=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let l="";const c=n.filter(d=>!!d).slice().reverse();for(const d of c)l=d(i,{data:e,defaultError:l}).message;return{...r,path:a,message:l}};function T(s,e){const t=ca(),n=da({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===rs?void 0:rs].filter(r=>!!r)});s.common.issues.push(n)}class re{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if(r.status==="aborted")return O;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const r of t){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return re.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return O;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const O=Object.freeze({status:"aborted"}),ot=s=>({status:"dirty",value:s}),me=s=>({status:"valid",value:s}),Hs=s=>s.status==="aborted",Us=s=>s.status==="dirty",Qe=s=>s.status==="valid",Nt=s=>typeof Promise<"u"&&s instanceof Promise;var S;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(S||(S={}));class Te{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Js=(s,e)=>{if(Qe(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ne(s.common.issues);return this._error=t,this._error}}};function $(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,l)=>{const{message:c}=s;return i.code==="invalid_enum_value"?{message:c??l.defaultError}:typeof l.data>"u"?{message:c??n??l.defaultError}:i.code!=="invalid_type"?{message:l.defaultError}:{message:c??t??l.defaultError}},description:r}}class B{get description(){return this._def.description}_getType(e){return Oe(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new re,ctx:{common:e.parent.common,data:e.data,parsedType:Oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Nt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oe(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Js(n,r)}"~validate"(e){var n,r;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oe(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return Qe(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(r=(n=a==null?void 0:a.message)==null?void 0:n.toLowerCase())!=null&&r.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>Qe(a)?{value:a.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Oe(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(Nt(r)?r:Promise.resolve(r));return Js(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const i=e(r),l=()=>a.addIssue({code:_.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(l(),!1)):i?!0:(l(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new Je({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return De.create(this,this._def)}nullable(){return st.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ke.create(this)}promise(){return Ot.create(this,this._def)}or(e){return It.create([this,e],this._def)}and(e){return Rt.create(this,e,this._def)}transform(e){return new Je({...$(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ls({...$(this._def),innerType:this,defaultValue:t,typeName:M.ZodDefault})}brand(){return new Oa({typeName:M.ZodBranded,type:this,...$(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new cs({...$(this._def),innerType:this,catchValue:t,typeName:M.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ts.create(this,e)}readonly(){return ds.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ua=/^c[^\s-]{8,}
vendor: 21,813 bytes, line 1
1$/i,fa=/^[0-9a-z]+$/,ha=/^[0-9A-HJKMNP-TV-Z]{26}$/i,ma=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pa=/^[a-z0-9_-]{21}$/i,ga=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,va=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ya=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,xa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let qt;const _a=/^(?:(?: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])$/,ba=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,wa=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,ka=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ta=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ca=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mn="((\\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])))",ja=new RegExp(`^${Mn}$`);function On(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Sa(s){return new RegExp(`^${On(s)}$`)}function Na(s){let e=`${Mn}T${On(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ea(s,e){return!!((e==="v4"||!e)&&_a.test(s)||(e==="v6"||!e)&&wa.test(s))}function Ia(s,e){if(!ga.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),r=JSON.parse(atob(n));return!(typeof r!="object"||r===null||"typ"in r&&(r==null?void 0:r.typ)!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Ra(s,e){return!!((e==="v4"||!e)&&ba.test(s)||(e==="v6"||!e)&&ka.test(s))}class je extends B{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==C.string){const a=this._getOrReturnCtx(e);return T(a,{code:_.invalid_type,expected:C.string,received:a.parsedType}),O}const n=new re;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),T(r,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),T(r,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,l=e.data.length<a.value;(i||l)&&(r=this._getOrReturnCtx(e,r),i?T(r,{code:_.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):l&&T(r,{code:_.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")ya.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"email",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")qt||(qt=new RegExp(xa,"u")),qt.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"emoji",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")ma.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"uuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")pa.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"nanoid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")ua.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"cuid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")fa.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"cuid2",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ha.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"ulid",code:_.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),T(r,{validation:"url",code:_.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"regex",code:_.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),T(r,{code:_.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),T(r,{code:_.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),T(r,{code:_.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Na(a).test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{code:_.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?ja.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{code:_.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Sa(a).test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{code:_.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?va.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"duration",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ea(e.data,a.version)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"ip",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Ia(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"jwt",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Ra(e.data,a.version)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"cidr",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Ta.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"base64",code:_.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Ca.test(e.data)||(r=this._getOrReturnCtx(e,r),T(r,{validation:"base64url",code:_.invalid_string,message:a.message}),n.dirty()):F.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(r=>e.test(r),{validation:t,code:_.invalid_string,...S.errToObj(n)})}_addCheck(e){return new je({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...S.errToObj(e)})}url(e){return this._addCheck({kind:"url",...S.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...S.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...S.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...S.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...S.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...S.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...S.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...S.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...S.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...S.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...S.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...S.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...S.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...S.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...S.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...S.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...S.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...S.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...S.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...S.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...S.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...S.errToObj(t)})}nonempty(e){return this.min(1,S.errToObj(e))}trim(){return new je({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new je({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new je({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}je.create=s=>new je({checks:[],typeName:M.ZodString,coerce:(s==null?void 0:s.coerce)??!1,...$(s)});function Ma(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=Number.parseInt(s.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class et extends B{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==C.number){const a=this._getOrReturnCtx(e);return T(a,{code:_.invalid_type,expected:C.number,received:a.parsedType}),O}let n;const r=new re;for(const a of this._def.checks)a.kind==="int"?F.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),T(n,{code:_.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),T(n,{code:_.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),T(n,{code:_.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Ma(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),T(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),T(n,{code:_.not_finite,message:a.message}),r.dirty()):F.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,S.toString(t))}gt(e,t){return this.setLimit("min",e,!1,S.toString(t))}lte(e,t){return this.setLimit("max",e,!0,S.toString(t))}lt(e,t){return this.setLimit("max",e,!1,S.toString(t))}setLimit(e,t,n,r){return new et({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:S.toString(r)}]})}_addCheck(e){return new et({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:S.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:S.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:S.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:S.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:S.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:S.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:S.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:S.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:S.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&F.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}et.create=s=>new et({checks:[],typeName:M.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class dt extends B{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==C.bigint)return this._getInvalidInput(e);let n;const r=new re;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),T(n,{code:_.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),T(n,{code:_.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),T(n,{code:_.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):F.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return T(t,{code:_.invalid_type,expected:C.bigint,received:t.parsedType}),O}gte(e,t){return this.setLimit("min",e,!0,S.toString(t))}gt(e,t){return this.setLimit("min",e,!1,S.toString(t))}lte(e,t){return this.setLimit("max",e,!0,S.toString(t))}lt(e,t){return this.setLimit("max",e,!1,S.toString(t))}setLimit(e,t,n,r){return new dt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:S.toString(r)}]})}_addCheck(e){return new dt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:S.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:S.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:S.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:S.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:S.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}dt.create=s=>new dt({checks:[],typeName:M.ZodBigInt,coerce:(s==null?void 0:s.coerce)??!1,...$(s)});class as extends B{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==C.boolean){const n=this._getOrReturnCtx(e);return T(n,{code:_.invalid_type,expected:C.boolean,received:n.parsedType}),O}return me(e.data)}}as.create=s=>new as({typeName:M.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...$(s)});class Et extends B{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==C.date){const a=this._getOrReturnCtx(e);return T(a,{code:_.invalid_type,expected:C.date,received:a.parsedType}),O}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return T(a,{code:_.invalid_date}),O}const n=new re;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),T(r,{code:_.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),T(r,{code:_.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):F.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Et({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:S.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:S.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Et.create=s=>new Et({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:M.ZodDate,...$(s)});class Ws extends B{_parse(e){if(this._getType(e)!==C.symbol){const n=this._getOrReturnCtx(e);return T(n,{code:_.invalid_type,expected:C.symbol,received:n.parsedType}),O}return me(e.data)}}Ws.create=s=>new Ws({typeName:M.ZodSymbol,...$(s)});class qs extends B{_parse(e){if(this._getType(e)!==C.undefined){const n=this._getOrReturnCtx(e);return T(n,{code:_.invalid_type,expected:C.undefined,received:n.parsedType}),O}return me(e.data)}}qs.create=s=>new qs({typeName:M.ZodUndefined,...$(s)});class Xs extends B{_parse(e){if(this._getType(e)!==C.null){const n=this._getOrReturnCtx(e);return T(n,{code:_.invalid_type,expected:C.null,received:n.parsedType}),O}return me(e.data)}}Xs.create=s=>new Xs({typeName:M.ZodNull,...$(s)});class is extends B{constructor(){super(...arguments),this._any=!0}_parse(e){return me(e.data)}}is.create=s=>new is({typeName:M.ZodAny,...$(s)});class Gs extends B{constructor(){super(...arguments),this._unknown=!0}_parse(e){return me(e.data)}}Gs.create=s=>new Gs({typeName:M.ZodUnknown,...$(s)});class Ae extends B{_parse(e){const t=this._getOrReturnCtx(e);return T(t,{code:_.invalid_type,expected:C.never,received:t.parsedType}),O}}Ae.create=s=>new Ae({typeName:M.ZodNever,...$(s)});class Ys extends B{_parse(e){if(this._getType(e)!==C.undefined){const n=this._getOrReturnCtx(e);return T(n,{code:_.invalid_type,expected:C.void,received:n.parsedType}),O}return me(e.data)}}Ys.create=s=>new Ys({typeName:M.ZodVoid,...$(s)});class ke extends B{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==C.array)return T(t,{code:_.invalid_type,expected:C.array,received:t.parsedType}),O;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,l=t.data.length<r.exactLength.value;(i||l)&&(T(t,{code:i?_.too_big:_.too_small,minimum:l?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(T(t,{code:_.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(T(t,{code:_.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,l)=>r.type._parseAsync(new Te(t,i,t.path,l)))).then(i=>re.mergeArray(n,i));const a=[...t.data].map((i,l)=>r.type._parseSync(new Te(t,i,t.path,l)));return re.mergeArray(n,a)}
vendor: 4,406 bytes, line 1
1get element(){return this._def.type}min(e,t){return new ke({...this._def,minLength:{value:e,message:S.toString(t)}})}max(e,t){return new ke({...this._def,maxLength:{value:e,message:S.toString(t)}})}length(e,t){return new ke({...this._def,exactLength:{value:e,message:S.toString(t)}})}nonempty(e){return this.min(1,e)}}ke.create=(s,e)=>new ke({type:s,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...$(e)});function Ke(s){if(s instanceof U){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=De.create(Ke(n))}return new U({...s._def,shape:()=>e})}else return s instanceof ke?new ke({...s._def,type:Ke(s.element)}):s instanceof De?De.create(Ke(s.unwrap())):s instanceof st?st.create(Ke(s.unwrap())):s instanceof Ue?Ue.create(s.items.map(e=>Ke(e))):s}class U extends B{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=F.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==C.object){const d=this._getOrReturnCtx(e);return T(d,{code:_.invalid_type,expected:C.object,received:d.parsedType}),O}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),l=[];if(!(this._def.catchall instanceof Ae&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||l.push(d);const c=[];for(const d of i){const u=a[d],f=r.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new Te(r,f,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof Ae){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of l)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(d==="strict")l.length>0&&(T(r,{code:_.unrecognized_keys,keys:l}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of l){const f=r.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new Te(r,f,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const f=await u.key,h=await u.value;d.push({key:f,value:h,alwaysSet:u.alwaysSet})}return d}).then(d=>re.mergeObjectSync(n,d)):re.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return S.errToObj,new U({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var a,i;const r=((i=(a=this._def).errorMap)==null?void 0:i.call(a,t,n).message)??n.defaultError;return t.code==="unrecognized_keys"?{message:S.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new U({...this._def,unknownKeys:"strip"})}passthrough(){return new U({...this._def,unknownKeys:"passthrough"})}extend(e){return new U({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new U({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:M.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new U({...this._def,catchall:e})}pick(e){const t={};for(const n of F.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new U({...this._def,shape:()=>t})}omit(e){const t={};for(const n of F.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new U({...this._def,shape:()=>t})}deepPartial(){return Ke(this)}partial(e){const t={};for(const n of F.objectKeys(this.shape)){const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}return new U({...this._def,shape:()=>t})}required(e){const t={};for(const n of F.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof De;)a=a._def.innerType;t[n]=a}return new U({...this._def,shape:()=>t})}keyof(){return Dn(F.objectKeys(this.shape))}}U.create=(s,e)=>new U({shape:()=>s,unknownKeys:"strip",catchall:Ae.create(),typeName:M.ZodObject,...$(e)});U.strictCreate=(s,e)=>new U({shape:()=>s,unknownKeys:"strict",catchall:Ae.create(),typeName:M.ZodObject,...$(e)});U.lazycreate=(s,e)=>new U({shape:s,unknownKeys:"strip",catchall:Ae.create(),typeName:M.ZodObject,...$(e)});class It extends B{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function r(a){for(const l of a)if(l.result.status==="valid")return l.result;for(const l of a)if(l.result.status==="dirty")return t.common.issues.push(...l.ctx.common.issues),l.result;
vendor: 4,704 bytes, line 1
1const i=a.map(l=>new Ne(l.ctx.common.issues));return T(t,{code:_.invalid_union,unionErrors:i}),O}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of n){const d={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:d});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const l=i.map(c=>new Ne(c));return T(t,{code:_.invalid_union,unionErrors:l}),O}}get options(){return this._def.options}}It.create=(s,e)=>new It({options:s,typeName:M.ZodUnion,...$(e)});function os(s,e){const t=Oe(s),n=Oe(e);if(s===e)return{valid:!0,data:s};if(t===C.object&&n===C.object){const r=F.objectKeys(e),a=F.objectKeys(s).filter(l=>r.indexOf(l)!==-1),i={...s,...e};for(const l of a){const c=os(s[l],e[l]);if(!c.valid)return{valid:!1};i[l]=c.data}return{valid:!0,data:i}}else if(t===C.array&&n===C.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],l=e[a],c=os(i,l);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===C.date&&n===C.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class Rt extends B{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Hs(a)||Hs(i))return O;const l=os(a.value,i.value);return l.valid?((Us(a)||Us(i))&&t.dirty(),{status:t.value,value:l.data}):(T(n,{code:_.invalid_intersection_types}),O)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Rt.create=(s,e,t)=>new Rt({left:s,right:e,typeName:M.ZodIntersection,...$(t)});class Ue extends B{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.array)return T(n,{code:_.invalid_type,expected:C.array,received:n.parsedType}),O;if(n.data.length<this._def.items.length)return T(n,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),O;!this._def.rest&&n.data.length>this._def.items.length&&(T(n,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...n.data].map((i,l)=>{const c=this._def.items[l]||this._def.rest;return c?c._parse(new Te(n,i,n.path,l)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>re.mergeArray(t,i)):re.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new Ue({...this._def,rest:e})}}Ue.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ue({items:s,typeName:M.ZodTuple,rest:null,...$(e)})};class Mt extends B{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.object)return T(n,{code:_.invalid_type,expected:C.object,received:n.parsedType}),O;const r=[],a=this._def.keyType,i=this._def.valueType;for(const l in n.data)r.push({key:a._parse(new Te(n,l,n.path,l)),value:i._parse(new Te(n,n.data[l],n.path,l)),alwaysSet:l in n.data});return n.common.async?re.mergeObjectAsync(t,r):re.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof B?new Mt({keyType:e,valueType:t,typeName:M.ZodRecord,...$(n)}):new Mt({keyType:je.create(),valueType:e,typeName:M.ZodRecord,...$(t)})}}class Ks extends B{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.map)return T(n,{code:_.invalid_type,expected:C.map,received:n.parsedType}),O;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([l,c],d)=>({key:r._parse(new Te(n,l,n.path,[d,"key"])),value:a._parse(new Te(n,c,n.path,[d,"value"]))}));if(n.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const c of i){const d=await c.key,u=await c.value;if(d.status==="aborted"||u.status==="aborted")return O;(d.status==="dirty"||u.status==="dirty")&&t.dirty(),l.set(d.value,u.value)}return{status:t.value,value:l}})}else{const l=new Map;for(const c of i){const d=c.key,u=c.value;if(d.status==="aborted"||u.status==="aborted")return O;(d.status==="dirty"||u.status==="dirty")&&t.dirty(),l.set(d.value,u.value)}return{status:t.value,value:l}}}}
vendor: 6,968 bytes, line 1
1Ks.create=(s,e,t)=>new Ks({valueType:e,keyType:s,typeName:M.ZodMap,...$(t)});class ut extends B{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==C.set)return T(n,{code:_.invalid_type,expected:C.set,received:n.parsedType}),O;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(T(n,{code:_.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(T(n,{code:_.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const u of c){if(u.status==="aborted")return O;u.status==="dirty"&&t.dirty(),d.add(u.value)}return{status:t.value,value:d}}const l=[...n.data.values()].map((c,d)=>a._parse(new Te(n,c,n.path,d)));return n.common.async?Promise.all(l).then(c=>i(c)):i(l)}min(e,t){return new ut({...this._def,minSize:{value:e,message:S.toString(t)}})}max(e,t){return new ut({...this._def,maxSize:{value:e,message:S.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ut.create=(s,e)=>new ut({valueType:s,minSize:null,maxSize:null,typeName:M.ZodSet,...$(e)});class Qs extends B{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Qs.create=(s,e)=>new Qs({getter:s,typeName:M.ZodLazy,...$(e)});class en extends B{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return T(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),O}return{status:"valid",value:e.data}}get value(){return this._def.value}}en.create=(s,e)=>new en({value:s,typeName:M.ZodLiteral,...$(e)});function Dn(s,e){return new tt({values:s,typeName:M.ZodEnum,...$(e)})}class tt extends B{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return T(t,{expected:F.joinValues(n),received:t.parsedType,code:_.invalid_type}),O}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return T(t,{received:t.data,code:_.invalid_enum_value,options:n}),O}return me(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return tt.create(e,{...this._def,...t})}exclude(e,t=this._def){return tt.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}tt.create=Dn;class tn extends B{_parse(e){const t=F.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==C.string&&n.parsedType!==C.number){const r=F.objectValues(t);return T(n,{expected:F.joinValues(r),received:n.parsedType,code:_.invalid_type}),O}if(this._cache||(this._cache=new Set(F.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=F.objectValues(t);return T(n,{received:n.data,code:_.invalid_enum_value,options:r}),O}return me(e.data)}get enum(){return this._def.values}}tn.create=(s,e)=>new tn({values:s,typeName:M.ZodNativeEnum,...$(e)});class Ot extends B{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==C.promise&&t.common.async===!1)return T(t,{code:_.invalid_type,expected:C.promise,received:t.parsedType}),O;const n=t.parsedType===C.promise?t.data:Promise.resolve(t.data);return me(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ot.create=(s,e)=>new Ot({type:s,typeName:M.ZodPromise,...$(e)});class Je extends B{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{T(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async l=>{if(t.value==="aborted")return O;const c=await this._def.schema._parseAsync({data:l,path:n.path,parent:n});return c.status==="aborted"?O:c.status==="dirty"||t.value==="dirty"?ot(c.value):c});{if(t.value==="aborted")return O;const l=this._def.schema._parseSync({data:i,path:n.path,parent:n});return l.status==="aborted"?O:l.status==="dirty"||t.value==="dirty"?ot(l.value):l}}if(r.type==="refinement"){const i=l=>{const c=r.refinement(l,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(n.common.async===!1){const l=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return l.status==="aborted"?O:(l.status==="dirty"&&t.dirty(),i(l.value),{status:t.value,value:l.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(l=>l.status==="aborted"?O:(l.status==="dirty"&&t.dirty(),i(l.value).then(()=>({status:t.value,value:l.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Qe(i))return O;const l=r.transform(i.value,a);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:l}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Qe(i)?Promise.resolve(r.transform(i.value,a)).then(l=>({status:t.value,value:l})):O);F.assertNever(r)}}Je.create=(s,e,t)=>new Je({schema:s,typeName:M.ZodEffects,effect:e,...$(t)});Je.createWithPreprocess=(s,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:s},typeName:M.ZodEffects,...$(t)});class De extends B{_parse(e){return this._getType(e)===C.undefined?me(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}De.create=(s,e)=>new De({innerType:s,typeName:M.ZodOptional,...$(e)});class st extends B{_parse(e){return this._getType(e)===C.null?me(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}st.create=(s,e)=>new st({innerType:s,typeName:M.ZodNullable,...$(e)});class ls extends B{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===C.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ls.create=(s,e)=>new ls({innerType:s,typeName:M.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...$(e)});class cs extends B{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Nt(r)?r.then(a=>
1({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ne(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Ne(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}cs.create=(s,e)=>new cs({innerType:s,typeName:M.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...$(e)});class sn extends B{_parse(e){if(this._getType(e)!==C.nan){const n=this._getOrReturnCtx(e);return T(n,{code:_.invalid_type,expected:C.nan,received:n.parsedType}),O}return{status:"valid",value:e.data}}}sn.create=s=>new sn({typeName:M.ZodNaN,...$(s)});class Oa extends B{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ts extends B{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?O:a.status==="dirty"?(t.dirty(),ot(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?O:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new Ts({in:e,out:t,typeName:M.ZodPipeline})}}class ds extends B{_parse(e){const t=this._def.innerType._parse(e),n=r=>(Qe(r)&&(r.value=Object.freeze(r.value)),r);return Nt(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}}ds.create=(s,e)=>new ds({innerType:s,typeName:M.ZodReadonly,...$(e)});var M;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(M||(M={}));const Y=je.create,Q=et.create,Da=as.create,An=is.create;Ae.create;const Se=ke.create,_e=U.create,Aa=It.create;Rt.create;Ue.create;const $n=Mt.create,Cs=tt.create;Ot.create;De.create;st.create;const js=Je.createWithPreprocess,$a=["dotnetspy","ebpfspy","gospy","phpspy","pyspy","rbspy","nodespy","javaspy","pyroscope-rs"],La=["scrape","tracing","unknown"],nn=[...$a,...La],Ba=js(s=>!s||!nn.includes(s)?"unknown":s,Cs(nn).default("unknown")),rn=["samples","objects","goroutines","bytes","lock_samples","lock_nanoseconds","trace_samples","exceptions","nanoseconds"],Pa=js(s=>rn.find(e=>s===e)||"unknown",Cs([...rn,"unknown"])),Fa=_e({watermark:_e({}).optional(),startTime:Q(),samples:Se(Q()),durationDelta:Q()}),Za=$n(Y(),Fa),za=_e({names:Se(js(s=>s||"unknown",Y().min(1))),levels:Se(Se(Q())),numTicks:Q(),maxSelf:Q()}),Va=_e({appName:Y().optional(),name:Y().optional(),startTime:Q().optional(),endTime:Q().optional(),query:Y().optional(),maxNodes:Q().optional(),format:Cs(["single","double"]),sampleRate:Q(),spyName:Ba,units:Pa});_e({version:Q().min(1).max(1).default(1),flamebearer:za,metadata:Va,timeline:Za,leftTicks:Q().optional(),rightTicks:Q().optional()});const Dt={format:"single",jStep:4,jName:3,getBarOffset:(s,e)=>s[e],getBarTotal:(s,e)=>s[e+1],getBarTotalDiff:(s,e)=>0,getBarSelf:(s,e)=>s[e+2],getBarSelfDiff:(s,e)=>0,getBarName:(s,e)=>s[e+3]},ft={format:"double",jStep:7,jName:6,getBarOffset:(s,e)=>s[e]+s[e+3],getBarTotal:(s,e)=>s[e+4]+s[e+1],getBarTotalLeft:(s,e)=>s[e+1],getBarTotalRght:(s,e)=>s[e+4],getBarTotalDiff:(s,e)=>s[e+4]-s[e+1],getBarSelf:(s,e)=>s[e+5]+s[e+2],getBarSelfLeft:(s,e)=>s[e+2],getBarSelfRght:(s,e)=>s[e+5],getBarSelfDiff:(s,e)=>s[e+5]-s[e+2],getBarName:(s,e)=>s[e+6]};function pt(s){switch(s){case"single":return Dt;case"double":return ft;default:throw new Error(`Unsupported type: '${s}'`)}}const Ha=_e({refType:Y(),traceID:Y(),spanID:Y()}),us=_e({key:Y(),type:Y(),value:Aa([Da(),Q(),Y()])}),Ua=_e({traceID:Y(),spanID:Y(),flags:Y(),operationName:Y(),references:Se(Ha),startTime:Q(),duration:Q(),tags:Se(us),logs:_e({timestamp:Q(),fields:Se(us)}),processID:Y(),warnings:An()}),Ja=_e({serviceName:Y(),tags:Se(us)});_e({traceID:Y(),spans:Se(Ua),processes:$n(Ja),warnings:An()});const We=22,fs=5,Wa=20,Ln=.5,ze=We-Ln;function hs(s){return s.toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function Bn(s){return`${ve(s)}%`}function ve(s){return Math.round(1e4*s)/100}function Ct(s,e){return(e-s)/s*100}function Ft(s,e,t){switch(t){case"samples":return new Xt(s/e);case"objects":return new bt(s);case"goroutines":return new bt(s);case"bytes":return new Xa(s);case"lock_nanoseconds":return new qa(s);case"lock_samples":return new bt(s);case"trace_samples":return new Xt(s/e,"",!0);case"exceptions":return new bt(s);default:return console.warn(`Unsupported unit: '${t}'. Defaulting to ''`),new Xt(s/e," ")}}class Xt{constructor(e,t,n){this.divider=1,this.enableSubsecondPrecision=!1,this.suffix="second",this.durations=[[60,"minute"],[60,"hour"],[24,"day"],[30,"month"],[12,"year"]],this.units="",n&&(this.enableSubsecondPrecision=n,this.durations=[[1e3,"ms"],[1e3,"second"],...this.durations],this.suffix="μs",e*=1e6),this.units=t||"";for(let r=0;r<this.durations.length;r++){const a=this.durations[r];if(!a){console.warn("Could not calculate level");break}if(e>=a[0])this.divider*=a[0],e/=a[0],this.suffix=a[1];else break}}format(e,t,n=!0){this.enableSubsecondPrecision&&(t/=1e6);const r=e/t/this.divider;let a=r.toFixed(2);return r===0?a="0.00":(r>=0&&r<.01||r<=0&&r>-.01)&&(a="< 0.01"),n?`${a} ${this.units||`${this.suffix}${r===1||this.suffix.length===2?"":"s"}`}`:a}formatPrecise(e,t){this.enableSubsecondPrecision&&(t/=1e6);const n=e/t/this.divider;return`${parseFloat(n.toFixed(5))} ${this.units||`${this.suffix}${n===1||this.suffix.length===2?"":"s"}`}`}}class qa{constructor(e){this.divider=1,this.multiplier=1,this.suffix="second",this.durations=[[60,"minute"],[60,"hour"],[24,"day"],[30,"month"],[12,"year"]],e/=1e9;for(let t=0;t<this.durations.length;t++){const n=this.durations[t];if(!n){console.warn("Could not calculate level");break}if(e>=n[0])this.divider*=n[0],e/=n[0],this.suffix=n[1];else break}}format(e){const t=e/1e9/this.divider;let n=t.toFixed(2);return(t>=0&&t<.01||t<=0&&t>-.01)&&(n="< 0.01"),`${n} ${this.suffix}${t===1?"":"s"}`}formatPrecise(e){const t=e/1e9/this.divider;return`${parseFloat(t.toFixed(5))} ${this.suffix}${t===1?"":"s"}`}}class bt{constructor(e){this.divider=1,this.suffix="",this.objects=[[1e3,"K"],[1e3,"M"],[1e3,"G"],[1e3,"T"],[1e3,"P"]];for(let t=0;t<this.objects.length;t++){const n=this.objects[t];if(!n){console.warn("Could not calculate level");break}if(e>=n[0])this.divider*=n[0],e/=n[0],this.suffix=n[1];else break}}format(e){const t=e/this.divider;let n=t.toFixed(2);return(t>=0&&t<.01||t<=0&&t>-.01)&&(n="< 0.01"),`${n} ${this.suffix}`}formatPrecise(e){const t=e/this.divider;return`${parseFloat(t.toFixed(5))} ${this.suffix}`}}class Xa{constructor(e){this.divider=1,this.suffix="bytes",this.bytes=[[1024,"KB"],[1024,"MB"],[1024,"GB"],[1024,"TB"],[1024,"PB"]];for(let t=0;t<this.bytes.length;t++){const n=this.bytes[t];if(!n){console.warn("Could not calculate level");break}if(e>=n[0]){this.divider*=n[0],e/=n[0];const r=n[1];r?this.suffix=r:(console.warn("Could not calculate suffix"),this.suffix="")}else break}}format(e){const t=e/this.divider;let n=t.toFixed(2);return(t>=0&&t<.01||t<=0&&t>-.01)&&(n="< 0.01"),`${n} ${this.suffix}`}formatPrecise(e){const t=e/this.divider;return`${parseFloat(t.toFixed(5))} ${this.suffix}`}}const Ss="TAIL",At="HEAD",wt=3;function an({mode:s,charSize:e,rectWidth:t,fullText:n,shortText:r}){switch(s){case Ss:if(e*n.length<=t)return{mode:s,text:n,marginLeft:wt};const a=e*r.length;return a<=t?{mode:s,text:r,marginLeft:wt}:{mode:s,text:r,marginLeft:-(a-t+wt)};case At:default:return{mode:s,text:n,marginLeft:wt}}}function Ga(s){switch(s){case Ss:return{direction:"rtl",overflow:"hidden",textOverflow:"ellipsis"};case At:default:return{overflow:"hidden",textOverflow:"ellipsis"}}}function Ya(s,e,t,n){const r=ft;if(!t||!n)return console.error("Properties 'rightTicks' and 'leftTicks' are required. Can't calculate ratio."),{leftRatio:0,rightRatio:0};const a=r.getBarTotalLeft(s,e)/t,i=r.getBarTotalRght(s,e)/n;return{leftRatio:a,rightRatio:i}}function Ka(s,e=0){let t,n,r,a,i,l,c,d;for(t=s.length&3,n=s.length-t,r=e,i=3432918353,l=461845907,d=0;d<n;)c=s.charCodeAt(d)&255|(s.charCodeAt(++d)&255)<<8|(s.charCodeAt(++d)&255)<<16|(s.charCodeAt(++d)&255)<<24,++d,c=(c&65535)*i+(((c>>>16)*i&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*l+(((c>>>16)*l&65535)<<16)&4294967295,r^=c,r=r<<13|r>>>19,a=(r&65535)*5+(((r>>>16)*5&65535)<<16)&4294967295,r=(a&65535)+27492+(((a>>>16)+58964&65535)<<16);switch(c=0,t){case 3:c^=(s.charCodeAt(d+2)&255)<<16;case 2:c^=(s.charCodeAt(d+1)&255)<<8;case 1:c^=s.charCodeAt(d)&255;default:c=(c&65535)*i+(((c>>>16)*i&65535)<<16)&4294967295,c=c<<15|c>>>17,c=(c&65535)*l+(((c>>>16)*l&65535)<<16)&4294967295,r^=c}return r^=s.length,r^=r>>>16,r=(r&65535)*2246822507+(((r>>>16)*2246822507&65535)<<16)&4294967295,r^=r>>>13,r=(r&65535)*3266489909+(((r>>>16)*3266489909&65535)<<16)&4294967295,r^=r>>>16,r>>>0}const Qa=L.rgb(148,142,142);L.rgb(200,0,0);L.rgb(0,170,0);L("#48CE73");function ei(s,e,t){const n=ti(e,t);return Zn(s)(n)}function ti(s,e){if(s===e)return 0;if(s===0)return 100;const t=(e-s)/s*100;return t>100?100:t<-100?-100:t}
1function ms(s,e){return L.rgb(s,s,s).alpha(e)}function si(s){switch(s){case"dotnetspy":return/^(?<packageName>.+)\.(.+)\.(.+)\(.*\)$/;case"ebpfspy":return/^(?<packageName>.+)$/;case"gospy":return/^(?<packageName>.*?\/.*?\.|.*?\.|.+)(?<functionName>.*)$/;case"scrape":return/^(?<packageName>.*?\/.*?\.|.*?\.|.+)(?<functionName>.*)$/;case"phpspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.php+)(?<line_info>.*)$/;case"pyspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.py+)(?<line_info>.*)$/;case"rbspy":return/^(?<packageName>(.*\/)*)(?<filename>.*\.rb+)(?<line_info>.*)$/;case"nodespy":return/^(\.\/node_modules\/)?(?<packageName>[^/]*)(?<filename>.*\.?(jsx?|tsx?)?):(?<functionName>.*):(?<line_info>.*)$/;case"tracing":return/^(?<packageName>.+?):.*$/;case"javaspy":return/^(?<packageName>.+\/)(?<filename>.+\.)(?<functionName>.+)$/;case"pyroscope-rs":return/^(?<packageName>[^::]+)/;case"unknown":return/^(?<packageName>.+)$/}return/^(?<packageName>.+)$/}function Pn(s,e){if(e.length===0)return e;const t=si(s),n=e.match(t);return n&&n.groups?n.groups.packageName||"":e}function Fn(s,e){const n=Ka(e,0)%s.colors.length,r=s.colors[n];return r||(console.warn("Could not calculate color. Defaulting to the first one"),s.colors[0])}function Zn(s){const{goodColor:e,neutralColor:t,badColor:n}=s,r=Wr().domain([-100,0,100]).range([e.rgb().toString(),t.rgb().toString(),n.rgb().toString()]);return a=>L(r(a).toString())}function zn(s,e){return e.toLowerCase().includes(s.toLowerCase())}function on(s){const{canvas:e,fitMode:t,units:n,tickToX:r,levels:a,palette:i}=s,{numTicks:l,sampleRate:c,pxPerTick:d}=s,{rangeMin:u,rangeMax:f}=s,{focusedNode:h,zoom:g}=s,m=oi(e);if(e.width=m,u>=f)throw new Error("'rangeMin' should be strictly smaller than 'rangeMax'");const{format:x}=s,y=pt(x),v=e.getContext("2d");if(!v)throw new Error("Could not get ctx");const k=g.mapOrElse(()=>0,j=>j.i),w=Ft(l,c,n),I=h.isJust,E=h.mapOrElse(()=>0,j=>j.i),D=We*(a.length-E)+(I?ze:0);e.height=D,devicePixelRatio>1&&(e.width*=2,e.height*=2,v.scale(2,2));const{names:b}=s;if(I){const j=l*d;v.beginPath(),v.rect(0,0,l*d,ze),v.fillStyle=ms(200,1).rgb().string(),v.fill();const R=h.mapOrElse(()=>"total",ee=>`total (${ee.i-1} level(s) collapsed)`);v.textBaseline="middle",v.font="400 11.5px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace";const N=v.measureText("a").width,A=an({mode:t,charSize:N,rectWidth:j,fullText:R,shortText:R}),Z=0,z=0,ue=ze;v.save(),v.clip(),v.fillStyle="black";const Ce=Math.round(Math.max(Z,0));v.fillText(A.text,Ce+A.marginLeft,z+ue/2+1),v.restore()}for(let j=0;j<a.length-E;j+=1){const R=a[E+j];if(!R)throw new Error(`Could not find level: ${E+j}`);for(let N=0;N<R.length;N+=y.jStep){const A=y.getBarOffset(R,N),Z=r(A),z=j*We+(I?ze:0),ue=ze,Ce=!!s.highlightQuery&&s.highlightQuery.length>0,ee=ln(N+y.jName,R,b,s.highlightQuery);let ce=y.getBarTotal(R,N);const de=ce*d<=fs;if(de)for(;N<R.length-y.jStep&&A+ce===y.getBarOffset(R,N+y.jStep)&&y.getBarTotal(R,N+y.jStep)*d<=fs&&ee===(s.highlightQuery&&ln(N+y.jStep+y.jName,R,b,s.highlightQuery)||!1);)N+=y.jStep,ce+=y.getBarTotal(R,N);const $e=ce*d-(de?0:Ln),{spyName:V}=s,te=(()=>{const Ge={level:R,j:N,i:j+h.mapOrElse(()=>0,Ye=>Ye.i),names:b,collapsed:de,selectedLevel:k,highlightModeOn:Ce,isHighlighted:ee,spyName:V,palette:i};switch(x){case"single":return ai({...Ge});case"double":return ii({...Ge,leftTicks:s.leftTicks,rightTicks:s.rightTicks});default:throw new Error(`Unsupported format: ${x}`)}})();if(v.beginPath(),v.rect(Z,z,$e,ue),v.fillStyle=te.string(),v.fill(),de||$e<Wa)continue;const ae=ni(b,N,x,R),ie=ri(ae,ce,l,c,w);v.textBaseline="middle",v.font="400 11.5px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace";const Xe=v.measureText("a").width,Le=an({mode:t,charSize:Xe,rectWidth:$e,fullText:ie,shortText:ae});v.save(),v.clip(),v.fillStyle="black";const Be=Math.round(Math.max(Z,0));v.fillText(Le.text,Be+Le.marginLeft,z+ue/2+1),v.restore()}}}function ni(s,e,t,n){const r=pt(t);let a=n[e+r.jName];a===void 0&&(a=-1);const i=s[a];return i||(console.warn("Could not find function name for",{j:e,format:t,level:n,names:s}),"")}function ri(s,e,t,n,r){const a=e/t,i=Bn(a);return`${s} (${i}, ${r.format(e,n)})`}function Vn({collapsed:s,highlightModeOn:e,isHighlighted:t}){return s||e&&!t?ms(200,.66):null}function ai(s){const e=Vn(s);if(e)return e;const t=pt("single"),n=s.selectedLevel>s.i?.33:1;let r=s.level[s.j+t.jName];r===void 0&&(console.warn("Could nto find level",{l:s.j,jName:t.jName,level:s.level}),r=-1);const a=s.names[r]||"",i=Pn(s.spyName,a)||"";return Fn(s.palette,i).alpha(n)}function ii(s){const e=Vn(s);if(e)return e;const t=s.selectedLevel>s.i?.33:1,{leftRatio:n,rightRatio:r}=Ya(s.level,s.j,s.leftTicks,s.rightTicks),a=ve(n),i=ve(r);
1return ei(s.palette,a,i).alpha(t)}function ln(s,e,t,n){const r=e[s];if(!r)return!1;const a=t[r];return a?zn(n,a):!1}function oi(s){return s.clientWidth||s.width}class li{constructor(e,t,n,r,a,i,l){if(this.flamebearer=e,this.canvas=t,this.focusedNode=n,this.fitMode=r,this.highlightQuery=a,this.zoom=i,this.palette=l,this.tickToX=c=>{const{rangeMin:d}=this.getRange();return(c-this.flamebearer.numTicks*d)*this.pxPerTick()},this.xyToBarPosition=c=>{const{ff:d}=this,{i:u,j:f}=this.xyToBarIndex(c.x,c.y),h=this.focusedNode.mapOrElse(()=>0,v=>v.i<0?0:v.i-1),g=this.flamebearer.levels[u];if(!g)throw new Error(`Could not find level: '${u}'`);const m=Math.max(this.tickToX(d.getBarOffset(g,f)),0),x=Math.max((u-h)*We,0),y=Math.min(this.tickToX(d.getBarOffset(g,f)+d.getBarTotal(g,f))-m,this.getCanvasWidth());return{x:m,y:x,width:y}},this.xyToBarData=c=>{const{i:d,j:u}=this.xyToBarIndex(c.x,c.y),f=this.flamebearer.levels[d];if(!f)throw new Error(`Could not find level: '${d}'`);switch(this.flamebearer.format){case"single":{const h=Dt;return{format:"single",name:this.flamebearer.names[h.getBarName(f,u)],self:h.getBarSelf(f,u),offset:h.getBarOffset(f,u),total:h.getBarTotal(f,u)}}case"double":{const h=ft;return{format:"double",barTotal:h.getBarTotal(f,u),totalLeft:h.getBarTotalLeft(f,u),totalRight:h.getBarTotalRght(f,u),totalDiff:h.getBarTotalDiff(f,u),name:this.flamebearer.names[h.getBarName(f,u)]}}default:throw new Error("Unsupported type")}},this.isWithinBounds=(c,d)=>{if(c<0||c>this.getCanvasWidth())return!1;try{const{i:u,j:f}=this.xyToBarIndex(c,d);if(f===-1||u===-1)return!1}catch{return!1}return!0},this.zoom=i,this.focusedNode=n,this.flamebearer=e,this.canvas=t,this.highlightQuery=a,this.ff=pt(e.format),this.palette=l,n.isJust&&i.isJust&&i.value.i<n.value.i)throw new Error("Zoom i level should be bigger than Focus")}render(){const{rangeMin:e,rangeMax:t}=this.getRange(),n={canvas:this.canvas,format:this.flamebearer.format,numTicks:this.flamebearer.numTicks,sampleRate:this.flamebearer.sampleRate,names:this.flamebearer.names,levels:this.flamebearer.levels,spyName:this.flamebearer.spyName,units:this.flamebearer.units,maxSelf:this.flamebearer.maxSelf,rangeMin:e,rangeMax:t,fitMode:this.fitMode,highlightQuery:this.highlightQuery,zoom:this.zoom,focusedNode:this.focusedNode,pxPerTick:this.pxPerTick(),tickToX:this.tickToX,palette:this.palette},{format:r}=this.flamebearer;switch(r){case"single":{on({...n,format:"single"});break}case"double":{on({...n,leftTicks:this.flamebearer.leftTicks,rightTicks:this.flamebearer.rightTicks});break}default:throw new Error(`Invalid format: '${r}'`)}}pxPerTick(){const{rangeMin:e,rangeMax:t}=this.getRange();return this.getCanvasWidth()/this.flamebearer.numTicks/(t-e)}getRange(){const{ff:e}=this,t=i=>{const l=this.flamebearer.levels[i.i];if(!l)throw new Error(`Could not find level: '${i.i}'`);const c=e.getBarOffset(l,i.j)/this.flamebearer.numTicks,d=(e.getBarOffset(l,i.j)+e.getBarTotal(l,i.j))/this.flamebearer.numTicks;return{rangeMin:c,rangeMax:d}},n=i=>{const l=this.flamebearer.levels[i.i];if(!l)throw new Error(`Could not find level: '${i.i}'`);const c=e.getBarOffset(l,i.j)/this.flamebearer.numTicks,d=(e.getBarOffset(l,i.j)+e.getBarTotal(l,i.j))/this.flamebearer.numTicks;return{rangeMin:c,rangeMax:d}},{zoom:r,focusedNode:a}=this;return r.match({Just:i=>a.match({Just:l=>{const c=n(l),d=t(i);return c.rangeMax-c.rangeMin<d.rangeMax-d.rangeMin?(console.warn("Focus is smaller than range, this shouldnt happen. Verify that the zoom is always bigger than the focus."),n(l)):t(i)},Nothing:()=>t(i)}),Nothing:()=>a.match({Just:i=>n(i),Nothing:()=>({rangeMin:0,rangeMax:1})})})}getCanvasWidth(){return this.canvas.clientWidth||this.canvas.width}isFocused(){return this.focusedNode.isJust}binarySearchLevel(e,t){const{ff:n}=this;let r=0,a=t.length-n.jStep;for(;r<=a;){const i=n.jStep*(r/n.jStep+a/n.jStep>>1),l=this.tickToX(n.getBarOffset(t,i)),c=this.tickToX(n.getBarOffset(t,i)+n.getBarTotal(t,i));if(l<=e&&c>=e)return c-l>fs?i:-1;l>e?a=i-n.jStep:r=i+n.jStep}return-1}xyToBarIndex(e,t){if(e<0||t<0)throw new Error(`x and y must be bigger than 0. x = ${e}, y = ${t}`);if(this.isFocused()&&t<=ze)return{i:0,j:0};const n=this.isFocused()?t-ze:t,r=this.focusedNode.mapOrElse(()=>0,l=>l.i<=0?0:l.i),a=this.zoom.match({Just:()=>this.focusedNode.match({Just:()=>r,Nothing:()=>0}),Nothing:()=>this.focusedNode.match({Just:()=>r,Nothing:()=>0})}),i=Math.floor(n/We)+a;if(i>=0&&i<this.flamebearer.levels.length){const l=this.flamebearer.levels[i];if(!l)throw new Error(`Could not find level: '${i}'`);const c=this.binarySearchLevel(e,l);return{i,j:c}}return{i:0,j:0}}parseXY(e,t){const n=this.isWithinBounds(e,t),r={x:e,y:t};return n?q.of(r):q.nothing()}xyToBar(e,t){return this.parseXY(e,t).map(n=>{const{i:r,j:a}=this.xyToBarIndex(e,t),i=this.xyToBarPosition(n),l=this.xyToBarData(n);return{i:r,j:a,...i,...l}})}}const ci="_noData_1g8k8_1",di={noData:ci};function ui(){return o.jsx("div",{"data-testid":"no-data",className:di.noData,children:o.jsx("span",{children:"No data available"})})}const fi=X[typeof document<"u"&&document.createElement!==void 0?"useLayoutEffect":"useEffect"],hi=s=>{const e=p.useRef(s);return p.useEffect(()=>{e.current=s}),e},mi=typeof window<"u"&&"ResizeObserver"in window?window.ResizeObserver:Mr;function pi(){}function Ns(s,e){const t=vi(),n=hi(e);return fi(()=>{let r=!1;const a=s&&"current"in s?s.current:s;
1if(!a)return pi;function i(l,c){r||n.current(l,c)}return t.subscribe(a,i),()=>{r=!0,t.unsubscribe(a,i)}},[s,t,n]),t.observer}function gi(){let s=!1,e=[];const t=new Map,n=new mi((r,a)=>{e=e.concat(r);function i(){const l=new Set;for(let c=0;c<e.length;c++){if(l.has(e[c].target))continue;l.add(e[c].target);const d=t.get(e[c].target);d==null||d.forEach(u=>u(e[c],a))}e=[],s=!1}s||window.requestAnimationFrame(i),s=!0});return{observer:n,subscribe(r,a){var i;n.observe(r);const l=(i=t.get(r))!==null&&i!==void 0?i:[];l.push(a),t.set(r,l)},unsubscribe(r,a){var i;const l=(i=t.get(r))!==null&&i!==void 0?i:[];if(l.length===1){n.unobserve(r),t.delete(r);return}const c=l.indexOf(a);c!==-1&&l.splice(c,1),t.set(r,l)}}}let Gt;const vi=()=>Gt||(Gt=gi()),Hn=s=>!!s&&s[0]==="o",cn=St.unstable_batchedUpdates,ht=(s,e)=>s===!0||!!(s&&s[e]),he=(s,e)=>typeof s=="function"?s(e):s,Un="_szhsinMenu",yi=s=>s[Un],xi=(s,e)=>Object.defineProperty(e,Un,{value:s}),Zt=(s,e)=>(e&&Object.keys(e).forEach(t=>{const n=s[t],r=e[t];typeof r=="function"&&n?s[t]=(...a)=>{r(...a),n(...a)}:s[t]=r}),s),_i=s=>{if(typeof s!="string")return{top:0,right:0,bottom:0,left:0};const e=s.trim().split(/\s+/,4).map(parseFloat),t=isNaN(e[0])?0:e[0],n=isNaN(e[1])?t:e[1];return{top:t,right:n,bottom:isNaN(e[2])?t:e[2],left:isNaN(e[3])?n:e[3]}},Yt=s=>{for(;s;){if(s=s.parentNode,!s||s===document.body||!s.parentNode)return;const{overflow:e,overflowX:t,overflowY:n}=getComputedStyle(s);if(/auto|scroll|overlay|hidden/.test(e+n+t))return s}};function Jn(s,e){return{"aria-disabled":s||void 0,tabIndex:e?0:-1}}function dn(s,e){for(let t=0;t<s.length;t++)if(s[t]===e)return t;return-1}const nt=({block:s,element:e,modifiers:t,className:n})=>p.useMemo(()=>{const r=e?`${s}__${e}`:s;let a=r;t&&Object.keys(t).forEach(l=>{const c=t[l];c&&(a+=` ${r}--${c===!0?l:`${l}-${c}`}`)});let i=typeof n=="function"?n(t):n;return typeof i=="string"&&(i=i.trim(),i&&(a+=` ${i}`)),a},[s,e,t,n]),bi="szh-menu-container",lt="szh-menu",wi="szh-menu-button",ki="arrow",Ti="item",Ci="header",Wn=p.createContext(),qn=p.createContext({}),un=p.createContext({}),Xn=p.createContext({}),ji=p.createContext({}),Es=p.createContext({}),xe=Object.freeze({ENTER:"Enter",ESC:"Escape",SPACE:" ",HOME:"Home",END:"End",LEFT:"ArrowLeft",RIGHT:"ArrowRight",UP:"ArrowUp",DOWN:"ArrowDown"}),W=Object.freeze({RESET:0,SET:1,UNSET:2,INCREASE:3,DECREASE:4,FIRST:5,LAST:6,SET_INDEX:7}),mt=Object.freeze({CLICK:"click",CANCEL:"cancel",BLUR:"blur",SCROLL:"scroll"}),ct=Object.freeze({FIRST:"first",LAST:"last"}),Si=Object.freeze({entering:"opening",entered:"open",exiting:"closing",exited:"closed"}),fn="absolute",Gn="none",Ni="menuitem",ps={preventScroll:!0},Ei=xi("MenuButton",p.forwardRef(function({className:e,isOpen:t,disabled:n,children:r,...a},i){const l=p.useMemo(()=>({open:t}),[t]);return o.jsx("button",{"aria-haspopup":!0,"aria-expanded":t,"aria-disabled":n||void 0,type:"button",disabled:n,...a,ref:i,className:nt({block:wi,modifiers:l,className:e}),children:r})})),Ii=({className:s,containerRef:e,containerProps:t,children:n,isOpen:r,theming:a,transition:i,onClose:l})=>{const c=ht(i,"item"),d=({key:f})=>{switch(f){case xe.ESC:he(l,{key:f,reason:mt.CANCEL});break}},u=f=>{r&&!f.currentTarget.contains(f.relatedTarget)&&he(l,{reason:mt.BLUR})};return o.jsx("div",{...Zt({onKeyDown:d,onBlur:u},t),className:nt({block:bi,modifiers:p.useMemo(()=>({theme:a,itemTransition:c}),[a,c]),className:s}),style:{position:"absolute",...t==null?void 0:t.style},ref:e,children:n})},Ri=()=>{let s,e=0;return{toggle:t=>{t?e++:e--,e=Math.max(e,0)},on:(t,n,r)=>{e?s||(s=setTimeout(()=>{s=0,n()},t)):r==null||r()},off:()=>{s&&(clearTimeout(s),s=0)}}},Mi=s=>{const[e,t]=p.useState(),r=p.useRef({items:[],hoverIndex:-1,sorted:!1}).current,a=p.useCallback((l,c)=>{const{items:d}=r;if(!l)r.items=[];else if(c)d.push(l);else{const u=d.indexOf(l);u>-1&&(d.splice(u,1),l.contains(document.activeElement)&&(s.current.focus(ps),t()))}r.hoverIndex=-1,r.sorted=!1},[r,s]),i=p.useCallback((l,c,d)=>{const{items:u,hoverIndex:f}=r,h=()=>{if(r.sorted)return;const x=s.current.querySelectorAll(".szh-menu__item");u.sort((y,v)=>dn(x,y)-dn(x,v)),r.sorted=!0}
1;let g=-1,m;switch(l){case W.RESET:break;case W.SET:m=c;break;case W.UNSET:m=x=>x===c?void 0:x;break;case W.FIRST:h(),g=0,m=u[g];break;case W.LAST:h(),g=u.length-1,m=u[g];break;case W.SET_INDEX:h(),g=d,m=u[g];break;case W.INCREASE:h(),g=f,g<0&&(g=u.indexOf(c)),g++,g>=u.length&&(g=0),m=u[g];break;case W.DECREASE:h(),g=f,g<0&&(g=u.indexOf(c)),g--,g<0&&(g=u.length-1),m=u[g];break}m||(g=-1),t(m),r.hoverIndex=g},[s,r]);return{hoverItem:e,dispatch:i,updateItems:a}},hn=(s,e)=>Math.round(s)===e?s:e,Oi=s=>{const e=s.getBoundingClientRect();return e.width=hn(e.width,s.offsetWidth),e.height=hn(e.height,s.offsetHeight),e},Di=(s,e,t,n)=>{const r=Oi(e),a=s.getBoundingClientRect(),i=t===window?{left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight}:t.getBoundingClientRect(),l=_i(n),c=m=>m+a.left-i.left-l.left,d=m=>m+a.left+r.width-i.right+l.right,u=m=>m+a.top-i.top-l.top,f=m=>m+a.top+r.height-i.bottom+l.bottom;return{menuRect:r,containerRect:a,getLeftOverflow:c,getRightOverflow:d,getTopOverflow:u,getBottomOverflow:f,confineHorizontally:m=>{let x=c(m);if(x<0)m-=x;else{const y=d(m);y>0&&(m-=y,x=c(m),x<0&&(m-=x))}return m},confineVertically:m=>{let x=u(m);if(x<0)m-=x;else{const y=f(m);y>0&&(m-=y,x=u(m),x<0&&(m-=x))}return m}}},Ai=({arrowRef:s,menuY:e,anchorRect:t,containerRect:n,menuRect:r})=>{let a=t.top-n.top-e+t.height/2;const i=s.current.offsetHeight*1.25;return a=Math.max(i,a),a=Math.min(a,r.height-i),a},$i=({anchorRect:s,containerRect:e,menuRect:t,placeLeftorRightY:n,placeLeftX:r,placeRightX:a,getLeftOverflow:i,getRightOverflow:l,confineHorizontally:c,confineVertically:d,arrowRef:u,arrow:f,direction:h,position:g})=>{let m=h,x=n;g!=="initial"&&(x=d(x),g==="anchor"&&(x=Math.min(x,s.bottom-e.top),x=Math.max(x,s.top-e.top-t.height)));let y,v,k;return m==="left"?(y=r,g!=="initial"&&(v=i(y),v<0&&(k=l(a),(k<=0||-v>k)&&(y=a,m="right")))):(y=a,g!=="initial"&&(k=l(y),k>0&&(v=i(r),(v>=0||-v<k)&&(y=r,m="left")))),g==="auto"&&(y=c(y)),{arrowY:f?Ai({menuY:x,arrowRef:u,anchorRect:s,containerRect:e,menuRect:t}):void 0,x:y,y:x,computedDirection:m}},Li=({arrowRef:s,menuX:e,anchorRect:t,containerRect:n,menuRect:r})=>{let a=t.left-n.left-e+t.width/2;const i=s.current.offsetWidth*1.25;return a=Math.max(i,a),a=Math.min(a,r.width-i),a},Bi=({anchorRect:s,containerRect:e,menuRect:t,placeToporBottomX:n,placeTopY:r,placeBottomY:a,getTopOverflow:i,getBottomOverflow:l,confineHorizontally:c,confineVertically:d,arrowRef:u,arrow:f,direction:h,position:g})=>{let m=h==="top"?"top":"bottom",x=n;g!=="initial"&&(x=c(x),g==="anchor"&&(x=Math.min(x,s.right-e.left),x=Math.max(x,s.left-e.left-t.width)));let y,v,k;return m==="top"?(y=r,g!=="initial"&&(v=i(y),v<0&&(k=l(a),(k<=0||-v>k)&&(y=a,m="bottom")))):(y=a,g!=="initial"&&(k=l(y),k>0&&(v=i(r),(v>=0||-v<k)&&(y=r,m="top")))),g==="auto"&&(y=d(y)),{arrowX:f?Li({menuX:x,arrowRef:u,anchorRect:s,containerRect:e,menuRect:t}):void 0,x,y,computedDirection:m}},Pi=({arrow:s,align:e,direction:t,gap:n,shift:r,position:a,anchorRect:i,arrowRef:l,positionHelpers:c})=>{const{menuRect:d,containerRect:u}=c,f=t==="left"||t==="right";let h=f?n:r,g=f?r:n;if(s){const E=l.current;f?h+=E.offsetWidth:g+=E.offsetHeight}const m=i.left-u.left-d.width-h,x=i.right-u.left+h,y=i.top-u.top-d.height-g,v=i.bottom-u.top+g;let k,w;e==="end"?(k=i.right-u.left-d.width,w=i.bottom-u.top-d.height):e==="center"?(k=i.left-u.left-(d.width-i.width)/2,w=i.top-u.top-(d.height-i.height)/2):(k=i.left-u.left,w=i.top-u.top),k+=h,w+=g;const I={...c,anchorRect:i,placeLeftX:m,placeRightX:x,placeLeftorRightY:w,placeTopY:y,placeBottomY:v,placeToporBottomX:k,arrowRef:l,arrow:s,direction:t,position:a};switch(t){case"left":case"right":return $i(I);case"top":case"bottom":default:return Bi(I)}},jt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?p.useLayoutEffect:p.useEffect;function mn(s,e){typeof s=="function"?s(e):s.current=e}const Is=(s,e)=>p.useMemo(()=>s?e?t=>{mn(s,t),mn(e,t)}:s:e,[s,e]),pn=-9999,Fi=({ariaLabel:s,menuClassName:e,menuStyle:t,arrow:n,arrowProps:r={},anchorPoint:a,anchorRef:i,containerRef:l,containerProps:c,externalRef:d,parentScrollingRef:u,align:f="start",direction:h="bottom",position:g="auto",overflow:m="visible",setDownOverflow:x,repositionFlag:y,captureFocus:v=!0,state:k,endTransition:w,isDisabled:I,menuItemFocus:E,gap:D=0,shift:b=0,children:j,onClose:R,focusProps:N,...A})=>{const[Z,z]=p.useState({x:pn,y:pn}),[ue,Ce]=p.useState({}),[ee,ce]=p.useState(),[de,$e]=p.useState(h),[V]=p.useState(Ri),[H,te]=p.useReducer(P=>P+1,1),{transition:ae,boundingBoxRef:ie,boundingBoxPadding:Xe,rootMenuRef:Le,rootAnchorRef:Be,scrollNodesRef:Ge,reposition:Ye,viewScroll:ne,submenuCloseDelay:Pe}=p.useContext(Es),{submenuCtx:Fe,reposSubmenu:fr=y}=p.useContext(un),Ee=p.useRef(),Os=p.useRef(),Ds=p.useRef(!1),{hoverItem:zt,dispatch:fe,updateItems:vt}=Mi(Ee),oe=Hn(k),As=ht(ae,"open"),$s=ht(ae,"close"),pe=Ge.current,hr=P=>{switch(P.key){case xe.HOME:fe(W.FIRST);break;case xe.END:fe(W.LAST);break;case xe.UP:fe(W.DECREASE,zt);break;case xe.DOWN:fe(W.INCREASE,zt);break;case xe.SPACE:P.target&&P.target.className.indexOf(lt)!==-1&&P.preventDefault();return;default:return}P.preventDefault(),P.stopPropagation()},mr=()=>{k==="closing"&&ce(),he(w)},pr=P=>{P.stopPropagation(),V.on(Pe,()=>{fe(W.RESET),Ee.current.focus(ps)})},gr=P=>{P.target===P.currentTarget&&V.off()},Ie=p.useCallback(P=>{var Zs;const se=Ee.current,ge=l.current;if(!se||!ge)return;const be=i?(Zs=i.current)==null?void 0:Zs.getBoundingClientRect():a?{left
1:a.x,right:a.x,top:a.y,bottom:a.y,width:0,height:0}:null;if(!be)return;pe.menu||(pe.menu=(ie?ie.current:Yt(Le.current))||window);const J=Di(ge,se,pe.menu,Xe);let{arrowX:yt,arrowY:wr,x:kr,y:xt,computedDirection:Tr}=Pi({arrow:n,align:f,direction:h,gap:D,shift:b,position:g,anchorRect:be,arrowRef:Os,positionHelpers:J});const{menuRect:Cr}=J,Fs=Cr.height;if(!P&&m!=="visible"){const{getTopOverflow:jr,getBottomOverflow:Sr}=J;let rt,Ut;const Jt=Sr(xt);if(Jt>0)rt=Fs-Jt,Ut=Jt;else{const _t=jr(xt);_t<0&&(rt=Fs+_t,Ut=0-_t,rt>=0&&(xt-=_t))}rt>=0&&ce({height:rt,overflowAmt:Ut})}n&&Ce({x:yt,y:wr}),z({x:kr,y:xt}),$e(Tr)},[n,f,Xe,h,D,b,g,m,a,i,l,ie,Le,pe]);jt(()=>{oe&&(Ie(),Ds.current&&te()),Ds.current=oe},[oe,Ie,fr]),jt(()=>{ee&&!x&&(Ee.current.scrollTop=0)},[ee,x]),jt(()=>vt,[vt]),p.useEffect(()=>{let{menu:P}=pe;if(!oe||!P)return;if(P=P.addEventListener?P:window,!pe.anchors){pe.anchors=[];let J=Yt(Be&&Be.current);for(;J&&J!==P;)pe.anchors.push(J),J=Yt(J)}let se=ne;if(pe.anchors.length&&se==="initial"&&(se="auto"),se==="initial")return;const ge=()=>{se==="auto"?cn(()=>Ie(!0)):he(R,{reason:mt.SCROLL})},be=pe.anchors.concat(ne!=="initial"?P:[]);return be.forEach(J=>J.addEventListener("scroll",ge)),()=>be.forEach(J=>J.removeEventListener("scroll",ge))},[Be,pe,oe,R,ne,Ie]);const Ls=!!ee&&ee.overflowAmt>0;p.useEffect(()=>{if(Ls||!oe||!u)return;const P=()=>cn(Ie),se=u.current;return se.addEventListener("scroll",P),()=>se.removeEventListener("scroll",P)},[oe,Ls,u,Ie]),p.useEffect(()=>{if(!oe||typeof ResizeObserver!="function"||Ye==="initial")return;const P=[],se=new ResizeObserver(J=>J.forEach(({target:yt})=>{P.indexOf(yt)<0?P.push(yt):St.flushSync(()=>{Ie(),te()})})),ge={box:"border-box"};se.observe(Ee.current,ge);const be=i==null?void 0:i.current;return be&&se.observe(be,ge),()=>se.disconnect()},[oe,Ye,i,Ie]),p.useEffect(()=>{if(!oe){fe(W.RESET),$s||ce();return}const{position:P,alwaysUpdate:se}=E||{},ge=()=>{P===ct.FIRST?fe(W.FIRST):P===ct.LAST?fe(W.LAST):P>=-1&&fe(W.SET_INDEX,void 0,P)};if(se)ge();else if(v){const be=setTimeout(()=>{const J=Ee.current;
1J&&!J.contains(document.activeElement)&&(J.focus(ps),ge())},As?170:100);return()=>clearTimeout(be)}},[oe,As,$s,v,E,fe]);const vr=p.useMemo(()=>({isParentOpen:oe,submenuCtx:V,dispatch:fe,updateItems:vt}),[oe,V,fe,vt]);let Vt,Ht;ee&&(x?Ht=ee.overflowAmt:Vt=ee.height);const yr=p.useMemo(()=>({reposSubmenu:H,submenuCtx:V,overflow:m,overflowAmt:Ht,parentMenuRef:Ee,parentDir:de}),[H,V,m,Ht,de]),xr=Vt>=0?{maxHeight:Vt,overflow:m}:void 0,Bs=p.useMemo(()=>({state:k,align:f,dir:de}),[k,f,de]),_r=p.useMemo(()=>({dir:de}),[de]),br=nt({block:lt,element:ki,modifiers:_r,className:r.className}),Ps=o.jsxs("ul",{role:"menu","aria-label":s,...Jn(I),...Zt({onPointerEnter:Fe==null?void 0:Fe.off,onPointerMove:pr,onPointerLeave:gr,onKeyDown:hr,onAnimationEnd:mr},A),ref:Is(d,Ee),className:nt({block:lt,modifiers:Bs,className:e}),style:{...t,...xr,margin:0,display:k==="closed"?"none":void 0,position:fn,left:Z.x,top:Z.y},children:[n&&o.jsx("li",{"aria-hidden":!0,...r,className:br,style:{display:"block",position:fn,left:ue.x,top:ue.y,...r.style},ref:Os}),o.jsx(un.Provider,{value:yr,children:o.jsx(qn.Provider,{value:vr,children:o.jsx(Wn.Provider,{value:zt,children:he(j,Bs)})})})]});return c?o.jsx(Ii,{...c,isOpen:oe,children:Ps}):Ps},Yn=p.forwardRef(function({"aria-label":e,className:t,containerProps:n,initialMounted:r,unmountOnClose:a,transition:i,transitionTimeout:l,boundingBoxRef:c,boundingBoxPadding:d,reposition:u="auto",submenuOpenDelay:f=300,submenuCloseDelay:h=150,viewScroll:g="initial",portal:m,theming:x,onItemClick:y,...v},k){const w=p.useRef(null),I=p.useRef({}),{anchorRef:E,state:D,onClose:b}=v,j=p.useMemo(()=>({initialMounted:r,unmountOnClose:a,transition:i,transitionTimeout:l,boundingBoxRef:c,boundingBoxPadding:d,rootMenuRef:w,rootAnchorRef:E,scrollNodesRef:I,reposition:u,viewScroll:g,submenuOpenDelay:f,submenuCloseDelay:h}),[r,a,i,l,E,c,d,u,g,f,h]),R=p.useMemo(()=>({handleClick(A,Z){A.stopPropagation||he(y,A);let z=A.keepOpen;z===void 0&&(z=Z&&A.key===xe.SPACE),z||he(b,{value:A.value,key:A.key,reason:mt.CLICK})},handleClose(A){he(b,{key:A,reason:mt.CLICK})}}),[y,b]);if(!D)return null;const N=o.jsx(Es.Provider,{value:j,children:o.jsx(Xn.Provider,{value:R,children:o.jsx(Fi,{...v,ariaLabel:e||"Menu",externalRef:k,containerRef:w,containerProps:{className:t,containerRef:w,containerProps:n,theming:x,transition:i,onClose:b}})})});return m===!0&&typeof document<"u"?St.createPortal(N,document.body):m?m.target?St.createPortal(N,m.target):m.stablePosition?null:N:N}),gs=0,vs=1,$t=2,Lt=3,Bt=4,Zi=5,Kn=6,zi=["preEnter","entering","entered","preExit","exiting","exited","unmounted"],Qn=s=>({_s:s,status:zi[s],isEnter:s<Lt,isMounted:s!==Kn,isResolved:s===$t||s>Bt}),ys=s=>s?Kn:Zi,Vi=(s,e)=>{switch(s){case vs:case gs:return $t;case Bt:case Lt:return ys(e)}},Hi=s=>typeof s=="object"?[s.enter,s.exit]:[s,s],Ui=(s,e)=>setTimeout(()=>{isNaN(document.body.offsetTop)||s(e+1)},0),gn=(s,e,t,n,r)=>{clearTimeout(n.current);const a=Qn(s);e(a),t.current=a,r&&r({current:a})},Ji=({enter:s=!0,exit:e=!0,preEnter:t,preExit:n,timeout:r,initialEntered:a,mountOnEnter:i,unmountOnExit:l,onStateChange:c}={})=>{const[d,u]=p.useState(()=>Qn(a?$t:ys(i))),f=p.useRef(d),h=p.useRef(),[g,m]=Hi(r),x=p.useCallback(()=>{const v=Vi(f.current._s,l);v&&gn(v,u,f,h,c)},[c,l]),y=p.useCallback(v=>{const k=I=>{switch(gn(I,u,f,h,c),I){case vs:g>=0&&(h.current=setTimeout(x,g));break;case Bt:m>=0&&(h.current=setTimeout(x,m));break;case gs:case Lt:h.current=Ui(k,I);break}},w=f.current.isEnter;typeof v!="boolean"&&(v=!w),v?!w&&k(s?t?gs:vs:$t):w&&k(e?n?Lt:Bt:ys(l))},[x,c,s,e,t,n,g,m,l]);return[d,y,x]},er=({initialOpen:s,initialMounted:e,unmountOnClose:t,transition:n,transitionTimeout:r=500,onMenuChange:a}={})=>{const i=ht(n,"open"),l=ht(n,"close"),[{status:c},d,u]=Ji({initialEntered:s,mountOnEnter:!e,unmountOnExit:t,timeout:r,enter:i,exit:l,onStateChange:p.useCallback(({current:{isEnter:f,isResolved:h}})=>{!a||f&&i&&h||!f&&l&&h||a({open:f})},[a,i,l])});return[{state:Si[c],endTransition:u},d]},Wi=s=>{const[e,t]=er(s),[n,r]=p.useState(),a=(i,l)=>{r({position:i,alwaysUpdate:l}),t(!0)};return[{menuItemFocus:n,...e},t,a]},qi=(s,e)=>{const[t]=p.useState({});return{onMouseDown:()=>{t.v=s&&s!=="closed"},onClick:n=>t.v?t.v=!1:e(!0,n)}},Xi=parseInt(p.version)<19,Gi=p.forwardRef(function({"aria-label":e,captureFocus:t,initialOpen:n,menuButton:r,instanceRef:a,onMenuChange:i,...l},c){const[d,u,f]=Wi({...l,onMenuChange:i}),{state:h}=d,g=Hn(h),m=p.useRef(null),x=qi(h,(E,D)=>f(D.detail?void 0:ct.FIRST)),y=p.useCallback(E=>{u(!1),E.key&&m.current.focus()},[u]),v=E=>{switch(E.key){case xe.UP:f(ct.LAST);break;case xe.DOWN:f(ct.FIRST);break;default:return}E.preventDefault()},k=he(r,{open:g});if(!k||!k.type)throw new Error("Menu requires a menuButton prop.");const w={...Zt({onKeyDown:v,...x},k.props),ref:Is(Xi?k.ref:k.props.ref,m)};yi(k.type)==="MenuButton"&&(w.isOpen=g);const I=p.cloneElement(k,w);return p.useImperativeHandle(a,()=>({openMenu:f,closeMenu:()=>u(!1)})),o.jsxs(p.Fragment,{children:[I,o.jsx(Yn,{...l,...d,"aria-label":e||(typeof k.props.children=="string"?k.props.children:"Menu"),anch
1orRef:m,ref:c,onClose:y})]})}),Yi=(s,e)=>{const t=p.memo(e),n=p.forwardRef((r,a)=>{const i=p.useRef(null);return o.jsx(t,{...r,itemRef:i,externalRef:a,isHovering:p.useContext(Wn)===i.current})});return n.displayName=`WithHovering(${s})`,n},Ki=s=>{const[e,t]=p.useState(!1);return p.useEffect(()=>{!s&&t(!1)},[s]),[e,()=>!e&&t(!0),()=>t(!1)]},Qi=(s,e,t)=>{jt(()=>{if(s)return;const n=e.current;return t(n,!0),()=>{t(n)}},[s,e,t])},eo=(s,e,t,n)=>{const[r,a,i]=Ki(t),{submenuCloseDelay:l}=p.useContext(Es),{isParentOpen:c,submenuCtx:d,dispatch:u,updateItems:f}=p.useContext(qn),h=()=>{!t&&!n&&u(W.SET,s.current)},g=()=>{!n&&u(W.UNSET,s.current)},m=v=>{t&&!v.currentTarget.contains(v.relatedTarget)&&g()},x=v=>{n||(v.stopPropagation(),a(),d.on(l,h,h))},y=(v,k)=>{i(),d.off(),!k&&g()};return Qi(n,s,f),p.useEffect(()=>{t&&c&&e.current&&e.current.focus()},[e,t,c]),{mouseOver:r,setHover:h,onBlur:m,onPointerMove:x,onPointerLeave:y}},Ze=Yi("MenuItem",function({className:e,value:t,href:n,type:r,checked:a,disabled:i,children:l,onClick:c,isHovering:d,itemRef:u,externalRef:f,...h}){const g=!!i,{mouseOver:m,setHover:x,...y}=eo(u,u,d,g),v=p.useContext(Xn),k=p.useContext(ji),w=r==="radio",I=r==="checkbox",E=!!n&&!g&&!w&&!I,D=w?k.value===t:I?!!a:!1,b=Z=>{if(g){Z.stopPropagation(),Z.preventDefault();return}const z={value:t,syntheticEvent:Z};Z.key!==void 0&&(z.key=Z.key),I&&(z.checked=!D),w&&(z.name=k.name),he(c,z),w&&he(k.onRadioChange,z),v.handleClick(z,I||w)},j=Z=>{if(d)switch(Z.key){case xe.ENTER:Z.preventDefault();case xe.SPACE:E?u.current.click():b(Z)}},R=p.useMemo(()=>({type:r,disabled:g,hover:m||d,checked:D,anchor:E}),[r,g,m,d,D,E]),N=Zt({...y,onPointerDown:x,onKeyDown:j,onClick:b},h),A={role:w?"menuitemradio":I?"menuitemcheckbox":Ni,"aria-checked":w||I?D:void 0,...Jn(g,d),...N,ref:Is(f,u),className:nt({block:lt,element:Ti,modifiers:R,className:e}),children:p.useMemo(()=>he(l,R),[l,R])};return E?o.jsx("li",{role:Gn,children:o.jsx("a",{href:n,...A})}):o.jsx("li",{...A})}),to=p.memo(p.forwardRef(function({className:e,...t},n){return o.jsx("li",{role:Gn,...t,ref:n,className:nt({block:lt,element:Ci,className:e})})})),vn=()=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",children:o.jsx("g",{id:"z9nPJj.tif",children:o.jsx("path",{d:"M62,13.33V49.68c-.02,.05-.04,.11-.05,.16-.3,2.66-2.66,5.16-6.08,5.15-15.92,0-31.83,0-47.75-.01-.54,0-1.1-.06-1.62-.19-2.73-.69-4.52-3.09-4.52-5.88,0-12,.01-23.56,.01-34.9,0-.29,.01-.57,.05-.86,.35-2.3,1.62-3.91,3.84-4.75,.6-.23,1.27-.28,1.9-.41,16.13,0,32.27,0,48.4,0,.09,.01,.17,.04,.26,.04,2.66,.21,4.8,2.01,5.4,4.57,.06,.24,.1,.48,.14,.72ZM28.99,31.81c0-3.92-.01-7.91-.01-11.81H8c0,3.91,.01,7.9,.01,11.81H28.99Zm27,0c0-3.92-.01-7.92-.01-11.81h-20.97c0,3.92,.01,7.91,.01,11.81h20.97Zm-47.98,5.19c0,3.7,0,8,0,11.69v.31H29v-12m6.01,.04c0,3.93-.01,8.05-.01,11.96h20.99c0-.12,0-.22,0-.31,0-3.7,0-7.99,0-11.69"})})}),yn=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",children:[o.jsx("path",{d:"M31,8.04H7.62c-.61,.13-1.26,.18-1.84,.41-2.14,.84-3.37,2.45-3.71,4.75-.04,.28-.05,.57-.05,.86,0,11.32-.02,22.88-.01,34.87,0,2.79,1.73,5.18,4.37,5.88,.51,.13,1.04,.19,1.57,.19,7.69,0,15.38,0,23.07,0V8.04Zm-2.92,11.99c0,3.9,.01,7.89,.01,11.8H7.82c0-3.9-.01-7.89-.01-11.8H28.08ZM7.82,49.01v-.31c0-3.69,0-7.99,0-11.68H28.1v11.99H7.82Z"}),o.jsx("path",{d:"M58.67,7.9h-25.67V55h2.9c1.84,0,2.9-1.55,2.9-3.45V27.14h11.6v6.37c0,1.91,1.49,3.45,3.33,3.45h4.94c1.84,0,3.33-1.55,3.33-3.45V11.35c0-1.91-1.49-3.45-3.33-3.45Z"})]}),xn=()=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",children:o.jsx("path",{d:"M5.44,8H58.56c1.9,0,3.44,1.54,3.44,3.44v6.16s0,9.6,0,9.6v6.36c0,1.9-1.54,3.44-3.44,3.44h-5.11c-1.9,0-3.44-1.54-3.44-3.44v-6.36h-12s0,9.8,0,9.8v9s0,5.56,0,5.56c0,1.9-1.1,3.44-3,3.44h-6c-1.9,0-3-1.54-3-3.44v-5.56h-9c-1.99,0-3-1.52-3-3.4v-5.6H5.44c-1.9,0-3.44-1.74-3.44-3.64v-6.16s0-9.6,0-9.6v-6.16c0-1.9,1.54-3.44,3.44-3.44Z"})}),tr=({fill:s})=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",fill:s,children:[o.jsx("g",{id:"shape_squiggle",children:o.jsx("path",{d:"M60,38.42c-4.62,0-6.97-2.64-8.86-4.75-1.81-2.03-2.86-3.08-5.13-3.08s-3.32,1.06-5.13,3.08c-1.89,2.12-4.24,4.75-8.86,4.75s-6.97-2.64-8.87-4.75c-1.81-2.03-2.86-3.08-5.14-3.08s-3.33,1.06-5.14,3.08c-1.89,2.12-4.25,4.75-8.87,4.75-1.38,0-2.5-1.12-2.5-2.5s1.12-2.5,2.5-2.5c2.28,0,3.33-1.06,5.14-3.09,1.89-2.12,4.25-4.75,8.87-4.75s6.97,2.64,8.87,4.75c1.81,2.03,2.86,3.09,5.14,3.09s3.32-1.06,5.13-3.08c1.89-2.12,4.24-4.75,8.86-4.75s6.97,2.64,8.86,4.75c1.81,2.03,2.86,3.08,5.13,3.08,1.38,0,2.5,1.12,2.5,2.5s-1.12,2.5-2.5,2.5Z"})}),o.jsxs("g",{id:"Layer_4",children:[o.jsx("rect",{x:"2",y:"8",width:"60",height:"14",rx:"3.94",ry:"3.94"}),o.jsx("path",{d:"M58.06,41h-18.64c-1.58,0-3.14,.42-4.5,1.22l-6.88,4.02c-1.87,1.09-4.19,1.09-6.06,0l-6.88-4.02c-1.37-.8-2.92-1.22-4.5-1.22H5.94c-2.18,0-3.94,1.76-3.94,3.94v7.12c0,2.18,1.76,3.94,3.94,3.94H58.06c2.18,0,3.94-1.76,3.94-3.94v-7.12c0-2.18-1.76-3.94-3.94-3.94Z"})]})]}),sr=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",children:[o.jsx("g",{id:"ab_shape",children:o.jsxs("g",{children:[o.jsx("path",{d:"M16.71,41l-.42-2.45h-.16c-1.63,1.95-4.06,2.95-6.91,2.95-4.8,0-7.86-3.45-7.86-7.45,0-6.4,6.01-9.3,14.13-9.3v-.4c0-1.5-.84-3.2-4.38-3.2-2.48,0-4.9,.75-6.54,1.7l-1.42-4.75c1.69-.9,5.01-2.1,9.44-2.1,8.33,0,10.65,4.95,10.65,10.45v8.7c0,2.25,.11,4.4,.37,5.85h-6.91Zm-.95-11.7c-3.64,0-6.9
11,.9-6.91,4,0,2.1,1.37,3,3,3s3.22-1.05,3.74-2.6c.11-.35,.16-.8,.16-1.2v-3.2Z"}),o.jsx("path",{d:"M29.36,41c.11-1.79,.21-4.62,.21-7.25V6h7.7v13.46h.11c1.42-1.99,3.8-3.28,7.06-3.28,5.85,0,9.7,5.01,9.65,12.16,0,8.69-5.22,13.16-10.81,13.16-2.74,0-5.22-.99-6.91-3.72h-.11l-.37,3.23h-6.54Zm7.91-9.83c0,.55,.05,.99,.16,1.39,.58,1.94,2.16,3.18,4.01,3.18,3.11,0,4.9-2.53,4.9-7,0-3.92-1.58-6.8-4.9-6.8-1.85,0-3.53,1.39-3.95,3.28-.16,.4-.21,.94-.21,1.44v4.52Z"})]})}),o.jsx("g",{id:"arrows",children:o.jsx("polygon",{points:"62 54 52 45 52 51 35 51 35 57 52 57 52 63 62 54"})})]}),nr=()=>o.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 64 64",children:[o.jsx("g",{id:"yz_shape",children:o.jsxs("g",{children:[o.jsx("path",{d:"M22.75,13l3.43,12.39c.42,1.47,.84,3.2,1.16,4.52h.11c.32-1.32,.69-3.05,1-4.47l2.9-12.44h8.01l-5.8,17.16c-2.95,8.33-5.17,12.54-8.07,15.23-2.58,2.39-5.43,3.3-7.17,3.55l-1.85-6.3c1.11-.25,2.32-.76,3.48-1.52,1.16-.71,2.32-1.88,2.95-3.05,.26-.41,.42-.76,.42-1.12,0-.31-.05-.66-.26-1.17L14.32,13h8.43Z"}),o.jsx("path",{d:"M41.62,33.46l7.59-10.16c1.27-1.57,2.37-2.95,3.58-4.27v-.15h-10.33v-5.89h19.45l-.05,4.57-7.28,9.8c-1.21,1.57-2.48,3.15-3.69,4.42v.1h11.33v5.94h-20.61v-4.37Z"})]})}),o.jsx("g",{id:"arrows",children:o.jsx("polygon",{points:"12 51 12 45 2 54 12 63 12 57 29 57 29 51 12 51"})})]}),gt={name:"Default",goodColor:L.rgb(0,170,0),neutralColor:L.rgb(148,142,142),badColor:L.rgb(200,0,0),colors:[L.hsl(24,69,60),L.hsl(34,65,65),L.hsl(194,52,61),L.hsl(163,45,55),L.hsl(211,48,60),L.hsl(246,40,65),L.hsl(305,63,79),L.hsl(47,100,73),L.rgb(183,219,171),L.rgb(244,213,152),L.rgb(78,146,249),L.rgb(249,186,143),L.rgb(242,145,145),L.rgb(130,181,216),L.rgb(229,168,226),L.rgb(174,162,224),L.rgb(154,196,138),L.rgb(242,201,109),L.rgb(101,197,219),L.rgb(249,147,78),L.rgb(234,100,96),L.rgb(81,149,206),L.rgb(214,131,206),L.rgb(128,110,183)]},so={...gt,name:"Color Blind",goodColor:L.rgb(26,133,255),neutralColor:L.rgb(148,142,142),badColor:L.rgb(220,50,32)};function no(){return o.jsxs("svg",{id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 30 30",children:[o.jsx("defs",{}),o.jsx("path",{style:{fill:"#7d7d7f"},d:"M24,19.56c0,5.22-3.54,9.44-7.92,9.44h-3.17c-4.37,0-7.92-4.23-7.92-9.44v-7.56H24v7.56Z"}),o.jsx("path",{style:{fill:"#7d7d7f"},d:"M15,1h.82c4.52,0,8.18,3.73,8.18,8.33v1.67H15V1Z"}),o.jsx("path",{d:"M13.18,1h.82V11H5v-1.67c0-4.6,3.66-8.33,8.18-8.33Z"})]})}function ro(){return o.jsxs("svg",{id:"Layer_1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 30 30",children:[o.jsx("defs",{}),o.jsx("path",{style:{fill:"#7d7d7f"},d:"M5,19.56c0,5.22,3.54,9.44,7.92,9.44h3.17c4.37,0,7.92-4.23,7.92-9.44v-7.56H5v7.56Z"}),o.jsx("path",{style:{fill:"#7d7d7f"},d:"M14,1h-.82c-4.52,0-8.18,3.73-8.18,8.33v1.67H14V1Z"}),o.jsx("path",{d:"M15.82,1h-.82V11h9v-1.67c0-4.6-3.66-8.33-8.18-8.33Z"})]})}const ao="_tooltip_q2z2b_1",io="_flamegraphDiffTooltip_q2z2b_13",oo="_tooltipName_q2z2b_16",lo="_functionName_q2z2b_28",co="_tooltipTable_q2z2b_34",uo="_clickInfo_q2z2b_46",Ve={tooltip:ao,flamegraphDiffTooltip:io,tooltipName:oo,functionName:lo,tooltipTable:co,clickInfo:uo};function rr({shouldShowFooter:s=!0,shouldShowTitle:e=!0,dataSourceRef:t,clickInfoSide:n,setTooltipContent:r}){const a=p.useRef(null),[i,l]=X.useState({title:{text:"",diff:{text:"",color:""}},tooltipData:[]}),[c,d]=p.useState(),u=()=>{d({visibility:"hidden"}),l({title:{text:"",diff:{text:"",color:""}},tooltipData:[]})},f=p.useCallback(h=>{if(!(a!=null&&a.current))throw new Error("Missing tooltipElement");const g=Math.min(h.clientX+12,window.innerWidth-a.current.clientWidth-20),x={top:h.clientY+20,left:g,visibility:"visible"};r(l,u,h),d(x)},[a,r]);return p.useEffect(()=>{const h=t.current;return h?(h.addEventListener("mousemove",f),h.addEventListener("mouseout",u),()=>{h.removeEventListener("mousemove",f),h.removeEventListener("mouseout",u)}):()=>{}},[f,t]),o.jsx("div",{"data-testid":"tooltip",className:le(Ve.tooltip,{[Ve.flamegraphDiffTooltip]:i.tooltipData.length>1}),style:c,ref:a,children:i.tooltipData.length>0&&o.jsxs(En,{bordered:!0,children:[e&&o.jsx("div",{className:Ve.tooltipName,"data-testid":"tooltip-title",children:i.title.text}),o.jsx("div",{className:Ve.functionName,"data-testid":"tooltip-function-name",children:i.title.text}),i.title.diff.text.length>0?o.jsx(bn,{data:i.tooltipData,diff:i.title.diff}):o.jsx(bn,{data:i.tooltipData}),s&&o.jsx(fo,{clickInfoSide:n})]})})}const _n={objects:{percent:"% of objects in RAM",formattedValue:"Objects in RAM",total:"% of total RAM"},goroutines:{percent:"% of goroutines",formattedValue:"Goroutines",total:"% of total goroutines"},bytes:{percent:"% of RAM",formattedValue:"RAM",total:"% of total bytes"},samples:{percent:"Share of CPU",formattedValue:"CPU Time",total:"% of total CPU"},lock_nanoseconds:{percent:"% of Time spent",formattedValue:"Time",total:"% of total seconds"},nanoseconds:{percent:"% of Time spent",formattedValue:"Time",total:"% of total seconds"},lock_samples:{percent:"% of contended locks",formattedValue:"Contended locks",total:"% of total locks"},trace_samples:{percent:"% of time",formattedValue:"Samples",total:"% of total samples"},exceptions:{percent:"% of thrown exceptions",formattedValue:"Thrown exceptions",total:"% of total thrown exceptions"},unknown:{percent:"Percentage",formattedValue:"Units",total:"% of total units"}};function bn({data:s,diff:e}){const[t,n]=s;if(!t)return null;const r=_n[t.units]||_n.unknown;let a;switch(t.tooltipType){case"flamegraph":a=()=>o.jsxs(o.Fragment,{children:[n&&o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{}),o.jsx("th",{children:"Baseline"}),o.jsx("th",{children:"Comparison"}),o.jsx("th",{children:"Diff"})]})}),o.jsxs("tbody",{children:[o.jsxs("tr",{children:[o.jsx("td",{children:r.percent}),o.jsx("td",{children:t.percent}),n&&o.jsxs(o.Fragment,{children:[o.jsx("td",{children:n.percent}),o.jsx("td",{children:e&&o.jsx("span",{"data-testid":"tooltip-diff",style:{color:e.color},children:e.text})})]})]}),o.jsxs("tr",{children:[o.jsx("td",{children:r.formattedValue}),o.jsx("td",{children:t.formattedValue}),n&&o.jsxs(o.Fragment,{children:[o.jsx("td",{children:n.formattedValue}),o.jsx("td",{})]})]}),o.jsxs("tr",{children:[o.jsx("td",{children:"Samples:"}),o.jsx("td",{children:t.samples}),n&&o.jsxs(o.Fragment,{children:[o.jsx("td",{children:n.samples}),o.jsx("td",{})]})]})]})]});break;case"table":a=()=>o.jsxs(o.Fragment,{children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("td",{}),o.jsxs("td",{children:["Self (",r.total,")"]}),o.jsxs("td",{children:["Total (",r.total,")"]})]})}),o.jsx("tbody",{children:o.jsxs("tr",{children:[o.jsx("td",{children:r.formattedValue}),o.jsx("td",{children:t.self}),o.jsx("td",{children:t.total})]})})]});break;default:a=()=>null}return o.jsx("table",{"data-testid":"tooltip-table",className:le(Ve.tooltipTable,{[Ve[`${t.tooltipType}${n?"Diff":""}`]]:t.tooltipType}),children:a()})}function fo({clickInfoSide:s}){let e;switch(s){case"right":e=o.jsxs(o.Fragment,{children:[o.jsx(ro,{}),o.jsx("span",{children:"Right click for more node viewing options"})]});break;case"left":e=o.jsxs(o.Fragment,{children:[o.jsx(no,{}),o.jsx("span",{children:"Click to highlight node in flamegraph"})]});break;default:e=o.jsx(o.Fragment,{})}return o.jsx("div",{"data-testid":"tooltip-footer",className:Ve.clickInfo,children:e})}function ho(s){const{format:e,canvasRef:t,xyToData:n,numTicks:r,sampleRate:a,units:i,leftTicks:l,rightTicks:c,palette:d}=s,u=p.useCallback((f,h,g)=>{const m=Ft(r,a,i),x=n(g.offsetX,g.offsetY);let y;if(x.isJust)y=x.value;else{h();return}switch(y.format){case"single":{const v={percent:Bn(y.total/r),samples:i==="trace_samples"?"":hs(y.total),units:i,formattedValue:m.format(y.total,a),tooltipType:"flamegraph"};
1f({title:{text:y.name,diff:{text:"",color:""}},tooltipData:[v]});break}case"double":{if(e==="single")throw new Error("props format is 'single' but it has been mapped to 'double'");const v=ar({formatter:m,sampleRate:a,totalLeft:y.totalLeft,leftTicks:l,totalRight:y.totalRight,rightTicks:c,title:y.name,units:i},d);f({title:v.title,tooltipData:v.tooltipData});break}default:throw new Error("Unsupported format:'")}},[r,a,i,l,c,d,e,n]);return o.jsx(rr,{dataSourceRef:t,clickInfoSide:"right",setTooltipContent:u,shouldShowFooter:!1})}function ar({formatter:s,sampleRate:e,totalLeft:t,leftTicks:n,totalRight:r,rightTicks:a,title:i,units:l},c=gt){const d=t/n,u=r/a,f=ve(d),h=ve(u),g={percent:`${f}%`,samples:hs(t),units:l,formattedValue:s.format(t,e),tooltipType:"flamegraph"},m={percent:`${h}%`,samples:hs(r),units:l,formattedValue:s.format(r,e),tooltipType:"flamegraph"},x=Ct(f,h);let y="";x>0?y=c.badColor.rgb().string():x<0&&(y=c.goodColor.rgb().string());let v="";return t?r?x>0?v=`(+${x.toFixed(2)}%)`:x<0&&(v=`(${x.toFixed(2)}%)`):v="(removed)":v="(new)",{title:{text:i,diff:{text:v,color:y}},tooltipData:[g,m]}}const mo="_dummy_re4qb_1",po={dummy:mo};function go(s){const[e,t]=er({transition:!0}),[n,r]=X.useState({x:0,y:0}),{canvasRef:a}=s,[i,l]=X.useState([]),{xyToMenuItems:c,onClose:d,onOpen:u}=s,f=()=>{t(!1),d()};return X.useEffect(()=>{t(!1);const h=a.current;if(!h)return()=>{};const g=m=>{m.preventDefault();const x=c(m.offsetX,m.offsetY);l(x);const y=m.clientX,v=m.clientY+20;r({x:y,y:v}),t(!0),u(m.offsetX,m.offsetY)};return h.addEventListener("contextmenu",g),()=>{h.removeEventListener("contextmenu",g)}},[c,a,u,t]),o.jsx(Yn,{...e,className:po.dummy,anchorPoint:n,onClose:f,children:i})}const vo="_highlightContextMenu_1sh5b_1",yo={highlightContextMenu:vo},wn={height:"0px",visibility:"hidden"};function xo(s){const{node:e,barHeight:t}=s,[n,r]=X.useState(wn);return X.useEffect(()=>{e.match({Nothing:()=>r(wn),Just:a=>r({visibility:"visible",height:`${t}px`,...a})})},[e,t]),o.jsx("div",{className:yo.highlightContextMenu,style:n,"data-testid":"flamegraph-highlight-contextmenu"})}const _o="_flamegraphHeader_1dznv_1",bo="_row_1dznv_18",wo="_flamegraphTitle_1dznv_23",Kt={flamegraphHeader:_o,row:bo,flamegraphTitle:wo},Qt={"flamegraph-legend":"_flamegraph-legend_10e9h_1","flamegraph-legend-list":"_flamegraph-legend-list_10e9h_8","flamegraph-legend-item":"_flamegraph-legend-item_10e9h_13"};function kn(s){const{palette:e,showMode:t}=s,n=ko(t),r=Zn(e);return o.jsx("div",{"data-testid":"flamegraph-legend",className:`${Qt["flamegraph-legend"]} ${Qt["flamegraph-legend-list"]}`,children:n.map(a=>o.jsxs("div",{className:Qt["flamegraph-legend-item"],style:{backgroundColor:r(a).rgb().toString()},children:[a>0?"+":"",a,"%"]},a))})}function ko(s){switch(s){case"large":return[-100,-80,-60,-40,-20,-10,0,10,20,40,60,80,100];case"small":return[-100,-40,-20,0,20,40,100];default:throw new Error(`Unsupported ${s}`)}}function To(){return o.jsx("svg",{version:"1.1",id:"Capa_1",xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"12px",height:"12px",viewBox:"0 0 405.272 405.272",children:o.jsx("g",{children:o.jsx("path",{d:`M393.401,124.425L179.603,338.208c-15.832,15.835-41.514,15.835-57.361,0L11.878,227.836 2 3 c-15.838-15.835-15.838-41.52,0-57.358c15.841-15.841,41.521-15.841,57.355-0.006l81.698,81.699L336.037,67.064 4 5 c15.841-15.841,41.523-15.829,57.358,0C409.23,82.902,409.23,108.578,393.401,124.425z`})})})}const Co="_dropdownMenu_u39u8_3",jo="_dropdownMenuButton_u39u8_36",xs={dropdownMenu:Co,dropdownMenuButton:jo};function So({id:s,children:e,className:t,disabled:n,value:r,label:a,onItemClick:i,overflow:l,position:c,direction:d,align:u,viewScroll:f,arrow:h,offsetX:g,offsetY:m,menuButtonClassName:x="",ariaLabel:y,portal:v,...k}){const w=k.menuButton||o.jsx(ir,{"aria-label":y,className:`${xs.dropdownMenuButton} ${x}`,disabled:n,type:"button",children:r||a});return o.jsxs(Gi,{id:s,"aria-label":y,className:le(t,xs.dropdownMenu),"data-testid":k["data-testid"],onItemClick:i,overflow:l,position:c,direction:d,align:u,viewScroll:f,arrow:h,menuButton:w,portal:v,children:[o.jsx(to,{children:a}),e]})}const No=Ze,ir=Ei,Eo="_diffPaletteDropdown_tr94g_1",Io="_dropdownWrapper_tr94g_8",Ro="_dropdownItem_tr94g_23",Mo="_row_tr94g_33",kt={diffPaletteDropdown:Eo,dropdownWrapper:Io,dropdownItem:Ro,row:Mo},Oo=[gt,so],Do=s=>
5{const{palette:e=gt,onChange:t}=s,n=X.useRef(null),r=$o(n);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:kt.row,role:"heading","aria-level":2,children:[o.jsx("p",{style:{color:e.goodColor.rgb().string()},children:"(-) Removed"}),o.jsx("p",{style:{color:e.badColor.rgb().string()},children:"Added (+)"})]}),o.jsx("div",{ref:n,className:kt.dropdownWrapper,children:o.jsx(So,{label:"Select a palette",align:"end",menuButton:o.jsx(ir,{className:le(xs.dropdownMenuButton,kt.diffPaletteDropdown),children:o.jsx(kn,{palette:e,showMode:r})}),onItemClick:a=>t(a.value),children:Oo.map(a=>o.jsx(No,{value:a,children:o.jsxs("div",{children:[o.jsx("label",{children:a.name}),o.jsxs("div",{className:kt.dropdownItem,children:[o.jsx(kn,{palette:a,showMode:r}),a===e?o.jsx(To,{}):null]})]})},a.name))})})]})},Ao=13*37,$o=s=>{const[e,t]=X.useState("large"),n=a=>a<Ao?"small":"large",r=s.current;return X.useLayoutEffect(()=>{if(r){const{width:a}=r.getBoundingClientRect();t(n(a))}},[r]),Ns(s,a=>{t(n(a.contentRect.width))}),e},Tn=new Map(Object.entries({objects:"number of objects in RAM per function",goroutines:"number of goroutines",bytes:"amount of RAM per function",samples:"CPU time per function",lock_nanoseconds:"time spent waiting on locks per function",lock_samples:"number of contended locks per function",trace_samples:"aggregated span duration",exceptions:"number of exceptions thrown",unknown:""}));function Lo(s){const{format:e,units:t,palette:n,setPalette:r,toolbarVisible:a}=s,l=a?(()=>{switch(e){case"single":return o.jsx("div",{children:o.jsx("div",{className:`${Kt.row} ${Kt.flamegraphTitle}`,role:"heading","aria-level":2,children:Tn.has(t)&&o.jsxs(o.Fragment,{children:["Frame width represents ",Tn.get(t)]})})});case"double":return o.jsx(o.Fragment,{children:o.jsx(Do,{palette:n,onChange:r})});default:throw new Error(`unexpected format ${e}`)}})():null;return o.jsx("div",{className:Kt.flamegraphHeader,children:o.jsx("div",{children:l})})}const Bo="_highlight_efyyb_1",Po={highlight:Bo};function Fo(s){const{canvasRef:e,barHeight:t,xyToHighlightData:n,zoom:r}=s,[a,i]=X.useState({height:"0px",visibility:"hidden"});X.useEffect(()=>{i({height:"0px",visibility:"hidden"})},[r]);const l=p.useCallback(()=>{i({...a,visibility:"hidden"})},[i,a]),c=p.useCallback(u=>{const f=n(u.offsetX,u.offsetY);if(f.isJust){const h=f.value;i({visibility:"visible",height:`${t}px`,...h})}else l()},[i,l,t,n]),d=e.current;return X.useEffect(()=>d?(d.addEventListener("mousemove",c),d.addEventListener("mouseout",l),()=>{d.removeEventListener("mousemove",c),d.removeEventListener("mouseout",l)}):()=>{},[d,c,l]),o.jsx("div",{className:Po.highlight,style:a,"data-testid":"flamegraph-highlight"})}const Zo="_logoLink_1m4nn_1",zo={logoLink:Zo};function Vo(){return o.jsxs("svg",{width:"22px",height:"22px",viewBox:"0 0 1024 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:[o.jsx("defs",{children:o.jsxs("radialGradient",{cx:"49.4236252%",cy:"92.6627823%",fx:"49.4236252%",fy:"92.6627823%",r:"195.066755%",gradientTransform:"translate(0.494236,0.926628),scale(1.000000,0.735610),rotate(-90.000000),translate(-0.494236,-0.926628)",id:"radialGradient-1",children:[o.jsx("stop",{stopColor:"#FFB90C",offset:"0%"}),o.jsx("stop",{stopColor:"#F9243A",offset:"38.390924%"}),o.jsx("stop",{stopColor:"#F9243A",offset:"50.5405%"}),o.jsx("stop",{stopColor:"#B51424",offset:"73.98091%"}),o.jsx("stop",{stopColor:"#B51424",offset:"100%"})]})}),o.jsx("g",{id:"Artboard",stroke:"none",strokeWidth:"1",fill:"none",fillRule:"evenodd",children:o.jsx("g",{id:"fire-part",transform:"translate(148.516736, 0.000000)",fillRule:"nonzero",children:o.jsxs("g",{id:"whole-thing",transform:"translate(363.983264, 495.000000) scale(-1, 1) rotate(-180.000000) translate(-363.983264, -495.000000) translate(0.483264, 0.000000)",children:[o.jsx("g",{id:"g70",transform:"translate(-0.000091, 0.685815)",fill:"url(#radialGradient-1)",children:o.jsx("path",{d:"M65.3646667,571.739321 L65.4492471,571.698868 C19.5139147,505.999969 -5.32464048,424.477859 1.04305801,336.877516 L1.04305801,336.877516 C14.0321963,158.179446 159.192462,13.7596653 338.059844,1.5917266 L338.059844,1.5917266 C419.418369,-3.93888015 495.500283,17.3823334 558.456522,57.4611191 L558.456522,57.4611191 L481.301947,162.097965 C437.516468,136.521928 399.367671,129.590556 363.486536,130.155994 L363.486536,130.155994 C234.497143,130.155994 129.556988,235.032238 129.556988,363.946998 L129.556988,363.946998 C129.556988,492.865683 234.497143,597.738003 363.486536,597.738003 L363.486536,597.738003 C492.483783,597.738003 597.427864,492.865683 597.427864,363.946998 L597.427864,363.946998 C597.41276,304.634864 581.39383,25
55.677522 530.630465,199.668053 L607.770843,95.1329436 C680.936847,161.576603 726.932594,257.364176 726.932594,363.946998 L726.932594,363.946998 C726.932594,458.031616 691.13483,543.75602 632.416071,608.271816 L632.416071,608.271816 L632.416071,608.275741 L533.597728,748.122808 L428.601388,617.203806 L434.703262,646.563419 C459.453008,765.59222 433.664131,889.543925 363.49439,988.853335 L363.49439,988.853335 L65.3646667,571.723019 L65.3646667,571.739321 Z",id:"path84"})}),o.jsx("g",{id:"blue",transform:"translate(191.447039, 191.331780)",children:o.jsxs("g",{id:"g88",transform:"translate(-0.000063, 0.685930)",children:[o.jsx("g",{id:"g94",transform:"translate(0.177296, 0.699054)",fill:"#3EC1D3",children:o.jsx("path",{d:"M171.862466,343.697728 C77.0961324,343.697728 -0.00497405932,266.647602 -0.00497405932,171.934957 C-0.00497405932,77.2182874 77.0961324,0.168162396 171.862466,0.168162396 C266.632828,0.168162396 343.741988,77.2182874 343.741988,171.934957 C343.741988,266.647602 266.632828,343.697728 171.862466,343.697728",id:"path96"})}),o.jsx("g",{id:"g98",transform:"translate(29.362379, 172.629585)",fill:"#FFFFFF",children:o.jsx("path",{d:"M22.8397982,0 L0.671669409,0 C0.671669409,78.2496309 64.380874,141.920035 142.678189,141.920035 L142.678189,119.765407 C76.6007327,119.765407 22.8397982,66.0372141 22.8397982,0",id:"path100"})})]})})]})})})]})}function Ho(){return o.jsxs("a",{className:zo.logoLink,href:"https://github.com/pyroscope-io/pyroscope/",target:"_blank",rel:"noreferrer",children:[Vo(),o.jsx("span",{children:"Pyroscope"})]})}const Uo="_flamegraphPane_1j7oo_1",Jo="_fitModeItem_1j7oo_5",Wo="_sandwichItem_1j7oo_6",es={flamegraphPane:Uo,fitModeItem:Jo,sandwichItem:Wo};function Cn(s){const e=X.useRef(null),t=p.useRef(),[n,r]=X.useState(q.nothing()),{flamebearer:a,focusedNode:i,fitMode:l,updateFitMode:c,highlightQuery:d,zoom:u,toolbarVisible:f,headerVisible:h=!0,disableClick:g=!1,showSingleLevel:m=!1,showCredit:x,setActiveItem:y,selectedItem:v,updateView:k}=s,{onZoom:w,onReset:I,isDirty:E,onFocusOnNode:D}=s,{"data-testid":b}=s,{palette:j,setPalette:R}=s,N=p.useCallback(()=>{var V,H,te;(V=e.current)==null||V.setAttribute("data-state","rendering"),(H=t.current)==null||H.render(),(te=e.current)==null||te.setAttribute("data-state","rendered")},[e,t]),A=p.useCallback(()=>{qr(()=>{N()})},[N]);Ns(e.current,()=>{t.current&&A()});const Z=p.useCallback(V=>{if(!t.current)return;const H=t.current.xyToBar(V.nativeEvent.offsetX,V.nativeEvent.offsetY);H.match({Nothing:()=>{},Just:te=>{u.match({Nothing:()=>{w(H)},Just:ae=>{te.i===ae.i&&te.j===ae.j?w(q.nothing()):w(H)}})}})},[t,u,w]),z=p.useCallback((V,H)=>{const te=e==null?void 0:e.current;return!t.current||!te?q.nothing():t.current.xyToBar(V,H).map(ie=>({left:te.offsetLeft+ie.x,top:te.offsetTop+ie.y,width:ie.width}))},[t,e]),ue=p.useCallback((V,H)=>t.current?t.current.xyToBar(V,H):null,[t]),Ce=p.useCallback(()=>{r(q.nothing())},[r]),ee=p.useCallback((V,H)=>{r(z(V,H))},[r,z]),ce=p.useCallback((V,H)=>{if(!t.current)throw new Error("Flamegraph not available");const te=E(),ae=t.current.xyToBar(V,H),ie=ae.isJust?ae.value.name:"",Xe=()=>{const ne=ae.mapOrElse(()=>!1,()=>!0),Pe=ae.mapOrElse(()=>()=>{},Fe=>D.bind(null,Fe.i,Fe.j));return o.jsxs(Ze,{disabled:!ne,onClick:Pe,children:[o.jsx(Pr,{}),"Collapse nodes above"]},"focus")},Le=()=>{const ne=()=>{navigator.clipboard&&navigator.clipboard.writeText(ie)};return o.jsxs(Ze,{onClick:ne,children:[o.jsx(Xr,{}),"Copy function name"]},"copy")},Be=()=>{const ne=()=>{y({name:ie})},Pe=v.isJust&&v.value===ie?"Clear highlight":"Highlight similar nodes";return o.jsxs(Ze,{onClick:ne,children:[o.jsx(Gr,{}),Pe]},"highlight-similar-nodes")},Ge=()=>{if(!k)return null;const ne=()=>{k&&(k("sandwich"),y({name:ie}))};return o.jsxs(Ze,{className:es.sandwichItem,onClick:ne,children:[o.jsx(tr,{fill:"black"}),"Open in sandwich view"]},"open-in-sandwich-view")},Ye=()=>{const ne=l===At,Pe=()=>{c(ne?Ss:At)};return o.jsxs(Ze,{className:es.fitModeItem,onClick:Pe,children:[ne?o.jsx(nr,{}):o.jsx(sr,{}),"Show text ",ne?"tail first":"head first"]},"fit-mode")};return[o.jsxs(Ze,{disabled:!te,onClick:I,children:[o.jsx(Vr,{}),"Reset View"]}
5,"reset"),Xe(),Le(),Be(),Ge(),Ye()].filter(Boolean)},[v,l,E,D,I,y,c,k,t]);X.useEffect(()=>{const V=e==null?void 0:e.current;if(V){const H=new li(a,V,i,l,d,u,j);t.current=H}N()},[e,j,a,i,l,d,u,N]);const de=!a||a&&a.names.length<=1,$e=p.useMemo(()=>o.jsx("canvas",{height:"0","data-testid":"flamegraph-canvas","data-highlightquery":d,className:le("flamegraph-canvas","canvas"),ref:e,onClick:g?void 0:Z}),[e,g,Z,d]);return o.jsxs("div",{"data-testid":"flamegraph-view",className:le(es.flamegraphPane,{"vertical-orientation":a.format==="double"}),children:[h&&o.jsx(Lo,{format:a.format,units:a.units,palette:j,setPalette:R,toolbarVisible:f}),o.jsx("div",{"data-testid":b,style:{opacity:de&&!m?0:1},children:$e}),x?o.jsx(Ho,{}):"",t&&e&&o.jsx(Fo,{barHeight:We,canvasRef:e,zoom:u,xyToHighlightData:z}),t&&o.jsx(xo,{barHeight:We,node:n}),t&&o.jsx(ho,{format:a.format,canvasRef:e,xyToData:ue,numTicks:a.numTicks,sampleRate:a.sampleRate,leftTicks:a.format==="double"?a.leftTicks:0,rightTicks:a.format==="double"?a.rightTicks:0,units:a.units,palette:j}),!g&&t&&e&&o.jsx(go,{canvasRef:e,xyToMenuItems:ce,onClose:Ce,onOpen:ee})]})}const qo="_button_qvzwg_1",Xo="_noIcon_qvzwg_13",Go="_noBox_qvzwg_17",Yo="_customIcon_qvzwg_23",Ko="_outline_qvzwg_33",Qo="_float_qvzwg_33",el="_primary_qvzwg_44",tl="_secondary_qvzwg_57",sl="_danger_qvzwg_75",nl="_grouped_qvzwg_95",ye={button:qo,noIcon:Xo,noBox:Go,customIcon:Yo,default:"_default_qvzwg_33",outline:Ko,float:Qo,primary:el,secondary:tl,danger:sl,grouped:nl},qe=X.forwardRef(function({disabled:e=!1,kind:t="default",type:n="button",icon:r,iconNode:a,children:i,grouped:l,onClick:c,id:d,className:u,form:f,noBox:h,autoFocus:g,...m},x){return o.jsxs("button",{...m,id:d,ref:x,type:n,"data-testid":m["data-testid"],disabled:e,onClick:c,form:f,autoFocus:g,"aria-label":m["aria-label"],className:le(ye.button,l?ye.grouped:"",rl(t),u,h&&ye.noBox,a&&ye.customIcon,!r&&!a&&ye.noIcon),children:[r||null,a,i]})});function rl(s){switch(s){case"default":return ye.default;case"primary":return ye.primary;case"secondary":return ye.secondary;case"danger":return ye.danger;case"outline":return ye.outline;case"float":return ye.float;default:throw Error(`Unsupported kind ${s}`)}}const al="_table_1tdvc_1",il="_sortable_1tdvc_5",ol="_sortArrow_1tdvc_9",ll="_asc_1tdvc_17",cl="_desc_1tdvc_22",dl="_isRowSelected_1tdvc_37",ul="_isRowDisabled_1tdvc_42",fl="_loadingSpinner_1tdvc_57",hl="_pagination_1tdvc_62",Me={table:al,sortable:il,sortArrow:ol,asc:ll,desc:cl,isRowSelected:dl,isRowDisabled:ul,loadingSpinner:fl,pagination:hl},ml=s=>{const e=s.filter(l=>l==null?void 0:l.default)[0]||s[0],[t,n]=p.useState(e.name),[r,a]=p.useState("desc");return{sortBy:t,sortByDirection:r,updateSortParams:l=>{let c=r;t===l?c=c==="asc"?"desc":"asc":c="desc",n(l),a(c)}}};function pl({sortByDirection:s,sortBy:e,updateSortParams:t,table:n,tableBodyRef:r,className:a,isLoading:i,itemsPerPage:l,tableStyle:c}){const d=s&&e&&t,[u,f]=p.useState(0),h=Rn(In);return i?o.jsx("div",{className:Me.loadingSpinner,children:o.jsx(Nn,{})}):o.jsxs(ea,{children:[o.jsxs("table",{className:le(Me.table,{[a||""]:a}),"data-testid":"table-ui",style:c,children:[o.jsx("thead",{children:o.jsx("tr",{children:n.headRow.map(({sortable:g,label:m,name:x,...y},v)=>!g||n.type==="not-filled"||!d?o.jsx("th",{...y,children:m},v):p.createElement("th",{...y,key:v,className:Me.sortable,onClick:()=>t(x)},m,o.jsx("span",{className:le(Me.sortArrow,{[Me[s]]:e===x})})))})}),o.jsx("tbody",{ref:r,children:n.type==="not-filled"?o.jsx("tr",{className:n==null?void 0:n.bodyClassName,children:o.jsx("td",{colSpan:n.headRow.length,children:n.value})}):_s(n.bodyRows,u,l).map(({cells:g,isRowSelected:m,isRowDisabled:x,className:y,...v})=>{const k=Math.random();return o.jsx("tr",{...v,className:le(y,{[Me.isRowSelected]:m,[Me.isRowDisabled]:x}),children:g&&g.map(({style:w,value:I,...E},D)=>o.jsx("td",{style:{...w,color:h==="dark"?"#fff":"#343f4f"},...E,children:I},k+D))},k)})})]}),o.jsx(gl,{bodyRows:n.type==="filled"?n.bodyRows:void 0,itemsPerPage:l,currPage:u,setCurrPage:f})]})}function _s(s,e,t){return t?s.slice(e*t,t*(e+1)):s}function gl({itemsPerPage:s,currPage:e,setCurrPage:t,bodyRows:n}){if(!s)return null;const r=n?_s(n,e+1,s).length>0:!1,a=n?_s(n,e-1,s).length>0:!1;return o.jsxs("nav",{className:Me.pagination,children:[o.jsx(qe,{"aria-label":"Previous Page",disabled:!a,kind:"float",icon:o.jsx(Fr,{}),onClick:()=>t(e-1)}),o.jsx(qe,{disabled:!r,"aria-label":"Next Page",kind:"float",icon:o.jsx(ta,{}),onClick:()=>t(e+1)})]})}function vl({numTicks:s,sampleRate:e,units:t,tableBodyRef:n,palette:r}){const a=Ft(s,e,t),i=a.format(s,e),l=p.useCallback((c,d,u)=>{var x;const f=(x=u.target.closest("tr"))==null?void 0:x.dataset.row;if(!f){d();return}const[h,g,...m]=f.split(";");switch(h){case"single":{const[y,v]=m,k=a.format(parseInt(y,10),e),w=a.format(parseInt(v,10),e),I=i.split(" "),E=I[0]==="<"?I[1]:I[0],D=k.split(" "),b=D[0]==="<"?D[1]:D[0],j=w.split(" "),R=j[0]==="<"?j[1]:j[0],N={units:t,self:`${k}(${(parseFloat(b)/parseFloat(E)*100).toFixed(2)}%)`,total:`${w}(${(parseFloat(R)/parseFloat(E)*100).toFixed(2)}%)`,tooltipType:"table"};c({title:{text:g,diff:{text:"",color:""}},tooltipData:[N]});break}case"double":{const[y,v,k,w]=m,I=ar({formatter:a,sampleRate:e,totalLeft:parseInt(y,10),leftTicks:parseInt(v,10),totalRight:parseInt(k,10),rightTicks:parseInt(w,10),title:g,units:t},r);c({title:I.title,tooltipData:I.tooltipData});break}}},[a,e,r,i,t]);return o.jsx(rr,{dataSourceRef:n,shouldShowTitle:!0,clickInfoSide:"left",setTooltipContent:l,shouldShowFooter:!1})}const we=s=>s||0;function yl(s,e,t,n){const r=e;return r.type="single",r.self=we(r.self)+s.getBarSelf(t,n),r.total=we(r.total)+s.getBarTotal(t,n),r}function xl(s,e,t,n,r,a){const i=e;return i.type="double",i.self=we(i.self)+s.getBarSelf(t,n),i.total=we(i.total)+s.getBarTotal(t,n),i.selfLeft=we(i.selfLeft)+s.getBarSelfLeft(t,n),i.selfRght=we(i.selfRght)+s.getBarSelfRght(t,n),i.selfDiff=we(i.selfDiff)+s.getBarSelfDiff(t,n),i.totalLeft=we(i.totalLeft)+s.getBarTotalLeft(t,n),i.totalRght=we(i.totalRght)+s.getBarTotalRght(t,n),i.totalDiff=we(i.totalDiff)+s.getBarTotalDiff(t,n),i.leftTicks=r,i.rightTicks=a,i}function _l(s){const e=[];
5if(!s)return e;const{names:t,levels:n,format:r}=s,a=r!=="double"?Dt:ft,i=new Map;for(let l=0;l<n.length;l++){const c=n[l];for(let d=0;d<c.length;d+=a.jStep){const u=a.getBarName(c,d),f=t[u];i.has(f)||i.set(f,{name:f||"<empty>",self:0,total:0});const h=i.get(f);if(!h)break;r==="single"?yl(Dt,h,c,d):xl(ft,h,c,d,s.leftTicks,s.rightTicks)}}return Array.from(i.values())}function jn(s,e,t){const r=148-s/e*148,a=t.alpha(1);return{backgroundImage:`linear-gradient(${a}, ${a})`,backgroundPosition:`-${r}px 0px`,backgroundRepeat:"no-repeat"}}const bl=[{sortable:1,name:"name",label:"Location"},{sortable:1,name:"self",label:"Self",default:!0},{sortable:1,name:"total",label:"Total"}],wl=[{sortable:1,name:"name",label:"Location"},{sortable:1,name:"baseline",label:"Baseline",default:!0},{sortable:1,name:"comparison",label:"Comparison"},{sortable:1,name:"diff",label:"Diff"}];function kl({tableBodyRef:s,flamebearer:e,isDoubles:t,fitMode:n,handleTableItemClick:r,highlightQuery:a,selectedItem:i,palette:l}){const c=t?wl:bl,d=ml(c),u={headRow:c,...Tl({flamebearer:e,sortBy:d.sortBy,sortByDirection:d.sortByDirection,isDoubles:t,fitMode:n,handleTableItemClick:r,highlightQuery:a,palette:l,selectedItem:i})};return o.jsx(pl,{...d,tableBodyRef:s,table:u,className:le("flamegraph-table",{"flamegraph-table-doubles":t})})}const Tl=({flamebearer:s,sortBy:e,sortByDirection:t,isDoubles:n,fitMode:r,handleTableItemClick:a,highlightQuery:i,palette:l,selectedItem:c})=>{const{numTicks:d,maxSelf:u,sampleRate:f,spyName:h,units:g}=s,m=_l(s).sort((b,j)=>j.total-b.total),x=t==="asc"?1:-1;let y;if(e==="name")y=m.sort((b,j)=>x*b[e].localeCompare(j[e]));else switch(e){case"total":case"self":{y=m.sort((b,j)=>x*(b[e]-j[e]));break}case"baseline":{y=m.sort((b,j)=>x*(b.totalLeft/b.leftTicks-j.totalLeft/j.leftTicks));break}case"comparison":{y=m.sort((b,j)=>x*(b.totalRght/b.rightTicks-j.totalRght/j.rightTicks));break}case"diff":{y=m.sort((b,j)=>{const R=Ct(ve(b.totalLeft/b.leftTicks),ve(b.totalRght/b.rightTicks)),N=Ct(ve(j.totalLeft/j.leftTicks),ve(j.totalRght/j.rightTicks));return x*(R-N)});break}default:y=m;break}const v=Ft(d,f,g),k=b=>c.isJust?b===c.value:!1,w=(b,j)=>o.jsxs("button",{className:"table-item-button",children:[o.jsx("span",{className:"color-reference",style:j}),o.jsx("div",{className:"symbol-name",style:Ga(r),children:b.name})]}),I=(b,j,R)=>({"data-row":`${b.type};${b.name};${b.self};${b.total}`,isRowSelected:k(b.name),onClick:()=>a(b),cells:[{value:w(b,R)},{value:v.format(b.self,f),style:jn(b.self,u,j)},{value:v.format(b.total,f),style:jn(b.total,d,j)}]}),E=(b,j)=>{const R=ve(b.totalLeft/b.leftTicks),N=ve(b.totalRght/b.rightTicks),A=Ct(R,N);let Z="";A>0?Z=l.badColor.rgb().string():A<0&&(Z=l.goodColor.rgb().string());let z="";return!b.totalLeft||A===1/0?z="(new)":b.totalRght?A>0?z=`(+${A.toFixed(2)}%)`:A<0&&(z=`(${A.toFixed(2)}%)`):z="(removed)",{"data-row":`${b.type};${b.name};${b.totalLeft};${b.leftTicks};${b.totalRght};${b.rightTicks}`,isRowSelected:k(b.name),onClick:()=>a(b),cells:[{value:w(b,j)},{value:`${R} %`},{value:`${N} %`},{value:z,style:{color:Z}}]}},D=y.filter(b=>i?zn(i,b.name):!0).map(b=>{const j=Pn(h,b.name),R=n?Qa:Fn(l,j),N={backgroundColor:R.rgb().toString()};return b.type==="double"?E(b,N):I(b,R,N)});return D.length>0?{bodyRows:D,type:"filled"}:{value:o.jsx("div",{className:"unsupported-format",children:"No items found"}),type:"not-filled"}},Cl=X.memo(function({flamebearer:e,fitMode:t,handleTableItemClick:n,highlightQuery:r,palette:a,selectedItem:i}){const l=p.useRef(null);return o.jsxs("div",{"data-testid":"table-view",children:[o.jsx(kl,{tableBodyRef:l,flamebearer:e,isDoubles:e.format==="double",fitMode:t,highlightQuery:r,handleTableItemClick:n,palette:a,selectedItem:i}),o.jsx(vl,{tableBodyRef:l,numTicks:e.numTicks,sampleRate:e.sampleRate,units:e.units,palette:a})]})});var or={exports:{}};/*! 6 Copyright (c) 2018 Jed Watson. 7 Licensed under the MIT License (MIT), see 8 http://jedwatson.github.io/classnames 9*/(function(s){(function(){var e={}.hasOwnProperty;function t(){for(var a="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(a=r(a,n.call(this,l)))}return a}
9function n(a){if(typeof a=="string"||typeof a=="number")return this&&this[a]||a;if(typeof a!="object")return"";if(Array.isArray(a))return t.apply(this,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var i="";for(var l in a)e.call(a,l)&&a[l]&&(i=r(i,this&&this[l]||l));return i}function r(a,i){return i?a?a+" "+i:a+i:a}s.exports?(t.default=t,s.exports=t):window.classNames=t})()})(or);var jl=or.exports;const Sl=Nr(jl),lr=X.forwardRef(({className:s,type:e,placeholder:t,minLength:n=0,onChange:r,value:a,htmlId:i})=>o.jsx("div",{children:o.jsx(sa,{id:i||"",className:`input ${s||""}`,min:n,placeholder:t,type:e||"text",value:a,onChange:r})}));lr.displayName="Input";const Nl="_wrapper_18zkf_1",El="_search_18zkf_8",Il="_searchWithSync_18zkf_8",Rl="_sync_18zkf_49",Ml="_syncSelected_18zkf_49",Re={wrapper:Nl,search:El,"search-synced":"_search-synced_18zkf_8",searchWithSync:Il,sync:Rl,syncSelected:Ml},Ol=s=>{const e=p.useRef();return p.useEffect(()=>{e.current=s}),e.current},Dl=({onHighlightChange:s,highlightQuery:e,sharedQuery:t,width:n})=>{const r=Ol(t==null?void 0:t.syncEnabled),a=d=>{s(d),t!=null&&t.syncEnabled&&t.onQueryChange(d)};p.useEffect(()=>{typeof(t==null?void 0:t.searchQuery)=="string"&&(t.syncEnabled&&s(t.searchQuery),!t.syncEnabled&&r&&r!==(t==null?void 0:t.id)&&s(""))},[t==null?void 0:t.searchQuery,t==null?void 0:t.syncEnabled,t==null?void 0:t.id,s,r]);const i=()=>{const d=t!=null&&t.syncEnabled?!1:(t==null?void 0:t.id)||!1;t==null||t.toggleSync(d),d?t==null||t.onQueryChange(e):(s(e),t==null||t.onQueryChange(""))},l=p.useMemo(()=>t!=null&&t.syncEnabled?t.searchQuery||"":e,[t,e]),c=p.useMemo(()=>`${t?Re.searchWithSync:Re.search} ${t!=null&&t.syncEnabled?Re["search-synced"]:""}`,[t]);return o.jsxs("div",{className:Re.wrapper,style:{width:n},children:[o.jsx(lr,{testId:"flamegraph-search",className:c,type:"text",name:"flamegraph-search",placeholder:"Searchâ¦",minLength:2,debounceTimeout:100,onChange:a,value:l}),t?o.jsx(He,{content:t.syncEnabled?"Unsync search bars":"Sync search bars",children:o.jsx("button",{className:t.syncEnabled?Re.syncSelected:Re.sync,onClick:i,children:o.jsx(Yr,{className:`${t.syncEnabled?Re.syncSelected:Re.sync}`})})}):null]})},Al="_navbar_7hrcw_1",$l="_viewType_7hrcw_14",Ll="_toggleViewButton_7hrcw_24",Bl="_fitModeButton_7hrcw_24",Pl="_selected_7hrcw_40",Fl="_collapseNodeButton_7hrcw_50",Zl="_resetViewButton_7hrcw_50",zl="_divider_7hrcw_67",Vl="_itemsContainer_7hrcw_74",Hl="_item_7hrcw_74",Ul="_moreButton_7hrcw_79",Jl="_active_7hrcw_85",Wl="_navbarCollapsedItems_7hrcw_93",K={navbar:Al,viewType:$l,toggleViewButton:Ll,fitModeButton:Bl,selected:Pl,collapseNodeButton:Fl,resetViewButton:Zl,divider:zl,itemsContainer:Vl,item:Hl,moreButton:Ul,active:Jl,navbarCollapsedItems:Wl},Pt=Sl.bind(K),ts=5,bs=175,ql=2,Xl=2,it=40+ql+Xl,Gl=16,Sn=(s,e,t)=>{const n=e===0?s-bs-5:s-bs-Gl-5;let r=0,a=0;return t.reverse().forEach(i=>{a+=i,n<=a&&(r+=1)}),r},Yl=(s,e)=>{const[t,n]=p.useState(!0),[r,a]=p.useState(0),i=s.current;p.useLayoutEffect(()=>{if(i){const{width:c}=i.getBoundingClientRect(),d=Sn(c,r,e);a(d)}},[i,e,r]);const l=()=>{n(c=>!c)};return Ns(s,c=>{const{width:d}=c.target.getBoundingClientRect(),u=Sn(d,r,e);a(u),n(!0)}),{isCollapsed:t,handleMoreClick:l,collapsedItemsNumber:r}},ss=()=>o.jsx("div",{className:K.divider}),cr=p.memo(({view:s,handleSearchChange:e,highlightQuery:t,isFlamegraphDirty:n,reset:r,updateFitMode:a,fitMode:i,updateView:l,selectedNode:c,onFocusOnSubtree:d,flamegraphType:u,enableChangingDisplay:f=!0,sharedQuery:h,ExportData:g})=>{const m=p.useRef(null),x={el:o.jsxs(o.Fragment,{children:[o.jsx(ec,{fitMode:i,updateFitMode:a}),o.jsx(ss,{})]}),width:it*2+ts},y={el:o.jsx(Ql,{isFlamegraphDirty:n,reset:r}),width:it},v={el:o.jsxs(o.Fragment,{children:[o.jsx(Kl,{selectedNode:c,onFocusOnSubtree:d}),o.jsx(ss,{})]}),width:it+ts},k=f?{el:o.jsx(sc,{flamegraphType:u,view:s,updateView:l}),width:it*(u==="single"?4:3)}:null,w=p.isValidElement(g)?{el:o.jsxs(o.Fragment,{children:[o.jsx(ss,{}),g]}),width:it+ts}:null,I=[x,y,v,k,w].filter(N=>N!==null),E=I.reduce((N,A)=>[...N,A.width],[]),{isCollapsed:D,collapsedItemsNumber:b,handleMoreClick:j}=Yl(m,E),R=I.reduce((N,A,Z)=>(Z<b?N.hidden.push(A):N.visible.push(A),N),{visible:[],hidden:[]});return o.jsx("div",{role:"toolbar",ref:m,children:o.jsxs("div",{className:K.navbar,children:[o.jsx("div",{children:o.jsx(Dl,{width:bs,onHighlightChange:e,highlightQuery:t,sharedQuery:h})}),o.jsx("div",{children:o.jsxs("div",{className:K.itemsContainer,children:[R.visible.map((N,A)=>o.jsx("div",{className:K.item,style:{width:N.width},children:N.el},A)),b!==0&&o.jsx(He,{content:"More",children:o.jsx("button",{onClick:j,className:Pt({[K.moreButton]:!0,[K.active]:!D}),children:o.jsx(Kr,{})})})]})}
9),!D&&o.jsx("div",{className:K.navbarCollapsedItems,children:R.hidden.map((N,A)=>o.jsx("div",{className:K.item,style:{width:N.width},children:N.el},A))})]})})});cr.displayName="Toolbar";function Kl({onFocusOnSubtree:s,selectedNode:e}){const t=e.mapOr(()=>{},n=>()=>s(n.i,n.j));return o.jsx(He,{content:"Collapse nodes above",children:o.jsx("div",{children:o.jsx(qe,{disabled:!e.isJust,onClick:t,className:K.collapseNodeButton,"aria-label":"Collapse nodes above",children:o.jsx(Qr,{})})})})}function Ql({isFlamegraphDirty:s,reset:e}){return o.jsx(He,{content:"Reset View",children:o.jsx("span",{children:o.jsx(qe,{id:"reset",disabled:!s,onClick:e,className:K.resetViewButton,"aria-label":"Reset View",children:o.jsx(Zr,{size:11})})})})}function ec({fitMode:s,updateFitMode:e}){const t=n=>s===n;return o.jsxs(o.Fragment,{children:[o.jsx(He,{content:"Head first",children:o.jsx(qe,{onClick:()=>e("HEAD"),className:Pt({[K.fitModeButton]:!0,[K.selected]:t("HEAD")}),children:o.jsx(sr,{})})}),o.jsx(He,{content:"Tail first",children:o.jsx(qe,{onClick:()=>e("TAIL"),className:Pt({[K.fitModeButton]:!0,[K.selected]:t("TAIL")}),children:o.jsx(nr,{})})})]})}const tc=s=>s==="single"?[{label:"Table",value:"table",Icon:vn},{label:"Table and Flamegraph",value:"both",Icon:yn},{label:"Flamegraph",value:"flamegraph",Icon:xn},{label:"Sandwich",value:"sandwich",Icon:tr}]:[{label:"Table",value:"table",Icon:vn},{label:"Table and Flamegraph",value:"both",Icon:yn},{label:"Flamegraph",value:"flamegraph",Icon:xn}];function sc({view:s,updateView:e,flamegraphType:t}){const n=tc(t);return o.jsx("div",{className:K.viewType,children:n.map(({label:r,value:a,Icon:i})=>o.jsx(He,{content:r,children:o.jsx(qe,{"data-testid":a,onClick:()=>e(a),className:Pt({[K.toggleViewButton]:!0,selected:s===a}),children:o.jsx(i,{})})},a))})}function dr(s,e){const t={},n={};let r={name:"total",children:[],self:[],total:[],key:"/total"};return[s].forEach((a,i)=>{var l,c;for(let d=0;d<a.levels.length;d+=1)for(let u=0;u<a.levels[d].length;u+=4){const f=[i,d,u].join("/"),h=a.names[a.levels[d][u+3]],g=a.levels[d][u+0],m=a.levels[d][u+1],x=a.levels[d][u+2];let y="";if(d!==0){const I=d-1,E=a.levels[I];for(let D=0;D<E.length;D+=4){const b=E[D+0],j=E[D+1];if(g>=b&&g<b+j){const R=[i,I,D].join("/");y=n[R].key;break}}}const v=[y||"",h].join("/"),k=!t[v];t[v]||(t[v]={name:h,children:[],self:[],total:[],key:v});const w=t[v];(l=w.total)[i]||(l[i]=0),w.total[i]+=m,(c=w.self)[i]||(c[i]=0),w.self[i]+=x,n[f]=w,y&&k&&t[y].children.push(w),d===0&&(r=w)}}),r}const ur=s=>{const e={maxSelf:100,names:[],levels:[]},t=(n,r,a)=>{var f;const{name:i,children:l,self:c,total:d,offset:u}=n;e.names.push(i),(f=e.levels)[r]||(f[r]=[]),e.maxSelf=Math.max(e.maxSelf,c[0]||0),e.levels[r]=e.levels[r].concat([a,d[0]||0,c[0]||0,e.names.length-1]);for(let h=0;h<l.length;h+=1){const g=t(l[h],r+1,a);a+=g}return u||d[0]||0};return t(s,0,0),e},nc=(s,e)=>{const t={};let n=t;return s.forEach(({name:r,...a})=>{const i={name:r,...a,total:[e]};n.children=[i],n=i}),t.children[0]};function Rs(s){const e=new Map;for(let t=0;t<s.children.length;t+=1)e.has(s.children[t].name)||e.set(s.children[t].name,s.children[t]);for(let t=0;t<s.children.length;t+=1){const n=s.children[t],r=e.get(s.children[t].name);r&&r!==n&&(r.total[0]+=n.total[0],r.self[0]+=n.self[0],r.children=r.children.concat(n.children))}s.children=Array.from(e.values());for(let t=0;t<s.children.length;t+=1)Rs(s.children[t])}function rc(s,e){const t=dr(s),n={format:"single",numTicks:0,maxSelf:100,sampleRate:100,names:[],levels:[],units:s.units,spyName:s.spyName},r={name:e,total:[],self:[0],children:[]},a=i=>{i.name===e&&(n.numTicks+=i.total[0],r.total=[n.numTicks],r.children=r.children.concat(i.children));for(let l=0;l<i.children.length;l+=1)a(i.children[l])};return a(t),Rs(r),{...n,...ur(r)}}function ac(s,e){const t=dr(s),n={format:"single",maxSelf:100,sampleRate:100,numTicks:0,names:[],levels:[],units:s.units,spyName:s.spyName},r=[],a=[],i={name:e,total:[0],self:[0],children:[]},l=(d,u=[])=>{const f=u.concat([{...d,children:[]}]);d.name===e&&(a.push(f),r.push(d.total[0]),n.numTicks+=d.total[0]);for(let h=0;h<d.children.length;h+=1)l(d.children[h],f)};l(t),a.forEach((d,u)=>{i.children.push(nc(d.reverse(),r[u]))}),Rs(i);const c=ur(i);return c.levels=c.levels.reverse().slice(0,-1),{...n,...c}}function ic(s,e){const t=JSON.parse(JSON.stringify(s));return rc(t,e)}function oc(s,e){const t=JSON.parse(JSON.stringify(s));return ac(t,e)}const lc="_flamegraphContainer_sxlwr_1",cc="_createdBy_sxlwr_15",dc="_horizontal_sxlwr_25",u
9c="_vertical_sxlwr_29",fc="_panesWrapper_sxlwr_34",hc="_tablePane_sxlwr_38",mc="_sandwichPane_sxlwr_39",pc="_sandwichPaneInfo_sxlwr_43",gc="_arrow_sxlwr_55",vc="_sandwichTop_sxlwr_71",yc="_sandwichBottom_sxlwr_75",xc="_name_sxlwr_78",G={flamegraphContainer:lc,createdBy:cc,horizontal:dc,vertical:uc,panesWrapper:fc,tablePane:hc,sandwichPane:mc,sandwichPaneInfo:pc,arrow:gc,sandwichTop:vc,sandwichBottom:yc,name:xc};function _c(s,e){const t=[...e];function n(r,a,i){for(const l of r){let c=0;for(let d=a;d<l.length;d+=i)l[d]+=c,c=l[d]+l[d+1]}}return s==="double"?(n(t,0,7),n(t,3,7)):n(t,0,4),t}function bc(s){return s.flamebearer.levels=_c(s.metadata.format,s.flamebearer.levels),s}function ns(s){if(s.profile&&s.flamebearer&&console.warn("'profile' and 'flamebearer' properties are mutually exclusive. Please use profile if possible."),s.profile){const t={...s.profile,flamebearer:{...s.profile.flamebearer}};t.flamebearer.levels=JSON.parse(JSON.stringify(t.flamebearer.levels)),bc(t);const n={...t,...t.metadata,...t.flamebearer,flamebearer:void 0,metadata:void 0};return delete n.flamebearer,delete n.metadata,n}return s.flamebearer?s.flamebearer:{format:"single",names:[],units:"unknown",levels:[[]],spyName:"unknown",numTicks:0,sampleRate:0,maxSelf:0}}function wc(s,e){var t;return s.format!==e.format||s.numTicks!==e.numTicks||s.sampleRate!==e.sampleRate||s.units!==e.units||((t=s.names)==null?void 0:t.length)!==(e==null?void 0:e.names.length)||s.levels.length!==e.levels.length||!s.names.every((n,r)=>n===e.names[r])||!kc(s.levels,e.levels)?!1:JSON.stringify({...s,levels:void 0,names:void 0})===JSON.stringify({...e,levels:void 0,names:void 0})}function kc(s,e){if(s.length!==e.length)return!1;for(let t=0;t<s.length;t++){if(s[t].length!==e[t].length)return!1;for(let n=0;n<s[t].length;n++)if(s[t][n]!==e[t][n])return!1}return!0}const Ms=class Ms extends p.Component{constructor(e){super(e),this.resetFlamegraphState={focusedNode:q.nothing(),zoom:q.nothing()},this.initialFlamegraphState=this.resetFlamegraphState,this.calcNewConfigs=(t,n)=>{const r=this.state.flamegraphConfigs,a=(c,d,u)=>{const f=(h,g,m)=>h.names[pt(h.format).getBarName(h.levels[g],m)];if(u.isNothing)return!0;try{const h=f(c,u.value.i,u.value.j),g=f(d,u.value.i,u.value.j);return h===g}catch{return!1}},i=this.state.flamegraphConfigs.zoom;a(t,n,i)||(r.zoom=this.resetFlamegraphState.zoom);const l=this.state.flamegraphConfigs.focusedNode;return a(t,n,l)||(r.focusedNode=this.resetFlamegraphState.focusedNode),r},this.onSearchChange=t=>{this.setState({searchQuery:t})},this.isSameFlamebearer=(t,n)=>wc(t,n),this.onReset=()=>{this.setState({...this.state,flamegraphConfigs:{...this.state.flamegraphConfigs,...this.initialFlamegraphState},selectedItem:q.nothing()})},this.onFlamegraphZoom=t=>{if(t.isJust&&t.value.i===0&&t.value.j===0){this.onReset();return}this.setState({...this.state,flamegraphConfigs:{...this.state.flamegraphConfigs,zoom:t}})},this.onFocusOnNode=(t,n)=>{if(t===0&&n===0){this.onReset();return}let r={...this.state.flamegraphConfigs};const{zoom:a}=this.state.flamegraphConfigs;a.isJust&&a.value.i<=t&&(r={...r,zoom:this.initialFlamegraphState.zoom}),this.setState({...this.state,flamegraphConfigs:{...r,focusedNode:q.just({i:t,j:n})}})},this.setActiveItem=t=>{const{name:n}=t;if(this.state.selectedItem.isJust&&n===this.state.selectedItem.value){this.setState({selectedItem:q.nothing()});return}this.setState({selectedItem:q.just(n)})},this.getHighlightQuery=()=>this.state.selectedItem.isJust?this.state.selectedItem.value:this.state.searchQuery,this.updateView=t=>{t==="sandwich"&&this.setState({searchQuery:"",flamegraphConfigs:this.resetFlamegraphState}),this.setState({view:t})},this.updateFlamegraphDirtiness=()=>{const t=this.isDirty();this.setState({isFlamegraphDirty:t})},this.updateFitMode=t=>{this.setState({fitMode:t})},this.isDirty=()=>this.state.selectedItem.isJust||JSON.stringify(this.initialFlamegraphState)!==JSON.stringify(this.state.flamegraphConfigs),this.render=()=>{const t=o.jsx("div",{className:le(G.tablePane,this.state.panesOrientation==="vertical"?G.vertical:G.horizontal),children:o.jsx(Cl,{"data-testid":"table-view",flamebearer:this.state.flamebearer,fitMode:this.state.fitMode,highlightQuery:this.state.searchQuery,selectedItem:this.state.selectedItem,handleTableItemClick:this.setActiveItem,palette:this.state.palette})},"table-pane"),n=this.shouldShowToolbar(),r=o.jsx(Cn,{showCredit:this.props.showCredit,flamebearer:this.state.flamebearer,highlightQuery:this.getHighlightQuery(),setActiveItem:this.setActiveItem,selectedItem:this.state.selectedItem,updateView:this.props.onlyDisplay?void 0:this.updateView,fitMode:this.state.fitMode,updateFitMode:this.updateFitMode,zoom:this.state.flamegraphConfigs.zoom,focusedNode:this.state.flamegraphConfigs.focusedNode,onZoom:this.onFlamegraphZoom,onFocusOnNode:this.onFocusOnNode,onReset:this.onReset,isDirty:this.isDirty,palette:this.state.palette,toolbarVisible:n,setPalette:c=>this.setState({palette:c})},"flamegraph-pane"),a=(()=>
9{if(this.state.selectedItem.isNothing)return o.jsx("div",{className:G.sandwichPane,children:o.jsxs("div",{className:le(G.sandwichPaneInfo,this.state.panesOrientation==="vertical"?G.vertical:G.horizontal),children:[o.jsx("div",{className:G.arrow}),"Select a function to view callers/callees sandwich view"]})},"sandwich-pane");const c=oc(this.state.flamebearer,this.state.selectedItem.value),d=ic(this.state.flamebearer,this.state.selectedItem.value),u=f=>o.jsx(Cn,{disableClick:!0,showCredit:this.props.showCredit,highlightQuery:"",setActiveItem:this.setActiveItem,selectedItem:this.state.selectedItem,fitMode:this.state.fitMode,updateFitMode:this.updateFitMode,zoom:this.state.flamegraphConfigs.zoom,focusedNode:this.state.flamegraphConfigs.focusedNode,onZoom:this.onFlamegraphZoom,onFocusOnNode:this.onFocusOnNode,onReset:this.onReset,isDirty:this.isDirty,palette:this.state.palette,toolbarVisible:n,setPalette:h=>this.setState({palette:h}),...f});return o.jsxs("div",{className:G.sandwichPane,children:[o.jsxs("div",{className:G.sandwichTop,children:[o.jsx("span",{className:G.name,children:"Callers"}),u({flamebearer:c})]}),o.jsxs("div",{className:G.sandwichBottom,children:[o.jsx("span",{className:G.name,children:"Callees"}),u({flamebearer:d,headerVisible:!1,showSingleLevel:!0})]})]},"sandwich-pane")})(),i=!this.state.flamebearer||this.state.flamebearer.names.length<=1,l=Tc(this.state.view,r,t,a);return o.jsx("div",{children:o.jsxs("div",{children:[n&&o.jsx(cr,{sharedQuery:this.props.sharedQuery,enableChangingDisplay:!this.props.onlyDisplay,flamegraphType:this.state.flamebearer.format,view:this.state.view,handleSearchChange:this.onSearchChange,reset:this.onReset,updateView:this.updateView,updateFitMode:this.updateFitMode,fitMode:this.state.fitMode,isFlamegraphDirty:this.isDirty(),selectedNode:this.state.flamegraphConfigs.zoom,highlightQuery:this.state.searchQuery,onFocusOnSubtree:this.onFocusOnNode,ExportData:this.props.ExportData}),this.props.children,o.jsx("div",{className:`${le(G.flamegraphContainer,this.state.panesOrientation==="vertical"?G.vertical:G.horizontal,G[this.state.panesOrientation],G.panesWrapper)}`,children:i?o.jsx(ui,{}):l.map(c=>c)})]})})},this.state={isFlamegraphDirty:!1,view:this.props.onlyDisplay?this.props.onlyDisplay:"both",fitMode:"HEAD",flamebearer:ns(e),panesOrientation:e.panesOrientation?e.panesOrientation:"horizontal",searchQuery:"",selectedItem:q.nothing(),flamegraphConfigs:this.initialFlamegraphState,palette:gt}}componentDidUpdate(e,t){const n=ns(e),r=ns(this.props);if(!this.isSameFlamebearer(n,r)){const a=this.calcNewConfigs(n,r);this.setState({flamebearer:r,flamegraphConfigs:{...this.state.flamegraphConfigs,...a},selectedItem:q.nothing()});return}t.flamegraphConfigs!==this.state.flamegraphConfigs&&this.updateFlamegraphDirtiness()}shouldShowToolbar(){return this.props.showToolbar!==void 0?this.props.showToolbar:!0}};Ms.defaultProps={showCredit:!0};let ws=Ms;function Tc(s,e,t,n){switch(s){case"table":return[t];case"flamegraph":return[e];case"sandwich":return[t,n];case"both":return[t,e];default:throw new Error(`Invalid view '${s}'`)}}const Cc={showPyroscopeLogo:!1},Tt=s=>o.jsx("pyro-flamegraph",{is:"span","data-flamegraph-color-mode":s.colorMode||"dark",children:o.jsx(ws,{...s,...Cc})}),wd=()=>{var k;const s=Or(),e=Br(),n=Rn(In)==="dark",r=p.useContext(Er)||{params:{}},a={fromTs:r.params.dateRange.fromTs,toTs:r.params.dateRange.toTs},i=r.params.appliedFilters||{};if(i.profiling&&r.params.appliedFilters.profiling.values&&Object.keys(i.profiling.values).length===3){let w=i.profiling.values;w=[w[0],w[w.length-1]],i.profiling.values=w}const l=((k=r.params.appliedFilters.profiling)==null?void 0:k.values)||[],[c,d]=p.useState(0),[u,f]=p.useState(),[h,g]=p.useState({is_loading:!1,data:{series:[],noDataFound:!0,timeRange:{fromTs:a.fromTs,toTs:a.toTs,interval:1e3}}}),m=w=>{if(w.length===0)return;const I={query:w.length>1?`${w[0]}{pyroscope_app="${w[1]}"}`:w[0],from:Math.floor(r.params.dateRange.fromTs/1e3),until:Math.floor(r.params.dateRange.toTs/1e3),format:"json"};g(E=>({...E,is_loading:!0})),e(Ar(I,(E,D)=>{E&&D.data&&Object.keys(D.data).length>0&&(f(D.data),x(D.data)),g(b=>({...b,is_loading:!1}))}))};p.useEffect(()=>{m(l)},[JSON.stringify(r.params.appliedFilters),r.params.dateRange]);const x=w=>{var Z,z;const I=new Date(a.fromTs),E=w.timeline.samples,D=((Z=w==null?void 0:w.timeline)==null?void 0:Z.durationDelta)*1e3,b=(z=w==null?void 0:w.metadata)==null?void 0:z.units,j=`${l[0]}{pyroscope_app="${l[1]||""}"}`,R=[];
9E.forEach((ue,Ce)=>{const ee=I.getTime()+Ce*D,ce=Number(ue)>=0?Number(ue):0;R.push([ee,ce])});const N=[{name:j,data:R,custom:{groups:[],metricName:j,config:{type:b==="bytes"?Hr:b==="samples"?Ur:Jr,label:"",config:{valueType:b==="samples"?"nanosecond":""}}}}],A={series:N,noDataFound:N.length===0,timeRange:{fromTs:a.fromTs,toTs:a.toTs,interval:D}};g({is_loading:!1,data:A})},y=[{label:"Flame Graph",value:0},{label:"Table & Flame Graph",value:1},{label:"Table",value:2},{label:"Sandwich",value:3}],v=w=>{if(w&&w!=""&&u){const I=u.flamebearer.names.filter(E=>E.includes(w));f(E=>{if(E)return{...E,flamebearer:{...E==null?void 0:E.flamebearer,names:I}}})}else m(l)};return s(zr.ContinuousProfiling)?o.jsxs("div",{className:"apm-profiling-section",children:[o.jsx("div",{className:"search-and-type",children:o.jsxs("div",{className:"profile-search-card",children:[o.jsx("div",{className:"profile-search",children:o.jsx($r,{onChange:v,placeholder:"Search location"})}),o.jsx("div",{className:"type",children:o.jsx(Lr,{tabs:y,selectedTab:c,onTabChange:({value:w})=>d(w)})})]})}),o.jsx("div",{className:"profile-timeseries-graph",children:o.jsx(En,{bordered:!0,className:"profiling-graph-card",children:h.is_loading?o.jsx(Nn,{}):o.jsx(Ir,{widget:{label:"Profiling Chart",builderId:1,scopeId:1,widgetAppId:1,builderViewOptions:{}},timeseriesData:h.data,nestedProps:{chartHeight:Rr.HEIGHT_150,chartType:"stacked_bar_chart"},onDateChange:()=>{},dateRange:a})})}),o.jsxs("div",{className:"flamegraph-container",children:[c===0&&o.jsx(Tt,{onlyDisplay:"flamegraph",showToolbar:!1,profile:u,showCredit:!1,colorMode:n?"dark":"light"}),c===1&&o.jsx(Tt,{onlyDisplay:"both",showToolbar:!1,profile:u,showCredit:!1,colorMode:n?"dark":"light"}),c===2&&o.jsx(Tt,{onlyDisplay:"table",showToolbar:!1,profile:u,showCredit:!1,colorMode:n?"dark":"light"}),c===3&&o.jsx(Tt,{onlyDisplay:"sandwich",showToolbar:!1,profile:u,showCredit:!1,colorMode:n?"dark":"light"})]})]}):o.jsx(Dr,{})};export{wd as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.