@cartanova/qgrid-cli 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +3 -2
  2. package/bundle/dist/application/qgrid/qgrid.frame.js +19 -3
  3. package/bundle/dist/application/qgrid/qgrid.types.js +2 -1
  4. package/bundle/dist/application/queries.generated.js +2 -1
  5. package/bundle/dist/application/request-log/request-log.model.js +15 -2
  6. package/bundle/dist/application/request-log/request-log.types.js +6 -2
  7. package/bundle/dist/application/sonamu.generated.js +14 -6
  8. package/bundle/dist/application/sonamu.generated.sso.js +5 -2
  9. package/bundle/dist/i18n/sd.generated.js +6 -3
  10. package/bundle/dist/migrations/20260423180818_alter_request_logs_add1_alter1.js +17 -0
  11. package/bundle/dist/migrations/20260423182017_alter_request_logs_add2_drop1_alter1.js +19 -0
  12. package/bundle/dist/migrations/20260423183613_alter_request_logs_add1_alter1.js +16 -0
  13. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +1 -1
  14. package/bundle/src/application/qgrid/qgrid.frame.ts +10 -1
  15. package/bundle/src/application/qgrid/qgrid.types.ts +1 -0
  16. package/bundle/src/application/queries.generated.ts +3 -0
  17. package/bundle/src/application/request-log/request-log.entity.json +33 -17
  18. package/bundle/src/application/request-log/request-log.model.ts +26 -2
  19. package/bundle/src/application/request-log/request-log.types.ts +6 -2
  20. package/bundle/src/application/sonamu.generated.http +16 -2
  21. package/bundle/src/application/sonamu.generated.sso.ts +9 -6
  22. package/bundle/src/application/sonamu.generated.ts +25 -5
  23. package/bundle/src/i18n/sd.generated.ts +5 -2
  24. package/bundle/src/migrations/20260423180818_alter_request_logs_add1_alter1.ts +18 -0
  25. package/bundle/src/migrations/20260423182017_alter_request_logs_add2_drop1_alter1.ts +20 -0
  26. package/bundle/src/migrations/20260423183613_alter_request_logs_add1_alter1.ts +15 -0
  27. package/bundle/web-dist/client/assets/index-BfL_bTVI.css +1 -0
  28. package/bundle/web-dist/client/assets/index-CMOHJBal.js +78 -0
  29. package/bundle/web-dist/client/assets/logs-B2pDXaji.js +1 -0
  30. package/bundle/web-dist/client/assets/{routes-DQKecVGa.js → routes-fpJMuLAs.js} +1 -1
  31. package/bundle/web-dist/client/assets/{sd.generated-NHYHS_-0.js → sd.generated-CIOZewtL.js} +1 -1
  32. package/bundle/web-dist/client/assets/{services.generated-DDVXMid7.js → services.generated-B2N0iPav.js} +1 -1
  33. package/bundle/web-dist/client/assets/{show-D2z1qxJ5.js → show-DFVBcmXm.js} +2 -2
  34. package/bundle/web-dist/client/assets/tokens--LyDCm10.js +1 -0
  35. package/bundle/web-dist/client/index.html +3 -3
  36. package/bundle/web-dist/server/assets/{copy-BVWDOV2T.js → copy-CKCGxwII.js} +1 -1
  37. package/bundle/web-dist/server/assets/{lazyRouteComponent-BJmwxFyJ.js → lazyRouteComponent-BlvOfJIF.js} +2 -2
  38. package/bundle/web-dist/server/assets/{logs-DgIbufNf.js → logs-BYIBD0yv.js} +172 -80
  39. package/bundle/web-dist/server/assets/{routes-x7-hqUm0.js → routes-p2n4SfAB.js} +2 -2
  40. package/bundle/web-dist/server/assets/{sd.generated-BZPIp4uL.js → sd.generated-CIg_jf8e.js} +5 -2
  41. package/bundle/web-dist/server/assets/{services.generated-BA0gbdmd.js → services.generated-DIeiDdqy.js} +20 -4
  42. package/bundle/web-dist/server/assets/{shim-DGrmZkac.js → shim-Dq_Izqnc.js} +1 -1
  43. package/bundle/web-dist/server/assets/{show-Bk3NayMH.js → show-DZ_U1u-N.js} +30 -9
  44. package/bundle/web-dist/server/assets/{tokens-CVSwt0x0.js → tokens-DOybPnNU.js} +16 -7
  45. package/bundle/web-dist/server/entry-server.generated.js +12 -8
  46. package/package.json +1 -1
  47. package/bundle/web-dist/client/assets/index-BRZCFaFz.css +0 -1
  48. package/bundle/web-dist/client/assets/index-D8eEjsZj.js +0 -78
  49. package/bundle/web-dist/client/assets/logs-CKnJzuH6.js +0 -1
  50. package/bundle/web-dist/client/assets/tokens-BaywaQkm.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{l as t,u as n}from"./vendor-tanstack-DJRQAbrY.js";import{i as r,r as i}from"./vendor-react-DH4kUfK2.js";import{n as a}from"./index-D8eEjsZj.js";import{n as o,t as s}from"./cost-DE_8cLD-.js";import{n as c,r as l,t as u}from"./services.generated-DDVXMid7.js";var d=e(r()),f=i(),p=e=>(0,f.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,f.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m15 18l-6-6l6-6`})}),m=e=>(0,f.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,f.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m9 18l6-6l-6-6`})}),h=50;function g(e){let t=new Date(e);return`${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function _(e){return e.toLocaleString()}function v(e){let t=e.input_tokens+e.cache_read_tokens+e.cache_creation_tokens;return t===0?`—`:`${Math.round(e.cache_read_tokens/t*100)}%`}function y(e,t=30){return e.length>t?`${e.slice(0,t)}...`:e}function b({page:e,onPageChange:r}={}){let i=n(),[a,b]=(0,d.useState)(1),x=e??a,S=r??b,[C,w]=(0,d.useState)(``),{data:T}=l.useTokens(`A`),E=(T?.rows??[]).map(e=>e.name).filter(Boolean),{data:D,isLoading:O}=c.useRequestLogs(`A`,{num:h,page:x,orderBy:`id-desc`,...C?{token_name:C}:{}}),{data:k}=u.useTotalCost(C||void 0),A=D?.rows??[],j=D?.total??0,M=Math.ceil(j/h);return(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 flex-wrap`,children:[E.length>0&&(0,f.jsxs)(`select`,{value:C,onChange:e=>{w(e.target.value),S(1)},className:`border border-sand-200 rounded-md px-2 py-1 text-xs text-sand-700 bg-white focus:outline-none focus:border-sienna-300`,children:[(0,f.jsx)(`option`,{value:``,children:`All Tokens`}),E.map(e=>(0,f.jsx)(`option`,{value:e,children:e},e))]}),(0,f.jsxs)(`span`,{className:`text-[11px] text-sand-400`,children:[j,` results`]}),(0,f.jsx)(`span`,{className:`text-[11px] tabular-nums font-medium text-sienna-600`,children:o(k?.usd??0)})]}),O?(0,f.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:5}).map((e,t)=>(0,f.jsx)(`div`,{className:`h-8 bg-sand-100 rounded animate-pulse`},`skel-${t}`))}):A.length===0?(0,f.jsx)(`div`,{className:`text-sand-400 text-center py-12 text-sm`,children:`No requests yet.`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{className:`rounded-lg bg-sand-50 overflow-hidden`,children:(0,f.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,f.jsx)(`thead`,{children:(0,f.jsxs)(`tr`,{className:`border-b border-sand-200`,children:[(0,f.jsx)(`th`,{className:`text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`ID`}),(0,f.jsx)(`th`,{className:`text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Date`}),(0,f.jsx)(`th`,{className:`text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Token`}),(0,f.jsx)(`th`,{className:`text-left px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Query`}),(0,f.jsx)(`th`,{className:`text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`In`}),(0,f.jsx)(`th`,{className:`text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Out`}),(0,f.jsx)(`th`,{className:`text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`C.Read`}),(0,f.jsx)(`th`,{className:`text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`C.Write`}),(0,f.jsx)(`th`,{className:`text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Hit`}),(0,f.jsx)(`th`,{className:`text-right px-3 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Cost`}),(0,f.jsx)(`th`,{className:`w-8 px-2 py-2.5`})]})}),(0,f.jsx)(`tbody`,{className:`divide-y divide-sand-200/60`,children:A.map(e=>(0,f.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 cursor-pointer`,onClick:t=>{if(t.metaKey||t.ctrlKey){window.open(`/requests/show?id=${e.id}`,`_blank`);return}i({to:`/requests/show`,search:{id:e.id}})},children:[(0,f.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,f.jsx)(t,{to:`/requests/show`,search:{id:e.id},onClick:e=>e.stopPropagation(),className:`text-xs text-sand-500 tabular-nums hover:text-sienna-500`,children:e.id})}),(0,f.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,f.jsx)(`span`,{className:`text-[10px] text-sand-400 tabular-nums whitespace-nowrap`,children:g(e.created_at)})}),(0,f.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,f.jsx)(`span`,{className:`text-xs text-sand-500`,children:e.token_name})}),(0,f.jsx)(`td`,{className:`px-3 py-2.5`,children:(0,f.jsx)(`span`,{className:`text-sand-800 truncate max-w-48`,title:e.query,children:y(e.query)})}),(0,f.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-sand-700`,children:_(e.input_tokens)}),(0,f.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-sand-700`,children:_(e.output_tokens)}),(0,f.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-sand-700`,children:_(e.cache_read_tokens)}),(0,f.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-sand-700`,children:_(e.cache_creation_tokens)}),(0,f.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-sand-700`,children:v(e)}),(0,f.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums text-sand-700`,children:e.cost_usd===null?`-`:s(e.cost_usd)}),(0,f.jsx)(`td`,{className:`px-2 py-2.5`,children:(0,f.jsx)(m,{className:`size-4 text-sand-400`})})]},e.id))})]})}),M>1&&(0,f.jsxs)(`div`,{className:`flex items-center justify-center gap-3 mt-3`,children:[(0,f.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:x===1,onClick:()=>S(x-1),children:(0,f.jsx)(p,{className:`size-4`})}),(0,f.jsxs)(`span`,{className:`text-[11px] text-sand-400 tabular-nums`,children:[x,` / `,M]}),(0,f.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sand-600 disabled:opacity-30 transition-colors`,disabled:x===M,onClick:()=>S(x+1),children:(0,f.jsx)(m,{className:`size-4`})})]})]})]})}function x(){let{page:e}=a.useSearch(),t=a.useNavigate();return(0,f.jsxs)(`div`,{className:`space-y-5 max-w-300 mx-auto -translate-x-4`,children:[(0,f.jsx)(`h1`,{className:`text-xl font-medium text-sand-900 tracking-tight`,children:`Request Logs`}),(0,f.jsx)(b,{page:e,onPageChange:e=>t({search:{page:e}})})]})}export{x as component};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{y as t}from"./vendor-tanstack-DJRQAbrY.js";import{i as n,r}from"./vendor-react-DH4kUfK2.js";import{S as i,_ as a,b as o,g as s,h as c,i as l,l as u,m as d,v as f,x as p,y as m}from"./sd.generated-NHYHS_-0.js";import{a as h,i as g,r as _}from"./index-D8eEjsZj.js";import{r as v,t as y}from"./services.generated-DDVXMid7.js";import{n as b,t as x}from"./copy-DdGJDXSK.js";var S=e(n()),C=r(),w=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,C.jsx)(`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 19.876 0a1 1 0 0 1 0 .696a10.75 10.75 0 0 1-19.876 0`}),(0,C.jsx)(`circle`,{cx:12,cy:12,r:3})]})}),T=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,C.jsx)(`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575a1 1 0 0 1 0 .696a10.8 10.8 0 0 1-1.444 2.49m-6.41-.679a3 3 0 0 1-4.242-4.242`}),(0,C.jsx)(`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151a1 1 0 0 1 0-.696a10.75 10.75 0 0 1 4.446-5.143M2 2l20 20`})]})}),E=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 12h14m-7-7v14`})}),D=d([`id-desc`]).describe(`RequestLogOrderBy`),O=d([`id`,`token_name`,`query`]).describe(`RequestLogSearchField`),k=d([`id-desc`,`ord-asc`]).describe(`TokenOrderBy`),A=d([`id`,`name`]).describe(`TokenSearchField`);p({id:m(),created_at:f(),token_name:i().max(100),query:i(),response:i(),input_tokens:m(),output_tokens:m(),cache_read_tokens:m(),cache_creation_tokens:m(),duration_ms:m(),cost_usd:m().nullable()});var j=p({id:m(),created_at:f(),token:i(),name:i(),refresh_token:i().nullable(),expires_at:c().nullable(),account_uuid:i().nullable(),active:s(),ord:m()});p({num:o().int().nonnegative(),page:o().int().min(1),search:O,keyword:i(),orderBy:D,queryMode:l,id:u(o().int().positive()),sonamuFilter:a(),token_name:i().max(100)}).partial(),p({num:o().int().nonnegative(),page:o().int().min(1),search:A,keyword:i(),orderBy:k,queryMode:l,id:u(o().int().positive()),sonamuFilter:a(),token:i()}).partial(),p({id:m(),created_at:f(),token_name:i().max(100),query:i(),response:i(),input_tokens:m(),output_tokens:m(),cache_read_tokens:m(),cache_creation_tokens:m(),duration_ms:m(),cost_usd:m().nullable()}),d([`A`]),p({id:m(),created_at:f(),token:i(),name:i(),refresh_token:i().nullable(),expires_at:c().nullable(),account_uuid:i().nullable(),active:s(),ord:m()}),d([`A`]);var M=j.partial({id:!0,created_at:!0,refresh_token:!0,expires_at:!0,account_uuid:!0,active:!0,ord:!0});M.pick({id:!0,token:!0,refresh_token:!0,name:!0});function N(){let[e,n]=(0,S.useState)(!1),[r,i]=(0,S.useState)(!1),[a,o]=(0,S.useState)(!1),{form:s,register:c,reset:l}=g(M,{name:``,token:``,refresh_token:``}),u=t(),d=y.useAddTokenMutation(),f=y.useOauthStartMutation(),p=async()=>{if(s.name?.trim()){o(!0);try{let{authUrl:e}=await f.mutateAsync({name:s.name.trim()});window.location.href=e}catch{o(!1)}}},m=async()=>{!s.token?.trim()||!s.name?.trim()||(await d.mutateAsync({token:s.token.trim(),name:s.name.trim(),refreshToken:s.refresh_token?.trim()??``})).added&&(await Promise.all([u.invalidateQueries({queryKey:[`Qgrid`]}),u.invalidateQueries({queryKey:[`Token`]})]),v())},v=()=>{n(!1),l(),i(!1),o(!1)};return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150 active:scale-[0.98] flex items-center gap-1`,onClick:()=>n(!0),children:[(0,C.jsx)(E,{className:`size-3.5`}),`Add Token`]}),e&&(0,C.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,C.jsx)(`div`,{className:`absolute inset-0`,onClick:v,onKeyDown:()=>{}}),(0,C.jsxs)(`div`,{className:`relative bg-white rounded-lg shadow-xl w-full max-w-md mx-4`,children:[(0,C.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100`,children:(0,C.jsx)(`h2`,{className:`text-base font-medium text-sand-900`,children:`Add Token`})}),(0,C.jsxs)(`div`,{className:`px-5 py-4 space-y-4`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name *`}),(0,C.jsx)(_,{...c(`name`),placeholder:`e.g. your-token-name`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`})]}),(0,C.jsx)(`button`,{type:`button`,className:`w-full py-2.5 text-sm font-medium rounded-md bg-sand-900 text-white hover:bg-sand-800 disabled:opacity-50 transition-colors duration-150 flex items-center justify-center gap-2`,disabled:!s.name?.trim()||a,onClick:p,children:a?(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full animate-spin`}),`Waiting for login...`]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(h,{className:`size-4`}),`Login with Claude`]})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,C.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`}),(0,C.jsx)(`span`,{className:`text-[10px] text-sand-400 uppercase`,children:`or`}),(0,C.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`oauth-token`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Access Token`}),(0,C.jsxs)(`div`,{className:`relative mt-1`,children:[(0,C.jsx)(_,{type:r?`text`:`password`,...c(`token`),placeholder:`sk-ant-oat01-...`,className:`w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300 pr-10`}),(0,C.jsx)(`button`,{type:`button`,className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-sand-400 hover:text-sand-600 transition-colors duration-150`,onClick:()=>i(!r),children:r?(0,C.jsx)(T,{className:`size-4`}):(0,C.jsx)(w,{className:`size-4`})})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`label`,{htmlFor:`refresh-token`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:[`Refresh Token`,` `,(0,C.jsx)(`span`,{className:`text-sand-400 normal-case tracking-normal`,children:`(optional)`})]}),(0,C.jsx)(_,{type:`password`,...c(`refresh_token`),placeholder:`sk-ant-ort01-...`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`}),(0,C.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-1`,children:`Enables auto-refresh when access token expires (~8h)`})]})]}),(0,C.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:v,children:`Cancel`}),s.token?.trim()&&(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:!s.name?.trim()||!s.token?.trim()||d.isPending,onClick:m,children:d.isPending?`Adding...`:`Add Token`})]})]})]})]})}var P=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497zM15 5l4 4`})}),F=e=>(0,C.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,C.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M10 11v6m4-6v6m5-11v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6M3 6h18M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`})});p({system:i().optional(),prompt:i(),model:i().optional(),timeout:o().optional()}),p({text:i(),tokenName:i().optional(),usage:p({input_tokens:o(),output_tokens:o(),cache_creation_input_tokens:o(),cache_read_input_tokens:o()}),durationMs:o(),costUsd:o()}),p({token:i(),name:i()}),p({token:i()}),p({token:i(),name:i(),requests:o()}),p({authUrl:i()});var I=p({utilization:o().nullable(),resets_at:i().nullable()}).nullable();p({error:i().optional(),five_hour:I.optional(),seven_day:I.optional(),seven_day_opus:I.optional(),seven_day_sonnet:I.optional(),seven_day_oauth_apps:I.optional(),seven_day_cowork:I.optional(),extra_usage:p({is_enabled:s(),monthly_limit:o().nullable(),used_credits:o().nullable(),utilization:o().nullable()}).nullable().optional()}),p({status:i(),activeTokens:o()});function L(e){return e.length>4?`...${e.slice(-4)}`:e}function R(e){if(!e)return{text:``,color:``};let t=Number(e)-Date.now();if(t<=0)return{text:`expired`,color:`text-red-500`};let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),i=n>0?`${n}h ${r}m`:`${r}m`;return t<36e5?{text:i,color:`text-amber-500`}:{text:i,color:`text-sand-400`}}function z({data:e,isLoading:n}){let[r,i]=(0,S.useState)(null),[a,o]=(0,S.useState)(null),[s,c]=(0,S.useState)(!1),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)(!1),[p,m]=(0,S.useState)(!1),{form:h,setForm:v,register:E}=g(M,{name:``,token:``,active:!0}),D=t(),O=y.useRemoveTokenMutation(),k=y.useUpdateTokenMutation(),A=y.useToggleTokenMutation(),j=()=>Promise.all([D.invalidateQueries({queryKey:[`Token`]}),D.invalidateQueries({queryKey:[`Qgrid`]})]),N=async e=>{await A.mutateAsync({id:e.id}),await j()},I=async()=>{r&&(await O.mutateAsync({token:r.token}),await j(),i(null))},z=e=>{o(e),v({name:e.name??``,token:e.token,active:e.active,refresh_token:e.refresh_token??``}),c(!1),u(!1),f(!1),m(!1)},B=async()=>{if(!a)return;let e=h.token&&h.token!==a.token?h.token.trim():void 0,t=[k.mutateAsync({token:a.token,name:h.name?.trim()??``,newToken:e??``,refreshToken:h.refresh_token?.trim()??``})];h.active!==a.active&&t.push(A.mutateAsync({id:a.id})),await Promise.all(t),await j(),o(null)},V=()=>{a&&(navigator.clipboard.writeText(a.token),f(!0),setTimeout(()=>f(!1),1500))},H=()=>{a?.refresh_token&&(navigator.clipboard.writeText(a.refresh_token),m(!0),setTimeout(()=>m(!1),1500))};if(n)return(0,C.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,C.jsx)(`div`,{className:`h-12 bg-sand-100 rounded-md animate-pulse`},`skeleton-${t}`))});let U=e??[];return U.length===0?(0,C.jsxs)(`div`,{className:`text-sand-400 text-center py-16 text-sm`,children:[`No tokens registered. Click `,(0,C.jsx)(`strong`,{className:`text-sand-600`,children:`Add Token`}),` to get started.`]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(`div`,{className:`rounded-lg bg-sand-50 overflow-hidden`,children:(0,C.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,C.jsx)(`thead`,{children:(0,C.jsxs)(`tr`,{className:`border-b border-sand-200`,children:[(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Token`}),(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Name`}),(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Status`}),(0,C.jsx)(`th`,{className:`text-left px-5 py-3 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Expires`}),(0,C.jsx)(`th`,{className:`w-20 px-3 py-3`})]})}),(0,C.jsx)(`tbody`,{className:`divide-y divide-sand-200/60`,children:U.map(e=>{let t=R(e.expires_at);return(0,C.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 ${e.active?``:`opacity-50`}`,children:[(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:L(e.token)})}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:e.name?(0,C.jsx)(`span`,{className:`text-sm text-sand-700`,children:e.name}):(0,C.jsx)(`span`,{className:`text-[11px] text-sand-400`,children:`—`})}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:(0,C.jsx)(`button`,{type:`button`,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 ${e.active?`bg-sage-400`:`bg-sand-300`}`,onClick:()=>N(e),disabled:A.isPending,children:(0,C.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform duration-200 ${e.active?`translate-x-4.5`:`translate-x-0.5`}`})})}),(0,C.jsx)(`td`,{className:`px-5 py-3`,children:t.text&&(0,C.jsx)(`span`,{className:`text-xs ${t.color}`,children:t.text})}),(0,C.jsx)(`td`,{className:`px-3 py-3`,children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,C.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:()=>z(e),children:(0,C.jsx)(P,{className:`size-4`})}),(0,C.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-red-500 transition-colors duration-150`,onClick:()=>i(e),children:(0,C.jsx)(F,{className:`size-4`})})]})})]},e.id)})})]})}),a&&(0,C.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,C.jsx)(`div`,{className:`absolute inset-0`,onClick:()=>o(null),onKeyDown:()=>{}}),(0,C.jsxs)(`div`,{className:`relative bg-white rounded-lg shadow-xl w-full max-w-sm mx-4`,children:[(0,C.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100`,children:(0,C.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Edit Token`})}),(0,C.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name`}),(0,C.jsx)(_,{...E(`name`),placeholder:`e.g. prod, dev, team-a`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`input`,{id:`token-active`,type:`checkbox`,checked:h.active??!0,onChange:e=>v({...h,active:e.target.checked}),className:`h-4 w-4 rounded border-sand-300 text-sienna-500 focus:ring-sienna-300`}),(0,C.jsx)(`label`,{htmlFor:`token-active`,className:`text-sm text-sand-700`,children:`Active`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsx)(`label`,{htmlFor:`token-value`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Token`}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:V,children:d?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(b,{className:`size-3 text-sage-500`}),(0,C.jsx)(`span`,{className:`text-sage-500`,children:`Copied`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(x,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Copy`})]})}),(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sand-600 transition-colors duration-150`,onClick:()=>c(!s),children:s?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(T,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Hide`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(w,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Show`})]})})]})]}),(0,C.jsx)(`input`,{id:`token-value`,type:s?`text`:`password`,value:h.token||(s?a.token:``),onChange:e=>v({...h,token:e.target.value}),placeholder:s?``:`●●●●●●●●●●●●●●●●`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-400 focus:outline-none focus:border-sienna-300`})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsxs)(`label`,{htmlFor:`edit-refresh-token`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:[`Refresh Token`,` `,(0,C.jsx)(`span`,{className:`text-sand-400 normal-case tracking-normal`,children:`(optional)`})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:H,children:p?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(b,{className:`size-3 text-sage-500`}),(0,C.jsx)(`span`,{className:`text-sage-500`,children:`Copied`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(x,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Copy`})]})}),(0,C.jsx)(`button`,{type:`button`,className:`flex items-center gap-1 text-[10px] text-sand-400 hover:text-sand-600 transition-colors duration-150`,onClick:()=>u(!l),children:l?(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(T,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Hide`})]}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(w,{className:`size-3`}),(0,C.jsx)(`span`,{children:`Show`})]})})]})]}),(0,C.jsx)(`input`,{id:`edit-refresh-token`,type:l?`text`:`password`,value:h.refresh_token??``,onChange:e=>v({...h,refresh_token:e.target.value}),placeholder:`sk-ant-ort01-...`,className:`mt-1 w-full border border-sand-200 rounded-md px-3 py-2 text-sm text-sand-900 bg-white placeholder:text-sand-300 focus:outline-none focus:border-sienna-300`}),(0,C.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-1`,children:`Enables auto-refresh when access token expires`})]})]}),(0,C.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:()=>o(null),children:`Cancel`}),(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:k.isPending,onClick:B,children:k.isPending?`Saving...`:`Save`})]})]})]}),r&&(0,C.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,C.jsx)(`div`,{className:`absolute inset-0`,onClick:()=>i(null),onKeyDown:()=>{}}),(0,C.jsxs)(`div`,{className:`relative bg-white rounded-lg shadow-xl w-full max-w-sm mx-4`,children:[(0,C.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,C.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Remove Token`}),(0,C.jsxs)(`p`,{className:`text-sm text-sand-700 mt-2`,children:[`Are you sure you want to remove`,` `,(0,C.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:L(r.token)}),r.name&&(0,C.jsxs)(`span`,{className:`text-sand-500`,children:[` (`,r.name,`)`]}),`?`]})]}),(0,C.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100 flex items-center justify-end gap-2`,children:[(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:()=>i(null),children:`Cancel`}),(0,C.jsx)(`button`,{type:`button`,className:`px-3 py-1 text-xs font-medium rounded-md bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 transition-colors duration-150`,disabled:O.isPending,onClick:I,children:O.isPending?`Removing...`:`Remove`})]})]})]})]})}function B(){let{data:e,isLoading:t}=v.useTokens(`A`);return(0,C.jsxs)(`div`,{className:`space-y-5 max-w-300 mx-auto -translate-x-4`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,C.jsx)(`h1`,{className:`text-xl font-medium text-sand-900 tracking-tight`,children:`Tokens`}),(0,C.jsx)(N,{})]}),(0,C.jsx)(z,{data:e?.rows,isLoading:t})]})}export{B as component};