@cartanova/qgrid-cli 2.4.2 → 2.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/dist/application/qgrid/qgrid.frame.js +13 -17
- package/bundle/dist/application/qgrid/token-subscriber.js +23 -9
- package/bundle/dist/application/qgrid/token-trigger-setup.js +4 -4
- package/bundle/dist/application/qgrid/tool-emulation.js +1 -1
- package/bundle/dist/application/sonamu.generated.js +5 -3
- package/bundle/dist/application/sonamu.generated.sso.js +3 -2
- package/bundle/dist/application/token/token.model.js +8 -3
- package/bundle/dist/application/token/token.types.js +8 -3
- package/bundle/dist/i18n/sd.generated.js +2 -1
- package/bundle/dist/index.js +3 -6
- package/bundle/dist/migrations/20260521134025_alter_request_log_steps_alter1.js +3 -9
- package/bundle/dist/migrations/20260706120000_alter_request_logs_add_image_cost.js +1 -1
- package/bundle/dist/migrations/20260710090000_alter_tokens_add_weight.js +41 -0
- package/bundle/dist/server-bootstrap.js +17 -0
- package/bundle/dist/sonamu.config.js +2 -10
- package/bundle/dist/startup-migrations.js +21 -0
- package/bundle/dist/testing/global.js +93 -5
- package/bundle/dist/testing/test-database-name.js +22 -0
- package/bundle/dist/utils/providers/anthropic/anthropic-dispatcher.js +24 -27
- package/bundle/dist/utils/providers/common/model-cost.js +22 -1
- package/bundle/dist/utils/providers/common/smooth-weighted-round-robin.js +43 -0
- package/bundle/dist/utils/providers/openai/codex-worker.js +19 -2
- package/bundle/dist/utils/providers/openai/openai-dispatcher.js +53 -40
- package/bundle/src/application/qgrid/qgrid.frame.test.ts +36 -14
- package/bundle/src/application/qgrid/qgrid.frame.ts +22 -25
- package/bundle/src/application/qgrid/token-subscriber.test.ts +102 -0
- package/bundle/src/application/qgrid/token-subscriber.ts +37 -6
- package/bundle/src/application/qgrid/token-trigger-setup.test.ts +9 -0
- package/bundle/src/application/qgrid/token-trigger-setup.ts +2 -2
- package/bundle/src/application/qgrid/token-weight-migration.test.ts +42 -0
- package/bundle/src/application/qgrid/tool-emulation.ts +6 -1
- package/bundle/src/application/sonamu.generated.http +4 -2
- package/bundle/src/application/sonamu.generated.sso.ts +1 -0
- package/bundle/src/application/sonamu.generated.ts +10 -1
- package/bundle/src/application/token/token.entity.json +17 -1
- package/bundle/src/application/token/token.model.test.ts +43 -0
- package/bundle/src/application/token/token.model.ts +18 -2
- package/bundle/src/application/token/token.types.test.ts +11 -0
- package/bundle/src/application/token/token.types.ts +3 -0
- package/bundle/src/i18n/sd.generated.ts +1 -0
- package/bundle/src/index.ts +2 -5
- package/bundle/src/migrations/20260521134025_alter_request_log_steps_alter1.ts +4 -8
- package/bundle/src/migrations/20260706120000_alter_request_logs_add_image_cost.ts +1 -1
- package/bundle/src/migrations/20260710090000_alter_tokens_add_weight.ts +38 -0
- package/bundle/src/server-bootstrap.test.ts +39 -0
- package/bundle/src/server-bootstrap.ts +21 -0
- package/bundle/src/sonamu.config.ts +3 -12
- package/bundle/src/startup-migrations.test.ts +25 -0
- package/bundle/src/startup-migrations.ts +20 -0
- package/bundle/src/testing/global.test.ts +130 -0
- package/bundle/src/testing/global.ts +143 -13
- package/bundle/src/testing/test-database-name.test.ts +38 -0
- package/bundle/src/testing/test-database-name.ts +21 -0
- package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.test.ts +75 -45
- package/bundle/src/utils/providers/anthropic/anthropic-dispatcher.ts +23 -29
- package/bundle/src/utils/providers/common/model-cost.test.ts +54 -0
- package/bundle/src/utils/providers/common/model-cost.ts +31 -0
- package/bundle/src/utils/providers/common/provider-dispatcher.ts +1 -1
- package/bundle/src/utils/providers/common/smooth-weighted-round-robin.test.ts +73 -0
- package/bundle/src/utils/providers/common/smooth-weighted-round-robin.ts +48 -0
- package/bundle/src/utils/providers/openai/codex-worker.test.ts +70 -1
- package/bundle/src/utils/providers/openai/codex-worker.ts +18 -6
- package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +109 -6
- package/bundle/src/utils/providers/openai/openai-dispatcher.ts +72 -55
- package/bundle/web-dist/client/assets/{index-CN7eSKO4.js → index-D1ExP77_.js} +3 -3
- package/bundle/web-dist/client/assets/{logs-NubdF_C_.js → logs-vuI-Zgnq.js} +1 -1
- package/bundle/web-dist/client/assets/routes-0Fki0JEi.js +5 -0
- package/bundle/web-dist/client/assets/{sd.generated-BrUnRt0B.js → sd.generated-WA5SGJYZ.js} +1 -1
- package/bundle/web-dist/client/assets/{services.generated-AsEvHbJ7.js → services.generated-DzZLnb7S.js} +1 -1
- package/bundle/web-dist/client/assets/{show-BvDjIZCX.js → show-BreAgaFH.js} +1 -1
- package/bundle/web-dist/client/assets/tokens-4VgHQtXd.js +1 -0
- package/bundle/web-dist/client/assets/use-update-token-mutation-BV6msjuy.js +1 -0
- package/bundle/web-dist/client/index.html +2 -2
- package/bundle/web-dist/server/assets/{lazyRouteComponent-BswulcOx.js → lazyRouteComponent-BrPAFtBA.js} +1 -1
- package/bundle/web-dist/server/assets/{logs-Bk9C0ELo.js → logs-CKM6W3W6.js} +3 -3
- package/bundle/web-dist/server/assets/{routes-D9OiKoqa.js → routes-DhIpPgXz.js} +130 -7
- package/bundle/web-dist/server/assets/{sd.generated-DRuQSIKo.js → sd.generated-Cwg2f53z.js} +1 -0
- package/bundle/web-dist/server/assets/{services.generated-Dp0uKgpV.js → services.generated-CsotZP44.js} +5 -5
- package/bundle/web-dist/server/assets/{show-3GokIDEJ.js → show-CV2UFjaH.js} +3 -3
- package/bundle/web-dist/server/assets/{tokens-Cjw6cQxZ.js → tokens-DfGj1y2v.js} +5 -5
- package/bundle/web-dist/server/assets/use-update-token-mutation-BL96w-Pg.js +7 -0
- package/bundle/web-dist/server/entry-server.generated.js +7 -7
- package/package.json +1 -1
- package/skills/qgrid/SKILL.md +1 -1
- package/skills/qgrid/references/anthropic-claude-code-runtime.md +2 -2
- package/skills/qgrid/references/cli-env-and-server-boot.md +9 -9
- package/skills/qgrid/references/decision-rationale.md +23 -0
- package/skills/qgrid/references/openai-codex-runtime.md +4 -3
- package/skills/qgrid/references/prompt-cache-and-usage.md +2 -0
- package/skills/qgrid/references/provider-runtime-differences.md +2 -1
- package/skills/qgrid/references/repo-map.md +2 -0
- package/skills/qgrid/references/token-auth-quota-lifecycle.md +8 -3
- package/skills/qgrid/references/verification-and-debugging.md +3 -0
- package/bundle/web-dist/client/assets/routes-NKxXqHvs.js +0 -5
- package/bundle/web-dist/client/assets/tokens-XAhJyLqj.js +0 -1
|
@@ -1,5 +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,n as r,r as i}from"./vendor-react-DH4kUfK2.js";import{r as a}from"./index-CN7eSKO4.js";import{r as o}from"./cost-CpjVoAqp.js";import{i as s,t as c}from"./services.generated-AsEvHbJ7.js";var l=e(r()),u=e(n());function d(){var e=[...arguments];return(0,u.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var f=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function p(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function m(e){return`nodeType`in e}function h(e){return e?p(e)?e:m(e)?e.ownerDocument?.defaultView??window:window:window}function g(e){let{Document:t}=h(e);return e instanceof t}function _(e){return p(e)?!1:e instanceof h(e).HTMLElement}function v(e){return e instanceof h(e).SVGElement}function y(e){return e?p(e)?e.document:m(e)?g(e)?e:_(e)||v(e)?e.ownerDocument:document:document:document}var b=f?u.useLayoutEffect:u.useEffect;function x(e){let t=(0,u.useRef)(e);return b(()=>{t.current=e}),(0,u.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function S(){let e=(0,u.useRef)(null);return[(0,u.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,u.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function C(e,t){let n=(0,u.useRef)();return(0,u.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function w(e){let t=x(e),n=(0,u.useRef)(null);return[n,(0,u.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}var T={};function ee(e,t){return(0,u.useMemo)(()=>{if(t)return t;let n=T[e]==null?0:T[e]+1;return T[e]=n,e+`-`+n},[e,t])}function E(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var D=E(1),te=E(-1);function O(e){return`clientX`in e&&`clientY`in e}function k(e){if(!e)return!1;let{KeyboardEvent:t}=h(e.target);return t&&e instanceof t}function ne(e){if(!e)return!1;let{TouchEvent:t}=h(e.target);return t&&e instanceof t}function re(e){if(ne(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return O(e)?{x:e.clientX,y:e.clientY}:null}var A=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[A.Translate.toString(e),A.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),j={display:`none`};function ie(e){let{id:t,value:n}=e;return u.createElement(`div`,{id:t,style:j},n)}function M(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return u.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function ae(){let[e,t]=(0,u.useState)(``);return{announce:(0,u.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var oe={draggable:`
|
|
2
|
-
To pick up a draggable item, press the space bar.
|
|
3
|
-
While dragging, use the arrow keys to move the item.
|
|
4
|
-
Press space again to drop the item in its new position, or press escape to cancel.
|
|
5
|
-
`},N={onDragStart(e){return`Picked up draggable item ${e}.`},onDragOver(e,t){return t?`Draggable item ${e} was moved over droppable area ${t}.`:`Draggable item ${e} is no longer over a droppable area.`},onDragEnd(e,t){return t?`Draggable item ${e} was dropped over droppable area ${t}`:`Draggable item ${e} was dropped.`},onDragCancel(e){return`Dragging was cancelled. Draggable item ${e} was dropped.`}},P;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(P||={});function F(...e){}var I=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(({disabled:e})=>!e)}getNodeFor(e){return this.get(e)?.node.current??void 0}},se=(0,u.createContext)({activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,activeNodeClientRect:null,activators:[],ariaDescribedById:{draggable:``},containerNodeRect:null,dispatch:F,draggableNodes:{},droppableRects:new Map,droppableContainers:new I,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:F},scrollableAncestors:[],scrollableAncestorRects:[],recomputeLayouts:F,windowRect:null,willRecomputeLayouts:!1});function ce(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:{},translate:{x:0,y:0}},droppable:{containers:new I}}}function le(e,t){switch(t.type){case P.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case P.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case P.DragEnd:case P.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case P.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new I(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case P.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new I(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case P.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new I(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}var ue=(0,u.createContext)({type:null,event:null});function L({onDragStart:e,onDragMove:t,onDragOver:n,onDragEnd:r,onDragCancel:i}){let a=(0,u.useContext)(ue),o=(0,u.useRef)(a);(0,u.useEffect)(()=>{if(a!==o.current){let{type:s,event:c}=a;switch(s){case P.DragStart:e?.(c);break;case P.DragMove:t?.(c);break;case P.DragOver:n?.(c);break;case P.DragCancel:i?.(c);break;case P.DragEnd:r?.(c);break}o.current=a}},[a,e,t,n,r,i])}function de({announcements:e=N,hiddenTextDescribedById:t,screenReaderInstructions:n}){let{announce:r,announcement:i}=ae(),a=ee(`DndLiveRegion`),[o,s]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{s(!0)},[]),L((0,u.useMemo)(()=>({onDragStart({active:t}){r(e.onDragStart(t.id))},onDragMove({active:t,over:n}){e.onDragMove&&r(e.onDragMove(t.id,n?.id))},onDragOver({active:t,over:n}){r(e.onDragOver(t.id,n?.id))},onDragEnd({active:t,over:n}){r(e.onDragEnd(t.id,n?.id))},onDragCancel({active:t}){r(e.onDragCancel(t.id))}}),[r,e])),o?(0,l.createPortal)(u.createElement(u.Fragment,null,u.createElement(ie,{id:t,value:n.draggable}),u.createElement(M,{id:a,announcement:i})),document.body):null}var R=Object.freeze({x:0,y:0});function fe(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function z(e,t=e.offsetLeft,n=e.offsetTop){return{x:t+e.width*.5,y:n+e.height*.5}}var pe=({collisionRect:e,droppableContainers:t})=>{let n=z(e,e.left,e.top),r=1/0,i=null;for(let e of t){let{rect:{current:t}}=e;if(t){let a=fe(z(t),n);a<r&&(r=a,i=e.id)}}return i};function me(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function he(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:R}function B(e){return function(t,...n){return n.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x,offsetLeft:t.offsetLeft+e*n.x,offsetTop:t.offsetTop+e*n.y}),{...t})}}var ge=B(1);function _e(e,t=window.getComputedStyle(e)){return t.position===`fixed`}function ve(e,t=window.getComputedStyle(e)){let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].find(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})!=null}function ye(e){let t=[];function n(e){if(!e)return t;if(g(e)&&e.scrollingElement!=null&&!t.includes(e.scrollingElement))return t.push(e.scrollingElement),t;if(!_(e)||v(e)||t.includes(e))return t;let r=window.getComputedStyle(e);return ve(e,r)&&t.push(e),_e(e,r)?t:n(e.parentNode)}return e?n(e.parentNode):t}function V(e){return!f||!e?null:p(e)?e:m(e)?g(e)||e===y(e).scrollingElement?window:_(e)?e:null:null}function H(e){return p(e)?{x:e.scrollX,y:e.scrollY}:{x:e.scrollLeft,y:e.scrollTop}}var U;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(U||={});function W(e){let t={x:0,y:0},n={x:e.scrollWidth-e.clientWidth,y:e.scrollHeight-e.clientHeight};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=n.y,isRight:e.scrollLeft>=n.x,maxScroll:n,minScroll:t}}function be(e){return!f||!e?!1:e===document.scrollingElement}var xe={x:.2,y:.2};function Se(e,t,{top:n,left:r,right:i,bottom:a},o=10,s=xe){let{clientHeight:c,clientWidth:l}=e,u=be(e)?{top:0,left:0,right:l,bottom:c,width:l,height:c}:t,{isTop:d,isBottom:f,isLeft:p,isRight:m}=W(e),h={x:0,y:0},g={x:0,y:0},_={height:u.height*s.y,width:u.width*s.x};return!d&&n<=u.top+_.height?(h.y=U.Backward,g.y=o*Math.abs((u.top+_.height-n)/_.height)):!f&&a>=u.bottom-_.height&&(h.y=U.Forward,g.y=o*Math.abs((u.bottom-_.height-a)/_.height)),!m&&i>=u.right-_.width?(h.x=U.Forward,g.x=o*Math.abs((u.right-_.width-i)/_.width)):!p&&r<=u.left+_.width&&(h.x=U.Backward,g.x=o*Math.abs((u.left+_.width-r)/_.width)),{direction:h,speed:g}}function Ce(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function G(e){return e.reduce((e,t)=>D(e,H(t)),R)}function K(e,t,n=R){if(!e||!_(e))return n;let r={x:n.x+e.offsetLeft,y:n.y+e.offsetTop};return e.offsetParent===t?r:K(e.offsetParent,t,r)}function q(e){let{offsetWidth:t,offsetHeight:n}=e,{x:r,y:i}=K(e,null);return{width:t,height:n,offsetTop:i,offsetLeft:r}}function J(e){if(p(e)){let e=window.innerWidth,t=window.innerHeight;return{top:0,left:0,right:e,bottom:t,width:e,height:t,offsetTop:0,offsetLeft:0}}let{offsetTop:t,offsetLeft:n}=q(e),{width:r,height:i,top:a,bottom:o,left:s,right:c}=e.getBoundingClientRect();return{width:r,height:i,top:a,bottom:o,right:c,left:s,offsetTop:t,offsetLeft:n}}function we(e){let{width:t,height:n,offsetTop:r,offsetLeft:i}=q(e),a=G(ye(e)),o=r-a.y,s=i-a.x;return{width:t,height:n,top:o,bottom:o+n,right:s+t,left:s,offsetTop:r,offsetLeft:i}}function Y(e,t){let n=Math.max(t.top,e.offsetTop),r=Math.max(t.left,e.offsetLeft),i=Math.min(t.left+t.width,e.offsetLeft+e.width),a=Math.min(t.top+t.height,e.offsetTop+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var Te=({collisionRect:e,droppableContainers:t})=>{let n=0,r=null;for(let i of t){let{rect:{current:t}}=i;if(t){let a=Y(t,e);a>n&&(n=a,r=i.id)}}return r},X;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(X||={});var Ee;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Ee||={});function De({acceleration:e,activator:t=X.Pointer,canScroll:n,draggingRect:r,enabled:i,interval:a=5,order:o=Ee.TreeOrder,pointerCoordinates:s,scrollableAncestors:c,scrollableAncestorRects:l,threshold:d}){let[f,p]=S(),m=(0,u.useRef)({x:1,y:1}),h=(0,u.useMemo)(()=>{switch(t){case X.Pointer:return s?{top:s.y,bottom:s.y,left:s.x,right:s.x}:null;case X.DraggableRect:return r}return null},[t,r,s]),g=(0,u.useRef)(R),_=(0,u.useRef)(null),v=(0,u.useCallback)(()=>{let e=_.current;if(!e)return;let t=m.current.x*g.current.x,n=m.current.y*g.current.y;e.scrollBy(t,n)},[]),y=(0,u.useMemo)(()=>o===Ee.TreeOrder?[...c].reverse():c,[o,c]);(0,u.useEffect)(()=>{if(!i||!c.length||!h){p();return}for(let t of y){if(n?.(t)===!1)continue;let r=l[c.indexOf(t)];if(!r)continue;let{direction:i,speed:o}=Se(t,r,h,e,d);if(o.x>0||o.y>0){p(),_.current=t,f(v,a),m.current=o,g.current=i;return}}m.current={x:0,y:0},g.current={x:0,y:0},p()},[e,v,n,p,i,a,JSON.stringify(h),f,c,y,l,JSON.stringify(d)])}function Oe(e,t){let n=t===null?void 0:e[t],r=n?n.node.current:null;return C(e=>t===null?null:r??e??null,[r,t])}function ke(e,t){return(0,u.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}function Ae(e){let t=(0,u.useRef)(e);return b(()=>{t.current!==e&&(t.current=e)},[e]),t}var je;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(je||={});var Me;(function(e){e.Optimized=`optimized`})(Me||={});var Ne=new Map,Pe={measure:q,strategy:je.WhileDragging,frequency:Me.Optimized};function Fe(e,{dragging:t,dependencies:n,config:r}){let[i,a]=(0,u.useState)(!1),{frequency:o,measure:s,strategy:c}={...Pe,...r},l=(0,u.useRef)(e),d=(0,u.useCallback)(()=>a(!0),[]),f=(0,u.useRef)(null),p=h(),m=C(n=>{if(p&&!t)return Ne;if(!n||n===Ne||l.current!==e||i){for(let t of e)t&&(t.rect.current=t.node.current?s(t.node.current):null);return Ie(e)}return n},[e,t,p,s,i]);return(0,u.useEffect)(()=>{l.current=e},[e]),(0,u.useEffect)(()=>{i&&a(!1)},[i]),(0,u.useEffect)(function(){p||requestAnimationFrame(d)},[t,p]),(0,u.useEffect)(function(){p||typeof o!=`number`||f.current!==null||(f.current=setTimeout(()=>{d(),f.current=null},o))},[o,p,d,...n]),{layoutRectMap:m,recomputeLayouts:d,willRecomputeLayouts:i};function h(){switch(c){case je.Always:return!1;case je.BeforeDragging:return t;default:return!t}}}function Ie(e){let t=new Map;if(e)for(let n of e){if(!n)continue;let{id:e,rect:r}=n;r.current!=null&&t.set(e,r.current)}return t}function Le(e){let[t,n]=(0,u.useState)(null),r=(0,u.useRef)(e),i=(0,u.useCallback)(e=>{let t=V(e.target);t&&n(e=>e?(e.set(t,H(t)),new Map(e)):null)},[]);return(0,u.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=V(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,H(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{V(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,u.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>D(e,t),R):G(e):R,[e,t])}var Re=[];function ze(e){let t=(0,u.useRef)(e),n=C(n=>e?n&&e&&t.current&&e.parentNode===t.current.parentNode?n:ye(e):Re,[e]);return(0,u.useEffect)(()=>{t.current=e},[e]),n}function Be(e){(0,u.useEffect)(()=>{if(!f)return;let t=e.map(({sensor:e})=>e.setup==null?void 0:e.setup());return()=>{for(let e of t)e?.()}},e.map(({sensor:e})=>e))}function Ve(e,t){return(0,u.useMemo)(()=>e.reduce((e,{eventName:n,handler:r})=>(e[n]=e=>{r(e,t)},e),{}),[e,t])}var He=Ge(J),Ue=Ke(J);function We(e,t,n){let r=(0,u.useRef)(e);return C(i=>e?n||!i&&e||e!==r.current?_(e)&&e.parentNode==null?null:t(e):i??null:null,[e,n,t])}function Ge(e){return(t,n)=>We(t,e,n)}function Ke(e){let t=[];return function(n,r){let i=(0,u.useRef)(n);return C(a=>n.length?r||!a&&n.length||n!==i.current?n.map(t=>e(t)):a??t:t,[n,r])}}function qe(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return _(t)?t:e}function Je(e){let{width:t,height:n,offsetLeft:r,offsetTop:i}=q(e);return{top:i,bottom:i+n,left:r,right:r+t,width:t,height:n,offsetTop:i,offsetLeft:r}}var Ye=Ge(Je);function Xe({disabled:e,forceRecompute:t}){let[n,r]=w(),i=Ye(e?null:qe(n.current),t);return(0,u.useMemo)(()=>({nodeRef:n,rect:i,setRef:r}),[i,n,r])}function Ze(e,t){return(0,u.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Qe(...e){return(0,u.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var $e=class{constructor(e){this.target=e,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))}}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function et(e){let{EventTarget:t}=h(e);return e instanceof t?e:y(e)}function tt(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Z;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Z||={});function nt(e){e.preventDefault()}function rt(e){e.stopPropagation()}var Q;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`})(Q||={});var it={start:[Q.Space,Q.Enter],cancel:[Q.Esc],end:[Q.Space,Q.Enter]},at=(e,{currentCoordinates:t})=>{switch(e.code){case Q.Right:return{...t,x:t.x+25};case Q.Left:return{...t,x:t.x-25};case Q.Down:return{...t,y:t.y+25};case Q.Up:return{...t,y:t.y-25}}},ot=class{constructor(e){this.props=e,this.autoScrollEnabled=!1,this.coordinates=R;let{event:{target:t}}=e;this.props=e,this.listeners=new $e(y(t)),this.windowListeners=new $e(h(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Z.Resize,this.handleCancel),this.windowListeners.add(Z.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Z.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props;if(!e.node.current)throw Error(`Active draggable node is undefined`);let n=J(e.node.current),r={x:n.left,y:n.top};this.coordinates=r,t(r)}handleKeyDown(e){if(k(e)){let{coordinates:t}=this,{active:n,context:r,options:i}=this.props,{keyboardCodes:a=it,coordinateGetter:o=at,scrollBehavior:s=`smooth`}=i,{code:c}=e;if(a.end.includes(c)){this.handleEnd(e);return}if(a.cancel.includes(c)){this.handleCancel(e);return}let l=o(e,{active:n,context:r.current,currentCoordinates:t});if(l){let n={x:0,y:0},{scrollableAncestors:i}=r.current;for(let r of i){let i=e.code,a=te(l,t),{isTop:o,isRight:c,isLeft:u,isBottom:d,maxScroll:f,minScroll:p}=W(r),m=Ce(r),h={x:Math.min(i===Q.Right?m.right-m.width/2:m.right,Math.max(i===Q.Right?m.left:m.left+m.width/2,l.x)),y:Math.min(i===Q.Down?m.bottom-m.height/2:m.bottom,Math.max(i===Q.Down?m.top:m.top+m.height/2,l.y))},g=i===Q.Right&&!c||i===Q.Left&&!u,_=i===Q.Down&&!d||i===Q.Up&&!o;if(g&&h.x!==l.x){if(i===Q.Right&&r.scrollLeft+a.x<=f.x||i===Q.Left&&r.scrollLeft+a.x>=p.x){r.scrollBy({left:a.x,behavior:s});return}n.x=i===Q.Right?r.scrollLeft-f.x:r.scrollLeft-p.x,r.scrollBy({left:-n.x,behavior:s});break}else if(_&&h.y!==l.y){if(i===Q.Down&&r.scrollTop+a.y<=f.y||i===Q.Up&&r.scrollTop+a.y>=p.y){r.scrollBy({top:a.y,behavior:s});return}n.y=i===Q.Down?r.scrollTop-f.y:r.scrollTop-p.y,r.scrollBy({top:-n.y,behavior:s});break}}this.handleMove(e,D(l,n))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t),this.coordinates=t}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};ot.activators=[{eventName:`onKeyDown`,handler:(e,{keyboardCodes:t=it,onActivation:n})=>{let{code:r}=e.nativeEvent;return t.start.includes(r)?(e.preventDefault(),n?.({event:e.nativeEvent}),!0):!1}}];function st(e){return!!(e&&`distance`in e)}function ct(e){return!!(e&&`delay`in e)}var lt=class{constructor(e,t,n=et(e.event.target)){this.props=e,this.events=t,this.autoScrollEnabled=!0,this.activated=!1,this.timeoutId=null;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=y(i),this.documentListeners=new $e(this.document),this.listeners=new $e(n),this.windowListeners=new $e(h(i)),this.initialCoordinates=re(r),this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(Z.Resize,this.handleCancel),this.windowListeners.add(Z.DragStart,nt),this.windowListeners.add(Z.VisibilityChange,this.handleCancel),this.windowListeners.add(Z.ContextMenu,nt),this.documentListeners.add(Z.Keydown,this.handleKeydown),t){if(st(t))return;if(ct(t)){this.timeoutId=setTimeout(this.handleStart,t.delay);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Z.Click,rt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Z.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=re(e),s=te(n,o);if(!t&&a){if(ct(a))return tt(s,a.tolerance)?this.handleCancel():void 0;if(st(a))return a.tolerance!=null&&tt(s,a.tolerance)?this.handleCancel():tt(s,a.distance)?this.handleStart():void 0}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onEnd:e}=this.props;this.detach(),e()}handleCancel(){let{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===Q.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},ut={move:{name:`pointermove`},end:{name:`pointerup`}},dt=class extends lt{constructor(e){let{event:t}=e,n=y(t.target);super(e,ut,n)}};dt.activators=[{eventName:`onPointerDown`,handler:({nativeEvent:e},{onActivation:t})=>!e.isPrimary||e.button!==0?!1:(t?.({event:e}),!0)}];var ft={move:{name:`mousemove`},end:{name:`mouseup`}},pt;(function(e){e[e.RightClick=2]=`RightClick`})(pt||={});var mt=class extends lt{constructor(e){super(e,ft,y(e.event.target))}};mt.activators=[{eventName:`onMouseDown`,handler:({nativeEvent:e},{onActivation:t})=>e.button===pt.RightClick?!1:(t?.({event:e}),!0)}];var ht={move:{name:`touchmove`},end:{name:`touchend`}},gt=class extends lt{constructor(e){super(e,ht)}static setup(){return window.addEventListener(ht.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(ht.move.name,e)};function e(){}}};gt.activators=[{eventName:`onTouchStart`,handler:({nativeEvent:e},{onActivation:t})=>{let{touches:n}=e;return n.length>1?!1:(t?.({event:e}),!0)}}];function _t(e,{transform:t,...n}){return e?.length?e.reduce((e,t)=>t({transform:e,...n}),t):t}var vt=[{sensor:dt,options:{}},{sensor:ot,options:{}}],yt={current:{}},bt=(0,u.createContext)({...R,scaleX:1,scaleY:1}),xt=(0,u.memo)(function({id:e,autoScroll:t=!0,announcements:n,children:r,sensors:i=vt,collisionDetection:a=Te,measuring:o,modifiers:s,screenReaderInstructions:c=oe,...d}){let[f,p]=(0,u.useReducer)(le,void 0,ce),[m,h]=(0,u.useState)(()=>({type:null,event:null})),[g,_]=(0,u.useState)(!1),{draggable:{active:v,nodes:y,translate:x},droppable:{containers:S}}=f,C=v?y[v]:null,w=(0,u.useRef)({initial:null,translated:null}),T=(0,u.useMemo)(()=>v==null?null:{id:v,data:C?.data??yt,rect:w},[v,C]),E=(0,u.useRef)(null),[te,O]=(0,u.useState)(null),[k,ne]=(0,u.useState)(null),A=(0,u.useRef)(d),j=ee(`DndDescribedBy`,e),ie=(0,u.useMemo)(()=>S.getEnabled(),[S]),{layoutRectMap:M,recomputeLayouts:ae,willRecomputeLayouts:N}=Fe(ie,{dragging:g,dependencies:[x.x,x.y],config:o?.droppable}),F=Oe(y,v),I=k?re(k):null,L=We(F,o?.draggable?.measure??we),fe=He(F),z=(0,u.useRef)(null),pe=z.current,B=(0,u.useRef)({active:null,activeNode:F,collisionRect:null,droppableRects:M,draggableNodes:y,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null,translatedRect:null}),_e=S.getNodeFor(B.current.over?.id),ve=He(F?F.ownerDocument.defaultView:null),ye=He(F?F.parentElement:null),V=ze(v?_e??F:null),H=Ue(V),U=Xe({disabled:v==null,forceRecompute:N}),W=U.rect??L,be=W===L?he(L,pe):R,xe=_t(s,{transform:{x:x.x-be.x,y:x.y-be.y,scaleX:1,scaleY:1},activatorEvent:k,active:T,activeNodeRect:fe,containerNodeRect:ye,draggingNodeRect:W,over:B.current.over,overlayNodeRect:U.rect,scrollableAncestors:V,scrollableAncestorRects:H,windowRect:ve}),Se=I?D(I,x):null,Ce=Le(V),G=D(xe,Ce),K=W?ge(W,xe):null,q=K?ge(K,Ce):null,J=T&&q?a({active:T,collisionRect:q,droppableContainers:ie}):null,[Y,X]=(0,u.useState)(null),Ee=me(xe,Y?.rect??null,L),Ae=(0,u.useCallback)((e,{sensor:t,options:n})=>{if(!E.current)return;let r=y[E.current];if(!r)return;let i=new t({active:E.current,activeNode:r,event:e.nativeEvent,options:n,context:B,onStart(e){let t=E.current;if(!t)return;let n=y[t];if(!n)return;let{onDragStart:r}=A.current,i={active:{id:t,data:n.data,rect:w}};(0,l.unstable_batchedUpdates)(()=>{p({type:P.DragStart,initialCoordinates:e,active:t}),h({type:P.DragStart,event:i})}),r?.(i)},onMove(e){p({type:P.DragMove,coordinates:e})},onEnd:a(P.DragEnd),onCancel:a(P.DragCancel)});(0,l.unstable_batchedUpdates)(()=>{O(i),ne(e.nativeEvent)});function a(e){return async function(){let{active:t,over:n,scrollAdjustedTranslate:r}=B.current,i=null;if(t&&r){let{cancelDrop:a}=A.current;i={active:t,delta:r,over:n},e===P.DragEnd&&typeof a==`function`&&await Promise.resolve(a(i))&&(e=P.DragCancel)}if(E.current=null,(0,l.unstable_batchedUpdates)(()=>{p({type:e}),X(null),_(!1),O(null),ne(null),i&&h({type:e,event:i})}),i){let{onDragCancel:t,onDragEnd:n}=A.current;(e===P.DragEnd?n:t)?.(i)}}}},[p,y]),je=ke(i,(0,u.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent;E.current!==null||i.dndKit||i.defaultPrevented||e(n,t.options)===!0&&(i.dndKit={capturedBy:t.sensor},E.current=r,Ae(n,t))},[Ae]));Be(i),b(()=>{A.current=d},Object.values(d)),(0,u.useEffect)(()=>{v!=null&&_(!0)},[v]),(0,u.useEffect)(()=>{T||(z.current=null),T&&L&&!z.current&&(z.current=L)},[L,T]),(0,u.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,over:n}=B.current;if(!t)return;let r={active:t,delta:{x:G.x,y:G.y},over:n};h({type:P.DragMove,event:r}),e?.(r)},[G.x,G.y]),(0,u.useEffect)(()=>{let{active:e,droppableContainers:t,scrollAdjustedTranslate:n}=B.current;if(!e||!E.current||!n)return;let{onDragOver:r}=A.current,i=t.get(J),a=i&&i.rect.current?{id:i.id,rect:i.rect.current,data:i.data,disabled:i.disabled}:null,o={active:e,delta:{x:n.x,y:n.y},over:a};(0,l.unstable_batchedUpdates)(()=>{X(a),h({type:P.DragOver,event:o}),r?.(o)})},[J]),b(()=>{B.current={active:T,activeNode:F,collisionRect:q,droppableRects:M,draggableNodes:y,draggingNodeRect:W,droppableContainers:S,over:Y,scrollableAncestors:V,scrollAdjustedTranslate:G,translatedRect:K},w.current={initial:W,translated:K}},[T,F,q,y,W,M,S,Y,V,G,K]),De({...Ne(),draggingRect:K,pointerCoordinates:Se,scrollableAncestors:V,scrollableAncestorRects:H});let Me=(0,u.useMemo)(()=>({active:T,activeNode:F,activeNodeRect:L,activeNodeClientRect:fe,activatorEvent:k,activators:je,ariaDescribedById:{draggable:j},containerNodeRect:ye,dispatch:p,dragOverlay:U,draggableNodes:y,droppableContainers:S,droppableRects:M,over:Y,recomputeLayouts:ae,scrollableAncestors:V,scrollableAncestorRects:H,willRecomputeLayouts:N,windowRect:ve}),[T,F,fe,L,k,je,ye,U,p,y,j,S,M,Y,ae,V,H,N,ve]);return u.createElement(ue.Provider,{value:m},u.createElement(se.Provider,{value:Me},u.createElement(bt.Provider,{value:Ee},r)),u.createElement(de,{announcements:n,hiddenTextDescribedById:j,screenReaderInstructions:c}));function Ne(){let e=te?.autoScrollEnabled===!1,n=typeof t==`object`?t.enabled===!1:t===!1,r=!e&&!n;return typeof t==`object`?{...t,enabled:r}:{enabled:r}}}),St=(0,u.createContext)(null),Ct=`button`,wt=`Droppable`;function Tt({id:e,data:t,disabled:n=!1,attributes:r}){let i=ee(wt),{active:a,activeNodeRect:o,activatorEvent:s,ariaDescribedById:c,draggableNodes:l,droppableRects:d,activators:f,over:p}=(0,u.useContext)(se),{role:m=Ct,roleDescription:h=`draggable`,tabIndex:g=0}=r??{},_=a?.id===e,v=(0,u.useContext)(_?bt:St),[y,b]=w(),x=Ve(f,e),S=Ae(t);return(0,u.useEffect)(()=>(l[e]={id:e,key:i,node:y,data:S},()=>{let t=l[e];t&&t.key===i&&delete l[e]}),[l,e]),{active:a,activeNodeRect:o,activatorEvent:s,attributes:(0,u.useMemo)(()=>({role:m,tabIndex:g,"aria-pressed":_&&m===Ct?!0:void 0,"aria-roledescription":h,"aria-describedby":c.draggable}),[m,g,_,h,c.draggable]),droppableRects:d,isDragging:_,listeners:n?void 0:x,node:y,over:p,setNodeRef:b,transform:v}}function Et(){return(0,u.useContext)(se)}var Dt=`Droppable`;function Ot({data:e,disabled:t=!1,id:n}){let r=ee(Dt),{active:i,dispatch:a,over:o}=(0,u.useContext)(se),s=(0,u.useRef)(null),[c,l]=w(),d=Ae(e);return b(()=>(a({type:P.RegisterDroppable,element:{id:n,key:r,disabled:t,node:c,rect:s,data:d}}),()=>a({type:P.UnregisterDroppable,key:r,id:n})),[n]),(0,u.useEffect)(()=>{a({type:P.SetDroppableDisabled,id:n,key:r,disabled:t})},[t]),{active:i,rect:s,isOver:o?.id===n,node:c,over:o,setNodeRef:l}}function kt(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function At(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function jt(e){return e!==null&&e>=0}var Mt=({layoutRects:e,activeIndex:t,overIndex:n,index:r})=>{let i=kt(e,n,t),a=e[r],o=i[r];return!o||!a?null:{x:o.offsetLeft-a.offsetLeft,y:o.offsetTop-a.offsetTop,scaleX:o.width/a.width,scaleY:o.height/a.height}},Nt=`Sortable`,Pt=u.createContext({activeIndex:-1,containerId:Nt,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Mt,wasDragging:{current:!1}});function Ft({children:e,id:t,items:n,strategy:r=Mt}){let{active:i,dragOverlay:a,droppableRects:o,over:s,recomputeLayouts:c,willRecomputeLayouts:l}=Et(),d=ee(Nt,t),f=a.rect!==null,p=(0,u.useMemo)(()=>n.map(e=>typeof e==`string`?e:e.id),[n]),m=i!=null,h=(0,u.useRef)(!1),g=i?p.indexOf(i.id):-1,_=g!==-1,v=s?p.indexOf(s.id):-1,y=(0,u.useRef)(p),x=At(p,o),S=!It(p,y.current),C=v!==-1&&g===-1||S;b(()=>{S&&_&&!l&&c()},[S,_,c,l]),(0,u.useEffect)(()=>{y.current=p},[p]),(0,u.useEffect)(()=>{let e=setTimeout(()=>{h.current=m},100);return()=>clearTimeout(e)},[m]);let w=(0,u.useMemo)(()=>({activeIndex:g,containerId:d,disableTransforms:C,items:p,overIndex:v,useDragOverlay:f,sortedRects:x,strategy:r,wasDragging:h}),[g,d,C,p,v,x,f,r,h]);return u.createElement(Pt.Provider,{value:w},e)}function It(e,t){return e.join()===t.join()}var Lt=({id:e,items:t,activeIndex:n,overIndex:r})=>kt(t,n,r).indexOf(e),Rt=({containerId:e,isSorting:t,wasDragging:n,index:r,items:i,newIndex:a,previousItems:o,previousContainerId:s,transition:c})=>!c||!n||o!==i&&r===a?!1:t?!0:a!==r&&e===s,zt={duration:200,easing:`ease`},Bt=`transform`,Vt=A.Transition.toString({property:Bt,duration:0,easing:`linear`}),Ht={roleDescription:`sortable`};function Ut({disabled:e,index:t,node:n,rect:r}){let[i,a]=(0,u.useState)(null),o=(0,u.useRef)(t);return b(()=>{if(!e&&t!==o.current&&n.current){let e=r.current;if(e){let t=J(n.current),r={x:e.offsetLeft-t.offsetLeft,y:e.offsetTop-t.offsetTop,scaleX:e.width/t.width,scaleY:e.height/t.height};(r.x||r.y)&&a(r)}}t!==o.current&&(o.current=t)},[e,t,n,r]),(0,u.useEffect)(()=>{i&&requestAnimationFrame(()=>{a(null)})},[i]),i}function Wt({animateLayoutChanges:e=Rt,attributes:t,disabled:n,data:r,getNewIndex:i=Lt,id:a,strategy:o,transition:s=zt}){let{items:c,containerId:l,activeIndex:f,disableTransforms:p,sortedRects:m,overIndex:h,useDragOverlay:g,strategy:_,wasDragging:v}=(0,u.useContext)(Pt),y=c.indexOf(a),b=(0,u.useMemo)(()=>({sortable:{containerId:l,index:y,items:c},...r}),[l,r,y,c]),{rect:x,node:S,setNodeRef:C}=Ot({id:a,data:b}),{active:w,activeNodeRect:T,activatorEvent:ee,attributes:E,setNodeRef:D,listeners:te,isDragging:O,over:k,transform:ne}=Tt({id:a,data:b,attributes:{...Ht,...t},disabled:n}),re=d(C,D),j=!!w,ie=j&&v.current&&!p&&jt(f)&&jt(h),M=!g&&O,ae=ie?(M&&ie?ne:null)??(o??_)({layoutRects:m,activeNodeRect:T,activeIndex:f,overIndex:h,index:y}):null,oe=jt(f)&&jt(h)?i({id:a,items:c,activeIndex:f,overIndex:h}):y,N=(0,u.useRef)(c),P=c!==N.current,F=(0,u.useRef)(oe),I=(0,u.useRef)(l),se=e({active:w,containerId:l,isDragging:O,isSorting:j,id:a,index:y,items:c,newIndex:F.current,previousItems:N.current,previousContainerId:I.current,transition:s,wasDragging:v.current}),ce=Ut({disabled:!se,index:y,node:S,rect:x});return(0,u.useEffect)(()=>{j&&F.current!==oe&&(F.current=oe),l!==I.current&&(I.current=l),c!==N.current&&(N.current=c)},[j,oe,l,c]),{active:w,attributes:E,activatorEvent:ee,rect:x,index:y,isSorting:j,isDragging:O,listeners:te,node:S,overIndex:h,over:k,setNodeRef:re,setDroppableNodeRef:C,setDraggableNodeRef:D,transform:ce??ae,transition:le()};function le(){if(ce||P&&F.current===y)return Vt;if(!(M||!s)&&(j||se))return A.Transition.toString({...s,property:Bt})}}Q.Down,Q.Right,Q.Up,Q.Left;var $=i(),Gt=e=>(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,$.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`m12 14l4-4M3.34 19a10 10 0 1 1 17.32 0`})}),Kt=e=>(0,$.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,$.jsxs)(`g`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,children:[(0,$.jsx)(`circle`,{cx:9,cy:12,r:1}),(0,$.jsx)(`circle`,{cx:9,cy:5,r:1}),(0,$.jsx)(`circle`,{cx:9,cy:19,r:1}),(0,$.jsx)(`circle`,{cx:15,cy:12,r:1}),(0,$.jsx)(`circle`,{cx:15,cy:5,r:1}),(0,$.jsx)(`circle`,{cx:15,cy:19,r:1})]})}),qt=new Set([`anthropic`,`openai`]);function Jt(e){let t=e.trim();if(t===``)return{ok:!0,value:null};if(!/^\d+$/.test(t))return{ok:!1,error:`정수만 입력하세요 (0–100)`};let n=Number(t);return n>100?{ok:!1,error:`100 이하여야 합니다`}:{ok:!0,value:n===0?null:n}}var Yt={openai:{stripe:`bg-openai-400`,bar:`bg-openai-bar`,badge:`bg-openai-50 text-openai-600`,cost:`text-openai-600`},anthropic:{stripe:`bg-anthropic-400`,bar:`bg-anthropic-400`,badge:`bg-anthropic-50 text-anthropic-600`,cost:`text-anthropic-600`},google:{stripe:`bg-google-400`,bar:`bg-google-400`,badge:`bg-google-50 text-google-600`,cost:`text-google-600`}},Xt={stripe:`bg-sand-400`,bar:`bg-sienna-400`,badge:`bg-sand-200 text-sand-500`,cost:`text-sienna-600`};function Zt(e){return Yt[e]??Xt}function Qt(e,t){return e>=95?`bg-danger-400`:e>=80?`bg-caution-400`:t.bar}function $t(e){if(!e)return``;let t=new Date(e).getTime()-Date.now();if(t<=0)return`resetting...`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`resets ${n}h ${r}m`:`resets ${r}m`}function en({label:e,utilization:t,resetsAt:n,theme:r,threshold:i}){let a=t??0,o=i!=null;return(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-xs text-sand-600 w-20 shrink-0`,children:e}),(0,$.jsxs)(`div`,{className:`relative flex-1 h-2 bg-sand-200 rounded-full overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-300 ${Qt(a,r)}`,style:{width:`${Math.min(a,100)}%`}}),o&&(0,$.jsx)(`div`,{className:`absolute top-[-2px] bottom-[-2px] w-0.5 bg-sienna-500 rounded-full`,style:{left:`calc(${Math.min(i,100)}% - 1px)`}})]}),(0,$.jsxs)(`span`,{className:`text-xs tabular-nums text-sand-700 w-10 text-right`,children:[a,`%`]}),(0,$.jsx)(`span`,{className:`text-[10px] text-sand-400 w-24 text-right`,children:$t(n)})]})}function tn({token:e,theme:t}){let{data:n,isLoading:r}=c.useUsage(e.id);if(r)return(0,$.jsxs)(`div`,{className:`animate-pulse space-y-2 py-2`,children:[(0,$.jsx)(`div`,{className:`h-2 w-full bg-sand-200 rounded-full`}),(0,$.jsx)(`div`,{className:`h-2 w-3/4 bg-sand-200 rounded-full`})]});if(n?.error){let e=n.error.includes(`re-login`)||n.error.includes(`token_revoked`)||n.error.includes(`401`);return(0,$.jsxs)(`div`,{className:`py-1`,children:[(0,$.jsx)(`p`,{className:`text-[11px] text-amber-600`,children:e?`Session expired`:`Unavailable`}),(0,$.jsx)(`p`,{className:`text-[10px] text-sand-400 mt-0.5`,children:e?`Please re-login via OAuth`:n.error})]})}if(!n?.fiveHour&&!n?.sevenDay)return(0,$.jsx)(`p`,{className:`text-[11px] text-sand-400 py-1`,children:`No usage data`});let i=qt.has(e.provider)?e.quota_threshold:null;return(0,$.jsxs)(`div`,{className:`space-y-1.5 py-1`,children:[n.fiveHour&&(0,$.jsx)(en,{label:`5h`,utilization:n.fiveHour.utilization,resetsAt:n.fiveHour.resetsAt,theme:t,threshold:i}),n.sevenDay&&(0,$.jsx)(en,{label:`7d`,utilization:n.sevenDay.utilization,resetsAt:n.sevenDay.resetsAt,theme:t})]})}function nn(e){e.stopPropagation()}function rn({token:e}){let[n,r]=(0,u.useState)(null),[i,o]=(0,u.useState)(``),s=(0,u.useRef)(null),l=t(),d=c.useUpdateTokenMutation(),f=qt.has(e.provider),p=n!==null,m=Jt(i),h=()=>{let t=s.current?.getBoundingClientRect();if(!t)return;let n=Math.min(Math.max(t.right-240,8),Math.max(window.innerWidth-240-8,8)),i=t.top-6-150,a=t.bottom+6;r({left:n,top:Math.min(Math.max(i>=8?i:a,8),Math.max(window.innerHeight-150-8,8))}),o(String(e.quota_threshold??100))},g=()=>r(null);if(!f)return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] text-sand-300 border border-sand-100`,title:`Quota threshold는 이 provider에서 지원되지 않습니다`,children:[(0,$.jsx)(Gt,{className:`size-3`}),`n/a`]});let _=e=>{let t=/^\d+$/.test(i.trim())?Number(i.trim()):0,n=Math.min(Math.max(t+e,0),100);o(String(n))};return(0,$.jsxs)(`div`,{className:`inline-flex`,onPointerDown:nn,onClick:nn,children:[(0,$.jsxs)(`button`,{ref:s,type:`button`,title:`사용률 제한 설정`,onClick:p?g:h,className:`flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[10px] border border-sand-200/80 text-sand-400 hover:text-sand-600 hover:border-sand-300 transition-colors duration-150`,children:[(0,$.jsx)(Gt,{className:`size-3`}),`Set limit`]}),p&&n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-40`,onPointerDown:g}),(0,$.jsxs)(`div`,{className:`fixed z-50 w-60 panel shadow-xl p-3`,style:{top:n.top,left:n.left},children:[(0,$.jsx)(`label`,{htmlFor:`threshold-${e.id}`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`사용률 제한`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>_(-10),className:`size-9 shrink-0 rounded-md border border-sand-200 text-sand-600 text-base leading-none hover:bg-sand-100 transition-colors duration-150`,children:`−`}),(0,$.jsx)(a,{id:`threshold-${e.id}`,value:i,onChange:e=>o(e.target.value),inputMode:`numeric`,className:`h-9 w-14 border rounded-md text-center text-sm text-sand-900 bg-white tabular-nums focus:outline-none ${m.ok?`border-sand-200 focus:border-sienna-300`:`border-red-300 focus:border-red-400`}`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>_(10),className:`size-9 shrink-0 rounded-md border border-sand-200 text-sand-600 text-base leading-none hover:bg-sand-100 transition-colors duration-150`,children:`+`}),(0,$.jsx)(`span`,{className:`text-sm text-sand-500`,children:`%`})]}),m.ok?(0,$.jsx)(`p`,{className:`mt-1.5 text-[11px] text-sand-500 leading-snug`,children:m.value===null?`제한 없음 — 사용률과 무관하게 항상 사용합니다.`:`5h 사용률이 임계치에 달하면 해당 토큰을 건너뜁니다.`}):(0,$.jsx)(`p`,{className:`mt-1.5 text-[11px] text-red-500`,children:m.error}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-end gap-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`px-2 py-1 text-[11px] font-medium rounded-md border border-sand-200 text-sand-600 hover:bg-sand-100 transition-colors duration-150`,onClick:g,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,className:`px-2 py-1 text-[11px] font-medium rounded-md bg-sienna-400 text-white hover:bg-sienna-500 disabled:opacity-50 transition-colors duration-150`,disabled:d.isPending||!m.ok,onClick:async()=>{m.ok&&(await d.mutateAsync({id:e.id,name:e.name??``,quotaThreshold:m.value}),await Promise.all([l.invalidateQueries({queryKey:[`Token`]}),l.invalidateQueries({queryKey:[`Qgrid`]})]),g())},children:d.isPending?`Saving...`:`Save`})]})]})]})]})}function an({token:e}){let{attributes:t,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:s}=Wt({id:String(e.id),transition:{duration:200,easing:`ease`}}),{data:l}=c.useTotalCost(e.name,{enabled:!!e.name}),u=Zt(e.provider);return(0,$.jsxs)(`div`,{ref:r,style:{transform:A.Translate.toString(i),transition:a,opacity:s?.5:1,zIndex:s?10:void 0},...t,...n,className:`relative rounded-lg bg-white border border-sand-200/80 overflow-hidden select-none cursor-grab active:cursor-grabbing touch-none shadow-sm hover:shadow-md transition-shadow duration-200`,children:[(0,$.jsx)(`div`,{className:`absolute inset-y-0 left-0 w-1 ${u.stripe}`}),(0,$.jsxs)(`div`,{className:`pl-4 pr-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(Kt,{className:`size-3.5 text-sand-300 shrink-0`}),(0,$.jsx)(`span`,{className:`text-[13px] font-medium text-sand-800 truncate`,children:e.name??`Unnamed`}),(0,$.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full shrink-0 uppercase ${u.badge}`,children:e.provider}),(0,$.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded-full shrink-0 ${e.active?`bg-sage-100 text-sage-600`:`bg-sand-200 text-sand-500`}`,children:e.active?`Active`:`Inactive`})]}),(0,$.jsx)(tn,{token:e,theme:u}),(0,$.jsx)(`div`,{className:`mt-2 flex items-center justify-end`,children:(0,$.jsx)(rn,{token:e})}),(0,$.jsxs)(`div`,{className:`absolute top-2.5 right-3 flex items-center gap-1.5`,children:[qt.has(e.provider)&&e.quota_threshold!==null&&(0,$.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded-md bg-sienna-50 text-[11px] tabular-nums font-medium border border-sienna-200 text-sienna-600`,title:`사용률 ${e.quota_threshold}% 이상이면 이 토큰 제외`,children:[`≤ `,e.quota_threshold,`%`]}),(0,$.jsx)(`span`,{className:`px-2 py-0.5 rounded-md bg-sand-50 text-[11px] tabular-nums font-medium border border-sand-200/80 ${u.cost}`,children:o(l?.usd??0)})]})]})]})}var on=[`all`,`openai`,`anthropic`];function sn(){let{data:e,isLoading:n}=s.useTokens(`A`,{orderBy:`ord-asc`}),r=t(),i=s.useReorderMutation(),[a,o]=(0,u.useState)([]),[c,l]=(0,u.useState)(`all`);(0,u.useEffect)(()=>{e?.rows&&o(e.rows)},[e?.rows]);let d=Qe(Ze(dt,{activationConstraint:{distance:5}})),f=t=>{let{active:n,over:c}=t;if(!c||n.id===c.id)return;let l=Number(n.id),u=Number(c.id),d=a.findIndex(e=>e.id===l),f=a.findIndex(e=>e.id===u);if(d===-1||f===-1)return;let p=kt(a,d,f);o(p);let m=s.getTokensQueryOptions(`A`,{orderBy:`ord-asc`}).queryKey,h=r.getQueryData(m);r.setQueryData(m,e=>e&&{...e,rows:p}),i.mutate({ids:p.map(e=>e.id)},{onError:()=>{r.setQueryData(m,h),e?.rows&&o(e.rows)},onSettled:()=>{Promise.all([r.invalidateQueries({queryKey:[`Token`]}),r.invalidateQueries({queryKey:[`Qgrid`]})])}})};if(n)return(0,$.jsx)(`div`,{className:`panel p-5`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-sand-50 px-4 py-3 animate-pulse`,children:[(0,$.jsx)(`div`,{className:`h-3 w-16 bg-sand-200 rounded mb-3`}),(0,$.jsx)(`div`,{className:`h-2 w-full bg-sand-200 rounded-full`})]},`skel-${t}`))})});if(a.length===0)return(0,$.jsx)(`div`,{className:`panel px-5 py-10`,children:(0,$.jsx)(`p`,{className:`text-sand-400 text-[13px] text-center`,children:`No tokens registered`})});let p=c===`all`?a:a.filter(e=>e.provider===c);return(0,$.jsxs)(`div`,{className:`panel overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`panel-header flex items-center justify-between px-5 py-2.5`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium text-sand-700`,children:`Token Usage`}),(0,$.jsx)(`div`,{className:`segmented-control flex gap-0.5`,children:on.map(e=>(0,$.jsx)(`button`,{type:`button`,"data-active":c===e,className:`px-2.5 py-[3px] text-[11px] font-medium rounded-[6px] transition-all duration-150 ${c===e?`text-sand-800`:`text-sand-500 hover:text-sand-700`}`,onClick:()=>l(e),children:e===`all`?`All`:e===`openai`?`OpenAI`:`Anthropic`},e))})]}),(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(xt,{sensors:d,collisionDetection:pe,onDragEnd:f,children:(0,$.jsx)(Ft,{items:p.map(e=>String(e.id)),strategy:Mt,children:(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:p.map(e=>(0,$.jsx)(an,{token:e},e.id))})})})})]})}function cn(){return(0,$.jsx)(`div`,{className:`max-w-6xl mx-auto`,children:(0,$.jsx)(sn,{})})}export{cn 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{i,r as a}from"./index-CN7eSKO4.js";import{i as o,t as s}from"./services.generated-AsEvHbJ7.js";var c=e(n()),l=r(),u=e=>(0,l.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,l.jsx)(`path`,{fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 12h14m-7-7v14`})});function d(){let[e,n]=(0,c.useState)(!1),[r,o]=(0,c.useState)(!1),[d,f]=(0,c.useState)(``),p=t(),m=s.useOauthStartMutation(),h=s.useOauthStartOpenAIMutation(),g=async e=>{if(d.trim())if(e===`openai`){let e=window.open(`about:blank`,`_blank`);o(!0);try{let{authUrl:t}=await h.mutateAsync({name:d.trim()});e?e.location.href=t:window.open(t,`_blank`);let n=setInterval(async()=>{await p.invalidateQueries({queryKey:[`Token`]}),await p.invalidateQueries({queryKey:[`Qgrid`]})},3e3);setTimeout(()=>{clearInterval(n),o(!1)},3e5)}catch(e){console.error(`OAuth start failed:`,e),o(!1)}}else{o(!0);try{let{authUrl:e}=await m.mutateAsync({name:d.trim()});window.location.href=e}catch(e){console.error(`OAuth start failed:`,e),o(!1)}}},_=()=>{n(!1),f(``),o(!1)};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(`button`,{type:`button`,className:`px-3.5 py-1.5 text-[12px] font-medium rounded-lg bg-sienna-500 text-white hover:bg-sienna-600 disabled:opacity-50 transition-all duration-150 active:scale-[0.97] flex items-center gap-1.5 shadow-sm`,onClick:()=>n(!0),children:[(0,l.jsx)(u,{className:`size-3.5`}),`Add Token`]}),e&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:_,onKeyDown:()=>{}}),(0,l.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-md mx-4`,children:[(0,l.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100/50`,children:(0,l.jsx)(`h2`,{className:`text-base font-medium text-sand-900`,children:`Add Token`})}),(0,l.jsxs)(`div`,{className:`px-5 py-4 space-y-4`,children:[(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name *`}),(0,l.jsx)(a,{value:d,onChange:e=>f(e.target.value),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,l.jsxs)(`div`,{className:`space-y-2`,children:[(0,l.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:!d.trim()||r,onClick:()=>g(`openai`),children:r?(0,l.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,l.jsx)(`span`,{className:`w-3.5 h-3.5 border-2 border-white border-t-transparent rounded-full animate-spin`}),`Waiting for login...`]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(i,{className:`size-4`}),`Login with OpenAI`]})}),(0,l.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,l.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`}),(0,l.jsx)(`span`,{className:`text-[10px] text-sand-400 uppercase`,children:`or`}),(0,l.jsx)(`div`,{className:`flex-1 h-px bg-sand-200`})]}),(0,l.jsxs)(`button`,{type:`button`,className:`w-full py-2.5 text-sm font-medium rounded-md border border-sand-300 text-sand-700 hover:bg-sand-100 disabled:opacity-50 transition-colors duration-150 flex items-center justify-center gap-2`,disabled:!d.trim()||r,onClick:()=>g(`anthropic`),children:[(0,l.jsx)(i,{className:`size-4`}),`Login with Claude`]})]})]}),(0,l.jsx)(`div`,{className:`px-5 py-3 border-t border-sand-100/50 flex items-center justify-end gap-2`,children:(0,l.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:_,children:`Cancel`})})]})]})]})}var f=e=>(0,l.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,l.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`})}),p=e=>(0,l.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`1.2em`,height:`1.2em`,...e,children:(0,l.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`})});function m(e){let t=e.credentials;return`expiresAt`in t&&typeof t.expiresAt==`number`?t.expiresAt:`accessTokenExpiresAt`in t&&typeof t.accessTokenExpiresAt==`number`?t.accessTokenExpiresAt:null}function h(e){if(!e)return{text:``,color:``};let t=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 g(e){let t=e.credentials.accessToken;return t.length<=12?t:`${t.slice(0,8)}...${t.slice(-4)}`}function _({data:e,isLoading:n}){let[r,i]=(0,c.useState)(null),[o,u]=(0,c.useState)(null),[d,_]=(0,c.useState)(``),v=t(),y=s.useRemoveTokenMutation(),b=s.useUpdateTokenMutation(),x=s.useToggleTokenMutation(),S=()=>Promise.all([v.invalidateQueries({queryKey:[`Token`]}),v.invalidateQueries({queryKey:[`Qgrid`]})]),C=async e=>{await x.mutateAsync({id:e.id}),await S()},w=async()=>{r&&(await y.mutateAsync({id:r.id}),await S(),i(null))},T=e=>{u(e),_(e.name??``)},E=async()=>{o&&(await b.mutateAsync({id:o.id,name:d.trim(),quotaThreshold:o.quota_threshold}),await S(),u(null))};if(n)return(0,l.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,t)=>(0,l.jsx)(`div`,{className:`h-12 bg-sand-100 rounded-md animate-pulse`},`skeleton-${t}`))});let D=e??[];return D.length===0?(0,l.jsxs)(`div`,{className:`text-sand-400 text-center py-16 text-sm`,children:[`No tokens registered. Click `,(0,l.jsx)(`strong`,{className:`text-sand-600`,children:`Add Token`}),` to get started.`]}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(`div`,{className:`panel overflow-hidden`,children:(0,l.jsxs)(`table`,{className:`w-full text-[13px]`,children:[(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`panel-header`,children:[(0,l.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Provider`}),(0,l.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Name`}),(0,l.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Token`}),(0,l.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Status`}),(0,l.jsx)(`th`,{className:`text-left px-5 py-2.5 text-[10px] uppercase tracking-wider text-sand-400 font-medium`,children:`Expires`}),(0,l.jsx)(`th`,{className:`w-20 px-3 py-2.5`})]})}),(0,l.jsx)(`tbody`,{className:`divide-y divide-sand-100/80`,children:D.map(e=>{let t=h(m(e));return(0,l.jsxs)(`tr`,{className:`transition-colors duration-150 hover:bg-sand-100/60 ${e.active?``:`opacity-50`}`,children:[(0,l.jsx)(`td`,{className:`px-5 py-3`,children:(0,l.jsx)(`span`,{className:`text-xs font-medium text-sand-500 uppercase`,children:e.provider})}),(0,l.jsx)(`td`,{className:`px-5 py-3`,children:e.name?(0,l.jsx)(`span`,{className:`text-sm text-sand-700`,children:e.name}):(0,l.jsx)(`span`,{className:`text-[11px] text-sand-400`,children:`—`})}),(0,l.jsx)(`td`,{className:`px-5 py-3`,children:(0,l.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:g(e)})}),(0,l.jsx)(`td`,{className:`px-5 py-3`,children:(0,l.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:()=>C(e),disabled:x.isPending,children:(0,l.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,l.jsx)(`td`,{className:`px-5 py-3`,children:t.text&&(0,l.jsx)(`span`,{className:`text-xs ${t.color}`,children:t.text})}),(0,l.jsx)(`td`,{className:`px-3 py-3`,children:(0,l.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,l.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-sienna-500 transition-colors duration-150`,onClick:()=>T(e),children:(0,l.jsx)(f,{className:`size-4`})}),(0,l.jsx)(`button`,{type:`button`,className:`p-1 rounded text-sand-400 hover:text-red-500 transition-colors duration-150`,onClick:()=>i(e),children:(0,l.jsx)(p,{className:`size-4`})})]})})]},e.id)})})]})}),o&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:()=>u(null),onKeyDown:()=>{}}),(0,l.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-sm mx-4`,children:[(0,l.jsx)(`div`,{className:`px-5 py-4 border-b border-sand-100/60`,children:(0,l.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Edit Token`})}),(0,l.jsx)(`div`,{className:`px-5 py-4 space-y-3`,children:(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`label`,{htmlFor:`token-name`,className:`text-[10px] uppercase tracking-wider text-sand-500 font-medium`,children:`Name`}),(0,l.jsx)(a,{value:d,onChange:e=>_(e.target.value),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,l.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100/60 flex items-center justify-end gap-2`,children:[(0,l.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:()=>u(null),children:`Cancel`}),(0,l.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:b.isPending,onClick:E,children:b.isPending?`Saving...`:`Save`})]})]})]}),r&&(0,l.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center pt-[15vh]`,children:[(0,l.jsx)(`div`,{className:`absolute inset-0 bg-sand-900/8 backdrop-blur-sm`,onClick:()=>i(null),onKeyDown:()=>{}}),(0,l.jsxs)(`div`,{className:`relative panel shadow-xl w-full max-w-sm mx-4`,children:[(0,l.jsxs)(`div`,{className:`px-5 py-4`,children:[(0,l.jsx)(`h3`,{className:`text-base font-medium text-sand-900`,children:`Remove Token`}),(0,l.jsxs)(`p`,{className:`text-sm text-sand-700 mt-2`,children:[`Are you sure you want to remove`,` `,(0,l.jsx)(`code`,{className:`text-[13px] font-mono text-sand-800`,children:g(r)}),r.name&&(0,l.jsxs)(`span`,{className:`text-sand-500`,children:[` (`,r.name,`)`]}),`?`]})]}),(0,l.jsxs)(`div`,{className:`px-5 py-3 border-t border-sand-100/60 flex items-center justify-end gap-2`,children:[(0,l.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,l.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:y.isPending,onClick:w,children:y.isPending?`Removing...`:`Remove`})]})]})]})]})}function v(){let{data:e,isLoading:t}=o.useTokens(`A`);return(0,l.jsxs)(`div`,{className:`max-w-6xl mx-auto space-y-4`,children:[(0,l.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,l.jsx)(d,{})}),(0,l.jsx)(_,{data:e?.rows,isLoading:t})]})}export{v as component};
|