@meyicloud/meyi-cost-ui 1.5.9 → 1.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.mjs +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
14
14
|
`+o)}}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=pt(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Dn.assertOptions(r,{silentJSONParsing:ge.transitional(ge.boolean),forcedJSONParsing:ge.transitional(ge.boolean),clarifyTimeoutError:ge.transitional(ge.boolean),legacyInterceptorReqResOrdering:ge.transitional(ge.boolean),advertiseZstdAcceptEncoding:ge.transitional(ge.boolean),validateStatusUndefinedResolves:ge.transitional(ge.boolean)},!1),s!=null&&(w.isFunction(s)?n.paramsSerializer={serialize:s}:Dn.assertOptions(s,{encode:ge.function,serialize:ge.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Dn.assertOptions(n,{baseUrl:ge.spelling("baseURL"),withXsrfToken:ge.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&w.merge(o.common,o[n.method]);o&&w.forEach(["delete","get","head","post","put","patch","query","common"],g=>{delete o[g]}),n.headers=be.concat(i,o);const c=[];let u=!0;this.interceptors.request.forEach(function(p){if(typeof p.runWhen=="function"&&p.runWhen(n)===!1)return;u=u&&p.synchronous;const x=n.transitional||cs;x&&x.legacyInterceptorReqResOrdering?c.unshift(p.fulfilled,p.rejected):c.push(p.fulfilled,p.rejected)});const f=[];this.interceptors.response.forEach(function(p){f.push(p.fulfilled,p.rejected)});let d,l=0,h;if(!u){const g=[bo.bind(this),void 0];for(g.unshift(...c),g.push(...f),h=g.length,d=Promise.resolve(n);l<h;)d=d.then(g[l++],g[l++]);return d}h=c.length;let m=n;for(;l<h;){const g=c[l++],p=c[l++];try{m=g(m)}catch(x){p.call(this,x);break}}try{d=bo.call(this,m)}catch(g){return Promise.reject(g)}for(l=0,h=f.length;l<h;)d=d.then(f[l++],f[l++]);return d}getUri(t){t=pt(this.defaults,t);const n=Ja(t.baseURL,t.url,t.allowAbsoluteUrls,t);return Ha(n,t.params,t.paramsSerializer)}};w.forEach(["delete","get","head","options"],function(t){ft.prototype[t]=function(n,r){return this.request(pt(r||{},{method:t,url:n,data:r&&w.hasOwnProp(r,"data")?r.data:void 0}))}});w.forEach(["post","put","patch","query"],function(t){function n(r){return function(o,i,c){return this.request(pt(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}ft.prototype[t]=n(),t!=="query"&&(ft.prototype[t+"Form"]=n(!0))});let tf=class ei{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new dn(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ei(function(s){t=s}),cancel:t}}};function nf(e){return function(n){return e.apply(null,n)}}function rf(e){return w.isObject(e)&&e.isAxiosError===!0}const Kr={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Kr).forEach(([e,t])=>{Kr[t]=e});function ti(e){const t=new ft(e),n=Aa(ft.prototype.request,t);return w.extend(n,ft.prototype,t,{allOwnKeys:!0}),w.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return ti(pt(e,s))},n}const ae=ti(un);ae.Axios=ft;ae.CanceledError=dn;ae.CancelToken=tf;ae.isCancel=Ka;ae.VERSION=us;ae.toFormData=sr;ae.AxiosError=T;ae.Cancel=ae.CanceledError;ae.all=function(t){return Promise.all(t)};ae.spread=nf;ae.isAxiosError=rf;ae.mergeConfig=pt;ae.AxiosHeaders=be;ae.formToJSON=e=>Ga(w.isHTMLForm(e)?new FormData(e):e);ae.getAdapter=Qa.getAdapter;ae.HttpStatusCode=Kr;ae.default=ae;const{Axios:wg,AxiosError:Sg,CanceledError:Rg,isCancel:Ng,CancelToken:Cg,VERSION:jg,all:Eg,Cancel:_g,isAxiosError:kg,spread:Pg,toFormData:Ag,AxiosHeaders:Og,HttpStatusCode:Tg,formToJSON:Lg,getAdapter:Ig,mergeConfig:Mg,create:Dg}=ae,ne=ae.create({baseURL:"/api/v1/cost"});function ni(e,t){ne.defaults.baseURL=`${e.replace(/\/$/,"")}/cost`,t?ne.defaults.headers.common.Authorization=`Bearer ${t}`:delete ne.defaults.headers.common.Authorization}function sf(e){e.interceptors.request.use(t=>{if(typeof window<"u"){const n=window.localStorage.getItem("access_token");n?(t.headers=t.headers||{},t.headers.Authorization=`Bearer ${n}`):t.headers&&delete t.headers.Authorization}return t})}const of=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),af=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase()),vo=e=>{const t=af(e);return t.charAt(0).toUpperCase()+t.slice(1)},ri=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim(),cf=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var lf={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const uf=P.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...c},u)=>P.createElement("svg",{ref:u,...lf,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:ri("lucide",s),...!o&&!cf(c)&&{"aria-hidden":"true"},...c},[...i.map(([f,d])=>P.createElement(f,d)),...Array.isArray(o)?o:[o]]));const ee=(e,t)=>{const n=P.forwardRef(({className:r,...s},o)=>P.createElement(uf,{ref:o,iconNode:t,className:ri(`lucide-${of(vo(e))}`,`lucide-${e}`,r),...s}));return n.displayName=vo(e),n};const df=[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]],si=ee("building-2",df);const ff=[["path",{d:"M16 14v2.2l1.6 1",key:"fo4ql5"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]],oi=ee("calendar-clock",ff);const hf=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]],mf=ee("chart-column",hf);const pf=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],gf=ee("chevron-down",pf);const xf=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],bf=ee("chevron-left",xf);const yf=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],vf=ee("chevron-right",yf);const wf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],ze=ee("circle-alert",wf);const Sf=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Rf=ee("circle-check",Sf);const Nf=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],Jn=ee("cloud",Nf);const Cf=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],ai=ee("database",Cf);const jf=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ii=ee("dollar-sign",jf);const Ef=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],fs=ee("download",Ef);const _f=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],ci=ee("external-link",_f);const kf=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Pf=ee("eye",kf);const Af=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]],Of=ee("file-down",Af);const Tf=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],li=ee("file-text",Tf);const Lf=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],If=ee("list",Lf);const Mf=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ct=ee("loader-circle",Mf);const Df=[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]],Ff=ee("map-pin",Df);const Uf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],$f=ee("plus",Uf);const Bf=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Tt=ee("refresh-cw",Bf);const zf=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],hs=ee("search",zf);const Wf=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],ui=ee("server",Wf);const Vf=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],di=ee("settings-2",Vf);const Hf=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],wo=ee("sparkles",Hf);const qf=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],fi=ee("trash-2",qf);const Gf=[["path",{d:"M16 17h6v-6",key:"t6n2it"}],["path",{d:"m22 17-8.5-8.5-5 5L2 7",key:"x473p"}]],Kf=ee("trending-down",Gf);const Yf=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],hi=ee("trending-up",Yf);const Jf=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Lt=ee("x",Jf);function mi(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(n=mi(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function Xf(){for(var e,t,n=0,r="",s=arguments.length;n<s;n++)(e=arguments[n])&&(t=mi(e))&&(r&&(r+=" "),r+=t);return r}const Zf=(e,t)=>{const n=new Array(e.length+t.length);for(let r=0;r<e.length;r++)n[r]=e[r];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Qf=(e,t)=>({classGroupId:e,validator:t}),pi=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Xn="-",So=[],eh="arbitrary..",th=e=>{const t=rh(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:i=>{if(i.startsWith("[")&&i.endsWith("]"))return nh(i);const c=i.split(Xn),u=c[0]===""&&c.length>1?1:0;return gi(c,u,t)},getConflictingClassGroupIds:(i,c)=>{if(c){const u=r[i],f=n[i];return u?f?Zf(f,u):u:f||So}return n[i]||So}}},gi=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;const s=e[t],o=n.nextPart.get(s);if(o){const f=gi(e,t+1,o);if(f)return f}const i=n.validators;if(i===null)return;const c=t===0?e.join(Xn):e.slice(t).join(Xn),u=i.length;for(let f=0;f<u;f++){const d=i[f];if(d.validator(c))return d.classGroupId}},nh=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),n=t.indexOf(":"),r=t.slice(0,n);return r?eh+r:void 0})(),rh=e=>{const{theme:t,classGroups:n}=e;return sh(n,t)},sh=(e,t)=>{const n=pi();for(const r in e){const s=e[r];ms(s,n,r,t)}return n},ms=(e,t,n,r)=>{const s=e.length;for(let o=0;o<s;o++){const i=e[o];oh(i,t,n,r)}},oh=(e,t,n,r)=>{if(typeof e=="string"){ah(e,t,n);return}if(typeof e=="function"){ih(e,t,n,r);return}ch(e,t,n,r)},ah=(e,t,n)=>{const r=e===""?t:xi(t,e);r.classGroupId=n},ih=(e,t,n,r)=>{if(lh(e)){ms(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Qf(n,e))},ch=(e,t,n,r)=>{const s=Object.entries(e),o=s.length;for(let i=0;i<o;i++){const[c,u]=s[i];ms(u,xi(t,c),n,r)}},xi=(e,t)=>{let n=e;const r=t.split(Xn),s=r.length;for(let o=0;o<s;o++){const i=r[o];let c=n.nextPart.get(i);c||(c=pi(),n.nextPart.set(i,c)),n=c}return n},lh=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,uh=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null);const s=(o,i)=>{n[o]=i,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(o){let i=n[o];if(i!==void 0)return i;if((i=r[o])!==void 0)return s(o,i),i},set(o,i){o in n?n[o]=i:s(o,i)}}},Yr="!",Ro=":",dh=[],No=(e,t,n,r,s)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:s}),fh=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=s=>{const o=[];let i=0,c=0,u=0,f;const d=s.length;for(let p=0;p<d;p++){const x=s[p];if(i===0&&c===0){if(x===Ro){o.push(s.slice(u,p)),u=p+1;continue}if(x==="/"){f=p;continue}}x==="["?i++:x==="]"?i--:x==="("?c++:x===")"&&c--}const l=o.length===0?s:s.slice(u);let h=l,m=!1;l.endsWith(Yr)?(h=l.slice(0,-1),m=!0):l.startsWith(Yr)&&(h=l.slice(1),m=!0);const g=f&&f>u?f-u:void 0;return No(o,m,h,g)};if(t){const s=t+Ro,o=r;r=i=>i.startsWith(s)?o(i.slice(s.length)):No(dh,!1,i,void 0,!0)}if(n){const s=r;r=o=>n({className:o,parseClassName:s})}return r},hh=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((n,r)=>{t.set(n,1e6+r)}),n=>{const r=[];let s=[];for(let o=0;o<n.length;o++){const i=n[o],c=i[0]==="[",u=t.has(i);c||u?(s.length>0&&(s.sort(),r.push(...s),s=[]),r.push(i)):s.push(i)}return s.length>0&&(s.sort(),r.push(...s)),r}},mh=e=>({cache:uh(e.cacheSize),parseClassName:fh(e),sortModifiers:hh(e),postfixLookupClassGroupIds:ph(e),...th(e)}),ph=e=>{const t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let r=0;r<n.length;r++)t[n[r]]=!0;return t},gh=/\s+/,xh=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:s,sortModifiers:o,postfixLookupClassGroupIds:i}=t,c=[],u=e.trim().split(gh);let f="";for(let d=u.length-1;d>=0;d-=1){const l=u[d],{isExternal:h,modifiers:m,hasImportantModifier:g,baseClassName:p,maybePostfixModifierPosition:x}=n(l);if(h){f=l+(f.length>0?" "+f:f);continue}let b=!!x,y;if(b){const C=p.substring(0,x);y=r(C);const R=y&&i[y]?r(p):void 0;R&&R!==y&&(y=R,b=!1)}else y=r(p);if(!y){if(!b){f=l+(f.length>0?" "+f:f);continue}if(y=r(p),!y){f=l+(f.length>0?" "+f:f);continue}b=!1}const v=m.length===0?"":m.length===1?m[0]:o(m).join(":"),N=g?v+Yr:v,j=N+y;if(c.indexOf(j)>-1)continue;c.push(j);const _=s(y,b);for(let C=0;C<_.length;++C){const R=_[C];c.push(N+R)}f=l+(f.length>0?" "+f:f)}return f},bh=(...e)=>{let t=0,n,r,s="";for(;t<e.length;)(n=e[t++])&&(r=bi(n))&&(s&&(s+=" "),s+=r);return s},bi=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=bi(e[r]))&&(n&&(n+=" "),n+=t);return n},yh=(e,...t)=>{let n,r,s,o;const i=u=>{const f=t.reduce((d,l)=>l(d),e());return n=mh(f),r=n.cache.get,s=n.cache.set,o=c,c(u)},c=u=>{const f=r(u);if(f)return f;const d=xh(u,n);return s(u,d),d};return o=i,(...u)=>o(bh(...u))},vh=[],ce=e=>{const t=n=>n[e]||vh;return t.isThemeGetter=!0,t},yi=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,vi=/^\((?:(\w[\w-]*):)?(.+)\)$/i,wh=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Sh=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Rh=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Nh=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Ch=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,jh=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,He=e=>wh.test(e),G=e=>!!e&&!Number.isNaN(Number(e)),Le=e=>!!e&&Number.isInteger(Number(e)),_r=e=>e.endsWith("%")&&G(e.slice(0,-1)),Fe=e=>Sh.test(e),wi=()=>!0,Eh=e=>Rh.test(e)&&!Nh.test(e),ps=()=>!1,_h=e=>Ch.test(e),kh=e=>jh.test(e),Ph=e=>!M(e)&&!F(e),Ah=e=>e.startsWith("@container")&&(e[10]==="/"&&e[11]!==void 0||e[11]==="s"&&e[16]!==void 0&&e.startsWith("-size/",10)||e[11]==="n"&&e[18]!==void 0&&e.startsWith("-normal/",10)),Oh=e=>Qe(e,Ni,ps),M=e=>yi.test(e),nt=e=>Qe(e,Ci,Eh),Co=e=>Qe(e,$h,G),Th=e=>Qe(e,Ei,wi),Lh=e=>Qe(e,ji,ps),jo=e=>Qe(e,Si,ps),Ih=e=>Qe(e,Ri,kh),vn=e=>Qe(e,_i,_h),F=e=>vi.test(e),Kt=e=>xt(e,Ci),Mh=e=>xt(e,ji),Eo=e=>xt(e,Si),Dh=e=>xt(e,Ni),Fh=e=>xt(e,Ri),wn=e=>xt(e,_i,!0),Uh=e=>xt(e,Ei,!0),Qe=(e,t,n)=>{const r=yi.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},xt=(e,t,n=!1)=>{const r=vi.exec(e);return r?r[1]?t(r[1]):n:!1},Si=e=>e==="position"||e==="percentage",Ri=e=>e==="image"||e==="url",Ni=e=>e==="length"||e==="size"||e==="bg-size",Ci=e=>e==="length",$h=e=>e==="number",ji=e=>e==="family-name",Ei=e=>e==="number"||e==="weight",_i=e=>e==="shadow",Bh=()=>{const e=ce("color"),t=ce("font"),n=ce("text"),r=ce("font-weight"),s=ce("tracking"),o=ce("leading"),i=ce("breakpoint"),c=ce("container"),u=ce("spacing"),f=ce("radius"),d=ce("shadow"),l=ce("inset-shadow"),h=ce("text-shadow"),m=ce("drop-shadow"),g=ce("blur"),p=ce("perspective"),x=ce("aspect"),b=ce("ease"),y=ce("animate"),v=()=>["auto","avoid","all","avoid-page","page","left","right","column"],N=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],j=()=>[...N(),F,M],_=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],R=()=>[F,M,u],k=()=>[He,"full","auto",...R()],L=()=>[Le,"none","subgrid",F,M],A=()=>["auto",{span:["full",Le,F,M]},Le,F,M],D=()=>[Le,"auto",F,M],O=()=>["auto","min","max","fr",F,M],$=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],J=()=>["start","end","center","stretch","center-safe","end-safe"],Y=()=>["auto",...R()],Q=()=>[He,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...R()],he=()=>[He,"screen","full","dvw","lvw","svw","min","max","fit",...R()],me=()=>[He,"screen","full","lh","dvh","lvh","svh","min","max","fit",...R()],I=()=>[e,F,M],E=()=>[...N(),Eo,jo,{position:[F,M]}],B=()=>["no-repeat",{repeat:["","x","y","space","round"]}],q=()=>["auto","cover","contain",Dh,Oh,{size:[F,M]}],K=()=>[_r,Kt,nt],H=()=>["","none","full",f,F,M],z=()=>["",G,Kt,nt],U=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],V=()=>[G,_r,Eo,jo],ie=()=>["","none",g,F,M],le=()=>["none",G,F,M],te=()=>["none",G,F,M],je=()=>[G,F,M],Ce=()=>[He,"full",...R()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[Fe],breakpoint:[Fe],color:[wi],container:[Fe],"drop-shadow":[Fe],ease:["in","out","in-out"],font:[Ph],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[Fe],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[Fe],shadow:[Fe],spacing:["px",G],text:[Fe],"text-shadow":[Fe],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",He,M,F,x]}],container:["container"],"container-type":[{"@container":["","normal","size",F,M]}],"container-named":[Ah],columns:[{columns:[G,M,F,c]}],"break-after":[{"break-after":v()}],"break-before":[{"break-before":v()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:j()}],overflow:[{overflow:_()}],"overflow-x":[{"overflow-x":_()}],"overflow-y":[{"overflow-y":_()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:k()}],"inset-x":[{"inset-x":k()}],"inset-y":[{"inset-y":k()}],start:[{"inset-s":k(),start:k()}],end:[{"inset-e":k(),end:k()}],"inset-bs":[{"inset-bs":k()}],"inset-be":[{"inset-be":k()}],top:[{top:k()}],right:[{right:k()}],bottom:[{bottom:k()}],left:[{left:k()}],visibility:["visible","invisible","collapse"],z:[{z:[Le,"auto",F,M]}],basis:[{basis:[He,"full","auto",c,...R()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[G,He,"auto","initial","none",M]}],grow:[{grow:["",G,F,M]}],shrink:[{shrink:["",G,F,M]}],order:[{order:[Le,"first","last","none",F,M]}],"grid-cols":[{"grid-cols":L()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":D()}],"col-end":[{"col-end":D()}],"grid-rows":[{"grid-rows":L()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":D()}],"row-end":[{"row-end":D()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":O()}],"auto-rows":[{"auto-rows":O()}],gap:[{gap:R()}],"gap-x":[{"gap-x":R()}],"gap-y":[{"gap-y":R()}],"justify-content":[{justify:[...$(),"normal"]}],"justify-items":[{"justify-items":[...J(),"normal"]}],"justify-self":[{"justify-self":["auto",...J()]}],"align-content":[{content:["normal",...$()]}],"align-items":[{items:[...J(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...J(),{baseline:["","last"]}]}],"place-content":[{"place-content":$()}],"place-items":[{"place-items":[...J(),"baseline"]}],"place-self":[{"place-self":["auto",...J()]}],p:[{p:R()}],px:[{px:R()}],py:[{py:R()}],ps:[{ps:R()}],pe:[{pe:R()}],pbs:[{pbs:R()}],pbe:[{pbe:R()}],pt:[{pt:R()}],pr:[{pr:R()}],pb:[{pb:R()}],pl:[{pl:R()}],m:[{m:Y()}],mx:[{mx:Y()}],my:[{my:Y()}],ms:[{ms:Y()}],me:[{me:Y()}],mbs:[{mbs:Y()}],mbe:[{mbe:Y()}],mt:[{mt:Y()}],mr:[{mr:Y()}],mb:[{mb:Y()}],ml:[{ml:Y()}],"space-x":[{"space-x":R()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":R()}],"space-y-reverse":["space-y-reverse"],size:[{size:Q()}],"inline-size":[{inline:["auto",...he()]}],"min-inline-size":[{"min-inline":["auto",...he()]}],"max-inline-size":[{"max-inline":["none",...he()]}],"block-size":[{block:["auto",...me()]}],"min-block-size":[{"min-block":["auto",...me()]}],"max-block-size":[{"max-block":["none",...me()]}],w:[{w:[c,"screen",...Q()]}],"min-w":[{"min-w":[c,"screen","none",...Q()]}],"max-w":[{"max-w":[c,"screen","none","prose",{screen:[i]},...Q()]}],h:[{h:["screen","lh",...Q()]}],"min-h":[{"min-h":["screen","lh","none",...Q()]}],"max-h":[{"max-h":["screen","lh",...Q()]}],"font-size":[{text:["base",n,Kt,nt]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,Uh,Th]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",_r,M]}],"font-family":[{font:[Mh,Lh,t]}],"font-features":[{"font-features":[M]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[s,F,M]}],"line-clamp":[{"line-clamp":[G,"none",F,Co]}],leading:[{leading:[o,...R()]}],"list-image":[{"list-image":["none",F,M]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",F,M]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[G,"from-font","auto",F,nt]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[G,"auto",F,M]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:R()}],"tab-size":[{tab:[Le,F,M]}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",F,M]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",F,M]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:E()}],"bg-repeat":[{bg:B()}],"bg-size":[{bg:q()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},Le,F,M],radial:["",F,M],conic:[Le,F,M]},Fh,Ih]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:K()}],"gradient-via-pos":[{via:K()}],"gradient-to-pos":[{to:K()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:H()}],"rounded-s":[{"rounded-s":H()}],"rounded-e":[{"rounded-e":H()}],"rounded-t":[{"rounded-t":H()}],"rounded-r":[{"rounded-r":H()}],"rounded-b":[{"rounded-b":H()}],"rounded-l":[{"rounded-l":H()}],"rounded-ss":[{"rounded-ss":H()}],"rounded-se":[{"rounded-se":H()}],"rounded-ee":[{"rounded-ee":H()}],"rounded-es":[{"rounded-es":H()}],"rounded-tl":[{"rounded-tl":H()}],"rounded-tr":[{"rounded-tr":H()}],"rounded-br":[{"rounded-br":H()}],"rounded-bl":[{"rounded-bl":H()}],"border-w":[{border:z()}],"border-w-x":[{"border-x":z()}],"border-w-y":[{"border-y":z()}],"border-w-s":[{"border-s":z()}],"border-w-e":[{"border-e":z()}],"border-w-bs":[{"border-bs":z()}],"border-w-be":[{"border-be":z()}],"border-w-t":[{"border-t":z()}],"border-w-r":[{"border-r":z()}],"border-w-b":[{"border-b":z()}],"border-w-l":[{"border-l":z()}],"divide-x":[{"divide-x":z()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":z()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[G,F,M]}],"outline-w":[{outline:["",G,Kt,nt]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",d,wn,vn]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",l,wn,vn]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:z()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[G,nt]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":z()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",h,wn,vn]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[G,F,M]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[G]}],"mask-image-linear-from-pos":[{"mask-linear-from":V()}],"mask-image-linear-to-pos":[{"mask-linear-to":V()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":V()}],"mask-image-t-to-pos":[{"mask-t-to":V()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":V()}],"mask-image-r-to-pos":[{"mask-r-to":V()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":V()}],"mask-image-b-to-pos":[{"mask-b-to":V()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":V()}],"mask-image-l-to-pos":[{"mask-l-to":V()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":V()}],"mask-image-x-to-pos":[{"mask-x-to":V()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":V()}],"mask-image-y-to-pos":[{"mask-y-to":V()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[F,M]}],"mask-image-radial-from-pos":[{"mask-radial-from":V()}],"mask-image-radial-to-pos":[{"mask-radial-to":V()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":N()}],"mask-image-conic-pos":[{"mask-conic":[G]}],"mask-image-conic-from-pos":[{"mask-conic-from":V()}],"mask-image-conic-to-pos":[{"mask-conic-to":V()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:E()}],"mask-repeat":[{mask:B()}],"mask-size":[{mask:q()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",F,M]}],filter:[{filter:["","none",F,M]}],blur:[{blur:ie()}],brightness:[{brightness:[G,F,M]}],contrast:[{contrast:[G,F,M]}],"drop-shadow":[{"drop-shadow":["","none",m,wn,vn]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",G,F,M]}],"hue-rotate":[{"hue-rotate":[G,F,M]}],invert:[{invert:["",G,F,M]}],saturate:[{saturate:[G,F,M]}],sepia:[{sepia:["",G,F,M]}],"backdrop-filter":[{"backdrop-filter":["","none",F,M]}],"backdrop-blur":[{"backdrop-blur":ie()}],"backdrop-brightness":[{"backdrop-brightness":[G,F,M]}],"backdrop-contrast":[{"backdrop-contrast":[G,F,M]}],"backdrop-grayscale":[{"backdrop-grayscale":["",G,F,M]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[G,F,M]}],"backdrop-invert":[{"backdrop-invert":["",G,F,M]}],"backdrop-opacity":[{"backdrop-opacity":[G,F,M]}],"backdrop-saturate":[{"backdrop-saturate":[G,F,M]}],"backdrop-sepia":[{"backdrop-sepia":["",G,F,M]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":R()}],"border-spacing-x":[{"border-spacing-x":R()}],"border-spacing-y":[{"border-spacing-y":R()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",F,M]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[G,"initial",F,M]}],ease:[{ease:["linear","initial",b,F,M]}],delay:[{delay:[G,F,M]}],animate:[{animate:["none",y,F,M]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[p,F,M]}],"perspective-origin":[{"perspective-origin":j()}],rotate:[{rotate:le()}],"rotate-x":[{"rotate-x":le()}],"rotate-y":[{"rotate-y":le()}],"rotate-z":[{"rotate-z":le()}],scale:[{scale:te()}],"scale-x":[{"scale-x":te()}],"scale-y":[{"scale-y":te()}],"scale-z":[{"scale-z":te()}],"scale-3d":["scale-3d"],skew:[{skew:je()}],"skew-x":[{"skew-x":je()}],"skew-y":[{"skew-y":je()}],transform:[{transform:[F,M,"","none","gpu","cpu"]}],"transform-origin":[{origin:j()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Ce()}],"translate-x":[{"translate-x":Ce()}],"translate-y":[{"translate-y":Ce()}],"translate-z":[{"translate-z":Ce()}],"translate-none":["translate-none"],zoom:[{zoom:[Le,F,M]}],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",F,M]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":["auto","stable","both"]}],"scrollbar-w":[{scrollbar:["auto","thin","none"]}],"scroll-m":[{"scroll-m":R()}],"scroll-mx":[{"scroll-mx":R()}],"scroll-my":[{"scroll-my":R()}],"scroll-ms":[{"scroll-ms":R()}],"scroll-me":[{"scroll-me":R()}],"scroll-mbs":[{"scroll-mbs":R()}],"scroll-mbe":[{"scroll-mbe":R()}],"scroll-mt":[{"scroll-mt":R()}],"scroll-mr":[{"scroll-mr":R()}],"scroll-mb":[{"scroll-mb":R()}],"scroll-ml":[{"scroll-ml":R()}],"scroll-p":[{"scroll-p":R()}],"scroll-px":[{"scroll-px":R()}],"scroll-py":[{"scroll-py":R()}],"scroll-ps":[{"scroll-ps":R()}],"scroll-pe":[{"scroll-pe":R()}],"scroll-pbs":[{"scroll-pbs":R()}],"scroll-pbe":[{"scroll-pbe":R()}],"scroll-pt":[{"scroll-pt":R()}],"scroll-pr":[{"scroll-pr":R()}],"scroll-pb":[{"scroll-pb":R()}],"scroll-pl":[{"scroll-pl":R()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",F,M]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[G,Kt,nt,Co]}],stroke:[{stroke:["none",...I()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{"container-named":["container-type"],overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","inset-bs","inset-be","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pbs","pbe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mbs","mbe","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-bs","border-w-be","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-bs","border-color-be","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mbs","scroll-mbe","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pbs","scroll-pbe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},postfixLookupClassGroups:["container-type"],orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},zh=yh(Bh);function Ut(...e){return zh(Xf(e))}function X(e,t="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:t,minimumFractionDigits:2}).format(e)}const ue=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("rounded-xl border bg-card text-card-foreground shadow",e),...t}));ue.displayName="Card";const Re=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("flex flex-col space-y-1.5 p-6",e),...t}));Re.displayName="CardHeader";const Pe=S.forwardRef(({className:e,...t},n)=>a.jsx("h3",{ref:n,className:Ut("font-semibold leading-none tracking-tight",e),...t}));Pe.displayName="CardTitle";const Wh=S.forwardRef(({className:e,...t},n)=>a.jsx("p",{ref:n,className:Ut("text-sm text-muted-foreground",e),...t}));Wh.displayName="CardDescription";const de=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("p-6 pt-0",e),...t}));de.displayName="CardContent";const Vh=S.forwardRef(({className:e,...t},n)=>a.jsx("div",{ref:n,className:Ut("flex items-center p-6 pt-0",e),...t}));Vh.displayName="CardFooter";function Zn({status:e,error:t}){const n=e?.action==="connect_source"||e?.state==="not_configured",r=e?.message||t||"CUR status could not be loaded. Verify the cost source, discovery job, and Athena configuration.";return a.jsx("section",{className:"rounded-md border bg-card p-6","aria-live":"polite",children:a.jsxs("div",{className:"flex items-start gap-3",children:[e?.state==="unavailable"||t?a.jsx(ze,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"}):a.jsx(ai,{className:"mt-0.5 h-5 w-5 shrink-0 text-primary"}),a.jsxs("div",{className:"min-w-0",children:[a.jsx("h2",{className:"font-semibold",children:n?"Enable AWS Cost and Usage Reports":"CUR data is not ready"}),a.jsx("p",{className:"mt-1 max-w-3xl text-sm text-muted-foreground",children:r}),a.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[a.jsxs(qn,{to:n?"/sources":"/cur-discovery",className:"inline-flex items-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground",children:[a.jsx(ci,{className:"h-4 w-4"}),n?"Connect AWS source":"Review CUR discovery"]}),!n&&a.jsx(qn,{to:"/sources",className:"rounded-md border px-3 py-2 text-sm font-medium hover:bg-muted",children:"Cost sources"})]})]})]})})}const oe={getOverview:e=>ne.get("/overview",{params:e}).then(t=>t.data),getAccounts:e=>ne.get("/accounts",{params:e}).then(t=>t.data),getReports:e=>ne.get("/reports",{params:e}).then(t=>t.data),getFilterOptions:e=>ne.get("/filter-options",{params:{start:e?.start,end:e?.end,tagKey:e?.filterTagKey,managementAccountId:e?.managementAccountId}}).then(t=>t.data),getTags:e=>ne.get("/tags",{params:e}).then(t=>t.data),getDataStatus:e=>ne.get("/data-status",{params:e}).then(t=>t.data),getAnalysisStatus:e=>ne.get("/analysis/status",{params:e}).then(t=>t.data),getLatestAnalysis:e=>ne.get("/analysis/latest",{params:e}).then(t=>t.data.analysis),getAnalysisSchedule:e=>ne.get("/analysis/schedule",{params:e}).then(t=>t.data),updateAnalysisSchedule:(e,t)=>ne.put("/analysis/schedule",e,{params:t}).then(n=>n.data),getAnalysisReports:e=>ne.get("/analysis/reports",{params:e}).then(t=>t.data.reports),removeAnalysisReport:e=>ne.delete(`/analysis/reports/${e}`).then(t=>t.data),downloadAnalysisPdf:e=>ne.get(`/analysis/reports/${e}/pdf`,{responseType:"blob"}).then(t=>t.data),getSources:()=>ne.get("/sources").then(e=>e.data),createSource:e=>ne.post("/sources",e).then(t=>t.data),getSourceStatus:e=>ne.get(`/sources/${e}/status`).then(t=>t.data),verifySource:e=>ne.post(`/sources/${e}/verify`).then(t=>t.data),removeSource:(e,t)=>ne.delete(`/sources/${e}`,{data:{deleteAwsResources:t}}).then(n=>n.data),downloadSourceTemplate:e=>ne.get(`/sources/${e}/template`,{responseType:"blob"}).then(t=>t.data),getCurDiscovery:e=>ne.get("/cur-discovery",{params:e}).then(t=>t.data)},ki=P.createContext("user"),Hh=ki.Provider,qh=()=>P.useContext(ki),Pi=P.createContext(null);function Gh({tenantId:e="default",children:t}){const n=`meyi-cost:selected-management-account:${e||"default"}`,[r,s]=P.useState([]),[o,i]=P.useState(""),[c,u]=P.useState(!0),f=P.useCallback(async()=>{u(!0);try{const m=((await oe.getSources()).sources||[]).filter(g=>!!g.managementAccountId);s(m),i(g=>{const x=window.localStorage.getItem(n)||""||g,b=m.find(v=>v.status==="CONNECTED")||m[0],y=m.some(v=>v.managementAccountId===x)?x:b?.managementAccountId||"";return y?window.localStorage.setItem(n,y):window.localStorage.removeItem(n),y})}catch{s([]),i("")}finally{u(!1)}},[n]);P.useEffect(()=>{f()},[f]);const d=P.useCallback(h=>{/^\d{12}$/.test(h)&&(window.localStorage.setItem(n,h),i(h))},[n]),l=P.useMemo(()=>({sources:r,managementAccountId:o,loading:c,selectManagementAccount:d,refreshSources:f}),[r,o,c,d,f]);return a.jsx(Pi.Provider,{value:l,children:t})}function $t(){const e=P.useContext(Pi);if(!e)throw new Error("useCostAccount must be used inside CostAccountProvider");return e}function ar(){const{sources:e,managementAccountId:t,loading:n,selectManagementAccount:r}=$t();return e.length<=1?null:a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx(si,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("span",{className:"sr-only",children:"Management account"}),a.jsx("select",{"aria-label":"Management account",value:t,onChange:s=>r(s.target.value),disabled:n,className:"max-w-72 rounded-md border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:e.map(s=>a.jsxs("option",{value:s.managementAccountId||"",children:["Management account ",s.managementAccountId]},s.connectionId))})]})}function Kh({points:e,currency:t="USD"}){const[n,r]=P.useState(null);if(!e.length)return a.jsx("p",{className:"py-20 text-center text-sm text-muted-foreground",children:"No trend data for this period."});const s=900,o=260,i=70,c=24,u=22,f=48,d=s-i-c,l=o-u-f,h=Math.max(...e.map(x=>x.value),1),m=e.map((x,b)=>({...x,x:i+(e.length===1?d/2:b*d/(e.length-1)),y:u+l-x.value/h*l})),g=n==null?null:m[n],p=x=>{const b=x.currentTarget.getBoundingClientRect(),y=(x.clientX-b.left)/b.width*s;let v=0;for(let N=1;N<m.length;N+=1)Math.abs(m[N].x-y)<Math.abs(m[v].x-y)&&(v=N);r(v)};return a.jsxs("div",{className:"relative w-full",children:[a.jsxs("svg",{viewBox:`0 0 ${s} ${o}`,className:"h-72 w-full",onMouseMove:p,onMouseLeave:()=>r(null),role:"img","aria-label":"Cost trend line chart",children:[[0,.25,.5,.75,1].map(x=>{const b=u+l*x;return a.jsxs("g",{children:[a.jsx("line",{x1:i,y1:b,x2:s-c,y2:b,stroke:"#d8e0e7",strokeDasharray:"4 4"}),a.jsx("text",{x:i-10,y:b+4,textAnchor:"end",fill:"currentColor",className:"text-[10px] text-muted-foreground",children:X(h*(1-x),t)})]},x)}),a.jsx("line",{x1:i,y1:u+l,x2:s-c,y2:u+l,stroke:"#aebbc5"}),a.jsx("polyline",{points:m.map(x=>`${x.x},${x.y}`).join(" "),fill:"none",stroke:"#1f5f85",strokeWidth:"4",strokeLinejoin:"round",strokeLinecap:"round"}),g&&a.jsx("line",{x1:g.x,y1:u,x2:g.x,y2:u+l,stroke:"#1f5f85",strokeDasharray:"3 4",opacity:"0.45"}),m.map((x,b)=>a.jsxs("g",{children:[a.jsx("circle",{cx:x.x,cy:x.y,r:n===b?7:5,fill:"#1f5f85",stroke:"white",strokeWidth:"2"}),a.jsx("text",{x:x.x,y:o-17,textAnchor:"middle",fill:"currentColor",className:"text-[11px] text-muted-foreground",children:x.label})]},x.key))]}),g&&a.jsxs("div",{className:"pointer-events-none absolute z-20 min-w-44 rounded-lg border bg-popover p-3 text-popover-foreground shadow-xl",style:{left:`${g.x/s*100}%`,top:`${Math.max(g.y/o*100-4,2)}%`,transform:g.x>s*.75?"translate(-100%, -100%)":"translate(-50%, -100%)"},children:[a.jsx("p",{className:"text-xs font-semibold",children:g.label}),a.jsx("p",{className:"mt-1 text-sm font-bold text-primary",children:X(g.value,t)}),g.details?.slice(0,5).map(x=>a.jsxs("div",{className:"mt-1 flex justify-between gap-4 text-xs",children:[a.jsx("span",{className:"max-w-40 truncate text-muted-foreground",children:x.label}),a.jsx("span",{children:X(x.value,t)})]},x.label))]})]})}const _o=e=>e.length>16?`${e.slice(0,14)}...`:e,Yh=(e,t)=>new Intl.NumberFormat("en-US",{style:"currency",currency:t||"USD",notation:"compact",maximumFractionDigits:1}).format(e);function Jh({title:e,items:t,currency:n}){const o={top:38,right:18,bottom:72,left:76},i=720-o.left-o.right,c=320-o.top-o.bottom,u=Math.max(...t.map(l=>l.amount),1),f=i/t.length,d=Math.min(56,f*.58);return a.jsxs("svg",{viewBox:"0 0 720 320",className:"h-80 w-full",role:"img","aria-label":`${e} cost bar chart`,children:[[0,.25,.5,.75,1].map(l=>{const h=o.top+c-l*c;return a.jsxs("g",{children:[a.jsx("line",{x1:o.left,y1:h,x2:720-o.right,y2:h,stroke:"currentColor",opacity:l===0?.3:.12,vectorEffect:"non-scaling-stroke"}),a.jsx("text",{x:o.left-12,y:h+4,textAnchor:"end",fill:"currentColor",opacity:"0.7",fontSize:"11",children:Yh(u*l,n)})]},l)}),a.jsx("line",{x1:o.left,y1:o.top,x2:o.left,y2:o.top+c,stroke:"currentColor",opacity:"0.3",vectorEffect:"non-scaling-stroke"}),t.map((l,h)=>{const m=o.left+f*h+f/2,g=Math.max(l.amount/u*c,3),p=o.top+c-g;return a.jsxs("g",{tabIndex:0,"aria-label":`${l.label}: ${X(l.amount,n)}`,className:"outline-none focus-visible:opacity-75",children:[a.jsxs("title",{children:[l.label,": ",X(l.amount,n)]}),a.jsx("rect",{x:m-d/2,y:p,width:d,height:g,rx:"4",className:"fill-primary opacity-80 transition-opacity hover:opacity-100"}),a.jsx("text",{x:m,y:Math.max(p-8,16),textAnchor:"middle",fill:"currentColor",fontSize:"11",fontWeight:"600",children:X(l.amount,n)}),a.jsx("text",{x:m,y:278,textAnchor:"middle",fill:"currentColor",opacity:"0.72",fontSize:"11",children:_o(l.label)}),l.accountId&&a.jsx("text",{x:m,y:295,textAnchor:"middle",fill:"currentColor",opacity:"0.55",fontSize:"9",children:_o(l.accountId)})]},l.key||l.label)}),a.jsxs("text",{x:"18",y:o.top+c/2,transform:`rotate(-90 18 ${o.top+c/2})`,textAnchor:"middle",fill:"currentColor",opacity:"0.65",fontSize:"11",children:["Cost (",n,")"]})]})}const Ai="min-h-32 transition-all duration-200 ease-out hover:-translate-y-1 hover:scale-[1.01] hover:border-primary/30 hover:shadow-lg";function kr({title:e,icon:t,items:n,currency:r}){const[s,o]=P.useState("chart"),i=n.slice(0,6),c=Math.max(...i.map(u=>u.amount),1);return a.jsxs(ue,{className:"min-w-0",children:[a.jsxs(Re,{className:"flex flex-row items-center justify-between gap-3 pb-3",children:[a.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[a.jsx("span",{className:"text-primary",children:t}),a.jsx(Pe,{className:"truncate text-sm",children:e})]}),a.jsxs("div",{className:"flex rounded-md border p-0.5","aria-label":`${e} view`,children:[a.jsx("button",{type:"button",onClick:()=>o("chart"),"aria-label":`Show ${e} as bar chart`,"aria-pressed":s==="chart",title:"Bar chart",className:`rounded p-1.5 ${s==="chart"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(mf,{className:"h-4 w-4"})}),a.jsx("button",{type:"button",onClick:()=>o("list"),"aria-label":`Show ${e} as list`,"aria-pressed":s==="list",title:"List",className:`rounded p-1.5 ${s==="list"?"bg-primary text-primary-foreground":"text-muted-foreground hover:bg-muted"}`,children:a.jsx(If,{className:"h-4 w-4"})})]})]}),a.jsx(de,{children:i.length?s==="chart"?a.jsx(Jh,{title:e,items:i,currency:r}):a.jsx("div",{className:"space-y-3",children:i.map(u=>a.jsxs("div",{className:"space-y-1",children:[a.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[a.jsxs("span",{className:"truncate text-muted-foreground",title:u.label,children:[u.label,u.accountId?a.jsxs("span",{className:"ml-1 text-xs",children:["(",u.accountId,")"]}):null]}),a.jsx("span",{className:"shrink-0 font-medium",children:X(u.amount,r)})]}),a.jsx("div",{className:"h-1.5 overflow-hidden rounded-full bg-muted",children:a.jsx("div",{className:"h-full rounded-full bg-primary/75",style:{width:`${u.amount/c*100}%`}})})]},u.key||u.label))}):a.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No cost data for this period."})})]})}function Xh(){return a.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"contents",children:[a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:Array.from({length:4},(e,t)=>a.jsxs(ue,{className:Ai,children:[a.jsx(Re,{className:"pb-2",children:a.jsx("div",{className:"h-3 w-24 animate-pulse rounded bg-muted"})}),a.jsxs(de,{children:[a.jsx("div",{className:"h-6 w-3/4 animate-pulse rounded bg-muted"}),a.jsx("div",{className:"mt-3 h-3 w-1/2 animate-pulse rounded bg-muted/80"})]})]},t))}),a.jsxs(ue,{children:[a.jsx(Re,{children:a.jsx("div",{className:"h-4 w-36 animate-pulse rounded bg-muted"})}),a.jsx(de,{children:a.jsx("div",{className:"h-72 animate-pulse rounded-lg bg-muted/70"})})]}),a.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:Array.from({length:3},(e,t)=>a.jsxs(ue,{children:[a.jsx(Re,{children:a.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-muted"})}),a.jsx(de,{className:"space-y-4",children:Array.from({length:5},(n,r)=>a.jsxs("div",{children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("div",{className:"h-3 w-2/5 animate-pulse rounded bg-muted"}),a.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"})]}),a.jsx("div",{className:"mt-2 h-1.5 animate-pulse rounded bg-muted/80"})]},r))})]},t))})]})}function Zh({data:e,period:t,selectedMonth:n}){const r=e.topServices[0],s=e.topAccounts[0],o=new Date,[i,c]=n.split("-").map(Number),u=t==="monthly"?new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(i,c-1,1)):String(o.getFullYear()),f=[{label:"Total cost",value:a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"block",children:X(e.totalCost,e.currency)}),a.jsxs("span",{className:"mt-1 block text-sm font-medium text-muted-foreground",children:["Accounts: ",e.activeAccounts]})]}),helper:u,icon:a.jsx(ii,{})},{label:"Active resources",value:e.activeResources==null?a.jsx("span",{className:"text-sm",title:e.activeResourcesMessage,children:"CUR access required"}):Number(e.activeResources).toLocaleString(),helper:`${u} across all accounts`,icon:a.jsx(Jn,{})},{label:"Highest cost service",value:r?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Service - ${r.label}
|
|
15
15
|
Cost - ${X(r.amount,e.currency)}`}):"-",helper:u,icon:a.jsx(ui,{})},{label:"Highest cost account",value:s?a.jsx("span",{className:"whitespace-pre-line text-sm",children:`Account Name - ${s.label}
|
|
16
16
|
Account Id - ${s.accountId||s.key||"Unknown"}
|
|
17
|
-
Cost - ${X(s.amount,e.currency)}`}):"-",helper:u,icon:a.jsx(Jn,{})}];return a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:f.map(d=>a.jsxs(ue,{className:Ai,children:[a.jsxs(Re,{className:"flex flex-row items-center justify-between pb-2",children:[a.jsx(Pe,{className:"text-xs font-medium text-muted-foreground",children:d.label}),a.jsx("span",{className:"text-muted-foreground [&>svg]:h-4 [&>svg]:w-4",children:d.icon})]}),a.jsxs(de,{children:[a.jsx("div",{className:"break-words text-base font-semibold leading-snug xl:text-lg",children:d.value}),a.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:d.helper})]})]},d.label))})}function Qh(){const e=new Date,t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,[n,r]=P.useState(null),[s,o]=P.useState(!0),[i,c]=P.useState(null),[u,f]=P.useState(null),[d,l]=P.useState("monthly"),[h,m]=P.useState(t),{managementAccountId:g,loading:p}=$t(),x=P.useRef(0),b=Array.from({length:e.getMonth()+1},(j,_)=>({value:`${e.getFullYear()}-${String(_+1).padStart(2,"0")}`,label:new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(e.getFullYear(),_,1))})),y=async(j=d,_=h,C=g)=>{const R=++x.current;o(!0),r(null),c(null);try{let k;if(j==="yearly")k={period:j,start:`${e.getFullYear()}-01-01`};else{const[O,$]=_.split("-").map(Number),J=_===t?e.getDate():new Date(O,$,0).getDate();k={period:j,start:`${_}-01`,end:`${_}-${String(J).padStart(2,"0")}`}}const L=C?{managementAccountId:C}:void 0,A=await oe.getDataStatus(L);if(R===x.current&&f(A),!A.ready)return;const D=await oe.getOverview({...k,...L});R===x.current&&r(D)}catch(k){R===x.current&&c(k?.response?.data?.error||k.message||"Failed to load AWS costs")}finally{R===x.current&&o(!1)}};return P.useEffect(()=>{p||y(d,h,g)},[d,h,g,p]),{data:n,dataStatus:u,loading:s||p,error:i,period:d,selectedMonth:h,monthOptions:b,changePeriod:j=>{j!==d&&(o(!0),r(null),l(j))},changeMonth:j=>{j===h||!b.some(_=>_.value===j)||(o(!0),r(null),m(j))},refresh:()=>y(d,h,g)}}function em(){const{data:e,dataStatus:t,loading:n,error:r,period:s,selectedMonth:o,monthOptions:i,changePeriod:c,changeMonth:u,refresh:f}=Qh();return a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(ii,{className:"h-6 w-6 text-primary"}),"Cloud Cost Management"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Costs for the selected AWS management account and its member accounts"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ar,{}),s==="monthly"&&a.jsx("select",{"aria-label":"Cost month",value:o,onChange:d=>u(d.target.value),disabled:n,className:"rounded-lg border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:i.map(d=>a.jsx("option",{value:d.value,children:d.label},d.value))}),a.jsx("div",{className:"flex rounded-lg border p-1",children:["monthly","yearly"].map(d=>a.jsx("button",{onClick:()=>c(d),className:`rounded-md px-3 py-1.5 text-sm capitalize transition-colors ${s===d?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:d},d))}),a.jsx("button",{onClick:()=>{f()},disabled:n,className:"rounded-lg border p-2 hover:bg-muted",children:a.jsx(Tt,{className:`h-4 w-4 ${n?"animate-spin":""}`})})]})]}),r&&e&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),r]}),n?a.jsx(Xh,{}):t&&!t.ready?a.jsx(Zn,{status:t}):r&&!e?a.jsx(Zn,{status:t,error:r}):e?a.jsxs(a.Fragment,{children:[e.dataSource&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[a.jsx("span",{children:"Source: AWS CUR via SaaS Athena - gross positive unblended charges"}),a.jsxs("span",{children:["CUR: Ready",t?.lastDataAt?`, updated ${new Date(t.lastDataAt).toLocaleString()}`:""]})]}),a.jsx(Zh,{data:e,period:s,selectedMonth:o}),e.message&&!/historical data beyond 14 months/i.test(e.message)&&a.jsx(ue,{children:a.jsx(de,{className:"py-8 text-center text-sm text-muted-foreground",children:e.message})}),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row items-center gap-2",children:[a.jsx(hi,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Cost Trend - ",s==="monthly"?"Monthly":"Yearly"]})]}),a.jsx(de,{children:a.jsx(Kh,{points:e.trends.map(d=>({key:d.month,label:s==="yearly"?d.month.slice(0,4):new Date(`${d.month}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",year:"2-digit"}),value:d.amount})),currency:e.currency})})]}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsx(kr,{title:"Top services",icon:a.jsx(ui,{className:"h-4 w-4"}),items:e.topServices,currency:e.currency}),a.jsx(kr,{title:"AWS accounts",icon:a.jsx(si,{className:"h-4 w-4"}),items:e.topAccounts,currency:e.currency}),a.jsx(kr,{title:"Regional distribution",icon:a.jsx(Ff,{className:"h-4 w-4"}),items:e.topRegions,currency:e.currency})]})]}):null]})}const Sn=["#6264e9","#eb67ad","#31c39a","#f29a05","#579bea","#9078ed","#f7842c","#24b9ad","#8ac926","#ffca3a","#6a4c93","#1982c4"];function ko(e,t){const n=new Date(e.length===10?`${e}T00:00:00Z`:e);return Number.isFinite(n.getTime())?n.toLocaleDateString(void 0,t?{month:"short",day:"numeric",year:"numeric"}:{month:"short",year:"numeric"}):e}function tm({timeline:e,currency:t="USD",daily:n=!1}){const[r,s]=P.useState(null),[o,i]=P.useState(null),c=P.useMemo(()=>{const g=new Map;for(const p of e)for(const x of p.groups)g.set(x.label,(g.get(x.label)||0)+x.amount);return[...g.entries()].sort((p,x)=>x[1]-p[1]).map(([p],x)=>({label:p,color:Sn[x%Sn.length]}))},[e]),u=new Map(c.map(g=>[g.label,g.color])),f=Math.max(...e.map(g=>g.total),1),d=r??o,l=d==null?null:e[d],h=n?52:80,m=Math.max(520,e.length*h);return e.length?a.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_288px]",onMouseLeave:()=>s(null),children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"grid min-h-80 min-w-0 grid-cols-[72px_minmax(0,1fr)] gap-3",children:[a.jsx("div",{className:"flex h-64 flex-col justify-between pb-1 text-right text-[11px] text-muted-foreground",children:[1,.75,.5,.25,0].map(g=>a.jsx("span",{children:X(f*g,t)},g))}),a.jsx("div",{className:"min-w-0 overflow-x-auto pb-2",children:a.jsxs("div",{style:{width:m},children:[a.jsxs("div",{className:"relative flex h-64 items-end border-b px-4",children:[[0,25,50,75].map(g=>a.jsx("span",{className:"pointer-events-none absolute left-0 right-0 border-t border-dashed border-slate-200",style:{top:`${g}%`}},g)),e.map((g,p)=>a.jsx("button",{type:"button",onMouseEnter:()=>s(p),onMouseLeave:()=>s(null),onPointerDown:x=>x.preventDefault(),onFocus:()=>i(p),onBlur:()=>i(null),className:"group z-10 flex h-full shrink-0 items-end justify-center px-2 outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{width:h},children:a.jsx("span",{className:"flex w-full max-w-16 flex-col-reverse overflow-hidden rounded-t-sm shadow-sm transition group-hover:brightness-95",style:{height:`${Math.max(g.total/f*100,1)}%`},children:g.groups.map(x=>a.jsx("span",{style:{backgroundColor:u.get(x.label)||Sn[0],height:`${g.total?x.amount/g.total*100:0}%`}},x.key||x.label))})},`${g.start}-${p}`))]}),a.jsx("div",{className:"flex px-4 pt-2",children:e.map((g,p)=>a.jsx("span",{className:"shrink-0 whitespace-nowrap text-center text-[11px] text-muted-foreground",style:{width:h},children:ko(g.start,n)},`${g.start}-label-${p}`))})]})})]}),a.jsxs("div",{className:"mt-5 flex flex-wrap gap-x-4 gap-y-2",children:[c.slice(0,8).map(g=>a.jsxs("span",{className:"flex items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:g.color}}),g.label]},g.label)),c.length>8&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",c.length-8," more"]})]})]}),a.jsx("aside",{"aria-live":"polite",className:"min-h-44",children:l?a.jsxs("div",{role:"tooltip",className:"rounded-2xl border bg-popover p-4 text-popover-foreground shadow-lg",children:[a.jsx("p",{className:"font-semibold",children:ko(l.start,n)}),a.jsxs("div",{className:"mt-3 space-y-2",children:[[...l.groups].sort((g,p)=>p.amount-g.amount).slice(0,5).map(g=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:u.get(g.label)||Sn[0]}}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),a.jsx("strong",{children:X(g.amount,t)})]},g.key||g.label)),l.groups.length>5&&a.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["+ ",l.groups.length-5," others"]})]}),a.jsxs("div",{className:"mt-3 flex justify-between border-t pt-3 text-sm",children:[a.jsx("strong",{children:"Total"}),a.jsx("strong",{className:"text-primary",children:X(l.total,t)})]})]}):a.jsx("div",{className:"flex min-h-44 items-center justify-center rounded-2xl border border-dashed p-4 text-center text-xs text-muted-foreground",children:"Hover over a bar to view its cost details."})})]}):a.jsx("p",{className:"py-24 text-center text-sm text-muted-foreground",children:"No trend data for this period."})}function nm({rows:e,currency:t}){const n=e.slice(0,8),r=Math.max(1,...n.flatMap(s=>[s.current?.amount||0,s.previous?.amount||0]));return a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm",children:"Comparison Overview"})}),a.jsx(de,{children:a.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[a.jsx("div",{className:"flex h-72 items-end gap-4 border-b border-l px-4 pt-4",children:n.map(s=>a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-center",children:[a.jsxs("div",{className:"flex h-56 w-full items-end justify-center gap-1",children:[a.jsx("div",{title:`Current: ${X(s.current?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-indigo-500",style:{height:`${Math.max((s.current?.amount||0)/r*100,s.current?.amount?1:0)}%`}}),a.jsx("div",{title:`Previous: ${X(s.previous?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-pink-400",style:{height:`${Math.max((s.previous?.amount||0)/r*100,s.previous?.amount?1:0)}%`}})]}),a.jsx("span",{title:s.label,className:"mt-2 w-full truncate text-center text-[10px] text-muted-foreground",children:s.label})]},s.key))}),a.jsxs("div",{className:"mt-4 flex gap-5 text-xs",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-indigo-500"}),"Current Period"]}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-pink-400"}),"Previous Period"]})]})]})})]})}function Me({label:e,value:t,helper:n,accent:r=!1,trend:s}){return a.jsxs("div",{className:"rounded-xl border bg-card p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[s!=null&&(s<0?a.jsx(Kf,{className:"h-4 w-4 text-red-500"}):a.jsx(hi,{className:"h-4 w-4 text-emerald-500"})),a.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:e})]}),a.jsx("p",{className:`mt-2 text-2xl font-bold ${r?"text-primary":s!=null&&s<0?"text-red-500":""}`,children:t}),n&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})}function Rn({label:e,options:t,selected:n,onChange:r}){const s=n.length?`${n.length} selected`:e;return a.jsxs("details",{className:"group relative",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between rounded-lg border bg-background px-3 py-3 text-sm text-primary",children:[a.jsx("span",{children:s}),a.jsx(gf,{className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),a.jsx("div",{className:"absolute z-30 mt-1 max-h-64 w-full overflow-auto rounded-lg border bg-popover p-2 shadow-xl",children:t.length?t.map(o=>a.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded px-2 py-2 text-xs hover:bg-muted",children:[a.jsx("input",{type:"checkbox",checked:n.includes(o.value),onChange:i=>r(i.target.checked?[...n,o.value]:n.filter(c=>c!==o.value))}),a.jsx("span",{className:"min-w-0 break-words",children:o.label})]},o.value)):a.jsx("p",{className:"p-2 text-xs text-muted-foreground",children:"No values available."})})]})}function rm(){return a.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"space-y-5",children:[a.jsxs("section",{className:"rounded-xl bg-primary/5 p-5",children:[a.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-primary",children:[a.jsx(ct,{className:"h-5 w-5 animate-spin"}),"Loading live AWS cost report..."]}),a.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[1,2,3].map(e=>a.jsx("div",{className:"h-28 animate-pulse rounded-xl border bg-card/70"},e))})]}),a.jsx("div",{className:"h-80 animate-pulse rounded-xl border bg-muted/40"}),a.jsx("div",{className:"h-64 animate-pulse rounded-xl border bg-muted/40"})]})}const Xe=10,Jr=new Date,Oi=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,sm=Oi(new Date(Jr.getFullYear(),Jr.getMonth()-2,1)),om=Oi(Jr),Yt={services:[],regions:[],accountIds:[],tagKey:"",tagValues:[]},ht={service:{tab:"Services",title:"Service Cost Summary",pdfTitle:"Service Cost Report",top:"Top service cost",count:"Service count",item:"Service",empty:"No service cost data found."},account:{tab:"Accounts",title:"Account Cost Summary",pdfTitle:"Account Cost Report",top:"Top account cost",count:"Account count",item:"Linked account",empty:"No linked account cost data found."},region:{tab:"Regions",title:"Regional Cost Summary",pdfTitle:"Region Cost Report",top:"Top region cost",count:"Region count",item:"Region",empty:"No regional cost data found."},resource:{tab:"Resources",title:"Resource Cost Summary",pdfTitle:"Resource Cost Report",top:"Top resource cost",count:"Resource count",item:"Resource",empty:"Resource-level cost data requires resource IDs in the CUR export."},tag:{tab:"Tags",title:"Tag Cost Summary",pdfTitle:"Tag Cost Report",top:"Top tag value cost",count:"Tag value count",item:"Tag value",empty:"No cost allocation tag data found."}};function Po(e){return e?new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"longOffset"}).format(new Date(e)).replace("GMT","UTC"):"Not updated yet"}function Ao(e,t){const n=new Date(`${e}T00:00:00Z`);if(t==="monthly"){const s=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)),i=new Date(s);i.setUTCDate(i.getUTCDate()-1);const c=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1));return{currentStart:s.toISOString().slice(0,10),currentEnd:o.toISOString().slice(0,10),previousStart:c.toISOString().slice(0,10),previousEnd:i.toISOString().slice(0,10)}}const r=new Date(n);return r.setUTCDate(r.getUTCDate()-1),{currentStart:e,currentEnd:e,previousStart:r.toISOString().slice(0,10),previousEnd:r.toISOString().slice(0,10)}}function It(e,t,n){const r=new Date(`${e}T00:00:00Z`),s=new Date(`${t}T00:00:00Z`);if(n==="monthly"&&r.getUTCFullYear()===s.getUTCFullYear()&&r.getUTCMonth()===s.getUTCMonth())return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(r);const o=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});return`${o.format(r)} – ${o.format(s)}`}function am(e){const t=new Map;return e.current.summary.forEach(n=>t.set(n.key||n.label,{current:n})),e.previous.summary.forEach(n=>{const r=n.key||n.label;t.set(r,{...t.get(r),previous:n})}),[...t.entries()].map(([n,r])=>{const s=r.current?.amount||0,o=r.previous?.amount||0,i=s-o;return{key:n,label:r.current?.label||r.previous?.label||n,...r,difference:i,change:o?i/Math.abs(o)*100:0}}).sort((n,r)=>Math.max(r.current?.amount||0,r.previous?.amount||0)-Math.max(n.current?.amount||0,n.previous?.amount||0))}function rt(e){return e?.length?e.map(t=>`${t.label}
|
|
17
|
+
Cost - ${X(s.amount,e.currency)}`}):"-",helper:u,icon:a.jsx(Jn,{})}];return a.jsx("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,240px),1fr))] gap-4",children:f.map(d=>a.jsxs(ue,{className:Ai,children:[a.jsxs(Re,{className:"flex flex-row items-center justify-between pb-2",children:[a.jsx(Pe,{className:"text-xs font-medium text-muted-foreground",children:d.label}),a.jsx("span",{className:"text-muted-foreground [&>svg]:h-4 [&>svg]:w-4",children:d.icon})]}),a.jsxs(de,{children:[a.jsx("div",{className:"break-words text-base font-semibold leading-snug xl:text-lg",children:d.value}),a.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:d.helper})]})]},d.label))})}function Qh(){const e=new Date,t=`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`,[n,r]=P.useState(null),[s,o]=P.useState(!0),[i,c]=P.useState(null),[u,f]=P.useState(null),[d,l]=P.useState("monthly"),[h,m]=P.useState(t),{managementAccountId:g,loading:p}=$t(),x=P.useRef(0),b=Array.from({length:e.getMonth()+1},(j,_)=>({value:`${e.getFullYear()}-${String(_+1).padStart(2,"0")}`,label:new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric"}).format(new Date(e.getFullYear(),_,1))})),y=async(j=d,_=h,C=g)=>{const R=++x.current;o(!0),r(null),c(null);try{let k;if(j==="yearly")k={period:j,start:`${e.getFullYear()}-01-01`};else{const[O,$]=_.split("-").map(Number),J=_===t?e.getDate():new Date(O,$,0).getDate();k={period:j,start:`${_}-01`,end:`${_}-${String(J).padStart(2,"0")}`}}const L=C?{managementAccountId:C}:void 0,A=await oe.getDataStatus(L);if(R===x.current&&f(A),!A.ready)return;const D=await oe.getOverview({...k,...L});R===x.current&&r(D)}catch(k){R===x.current&&c(k?.response?.data?.error||k.message||"Failed to load AWS costs")}finally{R===x.current&&o(!1)}};return P.useEffect(()=>{p||y(d,h,g)},[d,h,g,p]),{data:n,dataStatus:u,loading:s||p,error:i,period:d,selectedMonth:h,monthOptions:b,changePeriod:j=>{j!==d&&(o(!0),r(null),l(j))},changeMonth:j=>{j===h||!b.some(_=>_.value===j)||(o(!0),r(null),m(j))},refresh:()=>y(d,h,g)}}function em(){const{data:e,dataStatus:t,loading:n,error:r,period:s,selectedMonth:o,monthOptions:i,changePeriod:c,changeMonth:u,refresh:f}=Qh();return a.jsxs("div",{className:"flex w-full flex-col gap-6 p-2 md:p-6",children:[a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[a.jsxs("div",{children:[a.jsxs("h1",{className:"flex items-center gap-2 text-2xl font-bold",children:[a.jsx(ii,{className:"h-6 w-6 text-primary"}),"Cloud Cost Management"]}),a.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Costs for the selected AWS management account and its member accounts"})]}),a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx(ar,{}),s==="monthly"&&a.jsx("select",{"aria-label":"Cost month",value:o,onChange:d=>u(d.target.value),disabled:n,className:"rounded-lg border bg-background px-3 py-2 text-sm shadow-sm disabled:opacity-50",children:i.map(d=>a.jsx("option",{value:d.value,children:d.label},d.value))}),a.jsx("div",{className:"flex rounded-lg border p-1",children:["monthly","yearly"].map(d=>a.jsx("button",{onClick:()=>c(d),className:`rounded-md px-3 py-1.5 text-sm capitalize transition-colors ${s===d?"bg-primary text-primary-foreground":"hover:bg-muted"}`,children:d},d))}),a.jsx("button",{onClick:()=>{f()},disabled:n,className:"rounded-lg border p-2 hover:bg-muted",children:a.jsx(Tt,{className:`h-4 w-4 ${n?"animate-spin":""}`})})]})]}),r&&e&&a.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive",children:[a.jsx(ze,{className:"h-4 w-4"}),r]}),n?a.jsx(Xh,{}):t&&!t.ready?a.jsx(Zn,{status:t}):r&&!e?a.jsx(Zn,{status:t,error:r}):e?a.jsxs(a.Fragment,{children:[e.dataSource&&a.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[a.jsx("span",{children:"Source: AWS CUR via SaaS Athena - gross positive unblended charges"}),a.jsxs("span",{children:["CUR: Ready",t?.lastDataAt?`, updated ${new Date(t.lastDataAt).toLocaleString()}`:""]})]}),a.jsx(Zh,{data:e,period:s,selectedMonth:o}),e.message&&!/historical data beyond 14 months/i.test(e.message)&&a.jsx(ue,{children:a.jsx(de,{className:"py-8 text-center text-sm text-muted-foreground",children:e.message})}),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row items-center gap-2",children:[a.jsx(hi,{className:"h-4 w-4 text-primary"}),a.jsxs(Pe,{className:"text-sm",children:["Cost Trend - ",s==="monthly"?"Monthly":"Yearly"]})]}),a.jsx(de,{children:a.jsx(Kh,{points:e.trends.map(d=>({key:d.month,label:s==="yearly"?d.month.slice(0,4):new Date(`${d.month}T00:00:00Z`).toLocaleDateString(void 0,{month:"short",year:"2-digit"}),value:d.amount})),currency:e.currency})})]}),a.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[a.jsx(kr,{title:"Top services",icon:a.jsx(ui,{className:"h-4 w-4"}),items:e.topServices,currency:e.currency}),a.jsx(kr,{title:"AWS accounts",icon:a.jsx(si,{className:"h-4 w-4"}),items:e.topAccounts,currency:e.currency}),a.jsx(kr,{title:"Regional distribution",icon:a.jsx(Ff,{className:"h-4 w-4"}),items:e.topRegions,currency:e.currency})]})]}):null]})}const Sn=["#6264e9","#eb67ad","#31c39a","#f29a05","#579bea","#9078ed","#f7842c","#24b9ad","#8ac926","#ffca3a","#6a4c93","#1982c4"];function ko(e,t){const n=new Date(e.length===10?`${e}T00:00:00Z`:e);return Number.isFinite(n.getTime())?n.toLocaleDateString(void 0,t?{month:"short",day:"numeric"}:{month:"short",year:"numeric"}):e}function tm({timeline:e,currency:t="USD",daily:n=!1}){const[r,s]=P.useState(null),[o,i]=P.useState(null),c=P.useMemo(()=>{const g=new Map;for(const p of e)for(const x of p.groups)g.set(x.label,(g.get(x.label)||0)+x.amount);return[...g.entries()].sort((p,x)=>x[1]-p[1]).map(([p],x)=>({label:p,color:Sn[x%Sn.length]}))},[e]),u=new Map(c.map(g=>[g.label,g.color])),f=Math.max(...e.map(g=>g.total),1),d=r??o,l=d==null?null:e[d],h=n?52:80,m=Math.max(520,e.length*h);return e.length?a.jsxs("div",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_288px]",onMouseLeave:()=>s(null),children:[a.jsxs("div",{className:"min-w-0",children:[a.jsxs("div",{className:"grid min-h-80 min-w-0 grid-cols-[72px_minmax(0,1fr)] gap-3",children:[a.jsx("div",{className:"flex h-64 flex-col justify-between pb-1 text-right text-[11px] text-muted-foreground",children:[1,.75,.5,.25,0].map(g=>a.jsx("span",{children:X(f*g,t)},g))}),a.jsx("div",{className:"min-w-0 overflow-x-auto pb-2",children:a.jsxs("div",{style:{width:m},children:[a.jsxs("div",{className:"relative flex h-64 items-end border-b px-4",children:[[0,25,50,75].map(g=>a.jsx("span",{className:"pointer-events-none absolute left-0 right-0 border-t border-dashed border-slate-200",style:{top:`${g}%`}},g)),e.map((g,p)=>a.jsx("button",{type:"button",onMouseEnter:()=>s(p),onMouseLeave:()=>s(null),onPointerDown:x=>x.preventDefault(),onFocus:()=>i(p),onBlur:()=>i(null),className:"group z-10 flex h-full shrink-0 items-end justify-center px-2 outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{width:h},children:a.jsx("span",{className:"flex w-full max-w-16 flex-col-reverse overflow-hidden rounded-t-sm shadow-sm transition group-hover:brightness-95",style:{height:`${Math.max(g.total/f*100,1)}%`},children:g.groups.map(x=>a.jsx("span",{style:{backgroundColor:u.get(x.label)||Sn[0],height:`${g.total?x.amount/g.total*100:0}%`}},x.key||x.label))})},`${g.start}-${p}`))]}),a.jsx("div",{className:"flex px-4 pt-2",children:e.map((g,p)=>a.jsx("span",{className:"shrink-0 whitespace-nowrap text-center text-[11px] text-muted-foreground",style:{width:h},children:ko(g.start,n)},`${g.start}-label-${p}`))})]})})]}),a.jsxs("div",{className:"mt-5 flex min-w-0 flex-wrap gap-x-4 gap-y-2",children:[c.slice(0,8).map(g=>a.jsxs("span",{className:"flex max-w-full min-w-0 items-center gap-1.5 text-xs",children:[a.jsx("span",{className:"h-2.5 w-2.5 shrink-0 rounded-full",style:{backgroundColor:g.color}}),a.jsx("span",{className:"min-w-0 truncate",title:g.label,children:g.label})]},g.label)),c.length>8&&a.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",c.length-8," more"]})]})]}),a.jsx("aside",{"aria-live":"polite",className:"min-h-44",children:l?a.jsxs("div",{role:"tooltip",className:"rounded-2xl border bg-popover p-4 text-popover-foreground shadow-lg",children:[a.jsx("p",{className:"font-semibold",children:ko(l.start,n)}),a.jsxs("div",{className:"mt-3 space-y-2",children:[[...l.groups].sort((g,p)=>p.amount-g.amount).slice(0,5).map(g=>a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[a.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:u.get(g.label)||Sn[0]}}),a.jsx("span",{className:"min-w-0 flex-1 truncate",children:g.label}),a.jsx("strong",{children:X(g.amount,t)})]},g.key||g.label)),l.groups.length>5&&a.jsxs("p",{className:"text-xs italic text-muted-foreground",children:["+ ",l.groups.length-5," others"]})]}),a.jsxs("div",{className:"mt-3 flex justify-between border-t pt-3 text-sm",children:[a.jsx("strong",{children:"Total"}),a.jsx("strong",{className:"text-primary",children:X(l.total,t)})]})]}):a.jsx("div",{className:"flex min-h-44 items-center justify-center rounded-2xl border border-dashed p-4 text-center text-xs text-muted-foreground",children:"Hover over a bar to view its cost details."})})]}):a.jsx("p",{className:"py-24 text-center text-sm text-muted-foreground",children:"No trend data for this period."})}function nm({rows:e,currency:t}){const n=e.slice(0,8),r=Math.max(1,...n.flatMap(s=>[s.current?.amount||0,s.previous?.amount||0]));return a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm",children:"Comparison Overview"})}),a.jsx(de,{children:a.jsxs("div",{className:"rounded-xl border bg-card p-5",children:[a.jsx("div",{className:"flex h-72 items-end gap-4 border-b border-l px-4 pt-4",children:n.map(s=>a.jsxs("div",{className:"flex min-w-0 flex-1 flex-col items-center",children:[a.jsxs("div",{className:"flex h-56 w-full items-end justify-center gap-1",children:[a.jsx("div",{title:`Current: ${X(s.current?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-indigo-500",style:{height:`${Math.max((s.current?.amount||0)/r*100,s.current?.amount?1:0)}%`}}),a.jsx("div",{title:`Previous: ${X(s.previous?.amount||0,t)}`,className:"w-1/3 max-w-10 rounded-t bg-pink-400",style:{height:`${Math.max((s.previous?.amount||0)/r*100,s.previous?.amount?1:0)}%`}})]}),a.jsx("span",{title:s.label,className:"mt-2 w-full truncate text-center text-[10px] text-muted-foreground",children:s.label})]},s.key))}),a.jsxs("div",{className:"mt-4 flex gap-5 text-xs",children:[a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-indigo-500"}),"Current Period"]}),a.jsxs("span",{className:"flex items-center gap-2",children:[a.jsx("i",{className:"h-2.5 w-2.5 rounded-full bg-pink-400"}),"Previous Period"]})]})]})})]})}function Me({label:e,value:t,helper:n,accent:r=!1,trend:s}){return a.jsxs("div",{className:"rounded-xl border bg-card p-5 shadow-sm",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[s!=null&&(s<0?a.jsx(Kf,{className:"h-4 w-4 text-red-500"}):a.jsx(hi,{className:"h-4 w-4 text-emerald-500"})),a.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:e})]}),a.jsx("p",{className:`mt-2 text-2xl font-bold ${r?"text-primary":s!=null&&s<0?"text-red-500":""}`,children:t}),n&&a.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:n})]})}function Rn({label:e,options:t,selected:n,onChange:r}){const s=n.length?`${n.length} selected`:e;return a.jsxs("details",{className:"group relative",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between rounded-lg border bg-background px-3 py-3 text-sm text-primary",children:[a.jsx("span",{children:s}),a.jsx(gf,{className:"h-4 w-4 transition-transform group-open:rotate-180"})]}),a.jsx("div",{className:"absolute z-30 mt-1 max-h-64 w-full overflow-auto rounded-lg border bg-popover p-2 shadow-xl",children:t.length?t.map(o=>a.jsxs("label",{className:"flex cursor-pointer items-start gap-2 rounded px-2 py-2 text-xs hover:bg-muted",children:[a.jsx("input",{type:"checkbox",checked:n.includes(o.value),onChange:i=>r(i.target.checked?[...n,o.value]:n.filter(c=>c!==o.value))}),a.jsx("span",{className:"min-w-0 break-words",children:o.label})]},o.value)):a.jsx("p",{className:"p-2 text-xs text-muted-foreground",children:"No values available."})})]})}function rm(){return a.jsxs("div",{"aria-live":"polite","aria-busy":"true",className:"space-y-5",children:[a.jsxs("section",{className:"rounded-xl bg-primary/5 p-5",children:[a.jsxs("div",{className:"flex items-center gap-3 text-sm font-medium text-primary",children:[a.jsx(ct,{className:"h-5 w-5 animate-spin"}),"Loading live AWS cost report..."]}),a.jsx("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[1,2,3].map(e=>a.jsx("div",{className:"h-28 animate-pulse rounded-xl border bg-card/70"},e))})]}),a.jsx("div",{className:"h-80 animate-pulse rounded-xl border bg-muted/40"}),a.jsx("div",{className:"h-64 animate-pulse rounded-xl border bg-muted/40"})]})}const Xe=10,Jr=new Date,Oi=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`,sm=Oi(new Date(Jr.getFullYear(),Jr.getMonth()-2,1)),om=Oi(Jr),Yt={services:[],regions:[],accountIds:[],tagKey:"",tagValues:[]},ht={service:{tab:"Services",title:"Service Cost Summary",pdfTitle:"Service Cost Report",top:"Top service cost",count:"Service count",item:"Service",empty:"No service cost data found."},account:{tab:"Accounts",title:"Account Cost Summary",pdfTitle:"Account Cost Report",top:"Top account cost",count:"Account count",item:"Linked account",empty:"No linked account cost data found."},region:{tab:"Regions",title:"Regional Cost Summary",pdfTitle:"Region Cost Report",top:"Top region cost",count:"Region count",item:"Region",empty:"No regional cost data found."},resource:{tab:"Resources",title:"Resource Cost Summary",pdfTitle:"Resource Cost Report",top:"Top resource cost",count:"Resource count",item:"Resource",empty:"Resource-level cost data requires resource IDs in the CUR export."},tag:{tab:"Tags",title:"Tag Cost Summary",pdfTitle:"Tag Cost Report",top:"Top tag value cost",count:"Tag value count",item:"Tag value",empty:"No cost allocation tag data found."}};function Po(e){return e?new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"longOffset"}).format(new Date(e)).replace("GMT","UTC"):"Not updated yet"}function Ao(e,t){const n=new Date(`${e}T00:00:00Z`);if(t==="monthly"){const s=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth(),1)),o=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)),i=new Date(s);i.setUTCDate(i.getUTCDate()-1);const c=new Date(Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),1));return{currentStart:s.toISOString().slice(0,10),currentEnd:o.toISOString().slice(0,10),previousStart:c.toISOString().slice(0,10),previousEnd:i.toISOString().slice(0,10)}}const r=new Date(n);return r.setUTCDate(r.getUTCDate()-1),{currentStart:e,currentEnd:e,previousStart:r.toISOString().slice(0,10),previousEnd:r.toISOString().slice(0,10)}}function It(e,t,n){const r=new Date(`${e}T00:00:00Z`),s=new Date(`${t}T00:00:00Z`);if(n==="monthly"&&r.getUTCFullYear()===s.getUTCFullYear()&&r.getUTCMonth()===s.getUTCMonth())return new Intl.DateTimeFormat("en-US",{month:"long",year:"numeric",timeZone:"UTC"}).format(r);const o=new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"});return`${o.format(r)} – ${o.format(s)}`}function am(e){const t=new Map;return e.current.summary.forEach(n=>t.set(n.key||n.label,{current:n})),e.previous.summary.forEach(n=>{const r=n.key||n.label;t.set(r,{...t.get(r),previous:n})}),[...t.entries()].map(([n,r])=>{const s=r.current?.amount||0,o=r.previous?.amount||0,i=s-o;return{key:n,label:r.current?.label||r.previous?.label||n,...r,difference:i,change:o?i/Math.abs(o)*100:0}}).sort((n,r)=>Math.max(r.current?.amount||0,r.previous?.amount||0)-Math.max(n.current?.amount||0,n.previous?.amount||0))}function rt(e){return e?.length?e.map(t=>`${t.label}
|
|
18
18
|
${X(t.amount,"USD")}`).join(`
|
|
19
19
|
`):"—"}function Oo({values:e}){const[t,n]=P.useState(!1);return a.jsxs("div",{className:"relative",children:[a.jsxs("button",{type:"button",onClick:()=>n(r=>!r),className:"inline-flex items-center gap-2 text-primary",children:[a.jsx("span",{className:"rounded-full bg-primary/10 px-2 py-1 text-xs font-semibold",children:e.length}),a.jsx("span",{children:"›"})]}),t&&a.jsxs("div",{className:"absolute right-0 top-8 z-20 w-72 rounded-lg border bg-popover p-3 shadow-xl",children:[a.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[a.jsx("strong",{className:"text-xs",children:"Cost distribution"}),a.jsx("button",{onClick:()=>n(!1),children:a.jsx(Lt,{className:"h-3.5 w-3.5"})})]}),e.length?e.map(r=>a.jsxs("div",{className:"flex justify-between gap-3 border-t py-2 text-xs",children:[a.jsx("span",{className:"min-w-0 truncate",title:r.label,children:r.label}),a.jsx("strong",{children:X(r.amount,"USD")})]},r.key)):a.jsx("p",{className:"text-xs text-muted-foreground",children:"No related values."})]})]})}function Ti({page:e,pages:t,total:n,onChange:r}){const s=n?(e-1)*Xe+1:0,o=Math.min(e*Xe,n);return a.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t px-4 py-4 text-xs text-muted-foreground",children:[a.jsxs("span",{children:["Showing ",s,"–",o," of ",n]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("button",{"aria-label":"Previous page",disabled:e<=1,onClick:()=>r(e-1),className:"rounded-md border p-1.5 disabled:opacity-40",children:a.jsx(bf,{className:"h-4 w-4"})}),a.jsxs("span",{children:["Page ",e," of ",t]}),a.jsx("button",{"aria-label":"Next page",disabled:e>=t,onClick:()=>r(e+1),className:"rounded-md border p-1.5 disabled:opacity-40",children:a.jsx(vf,{className:"h-4 w-4"})})]})]})}function im({groupBy:e,report:t}){const[n,r]=P.useState(""),[s,o]=P.useState(1),[i,c]=P.useState(null),[u,f]=P.useState({percentage:!0,accounts:!0,regions:!0}),d=ht[e],l=P.useMemo(()=>{const p=n.trim().toLowerCase();return p?t.summary.filter(x=>`${x.label} ${x.accountId||""}`.toLowerCase().includes(p)):t.summary},[t,n]),h=Math.max(1,Math.ceil(l.length/Xe)),m=l.slice((s-1)*Xe,s*Xe),g=3+Number(u.percentage)+Number(u.accounts)+Number(u.regions);return P.useEffect(()=>{o(1)},[t,n,e]),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row flex-wrap items-center justify-between gap-3",children:[a.jsx(Pe,{className:"text-sm text-primary",children:"Cost and usage breakdown"}),a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs("label",{className:"flex items-center gap-2 rounded-full border bg-background px-4 py-2 text-sm",children:[a.jsx(hs,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("input",{"aria-label":"Search breakdown",value:n,onChange:p=>r(p.target.value),placeholder:"Search...",className:"w-48 bg-transparent outline-none"})]}),a.jsxs("details",{className:"relative",children:[a.jsxs("summary",{className:"flex cursor-pointer list-none items-center gap-2 rounded-md border px-3 py-2 text-sm text-primary",children:[a.jsx(di,{className:"h-4 w-4"}),"Column visibility"]}),a.jsx("div",{className:"absolute right-0 z-20 mt-1 w-48 rounded-md border bg-popover p-3 shadow-xl",children:Object.entries(u).map(([p,x])=>a.jsxs("label",{className:"flex gap-2 py-1 text-xs capitalize",children:[a.jsx("input",{type:"checkbox",checked:x,onChange:b=>f(y=>({...y,[p]:b.target.checked}))}),p]},p))})]})]})]}),a.jsx(de,{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-primary/5 text-left text-xs uppercase text-primary",children:[a.jsx("th",{className:"px-4 py-4",children:d.item}),a.jsx("th",{className:"px-4",children:"Cost"}),u.percentage&&a.jsx("th",{className:"px-4",children:"Percentage"}),u.accounts&&a.jsx("th",{className:"px-4",children:"Accounts"}),u.regions&&a.jsx("th",{className:"px-4",children:"Regions"}),a.jsx("th",{className:"px-4 text-center",children:"Actions"})]})}),a.jsx("tbody",{children:m.length?m.map(p=>a.jsxs("tr",{className:"border-b last:border-0",children:[a.jsxs("td",{className:"max-w-72 px-4 py-4 font-medium",children:[a.jsx("div",{className:"truncate",title:p.label,children:p.label}),e==="account"&&a.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:p.accountId||p.key})]}),a.jsx("td",{className:"px-4 font-semibold",children:X(p.amount,t.currency)}),u.percentage&&a.jsxs("td",{className:"px-4",children:[a.jsx("span",{className:"mr-2 inline-block h-1.5 w-12 overflow-hidden rounded-full bg-primary/15 align-middle",children:a.jsx("span",{className:"block h-full bg-primary",style:{width:`${Math.min(p.percentage||0,100)}%`}})}),a.jsxs("strong",{className:"text-primary",children:[p.percentage?.toFixed(2),"%"]})]}),u.accounts&&a.jsx("td",{className:"px-4",children:a.jsx(Oo,{values:p.accounts||[]})}),u.regions&&a.jsx("td",{className:"px-4",children:a.jsx(Oo,{values:p.regions||[]})}),a.jsx("td",{className:"px-4 text-center",children:a.jsx("button",{type:"button",onClick:()=>c(p),title:"View cost details",className:"text-primary hover:opacity-70",children:a.jsx(Pf,{className:"h-4 w-4"})})})]},p.key||p.label)):a.jsx("tr",{children:a.jsx("td",{colSpan:g,className:"py-12 text-center text-muted-foreground",children:d.empty})})})]})}),a.jsx(Ti,{page:s,pages:h,total:l.length,onChange:o}),i&&a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",onClick:()=>c(null),children:a.jsxs("div",{className:"max-h-[80vh] w-full max-w-2xl overflow-auto rounded-xl bg-card p-6 shadow-2xl",onClick:p=>p.stopPropagation(),children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-xs uppercase text-muted-foreground",children:d.item}),a.jsx("h3",{className:"mt-1 text-lg font-semibold",children:i.label})]}),a.jsx("button",{onClick:()=>c(null),children:a.jsx(Lt,{})})]}),a.jsxs("div",{className:"mt-5 grid gap-3 sm:grid-cols-3",children:[a.jsx(Me,{label:"Cost",value:X(i.amount,t.currency)}),a.jsx(Me,{label:"Accounts",value:String(i.accounts?.length||0)}),a.jsx(Me,{label:"Regions",value:String(i.regions?.length||0)})]}),a.jsxs("div",{className:"mt-5 grid gap-5 sm:grid-cols-2",children:[a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Accounts"}),(i.accounts||[]).map(p=>a.jsxs("div",{className:"flex justify-between border-t py-2 text-xs",children:[a.jsx("span",{children:p.label}),a.jsx("strong",{children:X(p.amount,t.currency)})]},p.key))]}),a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-sm font-semibold",children:"Regions"}),(i.regions||[]).map(p=>a.jsxs("div",{className:"flex justify-between border-t py-2 text-xs",children:[a.jsx("span",{children:p.label}),a.jsx("strong",{children:X(p.amount,t.currency)})]},p.key))]})]})]})})]})}function cm({rows:e,groupBy:t,comparison:n,granularity:r}){const[s,o]=P.useState(""),[i,c]=P.useState(1),u=P.useMemo(()=>{const m=s.trim().toLowerCase();return m?e.filter(g=>g.label.toLowerCase().includes(m)):e},[e,s]),f=Math.max(1,Math.ceil(u.length/Xe)),d=u.slice((i-1)*Xe,i*Xe),l=It(n.currentStart,n.currentEnd,r),h=It(n.previousStart,n.previousEnd,r);return P.useEffect(()=>{c(1)},[s,t,n]),a.jsxs(ue,{children:[a.jsxs(Re,{className:"flex flex-row flex-wrap items-center justify-between gap-3",children:[a.jsx(Pe,{className:"text-sm text-primary",children:"Comparison Details"}),a.jsxs("label",{className:"flex items-center gap-2 rounded-full border bg-background px-4 py-2 text-sm",children:[a.jsx(hs,{className:"h-4 w-4 text-muted-foreground"}),a.jsx("input",{"aria-label":"Search comparison",value:s,onChange:m=>o(m.target.value),placeholder:"Search...",className:"w-48 bg-transparent outline-none"})]})]}),a.jsx(de,{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b bg-primary/5 text-left text-xs uppercase text-primary",children:[a.jsxs("th",{className:"px-4 py-4",children:[ht[t].item," name"]}),a.jsxs("th",{className:"px-4",children:[l,a.jsx("small",{className:"block font-normal",children:"Cost"})]}),a.jsxs("th",{className:"px-4",children:[h,a.jsx("small",{className:"block font-normal",children:"Cost"})]}),a.jsx("th",{className:"px-4",children:"Difference"}),a.jsx("th",{className:"px-4",children:"Change %"})]})}),a.jsx("tbody",{children:d.length?d.map(m=>a.jsxs("tr",{className:"border-b",children:[a.jsx("td",{className:"max-w-80 px-4 py-4 font-medium",children:a.jsx("div",{className:"truncate",title:m.label,children:m.label})}),a.jsx("td",{className:"px-4",children:X(m.current?.amount||0,n.current.currency)}),a.jsx("td",{className:"px-4",children:X(m.previous?.amount||0,n.previous.currency)}),a.jsxs("td",{className:`px-4 font-medium ${m.difference<0?"text-red-500":"text-emerald-600"}`,children:[m.difference>=0?"+":"",X(m.difference,n.current.currency)]}),a.jsxs("td",{className:`px-4 font-medium ${m.change<0?"text-red-500":m.change>0?"text-emerald-600":"text-muted-foreground"}`,children:[m.change>0?"+":"",m.change.toFixed(1),"%"]})]},m.key)):a.jsx("tr",{children:a.jsx("td",{colSpan:5,className:"py-12 text-center text-muted-foreground",children:"No comparison data found."})})})]})}),a.jsx(Ti,{page:i,pages:f,total:u.length,onChange:c})]})}function lm(e){const{mode:t,groupBy:n,start:r,end:s,granularity:o,reportTagKey:i,options:c,filters:u,loading:f,filtersLoading:d,comparisonPeriods:l}=e;return a.jsxs("aside",{className:"space-y-4",children:[a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm uppercase text-primary",children:"Report parameters"})}),a.jsxs(de,{className:"space-y-4",children:[a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>e.onModeChange("standard"),className:`rounded-md px-4 py-2 text-xs font-semibold ${t==="standard"?"bg-primary text-primary-foreground":"border text-primary"}`,children:"Standard"}),a.jsx("button",{onClick:()=>e.onModeChange("compare"),className:`rounded-md px-4 py-2 text-xs font-semibold ${t==="compare"?"bg-primary text-primary-foreground":"border text-primary"}`,children:"Compare"})]}),t==="standard"&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Start date",a.jsx("input",{type:"date",value:r,onChange:h=>e.onStartChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground"})]}),a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["End date",a.jsx("input",{type:"date",value:s,onChange:h=>e.onEndChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground"})]})]}),a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Granularity",a.jsxs("select",{value:o,onChange:h=>e.onGranularityChange(h.target.value),className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground",children:[a.jsx("option",{value:"monthly",children:"Monthly"}),a.jsx("option",{value:"daily",children:"Daily"})]})]}),t==="compare"&&a.jsxs("p",{className:"rounded-md bg-background p-2 text-xs text-muted-foreground",children:["Current: ",l.currentStart," to ",l.currentEnd,a.jsx("br",{}),"Previous: ",l.previousStart," to ",l.previousEnd]}),n==="tag"&&a.jsxs("label",{className:"block text-xs text-muted-foreground",children:["Group by tag key",a.jsxs("select",{value:c.tagKeys.includes(i)?i:"",onChange:h=>e.onReportTagKeyChange(h.target.value),disabled:!c.tagKeys.length,className:"mt-1 w-full rounded-md border bg-background p-2 text-sm text-foreground disabled:opacity-60",children:[a.jsx("option",{value:"",children:d?"Loading tag keys...":"Select a tag key"}),c.tagKeys.map(h=>a.jsx("option",{children:h},h))]}),!d&&!c.tagKeys.length&&a.jsx("span",{className:"mt-2 block text-xs text-muted-foreground",children:"No activated AWS cost allocation tags are present in this CUR data."})]}),a.jsxs("button",{onClick:e.onRun,disabled:f||n==="tag"&&!c.tagKeys.length,className:"flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:[a.jsx(Tt,{className:`h-4 w-4 ${f?"animate-spin":""}`}),"Run report"]})]})]}),a.jsxs(ue,{className:"bg-primary/5",children:[a.jsx(Re,{children:a.jsx(Pe,{className:"text-sm uppercase text-primary",children:"Filter by"})}),a.jsxs(de,{className:"space-y-3",children:[a.jsx(Rn,{label:"Services",options:c.services,selected:u.services,onChange:h=>e.onFiltersChange(m=>({...m,services:h}))}),a.jsx(Rn,{label:"Region",options:c.regions,selected:u.regions,onChange:h=>e.onFiltersChange(m=>({...m,regions:h}))}),a.jsx(Rn,{label:"Linked Account",options:c.accounts,selected:u.accountIds,onChange:h=>e.onFiltersChange(m=>({...m,accountIds:h}))}),a.jsxs("select",{value:u.tagKey,onChange:h=>{const m=h.target.value;e.onFiltersChange(g=>({...g,tagKey:m,tagValues:[]})),m&&e.onLoadTagValues(m)},className:"w-full rounded-lg border bg-background px-3 py-3 text-sm text-primary",children:[a.jsx("option",{value:"",children:"Tag key"}),c.tagKeys.map(h=>a.jsx("option",{children:h},h))]}),u.tagKey&&a.jsx(Rn,{label:"Tag values",options:c.tagValues.map(h=>({value:h,label:h})),selected:u.tagValues,onChange:h=>e.onFiltersChange(m=>({...m,tagValues:h}))}),a.jsxs("div",{className:"grid grid-cols-2 gap-2 pt-2",children:[a.jsx("button",{onClick:e.onApply,disabled:d||f,className:"rounded-md bg-primary px-3 py-2 text-sm font-semibold text-primary-foreground disabled:opacity-50",children:"Apply Filters"}),a.jsx("button",{onClick:e.onReset,disabled:f,className:"rounded-md border bg-background px-3 py-2 text-sm text-primary disabled:opacity-50",children:"Reset"})]})]})]})]})}function um(){const{managementAccountId:e,loading:t}=$t(),[n,r]=P.useState("service"),[s,o]=P.useState("standard"),[i,c]=P.useState(sm),[u,f]=P.useState(om),[d,l]=P.useState("monthly"),[h,m]=P.useState("Name"),[g,p]=P.useState({services:[],regions:[],accounts:[],tagKeys:[],tagValues:[]}),[x,b]=P.useState(Yt),[y,v]=P.useState(Yt),[N,j]=P.useState(null),[_,C]=P.useState(null),[R,k]=P.useState(!0),[L,A]=P.useState(!1),[D,O]=P.useState(null),[$,J]=P.useState(null),Y=P.useRef(0),Q=P.useMemo(()=>_?am(_):[],[_]),he=Ao(u,d),me=(U,Z,V,ie)=>({start:Z,end:V,groupBy:ie,granularity:d,tagKey:h,services:U.services.join(","),regions:U.regions.join(","),accountIds:U.accountIds.join(","),filterTagKey:U.tagKey||void 0,tagValues:U.tagValues.join(","),managementAccountId:e}),I=async(U="")=>{A(!0);try{const Z=await oe.getDataStatus({managementAccountId:e});if(J(Z),!Z.ready)return;const V=await oe.getFilterOptions({start:i,end:u,filterTagKey:U||void 0,managementAccountId:e});p(ie=>U?{...ie,tagValues:V.tagValues}:V),!U&&V.tagKeys.length&&!V.tagKeys.includes(h)&&m(V.tagKeys[0])}catch(Z){O(Z?.response?.data?.error||Z.message||"Failed to load filter values")}finally{A(!1)}},E=async(U=y,Z=s,V=n)=>{const ie=++Y.current;k(!0),O(null),j(null),C(null);try{const le=await oe.getDataStatus({managementAccountId:e});if(ie===Y.current&&J(le),!le.ready)return;if(Z==="compare"){const te=Ao(u,d),[je,Ce]=await Promise.all([oe.getReports(me(U,te.currentStart,te.currentEnd,V)),oe.getReports(me(U,te.previousStart,te.previousEnd,V))]);ie===Y.current&&(j(je),C({current:je,previous:Ce,...te}))}else{const te=await oe.getReports(me(U,i,u,V));ie===Y.current&&j(te)}}catch(le){ie===Y.current&&O(le?.response?.data?.error||le.message||"Failed to generate cost report")}finally{ie===Y.current&&k(!1)}};return P.useEffect(()=>{t||(J(null),p({services:[],regions:[],accounts:[],tagKeys:[],tagValues:[]}),E(y,s,n),I())},[e,t]),{groupBy:n,mode:s,start:i,end:u,granularity:d,reportTagKey:h,options:g,draftFilters:x,report:N,comparison:_,loading:R||t,filtersLoading:L,error:D,dataStatus:$,comparedRows:Q,selectedComparisonPeriods:he,setStart:c,setEnd:f,setGranularity:l,setReportTagKey:m,setDraftFilters:b,changeGroup:U=>{U!==n&&(k(!0),j(null),C(null),r(U),E(y,s,U))},changeMode:U=>{U!==s&&(k(!0),j(null),C(null),o(U),E(y,U,n))},applyFilters:()=>{const U={...x,services:[...x.services],regions:[...x.regions],accountIds:[...x.accountIds],tagValues:[...x.tagValues]};v(U),E(U)},resetFilters:()=>{b(Yt),v(Yt),E(Yt)},runReport:()=>{I(),E()},loadOptions:I}}function dm(e){const{report:t,comparison:n,rows:r,groupBy:s,mode:o,start:i,end:c}=e,u=ht[s];let f,d;o==="compare"&&n?(f=[[u.item,"Current Cost","Previous Cost","Difference","Change %"].join(","),...r.map(h=>[`"${h.label.replace(/"/g,'""')}"`,h.current?.amount||0,h.previous?.amount||0,h.difference,h.change.toFixed(2)].join(","))].join(`
|
|
20
20
|
`),d=`comparison-report-${s}-${Date.now()}.csv`):(f=[[u.item,"Cost","Percentage","Accounts","Regions"].join(","),...t.summary.map(h=>[`"${h.label.replace(/"/g,'""')}"`,h.amount,h.percentage||0,h.accounts?.length||0,h.regions?.length||0].join(","))].join(`
|
package/dist/index.mjs
CHANGED
|
@@ -10117,7 +10117,7 @@ function im() {
|
|
|
10117
10117
|
const jn = ["#6264e9", "#eb67ad", "#31c39a", "#f29a05", "#579bea", "#9078ed", "#f7842c", "#24b9ad", "#8ac926", "#ffca3a", "#6a4c93", "#1982c4"];
|
|
10118
10118
|
function Lo(e, t) {
|
|
10119
10119
|
const n = new Date(e.length === 10 ? `${e}T00:00:00Z` : e);
|
|
10120
|
-
return Number.isFinite(n.getTime()) ? n.toLocaleDateString(void 0, t ? { month: "short", day: "numeric"
|
|
10120
|
+
return Number.isFinite(n.getTime()) ? n.toLocaleDateString(void 0, t ? { month: "short", day: "numeric" } : { month: "short", year: "numeric" }) : e;
|
|
10121
10121
|
}
|
|
10122
10122
|
function cm({ timeline: e, currency: t = "USD", daily: n = !1 }) {
|
|
10123
10123
|
const [r, s] = U(null), [o, i] = U(null), c = un(() => {
|
|
@@ -10137,10 +10137,10 @@ function cm({ timeline: e, currency: t = "USD", daily: n = !1 }) {
|
|
|
10137
10137
|
/* @__PURE__ */ a.jsx("div", { className: "flex px-4 pt-2", children: e.map((g, p) => /* @__PURE__ */ a.jsx("span", { className: "shrink-0 whitespace-nowrap text-center text-[11px] text-muted-foreground", style: { width: h }, children: Lo(g.start, n) }, `${g.start}-label-${p}`)) })
|
|
10138
10138
|
] }) })
|
|
10139
10139
|
] }),
|
|
10140
|
-
/* @__PURE__ */ a.jsxs("div", { className: "mt-5 flex flex-wrap gap-x-4 gap-y-2", children: [
|
|
10141
|
-
c.slice(0, 8).map((g) => /* @__PURE__ */ a.jsxs("span", { className: "flex items-center gap-1.5 text-xs", children: [
|
|
10142
|
-
/* @__PURE__ */ a.jsx("span", { className: "h-2.5 w-2.5 rounded-full", style: { backgroundColor: g.color } }),
|
|
10143
|
-
g.label
|
|
10140
|
+
/* @__PURE__ */ a.jsxs("div", { className: "mt-5 flex min-w-0 flex-wrap gap-x-4 gap-y-2", children: [
|
|
10141
|
+
c.slice(0, 8).map((g) => /* @__PURE__ */ a.jsxs("span", { className: "flex max-w-full min-w-0 items-center gap-1.5 text-xs", children: [
|
|
10142
|
+
/* @__PURE__ */ a.jsx("span", { className: "h-2.5 w-2.5 shrink-0 rounded-full", style: { backgroundColor: g.color } }),
|
|
10143
|
+
/* @__PURE__ */ a.jsx("span", { className: "min-w-0 truncate", title: g.label, children: g.label })
|
|
10144
10144
|
] }, g.label)),
|
|
10145
10145
|
c.length > 8 && /* @__PURE__ */ a.jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
10146
10146
|
"+",
|