1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[279],{82638(e,t,a){var s=a(72361),n=a(38288),l=a(68413),r=a(6702),i=a(72868),o=a(1738),c=a(74501),d=a(84935),u=a(56275);function m(e){return e?(0,d.A)(e).format("YYYY-MM-DDTHH:mm"):""}function x(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t}function p(e){let{start:t,end:a,onChange:p,className:h}=e,{t:g}=(0,r.Bd)(),[f,b]=(0,l.useState)(!1),[j,v]=(0,l.useState)(m(t)),[_,y]=(0,l.useState)(m(a)),N=(0,l.useMemo)(()=>{if(!t&&!a)return g("Date Range");let e=t?(0,d.A)(t).format("YYYY-MM-DD HH:mm"):"-",s=a?(0,d.A)(a).format("YYYY-MM-DD HH:mm"):"-";return`${e} ~ ${s}`},[a,t,g]),w=e=>{let t=(0,d.A)(),a={today:{start:t.startOf("day").toDate(),end:t.endOf("day").toDate()},"7d":{start:t.subtract(6,"day").startOf("day").toDate(),end:t.endOf("day").toDate()},week:{start:t.startOf("week").toDate(),end:t.endOf("week").toDate()},"30d":{start:t.subtract(29,"day").startOf("day").toDate(),end:t.endOf("day").toDate()},month:{start:t.startOf("month").toDate(),end:t.endOf("month").toDate()}}[e];v(m(a.start)),y(m(a.end)),p(a),b(!1)};return(0,s.jsxs)(c.AM,{open:f,onOpenChange:e=>{e&&(v(m(t)),y(m(a))),b(e)},children:[(0,s.jsxs)(c.Wv,{render:(0,s.jsx)(i.$,{type:"button",variant:"outline",className:(0,u.cn)("w-full justify-start gap-2 px-2.5 text-sm leading-5 font-normal tabular-nums",!t&&!a&&"text-muted-foreground",h)}),children:[(0,s.jsx)(n.A,{className:"text-muted-foreground size-4 shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:N})]}),(0,s.jsx)(c.hl,{align:"start",className:"w-[min(520px,calc(100vw-2rem))] p-3",children:(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[1fr_auto_1fr] sm:items-end",children:[(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:g("Start Time")}),(0,s.jsx)(o.p,{type:"datetime-local",value:j,onChange:e=>v(e.target.value),className:"h-8 text-sm leading-5 tabular-nums"})]}),(0,s.jsx)("span",{className:"text-muted-foreground hidden pb-2 text-xs sm:block",children:"~"}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("div",{className:"text-muted-foreground text-xs",children:g("End Time")}),(0,s.jsx)(o.p,{type:"datetime-local",value:_,onChange:e=>y(e.target.value),className:"h-8 text-sm leading-5 tabular-nums"})]})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-1.5",children:[(0,s.jsx)(i.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 flex-1 px-2 text-xs",onClick:()=>
1w("today"),children:g("Today")}),(0,s.jsx)(i.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 flex-1 px-2 text-xs",onClick:()=>w("7d"),children:g("7 Days")}),(0,s.jsx)(i.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 flex-1 px-2 text-xs",onClick:()=>w("week"),children:g("This week")}),(0,s.jsx)(i.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 flex-1 px-2 text-xs",onClick:()=>w("30d"),children:g("30 Days")}),(0,s.jsx)(i.$,{type:"button",variant:"secondary",size:"sm",className:"h-7 flex-1 px-2 text-xs",onClick:()=>w("month"),children:g("This month")})]}),(0,s.jsx)("div",{className:"flex justify-end",children:(0,s.jsx)(i.$,{size:"sm",className:"h-8",onClick:()=>{p({start:x(j),end:x(_)}),b(!1)},children:g("Confirm")})})]})})]})}a.d(t,{A:()=>p})},34444(e,t,a){var s=a(89795),n=a(52523);function l(){let{user:e}=(0,n.n)(e=>e.auth);return(e?.role??0)>=s.z7.ADMIN}a.d(t,{h:()=>l})},8803(e,t,a){var s=a(68413);let n="page-size";function l(e){let{search:t,navigate:a,pagination:l,globalFilter:r,columnFilters:i=[]}=e,o=l?.pageKey??"page",c=l?.pageSizeKey??"pageSize",d=l?.defaultPage??1,u=l?.defaultPageSize??20,m=r?.key??"filter",x=r?.enabled??!0,p=r?.trim??!0,h=(0,s.useMemo)(()=>{let e=[];for(let a of i){let s=t[a.searchKey],n=a.deserialize??(e=>e);if("string"===a.type){let t=n(s)??"";"string"==typeof t&&""!==t.trim()&&e.push({id:a.columnId,value:t})}else{let t=n(s)??[];Array.isArray(t)&&t.length>0&&e.push({id:a.columnId,value:t})}}return e},[i,t]),[g,f]=(0,s.useState)(h);(0,s.useEffect)(()=>{f(h)},[t]);let b=(0,s.useMemo)(()=>{let e=t[o],a=t[c];return{pageIndex:Math.max(0,("number"==typeof e?e:d)-1),pageSize:"number"==typeof a?a:function(){try{let e=parseInt(localStorage.getItem(n)??"",10);return e>0?e:void 0}catch{return}}()??u}},[t,o,c,d,u]),[j,v]=(0,s.useState)(()=>{if(!x)return;let e=t[m];return"string"==typeof e?e:""}),_=x?e=>{let t="function"==typeof e?e(j??""):e,s=p?t.trim():t;v(s),a({search:e=>({...e,[o]:void 0,[m]:s||void 0})})}:void 0;return{globalFilter:x?j??"":void 0,onGlobalFilterChange:_,columnFilters:g,onColumnFiltersChange:e=>{let t="function"==typeof e?e(g):e;f(t);let s={};for(let e of i){let a=t.find(t=>t.id===e.columnId),n=e.serialize??(e=>e);if("string"===e.type){let t="string"==typeof a?.value?a.value:"";s[e.searchKey]=""!==t.trim()?n(t):void 0}else{let t=Array.isArray(a?.value)?a.value:[];s[e.searchKey]=t.length>0?n(t):void 0}}a({search:e=>({...e,[o]:void 0,...s})})},pagination:b,onPaginationChange:e=>{let t="function"==typeof e?e(b):e,s=t.pageIndex+1,l=t.pageSize;l!==b.pageSize&&function(e){try{localStorage.setItem(n,String(e))}catch{}}(l),a({search:e=>({...e,[o]:s<=d?void 0:s,[c]:l})})},ensurePageInRange:function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{resetTo:"first"},n=t[o],l="number"==typeof n?n:d;e>0&&l>e&&a({replace:!0,search:t=>({...t,[o]:"last"===s.resetTo?e:void 0})})}}}a.d(t,{c:()=>l})},52602(e,t,a){a.r(t),a.d(t,{component:()=>sw});var s=a(72361),n=a(2718),l=a(82799),r=a(68413),i=a(6702),o=a(34444),c=a(13289),d=a(82814),u=a(56920),m=a(52154),x=a(20598),p=a(60641),h=a(33271),g=a(18372);function f(e){let{t}=(0,i.Bd)(),[a,n]=(0,r.useState)(!1),[l,o]=(0,r.useState)(null),c=(0,r.useRef)(0);(0,r.useEffect)(()=>{if(!e.open||!e.target?.rule_name||!e.target?.key_fp)return void o(null);let a=++c.current;n(!0),o(null),(0,g.Mb)(e.target).then(e=>{a===c.current&&(e.success?o(e.data||{}):x.oR.error(e.message||t("Request failed")))}).catch(()=>{a===c.current&&x.oR.error(t("Request failed"))}).finally(()=>{a===c.current&&n(!1)})},[e.open,e.target,t]);let d=(0,r.useMemo)(()=>{if(!l)return[];let a=[],s=Number(l.hit||0),n=Number(l.total||0);(l.rule_name||e.target?.rule_name)&&a.push({key:t("Rule"),value:l.rule_name||e.target?.rule_name||""}),(l.using_group||e.target?.using_group)&&a.push({key:t("Group"),value:l.using_group||e.target?.using_group||""}),e.target?.key_hint&&a.push({key:t("Key Summary"),value:e.target.key_hint}),(l.key_fp||e.target?.key_fp)&&a.push({key:t("Key Fingerprint"),value:l.key_fp||e.target?.key_fp||""}),Number(l.window_seconds||0)>0&&a.push({key:t("TTL (seconds)"),value:l.window_seconds}),n>0&&a.push({key:t("Hit Rate"),value:`${s}/${n} (${function(e,t){if(!t||t<=0)return"-";let a=e/t*100;return Number.isFinite(a)?`${a.toFixed(2)}%`:"-"}(s,n)})`}),Number(l.last_seen_at||0)>0&&a.push({key:t("Last Seen"),value:(0,h.fk)(l.last_seen_at)});let r=Number(l.prompt_tokens||0),i=Number(l.cached_tokens||0),o=Number(l.completion_tokens||0),c=Number(l.total_tokens||0);return r>0&&a.push({key:"Prompt tokens",value:r}),i>0&&a.push({key:"Cached tokens",value:i}),o>0&&a.push({key:"Completion tokens",value:o}),c>0&&a.push({key:"Total tokens",value:c}),a},[l,e.target,t]);return(0,s.jsxs)(p.l,{open:e.open,onOpenChange:e.onOpenChange,title:t("Channel Affinity: Upstream Cache Hit"),contentClassName:"sm:max-w-lg",contentHeight:"auto",bodyClassName:"space-y-4",children:[(0,s.jsx)("p",{className:"text-muted-foreground text-xs",children:t("Hit criteria: If cached tokens exist in usage, it counts as a hit.")}),a?(0,s.jsx)("div",{className:"text-muted-foreground py-8 text-center text-sm",children:t("Loading...")}):d.length>0?(0,s.jsx)("div",{className:"space-y-2",children:d.map(e=>(0,s.jsxs)("div",{className:"flex justify-between gap-4 border-b pb-1 text-sm",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:e.key}),(0,s.jsx)("span",{className:"text-right font-medium break-all",children:e.value})]},e.key))}):(0,s.jsx)("div",{className:"text-muted-foreground py-8 text-center text-sm",children:t("No data available")})]})}var b=a(96962),j=a(53540),v=a(55667),_=a(33834),y=a(72969),N=a(68974),w=a(72868),k=a(1738),C=a(11728),S=a(87212),A=a(38939),T=a(42817),I=a(73280),$=a(49302),R=a(91555),q=a(55581),F=a(3521),z=a(22990);async function D(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,a=await z.FH.get(`/api/log/export-tasks?page=${e}&page_size=${t}`);return a.data?.data}async function E(){let e=await z.FH.get("/api/log/export-queue-stats");return e.data?.data}async function M(){let e=await z.FH.get("/api/log/export-config");return e.data?.data}async function L(e){return(await z.FH.put("/api/log/export-config",e)).data}async function P(e){return(await z.FH.post(`/api/log/export-tasks/${e}/cancel`)).data}function O(e){if(0===e)return"0 B";let t=Math.floor(Math.log(e)/Math.log(1024)),a=e/Math.pow(1024,t);return`${a.toFixed(+(t>0))} ${["B","KB","MB","GB","TB"][t]}`}let K=["admin-export"];function B(){let{t:e}=(0,i.Bd)(),t=(0,b.jE)(),[a,n]=(0,r.useState)(1),[l,o]=(0,r.useState)(!1),[c,d]=(0,r.useState)(null),{data:u}=(0,j.I)({queryKey:["admin-export","stats"],queryFn:E,refetchInterval:15e3}),{data:m}=(0,j.I)({queryKey:["admin-export","config"],queryFn:M}),[p,g]=(0,r.useState)(null);(0,r.useEffect)(()=>{m&&g(m)},[m]);let f=(0,v.n)({mutationFn:e=>L(e),onSuccess:()=>{x.oR.success(e("Config saved")),t.invalidateQueries({queryKey:K})}}),{data:B,isLoading:U}=(0,j.I)({queryKey:["admin-export","tasks",a],queryFn:()=>D(a,10),placeholderData:e=>e}),V=B?.items??[],H=B?.total??0,W=(0,q.N4)({data:V,columns:[],pageCount:Math.ceil(H/10),state:{pagination:{pageIndex:a-1,pageSize:10}},onPaginationChange:e=>{n(("function"==typeof e?e({pageIndex:a-1,pageSize:10}):e).pageIndex+1)},getCoreRowModel:(0,F.HT)(),manualPagination:!0}
1),G=(0,v.n)({mutationFn:e=>P(e),onSuccess:()=>{x.oR.success(e("Task cancelled")),o(!1),t.invalidateQueries({queryKey:K})}});return(0,s.jsxs)("div",{className:"space-y-6",children:[u&&(0,s.jsxs)(N.Zp,{children:[(0,s.jsx)(N.aR,{children:(0,s.jsx)(N.ZB,{className:"text-sm",children:e("Queue Stats")})}),(0,s.jsx)(N.Wu,{children:(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-sm sm:grid-cols-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Queue Depth"),":"," "]}),u.queue_depth," / ",u.queue_capacity]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Workers"),":"," "]}),u.worker_count]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Storage"),":"," "]}),O(u.total_storage_bytes)]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Pending"),":"," "]}),u.pending_count,(0,s.jsxs)("span",{className:"text-muted-foreground ml-2",children:[e("Processing"),":"," "]}),u.processing_count]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Done"),":"," "]}),u.done_count]}),(0,s.jsxs)("div",{children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[e("Failed"),":"," "]}),u.failed_count]})]})})]}),p&&(0,s.jsxs)(N.Zp,{children:[(0,s.jsx)(N.aR,{children:(0,s.jsx)(N.ZB,{children:e("Export Config")})}),(0,s.jsxs)(N.Wu,{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(C.J,{children:e("Enabled")}),(0,s.jsx)(S.d,{checked:p.enabled,onCheckedChange:e=>g(t=>t&&{...t,enabled:e})})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(C.J,{children:e("Worker Count")}),(0,s.jsx)(k.p,{type:"number",value:p.worker_count,onChange:e=>g(t=>t&&{...t,worker_count:Number(e.target.value)}),className:"h-8"})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(C.J,{children:e("Queue Size")}),(0,s.jsx)(k.p,{type:"number",value:p.queue_size,onChange:e=>g(t=>t&&{...t,queue_size:Number(e.target.value)}),className:"h-8"})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(C.J,{children:e("Max File Size (MB)")}),(0,s.jsx)(k.p,{type:"number",value:p.max_file_size_mb,onChange:e=>g(t=>t&&{...t,max_file_size_mb:Number(e.target.value)}),className:"h-8"})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(C.J,{children:e("Max Total Storage (MB)")}),(0,s.jsx)(k.p,{type:"number",value:p.max_total_storage_mb,onChange:e=>g(t=>t&&{...t,max_total_storage_mb:Number(e.target.value)}),className:"h-8"})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(C.J,{children:e("User Cooldown Hours")}),(0,s.jsx)(k.p,{type:"number",value:p.user_cooldown_hours,onChange:e=>g(t=>t&&{...t,user_cooldown_hours:Number(e.target.value)}),className:"h-8"})]}),(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)(C.J,{children:e("Retention Hours")}),(0,s.jsx)(k.p,{type:"number",value:p.retention_hours,onChange:e=>g(t=>t&&{...t,retention_hours:Number(e.target.value)}),className:"h-8"})]})]}),(0,s.jsx)(A.w,{}),(0,s.jsx)(w.$,{size:"sm",onClick:()=>p&&f.mutate(p),disabled:f.isPending,children:e("Save")})]})]}),(0,s.jsxs)(N.Zp,{children:[(0,s.jsx)(N.aR,{children:(0,s.jsx)(N.ZB,{children:e("Export Tasks")})}),(0,s.jsxs)(N.Wu,{className:"space-y-3",children:[(0,s.jsx)("div",{className:"rounded-md border",children:(0,s.jsxs)($.XI,{children:[(0,s.jsx)($.A0,{children:(0,s.jsxs)($.Hj,{children:[(0,s.jsx)($.nd,{children:e("ID")}),(0,s.jsx)($.nd,{children:e("Username")}),(0,s.jsx)($.nd,{children:e("Export Range")}),(0,s.jsx)($.nd,{children:e("Status")}),(0,s.jsx)($.nd,{children:e("Progress")}),(0,s.jsx)($.nd,{children:e("Row Count")}),(0,s.jsx)($.nd,{children:e("File Size")}),(0,s.jsx)($.nd,{children:e("Created Time")}),(0,s.jsx)($.nd,{children:e("Actions")})]})}),(0,s.jsx)($.BF,{children:U&&0===V.length?(0,s.jsx)($.Hj,{children:(0,s.jsx)($.nA,{colSpan:9,className:"text-center py-8",children:e("Loading...")})}):0===V.length?(0,s.jsx)($.Hj,{children:(0,s.jsx)($.nA,{colSpan:9,className:"text-center py-8 text-muted-foreground",children:e("No data")})}):V.map(t=>(0,s.jsxs)($.Hj,{children:[(0,s.jsx)($.nA,{className:"font-mono text-xs",children:t.id}),(0,s.jsx)($.nA,{children:t.username||"-"}),(0,s.jsx)($.nA,{className:"text-xs",children:function(e){if(!e)return"-";try{let t=JSON.parse(e),a=t.start_timestamp?(0,h.Ey)(t.start_timestamp):"",s=t.end_timestamp?(0,h.Ey)(t.end_timestamp):"";if(!a&&!s)return"-";return`${a} ~ ${s}`}catch{return"-"}}(t.filters)}),(0,s.jsx)($.nA,{children:(0,s.jsx)(T.Wh,{variant:function(e){switch(e){case 0:return"warning";case 1:return"info";case 2:return"success";case 3:return"danger";default:return"neutral"}}(t.status),pulse:1===t.status,children:e(function(e){switch(e){case 0:return"Pending";case 1:return"Processing";case 2:return"Done";case 3:return"Failed";case 4:return"Cancelled";default:return"Unknown"}}(t.status))})}),(0,s.jsx)($.nA,{className:"text-xs",children:1===t.status?`${t.progress}%`:"-"}),(0,s.jsx)($.nA,{className:"text-xs",children:t.row_count>
10?t.row_count.toLocaleString():"-"}),(0,s.jsx)($.nA,{className:"text-xs",children:t.file_size>0?O(t.file_size):"-"}),(0,s.jsx)($.nA,{className:"text-xs",children:(0,h.Ey)(t.created_time)}),(0,s.jsx)($.nA,{children:(0,s.jsxs)("div",{className:"flex gap-1",children:[2===t.status&&(0,s.jsx)(w.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:async()=>{try{var a;let e=await (0,z.v$)((a=t.id,`/api/log/export-tasks/${a}/download`));if(!e.ok)throw Error(e.statusText);let s=await e.blob(),n=URL.createObjectURL(s),l=document.createElement("a");l.href=n,l.download=`${t.username||"export"}-${(0,h.Ey)(t.created_time).replaceAll("-","").replaceAll(":","").replace(" ","-")}.csv.gz`,document.body.appendChild(l),l.click(),l.remove(),URL.revokeObjectURL(n)}catch{x.oR.error(e("Download failed"))}},title:e("Download"),children:(0,s.jsx)(_.A,{className:"h-3.5 w-3.5"})}),(0===t.status||1===t.status)&&(0,s.jsx)(w.$,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{d(t),o(!0)},title:e("Cancel"),children:(0,s.jsx)(y.A,{className:"h-3.5 w-3.5"})})]})})]},t.id))})]})}),(0,s.jsx)(R.T,{table:W})]})]}),(0,s.jsx)(I.T,{open:l,onOpenChange:o,title:e("Cancel Export Task"),desc:`${e("Task ID")}: ${c?.id??"-"}`,destructive:!0,handleConfirm:()=>c&&G.mutate(c.id),isLoading:G.isPending})]})}var U=a(94150),V=a(38009),H=a(70261);function W(e,t,a){let[s,n]=(0,r.useState)(null),[l,i]=(0,r.useState)(!1);return(0,r.useEffect)(()=>{var s,l;let r=!1,o=null;return n(null),i(!1),(0,z.v$)((s=e.id,l=t.idx,a?`/api/image_result/${s}/file/${l}`:`/api/image_result/self/${s}/file/${l}`)).then(e=>{if(!e.ok)throw Error(e.statusText);return e.blob()}).then(e=>{let t=URL.createObjectURL(e);r?URL.revokeObjectURL(t):(o=t,n(t))}).catch(()=>{r||i(!0)}),()=>{r=!0,o&&URL.revokeObjectURL(o)}},[e.id,t.idx,a]),{blobUrl:s,failed:l}}function G(e){let{record:t,file:a,isAdminView:n,onPreview:l,size:r="md"}=e,{t:o}=(0,i.Bd)(),{blobUrl:c,failed:d}=W(t,a,n),u="sm"===r?"h-10 w-10":"h-16 w-16";return d?(0,s.jsx)("div",{className:`flex ${u} items-center justify-center rounded border bg-muted`,title:o("Failed to load image"),children:(0,s.jsx)(H.A,{className:"h-4 w-4 text-muted-foreground"})}):c?(0,s.jsx)("button",{type:"button",onClick:()=>l(t,a),title:o("Click to preview"),className:"block",children:(0,s.jsx)("img",{src:c,alt:t.prompt||t.model_name,className:`${u} rounded border object-cover transition-opacity hover:opacity-80`})}):(0,s.jsx)("div",{className:`${u} animate-pulse rounded border bg-muted`})}function Z(e){let{target:t,isAdminView:a,open:n,onOpenChange:l}=e;return t?(0,s.jsx)(Q,{record:t.record,file:t.file,isAdminView:a,open:n,onOpenChange:l}):null}function Q(e){let{record:t,file:a,isAdminView:n,open:l,onOpenChange:r}=e,{t:o}=(0,i.Bd)(),{blobUrl:c,failed:d}=W(t,a,n),u=(0,s.jsx)("img",{src:c??void 0,alt:t.prompt||t.model_name,className:"max-h-[550px] w-full rounded-lg object-contain"});return d?u=(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:o("Failed to load image")}):c||(u=(0,s.jsx)("div",{className:"h-[300px] w-full animate-pulse rounded-lg bg-muted"})),(0,s.jsxs)(p.l,{open:l,onOpenChange:r,title:o("Image Preview"),description:`${t.model_name} \xb7 ${(0,h.Ey)(t.created_time)}`,contentClassName:"sm:max-w-3xl",contentHeight:"auto",bodyClassName:"space-y-4",footer:(0,s.jsxs)(w.$,{onClick:()=>{var e;let s,n;c?(s=a.mime.split("/")[1]||"png",e=`${t.model_name||"image"}-${t.id}-${a.idx}.${s}`,(n=document.createElement("a")).href=c,n.download=e,document.body.appendChild(n),n.click(),n.remove()):x.oR.error(o("Download failed"))},disabled:!c,children:[(0,s.jsx)(_.A,{className:"mr-2 h-4 w-4"}),o("Download")]}),children:[(0,s.jsx)("div",{className:"bg-muted/50 relative flex min-h-[300px] items-center justify-center rounded-lg border",children:u}),t.prompt&&(0,s.jsx)("div",{className:"bg-muted rounded-md p-3",children:(0,s.jsx)("p",{className:"text-muted-foreground text-xs break-all",children:t.prompt})})]})}let J=(0,r.createContext)(void 0);function Y(e){let{children:t}=e,[a,n]=(0,r.useState)(null),[l,i]=(0,r.useState)(!1),[o,c]=(0,r.useState)(null),[d,u]=(0,r.useState)(!1),[m,x]=(0,r.useState)(!0),[p,h]=(0,r.useState)("all");return(0,s.jsx)(J.Provider,{value:{selectedUserId:a,setSelectedUserId:n,userInfoDialogOpen:l,setUserInfoDialogOpen:i,affinityTarget:o,setAffinityTarget:c,affinityDialogOpen:d,setAffinityDialogOpen:u,sensitiveVisible:m,setSensitiveVisible:x,viewScope:p,setVie
1wScope:h},children:t})}function X(){let e=(0,r.useContext)(J);if(!e)throw Error("useUsageLogsContext must be used within UsageLogsProvider");return e}function ee(){let e=(0,o.h)(),{viewScope:t,setViewScope:a}=X();return{canManageScope:e,viewScope:t,setViewScope:a,isAdminView:e&&"all"===t}}async function et(e,t,a){let s=await z.FH.get(a?"/api/image_result/":"/api/image_result/self",{params:{p:e,page_size:t}}),n=s.data?.data;return{items:n?.items??[],total:n?.total??0}}function ea(){let{t:e}=(0,i.Bd)(),{isAdminView:t}=ee(),a=(0,V.a)(),[n,l]=(0,r.useState)(1),[o,c]=(0,r.useState)(a?20:50),[d,u]=(0,r.useState)(null),[m,x]=(0,r.useState)(!1);(0,r.useEffect)(()=>{l(1)},[t]);let{data:p,isLoading:g}=(0,j.I)({queryKey:["image-results",t,n,o],queryFn:()=>et(n,o,t),placeholderData:e=>e}),f=p?.items??[],b=p?.total??0,v=(0,q.N4)({data:f,columns:[],pageCount:Math.max(1,Math.ceil(b/o)),rowCount:b,state:{pagination:{pageIndex:n-1,pageSize:o}},onPaginationChange:e=>{let t="function"==typeof e?e({pageIndex:n-1,pageSize:o}):e;if(t.pageSize!==o){c(t.pageSize),l(1);return}l(t.pageIndex+1)},getCoreRowModel:(0,F.HT)(),manualPagination:!0}),_=(e,t)=>{u({record:e,file:t}),x(!0)},y=t?6:5;return(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-3",children:[(0,s.jsx)("p",{className:"text-muted-foreground shrink-0 text-sm",children:e("Successful image generations are saved here for a limited time. If a request timed out on the client (e.g. CDN 120s limit), you can still download the result below.")}),(0,s.jsx)("div",{className:"min-h-0 flex-1 overflow-auto rounded-md border",children:(0,s.jsxs)($.XI,{children:[(0,s.jsx)($.A0,{children:(0,s.jsxs)($.Hj,{children:[(0,s.jsx)($.nd,{children:e("Time")}),t&&(0,s.jsx)($.nd,{children:e("Username")}),(0,s.jsx)($.nd,{children:e("Model")}),(0,s.jsx)($.nd,{children:e("Prompt")}),(0,s.jsx)($.nd,{children:e("Images")}),(0,s.jsx)($.nd,{children:e("Request ID")})]})}),(0,s.jsx)($.BF,{children:g&&0===f.length?(0,s.jsx)($.Hj,{children:(0,s.jsx)($.nA,{colSpan:y,className:"py-8 text-center",children:e("Loading...")})}):0===f.length?(0,s.jsx)($.Hj,{children:(0,s.jsx)($.nA,{colSpan:y,className:"py-8 text-center text-muted-foreground",children:e("No data")})}):f.map(e=>(0,s.jsxs)($.Hj,{children:[(0,s.jsx)($.nA,{className:"whitespace-nowrap text-xs",children:(0,h.Ey)(e.created_time)}),t&&(0,s.jsx)($.nA,{className:"text-xs",children:e.username||e.user_id}),(0,s.jsxs)($.nA,{className:"text-xs",children:[e.model_name,(0,s.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",e.mode,")"]})]}),(0,s.jsx)($.nA,{className:"max-w-[240px] truncate text-xs",title:e.prompt,children:e.prompt||"-"}),(0,s.jsx)($.nA,{children:(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:(e.files??[]).map(a=>(0,s.jsx)(G,{record:e,file:a,isAdminView:t,onPreview:_},a.idx))})}),(0,s.jsx)($.nA,{className:"font-mono text-xs",children:e.request_id||"-"})]},e.id))})]})}),(0,s.jsx)(U.j,{children:(0,s.jsx)(R.T,{table:v,totalRows:b})}),(0,s.jsx)(Z,{target:d,isAdminView:t,open:m,onOpenChange:x})]})}var es=a(55724);let en={quota:0,rpm:0,tpm:0},el={items:[],total:0},er=[{value:0,label:"Unknown",color:"default"},{value:1,label:"Top-up",color:"cyan"},{value:2,label:"Consume",color:"green"},{value:3,label:"Manage",color:"orange"},{value:4,label:"System",color:"purple"},{value:5,label:"Error",color:"red"},{value:6,label:"Refund",color:"blue"},{value:7,label:"Login",color:"teal"}],ei=[{label:"All Types",value:"0"},...er.filter(e=>0!==e.value).map(e=>({label:e.label,value:String(e.value)}))],eo="IMAGINE",ec="UPSCALE",ed="VIDEO",eu="EDITS",em="VARIATION",ex="HIGH_VARIATION",ep="LOW_VARIATION",eh="DESCRIBE",eg="BLEND",ef="UPLOAD",eb="SHORTEN",ej="REROLL",ev="INPAINT",e_="SWAP_FACE",ey="ZOOM",eN="CUSTOM_ZOOM",ew="generate",ek="textGenerate",eC="firstTailGenerate",eS="referenceGenerate",eA="remixGenerate",eT="SUCCESS",eI={[String(1)]:{label:"Submitted",variant:"green"},[String(21)]:{label:"Waiting",variant:"lime"},[String(22)]:{label:"Duplicate",variant:"orange"},[String(0)]:{label:"Not Submitted",variant:"yellow"}},e$=[0,2,5,6],eR=[2,5];function eq(e){return e$.includes(e)}function eF(e){return eR.includes(e)}function ez(e){return er.find(t=>t.value===e)||er["0"]}function eD(){let e,t=new Date(new Date);return t.setHours(0,0,0,0),{start:t,end:((e=new Date).setHours(23,59,59,999),e)}}function eE(e){let t=new URLSearchParams;
1return Object.entries(e).forEach(e=>{let[a,s]=e;null!=s&&""!==s&&t.append(a,String(s))}),t}function eM(e,t){let a=e.startTime??e.endTime?null:eD(),s=(e,a)=>{let s,n=e||a?.getTime();return n?(s=n,t?s:Math.floor(s/1e3)):void 0};return{start_timestamp:s(e.startTime,a?.start),end_timestamp:s(e.endTime,a?.end)}}function eL(e){let{page:t,pageSize:a,searchParams:s,columnFilters:n=[],isAdmin:l,totalCount:r}=e,i=e=>{let t=e=>{let t=Number(e);return Number.isFinite(t)?t:void 0};return Array.isArray(e)&&1===e.length?t(e[0]):"string"==typeof e&&""!==e?t(e):void 0},o={p:t,page_size:a,...s.type?{type:i(s.type)}:{},...s.model?{model_name:String(s.model)}:{},...s.token?{token_name:String(s.token)}:{},...s.group?{group:String(s.group)}:{},...l&&s.channel?{channel:Number(s.channel)||0}:{},...l&&s.username?{username:String(s.username)}:{},...s.requestId?{request_id:String(s.requestId)}:{},...s.upstreamRequestId?{upstream_request_id:String(s.upstreamRequestId)}:{},...eM(s,!1),...r&&r>0&&Number.isFinite(r)?{total_count:r}:{}};return n.length>0&&n.forEach(e=>{let{id:t,value:a}=e;if(null!=a&&""!==a)switch(t){case"type":o.type=i(a);break;case"model_name":o.model_name=String(a);break;case"token_name":o.token_name=String(a);break;case"group":o.group=String(a);break;case"channel":l&&(o.channel=Number(a)||0);break;case"username":l&&(o.username=String(a))}}),o}async function eP(e){let{logCategory:t,isAdmin:a,page:s,pageSize:n,searchParams:l,columnFilters:r,totalCount:i}=e;if("common"===t){let e=eL({page:s,pageSize:n,searchParams:l,columnFilters:r,isAdmin:a,totalCount:i});return a?await eH(e):await eW(e)}let o={...function(e){let{page:t,pageSize:a,searchParams:s,useMilliseconds:n=!1,totalCount:l}=e;return{p:t,page_size:a,...s.channel?{channel_id:String(s.channel)}:{},...eM(s,n),...l&&l>0&&Number.isFinite(l)?{total_count:l}:{}}}({page:s,pageSize:n,searchParams:l,useMilliseconds:"drawing"===t,totalCount:i}),..."drawing"===t?{mj_id:l.filter}:{},..."task"===t?{task_id:l.filter}:{}};return"drawing"===t?a?await eJ(o):await eY(o):a?await eX(o):await e0(o)}let eO=/\s*\(request id: [^)]*\)/g;function eK(e){return e?e.replace(eO,"").trimEnd():e??""}function eB(e,t){return t?e:`${e}/self`}async function eU(e,t,a){let s=eE({p:t.p||1,page_size:t.page_size||20,...t}),n=eB(e,a);return(await z.FH.get(`${n}?${s}`)).data}async function eV(e,t,a){let s=eE(t),n=eB(e,a);return(await z.FH.get(`${n}/stat?${s}`)).data}let eH=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return eU("/api/log",e,!0)},eW=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return eU("/api/log",e,!1)},eG=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return eV("/api/log",e,!0)},eZ=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return eV("/api/log",e,!1)};async function eQ(e){return(await z.FH.get(`/api/user/${e}`)).data}let eJ=e=>eU("/api/mj",e,!0),eY=e=>eU("/api/mj",e,!1),eX=e=>eU("/api/task",e,!0),e0=e=>eU("/api/task",e,!1);async function e1(e){return(await z.FH.post("/api/log/self/export-offline",e)).data}async function e5(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;return(await z.FH.get(`/api/log/self/export-tasks?page=${e}&page_size=${t}`)).data}function e2(e){let{userId:t,open:a,onOpenChange:n}=e,{t:l}=(0,i.Bd)(),[o,c]=(0,r.useState)(null),[d,u]=(0,r.useState)(!1),m=(0,r.useCallback)(async e=>{u(!0);try{let t=await eQ(e);t.success?c(t.data||null):x.oR.error(t.message||l("Failed to fetch user information"))}catch(e){console.error("Failed to fetch user info:",e),x.oR.error(l("Failed to fetch user information"))}finally{u(!1)}},[l]);(0,r.useEffect)(()=>{a&&t&&m(t)},[a,t,m]);let g=e=>{let{label:t,value:a}=e;return(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{className:"text-muted-foreground text-xs",children:t}),(0,s.jsx)("div",{className:"text-sm font-semibold",children:a})]})};return(0,s.jsx)(p.l,{open:a,onOpenChange:n,title:l("User Information"),description:l("View detailed information about this user including balance, usage statistics, and invitation details."),contentClassName:"sm:max-w-lg",contentHeight:"auto",bodyClassName:"space-y-4",children:d?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)(es.A,{className:"text-muted-foreground size-6 animate-spin"})}):o?(0,s.jsxs)("div",{className:"space-y-4 py-4",children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsx)(g,{label:l("Username"),value:o.username}),o.display_name&&(0,s.jsx)(g,{label:l("Display Name"),value:o.display_name})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsx)(g,{label:l("Balance"),value:(0,h.eN)(o.quota)}),(0,s.jsx)(g,{label:l("Used Quota"),value:(0,h.eN)(o.used_quota)})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsx)(g,{label:l("Request Count"),value:(0,h.wk)(o.request_count)}
1),o.group&&(0,s.jsx)(g,{label:l("User Group"),value:o.group})]}),(o.aff_code||void 0!==o.aff_count||void 0!==o.aff_quota&&o.aff_quota>0)&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[o.aff_code&&(0,s.jsx)(g,{label:l("Invitation Code"),value:o.aff_code}),void 0!==o.aff_count&&(0,s.jsx)(g,{label:l("Invited Users"),value:(0,h.wk)(o.aff_count)})]}),void 0!==o.aff_quota&&o.aff_quota>0&&(0,s.jsx)(g,{label:l("Invitation Quota"),value:(0,h.eN)(o.aff_quota)})]}),o.remark&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{className:"text-muted-foreground text-xs",children:l("Remark")}),(0,s.jsx)("div",{className:"text-sm leading-relaxed font-semibold break-words",children:o.remark})]})]}):(0,s.jsx)("div",{className:"text-muted-foreground py-8 text-center text-sm",children:l("No user information available")})})}var e3=a(56120),e4=a(7579),e6=a(8803),e8=a(56275),e7=a(10823),e9=a(40315),te=a(47296),tt=a(98622),ta=a(13683),ts=a(74501),tn=a(47303),tl=a(15585),tr=a(43459),ti=a(64832);let to={set:"Set",delete:"Delete",copy:"Copy",move:"Move",append:"Append",prepend:"Prepend",trim_prefix:"Trim Prefix",trim_suffix:"Trim Suffix",ensure_prefix:"Ensure Prefix",ensure_suffix:"Ensure Suffix",trim_space:"Trim Space",to_lower:"To Lower",to_upper:"To Upper",replace:"Replace",regex_replace:"Regex Replace",set_header:"Set Header",delete_header:"Delete Header",copy_header:"Copy Header",move_header:"Move Header",pass_headers:"Pass Headers",sync_fields:"Sync Fields",return_error:"Return Error"};function tc(e){return!!e&&(!0===e.violation_fee||!!e.violation_fee_code||!!e.violation_fee_marker)}function td(e){return"number"==typeof e&&Number.isFinite(e)&&e>0}function tu(e,t,a){return!0===e&&td(t)&&td(a)}function tm(e){if(!e)return null;try{return JSON.parse(e)}catch(e){return console.error("Failed to parse log other field:",e),null}}function tx(e){return e<5?"success":e<10?"warning":"danger"}function tp(e,t){var a;return t<100||e<=0?e<10?"success":e<30?"warning":"danger":(a=t/e)>=30?"success":a>=15?"warning":"danger"}function th(e){if(!e)return"";try{let t="u">typeof window?window.atob(e):Buffer.from(e,"base64").toString("binary"),a=new Uint8Array(t.length);for(let e=0;e<t.length;e++)a[e]=t.charCodeAt(e);if("u">typeof TextDecoder)return new TextDecoder().decode(a);return decodeURIComponent(Array.prototype.map.call(a,e=>`%${e.toString(16).padStart(2,"0")}`).join(""))}catch{return""}}function tg(e){return!!e&&((e.cache_tokens||0)>0||(e.cache_creation_tokens||0)>0||(e.cache_creation_tokens_5m||0)>0||(e.cache_creation_tokens_1h||0)>0)}function tf(e){var t;if(!e||"tiered_expr"!==e.billing_mode)return null;let a=th(e.expr_b64);if(!a)return null;let s=(0,ti.oK)(a),n=(t=e.matched_tier,0!==s.length&&t&&s.find(e=>{let a=(0,ti.wM)(e.label);return a===(0,ti.wM)(t)&&""!==a})||null);if(!n)return null;let l=tg(e),r=[];for(let e of ti.mq){if(!e.field||"cache"===e.group&&!l)continue;let t=Number(n[e.field]);Number.isFinite(t)&&t>0&&r.push({field:e.field,shortLabel:e.shortLabel,price:t})}return{tiers:s,tier:n,priceEntries:r}}let tb={login:"Logged in successfully via {{method}}","user.create":"Created user {{username}} (role {{role}})","user.update":"Updated user {{username}} (ID: {{id}})","user.delete":"Deleted user {{username}} (ID: {{id}})","user.manage":"Performed {{action}} on user {{username}} (ID: {{id}})","user.quota_add":"Increased user quota by {{quota}}","user.quota_subtract":"Decreased user quota by {{quota}}","user.quota_override":"Overrode user quota from {{from}} to {{to}}","user.binding_clear":"Cleared {{bindingType}} binding for user {{username}}","user.2fa_disable":"Force-disabled two-factor authentication for the user","user.passkey_register":"Registered a passkey","user.passkey_delete":"Deleted a passkey","user.topup_complete":"Completed top-up order for the user","user.reset_passkey":"Reset the user passkey","user.oauth_unbind":"Removed an OAuth binding for the user","option.update":"Updated system setting {{key}}","option.payment_compliance":"Confirmed payment compliance","option.reset_ratio":"Reset model ratios","option.clear_affinity_cache":"Cleared channel affinity cache","custom_oauth.create":"Created a custom OAuth provider","custom_oauth.update":"Updated a custom OAuth provider","custom_oauth.delete":"Deleted a custom OAuth provider","performance.clear_disk_cache":"Cleared disk cache","performance.gc":"Triggered garbage collection","performance.clear_logs":"Cleared log files","channel.create":"Created channel {{name}} (type {{type}}, count {{count}})","channel.update":"Updated channel {{name}} (ID: {{id}})","channel.delete":"Deleted channel {{name}} (ID: {{id}})","channel.delete_batch":"Batch deleted {{count}} channels","channel.delete_disabled":"Deleted all disabled channels ({{count}})","channel.key_view":"Viewed channel key {{name}} (ID: {{id}})","channel.tag_disable":"Disabled channels with tag {{tag}}","channel.tag_enable":"Enabled channels with tag {{tag}}","channel.tag_edit":"Edited channels with tag {{tag}}","channel.tag_batch_set":"Batch set tag for {{count}} channels","channel.copy":"Copied channel (source ID: {{sourceId}}) to {{name}} (new ID: {{id}})","channel.multi_key_manage":"Multi-key management {{action}} on channel (ID: {{id}})","channel.upstream_apply":"Applied upstream model changes to channel (ID: {{id}})","channel.upstream_apply_all":"Applied upstream model changes to {{count}} channels","redemption.create":"Created {{count}} redemption codes named {{name}} ({{quota}} each)","redemption.update":"Updated a redemption code","redemption.delete":"Deleted a redemption code","redemption.delete_invalid":"Deleted invali
1d redemption codes","prefill_group.create":"Created a prefill group","prefill_group.update":"Updated a prefill group","prefill_group.delete":"Deleted a prefill group","vendor.create":"Created a vendor","vendor.update":"Updated a vendor","vendor.delete":"Deleted a vendor","model.create":"Created a model","model.update":"Updated a model","model.delete":"Deleted a model","model.sync_upstream":"Synced upstream models","deployment.create":"Created a deployment","deployment.update":"Updated a deployment","deployment.delete":"Deleted a deployment","subscription.plan_create":"Created a subscription plan","subscription.plan_update":"Updated a subscription plan","subscription.bind":"Bound a subscription","ticket.invoice_issue":"Marked invoice ticket {{ticket_id}} as issued (fee {{fee_quota}})","ticket.invoice_reject":"Rejected invoice request on ticket {{ticket_id}}","log.clear":"Cleared historical logs","log.cleanup_start":"Log cleanup task started.",generic:"{{method}} {{route}}"};function tj(e,t){let a=e?.op;if(!a?.action)return null;let s=tb[a.action];return s?t(s,a.params??{}):null}var tv=a(67733),t_=a(67834),ty=a(99893),tN=a(35285),tw=a(96855),tk=a(73606),tC=a(86094),tS=a(61569),tA=a(59736),tT=a(74147),tI=a(75552),t$=a(71057),tR=a(76336),tq=a(39649),tF=a(51346),tz=a(29625);let tD="local",tE={status:"Status",models:"Models",group:"Group",type:"Type",base_url:"Base URL",key:"Key"};function tM(e){return"success"===e?"text-emerald-600":"warning"===e?"text-amber-600":"text-rose-600"}function tL(e){return(0,s.jsxs)("div",{className:"grid min-w-0 grid-cols-[5.25rem_minmax(0,1fr)] gap-2 text-sm sm:grid-cols-[7rem_minmax(0,1fr)] sm:gap-3",children:[(0,s.jsx)("span",{className:"text-muted-foreground min-w-0 text-xs",children:e.label}),(0,s.jsx)("span",{className:(0,e8.cn)("max-w-full min-w-0 text-xs break-all sm:wrap-break-word",e.mono&&"font-mono",e.muted&&"text-muted-foreground"),children:e.value})]})}function tP(e){let t="danger"===e.variant,a=t?"destructive":e.iconTone;return(0,s.jsxs)("div",{className:"min-w-0 space-y-1.5",children:[(0,s.jsxs)(C.J,{className:(0,e8.cn)("flex items-center gap-1.5 text-xs font-semibold",t&&"text-red-500"),children:[e.icon&&(0,s.jsx)(tq.f,{tone:a,size:"xs",children:e.icon}),e.label]}),(0,s.jsx)("div",{className:(0,e8.cn)("min-w-0 space-y-1 overflow-hidden rounded-md border p-2.5 max-sm:p-2",t?"border-red-200 bg-red-50 dark:border-red-900 dark:bg-red-950/20":"bg-muted/30"),children:e.children})]})}function tO(e,t){switch(t?.usage_billing_path){case tD:return e("Local Billing");case"billing-usage-openai":return e("Upstream Response (billing-usage-openai)");case"billing-usage-openai-estimated":return e("Upstream Response (billing-usage-openai-estimated)");case"billing-usage-anthropic":return e("Upstream Response (billing-usage-anthropic)");case"billing-usage-anthropic-estimated":return e("Upstream Response (billing-usage-anthropic-estimated)");case"billing-usage-gemini":return e("Upstream Response (billing-usage-gemini)");case"billing-usage-gemini-estimated":return e("Upstream Response (billing-usage-gemini-estimated)");case"upstream":return e("Upstream Response");default:return e(t?.local_count_tokens?"Local Billing":"Upstream Response")}}function tK(e){let{t}=(0,i.Bd)(),{log:a,other:n,isAdmin:l}=e,r=(n.model_price??0)>0,o=!0===n.claude,c="tiered_expr"===n.billing_mode,d=tf(n),u=[],m={digitsLarge:4,digitsSmall:6,abbreviate:!1},x=e=>(0,tr.AM)(e,m),p=null!=n.model_ratio?2*n.model_ratio:0;if(c)if(u.push({label:t("Billing Mode"),value:t("Dynamic Pricing")}),d)for(let e of(d.tier.label&&u.push({label:t("Matched Tier"),value:d.tier.label}),d.priceEntries))u.push({label:t(e.shortLabel),value:`${x(e.price)}/M`});else u.push({label:t("Matched Tier"),value:t("No matching results")});else r?(u.push({label:t("Billing Mode"),value:t("Per-call")}),null!=n.model_price&&u.push({label:t("Model Price"),value:x(n.model_price)})):(u.push({label:t("Billing Mode"),value:t("Per-token")}),null!=n.model_ratio&&u.push({label:t("Input"),value:`${x(p)}/M`}),null!=n.completion_ratio&&null!=n.model_ratio&&u.push({label:t("Output"),value:`${x(p*n.completion_ratio)}/M`}));let g=n.user_group_ratio,f=null!=g&&Number.isFinite(g)&&-1!==g,b=f?g:n.group_ratio;return(null!=b&&Number.isFinite(b)&&u.push({label:t(f?"User Exclusive Ratio":"Group Ratio"),value:`${null==b?"-":b.toFixed(4)}x`}),!c&&o&&tg(n)&&(null!=n.cache_ratio&&1!==n.cache_ratio&&u.push({label:t("Cache Read"),value:`${x(p*n.cache_ratio)}/M`}),null!=n.cache_creation_ratio&&1!==n.cache_creation_ratio&&u.push({label:t("Cache Creation"),value:`${x(p*n.cache_creation_ratio)}/M`}),null!=n.cache_creation_ratio_5m&&0!==n.cache_creation_ratio_5m&&u.push({label:t("Cache Creation (5m)"),value:`${x(p*n.cache_creation_ratio_5m)}/M`}),null!=n.cache_creation_ratio_1h&&0!==n.cache_creation_ratio_1h&&u.push({label:t("Cache Creation (1h)"),value:`${x(p*n.cache_creation_ratio_1h)}/M`})),c||(null!=n.audio_ratio&&1!==n.audio_ratio&&u.push({label:t("Audio input"),value:`${x(p*n.audio_ratio)}/M`}),null!=n.audio_completion_ratio&&1!==n.audio_completion_ratio&&u.push({label:t("Audio output"),value:`${x(p*n.audio_completion_ratio)}/M`}),null!=n.image_ratio&&1!==n.image_ratio&&u.push({label:t("Image input"),value:`${x(p*n.image_ratio)}/M`})),n.web_search&&n.web_search_call_count&&u.push({label:t("Web Search"),value:`${n.web_search_call_count}x${n.web_search_price?` (${x(n.web_search_price)})`:""}`}),n.file_search&&n.file_search_call_count&&u.push({label:t("File Search"),value:`${n.file_search_call_count}x${n.file_search_price?` (${x(n.file_search_price)})`:""}`}),n.image_generation_call&&n.image_generation_call_price&&u.push({label:t("Image Generation"),value:x(n.image_generation_call_price)}),n.audio_input_seperate_price&&n.audio_input_price&&u.push({label:t("Audio Input Price"),value:x(n.audio_input_price)}),l&&n.admin_info&&u.push({label:t("Billing Path"),value:tO(t,n.admin_info)}),u.push({label:t("Total Cost"),value:(0,h.qW)(a.quota)}),0===u.length)?null:(0,s.jsx)(tP,{label:t("Billing Details"),children:u.map(e=>(0,s.jsx)(tL,{label:e.label,value:e.value,mono:!0},e.label))})}function tB(e){let{t}=(0,i.Bd)(),{log:a,other:n}=e,l=a.prompt_tokens||0,r=a.completion_tokens||0,o=n.cache_tokens||0,c=n.cache_creation_tokens||0,d=n.cache_creation_tokens_5m||0,u=n.cache_creation_tokens_1h||0;if(!(l>0||r>0))return null;let m=[];
1return m.push({label:t("Input Tokens"),value:l.toLocaleString()}),m.push({label:t("Output Tokens"),value:r.toLocaleString()}),o>0&&m.push({label:t("Cache Read"),value:o.toLocaleString()}),c>0&&0===d&&0===u&&m.push({label:t("Cache Write"),value:c.toLocaleString()}),d>0&&m.push({label:t("Cache Write (5m)"),value:d.toLocaleString()}),u>0&&m.push({label:t("Cache Write (1h)"),value:u.toLocaleString()}),n.image&&n.image_output&&m.push({label:t("Image Tokens"),value:n.image_output.toLocaleString()}),(0,s.jsx)(tP,{label:t("Token Breakdown"),children:m.map(e=>(0,s.jsx)(tL,{label:e.label,value:e.value,mono:!0},e.label))})}function tU(e){var t,a;let{t:n}=(0,i.Bd)(),{copiedText:l,copyToClipboard:r}=(0,tz.C)({notify:!1}),o=eK(e.log.content??""),c=tm(e.log.other),d=ez(e.log.type),u=tc(c),m=6===e.log.type,x=2===e.log.type,g=1===e.log.type,f=3===e.log.type,b=c?.billing_source==="subscription",j=x&&!u&&c?.billing_mode==="tiered_expr"&&!!c?.expr_b64,v=c?.ws||c?.audio,_=eF(e.log.type),y=!!e.log.ip&&(_||e.isAdmin&&g),N=c?.admin_info,k=g&&e.isAdmin&&N?[N.payment_method&&{label:n("Order Payment Method"),value:N.payment_method},N.callback_payment_method&&{label:n("Callback Payment Method"),value:N.callback_payment_method},N.caller_ip&&{label:n("Callback Caller IP"),value:N.caller_ip},N.server_ip&&{label:n("Server IP"),value:N.server_ip},N.node_name&&{label:n("Node Name"),value:N.node_name},N.version&&{label:n("System Version"),value:N.version}].filter(Boolean):[],S=g&&e.isAdmin&&!N,A=g&&e.isAdmin&&(k.length>0||S),I=(()=>{if(!f||!e.isAdmin||!N)return null;let t=N.admin_username,a=N.admin_id,s=null!=t&&""!==String(t).trim(),n=null!=a&&""!==String(a).trim();return s||n?s&&n?`${t} (ID: ${a})`:s?String(t):`ID: ${a}`:null})(),$=f&&e.isAdmin&&N?.auth_method?"access_token"===N.auth_method?n("Access Token"):"session"===N.auth_method?n("Session"):String(N.auth_method):"",R=tj(c,n),q=f&&e.isAdmin?c?.audit_info:void 0,F=(f&&e.isAdmin&&Array.isArray(c?.op?.params?.changed_fields)?c.op.params.changed_fields:[]).map(e=>n(tE[e]??e)).join(", "),z=f&&e.isAdmin&&(null!=R||null!=q),D=7===e.log.type,E=D?[c?.login_method&&{label:n("Login Method"),value:String(c.login_method)},e.log.ip&&{label:n("IP Address"),value:e.log.ip},c?.user_agent&&{label:n("User Agent"),value:String(c.user_agent)}].filter(Boolean):[],M=c&&Array.isArray(c.request_conversion)?c.request_conversion.filter(Boolean):[],L=M.length<=1?n("Native format"):M.join(" -> "),P=e.isAdmin&&6!==e.log.type&&(c?.request_path||M.length>0),O=c?.admin_info?.use_channel,K=O&&O.length>0?O.join(" â "):void 0,B=function(e){switch(e?.trim().toLowerCase()){case"max":case"xhigh":case"high":return"orange";case"medium":return"yellow";case"low":case"minimal":return"green";default:return"grey"}}(c?.reasoning_effort);return(0,s.jsx)(p.l,{open:e.open,onOpenChange:e.onOpenChange,title:(0,s.jsxs)(s.Fragment,{children:[n("Log Details"),(0,s.jsx)(T.Wh,{label:n(d.label),variant:d.color,size:"sm",copyable:!1})]}),description:n("View the complete details for this log entry"),contentClassName:(0,e8.cn)("min-w-0 overflow-hidden","max-sm:max-h-[calc(100dvh-1.5rem)] max-sm:w-[calc(100vw-1.5rem)] max-sm:max-w-[calc(100vw-1.5rem)] max-sm:p-4",j?"sm:max-w-4xl lg:max-w-5xl":"sm:max-w-lg"),headerClassName:"max-sm:gap-1",titleClassName:"flex items-center gap-2 text-base",descriptionClassName:"sr-only",contentHeight:"min(72dvh, 720px)",bodyClassName:"pr-2 sm:pr-4",children:(0,s.jsxs)("div",{className:"w-full max-w-full min-w-0 space-y-2.5 overflow-x-hidden py-1 sm:space-y-3",children:[(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[e.log.request_id&&(0,s.jsx)(tL,{label:n("Request ID"),value:e.log.request_id,mono:!0}),e.log.upstream_request_id&&(0,s.jsx)(tL,{label:n("Upstream Request ID"),value:e.log.upstream_request_id,mono:!0}),e.isAdmin&&e.log.channel>0&&(0,s.jsx)(tL,{label:n("Channel"),value:(0,s.jsxs)("span",{children:[e.log.channel,e.log.channel_name&&(0,s.jsxs)("span",{className:"text-muted-foreground",children:[" ","(",e.log.channel_name,")"]})]}),mono:!0}),K&&e.isAdmin&&(0,s.jsx)(tL,{label:n("Retry Chain"),value:K,mono:!0}),e.log.token_name&&(0,s.jsx)(tL,{label:n("Token"),value:e.log.token_name,mono:!0}),(e.log.group||c?.group)&&(0,s.jsx)(tL,{label:n("Group"),value:e.log.group||c?.group||"",mono:!0}),y&&(0,s.jsx)(tL,{label:n("IP Address"),value:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)(tv.A,{className:"size-3 text-amber-500","aria-hidden":"true"}),e.log.ip]}),mono:!0}),_&&e.log.use_time>0&&(0,s.jsx)(tL,{label:n("Response Time"),value:(0,s.jsxs)("span",{className:(0,e8.cn)("font-medium",tM(tp(e.log.use_time,e.log.completion_tokens))),children:[(0,h.KK)(e.log.use_time),e.log.is_stream&&c?.frt!=null&&c.frt>0&&(0,s.jsxs)("span",{className:(0,e8.cn)("font-normal",tM(tx(c.frt/1e3))),children:[" ","(FRT: ",(0,h.KK)(c.frt/1e3),")"]})]})})]}),P&&(0,s.jsx)(tP,{label:n("Request Conversion"),children:(0,s.jsxs)("div",{className:"relative min-w-0",children:[(0,s.jsx)(w.$,{variant:"ghost",size:"sm",className:"absolute top-0 right-0 h-5 w-5 p-0",onClick:()=>r(L),title:n("Copy to clipboard"),"aria-label":n("Copy to clipboard"),
1children:l===L?(0,s.jsx)(t_.A,{className:"size-3 text-green-600"}):(0,s.jsx)(ty.A,{className:"size-3"})}),(0,s.jsxs)("div",{className:"min-w-0 space-y-1 pr-6",children:[c?.request_path&&(0,s.jsx)(tL,{label:n("Path"),value:c.request_path,mono:!0}),(0,s.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[(0,s.jsx)(tN.A,{className:"text-muted-foreground size-3","aria-hidden":"true"}),(0,s.jsx)("span",{className:"min-w-0 break-all sm:wrap-break-word",children:L})]})]})]})}),e.isAdmin&&c?.admin_info?.quota_saturation&&(0,s.jsxs)(tP,{icon:(0,s.jsx)(tw.A,{className:"size-3.5","aria-hidden":"true"}),label:n("Quota clamped"),variant:"danger",children:[(0,s.jsx)("p",{className:"mb-1 text-xs wrap-break-word",children:n("Quota saturation protection triggered")}),(0,s.jsx)(tL,{label:n("Kind"),value:(t=c.admin_info.quota_saturation.kind,"overflow"===t?n("Overflow"):"underflow"===t?n("Underflow"):n("Invalid (NaN)"))}),(0,s.jsx)(tL,{label:n("Original value"),value:String(c.admin_info.quota_saturation.original),mono:!0}),(0,s.jsx)(tL,{label:n("Clamped to"),value:String(c.admin_info.quota_saturation.clamped),mono:!0}),(0,s.jsx)(tL,{label:n("Operation"),value:c.admin_info.quota_saturation.op,mono:!0})]}),e.isAdmin&&c?.reject_reason&&(0,s.jsx)(tP,{icon:(0,s.jsx)(tw.A,{className:"size-3.5","aria-hidden":"true"}),label:n("Reject Reason"),variant:"danger",children:(0,s.jsx)("p",{className:"text-xs wrap-break-word",children:c.reject_reason})}),u&&c&&(0,s.jsxs)(tP,{icon:(0,s.jsx)(tw.A,{className:"size-3.5","aria-hidden":"true"}),label:n("Violation Fee"),variant:"danger",children:[c.violation_fee_code&&(0,s.jsx)(tL,{label:n("Violation Code"),value:c.violation_fee_code,mono:!0}),c.violation_fee_marker&&(0,s.jsx)(tL,{label:n("Violation Marker"),value:c.violation_fee_marker}),(0,s.jsx)(tL,{label:n("Fee Amount"),value:(0,h.qW)(c.fee_quota??e.log.quota),mono:!0})]}),m&&c&&(c.task_id||c.reason)&&(0,s.jsxs)(tP,{label:n("Refund Details"),children:[c.task_id&&(0,s.jsx)(tL,{label:n("Task ID"),value:c.task_id,mono:!0}),c.reason&&(0,s.jsx)(tL,{label:n("Reason"),value:c.reason})]}),A&&(0,s.jsxs)(tP,{icon:(0,s.jsx)(tk.A,{className:"size-3.5","aria-hidden":"true"}),iconTone:"success",label:n("Top-up Audit Info"),children:[k.map(e=>(0,s.jsx)(tL,{label:e.label,value:e.value,mono:!0},e.label)),S&&(0,s.jsxs)("div",{className:"flex items-start gap-1.5 text-xs text-amber-600 dark:text-amber-400",children:[(0,s.jsx)(tC.A,{className:"mt-0.5 size-3.5 shrink-0","aria-hidden":"true"}),(0,s.jsx)("span",{children:n("This historical record predates audit-info tracking and cannot be backfilled. The current instance already records server IP, callback IP, payment method, and system version for new top-ups going forward.")})]})]}),I&&(0,s.jsx)(tL,{label:(0,s.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(tS.A,{className:"text-muted-foreground size-3.5","aria-hidden":"true"}),n("Operator Admin")]}),value:I,mono:!0}),z&&(0,s.jsxs)(tP,{icon:(0,s.jsx)(tk.A,{className:"size-3.5","aria-hidden":"true"}),iconTone:"info",label:n("Operation Audit Info"),children:[null!=R&&(0,s.jsx)(tL,{label:n("Operation"),value:R}),""!==$&&(0,s.jsx)(tL,{label:n("Authentication Method"),value:$}),""!==F&&(0,s.jsx)(tL,{label:n("Changed Fields"),value:F}),q?.method&&q?.route&&(0,s.jsx)(tL,{label:n("Request"),value:`${q.method} ${q.route}`,mono:!0}),q?.status!=null&&(0,s.jsx)(tL,{label:n("Result"),value:q.success?`${n("Success")} (${q.status})`:`${n("Failed")} (${q.status})`,mono:!0})]}),D&&E.length>0&&(0,s.jsxs)(tP,{icon:(0,s.jsx)(tA.A,{className:"size-3.5","aria-hidden":"true"}),iconTone:"info",label:n("Login Info"),children:[null!=R&&(0,s.jsx)(tL,{label:n("Operation"),value:R}),E.map(e=>(0,s.jsx)(tL,{label:e.label,value:e.value,mono:!0},e.label))]}),v&&c&&(0,s.jsxs)(tP,{icon:(0,s.jsx)(tT.A,{className:"size-3.5","aria-hidden":"true"}),iconTone:"chart-4",label:n("Audio Tokens"),children:[null!=c.audio_input&&c.audio_input>0&&(0,s.jsx)(tL,{label:n("Audio Input"),value:(0,h._y)(c.audio_input),mono:!0}),null!=c.audio_output&&c.audio_output>0&&(0,s.jsx)(tL,{label:n("Audio Output"),value:(0,h._y)(c.audio_output),mono:!0}),null!=c.text_input&&c.text_input>0&&(0,s.jsx)(tL,{label:n("Text Input"),value:(0,h._y)(c.text_input),mono:!0}),null!=c.text_output&&c.text_output>0&&(0,s.jsx)(tL,{label:n("Text Output"),value:(0,h._y)(c.text_output),mono:!0})]}),c?.reasoning_effort&&(0,s.jsx)(tL,{label:n("Reasoning Effort"),value:(0,s.jsx)(T.Wh,{label:c.reasoning_effort,variant:B,size:"sm",copyable:!1})}),c?.is_system_prompt_overwritten&&(0,s.jsx)(tL,{label:n("System Prompt"),value:(0,s.jsx)(T.Wh,{label:n("Overwritten"),variant:"orange",size:"sm",copyable:!1})}),c?.is_model_mapped&&c?.upstream_model_name&&(0,s.jsxs)(tP,{label:n("Model Mapping"),children:[(0,s.jsx)(tL,{label:n("Request Model"),value:e.log.model_name,mono:!0}),(0,s.jsx)(tL,{label:n("Actual Model"),value:c.upstream_model_name,mono:!0})]}),[0,2,5,6].includes(e.log.type)&&c&&(0,s.jsx)(tB,{log:e.log,other:c}),x&&c&&!u&&(0,s.jsx)(tK,{log:e.log,other:c,isAdmin:e.isAdmin}),j&&c?.expr_b64&&(0,s.jsx)(tP,{label:n("Dynamic Pricing"),children:(0,s.jsx)(tF.N,{compact:!0,billingExpr:th(c.expr_b64),matchedTierLabel:c.matched_tier,requestRules:c.request_rules,hideCacheColumns:!tg(c)})}),e.isAdmin&&!x&&6!==e.log.type&&c?.admin_info&&(0,s.jsx)(tL,{label:n("Billing Path"),value:(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(a=c.admin_info,a?.usage_billing_path?a.usage_billing_path===tD:a?.local_count_tokens===!0)?(0,s.jsx)(tI.A,{className:"size-3 text-blue-500"}):(0,s.jsx)(t$.A,{className:"size-3 text-emerald-500"}),(0,s.jsx)("span",{className:"text-xs",children:tO(n,c.admin_info)})]})}),c?.stream_status&&"ok"!==c.stream_status.status&&(0,s.jsxs)(tP,{label:n("Stream Status"),children:[(0,s.jsx)(tL,{label:n("Status"),value:(0,s.jsx)(T.Wh,{label:c.stream_status.status||n("Error"),variant:"red",size:"sm",copyable:!1})}),c.stream_status.end_reason&&(0,s.jsx)(tL,{label:n("End Reason"),value:c.stream_status.end_reason}),(c.stream_status.error_count??0)>0&&(0,s.jsx)(tL,{label:n("Soft Errors"),value:String(c.stream_status.error_count)}
1),c.stream_status.end_error&&(0,s.jsx)(tL,{label:n("End Error"),value:c.stream_status.end_error}),Array.isArray(c.stream_status.errors)&&c.stream_status.errors.length>0&&(0,s.jsx)("pre",{className:"bg-background/60 mt-1 max-h-32 overflow-y-auto rounded border p-2 font-mono text-[11px] leading-relaxed wrap-break-word whitespace-pre-wrap",children:c.stream_status.errors.join("\n")})]}),b&&c&&(0,s.jsxs)(tP,{label:n("Subscription Billing"),children:[c.subscription_plan_id&&(0,s.jsx)(tL,{label:n("Plan"),value:`#${c.subscription_plan_id} ${c.subscription_plan_title||""}`.trim()}),c.subscription_id&&(0,s.jsx)(tL,{label:n("Instance"),value:`#${c.subscription_id}`,mono:!0}),null!=c.subscription_pre_consumed&&(0,s.jsx)(tL,{label:n("Pre-consumed"),value:(0,h.qW)(c.subscription_pre_consumed),mono:!0}),null!=c.subscription_post_delta&&0!==c.subscription_post_delta&&(0,s.jsx)(tL,{label:n("Post Delta"),value:(0,h.qW)(c.subscription_post_delta),mono:!0}),null!=c.subscription_consumed&&(0,s.jsx)(tL,{label:n("Final Consumed"),value:(0,h.qW)(c.subscription_consumed),mono:!0}),null!=c.subscription_remain&&(0,s.jsx)(tL,{label:n("Remaining"),value:`${(0,h.qW)(c.subscription_remain)}${null!=c.subscription_total?` / ${(0,h.qW)(c.subscription_total)}`:""}`,mono:!0})]}),c?.po&&Array.isArray(c.po)&&c.po.length>0&&(0,s.jsx)(tP,{icon:(0,s.jsx)(tR.A,{className:"size-3.5","aria-hidden":"true"}),iconTone:"chart-3",label:`${n("Param Override")} (${c.po.length})`,children:c.po.filter(Boolean).map(e=>{var t;let a,l=function(e){if("string"!=typeof e)return null;let t=e.indexOf(" ");return t<=0?{action:e,content:e}:{action:e.slice(0,t),content:e.slice(t+1)}}(e);return l?(0,s.jsxs)("div",{className:"bg-background/60 flex min-w-0 flex-col gap-1.5 rounded border p-2 sm:flex-row sm:items-start sm:gap-2",children:[(0,s.jsx)(T.Wh,{variant:"neutral",label:(t=l.action,(a=to[t.toLowerCase()])?n(a):t),className:"shrink-0 font-medium",copyable:!1}),(0,s.jsx)("span",{className:"min-w-0 font-mono text-[11px] leading-relaxed break-all sm:wrap-break-word",children:l.content})]},`${l.action}-${l.content}`):null})}),o&&(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)(C.J,{className:"text-xs font-semibold",children:n("Content")}),(0,s.jsxs)("div",{className:"bg-muted/30 relative min-w-0 overflow-hidden rounded-md border p-2.5",children:[(0,s.jsx)(w.$,{variant:"ghost",size:"sm",className:"absolute top-1.5 right-1.5 h-5 w-5 p-0",onClick:()=>r(o),title:n("Copy to clipboard"),"aria-label":n("Copy to clipboard"),children:l===o?(0,s.jsx)(t_.A,{className:"size-3 text-green-600"}):(0,s.jsx)(ty.A,{className:"size-3"})}),(0,s.jsx)("p",{className:"min-w-0 pr-6 text-xs leading-relaxed break-all whitespace-pre-wrap sm:wrap-break-word",children:o})]})]})]})})}var tV=a(21834),tH=a(74401),tW=a(90879);function tG(){let{t:e}=(0,i.Bd)(),t=e("Includes tool-call surcharge");return(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsxs)(tW.E,{variant:"warning",className:"h-5 min-w-5 cursor-help gap-0 rounded-full px-1",role:"img","aria-label":t,tabIndex:0,"data-tool-surcharge-indicator":"true",children:[(0,s.jsx)(tH.n,{icon:tV.A,strokeWidth:2,"aria-hidden":"true"}),(0,s.jsx)("span",{className:"text-[9px] leading-none font-bold","aria-hidden":"true",children:"+"})]})}),(0,s.jsx)(tn.ZI,{children:t})]})}function tZ(e){var t;let a,n=(a=(t=(0,h.qW)(e.quota)).match(/^([^0-9+\-.,\s]+)(.+)$/))?{prefix:a[1],amount:a[2]}:{prefix:"",amount:t};return(0,s.jsxs)("span",{className:"border-border/80 bg-muted/60 inline-flex h-6 w-fit items-center rounded-md border px-2 [font-family:var(--font-body)] text-sm leading-none font-semibold tabular-nums",children:[n.prefix?(0,s.jsx)("span",{className:"mr-1",children:n.prefix}):null,(0,s.jsx)("span",{children:n.amount})]})}function tQ(e){let{t}=(0,i.Bd)();return(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)(T.Wh,{label:t("Subscription"),variant:"success",size:"sm",copyable:!1,className:"cursor-help"})}),(0,s.jsx)(tn.ZI,{children:(0,s.jsxs)("span",{children:[t("Deducted by subscription"),": ",(0,h.qW)(e.quota)]})})]})}function tJ(e){var t;let a=e.other?.billing_source==="subscription",n=!!(t=e.other)&&(!!(Array.isArray(t.tool_surcharges)&&t.tool_surcharges.some(e=>"string"==typeof e?.name&&""!==e.name.trim()&&td(e.count)&&td(e.price))||tu(t.web_search,t.web_search_call_count,t.web_search_price)||tu(t.file_search,t.file_search_call_count,t.file_search_price))||!0===t.image_generation_call&&td(t.image_generation_call_price));return a||n?(0,s.jsx)(tn.Bc,{children:(0,s.jsxs)("div",{className:"inline-flex items-center gap-1",children:[a?(0,s.jsx)(tQ,{quota:e.quota}):(0,s.jsx)(tZ,{quota:e.quota}),n?(0,s.jsx)(tG,{}):null]})}):(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:(0,s.jsx)(tZ,{quota:e.quota})})}var tY=a(95327);function tX(e){let t,a,n=(t=e.modelName.toLowerCase(),(a=e=>e.some(e=>t.includes(e)))(["gpt-","chatgpt-","text-embedding-","omni-moderation","dall-e","whisper","tts-"])||/\bo[134](?:-|$)/.test(t)?{icon:"OpenAI.Color",label:"OpenAI"}:a(["claude-","anthropic"])?{icon:"Claude.Color",label:"Claude"}:a(["gemini-","learnlm-"])?{icon:"Gemini.Color",label:"Gemini"}:a(["grok-","xai-"])?{icon:"Grok.Color",label:"Grok"}:a(["deepseek-"])?{icon:"DeepSeek.Color",label:"DeepSeek"}
1:a(["qwen","qwq-"])?{icon:"Qwen.Color",label:"Qwen"}:a(["doubao-","volcengine"])?{icon:"Doubao.Color",label:"Doubao"}:a(["moonshot-","kimi-"])?{icon:"Moonshot.Color",label:"Moonshot"}:a(["minimax","abab"])?{icon:"Minimax.Color",label:"MiniMax"}:a(["glm-","chatglm","cogview","cogvideo"])?{icon:"Zhipu.Color",label:"Zhipu"}:a(["mimo-"])?{icon:"XiaomiMiMo",label:"MiMo"}:a(["ernie"])?{icon:"Wenxin.Color",label:"Baidu"}:a(["spark"])?{icon:"Spark.Color",label:"iFlyTek"}:a(["hunyuan"])?{icon:"Hunyuan.Color",label:"Tencent"}:a(["baichuan"])?{icon:"Baichuan.Color",label:"Baichuan"}:a(["internlm"])?{icon:"InternLM.Color",label:"InternLM"}:a(["step-"])?{icon:"Stepfun.Color",label:"StepFun"}:a(["yi-"])?{icon:"Yi.Color",label:"Yi"}:a(["mistral-","mixtral-"])?{icon:"Mistral.Color",label:"Mistral"}:a(["llama-","meta-"])?{icon:"Meta.Color",label:"Meta"}:a(["command-","cohere-"])?{icon:"Cohere.Color",label:"Cohere"}:null);return(0,s.jsx)(T.Wh,{copyText:e.modelName,size:"sm",showDot:!n,autoColor:n?void 0:e.modelName,className:(0,e8.cn)("border-border/60 bg-muted/30 h-6 max-w-none gap-1.5 rounded-md border px-2 [font-family:var(--font-body)]",n&&"text-foreground",e.className),children:(0,s.jsxs)("span",{className:"flex max-w-none items-center gap-1.5",children:[n&&(0,s.jsx)("span",{className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center",title:n.label,"aria-label":n.label,children:(0,tY.Y)(n.icon,18)}),(0,s.jsx)("span",{className:"whitespace-nowrap",children:e.modelName})]})})}function t0(e){let{t}=(0,i.Bd)();return e.actualModel?(0,s.jsxs)(ts.AM,{children:[(0,s.jsxs)(ts.Wv,{render:(0,s.jsx)("button",{type:"button",className:"inline-flex items-center gap-1"}),children:[(0,s.jsx)(tX,{...e}),(0,s.jsx)(tN.A,{className:"text-muted-foreground size-3 shrink-0"})]}),(0,s.jsx)(ts.hl,{className:"w-72",children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:t("Request Model:")}),(0,s.jsx)("span",{className:"truncate font-mono text-xs font-medium",children:e.modelName})]}),(0,s.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:t("Actual Model:")}),(0,s.jsx)("span",{className:"truncate font-mono text-xs font-medium",children:e.actualModel})]})]})})]}):(0,s.jsx)(tX,{...e})}var t1=a(52671);let t5={...T.jk,success:"bg-success/90",warning:"bg-warning/80",danger:"bg-destructive/80",neutral:"bg-neutral/80"};function t2(e){let{t}=(0,i.Bd)(),a=e.indicator??"bar",n=e.isStream,l=null!=e.frtMs&&e.frtMs>0?e.frtMs/1e3:null,r=null==l?"neutral":tx(l),o=tp(e.useTimeSec,e.completionTokens),c=null==l?t("N/A"):(0,h.KK)(l),d=(0,h.KK)(e.useTimeSec),u=(0,s.jsxs)("div",{className:"flex min-h-8 min-w-0 flex-col justify-center gap-0.5 text-xs leading-tight",children:[n&&(0,s.jsxs)("div",{className:"flex items-baseline gap-1.5",children:["dot"===a&&(0,s.jsx)("span",{"aria-hidden":!0,className:(0,e8.cn)("size-1.5 shrink-0 rounded-full",T.jk[r])}),(0,s.jsx)("span",{className:"text-muted-foreground shrink-0",children:t("First token")}),(0,s.jsx)("span",{className:(0,e8.cn)("tabular-nums",T.BQ[r]),children:c})]}),(0,s.jsxs)("div",{className:"flex items-baseline gap-1.5",children:["dot"===a&&(0,s.jsx)("span",{"aria-hidden":!0,className:(0,e8.cn)("size-1.5 shrink-0 rounded-full",T.jk[o])}),(0,s.jsx)("span",{className:"text-muted-foreground shrink-0",children:t("Duration")}),(0,s.jsx)("span",{className:(0,e8.cn)("tabular-nums",T.BQ[o]),children:d})]})]});return"dot"===a?(0,s.jsx)("div",{className:(0,e8.cn)("flex items-stretch",e.className),children:u}):(0,s.jsxs)("div",{className:(0,e8.cn)("flex items-stretch gap-2",e.className),children:[(0,s.jsx)("span",{"aria-hidden":!0,className:(0,e8.cn)("flex w-1 shrink-0 flex-col overflow-hidden rounded-full",!n&&t5[o]),children:n&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:(0,e8.cn)("flex-1",t5[r])}),(0,s.jsx)("span",{className:(0,e8.cn)("flex-1",t5[o])})]})}),u]})}function t3(e){let{t}=(0,i.Bd)(),a=e.isStream&&e.streamStatus&&"ok"!==e.streamStatus.status,n=null!=e.tokensPerSecond?`${Math.round(e.tokensPerSecond)} t/s`:"â",l=t(e.isStream?"Stream":"Non-stream");return(0,s.jsxs)("div",{className:(0,e8.cn)("flex shrink-0 flex-col items-start justify-center gap-0.5 text-xs leading-tight",e.className),children:[(0,s.jsxs)("span",{className:(0,e8.cn)("inline-flex items-center gap-1 font-medium",e.isStream?"text-info":"text-muted-foreground"),children:[l,a&&(0,s.jsx)(tn.Bc,{children:(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)(t1.A,{className:"text-destructive size-3"})}),(0,s.jsx)(tn.ZI,{children:(0,s.jsxs)("div",{className:"space-y-0.5 text-xs",children:[(0,s.jsxs)("p",{children:[t("Stream Status"),": ",t("Error")]}),(0,s.jsx)("p",{children:e.streamStatus?.end_reason||"unknown"}),(e.streamStatus?.error_count??0)>0&&(0,s.jsxs)("p",{children:[t("Soft Errors"),": ",e.streamStatus?.error_count]})]})})]})})]}
1),(0,s.jsx)("span",{className:"text-muted-foreground/60 px-0.5 tabular-nums",children:n})]})}function t4(e){return null!=e&&Number.isFinite(e)?e%1==0?String(e):e.toFixed(4).replace(/\.?0+$/,""):"-"}var t6=a(66701),t8=a(95397),t7=a(59587),t9=a(66590),ae=a(94369),at=a(86077),aa=a(13236),as=a(76651),an=a(3225),al=a(40051),ar=a(54622),ai=a(30544),ao=a(83940),ac=a(32221),ad=a(5623);function au(e){return{getLabel:function(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Unknown";return e[t]?.label??a},getVariant:function(t){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"neutral";return e[t]?.variant??a}}}let am=au({[eo]:{label:"Draw",variant:"blue"},[ec]:{label:"Upscale",variant:"orange"},[ed]:{label:"Video",variant:"orange"},[eu]:{label:"Edit",variant:"orange"},[em]:{label:"Vary",variant:"violet"},[ex]:{label:"Vary (Strong)",variant:"violet"},[ep]:{label:"Vary (Subtle)",variant:"violet"},PAN:{label:"Pan",variant:"cyan"},[eh]:{label:"Describe",variant:"yellow"},[eg]:{label:"Blend",variant:"lime"},[ef]:{label:"Upload",variant:"blue"},[eb]:{label:"Shorten",variant:"pink"},[ej]:{label:"Reroll",variant:"indigo"},[ev]:{label:"Inpaint",variant:"teal"},[e_]:{label:"Swap Face",variant:"purple"},[ey]:{label:"Zoom",variant:"green"},[eN]:{label:"Custom Zoom",variant:"green"}}),ax=au({SUCCESS:{label:"Success",variant:"green"},NOT_START:{label:"Not Started",variant:"neutral"},SUBMITTED:{label:"Queued",variant:"yellow"},IN_PROGRESS:{label:"In Progress",variant:"blue"},FAILURE:{label:"Failed",variant:"red"},MODAL:{label:"Waiting",variant:"amber"}}),ap=au(eI),ah=au({MUSIC:{label:"Generate Music",variant:"neutral"},LYRICS:{label:"Generate Lyrics",variant:"pink"},[ew]:{label:"Image to Video",variant:"blue"},[ek]:{label:"Text to Video",variant:"blue"},[eC]:{label:"First/Last Frame to Video",variant:"blue"},[eS]:{label:"Reference Video",variant:"blue"},[eA]:{label:"Video Remix",variant:"blue"},generations:{label:"Image Generation",variant:"violet"},edits:{label:"Image Edit",variant:"violet"}}),ag=au({[eT]:{label:"Success",variant:"green"},NOT_START:{label:"Not Started",variant:"neutral"},SUBMITTED:{label:"Queued",variant:"yellow"},IN_PROGRESS:{label:"In Progress",variant:"blue"},FAILURE:{label:"Failed",variant:"red"},QUEUED:{label:"Queued",variant:"orange"},UNKNOWN:{label:"Unknown",variant:"neutral"}});var af=a(15161),ab=a(97785);function aj(e){let{imageUrl:t,taskId:a,open:n,onOpenChange:l}=e,{t:o}=(0,i.Bd)(),[c,d]=(0,r.useState)(!0),[u,m]=(0,r.useState)(!1);return(0,s.jsx)(p.l,{open:n,onOpenChange:e=>{e&&(d(!0),m(!1)),l(e)},title:o("Image Preview"),description:a?`${o("Task ID:")} ${a}`:o("View the generated image"),contentClassName:"sm:max-w-3xl",contentHeight:"auto",bodyClassName:"space-y-4",children:(0,s.jsx)(af.F,{className:"max-h-[600px]",children:(0,s.jsxs)("div",{className:"py-4",children:[(0,s.jsxs)("div",{className:"bg-muted/50 relative flex min-h-[300px] items-center justify-center rounded-lg border",children:[(c||u)&&(0,s.jsx)(ab.E,{className:"absolute inset-0 h-full w-full rounded-lg"}),(0,s.jsx)("img",{src:t,alt:o("Generated image"),className:`max-h-[550px] w-full rounded-lg object-contain ${c||u?"opacity-0":"opacity-100"}`,onLoad:()=>{d(!1),m(!1)},onError:()=>{d(!1),m(!0)},loading:"lazy"}),u&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("p",{className:"text-muted-foreground text-sm",children:o("Failed to load image")})})]}),(0,s.jsx)("div",{className:"bg-muted mt-4 rounded-md p-3",children:(0,s.jsx)("p",{className:"text-muted-foreground font-mono text-xs break-all",children:t})})]})})})}function av(e){let{prompt:t,promptEn:a,open:n,onOpenChange:l}=e,{t:r}=(0,i.Bd)(),{copiedText:o,copyToClipboard:c}=(0,tz.C)({notify:!1});return(0,s.jsx)(p.l,{open:n,onOpenChange:l,title:r("Prompt Details"),description:r("View the complete prompt and its English translation"),contentClassName:"sm:max-w-lg",contentHeight:"auto",bodyClassName:"space-y-4",children:(0,s.jsx)(af.F,{className:"max-h-[500px] pr-4",children:(0,s.jsxs)("div",{className:"space-y-4 py-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(C.J,{className:"text-sm font-semibold",children:r("Prompt")}),(0,s.jsxs)("div",{className:"bg-muted/50 relative rounded-md border p-3",children:[(0,s.jsx)(w.$,{variant:"ghost",size:"sm",className:"absolute top-2 right-2 h-8 w-8 p-0",onClick:()=>
1c(t),title:r("Copy to clipboard"),children:o===t?(0,s.jsx)(t_.A,{className:"size-4 text-green-600"}):(0,s.jsx)(ty.A,{className:"size-4"})}),(0,s.jsx)("p",{className:"pr-10 text-sm leading-relaxed break-words whitespace-pre-wrap",children:t||"-"})]})]}),a&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(C.J,{className:"text-sm font-semibold",children:r("Prompt (EN)")}),(0,s.jsxs)("div",{className:"bg-muted/50 relative rounded-md border p-3",children:[(0,s.jsx)(w.$,{variant:"ghost",size:"sm",className:"absolute top-2 right-2 h-8 w-8 p-0",onClick:()=>c(a),title:r("Copy to clipboard"),children:o===a?(0,s.jsx)(t_.A,{className:"size-4 text-green-600"}):(0,s.jsx)(ty.A,{className:"size-4"})}),(0,s.jsx)("p",{className:"pr-10 text-sm leading-relaxed break-words whitespace-pre-wrap",children:a})]})]})]})})})}function a_(e){let{failReason:t,open:a,onOpenChange:n}=e,{t:l}=(0,i.Bd)(),{copiedText:r,copyToClipboard:o}=(0,tz.C)({notify:!1});return(0,s.jsx)(p.l,{open:a,onOpenChange:n,title:l("Fail Reason Details"),description:l("View the complete error message and details"),contentClassName:"sm:max-w-lg",contentHeight:"auto",bodyClassName:"space-y-4",children:(0,s.jsx)(af.F,{className:"max-h-[500px] pr-4",children:(0,s.jsx)("div",{className:"space-y-4 py-4",children:(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(C.J,{className:"text-sm font-semibold",children:l("Error Message")}),(0,s.jsxs)("div",{className:"bg-muted/50 relative rounded-md border border-red-200 p-3",children:[(0,s.jsx)(w.$,{variant:"ghost",size:"sm",className:"absolute top-2 right-2 h-8 w-8 p-0",onClick:()=>o(t),title:l("Copy to clipboard"),children:r===t?(0,s.jsx)(t_.A,{className:"size-4 text-green-600"}):(0,s.jsx)(ty.A,{className:"size-4"})}),(0,s.jsx)("p",{className:"overflow-wrap-anywhere pr-10 text-sm leading-relaxed break-all whitespace-pre-wrap text-red-600",children:t||"-"})]})]})})})})}function ay(e){let{submitTimeKey:t,finishTimeKey:a,unit:n="milliseconds",headerLabel:l,warningThresholdSec:r=60}=e;return{id:"duration",header:e=>{let{column:t}=e;return(0,s.jsx)(e3.wZ,{column:t,title:l})},cell:e=>{let{row:l}=e,i=l.original,o=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"milliseconds";if(!e||!t)return null;let s="milliseconds"===a?(t-e)/1e3:t-e;return{durationSec:s,variant:s>60?"red":"green"}}(i[t],i[a],n);if(!o)return(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"});let c=o.durationSec>r?"danger":"success";return(0,s.jsx)(T.Wh,{label:`${o.durationSec.toFixed(1)}s`,variant:c,size:"sm",copyable:!1,className:(0,e8.cn)("rounded-md font-mono",{success:"border border-emerald-200/40 bg-emerald-50/35 !text-emerald-600 dark:border-emerald-900/40 dark:bg-emerald-950/15 dark:!text-emerald-400",warning:"border border-amber-200/45 bg-amber-50/35 !text-amber-600 dark:border-amber-900/40 dark:bg-amber-950/15 dark:!text-amber-400",danger:"border border-rose-200/50 bg-rose-50/35 !text-red-600 dark:border-rose-900/40 dark:bg-rose-950/15 dark:!text-red-400"}[c])})},meta:{label:l}}}function aN(e){let{accessorKey:t="channel_id",headerLabel:a}=e;return{accessorKey:t,header:e=>{let{column:t}=e;return(0,s.jsx)(e3.wZ,{column:t,title:a})},cell:e=>{let{row:a}=e,n=a.getValue(t);return n?(0,s.jsx)(T.Wh,{label:`#${n}`,autoColor:String(n),copyText:String(n),size:"sm",showDot:!1,className:"font-mono"}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},meta:{label:a}}}function aw(e){let{accessorKey:t="progress",headerLabel:a}=e;return{accessorKey:t,header:e=>{let{column:t}=e;return(0,s.jsx)(e3.wZ,{column:t,title:a})},cell:e=>{let{row:a}=e,n=a.getValue(t);return n?(0,s.jsx)("span",{className:"border-border/60 bg-muted/30 inline-flex items-center rounded-md border px-1.5 py-0.5 font-mono text-xs",children:n}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},meta:{label:a}}}let ak={[eo]:t6.A,[ec]:t8.A,[ed]:t7.A,[eu]:t9.A,[em]:ae.A,[ex]:ae.A,[ep]:ae.A,PAN:at.A,[eh]:aa.A,[eg]:as.A,[ef]:an.A,[eb]:al.A,[ej]:ar.A,[ev]:ai.A,[e_]:ao.A,[ey]:ac.A,[eN]:ac.A};var aC=a(88419),aS=a(66552);function aA(e){let{clip:t}=e,{t:a}=(0,i.Bd)(),[n,l]=(0,r.useState)(!1),o=(0,r.useRef)(null);(0,r.useEffect)(()=>
1{l(!1)},[t.audio_url]);let c=t.title||a("Untitled"),d=t.tags||t.metadata?.tags||"",u=t.duration||t.metadata?.duration,m=t.image_url||t.image_large_url,p=t.audio_url;return p?(0,s.jsxs)("div",{className:"bg-card flex gap-4 rounded-lg border p-4",children:[m&&(0,s.jsx)("img",{src:m,alt:c,className:"h-20 w-20 shrink-0 rounded-lg object-cover",onError:e=>{e.target.style.display="none"}}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"mb-1 flex items-center gap-2",children:[(0,s.jsx)("span",{className:"truncate text-sm font-medium",children:c}),null!=u&&u>0&&(0,s.jsx)(T.Wh,{label:function(e){if(!e||e<=0)return"--:--";let t=Math.floor(e/60),a=Math.floor(e%60);return`${t}:${a.toString().padStart(2,"0")}`}(u),variant:"neutral",className:"shrink-0",copyable:!1})]}),d&&(0,s.jsx)("p",{className:"text-muted-foreground mb-2 truncate text-xs",children:d}),n?(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("span",{className:"text-destructive text-xs",children:a("Audio playback failed")}),(0,s.jsxs)(w.$,{variant:"outline",size:"sm",className:"h-7 gap-1 text-xs",onClick:()=>window.open(p,"_blank"),children:[(0,s.jsx)(aS.A,{className:"h-3 w-3"}),a("Open in new tab")]}),(0,s.jsxs)(w.$,{variant:"outline",size:"sm",className:"h-7 gap-1 text-xs",onClick:()=>{navigator.clipboard.writeText(p),x.oR.success(a("Copied"))},children:[(0,s.jsx)(ty.A,{className:"h-3 w-3"}),a("Copy Link")]})]}):(0,s.jsx)("audio",{ref:o,src:p,controls:!0,preload:"none",onError:()=>l(!0),className:"h-9 w-full"})]})]}):null}function aT(e){let{t}=(0,i.Bd)(),a=Array.isArray(e.clips)?e.clips:[];return(0,s.jsx)(p.l,{open:e.open,onOpenChange:e.onOpenChange,title:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tq.f,{tone:"chart-4",size:"sm",children:(0,s.jsx)(aC.A,{})}),t("Audio Preview")]}),contentClassName:"sm:max-w-lg",titleClassName:"flex items-center gap-2",contentHeight:"auto",bodyClassName:"space-y-4",children:0===a.length?(0,s.jsx)("p",{className:"text-muted-foreground py-4 text-center text-sm",children:t("None")}):(0,s.jsx)(af.F,{className:"max-h-[60vh]",children:(0,s.jsx)("div",{className:"space-y-3 pr-2",children:a.map((e,t)=>(0,s.jsx)(aA,{clip:e},e.clip_id||e.id||t))})})})}function aI(e){if(Array.isArray(e))return e;if("string"==typeof e)try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{}return[]}function a$(e){let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch{return null}if(!t||"object"!=typeof t||Array.isArray(t))return null;let a=t,s=Number(a.image_result_id);return!Number.isInteger(s)||s<=0?null:{imageResultId:s,count:Math.max((Array.isArray(a.data)?a.data:[]).length,1)}}function aR(e){let{log:t}=e,{isAdminView:a}=ee(),[n,l]=(0,r.useState)(null),[i,o]=(0,r.useState)(!1),c=(0,r.useMemo)(()=>a$(t.data),[t.data]);if(!c)return null;let d={id:c.imageResultId,user_id:t.user_id,username:t.username??"",model_name:t.properties?.origin_model_name??"",mode:t.action,prompt:t.properties?.input??"",request_id:t.task_id,created_time:t.finish_time??t.submit_time,files:[]},u=Array.from({length:c.count},(e,t)=>({idx:t,mime:"image/png",size:0,source:""}));return(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[u.map(e=>(0,s.jsx)(G,{record:d,file:e,isAdminView:a,size:"sm",onPreview:(e,t)=>{l({record:e,file:t}),o(!0)}},e.idx)),(0,s.jsx)(Z,{target:n,isAdminView:a,open:i,onOpenChange:o})]})}function aq(e){let{log:t}=e,{t:a}=(0,i.Bd)(),[n,l]=(0,r.useState)(!1),o=(0,r.useMemo)(()=>aI(t.data).filter(e=>e&&"object"==typeof e&&e.audio_url),[t.data]);return 0===o.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("button",{type:"button",className:"group flex items-center gap-1 text-left text-xs",onClick:()=>l(!0),children:[(0,s.jsx)(aC.A,{className:"text-muted-foreground size-3"}),(0,s.jsx)("span",{className:"text-foreground leading-snug group-hover:underline",children:a("Click to preview audio")})]}),(0,s.jsx)(aT,{open:n,onOpenChange:l,clips:o})]})}var aF=a(26043),az=a(97318),aD=a(48207),aE=a(92429),aM=a(5333),aL=a(88288);function aP(e,t){let a={...e.startTime&&{startTime:e.startTime.getTime()},...e.endTime&&{endTime:e.endTime.getTime()},...e.channel&&{channel:e.channel}};switch(t){case"common":return{...a,...e.model&&{model:e.model},...e.token&&{token:e.token},...e.group&&{group:e.group},...e.username&&{username:e.username},...e.requestId&&{requestId:e.requestId},...e.upstreamRequestId&&{upstreamRequestId:e.upstreamRequestId}};case"drawing":return{...a,...e.mjId&&{filter:e.mjId}};case"task":return{...a,...e.taskId&&{filter:e.taskId}};default:return a}}let aO=(0,n.GY)("/_authenticated/usage-logs/$section");function aK(e){return(0,s.jsxs)("span",{className:"border-border/60 bg-muted/25 inline-flex h-7 items-center gap-2 rounded-md border px-2.5 text-xs shadow-xs",children:[(0,s.jsx)("span",{className:(0,e8.cn)("h-3.5 w-0.5 rounded-full",e.accent)}),(0,s.jsx)("span",{className:"text-muted-foreground",children:e.label}
1),(0,s.jsx)("span",{className:"text-foreground/85 font-mono font-semibold tabular-nums",children:e.value})]})}function aB(){let{t:e}=(0,i.Bd)(),{isAdminView:t}=ee(),a=aO.useSearch(),{sensitiveVisible:n}=X(),{data:l,isLoading:r}=(0,j.I)({queryKey:["usage-logs-stats",t,a],queryFn:async()=>{let e=eL({page:1,pageSize:1,searchParams:a,columnFilters:[],isAdmin:t}),s=t?await eG(e):await eZ(e);return s.success&&s.data||en},placeholderData:e=>e});return r?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ab.E,{className:"h-7 w-[150px] rounded-md"}),(0,s.jsx)(ab.E,{className:"h-7 w-[100px] rounded-md"}),(0,s.jsx)(ab.E,{className:"h-7 w-[120px] rounded-md"})]}):(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(aK,{label:e("Usage"),value:n?(0,h.qW)(l?.quota||0):"â¢â¢â¢â¢",accent:"bg-sky-500/70"}),(0,s.jsx)(aK,{label:e("RPM"),value:l?.rpm||0,accent:"bg-rose-500/65"}),(0,s.jsx)(aK,{label:e("TPM"),value:l?.tpm||0,accent:"bg-slate-400/70"})]})}var aU=a(82638),aV=a(74559),aH=a(47497);let aW={0:{label:"Pending",variant:"warning",pulse:!0},1:{label:"Processing",variant:"blue",pulse:!0},2:{label:"Completed",variant:"success"},3:{label:"Failed",variant:"danger"},4:{label:"Cancelled",variant:"grey"}};async function aG(e,t){try{var a;let s=await (0,z.v$)((a=e.id,`/api/log/self/export-download/${a}`));if(429===s.status)return void x.oR.error(t("Export rate limit exceeded, please try again later"));if(!s.ok)throw Error(s.statusText);let n=await s.blob(),l=URL.createObjectURL(n),r=document.createElement("a");r.href=l,r.download=`${e.username||"export"}-${(0,h.fk)(e.created_time).replaceAll("-","").replaceAll(":","").replace(" ","-")}.csv.gz`,document.body.appendChild(r),r.click(),r.remove(),URL.revokeObjectURL(l)}catch(a){let e=a instanceof Error&&a.message?a.message:t("Download failed");x.oR.error(e)}}function aZ(e){var t;let{task:a}=e,{t:n}=(0,i.Bd)(),l=aW[a.status]??aW[4];return(0,s.jsxs)("div",{className:"border rounded-lg p-3 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)(T.Wh,{label:n(l.label),variant:l.variant,pulse:l.pulse,copyable:!1}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,h.fk)(a.created_time)})]}),1===a.status&&(0,s.jsx)(aH.ke,{value:a.progress,children:(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:[a.progress,"%"]})}),(0,s.jsxs)("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[a.email&&(0,s.jsxs)("div",{children:[n("Email"),": ",a.email]}),2===a.status&&(0,s.jsxs)(s.Fragment,{children:[a.row_count>0&&(0,s.jsxs)("div",{children:[n("Rows"),": ",a.row_count.toLocaleString()]}),a.file_size>0&&(0,s.jsxs)("div",{children:[n("File Size"),": ",(t=a.file_size)&&!(t<=0)?t<1024?`${t} B`:t<1048576?`${(t/1024).toFixed(1)} KB`:`${(t/1048576).toFixed(2)} MB`:"-"]}),a.completed_time>0&&(0,s.jsxs)("div",{children:[n("Completed"),": ",(0,h.fk)(a.completed_time)]})]}),3===a.status&&a.error_message&&(0,s.jsx)("div",{className:"text-destructive",children:a.error_message})]}),2===a.status&&(0,s.jsxs)(w.$,{variant:"outline",size:"sm",className:"w-full",onClick:()=>aG(a,n),children:[(0,s.jsx)(_.A,{className:"mr-1.5 h-3.5 w-3.5"}),n("Download")]})]})}function aQ(e){let{open:t,onOpenChange:a,autoDownloadTaskId:n,onAutoDownloadHandled:l}=e,{t:o}=(0,i.Bd)(),{data:c,isLoading:d,refetch:u}=(0,j.I)({queryKey:["export-tasks"],queryFn:()=>e5(1,20),enabled:t,refetchInterval:!!t&&1e4}),m=c?.data?.items??[],p=(0,r.useRef)(null);return(0,r.useEffect)(()=>{if(!n||!t||d||!c||p.current===n)return;p.current=n;let e=(c.data?.items??[]).find(e=>e.id===n);e?2===e.status?aG(e,o):3===e.status?x.oR.error(e.error_message||o("Export task failed")):x.oR.info(o("Export task is still processing, please wait")):x.oR.error(o("Export task not found or already expired")),l?.()},[n,t,d,c,o,l]),(0,s.jsx)(aV.cj,{open:t,onOpenChange:a,children:(0,s.jsxs)(aV.h,{side:"right",className:"sm:max-w-md",children:[(0,s.jsxs)(aV.Fm,{children:[(0,s.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,s.jsx)(aV.qp,{children:o("Export Tasks")}),(0,s.jsx)(w.$,{variant:"ghost",size:"icon-sm",onClick:()=>u(),disabled:d,"aria-label":o("Refresh"),children:(0,s.jsx)(ar.A,{className:d?"animate-spin":""})})]}),(0,s.jsx)(aV.Qs,{children:o("View and download your offline export tasks")})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto px-4 pb-4 space-y-3",children:[d&&0===m.length&&(0,s.jsx)("div",{className:"text-center text-sm text-muted-foreground py-8",children:o("Loading...")}),!d&&0===m.length&&(0,s.jsx)("div",{className:"text-center text-sm text-muted-foreground py-8",children:o("No exp
1ort tasks")}),m.map(e=>(0,s.jsx)(aZ,{task:e},e.id))]})]})})}var aJ=a(52523),aY=a(54052);function aX(e){let{open:t,onOpenChange:a,filters:n,logType:l}=e,{t:r}=(0,i.Bd)(),o=(0,b.jE)(),c=(0,aJ.n)(e=>e.auth.user?.email??""),d=(0,v.n)({mutationFn:e1,onSuccess:e=>{e.success?(x.oR.success(r("Task submitted, you will be notified by email when complete")),o.invalidateQueries({queryKey:["export-tasks"]}),a(!1)):x.oR.error(e.message||r("Export failed"))},onError:()=>{x.oR.error(r("Export failed"))}}),u=n.startTime?(0,h.fk)(Math.floor(n.startTime.getTime()/1e3)):"-",m=n.endTime?(0,h.fk)(Math.floor(n.endTime.getTime()/1e3)):"-";return(0,s.jsx)(aY.lG,{open:t,onOpenChange:a,children:(0,s.jsxs)(aY.Cf,{className:"sm:max-w-md",children:[(0,s.jsxs)(aY.c7,{children:[(0,s.jsx)(aY.L3,{children:r("Offline Export")}),(0,s.jsx)(aY.rr,{children:r("Export logs in the background and receive the file by email")})]}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"bg-muted rounded-lg p-3 text-sm space-y-1",children:[(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:r("Time Range")}),(0,s.jsxs)("span",{children:[u," ~ ",m]})]}),n.model&&(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:r("Model Name")}),(0,s.jsx)("span",{children:n.model})]}),n.token&&(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:r("Token Name")}),(0,s.jsx)("span",{children:n.token})]}),n.channel&&(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:r("Channel ID")}),(0,s.jsx)("span",{children:n.channel})]}),l&&(0,s.jsxs)("div",{className:"flex justify-between",children:[(0,s.jsx)("span",{className:"text-muted-foreground",children:r("Log Type")}),(0,s.jsx)("span",{children:l})]})]}),(0,s.jsxs)("div",{className:"text-sm",children:[(0,s.jsxs)("span",{className:"text-muted-foreground",children:[r("Notification Email"),": "]}),(0,s.jsx)("span",{className:"font-medium",children:c||r("No email bound, please set in account settings")})]}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground",children:r("Offline export limits: one task per 24 hours, results available for 72 hours after completion")})]}),(0,s.jsxs)(aY.Es,{children:[(0,s.jsx)(w.$,{variant:"outline",onClick:()=>a(!1),children:r("Cancel")}),(0,s.jsx)(w.$,{onClick:()=>{if(!n.startTime||!n.endTime)return void x.oR.error(r("Please select a time range"));let e=Math.floor(n.startTime.getTime()/1e3),t=Math.floor(n.endTime.getTime()/1e3);d.mutate({filters:{start_timestamp:e,end_timestamp:t,...n.model?{model_name:n.model}:{},...n.token?{token_name:n.token}:{},...n.channel?{channel_id:Number(n.channel)}:{}}})},disabled:d.isPending,children:d.isPending?r("Submitting..."):r("Submit Export Task")})]})]})})}var a0=a(37116),a1=a(96735);function a5(e){return(0,s.jsx)("div",{className:(0,e8.cn)("min-w-0 [&_[data-slot=select-trigger]]:w-full [&_[data-slot=select-trigger]]:text-sm [&_[data-slot=select-value]]:leading-5",e.wide&&"sm:col-span-2",e.className),children:e.children})}function a2(e){return(0,s.jsx)(k.p,{...e,className:(0,e8.cn)("h-8 min-w-0 text-sm leading-5",e.className)})}function a3(e){let{t}=(0,i.Bd)(),[a,n]=(0,r.useState)(!1),[l,o]=(0,r.useState)(!1),[c,d]=(0,r.useState)(!1),u=(0,e4.Ub)("(max-width: 640px)"),m=null!=e.advancedFilters,x=e.advancedFilterCount??+!!e.hasAdvancedActiveFilters,p=e.mobileFilterCount??x,h=m?(0,s.jsxs)(w.$,{type:"button",variant:"ghost",onClick:()=>n(e=>!e),"aria-expanded":a,className:(0,e8.cn)("text-muted-foreground hover:text-foreground gap-1 px-2",e.hasAdvancedActiveFilters&&!a&&"text-primary hover:text-primary"),children:[t(a?"Collapse":"Expand"),x>0&&(0,s.jsx)(tW.E,{className:"ml-0.5 size-5 justify-center p-0 text-[10px]",children:x}),(0,s.jsx)(a0.A,{className:(0,e8.cn)("size-3.5 transition-transform duration-200",a&&"rotate-180")})]}):null;return u&&null!=e.mobilePinnedFilters?(0,s.jsxs)(a1._s,{open:l,onOpenChange:o,children:[(0,s.jsxs)("div",{className:(0,e8.cn)("bg-card/50 rounded-lg border p-2.5",e.className),children:[!c&&(0,s.jsx)("div",{className:"grid gap-2",children:e.mobilePinnedFilters}),(0,s.jsxs)("div",{className:(0,e8.cn)("flex flex-col gap-2",!c&&"mt-2"),children:[!c&&e.stats,(0,s.jsxs)("div",{className:"flex items-center justify-end gap-1.5",children:[(0,s.jsx)(w.$,{type:"button",variant:"ghost",size:"icon",onClick:()=>d(e=>!e),"aria-expanded":!c,"aria-label":t(c?"Expand":"Collapse"),className:"text-muted-foreground hover:text-foreground mr-auto size-7",children:(0,s.jsx)(a0.A,{className:(0,e8.cn)("size-3.5 transition-transform duration-200",!c&&"rotate-180")}
1)}),e.actionStart,(0,s.jsx)(a1.Uz,{asChild:!0,children:(0,s.jsxs)(w.$,{type:"button",variant:"ghost",className:(0,e8.cn)("text-muted-foreground hover:text-foreground gap-1 px-2",p>0&&"text-primary hover:text-primary"),children:[t("Filter"),p>0&&(0,s.jsx)(tW.E,{className:"ml-0.5 size-5 justify-center p-0 text-[10px]",children:p})]})}),(0,s.jsxs)(w.$,{type:"button",onClick:e.onSearch,disabled:e.searchLoading,children:[e.searchLoading&&(0,s.jsx)(es.A,{className:"animate-spin"}),t("Search")]}),(0,s.jsx)(e3.io,{table:e.table})]})]})]}),(0,s.jsx)(a1.zj,{className:"max-h-[85dvh] p-0",children:(0,s.jsxs)("div",{className:"mx-auto flex w-full max-w-md flex-1 flex-col overflow-hidden",children:[(0,s.jsxs)(a1.BE,{className:"border-border/70 border-b px-4 py-3 text-left",children:[(0,s.jsx)(a1.gk,{children:t("Filter")}),(0,s.jsx)(a1.I6,{children:t("Adjust filters, then search to refresh the logs.")})]}),(0,s.jsx)("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-4 py-3",children:e.mobileFilters??(0,s.jsxs)(s.Fragment,{children:[e.primaryFilters,e.advancedFilters]})}),(0,s.jsxs)(a1.tb,{className:"border-border/70 grid grid-cols-2 gap-2 border-t px-4 py-3",children:[(0,s.jsx)(w.$,{type:"button",variant:"outline",onClick:()=>{e.onReset(),o(!1)},disabled:!e.hasActiveFilters,children:t("Reset")}),(0,s.jsxs)(w.$,{type:"button",onClick:()=>{e.onSearch(),o(!1)},disabled:e.searchLoading,children:[e.searchLoading&&(0,s.jsx)(es.A,{className:"animate-spin"}),t("Search")]})]})]})})]}):(0,s.jsxs)("div",{className:(0,e8.cn)("bg-card/50 rounded-lg border p-2.5 sm:p-3",e.className),children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-start gap-2",children:[(0,s.jsx)("div",{className:"grid min-w-0 flex-1 grid-cols-1 gap-2 sm:grid-cols-[repeat(auto-fit,minmax(10rem,1fr))]",children:e.primaryFilters}),h&&(0,s.jsx)("div",{className:"flex shrink-0 items-center justify-end",children:h})]}),a&&e.advancedFilters&&(0,s.jsx)("div",{className:"mt-2 grid grid-cols-1 gap-2 sm:grid-cols-[repeat(auto-fit,minmax(10rem,1fr))]",children:e.advancedFilters}),(0,s.jsxs)("div",{className:"mt-2 flex flex-wrap items-center gap-2",children:[e.stats,(0,s.jsxs)("div",{className:"ms-auto flex flex-wrap items-center justify-end gap-1.5 sm:gap-2",children:[e.actionStart,(0,s.jsx)(w.$,{type:"button",variant:"outline",onClick:e.onReset,disabled:!e.hasActiveFilters,children:t("Reset")}),(0,s.jsxs)(w.$,{type:"button",onClick:e.onSearch,disabled:e.searchLoading,children:[e.searchLoading&&(0,s.jsx)(es.A,{className:"animate-spin"}),t("Search")]}),(0,s.jsx)(e3.io,{table:e.table})]})]})]})}let a4=(0,n.GY)("/_authenticated/usage-logs/$section"),a6=new Set(ei.map(e=>e.value));function a8(e){return[e.startTime,e.endTime,e.channel,e.model,e.token,e.group,e.username,e.requestId,e.upstreamRequestId,Array.isArray(e.type)?e.type.join(","):e.type].map(e=>String(e??"")).join("\x1f")}function a7(e){let{t}=(0,i.Bd)(),a=(0,l.Z)(),n=(0,b.jE)(),o=a4.useSearch(),{isAdminView:d}=ee(),{status:u}=(0,c.s)(),{sensitiveVisible:m,setSensitiveVisible:p}=X(),h=(0,aF.C)({queryKey:["logs"]}),[g,f]=(0,r.useState)(!1),j=o.exportTask,[v,y]=(0,r.useState)(!!j);(0,r.useEffect)(()=>{j&&y(!0)},[j]);let N=(0,r.useCallback)(()=>{a({to:"/usage-logs/$section",params:{section:"common"},search:{...o,exportTask:void 0},replace:!0})},[a,o]),k=(0,r.useMemo)(()=>{var e,t;let{start:a,end:s}=eD(),n={startTime:o.startTime,endTime:o.endTime,channel:o.channel,model:o.model,token:o.token,group:o.group,username:o.username,requestId:o.requestId,upstreamRequestId:o.upstreamRequestId,type:o.type},l={startTime:o.startTime?new Date(o.startTime):a,endTime:o.endTime?new Date(o.endTime):s,channel:o.channel||void 0,model:o.model||void 0,token:o.token||void 0,group:o.group||void 0,username:o.username||void 0,requestId:o.requestId||void 0,upstreamRequestId:o.upstreamRequestId||void 0};return{sourceKey:a8(n),filters:l,logType:Array.isArray(e=o.type)&&1===e.length&&"string"==typeof e[0]&&(t=e[0],a6.has(t))?e[0]:"0"}},[o.startTime,o.endTime,o.channel,o.model,o.token,o.group,o.username,o.requestId,o.upstreamRequestId,o.type]),[C,S]=(0,r.useState)(()=>k),A=C.sourceKey===k.sourceKey?C:k,T=A.filters,I=A.logType,$=(0,r.useCallback)((e,t)=>{S(a=>{let s=a.sourceKey===k.sourceKey?a:k;return{sourceKey:k.sourceKey,filters:{...s.filters,[e]:t},logType:s.logType}})},[k]),R=(0,r.useCallback)(()=>{a({to:"/usage-logs/$section",params:{section:"common"},search:{...aP(T,"common"),type:[I],page:1}}),n.invalidateQueries({queryKey:["logs"]}),n.invalidateQueries({queryKey:["usage-logs-stats"]})},[T,I,a,n]),q=(0,r.useCallback)(()=>{let{start:e,end:t}=eD(),s={type:["0"],startTime:e.getTime(),endTime:t.getTime()};
1S({sourceKey:a8(s),filters:{startTime:e,endTime:t},logType:"0"}),a({to:"/usage-logs/$section",params:{section:"common"},search:{page:1,...s}}),n.invalidateQueries({queryKey:["logs"]}),n.invalidateQueries({queryKey:["usage-logs-stats"]})},[a,n]),F=(0,r.useCallback)(e=>{"Enter"===e.key&&R()},[R]),[D,E]=(0,r.useState)(!1),M=(0,r.useCallback)(async()=>{if(!d){let e=eD(),a=T.startTime?.getTime()??e.start.getTime();if((T.endTime?.getTime()??e.end.getTime())-a>26784e5)return void x.oR.error(t("Export time range cannot exceed one month"))}E(!0);let e=x.oR.loading(t("Exporting logs..."));try{let a,s={...eL({page:1,pageSize:10,searchParams:aP(T,"common"),isAdmin:d})};delete s.p,delete s.page_size,delete s.upstream_request_id,"0"!==I&&(s.type=I);let n=(a=eE(s),`${d?"/api/log/export":"/api/log/self/export"}?${a}`),l=await (0,z.v$)(n);if(429===l.status)return void x.oR.error(t("Export rate limit exceeded, please try again later"),{id:e,duration:5e3});if(!l.ok){try{let a=await l.json();x.oR.error(a.message||t("Export failed"),{id:e,duration:5e3})}catch{x.oR.error(t("Export failed"),{id:e,duration:5e3})}return}let r=l.body?.getReader();if(!r)return void x.oR.error(t("Export failed"),{id:e,duration:5e3});let i=[],o=0;for(;;){let{done:a,value:s}=await r.read();if(a)break;i.push(s);let n=((o+=s.length)/1024/1024).toFixed(1);x.oR.loading(t("Exporting logs... {{size}} MB",{size:n}),{id:e})}let c=new Blob(i,{type:"text/csv"}),u=URL.createObjectURL(c),m=document.createElement("a");m.href=u,m.download=`logs_${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(u),x.oR.success(t("Export completed"),{id:e,duration:5e3})}catch(s){let a=s instanceof Error&&s.message?s.message:t("Export failed");x.oR.error(a,{id:e,duration:5e3})}finally{E(!1)}},[T,I,d,t]),L=!!u?.enable_log_export_offline,P=!!T.token||!!T.username||!!T.channel||!!T.requestId||!!T.upstreamRequestId,O="0"!==I,K=!!T.model||!!T.group||O||P,B=[T.token,d?T.username:void 0,d?T.channel:void 0,T.requestId,T.upstreamRequestId].filter(Boolean).length,U=m?"text":"password",V=(0,r.useMemo)(()=>ei.map(e=>({value:e.value,label:t(e.label)})),[t]),H=V.find(e=>e.value===I)?.label??t("All Types"),W=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)(aB,{}),(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)(w.$,{variant:"ghost",size:"icon",onClick:M,disabled:D,"aria-label":t("Export Logs"),className:"text-muted-foreground hover:text-foreground size-7"}),children:(0,s.jsx)(_.A,{className:D?"animate-pulse":""})}),(0,s.jsxs)(tn.ZI,{children:[t("Export Logs"),": ",t("Download current page as CSV")]})]}),L&&(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)(w.$,{variant:"ghost",size:"icon",onClick:()=>f(!0),"aria-label":t("Offline Export"),className:"text-muted-foreground hover:text-foreground size-7"}),children:(0,s.jsx)(az.A,{})}),(0,s.jsxs)(tn.ZI,{children:[t("Offline Export"),":"," ",t("Background export, notified by email, one task per 24h")]})]}),L&&(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)(w.$,{variant:"ghost",size:"icon",onClick:()=>y(!0),"aria-label":t("Export Tasks"),className:"text-muted-foreground hover:text-foreground size-7"}),children:(0,s.jsx)(aD.A,{})}),(0,s.jsxs)(tn.ZI,{children:[t("Export Tasks"),":"," ",t("View task status and download completed exports")]})]}),L&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(aX,{open:g,onOpenChange:f,filters:T,logType:"0"!==I?I:void 0}),(0,s.jsx)(aQ,{open:v,onOpenChange:y,autoDownloadTaskId:j,onAutoDownloadHandled:N})]})]}),G=(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)(w.$,{variant:"ghost",size:"icon",onClick:()=>p(!m),"aria-label":m?t("Hide"):t("Show"),className:"text-muted-foreground hover:text-foreground size-7"}),children:m?(0,s.jsx)(aE.A,{}):(0,s.jsx)(aM.A,{})}),(0,s.jsx)(tn.ZI,{children:m?t("Hide"):t("Show")})]}),Z=(0,s.jsx)(a5,{wide:!0,children:(0,s.jsx)(aU.A,{start:T.startTime,end:T.endTime,onChange:e=>{let{start:t,end:a}=e;$("startTime",t),$("endTime",a)}})}),Q=(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Model Name"),value:T.model||"",onChange:e=>$("model",e.target.value),onKeyDown:F})}),J=(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Group"),type:U,value:T.group||"",onChange:e=>$("group",e.target.value),onKeyDown:F})}
1),Y=(0,s.jsx)(a5,{children:(0,s.jsxs)(aL.l6,{items:V,value:I,onValueChange:e=>{let t=null!==e&&a6.has(e)?e:"0";S(e=>{let a=e.sourceKey===k.sourceKey?e:k;return{sourceKey:k.sourceKey,filters:a.filters,logType:t}})},children:[(0,s.jsx)(aL.bq,{children:(0,s.jsx)(aL.yv,{children:H})}),(0,s.jsx)(aL.gC,{alignItemWithTrigger:!1,children:(0,s.jsx)(aL.s3,{children:ei.map(e=>(0,s.jsx)(aL.eb,{value:e.value,children:t(e.label)},e.value))})})]})}),et=(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Token Name"),type:U,value:T.token||"",onChange:e=>$("token",e.target.value),onKeyDown:F})}),d&&(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Username"),type:U,value:T.username||"",onChange:e=>$("username",e.target.value),onKeyDown:F})}),d&&(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Channel ID"),value:T.channel||"",onChange:e=>$("channel",e.target.value),onKeyDown:F})}),(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Request ID"),value:T.requestId||"",onChange:e=>$("requestId",e.target.value),onKeyDown:F})}),(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Upstream Request ID"),value:T.upstreamRequestId||"",onChange:e=>$("upstreamRequestId",e.target.value),onKeyDown:F})})]});return(0,s.jsx)(a3,{table:e.table,stats:W,actionStart:G,primaryFilters:(0,s.jsxs)(s.Fragment,{children:[Z,Q,J,Y]}),advancedFilters:et,mobilePinnedFilters:Z,mobileFilters:(0,s.jsxs)(s.Fragment,{children:[Q,J,Y,et]}),mobileFilterCount:[T.model,T.group,O].filter(Boolean).length+B,hasAdvancedActiveFilters:P,advancedFilterCount:B,hasActiveFilters:K,onSearch:R,searchLoading:h>0,onReset:q})}let a9=(0,n.GY)("/_authenticated/usage-logs/$section");function se(e){let{t}=(0,i.Bd)(),a=(0,l.Z)(),n=(0,b.jE)(),o=a9.useSearch(),{isAdminView:c}=ee(),d=(0,aF.C)({queryKey:["logs"]}),[u,m]=(0,r.useState)(()=>{let{start:e,end:t}=eD();return{startTime:e,endTime:t}});(0,r.useEffect)(()=>{let{start:t,end:a}=eD(),s={startTime:o.startTime?new Date(o.startTime):t,endTime:o.endTime?new Date(o.endTime):a,...o.channel?{channel:String(o.channel)}:{}};m("drawing"===e.logCategory?{...s,...o.filter?{mjId:o.filter}:{}}:{...s,...o.filter?{taskId:o.filter}:{}})},[e.logCategory,o.startTime,o.endTime,o.channel,o.filter]);let x=(0,r.useCallback)((e,t)=>{m(a=>({...a,[e]:t}))},[]),p=(0,r.useCallback)(()=>{let t=aP(u,e.logCategory);a({to:"/usage-logs/$section",params:{section:e.logCategory},search:{...t,page:1}}),n.invalidateQueries({queryKey:["logs"]})},[u,a,e.logCategory,n]),h=(0,r.useCallback)(()=>{let{start:t,end:s}=eD();m({startTime:t,endTime:s}),a({to:"/usage-logs/$section",params:{section:e.logCategory},search:{page:1,startTime:t.getTime(),endTime:s.getTime()}}),n.invalidateQueries({queryKey:["logs"]})},[a,e.logCategory,n]),g=(0,r.useCallback)(e=>{"Enter"===e.key&&p()},[p]),f=(0,r.useCallback)(t=>{m(a=>{var s;return s=e.logCategory,"drawing"===s?{...a,mjId:t}:{...a,taskId:t}})},[e.logCategory]),j="drawing"===e.logCategory?u.mjId||"":u.taskId||"",v=t("drawing"===e.logCategory?"Filter by MjProxy task ID":"Filter by task ID"),_=!!j||!!u.channel,y=(0,s.jsx)(a5,{wide:!0,children:(0,s.jsx)(aU.A,{start:u.startTime,end:u.endTime,onChange:e=>{let{start:t,end:a}=e;x("startTime",t),x("endTime",a)}})}),N=(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{"aria-label":t("Task ID"),placeholder:v,value:j,onChange:e=>f(e.target.value),onKeyDown:g})}),w=c?(0,s.jsx)(a5,{children:(0,s.jsx)(a2,{placeholder:t("Channel ID"),value:u.channel||"",onChange:e=>x("channel",e.target.value),onKeyDown:g})}):null;return(0,s.jsx)(a3,{table:e.table,primaryFilters:(0,s.jsxs)(s.Fragment,{children:[y,N,w]}),mobilePinnedFilters:y,mobileFilters:(0,s.jsxs)(s.Fragment,{children:[N,w]}
1),mobileFilterCount:[j,u.channel].filter(Boolean).length,hasActiveFilters:_,onSearch:p,searchLoading:d>0,onReset:h})}var st=a(11397),sa=a(12393);let ss={5:"bg-rose-50/40 dark:bg-rose-950/20 border-rose-200/50 dark:border-rose-900/30",6:"bg-blue-50/30 dark:bg-blue-950/15 border-blue-200/50 dark:border-blue-900/30"};function sn(){return(0,s.jsx)("div",{className:"border-border/50 bg-card overflow-hidden rounded-lg border",children:[1,2,3].map(e=>(0,s.jsxs)("div",{className:"border-border/40 space-y-2.5 border-b p-3 last:border-b-0",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,s.jsx)(ab.E,{className:"h-5 w-40 rounded-md"}),(0,s.jsx)(ab.E,{className:"h-5 w-16 rounded-md"})]}),(0,s.jsx)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-2",children:[1,2,3,4,5,6].map(e=>(0,s.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,s.jsx)(ab.E,{className:"h-3 w-10 rounded"}),(0,s.jsx)(ab.E,{className:"h-4 w-full rounded"})]},e))})]},e))})}function sl(e){let{cell:t,fallback:a="-",className:n,primaryOnly:l=!1}=e;return(0,s.jsx)("div",{className:(0,e8.cn)("min-w-0 overflow-hidden leading-tight [&_button]:max-w-full [&_span]:max-w-full",l&&"[&_.flex-col]:min-w-0 [&_.flex-col>*:not(:first-child)]:hidden",n),children:t?(0,q.Kv)(t.column.columnDef.cell,t.getContext()):(0,s.jsx)("span",{className:"text-muted-foreground/50",children:a})})}function sr(e){let{label:t,cell:a,className:n,valueClassName:l,primaryOnly:r=!1}=e;return a?(0,s.jsxs)("div",{className:(0,e8.cn)("bg-muted/20 min-w-0 rounded-md px-2 py-1.5",n),children:[null!=t&&""!==t&&(0,s.jsx)("div",{className:"text-muted-foreground mb-1 text-[11px] leading-none font-medium select-none",children:t}),(0,s.jsx)(sl,{cell:a,primaryOnly:r,className:l})]}):null}function si(e){let{createdAt:t,type:a}=e,{t:n}=(0,i.Bd)(),l=ez(("number"==typeof a?a:void 0)??0),r=l.color;return(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("div",{className:"font-mono text-xs leading-tight tabular-nums",children:(0,h.fk)("number"==typeof t?t:void 0)}),(0,s.jsxs)("div",{className:(0,e8.cn)("inline-flex items-center gap-1 text-xs leading-none font-medium",T.BQ[r]),children:[(0,s.jsx)("span",{className:(0,e8.cn)("size-1.5 shrink-0 rounded-full",T.jk[r]),"aria-hidden":"true"}),(0,s.jsx)("span",{children:n(l.label)})]})]})}function so(e){let{log:t}=e,{t:a}=(0,i.Bd)();if(!eq(t.type))return null;let n=t.prompt_tokens||0,l=t.completion_tokens||0;if(0===n&&0===l)return(0,s.jsx)("div",{className:"bg-muted/20 min-w-0 rounded-md px-2 py-1.5",children:(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})});let r=tm(t.other),o=r?.cache_tokens||0,c=r?.cache_creation_tokens_5m||0,d=r?.cache_creation_tokens_1h||0,u=c>0||d>0?c+d:r?.cache_creation_tokens||0,m=o>0||u>0;return(0,s.jsx)("div",{className:"bg-muted/20 min-w-0 rounded-md px-2 py-1.5",children:(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsxs)("span",{className:"font-mono text-xs font-medium tabular-nums",children:[n.toLocaleString()," / ",l.toLocaleString()]}),m?(0,s.jsxs)("div",{className:"text-muted-foreground flex flex-wrap items-center gap-x-1.5 gap-y-0.5 text-[11px] leading-none",children:[o>0&&(0,s.jsxs)("span",{children:[a("Cache"),"â ",o.toLocaleString()]}),u>0&&(0,s.jsxs)("span",{children:["â ",u.toLocaleString()]})]}):(0,s.jsx)("span",{className:"text-muted-foreground/50 text-[11px] leading-none",children:"â"})]})})}function sc(e){let{log:t}=e,{sensitiveVisible:a,setSelectedUserId:n,setUserInfoDialogOpen:l}=X();return t.username?(0,s.jsxs)("button",{type:"button",className:"bg-muted/20 flex min-w-0 items-center gap-1.5 rounded-md px-2 py-1.5 text-left",onClick:e=>{e.stopPropagation(),n(t.user_id),l(!0)},children:[(0,s.jsx)(ta.eu,{className:"ring-border/60 size-6 shrink-0 ring-1",children:(0,s.jsx)(ta.q5,{className:(0,e8.cn)("text-[11px] font-semibold",!a&&"bg-muted text-muted-foreground"),style:a?(0,tl.u)(t.username):void 0,children:a?(0,tl.f)(t.username):"â¢"})}),(0,s.jsx)("span",{className:"text-foreground min-w-0 truncate text-sm",children:a?t.username:"â¢â¢â¢â¢"})]}):null}function sd(e){let{log:t}=e;if(!eF(t.type))return null;let a=tm(t.other),n=t.use_time||0,l=n>0&&t.completion_tokens>0?t.completion_tokens/n:null;return(0,s.jsxs)("div",{className:"bg-muted/20 flex min-w-0 items-center gap-2.5 rounded-md px-2 py-1.5",children:[(0,s.jsx)(t2,{useTimeSec:n,completionTokens:t.completion_tokens,frtMs:a?.frt,isStream:t.is_stream,indicator:"dot",className:"min-w-0 flex-1"}),(0,s.jsx)(t3,{isStream:t.is_stream,tokensPerSecond:l,streamStatus:a?.stream_status,className:"shrink-0"})]})}function su(e){let{cells:t}=e,{t:a}=(0,i.Bd)(),n=t.get("model_name"),l=t.get("quota"),r=t.get("created_at")?.row.original;return(0,s.jsxs)("div",{className:"space-y-2.5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-center justify-between gap-3",children:[(0,s.jsx)(sl,{cell:n,className:"flex-1"}),(0,s.jsx)(sl,{cell:l,className:"shrink-0 text-right [&_.flex-col]:items-end"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,0.8fr)] ga
1p-1.5",children:[(0,s.jsx)("div",{className:"bg-muted/20 min-w-0 rounded-md px-2 py-1.5",children:(0,s.jsx)(si,{createdAt:r?.created_at,type:r?.type})}),(0,s.jsx)(sr,{cell:t.get("channel"),valueClassName:"[&_.flex-col]:max-w-none"}),r&&t.has("user")?(0,s.jsx)(sc,{log:r}):(0,s.jsx)(sr,{cell:t.get("user")}),(0,s.jsx)(sr,{cell:t.get("token_name"),valueClassName:"[&_.flex-col]:max-w-none [&_.flex-col>*:not(:first-child)]:text-[11px] [&_.flex-col>*:not(:first-child)]:leading-none"}),r?(0,s.jsx)(sd,{log:r}):(0,s.jsx)(sr,{cell:t.get("use_time")}),r?(0,s.jsx)(so,{log:r}):(0,s.jsx)(sr,{cell:t.get("prompt_tokens")}),(0,s.jsx)(sr,{label:a("Details"),cell:t.get("content"),className:"col-span-2 bg-transparent px-0 py-0"})]})]})}function sm(e){let{cells:t}=e,{t:a}=(0,i.Bd)(),n=t.get("task_id"),l=t.get("status"),r=t.get("submit_time");return(0,s.jsxs)("div",{className:"space-y-2.5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[(0,s.jsx)(sl,{cell:n,className:"flex-1"}),(0,s.jsx)(sl,{cell:l,className:"shrink-0 text-right"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-1.5",children:[(0,s.jsx)(sr,{label:a("Submit Time"),cell:r}),(0,s.jsx)(sr,{label:a("User"),cell:t.get("user"),primaryOnly:!0}),(0,s.jsx)(sr,{label:a("Result"),cell:t.get("fail_reason"),className:"col-span-2 bg-transparent px-0 py-0"})]})]})}function sx(e){let{cells:t}=e,{t:a}=(0,i.Bd)(),n=t.get("action"),l=t.get("code"),r=t.get("submit_time");return(0,s.jsxs)("div",{className:"space-y-2.5",children:[(0,s.jsxs)("div",{className:"flex min-w-0 items-start justify-between gap-3",children:[(0,s.jsx)(sl,{cell:n,className:"flex-1"}),(0,s.jsx)(sl,{cell:l,className:"shrink-0 text-right"})]}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-1.5",children:[(0,s.jsx)(sr,{label:a("Submit Time"),cell:r}),(0,s.jsx)(sr,{label:a("Channel"),cell:t.get("channel"),primaryOnly:!0}),(0,s.jsx)(sr,{label:a("Task ID"),cell:t.get("mj_id")}),(0,s.jsx)(sr,{label:a("Duration"),cell:t.get("duration"),primaryOnly:!0}),(0,s.jsx)(sr,{label:a("Image"),cell:t.get("image_url")}),(0,s.jsx)(sr,{label:a("Prompt"),cell:t.get("prompt"),primaryOnly:!0}),(0,s.jsx)(sr,{label:a("Fail Reason"),cell:t.get("fail_reason"),className:"col-span-2 bg-transparent px-0 py-0"})]})]})}function sp(e){let{table:t,isLoading:a=!1,emptyTitle:n,emptyDescription:l,logCategory:r}=e,{t:o}=(0,i.Bd)(),c=n??o("No Logs Found"),d=l??o("No usage logs available. Logs will appear here once API calls are made.");if(a)return(0,s.jsx)(sn,{});let u=t.getRowModel().rows;return u&&0!==u.length?(0,s.jsx)("div",{className:"border-border/50 bg-card overflow-hidden rounded-lg border",children:u.map(e=>{let t=new Map(e.getVisibleCells().map(e=>[e.column.id,e])),a=e.original.type,n=null!=a?ss[a]??"":"";return(0,s.jsxs)("div",{className:(0,e8.cn)("border-border/40 border-b border-l-2 border-l-transparent p-3 transition-colors last:border-b-0",n),children:["common"===r&&(0,s.jsx)(su,{cells:t}),"task"===r&&(0,s.jsx)(sm,{cells:t}),"drawing"===r&&(0,s.jsx)(sx,{cells:t})]},e.id)})}):(0,s.jsx)("div",{className:"rounded-lg border p-6",children:(0,s.jsx)(sa.Sv,{className:"border-none p-0",children:(0,s.jsxs)(sa.FT,{children:[(0,s.jsx)(sa.Kr,{variant:"icon",children:(0,s.jsx)(st.A,{className:"size-6"})}),(0,s.jsx)(sa.cz,{children:c}),(0,s.jsx)(sa.Ou,{children:d})]})})})}let sh=(0,n.GY)("/_authenticated/usage-logs/$section"),sg={5:"bg-rose-50/40 dark:bg-rose-950/20",6:"bg-blue-50/30 dark:bg-blue-950/15"};function sf(e){return(Array.isArray(e)?e:e?[e]:[]).filter(e=>"0"!==String(e))}function sb(e){let{logCategory:t}=e,{t:a}=(0,i.Bd)(),{isAdminView:n}=ee(),l=(0,e4.Ub)("(max-width: 640px)"),o=sh.useSearch(),c=(0,r.useRef)(0),d=(0,r.useRef)(""),{columnFilters:u,onColumnFiltersChange:m,pagination:p,onPaginationChange:g,ensurePageInRange:f}=(0,e6.c)({search:sh.useSearch(),navigate:sh.useNavigate(),pagination:{defaultPage:1,defaultPageSize:l?20:100},globalFilter:{enabled:!1},columnFilters:[{columnId:"created_at",searchKey:"type",type:"array",deserialize:sf},{columnId:"model_name",searchKey:"model",type:"string"},{columnId:"token_name",searchKey:"token",type:"string"},{columnId:"group",searchKey:"group",type:"string"},...n?[{columnId:"channel",searchKey:"channel",type:"string"},{columnId:"username",searchKey:"username",type:"string"}]:[]]}),{data:b,isLoading:v,isFetching:_}=(0,j.I)({queryKey:["logs",t,n,p.pageIndex+1,p.pageSize,u,o,a],queryFn:async()=>{let e=JSON.stringify({searchParams:o,columnFilters:u,logCategory:t})===d.current?c.current:0,s=await eP({logCategory:t,isAdmin:n,page:p.pageIndex+1,pageSize:p.pageSize,searchParams:o,columnFilters:u,totalCount:e});return s?.success?s.data||el:(x.oR.error(s?.message||a("Failed to load logs")),el)},placeholderData:(e,a)=>{if(a?.queryKey[1]===t)return e}}),y=b?.items||[],N=function(e,t){let a=function(e){let{t}=(0,i.Bd)(),a=[{accessorKey:"created_at",header:t("Time"),cell:e=>{let{row:a}=e,n=a.original,l=a.getValue("created_at"),r=ez(n.type);return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"truncate font-mono text-xs tabular-nums",children:(0,h.fk)(l)}),(0,s.jsx)(T.Wh,{label:t(r.label),variant:r.color,size:"sm",copyable:!1,className:"-ml-1.5 !text-xs [&_span]:!text-xs"})]})},filterFn:(e,t,a)=>!!(!Array.isArray(a)||0===a.length||a.includes("0"))||a.includes(String(e.original.type)),enableHiding:!1,size:180}];return e&&a.push({id:"channel",header:t("Channel"),accessorFn:e=>e.channel,cell:function(e){let{row:a}=e,{sensitiveVisible:n,setAffinityTarget:l,setAffinityDialogOpen:r}=X(),i=a.original;if(!eq(i.type))return null;let o=tm(i.other),c=o?.admin_info?.channel_affinity,d=o?.admin_info?.use_channel??[],u=Array.isArray(d)?d.map(String).filter(
1Boolean):[],m=u.length>1,x=m?u.join(" â "):void 0,p=i.channel_name?`${i.channel_name} #${i.channel}`:`#${i.channel}`,h=`#${i.channel}`,g=n?i.channel_name:"â¢â¢â¢â¢",f=o?.admin_info?.multi_key_index,b=o?.admin_info?.is_multi_key===!0&&"number"==typeof f&&Number.isFinite(f);return(0,s.jsx)(tn.Bc,{children:(0,s.jsxs)(tn.m_,{children:[(0,s.jsxs)(tn.k$,{render:(0,s.jsx)("div",{className:"flex max-w-[160px] flex-col gap-0.5"}),children:[(0,s.jsxs)("div",{className:"relative inline-flex w-fit items-center gap-1",children:[(0,s.jsx)(T.Wh,{label:h,autoColor:String(i.channel),copyText:String(i.channel),size:"sm",showDot:!1,className:"font-mono"}),b&&(0,s.jsx)(T.Wh,{label:String(f),size:"sm",showDot:!1,copyable:!1,variant:"neutral",className:"h-5 min-w-5 justify-center rounded-full px-1 font-mono text-xs","aria-label":`${t("Key")} ${f}`}),m&&(0,s.jsxs)(ts.AM,{children:[(0,s.jsx)(ts.Wv,{render:(0,s.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground focus-visible:ring-ring inline-flex size-5 shrink-0 items-center justify-center rounded-full transition-colors focus-visible:ring-2 focus-visible:outline-none","aria-label":t("Retry Chain"),onClick:e=>e.stopPropagation()}),children:(0,s.jsx)(e7.A,{className:"size-3.5 text-amber-500","aria-hidden":"true"})}),(0,s.jsx)(ts.hl,{side:"top",align:"start",className:"w-64 text-xs",children:(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsx)("p",{className:"font-medium",children:t("Retry Chain")}),(0,s.jsx)("p",{className:"text-muted-foreground font-mono break-all",children:x})]})})]}),c&&(0,s.jsx)("button",{type:"button",className:"absolute -top-1 -right-1 leading-none text-amber-500",onClick:e=>{e.stopPropagation(),l({rule_name:c.rule_name||"",using_group:c.using_group||c.selected_group||"",key_hint:c.key_hint||"",key_fp:c.key_fp||""}),r(!0)},children:(0,s.jsx)(e9.A,{className:"size-3 fill-current"})})]}),i.channel_name&&(0,s.jsx)("span",{className:"text-muted-foreground/70 truncate [font-family:var(--font-body)] !text-xs",children:g})]}),(0,s.jsx)(tn.ZI,{children:(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsx)("p",{children:n?p:h}),x&&(0,s.jsxs)("p",{className:"text-muted-foreground text-xs",children:[t("Chain"),": ",x]}),b&&(0,s.jsxs)("p",{className:"text-muted-foreground text-xs",children:[t("Key"),": ",f]}),c&&(0,s.jsxs)("div",{className:"border-t pt-1 text-xs",children:[(0,s.jsx)("p",{className:"font-medium",children:t("Channel Affinity")}),(0,s.jsxs)("p",{children:[t("Rule"),": ",c.rule_name||"-"]}),(0,s.jsxs)("p",{children:[t("Group"),":"," ",n?c.using_group||c.selected_group||"-":"â¢â¢â¢â¢"]})]})]})})]})})}},{id:"user",header:t("User"),accessorFn:e=>e.username,cell:function(e){let{row:t}=e,{sensitiveVisible:a,setSelectedUserId:n,setUserInfoDialogOpen:l}=X(),r=t.original;return r.username?(0,s.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 text-left",onClick:e=>{e.stopPropagation(),n(r.user_id),l(!0)},children:[(0,s.jsx)(ta.eu,{className:"ring-border/60 size-6 ring-1 max-sm:hidden",children:(0,s.jsx)(ta.q5,{className:(0,e8.cn)("text-[11px] font-semibold",!a&&"bg-muted text-muted-foreground"),style:a?(0,tl.u)(r.username):void 0,children:a?(0,tl.f)(r.username):"â¢"})}),(0,s.jsx)(tn.Bc,{delay:300,children:(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)("span",{className:"text-muted-foreground max-w-[100px] truncate text-sm hover:underline"}),children:a?r.username:"â¢â¢â¢â¢"}),a&&r.username.length>12&&(0,s.jsx)(tn.ZI,{side:"top",children:r.username})]})})]}):null}}),a.push({accessorKey:"token_name",header:t("Token"),cell:function(e){let{row:t}=e,{sensitiveVisible:a}=X(),n=t.original;if(!eq(n.type))return null;let l=n.token_name;if(!l)return null;let r=tm(n.other),i=a?l:"â¢â¢â¢â¢",o=n.group;o||(o=r?.group||"");let c=function(e){let t=e?.user_group_ratio;if(null!=t&&-1!==t&&Number.isFinite(t))return t;let a=e?.group_ratio;return null!=a&&1!==a&&Number.isFinite(a)?a:null}(r);return(0,s.jsxs)("div",{className:"flex max-w-[200px] flex-col gap-0.5",children:[(0,s.jsx)(tn.Bc,{delay:300,children:(0,s.jsxs)(tn.m_,{children:[(0,s.jsx)(tn.k$,{render:(0,s.jsx)("div",{className:"max-w-full"}),children:(0,s.jsx)(T.Wh,{label:i,icon:te.A,copyText:a?l:void 0,size:"sm",showDot:!1,className:"border-border/60 bg-muted/30 text-foreground h-6 max-w-full gap-1.5 overflow-hidden rounded-md border px-2 py-0.5 [font-family:var(--font-body)]"})}),a&&l.length>16&&(0,s.jsx)(tn.ZI,{side:"top",className:"max-w-xs break-all",children:l})]})}),(o||null!=c)&&(0,s.jsxs)("span",{className:"block max-w-full truncate text-xs leading-none",children:[o?(0,s.jsx)(tt.d,{group:o,label:a?void 0:"â¢â¢â¢â¢",type:"text",size:"sm",className:"inline align-baseline text-xs leading-none [&>span]:leading-none"}):null,o&&null!=c?" ":null,null!=c?(0,s.jsxs)("span",{className:"text-muted-foreground
1/60 relative top-px align-baseline tabular-nums",children:[t4(c),"x"]}):null]})]})},size:160}),a.push({accessorKey:"model_name",header:t("Model"),cell:function(e){let t,a,{row:n}=e,l=n.original;if(!eq(l.type))return null;let r=(t=tm(l.other),a=!!(t?.is_model_mapped&&t?.upstream_model_name&&""!==t.upstream_model_name),{name:l.model_name,isMapped:a,actualModel:a?t.upstream_model_name:void 0});return(0,s.jsx)("div",{className:"flex w-fit flex-col gap-0.5",children:(0,s.jsx)(t0,{modelName:r.name,actualModel:r.actualModel})})},meta:{mobileTitle:!0}},{accessorKey:"is_stream",header:t("Stream"),cell:e=>{let{row:t}=e,a=t.original;if(!eF(a.type))return null;let n=t.getValue("use_time"),l=tm(a.other),r=n>0&&a.completion_tokens>0?a.completion_tokens/n:null;return(0,s.jsx)(t3,{isStream:a.is_stream,tokensPerSecond:r,streamStatus:l?.stream_status})},meta:{label:t("Stream")}},{accessorKey:"prompt_tokens",header:"Tokens",cell:e=>{let{row:a}=e,n=a.original;if(!eq(n.type))return null;let l=tm(n.other),r=n.prompt_tokens||0,i=n.completion_tokens||0;if(0===r&&0===i)return(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let o=l?.cache_tokens||0,c=l?.cache_creation_tokens_5m||0,d=l?.cache_creation_tokens_1h||0,u=c>0||d>0?c+d:l?.cache_creation_tokens||0;return(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsxs)("span",{className:"font-mono text-xs font-medium tabular-nums",children:[r.toLocaleString()," /"," ",i.toLocaleString()]}),(o>0||u>0)&&(0,s.jsxs)("div",{className:"flex items-center gap-1 text-[11px]",children:[o>0&&(0,s.jsxs)("span",{className:"text-muted-foreground/60",children:[t("Cache"),"â ",o.toLocaleString()]}),u>0&&(0,s.jsxs)("span",{className:"text-muted-foreground/60",children:["â ",u.toLocaleString()]})]})]})}},{accessorKey:"quota",header:t("Cost"),cell:e=>{let{row:t}=e,a=t.original;if(!eq(a.type))return null;let n=t.getValue("quota"),l=tm(a.other);return(0,s.jsx)(tJ,{quota:n,other:l})}},{accessorKey:"use_time",header:t("Timing"),cell:e=>{let{row:t}=e,a=t.original;if(!eF(a.type))return null;let n=t.getValue("use_time"),l=tm(a.other);return(0,s.jsx)(t2,{useTimeSec:n,completionTokens:a.completion_tokens,frtMs:l?.frt,isStream:a.is_stream})}},{accessorKey:"content",header:t("Details"),cell:function(a){let n,{row:l}=a,[i,o]=(0,r.useState)(!1),c=l.original,d=tm(c.other),u=(n=function(e,t,a){if(3===e.type||7===e.type){let e=tj(t,a);return e?[{text:e}]:[]}if(6===e.type)return[{text:a("Async task refund")}];if(2!==e.type)return[];if(tc(t)){let s=[];return s.push({text:a("Violation Fee"),danger:!0}),t?.violation_fee_code&&s.push({text:t.violation_fee_code,muted:!0}),s.push({text:`${a("Fee")}: ${(0,h.qW)(t?.fee_quota??e.quota)}`,muted:!0}),s}if(!t)return[];let s=[],n={digitsLarge:4,digitsSmall:6,abbreviate:!1},l=e=>(0,tr.AM)(e,n),r=(e,t)=>{let a=e.join(" / ");return t?`${a}/M`:a},i="tiered_expr"===t.billing_mode,o=tf(t);if(i)if(o){let e=o.priceEntries.filter(e=>["inputPrice","outputPrice"].includes(e.field)).map(e=>l(e.price));if(e.length>0){let t=o.tier.label||a("Default");s.push({text:`${t} \xb7 ${r(e,!0)}`})}let t=o.priceEntries.filter(e=>["cacheReadPrice","cacheCreatePrice","cacheCreate1hPrice"].includes(e.field)).map(e=>l(e.price));t.length>0&&s.push({text:`${a("Cache")} ${r(t,!1)}`,muted:!0});let i=o.priceEntries.filter(e=>!["inputPrice","outputPrice","cacheReadPrice","cacheCreatePrice","cacheCreate1hPrice"].includes(e.field)).map(e=>{let t;return`${a(e.shortLabel)} ${t=e.price,`${(0,tr.AM)(t,n)}/M`}`});i.length>0&&s.push({text:i.join(" · "),muted:!0})}else s.push({text:`${a("Dynamic Pricing")} \xb7 ${a("No matching results")}`,muted:!0});else{let e=t.model_price;if((e??0)>0&&null!=e)s.push({text:`${a("Per-call")} \xb7 ${(0,tr.AM)(e,n)}`});else if(null!=t.model_ratio){let e=2*t.model_ratio,n=[l(e)];if(null!=t.completion_ratio&&n.push(l(e*t.completion_ratio)),s.push({text:`${a("Standard")} \xb7 ${r(n,!0)}`}),tg(t)){let n=[null!=t.cache_ratio&&1!==t.cache_ratio?l(e*t.cache_ratio):null,null!=t.cache_creation_ratio&&1!==t.cache_creation_ratio?l(e*t.cache_creation_ratio):null,null!=t.cache_creation_ratio_1h&&0!==t.cache_creation_ratio_1h?l(e*t.cache_creation_ratio_1h):null].filter(
1Boolean);n.length>0&&s.push({text:`${a("Cache")} ${r(n,!1)}`,muted:!0})}}else{let e=t.user_group_ratio,n=t.group_ratio,l=null!=e&&Number.isFinite(e)&&-1!==e,r=l?e:n,i=l?a("User Exclusive Ratio"):a("Group Ratio");null!=r&&Number.isFinite(r)&&s.push({text:`${i} ${t4(r)}x`})}}return t.is_system_prompt_overwritten&&s.push({text:a("System Prompt Override"),danger:!0}),s}(c,d,t),e&&d?.admin_info?.quota_saturation?[{text:t("Quota clamped"),danger:!0},...n]:n),m=u[0],x=u.length>1,p="text-foreground";m?.muted?p="text-muted-foreground/60":m?.danger&&(p="text-red-600 dark:text-red-400");let g=(0,s.jsx)("span",{className:"text-muted-foreground/40",children:"â"});return m?g=(0,s.jsxs)("span",{className:(0,e8.cn)("truncate leading-snug group-hover:underline",p),children:[m.text,x&&(0,s.jsxs)("span",{className:"text-muted-foreground/40 ml-0.5",children:["+",u.length-1]})]}):c.content&&(g=(0,s.jsx)("span",{className:"text-muted-foreground truncate group-hover:underline",children:eK(c.content)})),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"group flex max-w-[200px] items-center gap-1 text-left text-xs",onClick:()=>o(!0),title:t("Click to view full details"),children:g}),(0,s.jsx)(tU,{log:c,isAdmin:e,open:i,onOpenChange:o})]})},size:180,maxSize:200}),a}(t),n=function(e){let{t}=(0,i.Bd)(),a=[{accessorKey:"submit_time",header:t("Submit Time"),cell:e=>{let{row:a}=e,n=a.original,l=a.getValue("submit_time");return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"truncate font-mono text-xs tabular-nums",children:(0,h.fk)(l,"milliseconds")}),(0,s.jsx)(T.Wh,{label:t(ax.getLabel(n.status)),variant:ax.getVariant(n.status),size:"sm",copyable:!1})]})},size:180}];return e&&a.push(aN({headerLabel:t("Channel")})),a.push({accessorKey:"action",header:t("Type"),cell:e=>{let{row:a}=e,n=a.getValue("action");return(0,s.jsx)(T.Wh,{label:t(am.getLabel(n)),variant:am.getVariant(n),icon:ak[n]??ad.A,size:"sm",copyable:!1,className:"-ml-1.5"})}}),a.push({accessorKey:"mj_id",header:t("Task ID"),cell:e=>{let{row:t}=e,a=t.getValue("mj_id");return a?(0,s.jsx)("div",{className:"flex max-w-[160px] flex-col gap-0.5",children:(0,s.jsx)(T.Wh,{label:a,copyText:a,variant:"neutral",size:"sm",className:"border-border/60 bg-muted/30 !text-foreground max-w-full truncate rounded-md border px-1.5 py-0.5 font-mono"})}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},meta:{mobileTitle:!0}}),a.push(ay({submitTimeKey:"submit_time",finishTimeKey:"finish_time",headerLabel:t("Duration")})),e&&a.push({accessorKey:"code",header:t("Submit Result"),cell:e=>{let{row:a}=e,n=a.getValue("code");return(0,s.jsx)(T.Wh,{label:t(ap.getLabel(String(n))),variant:ap.getVariant(String(n)),size:"sm",copyable:!1,className:"-ml-1.5"})}}),a.push(aw({headerLabel:t("Progress")}),{accessorKey:"image_url",header:t("Image"),cell:function(e){let{row:a}=e,n=a.original,l=a.getValue("image_url"),[i,o]=(0,r.useState)(!1);return l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"group text-left text-xs",onClick:()=>o(!0),title:t("Click to view image"),children:(0,s.jsx)("span",{className:"text-foreground truncate leading-snug group-hover:underline",children:t("View")})}),(0,s.jsx)(aj,{imageUrl:l,taskId:n.mj_id,open:i,onOpenChange:o})]}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})}},{accessorKey:"prompt",header:t("Prompt"),cell:function(e){let{row:a}=e,n=a.original,l=a.getValue("prompt"),[i,o]=(0,r.useState)(!1);return l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"group flex max-w-[220px] items-center text-left text-xs",onClick:()=>o(!0),title:t("Click to view full prompt"),children:(0,s.jsx)("span",{className:"text-muted-foreground truncate leading-snug group-hover:underline",children:l})}),(0,s.jsx)(av,{prompt:l,promptEn:n.prompt_en,open:i,onOpenChange:o})]}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},size:200,maxSize:220},function(e){let{accessorKey:t="fail_reason",headerLabel:a,cellTitle:n}=e;return{accessorKey:t,header:e=>{let{column:t}=e;return(0,s.jsx)(e3.wZ,{column:t,title:a})},cell:function(e){let{row:a}=e,l=a.getValue(t),[i,o]=(0,r.useState)(!1);return l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"group flex max-w-[200px] items-center gap-1 text-left text-xs",onClick:()=>o(!0),title:n,children:(0,s.jsx)("span",{className:"truncate leading-snug text-red-600 group-hover:underline dark:text-red-400",children:l})}),(0,s.jsx)(a_,{failReason:l,open:i,onOpenChange:o})]}
1):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},meta:{label:a}}}({headerLabel:t("Fail Reason"),cellTitle:t("Click to view full error message")})),a}(t),l=function(e){let{t}=(0,i.Bd)(),a=[{accessorKey:"submit_time",header:t("Submit Time"),cell:e=>{let{row:t}=e,a=t.original,n=t.getValue("submit_time");return(0,s.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"truncate font-mono text-xs tabular-nums",children:(0,h.fk)(n,"seconds")}),a.finish_time?(0,s.jsx)("span",{className:"text-muted-foreground/60 truncate font-mono text-[11px] tabular-nums",children:(0,h.fk)(a.finish_time,"seconds")}):(0,s.jsx)("span",{className:"text-muted-foreground/50 text-[11px]",children:"-"})]})},size:180}];return e&&a.push(aN({headerLabel:t("Channel")}),{id:"user",header:t("User"),accessorFn:e=>e.username||e.user_id,cell:function(e){let{row:t}=e,{sensitiveVisible:a,setSelectedUserId:n,setUserInfoDialogOpen:l}=X(),r=t.original,i=r.username||String(r.user_id||"?");return(0,s.jsxs)("button",{type:"button",className:"flex items-center gap-1.5 text-left",onClick:e=>{e.stopPropagation(),n(r.user_id),l(!0)},children:[(0,s.jsx)(ta.eu,{className:"ring-border/60 size-6 ring-1 max-sm:hidden",children:(0,s.jsx)(ta.q5,{className:(0,e8.cn)("text-[11px] font-semibold",!a&&"bg-muted text-muted-foreground"),style:a?(0,tl.u)(i):void 0,children:a?(0,tl.f)(i):"â¢"})}),(0,s.jsx)("span",{className:"text-muted-foreground truncate text-sm hover:underline",children:a?i:"â¢â¢â¢â¢"})]})}}),a.push({accessorKey:"task_id",header:t("Task ID"),cell:e=>{let{row:a}=e,n=a.original,l=a.getValue("task_id");return l?(0,s.jsxs)("div",{className:"flex max-w-[170px] flex-col gap-0.5",children:[(0,s.jsx)(T.Wh,{label:l,copyText:l,variant:"neutral",size:"sm",className:"border-border/60 bg-muted/30 !text-foreground max-w-full truncate rounded-md border px-1.5 py-0.5 font-mono"}),(0,s.jsxs)("span",{className:"text-muted-foreground/60 truncate text-[11px]",children:[t(n.platform)," · ",t(ah.getLabel(n.action))]})]}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},meta:{mobileTitle:!0}},ay({submitTimeKey:"submit_time",finishTimeKey:"finish_time",unit:"seconds",headerLabel:t("Duration"),warningThresholdSec:300}),{accessorKey:"status",header:t("Status"),cell:e=>{let{row:a}=e,n=a.getValue("status");return(0,s.jsx)(T.Wh,{label:t(ag.getLabel(n,n||"Submitting")),variant:ag.getVariant(n),size:"sm",copyable:!1,className:"-ml-1.5"})}},aw({headerLabel:t("Progress")}),{accessorKey:"fail_reason",header:t("Details"),cell:function(e){let{row:a}=e,n=a.original,l=a.getValue("fail_reason"),i=n.status,[o,c]=(0,r.useState)(!1);if("suno"===n.platform&&i===eT&&aI(n.data).some(e=>e&&"object"==typeof e&&e.audio_url))return(0,s.jsx)(aq,{log:n});if("image"===n.platform&&i===eT&&a$(n.data))return(0,s.jsx)(aR,{log:n});let d=n.action===ew||n.action===ek||n.action===eC||n.action===eS||n.action===eA,u=l?.startsWith("http");if(i===eT&&d&&u){let e=`/v1/videos/${n.task_id}/content`;return(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-foreground text-xs hover:underline",children:t("Click to preview video")})}return l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("button",{type:"button",className:"group flex max-w-[200px] items-center gap-1 text-left text-xs",onClick:()=>c(!0),title:t("Click to view full error message"),children:(0,s.jsx)("span",{className:"truncate leading-snug text-red-600 group-hover:underline dark:text-red-400",children:l})}),(0,s.jsx)(a_,{failReason:l,open:o,onOpenChange:c})]}):(0,s.jsx)("span",{className:"text-muted-foreground/60 text-xs",children:"-"})},size:200,maxSize:220}),a}(t);switch(e){case"common":default:return a;case"drawing":return n;case"task":return l}}(t,n),w=v||_&&!b;(0,r.useEffect)(()=>{b?.total!=null&&(c.current=b.total,d.current=JSON.stringify({searchParams:o,columnFilters:u,logCategory:t}))},[b?.total,o,u,t]);let{table:k}=(0,e3.uI)({data:y,columns:N,columnFilters:u,columnVisibilityStorageKey:`usage-logs:${t}:${n?"admin":"user"}:column-visibility`,pagination:p,enableRowSelection:!1,onPaginationChange:g,onColumnFiltersChange:m,manualPagination:!0,manualFiltering:!0,totalCount:b?.total||0,ensurePageInRange:f}),C="common"===t;return(0,s.jsx)(e3.cx,{table:k,columns:N,isLoading:w,isFetching:_,totalRows:b?.total,emptyTitle:a("No Logs Found"),empty
1Description:a("No usage logs available. Logs will appear here once API calls are made."),skeletonKeyPrefix:"usage-log-skeleton",applyHeaderSize:!0,tableClassName:(0,e8.cn)("[&_[data-slot=table]]:text-[13px] [&_[data-slot=table]_td]:text-[13px] [&_[data-slot=table]_td_*]:text-[13px] [&_[data-slot=table]_th]:text-[13px] [&_[data-slot=table]_th_*]:text-[13px]"),mobile:(0,s.jsx)(sp,{table:k,isLoading:w,logCategory:t}),toolbar:C?(0,s.jsx)(a7,{table:k}):(0,s.jsx)(se,{table:k,logCategory:t}),renderRow:e=>{let t=e.original.type,a=C&&null!=t?sg[t]??"":"";if(C&&n){let t=tm(e.original.other??"");t?.admin_info?.quota_saturation&&(a="bg-amber-50/60 dark:bg-amber-950/25")}return(0,s.jsx)(e3.J2,{row:e,className:(0,e8.cn)("transition-colors",a),getColumnClassName:()=>C?"py-2":"py-3.5"},e.id)}})}var sj=a(51581);let sv=(0,n.GY)("/_authenticated/usage-logs/$section"),s_=["drawing","image-results","task"],sy={common:{titleKey:"Common Logs"},drawing:{titleKey:"Drawing Logs"},"image-results":{titleKey:"Image Results"},task:{titleKey:"Task Logs"},"export-management":{titleKey:"Export Management",descriptionKey:"Manage export queue, tasks and configuration"}};function sN(){let{t:e}=(0,i.Bd)(),t=(0,l.Z)(),a=sv.useParams(),n=(0,o.h)(),{status:x}=(0,c.s)(),p=!!x?.enable_log_export_offline,h=!!x?.image_result_enabled,g=a.section&&(0,sj.Dk)(a.section)?a.section:sj.Ck,{selectedUserId:b,userInfoDialogOpen:j,setUserInfoDialogOpen:v,affinityTarget:_,affinityDialogOpen:y,setAffinityDialogOpen:N}=X(),{canManageScope:w,viewScope:k,setViewScope:C}=ee(),S=(0,r.useMemo)(()=>[{title:"Task Logs",items:[...s_.filter(e=>"image-results"!==e||h).map(e=>({title:sy[e].titleKey,url:`/usage-logs/${e}`})),...n&&p?[{title:sy["export-management"].titleKey,url:"/usage-logs/export-management"}]:[]]}],[n,p,h]),A=(0,d.Kb)(S),T=(0,r.useMemo)(()=>(A[0]?.items??[]).map(e=>"url"in e&&"string"==typeof e.url?e.url.split("/").pop()??null:null).filter(e=>!!(e&&(0,sj.Dk)(e))),[A]);(0,r.useEffect)(()=>{!x||"common"===g||T.includes(g)||t({to:"/usage-logs/$section",params:{section:T[0]??"common"},replace:!0})},[x,g,T,t]);let I=(0,r.useCallback)(e=>{t({to:"/usage-logs/$section",params:{section:e}})},[t]),$=(0,r.useCallback)(e=>{("all"===e||"self"===e)&&C(e)},[C]),R="common"===g?sy.common:"export-management"===g?sy["export-management"]:sy.task,q="common"!==g&&T.length>1;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(m.Ni,{fixedContent:!0,children:[(0,s.jsx)(m.Ni.Title,{children:e(R.titleKey)}),w&&(0,s.jsx)(m.Ni.Actions,{children:(0,s.jsx)(u.tU,{value:k,onValueChange:$,children:(0,s.jsxs)(u.j7,{children:[(0,s.jsx)(u.Xi,{value:"all",children:e("All")}),(0,s.jsx)(u.Xi,{value:"self",children:e("Only Mine")})]})})}),(0,s.jsx)(m.Ni.Content,{children:(0,s.jsxs)("div",{className:"flex h-full min-h-0 flex-col gap-4",children:[q&&(0,s.jsx)(u.tU,{value:g,onValueChange:I,children:(0,s.jsx)(u.j7,{className:"max-w-full flex-wrap justify-start group-data-horizontal/tabs:h-auto",children:T.map(t=>(0,s.jsx)(u.Xi,{value:t,children:e(sy[t].titleKey)},t))})}),(0,s.jsx)("div",{className:"min-h-0 flex-1",children:"export-management"===g?(0,s.jsx)(B,{}):"image-results"===g?(0,s.jsx)(ea,{}):(0,s.jsx)(sb,{logCategory:g})})]})})]}),(0,s.jsx)(e2,{userId:b,open:j,onOpenChange:v}),(0,s.jsx)(f,{open:y,onOpenChange:N,target:_?{rule_name:_.rule_name||"",using_group:_.using_group||_.selected_group||"",key_hint:_.key_hint||"",key_fp:_.key_fp||""}:null})]})}let sw=function(){return(0,s.jsx)(Y,{children:(0,s.jsx)(sN,{})})}}}]);
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.