1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,12863,e=>{"use strict";var a=e.i(843476),t=e.i(283599),l=e.i(822315),s=e.i(952598),o=e.i(632418),n=e.i(720926),i=e.i(271645),r=e.i(819646),d=e.i(723897),u=e.i(591052),c=e.i(904896),g=e.i(514570),x=e.i(210332),m=e.i(117693),f=e.i(3626),h=e.i(103737),p=e.i(210557),b=e.i(961974),y=e.i(571604),j=e.i(577164),v=e.i(860386),k=e.i(402044);e.i(932966);var L=e.i(114282),w=e.i(807780);e.i(206126);var D=e.i(914028),C=e.i(484452),N=e.i(996418);e.i(399232);var I=e.i(329907);e.i(186786);var P=e.i(785556),T=e.i(719240),$=e.i(155524),F=e.i(746533),S=e.i(394544),W=e.i(845679),K=e.i(100614),O=e.i(869799),R=e.i(212401),z=e.i(443090),M=e.i(126863);e.i(559231);let q=/^[A-Za-z0-9\u3400-\u9FFF][A-Za-z0-9\u3400-\u9FFF\s-]*$/;function A(e){return"string"==typeof e&&e.trim()?e.trim():"number"==typeof e&&Number.isFinite(e)?String(e):""}function B(e,a,t){let l=e.other,s=A(l?.reason),o=A(l?.reject_reason),n=2===e.type,i=5===e.type,r=n||i;return[r&&e.requestId?{label:a("usageLogs.detail.requestId"),value:e.requestId}:null,n?{label:a("usageLogs.detail.totalCost"),value:function(e,a,t=!1){return function(e,a,t=!1){let l,s=function(e,a=!1){let t=e>0&&e<1e-4?1e-4:Number(e.toFixed(12));return(0,k.fNumber)(t,{maximumFractionDigits:4,...a?{minimumFractionDigits:4}:{}})}(e,t&&"TOKENS"!==a.quotaDisplayType);return"TOKENS"===a.quotaDisplayType?s:"USD"===a.quotaDisplayType?`$${s}`:"CNY"===a.quotaDisplayType?`\xa5${s}`:(l=a.customCurrencySymbol.trim())?q.test(l)?`${s} ${l}`:`${l}${s}`:s}((0,k.quotaToDisplayAmount)(e,a),a,t)}(e.quota,t,!0)}:null,r&&e.modelName?{label:a("usageLogs.table.model"),value:e.modelName}:null,r?{label:a("usageLogs.table.time"),value:(0,j.fDateTime)(e.createdAt)}:null,r&&e.tokenName?{label:a("usageLogs.table.token"),value:e.tokenName}:null,i&&e.content?{label:a("usageLogs.detail.content"),value:e.content,fullWidth:!0}:null,n||i||!e.content?null:{label:a("usageLogs.detail.content"),value:e.content,fullWidth:!0},o?{label:a("usageLogs.detail.rejectedReason"),value:o,fullWidth:!0}:null,s?{label:a("usageLogs.detail.failureReason"),value:s,fullWidth:!0}:null].filter(e=>null!==e)}String.raw`[\d.eE+-]+`,[{key:"p",labelKey:"usageLogs.detail.inputTokens",tone:"primary"},{key:"c",labelKey:"usageLogs.detail.outputTokens",tone:"secondary"},{key:"cr",labelKey:"usageLogs.detail.cacheReadTokens",tone:"success"},{key:"cc",labelKey:"usageLogs.detail.cacheWriteTokens",tone:"warning"},{key:"cc1h",labelKey:"usageLogs.detail.cacheWriteTokens1h",tone:"warning"},{key:"img",labelKey:"usageLogs.detail.imageInputFormulaLabel",tone:"info"},{key:"img_o",labelKey:"usageLogs.detail.imageOutputFormulaLabel",tone:"info"},{key:"ai",labelKey:"usageLogs.detail.audioInputFormulaLabel",tone:"info"},{key:"ao",labelKey:"usageLogs.detail.audioOutputFormulaLabel",tone:"info"}].map(e=>e.key);var U=e.i(95131);e.i(899068);var E=e.i(800103);e.i(46034);var _=e.i(463652),G=e.i(757484);let H={0:{labelKey:"usageLogs.type.unknown",color:"default"},1:{labelKey:"usageLogs.type.recharge",color:"info"},2:{labelKey:"usageLogs.type.consume",color:"success"},3:{labelKey:"usageLogs.type.manage",color:"warning"},4:{labelKey:"usageLogs.type.system",color:"error"},5:{labelKey:"usageLogs.type.error",color:"error"},6:{labelKey:"usageLogs.type.refund",color:"info"}};function V({row:e,quotaConfig:t}){let{t:l}=(0,L.useTranslate)("dashboard"),s=(0,n.useBoolean)(),o=H[e.type]||H[0],i=2===e.type,d=5===e.type,u=i||d,c=B(e,l,t),g=c.find(e=>e.label===l("usageLogs.detail.requestId")),x=c.filter(e=>e.label!==l("usageLogs.detail.requestId")),f=c.length>0,p=f?{cursor:"pointer"}:void 0,b=()=>{f&&s.onToggle()},y=e=>(0,a.jsx)(h.default,{align:e,onClick:b,sx:p});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(m.default,{hover:!0,onKeyDown:e=>{f&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),s.onToggle())},role:f?"button":void 0,tabIndex:f?0:void 0,"aria-expanded":f?s.value:void 0,sx:p,children:[(0,a.jsx)(h.default,{onClick:b,sx:p,children:(0,a.jsxs)(K.default,{direction:"row",spacing:1,alignItems:"center",children:[f&&(0,a.jsx)(z.default,{size:"small",onClick:e=>
1{e.stopPropagation(),s.onToggle()},"aria-label":s.value?l("usageLogs.expand.collapseAriaLabel"):l("usageLogs.expand.expandAriaLabel"),children:(0,a.jsx)(E.Iconify,{icon:s.value?"eva:arrow-ios-upward-fill":"eva:arrow-ios-downward-fill",width:18})}),(0,a.jsx)(M.default,{variant:"body2",noWrap:!0,children:(0,j.fDateTime)(e.createdAt)})]})}),u?(0,a.jsx)(h.default,{onClick:b,sx:p,children:(0,a.jsx)(W.default,{label:e.tokenName||"-",size:"small",variant:"soft"})}):y(),(0,a.jsx)(h.default,{onClick:b,sx:p,children:(0,a.jsx)(W.default,{label:l(o.labelKey),size:"small",color:o.color})}),u?(0,a.jsx)(h.default,{onClick:b,sx:{...p},children:(0,a.jsx)(_.ModelChip,{modelName:e.modelName||"-",icon:(0,U.getModelIconName)((0,U.getProviderFromModelName)(e.modelName))})}):y(),u?(0,a.jsx)(h.default,{align:"right",onClick:b,sx:p,children:(0,a.jsx)(M.default,{variant:"body2",sx:{color:"error.main",fontWeight:e=>e.typography.subtitle2.fontWeight},children:(0,G.formatUsageLogCostValue)(e.quota,t)})}):y("right"),(0,a.jsx)(h.default,{align:"right",onClick:b,sx:p,children:e.content?(0,a.jsx)(O.default,{title:e.content,placement:"top",arrow:!0,children:(0,a.jsx)(M.default,{variant:"body2",sx:{color:"text.secondary",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",textAlign:"right",textOverflow:"ellipsis",wordBreak:"break-word"},children:e.content})}):(0,a.jsx)(M.default,{variant:"body2",sx:{color:"text.disabled"},children:"-"})})]}),f?(0,a.jsx)(m.default,{children:(0,a.jsx)(h.default,{sx:{p:0,border:"none"},colSpan:6,children:(0,a.jsx)(R.default,{in:s.value,timeout:"auto",unmountOnExit:!0,sx:{bgcolor:"background.neutral"},children:(0,a.jsxs)(r.default,{sx:{px:2,py:1.5},children:[(0,a.jsx)(r.default,{sx:{display:"grid",columnGap:3,rowGap:1.25,gridTemplateColumns:{xs:"1fr",md:"repeat(2, minmax(0, 1fr))"}},children:x.map(e=>(0,a.jsxs)(r.default,{sx:{minWidth:0,gridColumn:e.fullWidth?"1 / -1":void 0},children:[(0,a.jsx)(M.default,{variant:"caption",sx:{color:"text.secondary"},children:e.label}),(0,a.jsx)(M.default,{variant:"body2",sx:{mt:.25,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.value})]},e.label))}),g?(0,a.jsx)(M.default,{variant:"caption",title:`${g.label}: ${g.value}`,noWrap:!0,sx:{mt:.75*!!x.length,display:"block",color:"text.disabled"},children:`${g.label}: ${g.value}`}):null]})})})}):null]})}var Q=e.i(781974),Z=e.i(524167),Y=e.i(839126);e.i(190118);var J=e.i(33334);e.i(387024);var X=e.i(840891),ee=e.i(147039);let ea={0:{labelKey:"usageLogs.type.unknown",color:"default"},1:{labelKey:"usageLogs.type.recharge",color:"info"},2:{labelKey:"usageLogs.type.consume",color:"success"},3:{labelKey:"usageLogs.type.manage",color:"warning"},4:{labelKey:"usageLogs.type.system",color:"error"},5:{labelKey:"usageLogs.type.error",color:"error"},6:{labelKey:"usageLogs.type.refund",color:"info"}};function et({row:e,quotaConfig:t}){let{t:l}=(0,L.useTranslate)("dashboard"),{t:s}=(0,L.useTranslate)("api-key"),o=(0,n.useBoolean)(),d=ea[e.type]||ea[0],u=2===e.type,c=5===e.type,g=u||c,x=B(e,l,t),m=x.find(e=>e.label===l("usageLogs.detail.requestId")),f=x.filter(e=>e.label!==l("usageLogs.detail.requestId")),h=x.length>0,p=e.tokenName||e.requestId||e.channelName,b=(0,U.getModelIconName)((0,U.getProviderFromModelName)(e.modelName)),y=e.modelName||l(d.labelKey),v=(0,G.getUsageLogHeaderQuotaUnit)(t),k=v?l("usageLogs.table.costWithUnit",{unit:v}):l("usageLogs.table.cost"),w=(0,G.formatUsageLogCostValue)(e.quota,t),D=(0,i.useCallback)(()=>{h&&o.onTrue()},[o,h]),C=(0,i.useCallback)(e=>{h&&("Enter"===e.key||" "===e.key)&&(e.preventDefault(),o.onTrue())},[o,h]),N={icon:(0,a.jsx)(E.Iconify,{icon:"solar:bill-list-bold",width:14}),content:(0,a.jsx)(r.default,{component:"span",sx:{color:"error.main",fontWeight:e=>e.typography.subtitle2.fontWeight},children:`${k} ${w}`})},I=u?[N]:c?[{icon:(0,a.jsx)(E.Iconify,{icon:"solar:file-text-bold",width:14}),content:e.content?(0,a.jsx)(r.default,{component:"span",sx:{display:"-webkit-box",overflow:"hidden",textOverflow:"ellipsis",WebkitLineClamp:2,WebkitBoxOrient:"vertical",wordBreak:"break-word"},children:`${l("usageLogs.table.details")} ${e.content}`}):`${l("usageLogs.table.details")} -`,fullWidth:!0,wrap:!0}]:[{icon:(0,a.jsx)(E.Iconify,{icon:"solar:key-bold",width:14}),content:`${l("usageLogs.table.token")} ${e.tokenName||"-"}`},{icon:(0,a.jsx)(E.Iconify,{icon:"solar:bill-list-bold",width:14}),content:`${k} ${w}`},{icon:(0,a.jsx)(E.Iconify,{icon:"solar:box-minimalistic-bold",width:14}),content:`${l("usageLogs.table.model")} ${e.modelName||"-"}`,fullWidth:!0,wrap:!0},{icon:(0,a.jsx)(E.Iconify,{icon:"solar:monitor-bold",width:14}),content:`${l("usageLogs.table.channel")} ${e.channelName||"-"}`},{icon:(0,a.jsx)(E.Iconify,{icon:"solar:file-text-bold",width:14}),content:e.content?(0,a.jsx)(r.default,{component:"span",sx:{dis
1play:"-webkit-box",overflow:"hidden",textOverflow:"ellipsis",WebkitLineClamp:2,WebkitBoxOrient:"vertical",wordBreak:"break-word"},children:`${l("usageLogs.table.details")} ${e.content}`}):`${l("usageLogs.table.details")} -`,fullWidth:!0,wrap:!0}];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ee.MobileDataCard,{avatar:(0,a.jsx)(X.ModelIcon,{size:48,iconSize:24,icon:b,name:y}),title:g&&e.modelName||l(d.labelKey),subtitle:`${l("usageLogs.table.time")} ${(0,j.fDateTime)(e.createdAt)}`,accent:p?(0,a.jsx)(r.default,{component:"span",sx:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p}):void 0,badge:(0,a.jsx)(J.Label,{variant:"soft",color:d.color,children:l(d.labelKey)}),onClick:h?D:void 0,onKeyDown:h?C:void 0,role:h?"button":void 0,tabIndex:h?0:void 0,sx:h?{cursor:"pointer",transition:e=>e.transitions.create(["border-color","box-shadow"],{duration:e.transitions.duration.shorter})}:void 0,items:I,footer:h?(0,a.jsx)(r.default,{sx:{display:"flex",justifyContent:"flex-end"},children:(0,a.jsxs)(r.default,{sx:e=>({px:1,py:.375,gap:.5,display:"inline-flex",alignItems:"center",borderRadius:99,color:"text.secondary",typography:"caption",border:`solid 1px ${e.vars.palette.divider}`,bgcolor:"background.paper"}),children:[(0,a.jsx)(r.default,{component:"span",children:l("usageLogs.table.details")}),(0,a.jsx)(E.Iconify,{icon:"eva:arrow-ios-forward-fill",width:11})]})}):void 0}),(0,a.jsxs)(Q.default,{open:o.value,onClose:o.onFalse,maxWidth:"sm",fullWidth:!0,PaperProps:{sx:{borderRadius:4,backgroundImage:"none"}},children:[(0,a.jsxs)(Z.default,{sx:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,pb:2},children:[(0,a.jsxs)(r.default,{sx:{minWidth:0},children:[(0,a.jsx)(M.default,{variant:"h6",noWrap:!0,children:g&&e.modelName||l(d.labelKey)}),(0,a.jsx)(M.default,{variant:"body2",sx:{mt:.5,color:"text.secondary"},children:(0,j.fDateTime)(e.createdAt)})]}),(0,a.jsx)(z.default,{onClick:o.onFalse,sx:{color:"text.secondary"},"aria-label":s("usage.close"),children:(0,a.jsx)(E.Iconify,{icon:"mingcute:close-line",width:18})})]}),(0,a.jsxs)(Y.default,{sx:{pb:3},children:[(0,a.jsx)(r.default,{sx:{display:"grid",gap:1.25},children:f.map(e=>(0,a.jsxs)(r.default,{sx:{minWidth:0},children:[(0,a.jsx)(M.default,{variant:"caption",sx:{color:"text.secondary"},children:e.label}),(0,a.jsx)(M.default,{variant:"body2",sx:{mt:.25,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.value})]},e.label))}),m?(0,a.jsx)(M.default,{variant:"caption",sx:{mt:1.25*!!f.length,display:"block",color:"text.disabled",wordBreak:"break-all"},children:`${m.label}: ${m.value}`}):null]})]})]})}var el=e.i(937910),es=e.i(582561),eo=e.i(869095),en=e.i(236807),ei=e.i(836773),er=e.i(936151),ed=e.i(790498),eu=e.i(872745),ec=e.i(516258),eg=e.i(357089),eg=eg;e.i(463740);var ex=e.i(508714);function em(e){return(0,U.getProviderFromModelName)(e)??"others"}function ef({filters:e,dateError:t,onResetPage:l,localFilters:s,modelOptions:o,onSearch:d,onClear:u,onChangeLocalFilters:c}){let{t:g}=(0,L.useTranslate)("dashboard"),x=(0,p.useTheme)(),m=(0,b.default)(x.breakpoints.down("md")),f=(0,n.useBoolean)(),{state:h}=e,y=!!(s.tokenName||s.modelName||s.startDate||s.endDate||h.tokenName||h.modelName||h.startDate||h.endDate),j=[...o].sort((e,a)=>{let t=em(e),l=em(a);return t!==l?"others"===t?1:"others"===l?-1:t.localeCompare(l):e.localeCompare(a)}),v=(0,i.useCallback)(e=>{c({tokenName:e.target.value})},[c]),k=(0,i.useCallback)((e,a)=>{c({modelName:a??""})},[c]),w=(0,i.useCallback)(e=>{c({startDate:e})},[c]),D=(0,i.useCallback)(e=>{c({endDate:e})},[c]),C=(0,i.useCallback)(()=>{l(),d(),f.onFalse()},[f,l,d]),N=(0,i.useCallback)(()=>{l(),u()},[u,l]),I=()=>(0,a.jsx)(er.default,{fullWidth:!0,value:s.tokenName,onChange:v,placeholder:g("usageLogs.filter.tokenName"),slotProps:{input:{startAdornment:(0,a.jsx)(eu.default,{position:"start",children:(0,a.jsx)(E.Iconify,{icon:"eva:search-fill",sx:{color:"text.disabled"}})})}}}),P=()=>(0,a.jsx)(ed.default,{fullWidth:!0,freeSolo:!0,options:j,groupBy:e=>{let a;return"others"===(a=em(e))?g("modelCenter.filter.others"):a.toUpperCase()},value:s.modelName,onChange:k,onInputChange:(e,a)=>{c({modelName:a})},renderInput:e=>(0,a.jsx)(er.default,{...e,placeholder:g("usageLogs.filter.modelName"),slotProps:{input:{...e.InputProps,startAdornment:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(eu.default,{position:"start",children:(0,a.jsx)(E.Iconify,{icon:"eva:search-fill",sx:{color:"text.disabled"}})}),e.InputProps.startAdornment]})}}})});return m?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K.default,{spacing:1.5,sx:{p:2.5},children:(0,a.jsx)(r.default,{sx:{display:"flex"},children:(0,a.jsx)(en.default,{disableRipple:!0,color:"inherit",onClick:f.onTrue,endIcon:(0,a.jsx)(es.default,{color:"error",variant:"dot",invisible:!y,children:(0,a.jsx)(E.Iconify,{icon:"ic:round-filter-list"})}),children:g("usageLogs.filter.title")})})}),(0,a.jsxs)(eo.default,{anchor:"right",open:f.value,onClose:f.onFalse,slotProps:{backdrop:{invisible:!0},paper:{sx:{width:320}}},children:[(0,a.jsxs)(r.default,{sx:{py:2,pr:1,pl:2.5,display:"flex",alignItems:"center"},children:[(0,a.jsx)(M.default,{variant:"h6",sx:{flexGrow:1},children:g("usageLogs.filter.title")}),(0,a.jsx)(O.default,{title:g("usageLogs.filter.reset"),children:(0,a.jsx)(z.default,{onClick:N,children:(0,a.jsx)(es.default,{color:"error",variant:"dot",invisible:!y,children:(0,a.jsx)(E.Iconify,{icon:"solar:restart-bold"})})})}),(0,a.jsx)(z.default,{onClick:f.onFalse,children:(0,a.jsx)(E.Iconify,{icon:"mingcute:close-line"})})]}),(0,a.jsx)(ei.default,{sx:{borderStyle:"dashed"}}),(0,a.jsx)(ex.Scrollbar,{sx:{px:2.5,py:3},children:(0,a.jsxs)(K.default,{spacing:2.5,children:[((e=!1)=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ec.DatePicker,{label:g("usageLogs.filter.startDate"),value:s.startDate,onChange:w,sx:{width:"100%"}}),(0,a.jsx)(ec.DatePicker,{label:g("usageLogs.filter.endDate"),value:s.endDate,onChange:D,slotProps:{textField:{error:t,helperText:t?g("usageLogs.filter.dateError"):null}},sx:{width:"100%",...!e&&{[`& .${eg.default.root}`]:{bottom:{md:-40},position:{md:"absolute"}}}}})]}))(!0),I(),P(),(0,a.jsx)(r.default,{sx:{display:"flex",justifyContent:"flex-start"},children:(0,a.jsx)(en.default,{variant:"contained",onClick:C,children:g("action.search")})})]})})]})]}):(0,a.jsx)(K.default,{spacing:2,sx:{p:2.5,pr:2.5},children:(0,a.jsxs)(el.default,{container:!0,spacing:2,alignItems:"center",children:[(0,a.jsx)(el.default,{size:{xs:12,md:1.8},children:(0,a.jsx)(ec.DatePicker,{label:g("usageLogs.filter.startDate"),value:s.startDate,onChange:w,sx:{width:"100%"}})}),(0,a.jsx)(el.default,{size:{xs:12,md:1.8},children:(0,a.jsx)(ec.DatePicker,{label:g("usageLogs.filter.endDate"),value:s.endDate,onChange:D,slotProps:{textField:{error:t,helperText:t?g("usageLogs.filter.dateError"):null}},sx:{width:"100%",[`& .${eg.default.root}`]:{bottom:{md:-40},position:{md:"absolute"}}}})}),(0,a.jsx)(el.default,{size:{xs:12,md:2.2},children:I()}),(0,a.jsx)(el.default,{size:{xs:12,md:2.2},children:P()}),(0,a.jsx)(el.default,{size:{xs:12,md:"auto"},children:(0,a.jsx)(en.default,{variant:"contained",onClick:C,children:g("action.search")})}),(0,a.jsx)(el.default,{size:{xs:12,md:"auto"},children:(0,a.jsx)(en.default,{color:"inherit",variant:"text",onClick:N,disabled:!y,children:g("usageLogs.filter.clear")})})]})})}function eh({filters:e,totalResults:t,onResetPage:l,sx:s}){let{t:o}=(0,L.useTranslate)("dashboard"),{state:n,setState:d,resetState:u}=e,c=(0,i.useCallback)(()=>{l(),d({tokenName:""})},[l,d]),g=(0,i.useCallback)(()=>{l(),d({modelName:""})},[l,d]),x=(0,i.useCallback)(()=>{l(),d({type:"all"})},[l,d]),m=(0,i.useCallback)(()=>
1{l(),d({startDate:null,endDate:null})},[l,d]),f=(0,i.useCallback)(()=>{l(),u()},[l,u]);return(0,a.jsxs)(r.default,{sx:s,children:[(0,a.jsxs)(r.default,{sx:{mb:1.5,typography:"body2"},children:[(0,a.jsx)("strong",{children:t}),(0,a.jsx)(r.default,{component:"span",sx:{color:"text.secondary",ml:.5},children:o("usageLogs.filter.resultsFound")})]}),(0,a.jsxs)(K.default,{direction:"row",spacing:1,sx:{flexWrap:"wrap",alignItems:"center"},children:[!!n.tokenName&&(0,a.jsx)(W.default,{size:"small",label:`${o("usageLogs.filter.tokenLabel")}: ${n.tokenName}`,onDelete:c}),!!n.modelName&&(0,a.jsx)(W.default,{size:"small",label:`${o("usageLogs.filter.modelLabel")}: ${n.modelName}`,onDelete:g}),"all"!==n.type&&(0,a.jsx)(W.default,{size:"small",label:`${o("usageLogs.filter.type")}: ${(()=>{switch(n.type){case"2":return o("usageLogs.type.consume");case"3":return o("usageLogs.type.manage");case"4":return o("usageLogs.type.system");case"5":return o("usageLogs.type.error");default:return""}})()}`,onDelete:x}),n.startDate&&n.endDate&&(0,a.jsx)(W.default,{size:"small",label:`${o("usageLogs.filter.dateLabel")}: ${(0,j.fDateRangeShortLabel)(n.startDate,n.endDate)}`,onDelete:m}),(0,a.jsx)(en.default,{color:"error",onClick:f,startIcon:(0,a.jsx)(E.Iconify,{icon:"solar:trash-bin-trash-bold"}),children:o("usageLogs.filter.clear")})]})]})}function ep(e,a){return!e&&!a||!!e&&!!a&&e.valueOf()===a.valueOf()}function eb(){let e=(0,p.useTheme)(),{t:W}=(0,L.useTranslate)("dashboard"),K=(0,b.default)(e.breakpoints.down("md")),O=(0,P.useTable)({defaultRowsPerPage:10}),R=(O.dense?56:76)*Math.min(O.rowsPerPage,8)+56,{data:z}=(0,t.default)("/api/system-status",N.fetchSystemStatus),M=(0,k.normalizeQuotaDisplayConfig)(z),q=(0,G.getUsageLogHeaderQuotaUnit)(M),A=[{id:"time",label:W("usageLogs.table.time")},{id:"token",label:W("usageLogs.table.token")},{id:"type",label:W("usageLogs.table.type")},{id:"model",label:W("usageLogs.table.model")},{id:"cost",label:q?W("usageLogs.table.costWithUnit",{unit:q}):W("usageLogs.table.cost"),align:"right"},{id:"details",label:W("usageLogs.table.details"),align:"right"}],B=(0,n.useSetState)({type:"all",modelName:"",tokenName:"",startDate:null,endDate:null}),[U,E]=(0,i.useState)({tokenName:"",modelName:"",startDate:null,endDate:null});(0,i.useEffect)(()=>{E({tokenName:B.state.tokenName,modelName:B.state.modelName,startDate:B.state.startDate,endDate:B.state.endDate})},[B.state.tokenName,B.state.modelName,B.state.startDate,B.state.endDate]);let _=(e,a)=>({p:e,page_size:a,type:"all"===B.state.type?void 0:Number(B.state.type),token_name:B.state.tokenName||void 0,model_name:B.state.modelName||void 0,start_timestamp:B.state.startDate?(0,l.default)(B.state.startDate).startOf("day").unix():void 0,end_timestamp:B.state.endDate?(0,l.default)(B.state.endDate).endOf("day").unix():void 0}),H=(0,j.fIsAfter)(B.state.startDate,B.state.endDate),Q=O.rowsPerPage,{data:Z=[]}=(0,t.default)("/api/user/models",w.getTokenModels,{revalidateIfStale:!1,revalidateOnFocus:!1,revalidateOnReconnect:!1}),{data:Y,isLoading:J,isValidating:X,mutate:ee}=(0,t.default)(K||H?null:["/api/log/self",O.page,O.rowsPerPage,B.state.type,B.state.tokenName,B.state.modelName,B.state.startDate?.valueOf()??null,B.state.endDate?.valueOf()??null],()=>(0,C.fetchSelfUsageLogs)(_(O.page+1,O.rowsPerPage)),{revalidateIfStale:!1,revalidateOnMount:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1,keepPreviousData:!0}),{data:ea,isLoading:el,isValidating:es,mutate:eo,size:en,setSize:ei}=(0,s.default)((e,a)=>{if(!K||H)return null;let t=a?.data?.total??0;return e>0&&t>0&&e*Q>=t?null:["/api/log/self/mobile",e+1,Q,B.state.type,B.state.tokenName,B.state.modelName,B.state.startDate?.valueOf()??null,B.state.endDate?.valueOf()??null]},([,e,a])=>(0,C.fetchSelfUsageLogs)(_(e,a)),{revalidateIfStale:!1,revalidateOnMount:!0,revalidateOnFocus:!1,revalidateOnReconnect:!1}),er=(0,v.transformUsageLogs)(Y?.data?.items??[]),ed=(ea??[]).flatMap(e=>(0,v.transformUsageLogs)(e?.data?.items??[])),eu=K?ed:er,ec=el||es,eg=K?ea?.[0]?.data?.total??eu.length:Y?.data?.total??eu.length,ex=K?ec:J||X,em=!ex&&!eu.length,eb=!!K&&eg>eu.length,ey=!K&&J&&0===er.length,ej=!K&&X&&er.length>0,ev=!!(B.state.tokenName||B.state.modelName||"all"!==B.state.type||B.state.startDate||B.state.endDate),ek=[{value:"all",label:W("usageLogs.filter.all")},{value:"2",label:W("usageLogs.type.consume")},{value:"5",label:W("usageLogs.type.error")}],eL=(0,i.useCallback)((e,a)=>{O.onResetPage(),B.setState({type:a})},[B,O]),ew=(0,i.useCallback)(async()=>{await Promise.allSettled([ee(),eo()])},[ee,eo]),eD=(0,i.useCallback)(()=>{U.tokenName===B.state.tokenName&&U.modelName===B.state.modelName&&ep(U.startDate,B.state.startDate)&&ep(U.endDate,B.state.endDate)?ew():B.setState({tokenName:U.tokenName,modelName:U.modelName,startDate:U.startDate,endD
1ate:U.endDate})},[B,U,ew]),eC=(0,i.useCallback)(()=>{E({tokenName:"",modelName:"",startDate:null,endDate:null}),B.setState({tokenName:"",modelName:"",startDate:null,endDate:null})},[B]),eN=(0,i.useCallback)(()=>{eb&&!es&&ei(en+1)},[eb,en,es,ei]);return(0,a.jsxs)(D.DashboardContent,{maxWidth:"xl",children:[(0,a.jsx)(I.CustomBreadcrumbs,{heading:W("pages.usageLogs.title"),sx:{mb:{xs:3,md:5}}}),(0,a.jsxs)(c.default,{children:[(0,a.jsx)(u.default,{value:B.state.type,onChange:eL,sx:{px:{md:2.5},boxShadow:`inset 0 -2px 0 0 ${(0,o.varAlpha)(e.vars.palette.grey["500Channel"],.08)}`},children:ek.map(e=>(0,a.jsx)(d.default,{value:e.value,label:e.label},e.value))}),(0,a.jsx)(ef,{filters:B,dateError:H,onResetPage:O.onResetPage,localFilters:U,modelOptions:Z,onSearch:eD,onClear:eC,onChangeLocalFilters:e=>E(a=>({...a,...e}))}),ev&&(0,a.jsx)(eh,{filters:B,onResetPage:O.onResetPage,totalResults:eg,sx:{p:2.5,pt:0}}),(0,a.jsx)(F.ResponsiveDataList,{items:eu,loading:ex,notFound:em,desktopLoadingBar:ej,noDataTitle:W("usageLogs.noData"),noDataDescription:W("common.noData"),mobileMode:"server",mobileHasMore:eb,onMobileLoadMore:eN,renderMobileSkeleton:e=>(0,a.jsxs)(c.default,{variant:"outlined",sx:{overflow:"hidden",borderRadius:3,bgcolor:"background.neutral"},children:[(0,a.jsxs)(r.default,{sx:{p:3,pb:2},children:[(0,a.jsx)(x.default,{variant:"rounded",width:48,height:48,sx:{mb:2,borderRadius:1.5}}),(0,a.jsx)(x.default,{width:"48%"}),(0,a.jsx)(x.default,{width:"38%",sx:{mt:1}}),(0,a.jsx)(x.default,{width:"72%",sx:{mt:2}})]}),(0,a.jsx)(r.default,{sx:{borderTop:e=>`dashed 1px ${e.vars.palette.divider}`}}),(0,a.jsxs)(r.default,{sx:{p:3,display:"grid",rowGap:1.5,columnGap:2,gridTemplateColumns:"repeat(2, minmax(0, 1fr))"},children:[(0,a.jsx)(x.default,{width:"76%"}),(0,a.jsx)(x.default,{width:"68%"}),(0,a.jsx)(x.default,{width:"70%"}),(0,a.jsx)(x.default,{width:"64%"}),(0,a.jsx)(x.default,{width:"100%",sx:{gridColumn:"1 / -1"}})]})]},e),desktopContent:(0,a.jsx)(y.default,{sx:{maxHeight:R,overflow:"auto"},children:(0,a.jsxs)(g.default,{size:O.dense?"small":"medium",sx:{width:"100%",minWidth:860,tableLayout:"fixed","& th, & td":{width:"calc(100% / 6)"}},children:[(0,a.jsx)($.TableHeadCustom,{headCells:A}),(0,a.jsxs)(f.default,{children:[ey?Array.from({length:8}).map((e,t)=>(0,a.jsxs)(m.default,{children:[(0,a.jsx)(h.default,{children:(0,a.jsx)(x.default,{width:"78%"})}),(0,a.jsx)(h.default,{children:(0,a.jsx)(x.default,{width:60})}),(0,a.jsx)(h.default,{children:(0,a.jsx)(x.default,{width:60})}),(0,a.jsx)(h.default,{children:(0,a.jsx)(x.default,{width:"64%"})}),(0,a.jsx)(h.default,{align:"right",children:(0,a.jsx)(x.default,{width:80,sx:{ml:"auto"}})}),(0,a.jsx)(h.default,{align:"right",children:(0,a.jsx)(x.default,{width:150,sx:{ml:"auto"}})})]},t)):eu.map(e=>(0,a.jsx)(V,{row:e,quotaConfig:M},e.id)),(0,a.jsx)(T.TableNoData,{notFound:em,title:W("usageLogs.noData"),description:W("common.noData"),sx:{py:6}})]})]})}),renderMobileCard:e=>(0,a.jsx)(et,{row:e,quotaConfig:M}),getMobileCardKey:e=>e.id}),K?null:(0,a.jsx)(S.TablePaginationCustom,{page:O.page,dense:O.dense,count:Y?.data?.total||0,rowsPerPage:O.rowsPerPage,onPageChange:O.onChangePage,onChangeDense:O.onChangeDense,onRowsPerPageChange:O.onChangeRowsPerPage})]})]})}e.s(["UsageListView",()=>eb],12863)}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.