@meetploy/emulator 1.53.0 → 1.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard-dist/assets/{main-C7JOL9F1.js → main-DTu_EFFr.js} +1 -1
- package/dist/dashboard-dist/index.html +1 -1
- package/dist/nextjs-dev.js +2 -1
- package/dist/nextjs-dev.js.map +1 -1
- package/dist/runtime/db-runtime.spec.js +77 -0
- package/dist/runtime/db-runtime.spec.js.map +1 -1
- package/dist/services/auth-service.spec.js +4 -2
- package/dist/services/auth-service.spec.js.map +1 -1
- package/dist/services/db-service.js +10 -5
- package/dist/services/db-service.js.map +1 -1
- package/dist/utils/sqlite-db.js +2 -0
- package/dist/utils/sqlite-db.js.map +1 -1
- package/package.json +1 -1
|
@@ -352,4 +352,4 @@ Please change the parent <Route path="${k}"> to <Route path="${k==="/"?"*":`${k}
|
|
|
352
352
|
*
|
|
353
353
|
* This source code is licensed under the ISC license.
|
|
354
354
|
* See the LICENSE file in the root directory of this source tree.
|
|
355
|
-
*/const Hw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],qw=Jn("x",Hw);function Bw(a){const l=Math.floor((new Date().getTime()-a.getTime())/1e3);return l<5?"just now":l<60?`${String(l)}s ago`:l<3600?`${String(Math.floor(l/60))}m ago`:l<86400?`${String(Math.floor(l/3600))}h ago`:l<604800?`${String(Math.floor(l/86400))}d ago`:a.toLocaleDateString()}function yd({value:a}){const[l,s]=x.useState(!1);return r.jsx("button",{onClick:u=>{u.stopPropagation(),navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>{s(!1)},2e3)}).catch(()=>{const f=document.createElement("textarea");f.value=a,document.body.appendChild(f),f.select();try{document.execCommand("copy")}catch{}document.body.removeChild(f),s(!0),setTimeout(()=>{s(!1)},2e3)})},className:ve("p-1 rounded transition-colors flex-shrink-0",l?"text-green-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"),title:l?"Copied!":"Copy to clipboard",children:l?r.jsx(lv,{className:"w-3 h-3"}):r.jsx(Mw,{className:"w-3 h-3"})})}function yn({timestamp:a,className:l,rawValue:s,forceOpen:u=!1}){const[f,d]=x.useState(!1),[,m]=x.useState(0),y=u||f;if(x.useEffect(()=>{const j=setInterval(()=>{m(E=>E+1)},1e3);return()=>{clearInterval(j)}},[]),!a)return null;let p;typeof a=="number"?p=new Date(a<1e10?a*1e3:a):p=new Date(a);const g=p.toISOString(),b=p.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),S=Bw(p);return r.jsxs("div",{className:ve("relative inline-block",l),onMouseEnter:()=>{d(!0)},onMouseLeave:()=>{d(!1)},children:[r.jsx("time",{dateTime:g,className:"cursor-help border-b border-gray-400 dark:border-gray-400 text-gray-700 dark:text-gray-300",children:S}),r.jsx("div",{className:ve("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-[9999] w-72","transition-all duration-200 ease-out origin-bottom",y?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 translate-y-2 pointer-events-none"),children:r.jsx(Ro,{rounded:"lg",shadow:"lg",className:"p-3 text-xs !bg-white dark:!bg-gray-900 !backdrop-blur-none",children:r.jsxs("div",{className:"space-y-2.5",children:[s!==void 0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Raw Value"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:typeof s=="object"?JSON.stringify(s):String(s)}),r.jsx(yd,{value:typeof s=="object"?JSON.stringify(s):String(s)})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"UTC ISO"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:g}),r.jsx(yd,{value:g})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Local Time"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-200 leading-tight",children:b}),r.jsx(yd,{value:b})]})]})]})})})]})}function Qw(a){return a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`}function Yw(a){return typeof a!="string"?!1:[/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,/^\d{4}-\d{2}-\d{2}$/].some(l=>l.test(a))}function Gw(a){const l=a.toLowerCase();return!!(l.includes("created")||l.includes("date")||l.includes("updated")||a.endsWith("At")||l.endsWith("_at"))}function Vw(a,l){for(const s of l){const u=s[a];if(u!=null)return typeof u=="boolean"?"bool":typeof u=="number"&&Gw(a)?"date":typeof u=="number"?"number":Yw(u)?"date":"string"}return"string"}function iv({results:a,meta:l,columns:s,error:u,title:f="Results",pageSize:d=25,onExportCsv:m,onExportJson:y,serverPagination:p}){const g=a??[],[b,S]=x.useState(""),[j,E]=x.useState(null),[O,T]=x.useState(new Set),[A,k]=x.useState(1),B=!!p,K=p?Math.floor(p.offset/p.limit)+1:1,D=p?Math.ceil(p.total/p.limit):1,G=x.useMemo(()=>s||(g.length===0?[]:Object.keys(g[0]).map(le=>({key:le,label:le,type:Vw(le,g)}))),[s,g]),ae=x.useMemo(()=>b?g.filter(le=>Object.values(le).some(P=>String(P).toLowerCase().includes(b.toLowerCase()))):g,[g,b]),V=x.useMemo(()=>j?[...ae].sort((le,P)=>{const R=le[j.key],$=P[j.key];return R==null?1:$==null?-1:R<$?j.direction==="asc"?-1:1:R>$?j.direction==="asc"?1:-1:0}):ae,[ae,j]),H=Math.ceil(V.length/d),ee=x.useMemo(()=>{const le=(A-1)*d;return V.slice(le,le+d)},[V,A,d]);x.useMemo(()=>{k(1)},[b,j]);const Q=le=>{E(P=>(P==null?void 0:P.key)===le?P.direction==="asc"?{key:le,direction:"desc"}:null:{key:le,direction:"asc"})},se=()=>{O.size===ee.length?T(new Set):T(new Set(ee.map((le,P)=>P)))},re=le=>{const P=new Set(O);P.has(le)?P.delete(le):P.add(le),T(P)},ue=(le,P)=>{const R=le[P.key];if(R==null)return r.jsx("span",{className:"text-xs italic dark:text-gray-600 text-gray-400",children:"NULL"});switch(P.type??"string"){case"bool":return R===!0?r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(lv,{className:"w-3.5 h-3.5"})}):r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(qw,{className:"w-3.5 h-3.5"})});case"date":return r.jsx(yn,{timestamp:R,rawValue:typeof R=="number"?R:void 0});case"number":return r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:typeof R=="number"?R.toLocaleString():JSON.stringify(R)});default:return typeof R=="object"?r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:JSON.stringify(R)}):r.jsx("span",{className:"text-sm dark:text-gray-300 text-gray-700",children:typeof R=="object"?JSON.stringify(R):String(R)})}};return u?r.jsxs(Ro,{rounded:"2xl",shadow:"lg",className:"border-red-500/30 dark:border-red-500/20",children:[r.jsx("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200",children:r.jsx("h2",{className:"text-lg font-semibold text-red-500",children:"Query Error"})}),r.jsx("div",{className:"p-5",children:r.jsx("p",{className:"font-mono text-sm text-red-500",children:u})})]}):r.jsxs(Ro,{rounded:"2xl",shadow:"lg",className:"flex flex-col",children:[r.jsxs("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200 flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h2",{className:"text-lg font-semibold dark:text-white text-gray-900",children:f}),l&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20",children:Qw(l.duration)}),r.jsxs("span",{className:"text-sm dark:text-gray-500 text-gray-500",children:[g.length," row",g.length!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative group",children:[r.jsx(Uw,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 group-focus-within:text-blue-500 transition-colors"}),r.jsx("input",{type:"text",placeholder:"Search results...",value:b,onChange:le=>{S(le.target.value)},className:"pl-9 pr-4 py-2 rounded-lg text-sm bg-gray-100 dark:bg-white/[0.06] border border-transparent focus:bg-white dark:focus:bg-black focus:border-blue-500 focus:ring-1 focus:ring-blue-500 outline-none transition-all w-full sm:w-64 dark:text-white text-gray-900 placeholder-gray-500"})]}),(m??y)&&r.jsxs("div",{className:"flex items-center gap-2 border-l dark:border-white/[0.08] border-gray-200 pl-3 ml-1",children:[m&&r.jsx("button",{onClick:m,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export CSV",children:r.jsx(kw,{className:"w-4 h-4"})}),y&&r.jsx("button",{onClick:y,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export JSON",children:r.jsx(Ow,{className:"w-4 h-4"})})]})]})]}),r.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:r.jsxs("table",{className:"w-full text-left border-collapse font-mono",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b dark:border-white/[0.08] border-gray-200 bg-gray-50/50 dark:bg-white/[0.02]",children:[r.jsx("th",{className:"p-4 w-12",children:r.jsx("input",{type:"checkbox",checked:O.size===ee.length&&ee.length>0,onChange:se,className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),G.map(le=>r.jsx("th",{className:"p-4 text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors select-none group",onClick:()=>{Q(le.key)},children:r.jsxs("div",{className:"flex items-center gap-1",children:[le.label,r.jsxs("div",{className:ve("flex flex-col opacity-0 group-hover:opacity-50",(j==null?void 0:j.key)===le.key&&"opacity-100"),children:[r.jsx(Tw,{className:ve("w-2 h-2",(j==null?void 0:j.key)===le.key&&j.direction==="asc"&&"text-blue-500")}),r.jsx(Nw,{className:ve("w-2 h-2",(j==null?void 0:j.key)===le.key&&j.direction==="desc"&&"text-blue-500")})]})]})},le.key))]})}),r.jsx("tbody",{className:"divide-y dark:divide-white/[0.04] divide-gray-100",children:ee.length>0?ee.map((le,P)=>r.jsxs("tr",{className:ve("group transition-colors",O.has(P)?"bg-blue-50/50 dark:bg-blue-500/10":"hover:bg-gray-50 dark:hover:bg-white/[0.02]"),children:[r.jsx("td",{className:"p-4",children:r.jsx("input",{type:"checkbox",checked:O.has(P),onChange:()=>{re(P)},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),G.map(R=>r.jsx("td",{className:"p-4 whitespace-nowrap",children:ue(le,R)},`${String(P)}-${R.key}`))]},P)):r.jsx("tr",{children:r.jsx("td",{colSpan:G.length+1,className:"p-8 text-center text-gray-500 dark:text-gray-400",children:b?`No results found matching "${b}"`:"Query executed successfully. No rows returned."})})})]})}),r.jsxs("div",{className:"p-4 border-t dark:border-white/[0.08] border-gray-200 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[r.jsxs("div",{children:[B?r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.offset+1}),"-",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:Math.min(p.offset+g.length,p.total)})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.total})," ","total"]}):r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:ee.length})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:V.length})," ","results"]}),O.size>0&&r.jsxs("span",{className:"ml-3 text-blue-500 font-medium",children:[O.size," row",O.size!==1?"s":""," ","selected"]})]}),B&&D>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{p.onPageChange(Math.max(0,p.offset-p.limit))},disabled:K===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(dx,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(D,5)},(le,P)=>{let R;return D<=5||K<=3?R=P+1:K>=D-2?R=D-4+P:R=K-2+P,r.jsx("button",{onClick:()=>{p.onPageChange((R-1)*p.limit)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",K===R?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:R},R)})}),r.jsx("button",{onClick:()=>{p.onPageChange(p.offset+p.limit)},disabled:K===D,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(hx,{className:"w-4 h-4"})})]}),!B&&H>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{k(le=>Math.max(1,le-1))},disabled:A===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(dx,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(H,5)},(le,P)=>{let R;return H<=5||A<=3?R=P+1:A>=H-2?R=H-4+P:R=A-2+P,r.jsx("button",{onClick:()=>{k(R)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",A===R?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:R},R)})}),r.jsx("button",{onClick:()=>{k(le=>Math.min(H,le+1))},disabled:A===H,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(hx,{className:"w-4 h-4"})})]})]})]})}function vh(){return typeof window<"u"}function Ms(a){var l;return(a==null||(l=a.ownerDocument)==null?void 0:l.defaultView)||window}function Xw(a){return vh()?a instanceof Element||a instanceof Ms(a).Element:!1}function Ho(a){return vh()?a instanceof HTMLElement||a instanceof Ms(a).HTMLElement:!1}function Kw(a){return!vh()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof Ms(a).ShadowRoot}function $w(a){return Ms(a).getComputedStyle(a)}const bh={...zS},xd=bh.useInsertionEffect,Zw=xd&&xd!==bh.useLayoutEffect?xd:a=>a();function qe(a){const l=ca(Fw).current;return l.next=a,Zw(l.effect),l.trampoline}function Fw(){const a={next:void 0,callback:Jw,trampoline:(...l)=>{var s;return(s=a.callback)==null?void 0:s.call(a,...l)},effect:()=>{a.callback=a.next}};return a}function Jw(){}const Pw=()=>{},Ve=typeof document<"u"?x.useLayoutEffect:Pw,sv=x.createContext(void 0);function Sh(a=!1){const l=x.useContext(sv);if(l===void 0&&!a)throw new Error(Ya(16));return l}function Iw(a){const{focusableWhenDisabled:l,disabled:s,composite:u=!1,tabIndex:f=0,isNativeButton:d}=a,m=u&&l!==!1,y=u&&l===!1;return{props:x.useMemo(()=>{const g={onKeyDown(b){s&&l&&b.key!=="Tab"&&b.preventDefault()}};return u||(g.tabIndex=f,!d&&s&&(g.tabIndex=l?f:-1)),(d&&(l||m)||!d&&s)&&(g["aria-disabled"]=s),d&&(!l||y)&&(g.disabled=s),g},[u,s,l,m,y,d,f])}}function Gd(a){return(a==null?void 0:a.ownerDocument)||document}function So(a,l,{detail:s=0}={}){a.dispatchEvent(new(Ms(a)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:s,shiftKey:l.shiftKey,ctrlKey:l.ctrlKey,altKey:l.altKey,metaKey:l.metaKey}))}function qo(a={}){const{disabled:l=!1,focusableWhenDisabled:s,tabIndex:u=0,native:f=!0,composite:d}=a,m=x.useRef(null),y=Sh(!0),p=d??y!==void 0,{props:g}=Iw({focusableWhenDisabled:s,disabled:l,composite:p,tabIndex:u,isNativeButton:f}),b=x.useCallback(()=>{const E=m.current;vd(E)&&p&&l&&g.disabled===void 0&&E.disabled&&(E.disabled=!1)},[l,g.disabled,p]);Ve(b,[b]);const S=x.useCallback((E={})=>{const{onClick:O,onMouseDown:T,onKeyUp:A,onKeyDown:k,onPointerDown:B,...K}=E;return Uo({onClick(D){if(l){D.preventDefault();return}O==null||O(D)},onMouseDown(D){l||T==null||T(D)},onKeyDown(D){if(l||(Co(D),k==null||k(D),D.baseUIHandlerPrevented))return;const G=D.target===D.currentTarget,ae=D.currentTarget,V=vd(ae),H=!f&&Ww(ae),ee=G&&(f?V:!H),Q=D.key==="Enter",se=D.key===" ",re=ae.getAttribute("role"),ue=(re==null?void 0:re.startsWith("menuitem"))||re==="option"||re==="gridcell";if(G&&p&&se){if(D.defaultPrevented&&ue)return;D.preventDefault(),(!f||V)&&(D.preventBaseUIHandler(),So(ae,D));return}if(!ee||f||!se&&!Q){G&&H&&se&&D.preventDefault();return}D.defaultPrevented||(D.preventDefault(),Q&&(D.preventBaseUIHandler(),So(ae,D)))},onKeyUp(D){if(!l){if(Co(D),A==null||A(D),D.target===D.currentTarget&&f&&p&&vd(D.currentTarget)&&D.key===" "){D.preventDefault();return}D.baseUIHandlerPrevented||D.target===D.currentTarget&&!f&&!p&&!D.defaultPrevented&&D.key===" "&&(D.preventBaseUIHandler(),So(D.currentTarget,D))}},onPointerDown(D){if(l){D.preventDefault();return}B==null||B(D)}},f?{type:"button"}:{role:"button"},g,K)},[l,g,p,f]),j=qe(E=>{m.current=E,b()});return{getButtonProps:S,buttonRef:j}}function vd(a){return Ho(a)&&a.tagName==="BUTTON"}function Ww(a){return Ho(a)&&a.tagName==="A"&&!!a.href}const eC=x.forwardRef(function(l,s){const{render:u,className:f,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:y=!0,style:p,...g}=l,{getButtonProps:b,buttonRef:S}=qo({disabled:d,focusableWhenDisabled:m,native:y});return qt("button",l,{state:{disabled:d},ref:[s,S],props:[g,b]})}),tC={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},nC={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},aC={disabled:!1,...nC},rv={valid(a){return a===null?null:a?{"data-valid":""}:{"data-invalid":""}}},lC={invalid:void 0,name:void 0,validityData:{state:tC,errors:[],error:"",value:"",initialValue:null},setValidityData:Zt,disabled:void 0,setTouched:Zt,setDirty:Zt,setFilled:Zt,setFocused:Zt,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:aC,registerFieldControl:Zt,validation:{getValidationProps:(a,l=Ha)=>l,inputRef:{current:null},registeredInputs:new Map,registerInput:Zt,getInputControl:()=>null,commit:async()=>{},change:Zt}},iC=x.createContext(lC);function jh(a=!0){const l=x.useContext(iC);if(l.setValidityData===Zt&&!a)throw new Error(Ya(28));return l}const sC=x.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Zt,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function uv(){return x.useContext(sC)}let mx=0;function rC(a,l="mui"){const[s,u]=x.useState(a),f=a||s;return x.useEffect(()=>{s==null&&(mx+=1,u(`${l}-${mx}`))},[s,l]),f}const px=bh.useId;function uC(a,l){if(px!==void 0){const s=px();return a??`${l}-${s}`}return rC(a,l)}function ci(a){return uC(a,"base-ui")}const oC=x.createContext({controlId:void 0,registerControlId:Zt,labelId:void 0,setLabelId:Zt,messageIds:[],setMessageIds:Zt,getDescriptionProps:a=>a});function Nh(){return x.useContext(oC)}function cC(a,l,s,u=!0,f){const[d,m]=x.useState(),y=ci(f?`${f}-label`:void 0),p=a??l??d;return Ve(()=>{const g=a||l||!u?void 0:fC(s.current,y);d!==g&&m(g)}),p}function fC(a,l){const s=dC(a);if(s)return!s.id&&l&&(s.id=l),s.id||void 0}function dC(a){if(!a)return;const l=a.parentElement;if(l&&l.tagName==="LABEL")return l;const s=a.id;if(s){const f=a.nextElementSibling;if(f&&f.htmlFor===s)return f}const u=a.labels;return u&&u[0]}function ov(a={}){const{id:l,implicit:s=!1,controlRef:u}=a,{controlId:f,registerControlId:d}=Nh(),m=ci(l),y=s?f:void 0,p=ca(()=>Symbol()),g=x.useRef(!1),b=x.useRef(l!=null),S=qe(()=>{!g.current||d===Zt||(g.current=!1,d(p.current,void 0))});return Ve(()=>{if(d===Zt)return;let j;if(s){const E=u==null?void 0:u.current;Xw(E)&&E.closest("label")!=null?j=l??null:j=y??m}else if(l!=null)b.current=!0,j=l;else if(b.current)j=m;else{S();return}if(j===void 0){S();return}g.current=!0,d(p.current,j)},[l,u,y,d,s,m,p,S]),x.useEffect(()=>S,[S]),f??m}function hC(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:mC,platform:pC,maxTouchPoints:eT}=hC(),cv=mC.toLowerCase();pC.toLowerCase();var Vx;const Eh=typeof CSS<"u"&&!!((Vx=CSS.supports)!=null&&Vx.call(CSS,"-webkit-backdrop-filter:none"));!Eh&&cv.includes("firefox");!Eh&&cv.includes("chrom");function fv(a){var s;let l=a.activeElement;for(;((s=l==null?void 0:l.shadowRoot)==null?void 0:s.activeElement)!=null;)l=l.shadowRoot.activeElement;return l}function wh(a,l){var u;if(!a||!l)return!1;const s=(u=l.getRootNode)==null?void 0:u.call(l);if(a.contains(l))return!0;if(s&&Kw(s)){let f=l;for(;f;){if(a===f)return!0;f=f.parentNode||f.host}}return!1}function Vd(a){return"composedPath"in a?a.composedPath()[0]:a.target}function bd(a,l){return l<0||l>=a.length}function gC(a,l){return zr(a.current,{disabledIndices:l})}function yC(a,l){return zr(a.current,{decrement:!0,startingIndex:a.current.length,disabledIndices:l})}function zr(a,{startingIndex:l=-1,decrement:s=!1,disabledIndices:u,amount:f=1}={}){let d=l;do d+=s?-f:f;while(d>=0&&d<=a.length-1&&Xd(a,d,u));return d}function Xd(a,l,s){if(typeof s=="function"?s(l):(s==null?void 0:s.includes(l))??!1)return!0;const f=a[l];return f?!vC(f)||f.matches(":disabled")?!0:!s&&(f.hasAttribute("disabled")||f.getAttribute("aria-disabled")==="true"):!1}function xC(a){return a.visibility==="hidden"||a.visibility==="collapse"}function vC(a,l=a?$w(a):null){return!a||!a.isConnected||!l||xC(l)?!1:typeof a.checkVisibility=="function"?a.checkVisibility():l.display!=="none"&&l.display!=="contents"}function dv(a){x.useEffect(a,To)}const Rr=0;class Ch{constructor(){pn(this,"currentId",Rr);pn(this,"clear",()=>{this.currentId!==Rr&&(clearTimeout(this.currentId),this.currentId=Rr)});pn(this,"disposeEffect",()=>this.clear)}static create(){return new Ch}start(l,s){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Rr,s()},l)}isStarted(){return this.currentId!==Rr}}function Mo(){const a=ca(Ch.create).current;return dv(a.disposeEffect),a}const uo=null;class bC{constructor(){pn(this,"callbacks",[]);pn(this,"callbacksCount",0);pn(this,"nextId",1);pn(this,"startId",1);pn(this,"isScheduled",!1);pn(this,"tick",l=>{var f;this.isScheduled=!1;const s=this.callbacks,u=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,u>0)for(let d=0;d<s.length;d+=1)(f=s[d])==null||f.call(s,l)})}request(l){const s=this.nextId;return this.nextId+=1,this.callbacks.push(l),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),s}cancel(l){const s=l-this.startId;s<0||s>=this.callbacks.length||(this.callbacks[s]=null,this.callbacksCount-=1)}}let oo=new bC;class gn{constructor(){pn(this,"currentId",uo);pn(this,"cancel",()=>{this.currentId!==uo&&(oo.cancel(this.currentId),this.currentId=uo)});pn(this,"disposeEffect",()=>this.cancel)}static create(){return new gn}static request(l){return oo.request(l)}static cancel(l){return oo.cancel(l)}request(l){this.cancel(),this.currentId=oo.request(()=>{this.currentId=uo,l()})}}function SC(){const a=ca(gn.create).current;return dv(a.disposeEffect),a}function jC(a){return a==null?a:"current"in a?a.current:a}function hv(a,l=!1){const s=SC();return qe((u,f=null)=>{s.cancel();const d=jC(a);if(d==null)return;const m=d,y=()=>{Aj.flushSync(u)};if(typeof m.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){u();return}function p(){Promise.all(m.getAnimations().map(g=>g.finished)).then(()=>{f!=null&&f.aborted||y()},()=>{if(f!=null&&f.aborted)return;if(m.getAnimations().some(b=>b.pending||b.playState!=="finished")){p();return}y()})}if(l){const g="data-starting-style";if(!m.hasAttribute(g)){s.request(p);return}const b=new MutationObserver(()=>{m.hasAttribute(g)||(b.disconnect(),p())});b.observe(m,{attributes:!0,attributeFilter:[g]}),f==null||f.addEventListener("abort",()=>b.disconnect(),{once:!0});return}s.request(p)})}function mv(a){const{enabled:l=!0,open:s,ref:u,onComplete:f}=a,d=qe(f),m=hv(u,s);x.useEffect(()=>{if(!l)return;const y=new AbortController;return m(d,y.signal),()=>{y.abort()}},[l,s,d,m])}let gx=(function(a){return a.startingStyle="data-starting-style",a.endingStyle="data-ending-style",a})({});const NC={"data-starting-style":""},EC={"data-ending-style":""},Th={transitionStatus(a){return a==="starting"?NC:a==="ending"?EC:null}};function pv(a,l=!1,s=!1){const[u,f]=x.useState(a&&l?"idle":void 0),[d,m]=x.useState(a);return a&&!d&&(m(!0),f("starting")),!a&&d&&u!=="ending"&&!s&&f("ending"),!a&&!d&&u==="ending"&&f(void 0),Ve(()=>{if(!a&&d&&u!=="ending"&&s){const y=gn.request(()=>{f("ending")});return()=>{gn.cancel(y)}}},[a,d,u,s]),Ve(()=>{if(!a||l)return;const y=gn.request(()=>{f(void 0)});return()=>{gn.cancel(y)}},[l,a]),Ve(()=>{if(!a||!l)return;a&&d&&u!=="idle"&&f("starting");const y=gn.request(()=>{f("idle")});return()=>{gn.cancel(y)}},[l,a,d,u]),{mounted:d,setMounted:m,transitionStatus:u}}function Bo({controlled:a,default:l,name:s,state:u="value"}){const{current:f}=x.useRef(a!==void 0),[d,m]=x.useState(l),y=f?a:d,p=x.useCallback(g=>{f||m(g)},[]);return[y,p]}function gv(a,l,s,u,f=!0,d){const{registerFieldControl:m}=jh(),y=ca(()=>Symbol());Ve(()=>{const p=y.current;if(!f){m(p,void 0);return}m(p,{controlRef:a,getValue:u,id:l,name:d,value:s})},[a,f,u,l,d,m,y,s]),Ve(()=>{const p=y.current;return()=>{m(p,void 0)}},[m,y])}const Qo="none",wC="trigger-press",CC="disabled",yx="missing",xx="initial";function As(a,l,s,u){let f=!1,d=!1;const m=u??Ha;return{reason:a,event:l??new Event("base-ui"),cancel(){f=!0},allowPropagation(){d=!0},get isCanceled(){return f},get isPropagationAllowed(){return d},trigger:s,...m}}const TC=x.forwardRef(function(l,s){const{render:u,className:f,id:d,name:m,value:y,disabled:p=!1,onValueChange:g,defaultValue:b,autoFocus:S=!1,style:j,...E}=l,{state:O,name:T,disabled:A,setTouched:k,setDirty:B,validityData:K,setFocused:D,setFilled:G,validationMode:ae,validation:V}=jh(),{clearErrors:H}=uv(),ee=A||p,Q=T??m,se={...O,disabled:ee},{labelId:re}=Nh(),ue=ov({id:d});Ve(()=>{var N;const I=y!=null;(N=V.inputRef.current)!=null&&N.value||I&&y!==""?G(!0):I&&y===""&&G(!1)},[V.inputRef,G,y]);const le=x.useRef(null);Ve(()=>{S&&le.current===fv(Gd(le.current))&&D(!0)},[S,D]);const[P]=Bo({controlled:y,default:b,name:"FieldControl",state:"value"}),R=y!==void 0,$=R?P:void 0,Y=qe(()=>{var I;return(I=V.inputRef.current)==null?void 0:I.value});return gv(V.inputRef,ue,$,Y,!ee,m),qt("input",l,{ref:[s,le],state:se,props:[{id:ue,disabled:ee,name:Q,ref:V.inputRef,"aria-labelledby":re,autoFocus:S,...R?{value:$}:{defaultValue:b},onChange(I){const N=I.currentTarget.value;g==null||g(N,As(Qo,I.nativeEvent)),B(N!==(K.initialValue??"")),G(N!==""),I.nativeEvent.defaultPrevented||(H(Q),V.change(N))},onFocus(){D(!0)},onBlur(I){k(!0),D(!1),ae==="onBlur"&&V.commit(I.currentTarget.value)},onKeyDown(I){I.currentTarget.tagName==="INPUT"&&I.key==="Enter"&&(k(!0),V.commit(I.currentTarget.value))}},E,I=>V.getValidationProps(ee,I)],stateAttributesMapping:rv})}),RC=x.forwardRef(function(l,s){return r.jsx(TC,{ref:s,...l})}),yv=x.createContext(void 0);function Yo(){const a=x.useContext(yv);if(a===void 0)throw new Error(Ya(53));return a}const MC=500,Kd=16;function Tl(a,l,s){if(!a)return 0;const u=getComputedStyle(a),f=`${l}${s==="x"?"Inline":"Block"}`,d=parseFloat(u[`${f}Start`]);return s==="x"&&l==="margin"?d*2:d+parseFloat(u[`${f}End`])}const co="base-ui-disable-scrollbar",xv={className:co,getElement(a){return r.jsx("style",{nonce:a,href:co,precedence:"base-ui:low",children:`.${co}{scrollbar-width:none}.${co}::-webkit-scrollbar{display:none}`})}},ts=a=>l=>l?{[a]:""}:null,Rh={hasOverflowX:ts("data-has-overflow-x"),hasOverflowY:ts("data-has-overflow-y"),overflowXStart:ts("data-overflow-x-start"),overflowXEnd:ts("data-overflow-x-end"),overflowYStart:ts("data-overflow-y-start"),overflowYEnd:ts("data-overflow-y-end"),cornerHidden:()=>null},AC=x.createContext(void 0),OC={disableStyleElements:!1};function zC(){return x.useContext(AC)??OC}const kC={x:0,y:0},vx={width:0,height:0},DC={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},_C={x:!0,y:!0,corner:!0},LC=x.forwardRef(function(l,s){const{render:u,className:f,overflowEdgeThreshold:d,style:m,...y}=l,{xStart:p,xEnd:g,yStart:b,yEnd:S}=UC(d),j=ci(),E=Mo(),O=Mo(),{nonce:T,disableStyleElements:A}=zC(),[k,B]=x.useState(!1),[K,D]=x.useState(!1),[G,ae]=x.useState(!1),[V,H]=x.useState(!1),[ee,Q]=x.useState(!1),[se,re]=x.useState(vx),[ue,le]=x.useState(vx),[P,R]=x.useState(DC),[$,Y]=x.useState(_C),F=x.useRef(null),I=x.useRef(null),N=x.useRef(null),_=x.useRef(null),Z=x.useRef(null),te=x.useRef(null),ie=x.useRef(null),oe=x.useRef(null),ce=x.useRef(0),ge=x.useRef(0),ye=x.useRef(0),Xe=x.useRef(0),Be=x.useRef("vertical"),tt=x.useRef(kC),ft=x.useRef(null);function we(Ae){const Ke=Ae?ae:D,Je=Ae?E:O;Ke(!0),Je.start(MC,()=>{Ke(!1)})}const Nt=qe(Ae=>{const Ke=Ae.x-tt.current.x,Je=Ae.y-tt.current.y;tt.current=Ae,Je!==0&&we(!0),Ke!==0&&we(!1)}),Bt=qe(()=>{const Ae=I.current;Ae&&ft.current===null&&(ft.current=Ae.style.scrollSnapType,Ae.style.scrollSnapType="none")}),di=qe(Ae=>{if(Ae.button!==0)return;if(oe.current!==null){const rn=Be.current==="vertical"?Z.current:te.current;if(rn!=null&&rn.hasPointerCapture(oe.current))return}oe.current=Ae.pointerId,ce.current=Ae.clientY,ge.current=Ae.clientX,Be.current=Ae.currentTarget.getAttribute("data-orientation");const Ke=I.current;Ke&&(ye.current=Ke.scrollTop,Xe.current=Ke.scrollLeft,Bt());const Je=Be.current==="vertical"?Z.current:te.current;Je==null||Je.setPointerCapture(Ae.pointerId)}),Va=qe(Ae=>{if(Ae.pointerId!==oe.current)return;oe.current=null,(Be.current==="vertical"?ae:D)(!1),ft.current!==null&&(I.current&&(I.current.style.scrollSnapType=ft.current),ft.current=null);const Ke=Be.current==="vertical"?Z.current:te.current;Ke!=null&&Ke.hasPointerCapture(Ae.pointerId)&&Ke.releasePointerCapture(Ae.pointerId)}),Pn=qe(Ae=>{if(Ae.pointerId!==oe.current)return;if(Ae.buttons%2===0){Va(Ae);return}const Ke=I.current;if(!Ke)return;const Je=Be.current==="vertical",rn=Je?Z.current:te.current,da=Je?N.current:_.current;if(!rn||!da)return;const hi=Je?"y":"x",mi=Tl(da,"padding",hi),Wn=Tl(rn,"margin",hi),Mt=Je?rn.offsetHeight:rn.offsetWidth,Et=(Je?da.offsetHeight:da.offsetWidth)-Mt-mi-Wn,pi=Je?Ae.clientY-ce.current:Ae.clientX-ge.current,zs=Et<=0?0:pi/Et,ks=Je?Ke.scrollHeight:Ke.scrollWidth,ea=Je?Ke.clientHeight:Ke.clientWidth,ma=(Je?ye.current:Xe.current)+zs*(ks-ea);Je?Ke.scrollTop=ma:Ke.scrollLeft=ma,Ae.preventDefault(),we(Je)});function In(Ae){H(Ae.pointerType==="touch")}function qn(Ae){if(In(Ae),Ae.pointerType!=="touch"){const Ke=wh(F.current,Ae.target);B(Ke)}}const fa=x.useMemo(()=>({scrolling:K||G,hasOverflowX:!$.x,hasOverflowY:!$.y,overflowXStart:P.xStart,overflowXEnd:P.xEnd,overflowYStart:P.yStart,overflowYEnd:P.yEnd,cornerHidden:$.corner}),[K,G,$.x,$.y,$.corner,P]),Al={role:"presentation",onPointerEnter:qn,onPointerMove:qn,onPointerDown:In,onPointerLeave(){B(!1)},style:{position:"relative","--scroll-area-corner-height":`${se.height}px`,"--scroll-area-corner-width":`${se.width}px`}},Rt=qt("div",l,{state:fa,ref:[s,F],props:[Al,y],stateAttributesMapping:Rh}),Os=x.useMemo(()=>({handlePointerDown:di,handlePointerMove:Pn,handlePointerUp:Va,handleScroll:Nt,disableViewportSnap:Bt,cornerSize:se,setCornerSize:re,thumbSize:ue,setThumbSize:le,hasMeasuredScrollbar:ee,setHasMeasuredScrollbar:Q,touchModality:V,cornerRef:ie,scrollingX:K,scrollingY:G,hovering:k,setHovering:B,viewportRef:I,scrollbarYRef:N,scrollbarXRef:_,thumbYRef:Z,thumbXRef:te,rootId:j,hiddenState:$,setHiddenState:Y,overflowEdges:P,setOverflowEdges:R,viewportState:fa,overflowEdgeThreshold:{xStart:p,xEnd:g,yStart:b,yEnd:S}}),[di,Pn,Va,Nt,Bt,se,ue,ee,V,K,G,k,j,$,P,fa,p,g,b,S]);return r.jsxs(yv.Provider,{value:Os,children:[!A&&xv.getElement(T),Rt]})});function UC(a){const l=typeof a=="number"?{xStart:a,xEnd:a,yStart:a,yEnd:a}:a;return{xStart:Math.max(0,(l==null?void 0:l.xStart)||0),xEnd:Math.max(0,(l==null?void 0:l.xEnd)||0),yStart:Math.max(0,(l==null?void 0:l.yStart)||0),yEnd:Math.max(0,(l==null?void 0:l.yEnd)||0)}}const HC=x.createContext(void 0),qC=x.createContext(void 0);function Mh(){const a=x.useContext(qC);return(a==null?void 0:a.direction)??"ltr"}function vv(a,l=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){return Math.max(l,Math.min(a,s))}const bx=1;function Sx(a,l){if(l<=0)return 0;const s=vv(a,0,l),u=s,f=l-s,d=u<=bx,m=f<=bx;return d&&m?u<=f?0:l:d?0:m?l:s}const bv=["--scroll-area-overflow-x-start","--scroll-area-overflow-x-end","--scroll-area-overflow-y-start","--scroll-area-overflow-y-end"];let jx=!1;function BC(){jx||Eh||(typeof CSS<"u"&&"registerProperty"in CSS&&bv.forEach(a=>{try{CSS.registerProperty({name:a,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),jx=!0)}const QC=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,{viewportRef:y,scrollbarYRef:p,scrollbarXRef:g,thumbYRef:b,thumbXRef:S,cornerRef:j,cornerSize:E,setCornerSize:O,setThumbSize:T,rootId:A,setHiddenState:k,hiddenState:B,setHasMeasuredScrollbar:K,handleScroll:D,touchModality:G,setHovering:ae,setOverflowEdges:V,overflowEdgeThreshold:H,viewportState:ee}=Yo(),Q=Mh(),se=x.useRef(!0),re=x.useRef([NaN,NaN,NaN,NaN]),ue=Mo(),le=Mo(),P=qe(()=>{const I=y.current,N=p.current,_=g.current,Z=b.current,te=S.current,ie=j.current;if(!I)return;const oe=I.scrollHeight,ce=I.scrollWidth,ge=I.clientHeight,ye=I.clientWidth,Xe=I.scrollTop,Be=I.scrollLeft,tt=re.current,ft=Number.isNaN(tt[0]);if(tt[0]=ge,tt[1]=oe,tt[2]=ye,tt[3]=ce,ft&&K(!0),oe===0||ce===0)return;const we=YC(I),Nt=we.y,Bt=we.x,di=ye/ce,Va=ge/oe,Pn=Math.max(0,ce-ye),In=Math.max(0,oe-ge);let qn=0,fa=0;Bt||(qn=Sx(Q==="rtl"?-Be:Be,Pn),fa=Pn-qn);const Al=Nt?0:Sx(Xe,In),Rt=Nt?0:In-Al,Os=Bt?0:ye,Ae=Nt?0:ge;let Ke=0,Je=0;!Bt&&!Nt&&(Ke=(N==null?void 0:N.offsetWidth)||0,Je=(_==null?void 0:_.offsetHeight)||0);const rn=E.width===0&&E.height===0,da=rn?Ke:0,hi=rn?Je:0,mi=Tl(_,"padding","x"),Wn=Tl(N,"padding","y"),Mt=Tl(te,"margin","x"),vn=Tl(Z,"margin","y"),Et=Os-mi-Mt,pi=Ae-Wn-vn,zs=_?Math.min(_.offsetWidth-da,Et):Et,ks=N?Math.min(N.offsetHeight-hi,pi):pi,ea=Math.max(Kd,zs*di),ha=Math.max(Kd,ks*Va);if(T(At=>fo(At,{width:ea,height:ha})),N&&Z){const At=N.offsetHeight-ha-Wn-vn,Bn=Nx(Z,"--scroll-area-thumb-height",Xe,In,oe,ha,At);Z.style.transform=`translate3d(0,${Bn}px,0)`}if(_&&te){const At=_.offsetWidth-ea-mi-Mt,Bn=Q==="rtl"?-Be:Be,Vr=Nx(te,"--scroll-area-thumb-width",Bn,Pn,ce,ea,At);te.style.transform=`translate3d(${Q==="rtl"?-Vr:Vr}px,0,0)`}const ma=[qn,fa,Al,Rt];bv.forEach((At,Bn)=>{I.style.setProperty(At,`${ma[Bn]}px`)}),ie&&O(At=>fo(At,{width:Ke,height:Je})),k(At=>fo(At,we));const pa={xStart:!Bt&&qn>H.xStart,xEnd:!Bt&&fa>H.xEnd,yStart:!Nt&&Al>H.yStart,yEnd:!Nt&&Rt>H.yEnd};V(At=>fo(At,pa))});Ve(()=>{BC()},[]),Ve(()=>{queueMicrotask(P)},[P,B,Q,H.xStart,H.xEnd,H.yStart,H.yEnd]),Ve(()=>{var I;(I=y.current)!=null&&I.matches(":hover")&&ae(!0)},[y,ae]),Ve(()=>{const I=y.current;if(typeof ResizeObserver>"u"||!I)return;let N=!1;const _=new ResizeObserver(()=>{if(!N){N=!0;const Z=re.current;if(Z[0]===I.clientHeight&&Z[1]===I.scrollHeight&&Z[2]===I.clientWidth&&Z[3]===I.scrollWidth)return}P()});return _.observe(I),le.start(0,()=>{const Z=I.getAnimations({subtree:!0});Z.length!==0&&Promise.allSettled(Z.map(te=>te.finished)).then(P).catch(()=>{})}),()=>{_.disconnect(),le.clear()}},[P,y,le]);function R(){se.current=!1}const $={role:"presentation",...A&&{"data-id":`${A}-viewport`},tabIndex:B.x&&B.y?-1:0,className:xv.className,style:{overflow:"scroll"},onScroll(){y.current&&(P(),(G||!se.current)&&D({x:y.current.scrollLeft,y:y.current.scrollTop}),ue.start(100,()=>{se.current=!0}))},onWheel:R,onPointerMove:R,onPointerEnter:R,onKeyDown:R},Y=qt("div",l,{ref:[s,y],state:ee,props:[$,m],stateAttributesMapping:Rh}),F=x.useMemo(()=>({computeThumbPosition:P}),[P]);return r.jsx(HC.Provider,{value:F,children:Y})});function YC(a){const l=a.clientHeight>=a.scrollHeight,s=a.clientWidth>=a.scrollWidth;return{y:l,x:s,corner:l||s}}function fo(a,l){for(const s in l)if(a[s]!==l[s])return l;return a}function Nx(a,l,s,u,f,d,m){const y=vv(s,0,u),p=s-y,g=Math.max(Kd,d*f/(f+Math.abs(p)));return a.style.setProperty(l,p?`${g}px`:""),(u?y/u*m:0)+(p>0?d-g:0)}function Sv(a,l,s,u){return a.addEventListener(l,s,u),()=>{a.removeEventListener(l,s,u)}}const jv=x.createContext(void 0);function GC(){const a=x.useContext(jv);if(a===void 0)throw new Error(Ya(54));return a}const VC=x.forwardRef(function(l,s){const{render:u,className:f,orientation:d="vertical",keepMounted:m=!1,style:y,...p}=l,{hovering:g,scrollingX:b,scrollingY:S,hiddenState:j,scrollbarYRef:E,scrollbarXRef:O,viewportRef:T,thumbYRef:A,thumbXRef:k,handlePointerDown:B,handlePointerUp:K,handleScroll:D,disableViewportSnap:G,rootId:ae,thumbSize:V,hasMeasuredScrollbar:H,viewportState:ee}=Yo(),Q=d==="vertical",se={...ee,hovering:g,scrolling:Q?S:b,orientation:d},re=Mh(),ue=!H&&!m,le=Q?j.y:j.x,P=m||!le;x.useEffect(()=>{if(!P)return;const Y=T.current,F=Q?E.current:O.current;if(!F)return;function I(N){if(!Y||N.ctrlKey)return;const _=!Q,Z=_?"scrollLeft":"scrollTop",te=_?N.deltaX:N.deltaY;if(te===0)return;const ie=_?Y.scrollWidth-Y.clientWidth:Y.scrollHeight-Y.clientHeight,oe=_&&re==="rtl"?-ie:0,ce=_&&re==="rtl"?0:ie,ge=Y[Z];ge<=oe&&te<0||ge>=ce&&te>0||(N.preventDefault(),Y[Z]=Math.min(ce,Math.max(oe,ge+te)),D({x:Y.scrollLeft,y:Y.scrollTop}))}return Sv(F,"wheel",I,{passive:!1})},[re,D,Q,O,E,P,T]);const R={...ae&&{"data-id":`${ae}-scrollbar`},onPointerDown(Y){if(Y.button!==0)return;const F=Vd(Y.nativeEvent),I=Q?A.current:k.current;if(I&&wh(I,F))return;const N=T.current;if(!N)return;const _=Q?E.current:O.current;if(!I||!_)return;const Z=Q?"y":"x",te=Tl(I,"margin",Z),ie=Tl(_,"padding",Z),oe=Q?I.offsetHeight:I.offsetWidth,ce=_.getBoundingClientRect(),ge=Q?Y.clientY-ce.top-oe/2-ie+te/2:Y.clientX-ce.left-oe/2-ie+te/2,ye=Q?N.scrollHeight:N.scrollWidth,Xe=Q?N.clientHeight:N.clientWidth,tt=(Q?_.offsetHeight:_.offsetWidth)-oe-ie-te;if(tt<=0)return;const ft=ge/tt,we=ye-Xe;G(),Q?N.scrollTop=ft*we:re==="rtl"?N.scrollLeft=-(1-ft)*we:N.scrollLeft=ft*we,D({x:N.scrollLeft,y:N.scrollTop}),B(Y)},onPointerUp:K,onPointerCancel:K,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:ue?"hidden":void 0,...Q?{top:0,bottom:"var(--scroll-area-corner-height)",insetInlineEnd:0,"--scroll-area-thumb-height":`${V.height}px`}:{insetInlineStart:0,insetInlineEnd:"var(--scroll-area-corner-width)",bottom:0,"--scroll-area-thumb-width":`${V.width}px`}}},$=qt("div",l,{ref:[s,Q?E:O],state:se,props:[R,p],stateAttributesMapping:Rh});return P?r.jsx(jv.Provider,{value:d,children:$}):null}),XC=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,{thumbYRef:y,thumbXRef:p,handlePointerDown:g,handlePointerMove:b,handlePointerUp:S,scrollingX:j,scrollingY:E,hasMeasuredScrollbar:O}=Yo(),T=GC(),A=T==="vertical";return qt("div",l,{ref:[s,A?y:p],state:{scrolling:A?E:j,orientation:T},props:[{onPointerDown:g,onPointerMove:b,onPointerUp:S,onPointerCancel:S,style:{visibility:O?void 0:"hidden",...A?{height:"var(--scroll-area-thumb-height)"}:{width:"var(--scroll-area-thumb-width)"}}},m]})}),KC=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,{cornerRef:y,cornerSize:p,hiddenState:g}=Yo(),b=qt("div",l,{ref:[s,y],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:p.width,height:p.height}},m]});return g.corner?null:b});function _n({className:a,...l}){return r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:ve("w-full caption-bottom text-sm",a),...l})})}function Ln({className:a,...l}){return r.jsx("thead",{"data-slot":"table-header",className:ve("[&_tr]:border-b",a),...l})}function Un({className:a,...l}){return r.jsx("tbody",{"data-slot":"table-body",className:ve("[&_tr:last-child]:border-0",a),...l})}function ct({className:a,...l}){return r.jsx("tr",{"data-slot":"table-row",className:ve("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...l})}function je({className:a,...l}){return r.jsx("th",{"data-slot":"table-head",className:ve("h-12 px-3 text-left align-middle text-xs font-medium tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0",a),...l})}function Ne({className:a,...l}){return r.jsx("td",{"data-slot":"table-cell",className:ve("p-3 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...l})}const Nv=x.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function $C(){return x.useContext(Nv)}function Ev(a={}){const{guess:l,label:s,metadata:u,textRef:f,index:d}=a,{register:m,unregister:y,subscribeMapChange:p,nextIndexRef:g}=$C(),b=x.useRef(-1),[S,j]=x.useState(d==null&&l?()=>{if(b.current===-1){const A=g.current;g.current+=1,b.current=A}return b.current}:-1),E=d??S,O=x.useRef(null),T=x.useCallback(A=>{const k=O.current;k&&y(k),O.current=A,A&&m(A,{metadata:u??null,index:d??null,label:s,textRef:f})},[d,m,y,u,s,f]);return Ve(()=>{if(d==null)return p(A=>{var B;const k=O.current?(B=A.get(O.current))==null?void 0:B.index:null;k!=null&&j(k)})},[d,p]),{ref:T,index:E}}function ZC(a){const l=ca(FC,a).current;return l.next=a,Ve(l.effect),l}function FC(a){const l={current:a,next:a,effect:()=>{l.current=l.next}};return l}const wv={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},JC={...wv,position:"fixed",top:0,left:0},PC={...wv,position:"absolute"},$d="ArrowUp",Zd="ArrowDown",Fd="ArrowLeft",Jd="ArrowRight",Pd="Home",Id="End",IC=new Set([$d,Zd,Fd,Jd,Pd,Id]),WC="Shift",e3=[WC,"Control","Alt","Meta"];function t3(a){return Ho(a)&&a.tagName==="INPUT"}function Ex(a){return!!(t3(a)&&a.selectionStart!=null||Ho(a)&&a.tagName==="TEXTAREA")}function wx(a,l,s,u){if(!a||!l||!l.scrollTo)return;let f=a.scrollLeft,d=a.scrollTop;const m=a.clientWidth<a.scrollWidth,y=a.clientHeight<a.scrollHeight;if(m&&u!=="vertical"){const p=Cx(a,l,"left"),g=ho(a),b=ho(l);s==="ltr"&&(p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight?f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight:p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft&&(f=p-b.scrollMarginLeft-g.scrollPaddingLeft)),s==="rtl"&&(p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft?f=p-b.scrollMarginLeft-g.scrollPaddingLeft:p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight&&(f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight))}if(y&&u!=="horizontal"){const p=Cx(a,l,"top"),g=ho(a),b=ho(l);p-b.scrollMarginTop<a.scrollTop+g.scrollPaddingTop?d=p-b.scrollMarginTop-g.scrollPaddingTop:p+l.offsetHeight+b.scrollMarginBottom>a.scrollTop+a.clientHeight-g.scrollPaddingBottom&&(d=p+l.offsetHeight+b.scrollMarginBottom-a.clientHeight+g.scrollPaddingBottom)}a.scrollTo({left:f,top:d,behavior:"auto"})}function Cx(a,l,s){const u=s==="left"?"offsetLeft":"offsetTop";let f=0;for(;l.offsetParent&&(f+=l[u],l.offsetParent!==a);)l=l.offsetParent;return f}function ho(a){const l=getComputedStyle(a);return{scrollMarginTop:parseFloat(l.scrollMarginTop)||0,scrollMarginRight:parseFloat(l.scrollMarginRight)||0,scrollMarginBottom:parseFloat(l.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(l.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(l.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(l.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(l.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(l.scrollPaddingLeft)||0}}function n3(a){return V0(19)?a:a?"true":void 0}function Cv(a){const{children:l,elementsRef:s,labelsRef:u,onMapChange:f}=a,d=qe(f),[,m]=x.useState(!1),y=ca(l3).current,p=ca(a3).current,g=x.useRef(0),b=x.useRef(!0),S=x.useRef([]),j=x.useRef(null),E=qe(()=>{b.current||(b.current=!0,m(G=>!G))}),O=qe((G,ae)=>{p.set(G,ae),E()}),T=qe(G=>{p.delete(G),E()}),A=qe(G=>{const ae=new Map;return s.current.length=0,u&&(u.current.length=0),G.forEach(V=>{var H,ee;ae.set(V.element,{...V.registration.metadata??{},index:V.index}),s.current[V.index]=V.element,u&&(u.current[V.index]=V.registration.label!==void 0?V.registration.label:((ee=(H=V.registration.textRef)==null?void 0:H.current)==null?void 0:ee.textContent)??V.element.textContent)}),g.current=s.current.length,ae});function k(G){var H;if((H=j.current)==null||H.disconnect(),j.current=null,typeof MutationObserver!="function"||G.length<2)return;const ae=new MutationObserver(ee=>{if(!r3(ee))return;let Q=null;for(const se of G)if(se.isConnected){if(Q&&Tv(Q,se)>0){ae.disconnect(),E();return}Q=se}});j.current=ae;const V=new Set;for(let ee=1;ee<G.length;ee+=1){const Q=s3(G[ee-1],G[ee]);Q&&V.add(Q)}V.forEach(ee=>ae.observe(ee,{childList:!0}))}const B=qe(()=>{const[G,ae]=i3(p),V=A(G);k(ae),S.current=G,b.current=!1,y.forEach(H=>H(V)),d(V)});Ve(()=>(b.current||A(S.current),()=>{s.current=[],u&&(u.current=[])}),[s,u,A]),Ve(()=>{b.current&&B()}),Ve(()=>()=>{var G;(G=j.current)==null||G.disconnect(),b.current=!0},[]);const K=qe(G=>(y.add(G),()=>{y.delete(G)})),D=x.useMemo(()=>({register:O,unregister:T,subscribeMapChange:K,nextIndexRef:g}),[O,T,K,g]);return r.jsx(Nv.Provider,{value:D,children:l})}function a3(){return new Map}function l3(){return new Set}function i3(a){const l=new Set,s=[],u=[];a.forEach((d,m)=>{if(!m.isConnected)return;const y=d.index,p={index:y??-1,element:m,registration:d};y===null?u.push(p):y>=0&&(l.add(y),s.push(p))});let f=0;return u.sort((d,m)=>Tv(d.element,m.element)),u.forEach(d=>{for(;l.has(f);)f+=1;d.index=f,s.push(d),f+=1}),l.size>0&&s.sort((d,m)=>d.index-m.index),[s,u.map(d=>d.element)]}function s3(a,l){let s=a.parentElement;for(;s&&!s.contains(l);)s=s.parentElement;return s}function r3(a){for(const l of a)for(let s=0;s<l.removedNodes.length;s+=1)if(l.removedNodes[s].isConnected)return!0;return!1}function Tv(a,l){return a.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function u3(a,l){const s=x.useRef(a),u=qe(l);Ve(()=>{s.current!==a&&u(s.current),s.current=a},[a,u])}function o3(a={}){const{highlightItemOnHover:l,highlightedIndex:s,onHighlightedIndexChange:u}=Sh(),{ref:f,index:d}=Ev(a),m=s===d,y=x.useRef(null),p=Ss(f,y);return{compositeProps:{tabIndex:m?0:-1,onFocus(){u(d)},onMouseMove(){const b=y.current;if(!l||!b)return;const S=b.hasAttribute("disabled")||b.ariaDisabled==="true";!m&&!S&&b.focus()}},compositeRef:p,index:d}}function c3(a){return a==null||a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true"}const Rv="data-composite-item-active",f3=[];function d3(a){const{loopFocus:l=!0,orientation:s="both",grid:u,onLoop:f,direction:d,highlightedIndex:m,onHighlightedIndexChange:y,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:b,disabledIndices:S,modifierKeys:j=f3}=a,[E,O]=x.useState(0),T=u!=null,A=x.useRef(null),k=Ss(A,p),B=x.useRef([]),K=x.useRef(!1),D=m??E,G=qe((Q,se=!1)=>{if((y??O)(Q),se){const re=B.current[Q];wx(A.current,re,d,s)}}),ae=qe(Q=>{var le;if(Q.size===0||K.current)return;K.current=!0;const se=Array.from(Q.keys()),re=se.find(P=>P==null?void 0:P.hasAttribute(Rv))??null,ue=re?((le=Q.get(re))==null?void 0:le.index)??-1:-1;if(ue!==-1)G(ue);else if(Xd(se,D,S)){const P=zr(se,{disabledIndices:S});bd(se,P)||G(P)}wx(A.current,re,d,s)});Ve(()=>{if(S==null||m!=null||!K.current)return;const Q=B.current;if(Xd(Q,D,S)){const se=zr(Q,{disabledIndices:S});bd(Q,se)||G(se)}},[S,m,D,B,G]);const V=qe((Q,se,re)=>f?f(Q,se,re,B):re),H=qe(Q=>{const se=Q.key===Pd||Q.key===Id;if(!IC.has(Q.key)||!g&&se||h3(Q,j)||!A.current)return;const ue=d==="rtl",le=ue?Fd:Jd,P=ue?Jd:Fd,R=s==="vertical"?Zd:le,$=s==="vertical"?$d:P,Y=Vd(Q.nativeEvent);if(Y!=null&&Ex(Y)&&!c3(Y)){const te=Y.selectionStart,ie=Y.selectionEnd,oe=Y.value;if(te==null||Q.shiftKey||te!==ie||Q.key!==$&&te<oe.length||Q.key!==R&&te>0)return}let F=D;const I=gC(B,S),N=yC(B,S);u!=null&&(F=u({disabledIndices:S,elementsRef:B,event:Q,highlightedIndex:D,loopFocus:l,maxIndex:N,minIndex:I,onLoop:V,orientation:s,rtl:ue}));const _=s!=="vertical"&&Q.key===le||s!=="horizontal"&&Q.key===Zd,Z=s!=="vertical"&&Q.key===P||s!=="horizontal"&&Q.key===$d;g&&(Q.key===Pd?F=I:Q.key===Id&&(F=N)),F===D&&(_||Z)&&(l&&F===N&&_?(F=I,f&&(F=f(Q,D,F,B))):l&&F===I&&Z?(F=N,f&&(F=f(Q,D,F,B))):F=zr(B.current,{startingIndex:F,decrement:Z,disabledIndices:S})),F!==D&&!bd(B.current,F)&&(b&&Q.stopPropagation(),(T||se||_||Z)&&Q.preventDefault(),G(F,!0),queueMicrotask(()=>{var te;(te=B.current[F])==null||te.focus()}))});return{props:{ref:k,onFocus(Q){const se=A.current,re=Vd(Q.nativeEvent);!se||re==null||!Ex(re)||re.setSelectionRange(0,re.value.length)},onKeyDown:H},highlightedIndex:D,onHighlightedIndexChange:G,elementsRef:B,onMapChange:ae,relayKeyboardEvent:H}}function h3(a,l){for(const s of e3)if(!l.includes(s)&&a.getModifierState(s))return!0;return!1}function m3(a){const{render:l,className:s,style:u,refs:f=To,props:d=To,state:m=Ha,stateAttributesMapping:y,highlightedIndex:p,onHighlightedIndexChange:g,orientation:b,grid:S,loopFocus:j,onLoop:E,enableHomeAndEndKeys:O,onMapChange:T,stopEventPropagation:A=!0,rootRef:k,disabledIndices:B,modifierKeys:K,highlightItemOnHover:D=!1,tag:G="div",...ae}=a,V=Mh(),{props:H,highlightedIndex:ee,onHighlightedIndexChange:Q,elementsRef:se,onMapChange:re,relayKeyboardEvent:ue}=d3({grid:S,loopFocus:j,onLoop:E,orientation:b,highlightedIndex:p,onHighlightedIndexChange:g,rootRef:k,stopEventPropagation:A,enableHomeAndEndKeys:O,direction:V,disabledIndices:B,modifierKeys:K}),le=qt(G,a,{state:m,ref:f,props:[H,...d,ae],stateAttributesMapping:y}),P=x.useMemo(()=>({highlightedIndex:ee,onHighlightedIndexChange:Q,highlightItemOnHover:D,relayKeyboardEvent:ue}),[ee,Q,D,ue]);return r.jsx(sv.Provider,{value:P,children:r.jsx(Cv,{elementsRef:se,onMapChange:R=>{T==null||T(R),re(R)},children:le})})}const Mv=x.createContext(void 0);function p3(){const a=x.useContext(Mv);if(a===void 0)throw new Error(Ya(63));return a}const Av={...rv,checked(a){return a?{"data-checked":""}:{"data-unchecked":""}}},g3=x.forwardRef(function(l,s){const{checked:u,className:f,defaultChecked:d,"aria-labelledby":m,form:y,id:p,inputRef:g,name:b,nativeButton:S=!1,onCheckedChange:j,readOnly:E=!1,required:O=!1,disabled:T=!1,render:A,uncheckedValue:k,value:B,style:K,...D}=l,{clearErrors:G}=uv(),{state:ae,setTouched:V,setDirty:H,validityData:ee,setFilled:Q,setFocused:se,validationMode:re,disabled:ue,name:le,validation:P}=jh(),{labelId:R}=Nh(),$=ue||T,Y=le??b,F=x.useRef(null),I=Ss(F,g,P.inputRef),N=x.useRef(null),_=ci(),Z=ov({id:p,implicit:!1,controlRef:N}),te=S?void 0:Z,[ie,oe]=Bo({controlled:u,default:!!d,name:"Switch",state:"checked"});gv(N,_,ie,void 0,!$,b),Ve(()=>{F.current&&Q(F.current.checked)},[Q]),u3(ie,()=>{G(Y),H(ie!==ee.initialValue),Q(ie),P.change(ie)});const{getButtonProps:ce,buttonRef:ge}=qo({disabled:$,native:S}),ye=cC(m,R,F,!S,te),Xe={id:S?Z:_,role:"switch","aria-checked":ie,"aria-readonly":E||void 0,"aria-required":O||void 0,"aria-labelledby":ye,onFocus(){$||se(!0)},onBlur(){const we=F.current;!we||$||(V(!0),se(!1),re==="onBlur"&&P.commit(we.checked))},onClick(we){if(E||$)return;we.preventDefault();const Nt=F.current;Nt&&So(Nt,we)}},Be={...P.getValidationProps($),checked:ie,disabled:$,form:y,id:te,name:Y,required:O,style:Y?PC:JC,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:I,onChange(we){if(we.nativeEvent.defaultPrevented)return;if(E){we.preventDefault();return}const Nt=we.currentTarget.checked,Bt=As(Qo,we.nativeEvent);j==null||j(Nt,Bt),!Bt.isCanceled&&oe(Nt)},onClick(we){we.stopPropagation()},onFocus(){var we;(we=N.current)==null||we.focus()},...B!==void 0?{value:B}:Ha},tt=x.useMemo(()=>({...ae,checked:ie,disabled:$,readOnly:E,required:O}),[ae,ie,$,E,O]),ft=qt("span",l,{state:tt,ref:[s,N,ge],props:[Xe,D,ce,we=>P.getValidationProps($,we)],stateAttributesMapping:Av});return r.jsxs(Mv.Provider,{value:tt,children:[ft,!ie&&Y&&k!==void 0&&r.jsx("input",{type:"hidden",form:y,name:Y,value:k,disabled:$}),r.jsx("input",{...Be,suppressHydrationWarning:!0})]})}),y3=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,y=p3();return qt("span",l,{state:y,ref:s,stateAttributesMapping:Av,props:m})}),Ov=x.createContext(void 0);function Ah(){const a=x.useContext(Ov);if(a===void 0)throw new Error(Ya(64));return a}const Go={tabActivationDirection:a=>({"data-activation-direction":a})},x3=x.forwardRef(function(l,s){const{className:u,defaultValue:f=0,onValueChange:d,orientation:m="horizontal",render:y,value:p,style:g,...b}=l,S=l.defaultValue!==void 0,j=x.useRef([]),[E,O]=x.useState(()=>new Map),[T,A]=Bo({controlled:p,default:f,name:"Tabs",state:"value"}),k=p!==void 0,[B,K]=x.useState(()=>new Map),D=x.useRef(void 0),G=x.useCallback(ge=>Wd(B,ge),[B]),[ae,V]=x.useState(()=>({previousValue:T,tabActivationDirection:"none"})),{previousValue:H,tabActivationDirection:ee}=ae;let Q=ee,se=!1;H!==T&&(Q=Tx(H,T,m,B),se=H!=null&&T!=null&&G(T)==null);const re=se?H:T,ue=H!==re||ee!==Q;Ve(()=>{ue&&V({previousValue:re,tabActivationDirection:Q})},[re,ue,Q]);const le=qe((ge,ye)=>{const Xe=Tx(T,ge,m,B);ye.activationDirection=Xe,d==null||d(ge,ye),!ye.isCanceled&&A(ge)}),P=qe((ge,ye)=>{d==null||d(ge,As(ye,void 0,void 0,{activationDirection:"none"}))}),R=qe((ge,ye)=>(O(Xe=>{const Be=new Map(Xe);return Be.set(ge,ye),Be}),()=>{O(Xe=>{if(Xe.get(ge)!==ye)return Xe;const Be=new Map(Xe);return Be.delete(ge),Be})})),$=x.useCallback(ge=>E.get(ge),[E]),Y=x.useCallback(ge=>{for(const ye of B.values())if(ge===ye.value)return ye.id},[B]),F=x.useMemo(()=>({getTabElementBySelectedValue:G,getTabIdByPanelValue:Y,getTabPanelIdByValue:$,onValueChange:le,orientation:m,registerMountedTabPanel:R,setTabMap:K,tabActivationDirection:Q,value:T}),[G,Y,$,le,m,R,K,Q,T]),I=x.useMemo(()=>{for(const ge of B.values())if(ge.value===T)return ge},[B,T]),N=x.useMemo(()=>{for(const ge of B.values())if(!ge.disabled)return ge.value},[B]),_=x.useRef(!S),Z=x.useRef(f),te=x.useRef(S),ie=x.useRef(!1);Ve(()=>{var tt;if(k)return;function ge(ft,we){A(ft),V({previousValue:ft,tabActivationDirection:"none"}),P(ft,we),_.current=!1}if(B.size===0){ie.current&&T!==null&&!((tt=D.current)!=null&&tt.isConnected)&&ge(null,yx);return}ie.current=!0,D.current=B.keys().next().value;const ye=I==null?void 0:I.disabled,Xe=I==null&&T!==null;if(!ye&&T===Z.current&&(te.current=!1),te.current&&ye&&T===Z.current)return;const Be=_.current;if(ye||Xe){const ft=N??null;if(T===ft){_.current=!1;return}let we=yx;Be?we=xx:ye&&(we=CC),ge(ft,we);return}Be&&I!=null&&(P(T,xx),_.current=!1)},[N,k,P,I,A,B,T]);const ce=qt("div",l,{state:{orientation:m,tabActivationDirection:Q},ref:s,props:b,stateAttributesMapping:Go});return r.jsx(Ov.Provider,{value:F,children:r.jsx(Cv,{elementsRef:j,children:ce})})});function Wd(a,l){for(const[s,u]of a.entries())if(l===u.value)return s;return null}function Tx(a,l,s,u){if(a==null||l==null)return"none";const[f,d,m]=s==="horizontal"?["left","left","right"]:["top","up","down"],y=Wd(u,a),p=Wd(u,l);if(y==null||p==null)return y!==p&&(typeof a=="number"||typeof a=="string")&&typeof a==typeof l?l>a?m:d:"none";const g=y.getBoundingClientRect()[f],b=p.getBoundingClientRect()[f];return b<g?d:b>g?m:"none"}const zv=x.createContext(void 0);function v3(){const a=x.useContext(zv);if(a===void 0)throw new Error(Ya(65));return a}const b3=x.forwardRef(function(l,s){const{className:u,disabled:f=!1,render:d,value:m,id:y,nativeButton:p=!0,style:g,...b}=l,{value:S,getTabPanelIdByValue:j,onValueChange:E,orientation:O,tabActivationDirection:T}=Ah(),{activateOnFocus:A,registerTabResizeObserverElement:k,tabsListElement:B}=v3(),{highlightedIndex:K,onHighlightedIndexChange:D}=Sh(),G=ci(y),ae=x.useMemo(()=>({disabled:f,id:G,value:m}),[f,G,m]),{compositeProps:V,compositeRef:H,index:ee}=o3({metadata:ae}),Q=m===S,se=x.useRef(!1),re=x.useRef(null),ue=qe(ie=>{var oe;(oe=re.current)==null||oe.call(re),re.current=ie?k(ie):null});Ve(()=>{if(se.current){se.current=!1;return}if(!(Q&&ee>-1&&K!==ee))return;const ie=B;if(ie!=null){const oe=fv(Gd(ie));if(oe&&wh(ie,oe))return}f||D(ee)},[Q,ee,K,D,f,B]);const{getButtonProps:le,buttonRef:P}=qo({disabled:f,native:p,focusableWhenDisabled:!0}),R=j(m),$=x.useRef(!1),Y=x.useRef(!1);function F(ie){E(m,As(Qo,ie.nativeEvent,void 0,{activationDirection:"none"}))}function I(ie){Q||f||F(ie)}function N(ie){Q||f||A&&(!$.current||Y.current)&&F(ie)}function _(ie){if(Q||f)return;$.current=!0,Y.current=ie.button===0;const oe=Gd(ie.currentTarget);function ce(){$.current=!1,Y.current=!1,oe.removeEventListener("pointerup",ce),oe.removeEventListener("pointercancel",ce)}oe.addEventListener("pointerup",ce),oe.addEventListener("pointercancel",ce)}return qt("button",l,{state:{disabled:f,active:Q,orientation:O,tabActivationDirection:T},ref:[s,P,H,ue],props:[V,{role:"tab","aria-controls":R,"aria-selected":Q,id:G,onClick:I,onFocus:N,onPointerDown:_,[Rv]:Q?"":void 0,onKeyDownCapture(){se.current=!0}},b,le],stateAttributesMapping:Go})}),S3={...Go,...Th},j3=x.forwardRef(function(l,s){const{className:u,value:f,render:d,keepMounted:m=!1,style:y,...p}=l,{value:g,getTabIdByPanelValue:b,orientation:S,tabActivationDirection:j,registerMountedTabPanel:E}=Ah(),O=ci(),{ref:T,index:A}=Ev(),k=f===g,{mounted:B,transitionStatus:K,setMounted:D}=pv(k),G=!B,ae=b(f),V={hidden:G,orientation:S,tabActivationDirection:j,transitionStatus:K},H=x.useRef(null),ee=qt("div",l,{state:V,ref:[s,T,H],props:[{"aria-labelledby":ae,hidden:G,id:O,role:"tabpanel",tabIndex:k?0:-1,inert:n3(!k),"data-index":A},p],stateAttributesMapping:S3});return mv({open:k,ref:H,onComplete(){k||D(!1)}}),Ve(()=>{if(!(O==null||G&&!m))return E(f,O)},[G,m,f,O,E]),m||B?ee:null}),N3=x.forwardRef(function(l,s){const{activateOnFocus:u=!1,className:f,loopFocus:d=!0,render:m,style:y,...p}=l,{orientation:g,setTabMap:b,tabActivationDirection:S}=Ah(),[j,E]=x.useState(0),[O,T]=x.useState(null),A=x.useRef(new Set),k=x.useRef(new Set),B=x.useRef(null);Ve(()=>{if(typeof ResizeObserver>"u")return;const H=new ResizeObserver(()=>{A.current.forEach(ee=>{ee()})});return B.current=H,O&&H.observe(O),k.current.forEach(ee=>{H.observe(ee)}),()=>{H.disconnect(),B.current=null}},[O]);const K=qe(H=>(A.current.add(H),()=>{A.current.delete(H)})),D=qe(H=>{var ee;return k.current.add(H),(ee=B.current)==null||ee.observe(H),()=>{var Q;k.current.delete(H),(Q=B.current)==null||Q.unobserve(H)}}),G={orientation:g,tabActivationDirection:S},ae={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},V=x.useMemo(()=>({activateOnFocus:u,registerIndicatorUpdateListener:K,registerTabResizeObserverElement:D,tabsListElement:O}),[u,K,D,O]);return r.jsx(zv.Provider,{value:V,children:r.jsx(m3,{render:m,className:f,style:y,state:G,refs:[s,T],props:[ae,p],stateAttributesMapping:Go,highlightedIndex:j,enableHomeAndEndKeys:!0,loopFocus:d,orientation:g,onHighlightedIndexChange:E,onMapChange:b,disabledIndices:To})})});function E3(a){const{open:l,defaultOpen:s,onOpenChange:u,disabled:f}=a,[d,m]=Bo({controlled:l,default:s,name:"Collapsible",state:"open"}),{mounted:y,setMounted:p,transitionStatus:g}=pv(d,!0,!0),b=ci(),[S,j]=x.useState(),E=S===null?void 0:S??b,O=qe(T=>{const A=!d,k=As(wC,T.nativeEvent);u(A,k),!k.isCanceled&&m(A)});return x.useMemo(()=>({defaultPanelId:b,disabled:f,handleTrigger:O,mounted:y,open:d,panelId:E,setMounted:p,setOpen:m,setPanelIdState:j,transitionStatus:g}),[b,f,O,y,d,E,p,m,j,g])}const kv=x.createContext(void 0);function Dv(){const a=x.useContext(kv);if(a===void 0)throw new Error(Ya(15));return a}let Oh=(function(a){return a.open="data-open",a.closed="data-closed",a[a.startingStyle=gx.startingStyle]="startingStyle",a[a.endingStyle=gx.endingStyle]="endingStyle",a})({}),w3=(function(a){return a.panelOpen="data-panel-open",a})({});const C3={[Oh.open]:""},T3={[Oh.closed]:""},R3={open(a){return a?{[w3.panelOpen]:""}:null}},M3={open(a){return a?C3:T3}},Mr={height:void 0,width:void 0};function A3(a){const{externalRef:l,hiddenUntilFound:s,id:u,keepMounted:f,mounted:d,onOpenChange:m,open:y,setMounted:p,setOpen:g,transitionStatus:b}=a,S=x.useRef(null),j=x.useRef(null),[E,O]=x.useState(Mr),T=x.useRef(Mr),A=x.useRef(!1),k=x.useRef(y),B=x.useRef(!1),[K,D]=x.useState(!1),G=x.useRef(null),ae=Ss(l,S),V=ZC(y),H=hv(S),ee=!y&&!d,Q=K?"idle":b,se=y&&(k.current||B.current),re=!y&&d&&j.current==="css-animation"&&E.height===void 0&&E.width===void 0?T.current:E,ue=s&&ee&&j.current!=="css-animation",le=qe((F,I=!0)=>{I&&(T.current=F),O(F)}),P=qe(()=>{var F;(F=G.current)==null||F.call(G),G.current=null}),R=qe(F=>{P(),G.current=()=>{G.current=null,F()}}),$=qe(()=>{y&&d&&j.current==="css-animation"&&(B.current=!0)});Ve(()=>{!K||b==="starting"||D(!1)},[K,b]),x.useEffect(()=>()=>{$(),P()},[$,P]),Ve(()=>{const F=S.current;if(!F)return;!y&&G.current&&P();const I=O3(F,se);if(j.current=I,y&&b==="idle"&&k.current&&I==="css-animation"){T.current=ns(F);return}if(y&&b==="starting"){const Z=A.current;if(A.current=!1,I==="none"){le(ns(F)),D(!0);return}if(I==="css-transition"){const oe=z3(F);if(le(ns(F)),!Z)return oe;const ce=mo(F,"transition-duration","0s");return R(ce),D(!0),oe}le(ns(F));const te=mo(F,"animation-name","none");if(!Z){te();return}const ie=mo(F,"animation-duration","0s");te(),R(ie),D(!0);return}if(!y&&d&&(b==="idle"||b==="starting")){if(k.current=!1,B.current=!1,I==="none"){le(Mr,!1),p(!1);return}le(ns(F));return}if(b!=="ending")return;if(I==="none"){p(!1);return}const N=ns(F);if(!(N.height>0||N.width>0)){p(!1);return}le(N),I==="css-animation"&&mo(F,"animation-name","none")()},[d,y,P,le,p,R,se,b]),mv({enabled:y&&d&&Q==="idle",open:!0,ref:S,onComplete(){y&&le(Mr,!1)}}),x.useEffect(()=>{if(y||!d||Q!=="ending"||!S.current)return;const I=new AbortController;let N=-1;function _(){V.current||(p(!1),le(Mr,!1))}return N=gn.request(()=>{H(_,I.signal)}),()=>{gn.cancel(N),I.abort()}},[V,d,y,Q,H,le,p]),Ve(()=>{const F=S.current;!F||!s||!ee||F.setAttribute("hidden","until-found")},[ee,s]),x.useEffect(function(){const I=S.current;if(!I)return;function N(_){const Z=As(Qo,_);m(!0,Z),!Z.isCanceled&&(A.current=!0,g(!0))}return Sv(I,"beforematch",N)},[m,g]);const Y=f||s||d||y;return{height:re.height,props:{...ue?{[Oh.startingStyle]:""}:void 0,hidden:ee,id:u},ref:ae,shouldPreventOpenAnimation:se,shouldRender:Y,transitionStatus:Q,width:re.width}}function ns(a){return{height:a.scrollHeight,width:a.scrollWidth}}function O3(a,l){const s=Ms(a).getComputedStyle(a),u=(s.animationName.split(",").map(d=>d.trim()).some(d=>d!==""&&d!=="none")||l)&&Rx(s.animationDuration),f=Rx(s.transitionDuration);return u&&f||f?"css-transition":u?"css-animation":"none"}function Rx(a){return a.split(",").map(l=>l.trim()).some(l=>l!==""&&Number.parseFloat(l)>0)}function mo(a,l,s){const u=a.style.getPropertyValue(l),f=a.style.getPropertyPriority(l);return a.style.setProperty(l,s),()=>{if(u===""){a.style.removeProperty(l);return}a.style.setProperty(l,u,f)}}function z3(a){const l={"justify-content":a.style.justifyContent,"align-items":a.style.alignItems,"align-content":a.style.alignContent,"justify-items":a.style.justifyItems};Object.keys(l).forEach(f=>{a.style.setProperty(f,"initial","important")});function s(){Object.entries(l).forEach(([f,d])=>{if(d===""){a.style.removeProperty(f);return}a.style.setProperty(f,d)})}const u=gn.request(s);return()=>{gn.cancel(u),s()}}const _v={...M3,...Th},k3=x.forwardRef(function(l,s){const{render:u,className:f,defaultOpen:d=!1,disabled:m=!1,onOpenChange:y,open:p,style:g,...b}=l,S=qe(y),j=E3({open:p,defaultOpen:d,onOpenChange:S,disabled:m}),E=x.useMemo(()=>({open:j.open,disabled:j.disabled,transitionStatus:j.transitionStatus}),[j.open,j.disabled,j.transitionStatus]),O=x.useMemo(()=>({...j,onOpenChange:S,state:E}),[j,S,E]),T=qt("div",l,{state:E,ref:s,props:b,stateAttributesMapping:_v});return r.jsx(kv.Provider,{value:O,children:T})}),D3={...R3,...Th},_3=x.forwardRef(function(l,s){const{panelId:u,open:f,handleTrigger:d,state:m,disabled:y}=Dv(),{className:p,disabled:g=y,render:b,nativeButton:S=!0,style:j,...E}=l,{getButtonProps:O,buttonRef:T}=qo({disabled:g,focusableWhenDisabled:!0,native:S});return qt("button",l,{state:m,ref:[s,T],props:[{"aria-controls":f?u:void 0,"aria-expanded":f,onClick:d},E,O],stateAttributesMapping:D3})});let Mx=(function(a){return a.collapsiblePanelHeight="--collapsible-panel-height",a.collapsiblePanelWidth="--collapsible-panel-width",a})({});const L3=x.forwardRef(function(l,s){const{className:u,hiddenUntilFound:f,keepMounted:d,render:m,id:y,style:p,...g}=l,{defaultPanelId:b,mounted:S,onOpenChange:j,open:E,setMounted:O,setPanelIdState:T,setOpen:A,state:k,transitionStatus:B}=Dv(),K=f??!1,D=d??!1,G=y||void 0,ae=G??b;Ve(()=>(T($=>G??($===null?void 0:$)),()=>{T($=>$===G?null:$)}),[G,T]);const{height:V,props:H,ref:ee,shouldPreventOpenAnimation:Q,shouldRender:se,transitionStatus:re,width:ue}=A3({externalRef:s,hiddenUntilFound:K,id:ae,keepMounted:D,mounted:S,onOpenChange:j,open:E,setMounted:O,setOpen:A,transitionStatus:B}),le={...k,transitionStatus:re},P=X0(p,le),R=qt("div",{...l,style:void 0},{state:le,ref:ee,props:[H,{style:{[Mx.collapsiblePanelHeight]:V===void 0?"auto":`${V}px`,[Mx.collapsiblePanelWidth]:ue===void 0?"auto":`${ue}px`}},g,P?{style:P}:void 0,Q?{style:{animationName:"none"}}:void 0],stateAttributesMapping:_v});return se?R:null});function Lv(a){var l,s,u="";if(typeof a=="string"||typeof a=="number")u+=a;else if(typeof a=="object")if(Array.isArray(a)){var f=a.length;for(l=0;l<f;l++)a[l]&&(s=Lv(a[l]))&&(u&&(u+=" "),u+=s)}else for(s in a)a[s]&&(u&&(u+=" "),u+=s);return u}function U3(){for(var a,l,s=0,u="",f=arguments.length;s<f;s++)(a=arguments[s])&&(l=Lv(a))&&(u&&(u+=" "),u+=l);return u}const Ax=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,Ox=U3,zh=(a,l)=>s=>{var u;if((l==null?void 0:l.variants)==null)return Ox(a,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:f,defaultVariants:d}=l,m=Object.keys(f).map(g=>{const b=s==null?void 0:s[g],S=d==null?void 0:d[g];if(b===null)return null;const j=Ax(b)||Ax(S);return f[g][j]}),y=s&&Object.entries(s).reduce((g,b)=>{let[S,j]=b;return j===void 0||(g[S]=j),g},{}),p=l==null||(u=l.compoundVariants)===null||u===void 0?void 0:u.reduce((g,b)=>{let{class:S,className:j,...E}=b;return Object.entries(E).every(O=>{let[T,A]=O;return Array.isArray(A)?A.includes({...d,...y}[T]):{...d,...y}[T]===A})?[...g,S,j]:g},[]);return Ox(a,m,p,s==null?void 0:s.class,s==null?void 0:s.className)},H3=zh("inline-flex w-fit shrink-0 items-center justify-center gap-1.5 overflow-hidden rounded-none border px-2 py-0.5 text-[0.625rem] font-semibold uppercase tracking-widest whitespace-nowrap transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/80",destructive:"border-destructive/20 bg-destructive/10 text-destructive [a&]:hover:bg-destructive/20",outline:"border-border text-foreground [a&]:hover:bg-muted [a&]:hover:text-foreground"}},defaultVariants:{variant:"default"}});function q3({className:a,variant:l="default",render:s,...u}){return zE({defaultTagName:"span",props:Uo({className:ve(H3({variant:l}),a)},u),render:s,state:{slot:"badge",variant:l}})}const B3={default:"text-muted-foreground bg-muted border-border",success:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400",error:"text-red-700 bg-red-500/10 border-red-500/25 dark:text-red-400",warning:"text-amber-700 bg-amber-500/10 border-amber-500/25 dark:text-amber-400",purple:"text-purple-700 bg-purple-500/10 border-purple-500/25 dark:text-purple-400",blue:"text-blue-700 bg-blue-500/10 border-blue-500/25 dark:text-blue-400",orange:"text-orange-700 bg-orange-500/10 border-orange-500/25 dark:text-orange-400",emerald:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400"};function Ml({className:a,icon:l,variant:s="default",children:u,...f}){return r.jsxs("div",{"data-slot":"tag",className:ve("inline-flex items-center gap-1.5 rounded-none border px-2.5 py-1 text-[0.625rem] font-semibold uppercase tracking-widest [&_svg]:h-3 [&_svg]:w-3",B3[s],a),...f,children:[l&&r.jsx("span",{className:"flex-shrink-0",children:l}),r.jsx("span",{className:"leading-none",children:u})]})}const Q3=zh("group/button relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-none border border-transparent bg-clip-padding text-xs font-semibold uppercase tracking-widest transition-all outline-none select-none cursor-pointer focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",primary:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",outline:"border-border bg-transparent hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-input/30",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",danger:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",success:"bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20 dark:bg-emerald-500/15 dark:text-emerald-400 dark:hover:bg-emerald-500/25",link:"text-primary underline underline-offset-4 hover:underline",icon:"border-border bg-transparent hover:bg-muted hover:text-foreground dark:hover:bg-input/30"},size:{default:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",xs:"h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",sm:"h-9 gap-1 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",md:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",lg:"h-11 gap-1.5 px-8 has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5",icon:"size-10","icon-xs":"size-7 [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-9","icon-md":"size-10","icon-lg":"size-11"}},defaultVariants:{variant:"default",size:"default"}});function De({className:a,variant:l="default",size:s="default",isLoading:u=!1,children:f,disabled:d,render:m,nativeButton:y,...p}){const g=y??(m===void 0||x.isValidElement(m)&&m.type==="button");return r.jsxs(eC,{"data-slot":"button",className:ve(Q3({variant:l,size:s,className:a})),disabled:d===!0||u,render:m,nativeButton:g,...p,children:[u&&r.jsx(_w,{className:"size-3.5 animate-spin"}),f]})}const Y3={sm:"h-9 text-xs",md:"h-10 text-sm",lg:"h-11 text-base"};function oa({className:a,label:l,error:s,leftIcon:u,rightContent:f,inputSize:d="md","aria-invalid":m,...y}){const p=!!s||m!==void 0&&m!==!1&&m!=="false";return r.jsxs("div",{className:"w-full",children:[l&&r.jsx("label",{className:"mb-2 block text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:l}),r.jsxs("div",{className:ve("flex items-center gap-2 border border-transparent border-b-input bg-transparent transition-[color,border-color] focus-within:border-b-ring",p&&"border-b-destructive focus-within:border-b-destructive",a),children:[u&&r.jsx(u,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx(RC,{"data-slot":"input","aria-invalid":p||void 0,className:ve("w-full min-w-0 flex-1 border-0 bg-transparent px-0 py-1 outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",Y3[d]),...y}),f&&r.jsx("div",{className:"shrink-0",children:f})]}),s&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:s})]})}function Uv({className:a,children:l,...s}){return r.jsxs(LC,{"data-slot":"scroll-area",className:ve("relative",a),...s,children:[r.jsx(QC,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r.jsx(G3,{}),r.jsx(KC,{})]})}function G3({className:a,orientation:l="vertical",...s}){return r.jsx(VC,{"data-slot":"scroll-area-scrollbar","data-orientation":l,orientation:l,className:ve("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...s,children:r.jsx(XC,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-none bg-border"})})}ve("flex items-center justify-between gap-2 rounded-none border border-border bg-transparent px-3 py-2 text-xs font-semibold uppercase tracking-widest transition-colors","hover:bg-muted focus:outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 data-popup-open:bg-muted");function Sd({className:a,size:l="default",...s}){return r.jsx(g3,{"data-slot":"switch","data-size":l,className:ve("peer group/switch relative inline-flex shrink-0 items-center rounded-none border transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=default]:h-4.5 data-[size=default]:w-8.25 data-[size=sm]:h-3.5 data-[size=sm]:w-6.25 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-unchecked:border-input/50 data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50",a),...s,children:r.jsx(y3,{"data-slot":"switch-thumb",className:"pointer-events-none block bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-2.5 data-checked:translate-x-[calc(100%+2px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0.25 dark:data-unchecked:bg-foreground"})})}function Hv({className:a,orientation:l="horizontal",...s}){return r.jsx(x3,{"data-slot":"tabs","data-orientation":l,className:ve("group/tabs flex gap-2 data-horizontal:flex-col",a),...s})}const V3=zh("group/tabs-list inline-flex w-fit items-center justify-center p-1 text-muted-foreground group-data-horizontal/tabs:h-10 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function qv({className:a,variant:l="default",...s}){return r.jsx(N3,{"data-slot":"tabs-list","data-variant":l,className:ve(V3({variant:l}),a),...s})}function kr({className:a,...l}){return r.jsx(b3,{"data-slot":"tabs-trigger",className:ve("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-2 border border-transparent px-4 py-1.5 text-xs font-semibold tracking-wider whitespace-nowrap text-foreground/60 uppercase transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-4 group-data-vertical/tabs:py-2 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",a),...l})}function Dr({className:a,...l}){return r.jsx(j3,{"data-slot":"tabs-content",className:ve("flex-1 text-sm outline-none",a),...l})}function zn({className:a,...l}){return r.jsx("label",{"data-slot":"label",className:ve("flex items-center gap-2 text-xs font-semibold tracking-wide uppercase select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-[slot=checkbox]:text-sm peer-data-[slot=checkbox]:font-normal peer-data-[slot=checkbox]:tracking-normal peer-data-[slot=checkbox]:normal-case peer-data-[slot=radio-group-item]:text-sm peer-data-[slot=radio-group-item]:font-normal peer-data-[slot=radio-group-item]:tracking-normal peer-data-[slot=radio-group-item]:normal-case peer-data-[slot=switch]:text-sm peer-data-[slot=switch]:font-normal peer-data-[slot=switch]:tracking-normal peer-data-[slot=switch]:normal-case",a),...l})}function X3({className:a,...l}){return r.jsx("textarea",{"data-slot":"textarea",className:ve("flex field-sizing-content min-h-16 w-full resize-none rounded-none border border-transparent border-b-input bg-transparent px-0 py-3 text-base transition-[color,border-color] outline-none placeholder:text-muted-foreground focus-visible:border-b-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-b-destructive md:text-sm dark:aria-invalid:border-b-destructive/50",a),...l})}function Bv({...a}){return r.jsx(k3,{"data-slot":"collapsible",...a})}function Qv({...a}){return r.jsx(_3,{"data-slot":"collapsible-trigger",...a})}function Yv({...a}){return r.jsx(L3,{"data-slot":"collapsible-content",...a})}const K3=["prompt_tokens","completion_tokens","input_tokens","output_tokens","inputTokens","outputTokens","inputTokens.total","outputTokens.total","cost","cost_usd_total","cost_details.total_cost"],$3=new Set(["model","modelId","provider","type","status","message.model","metadata.used_model","metadata.used_provider","providerMetadata.llmgateway.usedModel","providerMetadata.llmgateway.usedProvider","providerMetadata.llmgateway.provider",...K3.flatMap(a=>["usage","message.usage","providerMetadata.llmgateway.usage","providerMetadata.llmgateway","providerMetadata.gateway"].map(l=>`${l}.${a}`))]),Gv=new Set([...$3].flatMap(a=>{const l=a.split(".");return l.map((s,u)=>l.slice(0,u+1).join("."))}));Gv.add("choices");Gv.add("error");var zx;(function(a){a.STATIC="static",a.DYNAMIC="dynamic"})(zx||(zx={}));var ls;(function(a){a.SMALL="small",a.DEFAULT="default",a.LARGE="large",a.XLARGE="xlarge"})(ls||(ls={}));ls.SMALL+"",ls.DEFAULT+"",ls.LARGE+"",ls.XLARGE+"";var kx;(function(a){a.INFO="info",a.ERROR="error",a.WARNING="warning"})(kx||(kx={}));ve("relative overflow-hidden","dark:bg-[#1a1a1a] bg-white","border dark:border-white/[0.08] border-gray-200","backdrop-blur-xl","rounded-2xl","dark:shadow-[0_8px_32px_rgba(0,0,0,0.4)] shadow-[0_2px_8px_rgba(0,0,0,0.04)]");function Z3({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(z0,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(A0,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function F3({table:a,onInsertText:l}){const[s,u]=x.useState(!1);return r.jsxs(Bv,{open:s,onOpenChange:u,children:[r.jsxs(Qv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(M0,{className:"h-4 w-4 shrink-0"}):r.jsx(ui,{className:"h-4 w-4 shrink-0"}),r.jsx(_o,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Yv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx(Z3,{column:f,onInsertText:l},f.name))})})]})}function J3({onInsertText:a}){const{data:l,isLoading:s,refetch:u}=it({queryKey:["auth-schema"],queryFn:rE,staleTime:3e4}),f=(l==null?void 0:l.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Auth Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(),disabled:s,children:r.jsx(Gr,{className:ve("h-4 w-4",s&&"animate-spin")})})]}),r.jsx(Uv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:s?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):f.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:f.map(d=>r.jsx(F3,{table:d,onInsertText:a},d.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function P3(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function I3(a){if(a<60)return`${a} seconds`;if(a<3600)return`${Math.floor(a/60)} minutes`;if(a<86400){const s=Math.floor(a/3600);return`${s} hour${s>1?"s":""}`}const l=Math.floor(a/86400);return`${l} day${l>1?"s":""}`}function W3({settings:a,onUpdate:l,isUpdating:s}){var ae;const[u,f]=x.useState(a.sessionTokenExpiry.toString()),[d,m]=x.useState(a.sessionUpdateAge.toString()),[y,p]=x.useState(((ae=a.sessionMaxLifetime)==null?void 0:ae.toString())??""),[g,b]=x.useState(a.sessionCookieCacheMaxAge.toString()),[S,j]=x.useState(a.allowSignups),[E,O]=x.useState(a.requireEmailVerification),[T,A]=x.useState(a.requireName),[k,B]=x.useState(a.cookieDomain??""),K={sessionTokenExpiry:parseInt(u,10),sessionUpdateAge:parseInt(d,10),sessionMaxLifetime:y.trim()===""?null:parseInt(y,10),sessionCookieCacheMaxAge:parseInt(g,10)},D=()=>{l({...K,allowSignups:S,requireEmailVerification:E,requireName:T,cookieDomain:k.trim()||null})},G=K.sessionTokenExpiry!==a.sessionTokenExpiry||K.sessionUpdateAge!==a.sessionUpdateAge||K.sessionMaxLifetime!==a.sessionMaxLifetime||K.sessionCookieCacheMaxAge!==a.sessionCookieCacheMaxAge||S!==a.allowSignups||E!==a.requireEmailVerification||T!==a.requireName||(k.trim()||null)!==a.cookieDomain;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionTokenExpiry",children:"Idle Session Lifetime (seconds)"}),r.jsx(oa,{id:"sessionTokenExpiry",type:"number",min:300,max:7776e3,value:u,onChange:V=>f(V.target.value)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",I3(parseInt(u,10)||0)," (min: 5 minutes, max: 90 days)"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionUpdateAge",children:"Session Refresh Interval (seconds)"}),r.jsx(oa,{id:"sessionUpdateAge",type:"number",min:0,value:d,onChange:V=>m(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"A used session is extended to the full expiry at most this often. 0 disables renewal. Positive intervals must be shorter than the idle lifetime."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionMaxLifetime",children:"Maximum Session Age (seconds)"}),r.jsx(oa,{id:"sessionMaxLifetime",type:"number",min:3600,max:3456e4,placeholder:"34560000 (400 days)",value:y,onChange:V=>p(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Sessions end this long after sign-in, however active. Empty allows up to 400 days."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionCookieCacheMaxAge",children:"Session Cookie Cache (seconds)"}),r.jsx(oa,{id:"sessionCookieCacheMaxAge",type:"number",min:0,max:600,value:g,onChange:V=>b(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"/me answers from a signed cookie for this long. Revocation can be delayed by this duration. 0 turns it off."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"cookieDomain",children:"Shared session domain"}),r.jsx(oa,{id:"cookieDomain",placeholder:"myapp.localhost",value:k,onChange:V=>B(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Share one session across subdomains, e.g. app.myapp.localhost and api.myapp.localhost. Leave empty to keep sessions on one host."})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zn,{children:"Allow Signups"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Allow new users to create accounts"})]}),r.jsx(Sd,{checked:S,onCheckedChange:j})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zn,{children:"Require Email Verification"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Users must verify their email before accessing the app"})]}),r.jsx(Sd,{checked:E,onCheckedChange:O})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zn,{children:"Require Name"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Require users to enter their name during sign up"})]}),r.jsx(Sd,{checked:T,onCheckedChange:A})]})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(De,{onClick:D,disabled:!G||s,children:s?"Saving...":"Save Settings"})})]})}function e4(){var ue,le,P,R,$,Y;const a=Ns(),[l,s]=x.useState("settings"),[u,f]=x.useState(""),[d,m]=x.useState(null),[y,p]=x.useState(null),[g,b]=x.useState(null),[S,j]=x.useState(0),E=50,T=((le=(ue=it({queryKey:["config"],queryFn:Lo,staleTime:6e4}).data)==null?void 0:ue.auth)==null?void 0:le.binding)||"AUTH",A=it({queryKey:["auth-settings"],queryFn:oE,staleTime:0}),k=vs({mutationFn:cE,onSuccess:()=>{a.invalidateQueries({queryKey:["auth-settings"]})}}),B=F=>{k.mutate(F)},K=x.useCallback(F=>{f(I=>I+F)},[]),D=vs({mutationFn:F=>uE(F),onSuccess:F=>{m(F),p(null)},onError:F=>{p(F instanceof Error?F.message:"Failed to execute query"),m(null)}}),G=()=>{u.trim()&&D.mutate(u)},ae=it({queryKey:["auth-tables"],queryFn:iE,staleTime:0,gcTime:0}),V=it({queryKey:["auth-tableData",g,E,S],queryFn:()=>sE(g,E,S),staleTime:0,gcTime:0,enabled:!!g}),H=((P=ae.data)==null?void 0:P.tables)||[],ee=((R=V.data)==null?void 0:R.data)||[],Q=(($=V.data)==null?void 0:$.columns)||[],se=((Y=V.data)==null?void 0:Y.total)||0,re=F=>{b(F),j(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Auth: ",T]}),r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/50 p-4",children:[r.jsx(O0,{className:"h-5 w-5 mt-0.5 text-blue-500 shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Ploy Auth Database"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"This is the Ploy Auth database containing user accounts and refresh tokens. Password hashes are hidden for security. Only SELECT queries are allowed."})]})]}),r.jsxs(Hv,{value:l,onValueChange:s,children:[r.jsxs(qv,{children:[r.jsxs(kr,{value:"settings",children:[r.jsx(MN,{className:"mr-2 h-4 w-4"}),"Settings"]}),r.jsx(kr,{value:"query",children:"SQL Editor"}),r.jsx(kr,{value:"tables",children:"Tables"})]}),r.jsx(Dr,{value:"settings",className:"mt-4",children:r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Auth Settings"}),r.jsx(kt,{children:"Configure authentication settings for local development."})]}),r.jsx(ut,{children:A.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.data?r.jsx(W3,{settings:A.data,onUpdate:B,isUpdating:k.isPending}):r.jsx("p",{className:"text-muted-foreground",children:"Failed to load settings"})})]})}),r.jsx(Dr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute read-only SELECT queries against auth tables"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:u,onChange:F=>f(F.target.value),onKeyDown:F=>{(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&G()},placeholder:"SELECT * FROM auth_users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute (SELECT only)"}),r.jsxs(De,{onClick:G,disabled:D.isPending||!u.trim(),children:[r.jsx(ph,{className:"mr-2 h-4 w-4"}),D.isPending?"Executing...":"Execute"]})]})]})]}),y&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:y})})}),d&&r.jsx(iv,{results:d.results,meta:d.meta,error:d.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(J3,{onInsertText:K})})]})}),r.jsx(Dr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>ae.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:ae.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):H.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:H.map(F=>r.jsxs("button",{onClick:()=>re(F.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${g===F.name?"bg-muted font-medium":""}`,children:[r.jsx(_o,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:F.name})]},F.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:g||"Select a Table"}),g&&r.jsxs(kt,{children:[se," total rows"]})]}),r.jsx(ut,{children:g?V.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ee.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsx(ct,{children:Q.map(F=>r.jsx(je,{className:"font-mono",children:F},F))})}),r.jsx(Un,{children:ee.map((F,I)=>r.jsx(ct,{children:Q.map(N=>r.jsx(Ne,{className:"font-mono text-sm",children:P3(F[N])},N))},I))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",S+1," -"," ",Math.min(S+E,se)," of ",se]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:S===0,onClick:()=>j(Math.max(0,S-E)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:S+E>=se,onClick:()=>j(S+E),children:["Next",r.jsx(ui,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}function Hn(){return r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}function sn({children:a}){return r.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:a})}function fi({id:a}){return r.jsxs("span",{className:"font-mono text-xs",children:[a.slice(0,8),"..."]})}function Vt({title:a,value:l,icon:s,isLoading:u}){return r.jsxs(rt,{children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-sm font-medium",children:a}),s]}),r.jsx(ut,{children:r.jsx("div",{className:"text-2xl font-bold",children:u?r.jsx(Dn,{className:"h-5 w-5 animate-spin"}):l})})]})}function Ga({title:a,children:l}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:a}),l]})}function t4(a){const l='<base target="_blank">';return/<head[^>]*>/i.test(a)?a.replace(/<head[^>]*>/i,s=>`${s}${l}`):`${l}${a}`}function n4({receive:a,inbox:l}){var g,b;const s=Ns(),u=(g=a[0])!=null&&g.startsWith("*@")?`test${a[0].slice(1)}`:a[0]??(l?"inbox@in.ploy.email":""),[f,d]=x.useState({from:"sender@example.com",to:u,subject:"Hello",text:"This is a test email from the Ploy dev dashboard."}),m=vs({mutationFn:mE,onSuccess:async()=>{await s.invalidateQueries({queryKey:["auth-emails"]})}}),y=S=>j=>{d({...f,[S]:j.target.value})},p=(b=m.data)==null?void 0:b.result;return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Send test email"}),r.jsx(kt,{children:"Delivers an email to your worker's email() handler, as if it arrived at an address in email.receive or the project's inbox address. Replies and forwards land in the inbox below."})]}),r.jsx(ut,{children:r.jsxs("form",{className:"grid gap-3 md:grid-cols-2",onSubmit:S=>{S.preventDefault(),m.mutate(f)},children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(zn,{htmlFor:"test-email-from",children:"From"}),r.jsx(oa,{id:"test-email-from",value:f.from,onChange:y("from")})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(zn,{htmlFor:"test-email-to",children:"To"}),r.jsx(oa,{id:"test-email-to",value:f.to,onChange:y("to")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(zn,{htmlFor:"test-email-subject",children:"Subject"}),r.jsx(oa,{id:"test-email-subject",value:f.subject,onChange:y("subject")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(zn,{htmlFor:"test-email-text",children:"Text"}),r.jsx(X3,{id:"test-email-text",rows:3,value:f.text,onChange:y("text")})]}),r.jsxs("div",{className:"flex items-center gap-3 md:col-span-2",children:[r.jsxs(De,{type:"submit",size:"sm",disabled:m.isPending,children:[r.jsx(TN,{className:"mr-2 h-4 w-4"}),"Send"]}),r.jsx("span",{className:"text-sm text-muted-foreground",children:m.error?m.error.message:p!=null&&p.rejected?`Rejected: ${p.rejected}`:p!=null&&p.relayed?"Relayed to the original sender":p!=null&&p.success?"Handled by email()":(p==null?void 0:p.error)??""})]})]})})]})}function a4({id:a}){const{data:l,isLoading:s}=it({queryKey:["auth-email",a],queryFn:()=>dE(a)});if(s)return r.jsx(Hn,{});if(!l)return r.jsx(sn,{children:"Email not found"});const{email:u}=l;return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1 text-sm",children:[u.from&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"From: "}),u.from]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"To: "}),u.to]}),u.cc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Cc: "}),u.cc]}),u.bcc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Bcc: "}),u.bcc]}),u.replyTo&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Reply-To: "}),u.replyTo]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Subject: "}),u.subject]}),r.jsx("div",{className:"text-muted-foreground",children:new Date(u.createdAt).toLocaleString()})]}),u.html?r.jsx("iframe",{title:u.subject,sandbox:"allow-popups allow-popups-to-escape-sandbox",srcDoc:t4(u.html),className:"h-[560px] w-full rounded-md border bg-white"}):null,r.jsxs("details",{className:"text-sm",open:!u.html,children:[r.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Plain text"}),r.jsx("pre",{className:"mt-2 whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",children:u.text})]})]})}function l4(){var g;const a=Ns(),[l,s]=x.useState(null),{data:u,isLoading:f}=it({queryKey:["auth-emails"],queryFn:fE,refetchInterval:3e3}),{data:d}=it({queryKey:["config"],queryFn:Lo}),m=vs({mutationFn:hE,onSuccess:async()=>{s(null),await a.invalidateQueries({queryKey:["auth-emails"]})}}),y=(u==null?void 0:u.emails)??[],p=l??((g=y[0])==null?void 0:g.id)??null;return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:"Emails",children:r.jsxs(De,{variant:"outline",size:"sm",disabled:y.length===0||m.isPending,onClick:()=>{m.mutate()},children:[r.jsx(L0,{className:"mr-2 h-4 w-4"}),"Clear inbox"]})}),(d==null?void 0:d.email)&&r.jsx(n4,{receive:d.email.receive??[],inbox:d.email.inbox??!1}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Inbox"}),r.jsx(kt,{children:"Emails from Ploy Auth and from your worker's email binding. Under ploy dev nothing is sent; every email lands here."})]}),r.jsx(ut,{children:f?r.jsx(Hn,{}):y.length===0?r.jsx(sn,{children:"No emails yet. Send one from your worker, sign up or request a password reset to see one."}):r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Time"}),r.jsx(je,{children:"Type"}),r.jsx(je,{children:"To"}),r.jsx(je,{children:"Subject"})]})}),r.jsx(Un,{children:y.map(b=>r.jsxs(ct,{className:ve("cursor-pointer",b.id===p&&"bg-muted"),onClick:()=>{s(b.id)},children:[r.jsx(Ne,{className:"whitespace-nowrap text-xs text-muted-foreground",children:new Date(b.createdAt).toLocaleTimeString()}),r.jsx(Ne,{children:r.jsx(q3,{variant:"outline",children:b.purpose==="worker"?"Worker":"Auth"})}),r.jsx(Ne,{className:"text-sm",children:b.to}),r.jsx(Ne,{className:"text-sm",children:b.subject})]},b.id))})]})})]}),r.jsx(rt,{children:r.jsx(ut,{className:"pt-6",children:p?r.jsx(a4,{id:p}):r.jsx(sn,{children:"Select an email to preview it"})})})]})]})})}const po=20;function i4(a){if(a===null)return"Never";const l=a-Math.floor(Date.now()/1e3);return l<=0?"Expired":l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function s4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Cache Entries"}),r.jsx(kt,{children:"Key-value entries in this cache store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"}),r.jsx(je,{children:"Expires"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:i4(s.expiresAt)})]},s.key))})]}):r.jsx(sn,{children:"No entries in this cache store"})})]})}function r4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["cacheEntries",l,s,f],queryFn:()=>FN(l,po,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,S=Math.floor(s/po)+1,j=E=>{E.preventDefault(),d(m),u(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Cache: ${l}`}),r.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[r.jsx(oa,{placeholder:"Search by key...",value:m,onChange:E=>y(E.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(_0,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),u(0)},children:"Clear"})]}),r.jsx(s4,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",S]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(Math.max(0,s-po)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(s+po),disabled:!b,children:["Next",r.jsx(ui,{className:"h-4 w-4"})]})]})]})]})})}const u4={PENDING:{variant:"default",icon:r.jsx(oi,{className:"h-3 w-3"}),label:"Pending"},RUNNING:{variant:"blue",icon:r.jsx(Dn,{className:"h-3 w-3 animate-spin"}),label:"Running"},COMPLETED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(Cs,{className:"h-3 w-3"}),label:"Failed"},CANCELLED:{variant:"default",icon:r.jsx(Qj,{className:"h-3 w-3"}),label:"Cancelled"}},o4={PENDING:{variant:"default",icon:r.jsx(oi,{className:"h-3 w-3"}),label:"Pending"},PROCESSING:{variant:"blue",icon:r.jsx(Dn,{className:"h-3 w-3 animate-spin"}),label:"Processing"},ACKNOWLEDGED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Acknowledged"},FAILED:{variant:"error",icon:r.jsx(Cs,{className:"h-3 w-3"}),label:"Failed"},DEAD_LETTER:{variant:"orange",icon:r.jsx(Wj,{className:"h-3 w-3"}),label:"Dead Letter"}};function kh({status:a}){const l=u4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const c4={PENDING:{variant:"default",icon:r.jsx(oi,{className:"h-3 w-3"}),label:"Pending"},FIRED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Fired"},COMPLETED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(Cs,{className:"h-3 w-3"}),label:"Failed"}};function Vv({status:a}){const l=c4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}function f4({status:a}){const l=o4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const d4={provisioning:{variant:"blue",icon:r.jsx(Dn,{className:"h-3 w-3 animate-spin"}),label:"Provisioning"},active:{variant:"success",icon:r.jsx(T0,{className:"h-3 w-3"}),label:"Active"},idle:{variant:"default",icon:r.jsx(D0,{className:"h-3 w-3"}),label:"Idle"},sleeping:{variant:"warning",icon:r.jsx(k0,{className:"h-3 w-3"}),label:"Sleeping"},stopped:{variant:"default",icon:r.jsx(_N,{className:"h-3 w-3"}),label:"Stopped"},destroyed:{variant:"error",icon:r.jsx(L0,{className:"h-3 w-3"}),label:"Destroyed"}};function h4({status:a,active:l}){const u=d4[a==="running"?l?"active":"idle":a];return u?r.jsx(Ml,{variant:u.variant,icon:u.icon,children:u.label}):r.jsx(Ml,{children:a})}function m4({executions:a,cronExpression:l,isLoading:s}){const u=(a==null?void 0:a.filter(d=>d.status==="COMPLETED").length)??0,f=(a==null?void 0:a.filter(d=>d.status==="FAILED").length)??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[r.jsx(Vt,{title:"Schedule",value:l??"-",icon:r.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}),isLoading:s}),r.jsx(Vt,{title:"Completed",value:u,icon:r.jsx(Rl,{className:"h-4 w-4 text-green-500"}),isLoading:s}),r.jsx(Vt,{title:"Failed",value:f,icon:r.jsx(Cs,{className:"h-4 w-4 text-red-500"}),isLoading:s})]})}function p4({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent cron handler executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Triggered"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Completed"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(kh,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.triggeredAt})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:s.completedAt?r.jsx(yn,{timestamp:s.completedAt}):"-"})]},s.id))})]}):r.jsx(sn,{children:"No cron executions yet"})})]})}function g4(){const{binding:a}=Qa(),l=a||"",s=Ns(),{data:u,isLoading:f}=it({queryKey:["cronExecutions",l],queryFn:()=>aE(l,20),enabled:!!l,refetchInterval:5e3}),d=vs({mutationFn:()=>lE(l),onSettled:()=>{s.invalidateQueries({queryKey:["cronExecutions",l]})}});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Cron: ${l}`,children:r.jsxs(De,{size:"sm",disabled:!l||d.isPending,onClick:()=>{d.mutate()},children:[r.jsx(ph,{className:"h-4 w-4 mr-1"}),d.isPending?"Running...":"Run now"]})}),r.jsx(m4,{executions:u==null?void 0:u.executions,cronExpression:u==null?void 0:u.cronExpression,isLoading:f}),r.jsx(p4,{executions:u==null?void 0:u.executions,isLoading:f})]})})}function y4({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(z0,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(A0,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function x4({table:a,onInsertText:l}){const[s,u]=x.useState(!1);return r.jsxs(Bv,{open:s,onOpenChange:u,children:[r.jsxs(Qv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(M0,{className:"h-4 w-4 shrink-0"}):r.jsx(ui,{className:"h-4 w-4 shrink-0"}),r.jsx(_o,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Yv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx(y4,{column:f,onInsertText:l},f.name))})})]})}function v4({bindingName:a,onInsertText:l}){const{data:s,isLoading:u,refetch:f}=it({queryKey:["schema",a],queryFn:()=>$N(a),staleTime:3e4}),d=(s==null?void 0:s.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(),disabled:u,children:r.jsx(Gr,{className:ve("h-4 w-4",u&&"animate-spin")})})]}),r.jsx(Uv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:u?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):d.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:d.map(m=>r.jsx(x4,{table:m,onInsertText:l},m.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function b4(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function S4(){var ee,Q,se,re;const{binding:a}=Qa(),l=a||"",[s,u]=x.useState("query"),[f,d]=x.useState(""),[m,y]=x.useState(null),[p,g]=x.useState(null),[b,S]=x.useState(null),[j,E]=x.useState(0),O=50,T=x.useCallback(ue=>{d(le=>le+ue)},[]),A=vs({mutationFn:ue=>VN(l,ue),onSuccess:ue=>{y(ue),g(null)},onError:ue=>{g(ue instanceof Error?ue.message:"Failed to execute query"),y(null)}}),k=()=>{f.trim()&&A.mutate(f)},B=it({queryKey:["tables",l],queryFn:()=>XN(l),staleTime:0,gcTime:0,enabled:!!l}),K=it({queryKey:["tableData",l,b,O,j],queryFn:()=>KN(l,b,O,j),staleTime:0,gcTime:0,enabled:!!l&&!!b}),D=((ee=B.data)==null?void 0:ee.tables)||[],G=((Q=K.data)==null?void 0:Q.data)||[],ae=((se=K.data)==null?void 0:se.columns)||[],V=((re=K.data)==null?void 0:re.total)||0,H=ue=>{S(ue),E(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Database: ",l]}),r.jsxs(Hv,{value:s,onValueChange:u,children:[r.jsxs(qv,{children:[r.jsx(kr,{value:"query",children:"SQL Editor"}),r.jsx(kr,{value:"tables",children:"Tables"})]}),r.jsx(Dr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute SQL queries against your database"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:f,onChange:ue=>d(ue.target.value),onKeyDown:ue=>{(ue.metaKey||ue.ctrlKey)&&ue.key==="Enter"&&k()},placeholder:"SELECT * FROM users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute"}),r.jsxs(De,{onClick:k,disabled:A.isPending||!f.trim(),children:[r.jsx(ph,{className:"mr-2 h-4 w-4"}),A.isPending?"Executing...":"Execute"]})]})]})]}),p&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:p})})}),m&&r.jsx(iv,{results:m.results,meta:m.meta,error:m.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(v4,{bindingName:l,onInsertText:T})})]})}),r.jsx(Dr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>B.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:B.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):D.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:D.map(ue=>r.jsxs("button",{onClick:()=>H(ue.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${b===ue.name?"bg-muted font-medium":""}`,children:[r.jsx(_o,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:ue.name})]},ue.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:b||"Select a Table"}),b&&r.jsxs(kt,{children:[V," total rows"]})]}),r.jsx(ut,{children:b?K.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):G.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsx(ct,{children:ae.map(ue=>r.jsx(je,{className:"font-mono",children:ue},ue))})}),r.jsx(Un,{children:G.map((ue,le)=>r.jsx(ct,{children:ae.map(P=>r.jsx(Ne,{className:"font-mono text-sm",children:b4(ue[P])},P))},le))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",j+1," -"," ",Math.min(j+O,V)," of ",V]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:j===0,onClick:()=>E(Math.max(0,j-O)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:j+O>=V,onClick:()=>E(j+O),children:["Next",r.jsx(ui,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}const Fl=20;function j4(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)} MB`:`${(a/(1024*1024*1024)).toFixed(1)} GB`}function N4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Files"}),r.jsx(kt,{children:"Stored files with metadata (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Size"}),r.jsx(je,{children:"Content Type"}),r.jsx(je,{children:"Created At"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:j4(s.size)}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:s.contentType}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:s.createdAt})]},s.key))})]}):r.jsx(sn,{children:"No files in this storage"})})]})}function E4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(0),{data:f,isLoading:d}=it({queryKey:["fileStorageEntries",l,s],queryFn:()=>pE(l,Fl,s),enabled:!!l,refetchInterval:5e3}),m=(f==null?void 0:f.total)??0,y=Math.floor(s/Fl)+1,p=Math.ceil(m/Fl);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`File Storage: ${l}`}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:r.jsx(Vt,{title:"Total Files",value:m})}),r.jsx(N4,{entries:f==null?void 0:f.entries,isLoading:d}),m>Fl&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",y," of ",p]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(Math.max(0,s-Fl)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(s+Fl),disabled:s+Fl>=m,children:["Next",r.jsx(ui,{className:"h-4 w-4"})]})]})]})]})})}function w4({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Processing",value:(a==null?void 0:a.processing)??0,icon:r.jsx(Dn,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Acknowledged",value:(a==null?void 0:a.acknowledged)??0,icon:r.jsx(Rl,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Failed",value:(a==null?void 0:a.failed)??0,icon:r.jsx(Cs,{className:"h-4 w-4 text-red-500"}),isLoading:l}),r.jsx(Vt,{title:"Dead Letter",value:(a==null?void 0:a.deadLetter)??0,icon:r.jsx(xN,{className:"h-4 w-4 text-orange-500"}),isLoading:l})]})}function C4({messages:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Messages"}),r.jsx(kt,{children:"Latest messages in this queue (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Attempt"}),r.jsx(je,{children:"Created"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(f4,{status:s.status})}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:JSON.stringify(s.payload)}),r.jsx(Ne,{children:s.attempt}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No messages in this queue"})})]})}function T4(){const{binding:a}=Qa(),l=a||"",{data:s,isLoading:u}=it({queryKey:["queueMetrics",l],queryFn:()=>JN(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["queueMessages",l],queryFn:()=>PN(l,10),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Queue: ${l}`}),r.jsx(w4,{metrics:s==null?void 0:s.metrics,isLoading:u}),r.jsx(C4,{messages:f==null?void 0:f.messages,isLoading:d})]})})}function R4({sandboxes:a,isLoading:l}){const s=(a==null?void 0:a.length)??0,u=(a==null?void 0:a.filter(y=>y.active).length)??0,f=(a==null?void 0:a.filter(y=>y.status==="running"&&!y.active).length)??0,d=(a==null?void 0:a.filter(y=>y.status==="sleeping").length)??0,m=(a==null?void 0:a.reduce((y,p)=>y+p.sessionCount,0))??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Sandboxes",value:s,icon:r.jsx(R0,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Active",value:u,icon:r.jsx(T0,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Idle",value:f,icon:r.jsx(D0,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Sleeping",value:d,icon:r.jsx(k0,{className:"h-4 w-4 text-orange-500"}),isLoading:l}),r.jsx(Vt,{title:"Sessions",value:m,icon:r.jsx(kN,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l})]})}function M4({sandboxes:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Sandboxes"}),r.jsx(kt,{children:"Live sandbox instances launched via env.<binding>.get(id) (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Image"}),r.jsx(je,{children:"Sessions"}),r.jsx(je,{children:"Container"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-xs",children:s.externalId}),r.jsx(Ne,{children:r.jsx(h4,{status:s.status,active:s.active})}),r.jsx(Ne,{className:"font-mono text-xs",children:s.image}),r.jsx(Ne,{children:s.sessionCount}),r.jsx(Ne,{children:s.containerId?r.jsx(fi,{id:s.containerId}):r.jsx("span",{className:"text-muted-foreground",children:"—"})})]},s.id))})]}):r.jsx(sn,{children:"No sandboxes yet — call env.<binding>.get(id) from your worker to launch one"})})]})}function A4(){const{data:a,isLoading:l}=it({queryKey:["sandboxes"],queryFn:GN,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:"Sandboxes"}),r.jsx(R4,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l}),r.jsx(M4,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l})]})})}const go=20;function O4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"State Entries"}),r.jsx(kt,{children:"Key-value entries in this state store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value})]},s.key))})]}):r.jsx(sn,{children:"No entries in this state store"})})]})}function z4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["stateEntries",l,s,f],queryFn:()=>ZN(l,go,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,S=Math.floor(s/go)+1,j=E=>{E.preventDefault(),d(m),u(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`State: ${l}`}),r.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[r.jsx(oa,{placeholder:"Search by key...",value:m,onChange:E=>y(E.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(_0,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),u(0)},children:"Clear"})]}),r.jsx(O4,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",S]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(Math.max(0,s-go)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(s+go),disabled:!b,children:["Next",r.jsx(ui,{className:"h-4 w-4"})]})]})]})]})})}function k4(a){if(a<1e3)return`${a}ms`;const l=Math.floor(a/1e3);if(l<60)return`${l}s`;const s=Math.floor(l/60),u=l%60;if(s<60)return u===0?`${s}m`:`${s}m ${u}s`;const f=Math.floor(s/60),d=s%60;if(f<24)return d===0?`${f}h`:`${f}h ${d}m`;const m=Math.floor(f/24),y=f%24;return y===0?`${m}d`:`${m}d ${y}h`}function D4({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Fired",value:(a==null?void 0:a.fired)??0,icon:r.jsx(Rl,{className:"h-4 w-4 text-green-500"}),isLoading:l})]})}function _4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Scheduled Timers"}),r.jsx(kt,{children:"Timer entries scheduled by your worker (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Interval"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Created"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Vv,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{className:"text-xs",children:s.intervalMs!==void 0&&s.intervalMs!==null?r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(EN,{className:"h-3 w-3"}),k4(s.intervalMs)]}):"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:s.payload!==void 0&&s.payload!==null?JSON.stringify(s.payload):"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timers scheduled"})})]})}function L4({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent timer handler executions"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Timer ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Executed"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.timerId})}),r.jsx(Ne,{children:r.jsx(Vv,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timer executions yet"})})]})}function U4(){const{binding:a}=Qa(),l=a||"",{data:s,isLoading:u}=it({queryKey:["timerMetrics",l],queryFn:()=>tE(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["timerEntries",l],queryFn:()=>eE(l,20),enabled:!!l,refetchInterval:5e3}),{data:m,isLoading:y}=it({queryKey:["timerExecutions",l],queryFn:()=>nE(l,20),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Timers: ${l}`}),r.jsx(D4,{metrics:s==null?void 0:s.metrics,isLoading:u}),r.jsx(_4,{entries:f==null?void 0:f.entries,isLoading:d}),r.jsx(L4,{executions:m==null?void 0:m.executions,isLoading:y})]})})}function Or(a){return a!=null}function H4(a,l){const s=[];a&&Or(a.input)&&s.push("execution-input"),a&&Or(a.output)&&s.push("execution-output");for(const u of l)Or(u.input)&&s.push(`${u.id}-input`),Or(u.output)&&s.push(`${u.id}-output`);return s}function Ao({id:a,label:l,value:s,isOpen:u,onToggle:f}){return Or(s)?r.jsxs("details",{className:"mt-2",open:u,onToggle:d=>{f(a,d.currentTarget.open)},children:[r.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:l}),r.jsx("pre",{className:"mt-1 p-2 rounded bg-muted text-xs font-mono overflow-x-auto",children:JSON.stringify(s,null,2)})]}):null}function q4({status:a}){switch(a){case"COMPLETED":return r.jsx(Rl,{className:"h-5 w-5 text-green-500"});case"RUNNING":return r.jsx(Dn,{className:"h-5 w-5 text-blue-500 animate-spin"});case"FAILED":return r.jsx(Cs,{className:"h-5 w-5 text-red-500"});case"PENDING":default:return r.jsx(oi,{className:"h-5 w-5 text-gray-400"})}}function B4(a){switch(a){case"COMPLETED":return"bg-green-500";case"RUNNING":return"bg-blue-500";case"FAILED":return"bg-red-500";case"PENDING":default:return"bg-gray-300 dark:bg-gray-600"}}function Q4(a){return a.attempt!==null&&a.attempt!==void 0&&a.maxRetries!==null&&a.maxRetries!==void 0&&(a.attempt>1||a.status!=="COMPLETED")}function Y4({steps:a,openIoSectionIds:l,onToggleIoSection:s}){if(a.length===0)return r.jsx(sn,{children:"No steps recorded for this execution"});const u=a.reduce((f,d)=>f+(d.durationMs||0),0);return r.jsxs("div",{className:"space-y-4",children:[u>0&&r.jsxs("div",{className:"mb-6",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground mb-2",children:[r.jsx("span",{children:"Total Duration"}),r.jsx("span",{children:as(u)})]}),r.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden flex",children:a.map((f,d)=>{const m=f.durationMs?f.durationMs/u*100:0;return r.jsx("div",{className:ve(B4(f.status),"h-full transition-all",d>0&&"border-l border-background"),style:{width:`${m}%`},title:`${f.stepName}: ${as(f.durationMs)}`},f.id)})})]}),r.jsx("div",{className:"relative",children:a.map((f,d)=>{const m=Q4(f);return r.jsxs("div",{className:"relative pb-6 last:pb-0",children:[d<a.length-1&&r.jsx("div",{className:ve("absolute left-[9px] top-6 w-0.5 h-full -ml-px",f.status==="COMPLETED"?"bg-green-200 dark:bg-green-900":"bg-muted")}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"flex-shrink-0 relative z-10 bg-background",children:r.jsx(q4,{status:f.status})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium",children:f.stepName}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(Step ",f.stepIndex+1,")"]}),m&&r.jsxs("span",{className:ve("inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full font-mono",f.attempt!==null&&f.attempt!==void 0&&f.attempt>1?f.status==="FAILED"?"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300":"bg-yellow-100 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300":"bg-muted text-muted-foreground"),children:[r.jsx(Gr,{className:"h-3 w-3"}),f.attempt,"/",(f.maxRetries??0)+1]})]}),r.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:as(f.durationMs)})]}),f.errorMessage&&r.jsx("div",{className:"mt-2 p-2 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:f.errorMessage}),f.retryAttempts&&f.retryAttempts.length>0&&r.jsxs("div",{className:"mt-2 space-y-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Previous failures"}),f.retryAttempts.map(y=>r.jsxs("div",{className:"rounded border border-yellow-200 bg-yellow-50 px-3 py-2 dark:border-yellow-900 dark:bg-yellow-950/40",children:[r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-xs text-yellow-800 dark:text-yellow-200",children:[r.jsxs("span",{className:"font-medium",children:["Attempt ",y.attempt," failed"]}),r.jsx("span",{className:"font-mono",children:as(y.durationMs??null)})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs font-mono text-yellow-900 dark:text-yellow-100",children:y.errorMessage})]},`${f.id}-${y.attempt}`))]}),r.jsx(Ao,{id:`${f.id}-input`,label:"View input",value:f.input,isOpen:l.has(`${f.id}-input`),onToggle:s}),r.jsx(Ao,{id:`${f.id}-output`,label:"View output",value:f.output,isOpen:l.has(`${f.id}-output`),onToggle:s}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r.jsx(yn,{timestamp:f.createdAt})})]})]})]},f.id)})})]})}function G4(){const{binding:a,executionId:l}=Qa(),s=a||"",u=l||"",{data:f,isLoading:d}=it({queryKey:["workflowExecution",s,u],queryFn:()=>WN(s,u),enabled:!!s&&!!u,refetchInterval:5e3}),m=f==null?void 0:f.execution,y=(f==null?void 0:f.steps)||[],p=H4(m??null,y),[g,b]=x.useState(()=>new Set),S=p.length>0&&p.every(O=>g.has(O));function j(O,T){b(A=>{const k=new Set(A);return T?k.add(O):k.delete(O),k})}function E(){b(()=>S?new Set:new Set(p))}return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(Gt,{to:`/workflows/${s}`,children:r.jsxs(De,{variant:"ghost",size:"sm",children:[r.jsx(qj,{className:"mr-2 h-4 w-4"}),"Back"]})}),r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Execution: ",r.jsx(fi,{id:u})]})]}),p.length>0&&r.jsxs(De,{variant:"ghost",size:"sm",onClick:E,children:[S?r.jsx(Fj,{className:"h-4 w-4"}):r.jsx(Pj,{className:"h-4 w-4"}),S?"Collapse All I/O":"Expand All I/O"]})]}),d?r.jsx(Hn,{}):m?r.jsxs(r.Fragment,{children:[r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(xt,{children:"Execution Details"}),r.jsx(kt,{children:m.startedAt?r.jsxs(r.Fragment,{children:["Started ",r.jsx(yn,{timestamp:m.startedAt})]}):"Not started yet"})]}),r.jsx(kh,{status:m.status})]})}),r.jsxs(ut,{children:[r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Duration"}),r.jsx("p",{className:"font-mono",children:as(m.durationMs)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Steps Completed"}),r.jsxs("p",{className:"font-mono",children:[m.stepsCompleted," / ",m.stepsCount]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Created"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.createdAt})})]}),m.completedAt&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.completedAt})})]})]}),m.errorMessage&&r.jsx("div",{className:"mt-4 p-3 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:m.errorMessage}),r.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Input"}),r.jsx(Ao,{id:"execution-input",label:"View execution input",value:m.input,isOpen:g.has("execution-input"),onToggle:j})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Output"}),r.jsx(Ao,{id:"execution-output",label:"View execution output",value:m.output,isOpen:g.has("execution-output"),onToggle:j})]})]})]})]}),r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{children:[r.jsx(xt,{children:"Steps"}),r.jsx(kt,{children:"Workflow step execution timeline"})]})}),r.jsx(ut,{children:r.jsx(Y4,{steps:y,openIoSectionIds:g,onToggleIoSection:j})})]})]}):r.jsx(sn,{children:"Execution not found"})]})})}const jd=20,V4=[{value:"",label:"All statuses"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],X4=[{value:"",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function K4({executions:a,isLoading:l,bindingName:s}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Executions"}),r.jsx(kt,{children:"Workflow executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Steps"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Started"}),r.jsx(je,{})]})}),r.jsx(Un,{children:a.map(u=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:u.id})}),r.jsx(Ne,{children:r.jsx(kh,{status:u.status})}),r.jsx(Ne,{children:r.jsxs("span",{className:"text-sm",children:[u.stepsCompleted,"/",u.stepsCount]})}),r.jsx(Ne,{className:"text-sm",children:as(u.durationMs)}),r.jsx(Ne,{children:u.startedAt?r.jsx(yn,{timestamp:u.startedAt}):"-"}),r.jsx(Ne,{children:r.jsx(Gt,{to:`/workflows/${s}/${u.id}`,className:"flex items-center text-sm text-primary hover:underline",children:"View"})})]},u.id))})]}):r.jsx(sn,{children:"No executions for this workflow"})})]})}function $4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(""),[f,d]=x.useState(""),[m,y]=x.useState(0),p=m*jd,{data:g,isLoading:b}=it({queryKey:["workflowExecutions",l,s,f,m],queryFn:()=>IN(l,jd,p,s||void 0,f||void 0),enabled:!!l,refetchInterval:5e3}),S=g?Math.ceil(g.total/jd):0,j=()=>y(0);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Workflow: ${l}`}),r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsx("select",{value:s,onChange:E=>{u(E.target.value),j()},className:"text-sm border rounded px-2 py-1 bg-background",children:V4.map(E=>r.jsx("option",{value:E.value,children:E.label},E.value))}),r.jsx("select",{value:f,onChange:E=>{d(E.target.value),j()},className:"text-sm border rounded px-2 py-1 bg-background",children:X4.map(E=>r.jsx("option",{value:E.value,children:E.label},E.value))}),g&&r.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.total," total"]})]}),r.jsx(K4,{executions:g==null?void 0:g.executions,isLoading:b,bindingName:l}),S>1&&r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m===0,onClick:()=>y(E=>E-1),children:"Previous"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",m+1," of ",S]}),r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m>=S-1,onClick:()=>y(E=>E+1),children:"Next"})]})]})})}function Z4(){const a=Fn(),{data:l,isLoading:s}=it({queryKey:["config"],queryFn:Lo,staleTime:6e4}),u=l!=null&&l.db?Object.keys(l.db):[],f=l!=null&&l.queue?Object.keys(l.queue):[],d=l!=null&&l.state?Object.keys(l.state):[],m=l!=null&&l.cache?Object.keys(l.cache):[],y=l!=null&&l.fs?Object.keys(l.fs):[],p=l!=null&&l.workflow?Object.keys(l.workflow):[],g=l!=null&&l.cron?Object.keys(l.cron):[],b=l!=null&&l.timer?Object.keys(l.timer):[],S=l!=null&&l.sandbox?Object.keys(l.sandbox):[];return r.jsxs("aside",{className:"fixed inset-y-0 left-0 z-10 w-64 flex flex-col border-r bg-background",children:[r.jsx("div",{className:"flex h-14 items-center border-b px-4",children:r.jsxs(Gt,{to:"/",className:"flex items-center gap-2 font-semibold",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground",children:"P"}),r.jsx("span",{children:"Ploy Dev"})]})}),r.jsx("nav",{className:"flex-1 overflow-auto p-4",children:s?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"space-y-6",children:[u.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Database"}),r.jsx("div",{className:"space-y-1",children:u.map(j=>{const E=a.pathname===`/db/${j}`;return r.jsx(Gt,{to:`/db/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(iN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),(l==null?void 0:l.auth)&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Auth"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth",children:r.jsxs(De,{variant:a.pathname==="/auth"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth"&&"bg-muted"),children:[r.jsx(ON,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 text-left",children:l.auth.binding}),r.jsx(O0,{className:"h-3.5 w-3.5 text-muted-foreground",title:"Ploy Auth tables (users & sessions)"})]})})})]}),((l==null?void 0:l.auth)||(l==null?void 0:l.email))&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth/emails",children:r.jsxs(De,{variant:a.pathname==="/auth/emails"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth/emails"&&"bg-muted"),children:[r.jsx(gN,{className:"mr-2 h-4 w-4"}),"Emails"]})})})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Queues"}),r.jsx("div",{className:"space-y-1",children:f.map(j=>{const E=a.pathname===`/queues/${j}`;return r.jsx(Gt,{to:`/queues/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(fN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),d.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"State"}),r.jsx("div",{className:"space-y-1",children:d.map(j=>{const E=a.pathname===`/state/${j}`;return r.jsx(Gt,{to:`/state/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(Uj,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),m.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cache"}),r.jsx("div",{className:"space-y-1",children:m.map(j=>{const E=a.pathname===`/cache/${j}`;return r.jsx(Gt,{to:`/cache/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(QN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),y.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"File Storage"}),r.jsx("div",{className:"space-y-1",children:y.map(j=>{const E=a.pathname===`/fs/${j}`;return r.jsx(Gt,{to:`/fs/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(rN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),p.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Workflows"}),r.jsx("div",{className:"space-y-1",children:p.map(j=>{const E=a.pathname.startsWith(`/workflows/${j}`);return r.jsx(Gt,{to:`/workflows/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(oN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),g.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cron"}),r.jsx("div",{className:"space-y-1",children:g.map(j=>{const E=a.pathname===`/cron/${j}`;return r.jsx(Gt,{to:`/cron/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(HN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),b.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Timers"}),r.jsx("div",{className:"space-y-1",children:b.map(j=>{const E=a.pathname===`/timers/${j}`;return r.jsx(Gt,{to:`/timers/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(Gj,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),S.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Sandboxes"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/sandboxes",children:r.jsxs(De,{variant:a.pathname==="/sandboxes"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/sandboxes"&&"bg-muted"),children:[r.jsx(R0,{className:"mr-2 h-4 w-4"}),"Sandboxes"]})})})]}),u.length===0&&f.length===0&&d.length===0&&m.length===0&&y.length===0&&p.length===0&&g.length===0&&b.length===0&&S.length===0&&!(l!=null&&l.auth)&&r.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No bindings configured in ploy.yaml"})]})})]})}function F4(){const{data:a,isLoading:l}=it({queryKey:["config"],queryFn:Lo,staleTime:6e4});if(!l&&a){const s=a.db?Object.keys(a.db):[],u=a.queue?Object.keys(a.queue):[],f=a.state?Object.keys(a.state):[],d=a.fs?Object.keys(a.fs):[],m=a.workflow?Object.keys(a.workflow):[];if(s.length>0)return r.jsx(ia,{to:`/db/${s[0]}`,replace:!0});if(a.auth)return r.jsx(ia,{to:"/auth",replace:!0});if(u.length>0)return r.jsx(ia,{to:`/queues/${u[0]}`,replace:!0});if(f.length>0)return r.jsx(ia,{to:`/state/${f[0]}`,replace:!0});const y=a.cache?Object.keys(a.cache):[];if(y.length>0)return r.jsx(ia,{to:`/cache/${y[0]}`,replace:!0});if(d.length>0)return r.jsx(ia,{to:`/fs/${d[0]}`,replace:!0});if(m.length>0)return r.jsx(ia,{to:`/workflows/${m[0]}`,replace:!0});const p=a.cron?Object.keys(a.cron):[];if(p.length>0)return r.jsx(ia,{to:`/cron/${p[0]}`,replace:!0});const g=a.timer?Object.keys(a.timer):[];if(g.length>0)return r.jsx(ia,{to:`/timers/${g[0]}`,replace:!0});if((a.sandbox?Object.keys(a.sandbox):[]).length>0)return r.jsx(ia,{to:"/sandboxes",replace:!0})}return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Ploy Dev Dashboard"}),l?r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"}):r.jsx("p",{className:"text-muted-foreground",children:"Configure database, queue, or workflow bindings in ploy.yaml to get started."})]})}function J4(){return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx(Z4,{}),r.jsx("main",{className:"pl-64",children:r.jsx("div",{className:"container mx-auto px-6 py-4",children:r.jsxs(J2,{children:[r.jsx(nn,{path:"/",element:r.jsx(F4,{})}),r.jsx(nn,{path:"/db/:binding",element:r.jsx(S4,{})}),r.jsx(nn,{path:"/auth",element:r.jsx(e4,{})}),r.jsx(nn,{path:"/auth/emails",element:r.jsx(l4,{})}),r.jsx(nn,{path:"/queues/:binding",element:r.jsx(T4,{})}),r.jsx(nn,{path:"/state/:binding",element:r.jsx(z4,{})}),r.jsx(nn,{path:"/cache/:binding",element:r.jsx(r4,{})}),r.jsx(nn,{path:"/fs/:binding",element:r.jsx(E4,{})}),r.jsx(nn,{path:"/cron/:binding",element:r.jsx(g4,{})}),r.jsx(nn,{path:"/timers/:binding",element:r.jsx(U4,{})}),r.jsx(nn,{path:"/workflows/:binding",element:r.jsx($4,{})}),r.jsx(nn,{path:"/workflows/:binding/:executionId",element:r.jsx(G4,{})}),r.jsx(nn,{path:"/sandboxes",element:r.jsx(A4,{})})]})})})]})}function Xv(){const a=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",a)}Xv();window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",Xv);const P4=new wS({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});JS.createRoot(document.getElementById("root")).render(r.jsx(x.StrictMode,{children:r.jsx(kS,{client:P4,children:r.jsx(bj,{children:r.jsx(J4,{})})})}));
|
|
355
|
+
*/const Hw=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],qw=Jn("x",Hw);function Bw(a){const l=Math.floor((new Date().getTime()-a.getTime())/1e3);return l<5?"just now":l<60?`${String(l)}s ago`:l<3600?`${String(Math.floor(l/60))}m ago`:l<86400?`${String(Math.floor(l/3600))}h ago`:l<604800?`${String(Math.floor(l/86400))}d ago`:a.toLocaleDateString()}function yd({value:a}){const[l,s]=x.useState(!1);return r.jsx("button",{onClick:u=>{u.stopPropagation(),navigator.clipboard.writeText(a).then(()=>{s(!0),setTimeout(()=>{s(!1)},2e3)}).catch(()=>{const f=document.createElement("textarea");f.value=a,document.body.appendChild(f),f.select();try{document.execCommand("copy")}catch{}document.body.removeChild(f),s(!0),setTimeout(()=>{s(!1)},2e3)})},className:ve("p-1 rounded transition-colors flex-shrink-0",l?"text-green-500":"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"),title:l?"Copied!":"Copy to clipboard",children:l?r.jsx(lv,{className:"w-3 h-3"}):r.jsx(Mw,{className:"w-3 h-3"})})}function yn({timestamp:a,className:l,rawValue:s,forceOpen:u=!1}){const[f,d]=x.useState(!1),[,m]=x.useState(0),y=u||f;if(x.useEffect(()=>{const j=setInterval(()=>{m(E=>E+1)},1e3);return()=>{clearInterval(j)}},[]),!a)return null;let p;typeof a=="number"?p=new Date(a<1e10?a*1e3:a):p=new Date(a);const g=p.toISOString(),b=p.toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"}),S=Bw(p);return r.jsxs("div",{className:ve("relative inline-block",l),onMouseEnter:()=>{d(!0)},onMouseLeave:()=>{d(!1)},children:[r.jsx("time",{dateTime:g,className:"cursor-help border-b border-gray-400 dark:border-gray-400 text-gray-700 dark:text-gray-300",children:S}),r.jsx("div",{className:ve("absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-[9999] w-72","transition-all duration-200 ease-out origin-bottom",y?"opacity-100 scale-100 translate-y-0":"opacity-0 scale-95 translate-y-2 pointer-events-none"),children:r.jsx(Ro,{rounded:"lg",shadow:"lg",className:"p-3 text-xs !bg-white dark:!bg-gray-900 !backdrop-blur-none",children:r.jsxs("div",{className:"space-y-2.5",children:[s!==void 0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Raw Value"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:typeof s=="object"?JSON.stringify(s):String(s)}),r.jsx(yd,{value:typeof s=="object"?JSON.stringify(s):String(s)})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"UTC ISO"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"font-mono text-gray-700 dark:text-gray-200 break-all leading-tight",children:g}),r.jsx(yd,{value:g})]})]}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] uppercase tracking-wider text-gray-500 dark:text-gray-400 font-semibold mb-0.5",children:"Local Time"}),r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"text-gray-700 dark:text-gray-200 leading-tight",children:b}),r.jsx(yd,{value:b})]})]})]})})})]})}function Qw(a){return a<1e3?`${a.toFixed(2)}ms`:`${(a/1e3).toFixed(2)}s`}function Yw(a){return typeof a!="string"?!1:[/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/,/^\d{4}-\d{2}-\d{2}$/].some(l=>l.test(a))}function Gw(a){const l=a.toLowerCase();return!!(l.includes("created")||l.includes("date")||l.includes("updated")||a.endsWith("At")||l.endsWith("_at"))}function Vw(a,l){for(const s of l){const u=s[a];if(u!=null)return typeof u=="boolean"?"bool":typeof u=="number"&&Gw(a)?"date":typeof u=="number"?"number":Yw(u)?"date":"string"}return"string"}function iv({results:a,meta:l,columns:s,error:u,title:f="Results",pageSize:d=25,onExportCsv:m,onExportJson:y,serverPagination:p}){const g=a??[],[b,S]=x.useState(""),[j,E]=x.useState(null),[O,T]=x.useState(new Set),[A,k]=x.useState(1),B=!!p,K=p?Math.floor(p.offset/p.limit)+1:1,D=p?Math.ceil(p.total/p.limit):1,G=x.useMemo(()=>s||(g.length===0?[]:Object.keys(g[0]).map(le=>({key:le,label:le,type:Vw(le,g)}))),[s,g]),ae=x.useMemo(()=>b?g.filter(le=>Object.values(le).some(P=>String(P).toLowerCase().includes(b.toLowerCase()))):g,[g,b]),V=x.useMemo(()=>j?[...ae].sort((le,P)=>{const R=le[j.key],$=P[j.key];return R==null?1:$==null?-1:R<$?j.direction==="asc"?-1:1:R>$?j.direction==="asc"?1:-1:0}):ae,[ae,j]),H=Math.ceil(V.length/d),ee=x.useMemo(()=>{const le=(A-1)*d;return V.slice(le,le+d)},[V,A,d]);x.useMemo(()=>{k(1)},[b,j]);const Q=le=>{E(P=>(P==null?void 0:P.key)===le?P.direction==="asc"?{key:le,direction:"desc"}:null:{key:le,direction:"asc"})},se=()=>{O.size===ee.length?T(new Set):T(new Set(ee.map((le,P)=>P)))},re=le=>{const P=new Set(O);P.has(le)?P.delete(le):P.add(le),T(P)},ue=(le,P)=>{const R=le[P.key];if(R==null)return r.jsx("span",{className:"text-xs italic dark:text-gray-600 text-gray-400",children:"NULL"});switch(P.type??"string"){case"bool":return R===!0?r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(lv,{className:"w-3.5 h-3.5"})}):r.jsx("div",{className:"flex items-center justify-center w-6 h-6 rounded-full dark:bg-white/[0.06] bg-black/[0.04] dark:text-gray-300 text-gray-700",children:r.jsx(qw,{className:"w-3.5 h-3.5"})});case"date":return r.jsx(yn,{timestamp:R,rawValue:typeof R=="number"?R:void 0});case"number":return r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:typeof R=="number"?R.toLocaleString():JSON.stringify(R)});default:return typeof R=="object"?r.jsx("span",{className:"text-sm font-mono dark:text-gray-300 text-gray-700",children:JSON.stringify(R)}):r.jsx("span",{className:"text-sm dark:text-gray-300 text-gray-700",children:typeof R=="object"?JSON.stringify(R):String(R)})}};return u?r.jsxs(Ro,{rounded:"2xl",shadow:"lg",className:"border-red-500/30 dark:border-red-500/20",children:[r.jsx("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200",children:r.jsx("h2",{className:"text-lg font-semibold text-red-500",children:"Query Error"})}),r.jsx("div",{className:"p-5",children:r.jsx("p",{className:"font-mono text-sm text-red-500",children:u})})]}):r.jsxs(Ro,{rounded:"2xl",shadow:"lg",className:"flex flex-col",children:[r.jsxs("div",{className:"p-5 border-b dark:border-white/[0.08] border-gray-200 flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("h2",{className:"text-lg font-semibold dark:text-white text-gray-900",children:f}),l&&r.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 border border-green-500/20",children:Qw(l.duration)}),r.jsxs("span",{className:"text-sm dark:text-gray-500 text-gray-500",children:[g.length," row",g.length!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"relative group",children:[r.jsx(Uw,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 group-focus-within:text-blue-500 transition-colors"}),r.jsx("input",{type:"text",placeholder:"Search results...",value:b,onChange:le=>{S(le.target.value)},className:"pl-9 pr-4 py-2 rounded-lg text-sm bg-gray-100 dark:bg-white/[0.06] border border-transparent focus:bg-white dark:focus:bg-black focus:border-blue-500 focus:ring-1 focus:ring-blue-500 outline-none transition-all w-full sm:w-64 dark:text-white text-gray-900 placeholder-gray-500"})]}),(m??y)&&r.jsxs("div",{className:"flex items-center gap-2 border-l dark:border-white/[0.08] border-gray-200 pl-3 ml-1",children:[m&&r.jsx("button",{onClick:m,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export CSV",children:r.jsx(kw,{className:"w-4 h-4"})}),y&&r.jsx("button",{onClick:y,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] text-gray-500 dark:text-gray-400 transition-colors",title:"Export JSON",children:r.jsx(Ow,{className:"w-4 h-4"})})]})]})]}),r.jsx("div",{className:"overflow-x-auto overflow-y-visible",children:r.jsxs("table",{className:"w-full text-left border-collapse font-mono",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b dark:border-white/[0.08] border-gray-200 bg-gray-50/50 dark:bg-white/[0.02]",children:[r.jsx("th",{className:"p-4 w-12",children:r.jsx("input",{type:"checkbox",checked:O.size===ee.length&&ee.length>0,onChange:se,className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),G.map(le=>r.jsx("th",{className:"p-4 text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-gray-400 cursor-pointer hover:text-blue-500 dark:hover:text-blue-400 transition-colors select-none group",onClick:()=>{Q(le.key)},children:r.jsxs("div",{className:"flex items-center gap-1",children:[le.label,r.jsxs("div",{className:ve("flex flex-col opacity-0 group-hover:opacity-50",(j==null?void 0:j.key)===le.key&&"opacity-100"),children:[r.jsx(Tw,{className:ve("w-2 h-2",(j==null?void 0:j.key)===le.key&&j.direction==="asc"&&"text-blue-500")}),r.jsx(Nw,{className:ve("w-2 h-2",(j==null?void 0:j.key)===le.key&&j.direction==="desc"&&"text-blue-500")})]})]})},le.key))]})}),r.jsx("tbody",{className:"divide-y dark:divide-white/[0.04] divide-gray-100",children:ee.length>0?ee.map((le,P)=>r.jsxs("tr",{className:ve("group transition-colors",O.has(P)?"bg-blue-50/50 dark:bg-blue-500/10":"hover:bg-gray-50 dark:hover:bg-white/[0.02]"),children:[r.jsx("td",{className:"p-4",children:r.jsx("input",{type:"checkbox",checked:O.has(P),onChange:()=>{re(P)},className:"rounded border-gray-300 text-blue-600 focus:ring-blue-500 bg-transparent"})}),G.map(R=>r.jsx("td",{className:"p-4 whitespace-nowrap",children:ue(le,R)},`${String(P)}-${R.key}`))]},P)):r.jsx("tr",{children:r.jsx("td",{colSpan:G.length+1,className:"p-8 text-center text-gray-500 dark:text-gray-400",children:b?`No results found matching "${b}"`:"Query executed successfully. No rows returned."})})})]})}),r.jsxs("div",{className:"p-4 border-t dark:border-white/[0.08] border-gray-200 flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[r.jsxs("div",{children:[B?r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.offset+1}),"-",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:Math.min(p.offset+g.length,p.total)})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:p.total})," ","total"]}):r.jsxs(r.Fragment,{children:["Showing"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:ee.length})," ","of"," ",r.jsx("span",{className:"font-medium dark:text-white text-gray-900",children:V.length})," ","results"]}),O.size>0&&r.jsxs("span",{className:"ml-3 text-blue-500 font-medium",children:[O.size," row",O.size!==1?"s":""," ","selected"]})]}),B&&D>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{p.onPageChange(Math.max(0,p.offset-p.limit))},disabled:K===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(dx,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(D,5)},(le,P)=>{let R;return D<=5||K<=3?R=P+1:K>=D-2?R=D-4+P:R=K-2+P,r.jsx("button",{onClick:()=>{p.onPageChange((R-1)*p.limit)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",K===R?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:R},R)})}),r.jsx("button",{onClick:()=>{p.onPageChange(p.offset+p.limit)},disabled:K===D,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(hx,{className:"w-4 h-4"})})]}),!B&&H>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>{k(le=>Math.max(1,le-1))},disabled:A===1,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(dx,{className:"w-4 h-4"})}),r.jsx("div",{className:"flex items-center gap-1",children:Array.from({length:Math.min(H,5)},(le,P)=>{let R;return H<=5||A<=3?R=P+1:A>=H-2?R=H-4+P:R=A-2+P,r.jsx("button",{onClick:()=>{k(R)},className:ve("px-2.5 py-1 rounded-lg font-medium transition-colors",A===R?"bg-blue-500/10 text-blue-600 dark:text-blue-400":"hover:bg-gray-100 dark:hover:bg-white/[0.06]"),children:R},R)})}),r.jsx("button",{onClick:()=>{k(le=>Math.min(H,le+1))},disabled:A===H,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-white/[0.06] disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:r.jsx(hx,{className:"w-4 h-4"})})]})]})]})}function vh(){return typeof window<"u"}function Ms(a){var l;return(a==null||(l=a.ownerDocument)==null?void 0:l.defaultView)||window}function Xw(a){return vh()?a instanceof Element||a instanceof Ms(a).Element:!1}function Ho(a){return vh()?a instanceof HTMLElement||a instanceof Ms(a).HTMLElement:!1}function Kw(a){return!vh()||typeof ShadowRoot>"u"?!1:a instanceof ShadowRoot||a instanceof Ms(a).ShadowRoot}function $w(a){return Ms(a).getComputedStyle(a)}const bh={...zS},xd=bh.useInsertionEffect,Zw=xd&&xd!==bh.useLayoutEffect?xd:a=>a();function qe(a){const l=ca(Fw).current;return l.next=a,Zw(l.effect),l.trampoline}function Fw(){const a={next:void 0,callback:Jw,trampoline:(...l)=>{var s;return(s=a.callback)==null?void 0:s.call(a,...l)},effect:()=>{a.callback=a.next}};return a}function Jw(){}const Pw=()=>{},Ve=typeof document<"u"?x.useLayoutEffect:Pw,sv=x.createContext(void 0);function Sh(a=!1){const l=x.useContext(sv);if(l===void 0&&!a)throw new Error(Ya(16));return l}function Iw(a){const{focusableWhenDisabled:l,disabled:s,composite:u=!1,tabIndex:f=0,isNativeButton:d}=a,m=u&&l!==!1,y=u&&l===!1;return{props:x.useMemo(()=>{const g={onKeyDown(b){s&&l&&b.key!=="Tab"&&b.preventDefault()}};return u||(g.tabIndex=f,!d&&s&&(g.tabIndex=l?f:-1)),(d&&(l||m)||!d&&s)&&(g["aria-disabled"]=s),d&&(!l||y)&&(g.disabled=s),g},[u,s,l,m,y,d,f])}}function Gd(a){return(a==null?void 0:a.ownerDocument)||document}function So(a,l,{detail:s=0}={}){a.dispatchEvent(new(Ms(a)).PointerEvent("click",{bubbles:!0,cancelable:!0,composed:!0,detail:s,shiftKey:l.shiftKey,ctrlKey:l.ctrlKey,altKey:l.altKey,metaKey:l.metaKey}))}function qo(a={}){const{disabled:l=!1,focusableWhenDisabled:s,tabIndex:u=0,native:f=!0,composite:d}=a,m=x.useRef(null),y=Sh(!0),p=d??y!==void 0,{props:g}=Iw({focusableWhenDisabled:s,disabled:l,composite:p,tabIndex:u,isNativeButton:f}),b=x.useCallback(()=>{const E=m.current;vd(E)&&p&&l&&g.disabled===void 0&&E.disabled&&(E.disabled=!1)},[l,g.disabled,p]);Ve(b,[b]);const S=x.useCallback((E={})=>{const{onClick:O,onMouseDown:T,onKeyUp:A,onKeyDown:k,onPointerDown:B,...K}=E;return Uo({onClick(D){if(l){D.preventDefault();return}O==null||O(D)},onMouseDown(D){l||T==null||T(D)},onKeyDown(D){if(l||(Co(D),k==null||k(D),D.baseUIHandlerPrevented))return;const G=D.target===D.currentTarget,ae=D.currentTarget,V=vd(ae),H=!f&&Ww(ae),ee=G&&(f?V:!H),Q=D.key==="Enter",se=D.key===" ",re=ae.getAttribute("role"),ue=(re==null?void 0:re.startsWith("menuitem"))||re==="option"||re==="gridcell";if(G&&p&&se){if(D.defaultPrevented&&ue)return;D.preventDefault(),(!f||V)&&(D.preventBaseUIHandler(),So(ae,D));return}if(!ee||f||!se&&!Q){G&&H&&se&&D.preventDefault();return}D.defaultPrevented||(D.preventDefault(),Q&&(D.preventBaseUIHandler(),So(ae,D)))},onKeyUp(D){if(!l){if(Co(D),A==null||A(D),D.target===D.currentTarget&&f&&p&&vd(D.currentTarget)&&D.key===" "){D.preventDefault();return}D.baseUIHandlerPrevented||D.target===D.currentTarget&&!f&&!p&&!D.defaultPrevented&&D.key===" "&&(D.preventBaseUIHandler(),So(D.currentTarget,D))}},onPointerDown(D){if(l){D.preventDefault();return}B==null||B(D)}},f?{type:"button"}:{role:"button"},g,K)},[l,g,p,f]),j=qe(E=>{m.current=E,b()});return{getButtonProps:S,buttonRef:j}}function vd(a){return Ho(a)&&a.tagName==="BUTTON"}function Ww(a){return Ho(a)&&a.tagName==="A"&&!!a.href}const eC=x.forwardRef(function(l,s){const{render:u,className:f,disabled:d=!1,focusableWhenDisabled:m=!1,nativeButton:y=!0,style:p,...g}=l,{getButtonProps:b,buttonRef:S}=qo({disabled:d,focusableWhenDisabled:m,native:y});return qt("button",l,{state:{disabled:d},ref:[s,S],props:[g,b]})}),tC={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},nC={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},aC={disabled:!1,...nC},rv={valid(a){return a===null?null:a?{"data-valid":""}:{"data-invalid":""}}},lC={invalid:void 0,name:void 0,validityData:{state:tC,errors:[],error:"",value:"",initialValue:null},setValidityData:Zt,disabled:void 0,setTouched:Zt,setDirty:Zt,setFilled:Zt,setFocused:Zt,validationMode:"onSubmit",shouldValidateOnChange:()=>!1,state:aC,registerFieldControl:Zt,validation:{getValidationProps:(a,l=Ha)=>l,inputRef:{current:null},registeredInputs:new Map,registerInput:Zt,getInputControl:()=>null,commit:async()=>{},change:Zt}},iC=x.createContext(lC);function jh(a=!0){const l=x.useContext(iC);if(l.setValidityData===Zt&&!a)throw new Error(Ya(28));return l}const sC=x.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:Zt,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function uv(){return x.useContext(sC)}let mx=0;function rC(a,l="mui"){const[s,u]=x.useState(a),f=a||s;return x.useEffect(()=>{s==null&&(mx+=1,u(`${l}-${mx}`))},[s,l]),f}const px=bh.useId;function uC(a,l){if(px!==void 0){const s=px();return a??`${l}-${s}`}return rC(a,l)}function ci(a){return uC(a,"base-ui")}const oC=x.createContext({controlId:void 0,registerControlId:Zt,labelId:void 0,setLabelId:Zt,messageIds:[],setMessageIds:Zt,getDescriptionProps:a=>a});function Nh(){return x.useContext(oC)}function cC(a,l,s,u=!0,f){const[d,m]=x.useState(),y=ci(f?`${f}-label`:void 0),p=a??l??d;return Ve(()=>{const g=a||l||!u?void 0:fC(s.current,y);d!==g&&m(g)}),p}function fC(a,l){const s=dC(a);if(s)return!s.id&&l&&(s.id=l),s.id||void 0}function dC(a){if(!a)return;const l=a.parentElement;if(l&&l.tagName==="LABEL")return l;const s=a.id;if(s){const f=a.nextElementSibling;if(f&&f.htmlFor===s)return f}const u=a.labels;return u&&u[0]}function ov(a={}){const{id:l,implicit:s=!1,controlRef:u}=a,{controlId:f,registerControlId:d}=Nh(),m=ci(l),y=s?f:void 0,p=ca(()=>Symbol()),g=x.useRef(!1),b=x.useRef(l!=null),S=qe(()=>{!g.current||d===Zt||(g.current=!1,d(p.current,void 0))});return Ve(()=>{if(d===Zt)return;let j;if(s){const E=u==null?void 0:u.current;Xw(E)&&E.closest("label")!=null?j=l??null:j=y??m}else if(l!=null)b.current=!0,j=l;else if(b.current)j=m;else{S();return}if(j===void 0){S();return}g.current=!0,d(p.current,j)},[l,u,y,d,s,m,p,S]),x.useEffect(()=>S,[S]),f??m}function hC(){return typeof navigator>"u"?{userAgent:"",platform:"",maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??0}}const{userAgent:mC,platform:pC,maxTouchPoints:eT}=hC(),cv=mC.toLowerCase();pC.toLowerCase();var Vx;const Eh=typeof CSS<"u"&&!!((Vx=CSS.supports)!=null&&Vx.call(CSS,"-webkit-backdrop-filter:none"));!Eh&&cv.includes("firefox");!Eh&&cv.includes("chrom");function fv(a){var s;let l=a.activeElement;for(;((s=l==null?void 0:l.shadowRoot)==null?void 0:s.activeElement)!=null;)l=l.shadowRoot.activeElement;return l}function wh(a,l){var u;if(!a||!l)return!1;const s=(u=l.getRootNode)==null?void 0:u.call(l);if(a.contains(l))return!0;if(s&&Kw(s)){let f=l;for(;f;){if(a===f)return!0;f=f.parentNode||f.host}}return!1}function Vd(a){return"composedPath"in a?a.composedPath()[0]:a.target}function bd(a,l){return l<0||l>=a.length}function gC(a,l){return zr(a.current,{disabledIndices:l})}function yC(a,l){return zr(a.current,{decrement:!0,startingIndex:a.current.length,disabledIndices:l})}function zr(a,{startingIndex:l=-1,decrement:s=!1,disabledIndices:u,amount:f=1}={}){let d=l;do d+=s?-f:f;while(d>=0&&d<=a.length-1&&Xd(a,d,u));return d}function Xd(a,l,s){if(typeof s=="function"?s(l):(s==null?void 0:s.includes(l))??!1)return!0;const f=a[l];return f?!vC(f)||f.matches(":disabled")?!0:!s&&(f.hasAttribute("disabled")||f.getAttribute("aria-disabled")==="true"):!1}function xC(a){return a.visibility==="hidden"||a.visibility==="collapse"}function vC(a,l=a?$w(a):null){return!a||!a.isConnected||!l||xC(l)?!1:typeof a.checkVisibility=="function"?a.checkVisibility():l.display!=="none"&&l.display!=="contents"}function dv(a){x.useEffect(a,To)}const Rr=0;class Ch{constructor(){pn(this,"currentId",Rr);pn(this,"clear",()=>{this.currentId!==Rr&&(clearTimeout(this.currentId),this.currentId=Rr)});pn(this,"disposeEffect",()=>this.clear)}static create(){return new Ch}start(l,s){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Rr,s()},l)}isStarted(){return this.currentId!==Rr}}function Mo(){const a=ca(Ch.create).current;return dv(a.disposeEffect),a}const uo=null;class bC{constructor(){pn(this,"callbacks",[]);pn(this,"callbacksCount",0);pn(this,"nextId",1);pn(this,"startId",1);pn(this,"isScheduled",!1);pn(this,"tick",l=>{var f;this.isScheduled=!1;const s=this.callbacks,u=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,u>0)for(let d=0;d<s.length;d+=1)(f=s[d])==null||f.call(s,l)})}request(l){const s=this.nextId;return this.nextId+=1,this.callbacks.push(l),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),s}cancel(l){const s=l-this.startId;s<0||s>=this.callbacks.length||(this.callbacks[s]=null,this.callbacksCount-=1)}}let oo=new bC;class gn{constructor(){pn(this,"currentId",uo);pn(this,"cancel",()=>{this.currentId!==uo&&(oo.cancel(this.currentId),this.currentId=uo)});pn(this,"disposeEffect",()=>this.cancel)}static create(){return new gn}static request(l){return oo.request(l)}static cancel(l){return oo.cancel(l)}request(l){this.cancel(),this.currentId=oo.request(()=>{this.currentId=uo,l()})}}function SC(){const a=ca(gn.create).current;return dv(a.disposeEffect),a}function jC(a){return a==null?a:"current"in a?a.current:a}function hv(a,l=!1){const s=SC();return qe((u,f=null)=>{s.cancel();const d=jC(a);if(d==null)return;const m=d,y=()=>{Aj.flushSync(u)};if(typeof m.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED){u();return}function p(){Promise.all(m.getAnimations().map(g=>g.finished)).then(()=>{f!=null&&f.aborted||y()},()=>{if(f!=null&&f.aborted)return;if(m.getAnimations().some(b=>b.pending||b.playState!=="finished")){p();return}y()})}if(l){const g="data-starting-style";if(!m.hasAttribute(g)){s.request(p);return}const b=new MutationObserver(()=>{m.hasAttribute(g)||(b.disconnect(),p())});b.observe(m,{attributes:!0,attributeFilter:[g]}),f==null||f.addEventListener("abort",()=>b.disconnect(),{once:!0});return}s.request(p)})}function mv(a){const{enabled:l=!0,open:s,ref:u,onComplete:f}=a,d=qe(f),m=hv(u,s);x.useEffect(()=>{if(!l)return;const y=new AbortController;return m(d,y.signal),()=>{y.abort()}},[l,s,d,m])}let gx=(function(a){return a.startingStyle="data-starting-style",a.endingStyle="data-ending-style",a})({});const NC={"data-starting-style":""},EC={"data-ending-style":""},Th={transitionStatus(a){return a==="starting"?NC:a==="ending"?EC:null}};function pv(a,l=!1,s=!1){const[u,f]=x.useState(a&&l?"idle":void 0),[d,m]=x.useState(a);return a&&!d&&(m(!0),f("starting")),!a&&d&&u!=="ending"&&!s&&f("ending"),!a&&!d&&u==="ending"&&f(void 0),Ve(()=>{if(!a&&d&&u!=="ending"&&s){const y=gn.request(()=>{f("ending")});return()=>{gn.cancel(y)}}},[a,d,u,s]),Ve(()=>{if(!a||l)return;const y=gn.request(()=>{f(void 0)});return()=>{gn.cancel(y)}},[l,a]),Ve(()=>{if(!a||!l)return;a&&d&&u!=="idle"&&f("starting");const y=gn.request(()=>{f("idle")});return()=>{gn.cancel(y)}},[l,a,d,u]),{mounted:d,setMounted:m,transitionStatus:u}}function Bo({controlled:a,default:l,name:s,state:u="value"}){const{current:f}=x.useRef(a!==void 0),[d,m]=x.useState(l),y=f?a:d,p=x.useCallback(g=>{f||m(g)},[]);return[y,p]}function gv(a,l,s,u,f=!0,d){const{registerFieldControl:m}=jh(),y=ca(()=>Symbol());Ve(()=>{const p=y.current;if(!f){m(p,void 0);return}m(p,{controlRef:a,getValue:u,id:l,name:d,value:s})},[a,f,u,l,d,m,y,s]),Ve(()=>{const p=y.current;return()=>{m(p,void 0)}},[m,y])}const Qo="none",wC="trigger-press",CC="disabled",yx="missing",xx="initial";function As(a,l,s,u){let f=!1,d=!1;const m=u??Ha;return{reason:a,event:l??new Event("base-ui"),cancel(){f=!0},allowPropagation(){d=!0},get isCanceled(){return f},get isPropagationAllowed(){return d},trigger:s,...m}}const TC=x.forwardRef(function(l,s){const{render:u,className:f,id:d,name:m,value:y,disabled:p=!1,onValueChange:g,defaultValue:b,autoFocus:S=!1,style:j,...E}=l,{state:O,name:T,disabled:A,setTouched:k,setDirty:B,validityData:K,setFocused:D,setFilled:G,validationMode:ae,validation:V}=jh(),{clearErrors:H}=uv(),ee=A||p,Q=T??m,se={...O,disabled:ee},{labelId:re}=Nh(),ue=ov({id:d});Ve(()=>{var N;const I=y!=null;(N=V.inputRef.current)!=null&&N.value||I&&y!==""?G(!0):I&&y===""&&G(!1)},[V.inputRef,G,y]);const le=x.useRef(null);Ve(()=>{S&&le.current===fv(Gd(le.current))&&D(!0)},[S,D]);const[P]=Bo({controlled:y,default:b,name:"FieldControl",state:"value"}),R=y!==void 0,$=R?P:void 0,Y=qe(()=>{var I;return(I=V.inputRef.current)==null?void 0:I.value});return gv(V.inputRef,ue,$,Y,!ee,m),qt("input",l,{ref:[s,le],state:se,props:[{id:ue,disabled:ee,name:Q,ref:V.inputRef,"aria-labelledby":re,autoFocus:S,...R?{value:$}:{defaultValue:b},onChange(I){const N=I.currentTarget.value;g==null||g(N,As(Qo,I.nativeEvent)),B(N!==(K.initialValue??"")),G(N!==""),I.nativeEvent.defaultPrevented||(H(Q),V.change(N))},onFocus(){D(!0)},onBlur(I){k(!0),D(!1),ae==="onBlur"&&V.commit(I.currentTarget.value)},onKeyDown(I){I.currentTarget.tagName==="INPUT"&&I.key==="Enter"&&(k(!0),V.commit(I.currentTarget.value))}},E,I=>V.getValidationProps(ee,I)],stateAttributesMapping:rv})}),RC=x.forwardRef(function(l,s){return r.jsx(TC,{ref:s,...l})}),yv=x.createContext(void 0);function Yo(){const a=x.useContext(yv);if(a===void 0)throw new Error(Ya(53));return a}const MC=500,Kd=16;function Tl(a,l,s){if(!a)return 0;const u=getComputedStyle(a),f=`${l}${s==="x"?"Inline":"Block"}`,d=parseFloat(u[`${f}Start`]);return s==="x"&&l==="margin"?d*2:d+parseFloat(u[`${f}End`])}const co="base-ui-disable-scrollbar",xv={className:co,getElement(a){return r.jsx("style",{nonce:a,href:co,precedence:"base-ui:low",children:`.${co}{scrollbar-width:none}.${co}::-webkit-scrollbar{display:none}`})}},ts=a=>l=>l?{[a]:""}:null,Rh={hasOverflowX:ts("data-has-overflow-x"),hasOverflowY:ts("data-has-overflow-y"),overflowXStart:ts("data-overflow-x-start"),overflowXEnd:ts("data-overflow-x-end"),overflowYStart:ts("data-overflow-y-start"),overflowYEnd:ts("data-overflow-y-end"),cornerHidden:()=>null},AC=x.createContext(void 0),OC={disableStyleElements:!1};function zC(){return x.useContext(AC)??OC}const kC={x:0,y:0},vx={width:0,height:0},DC={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},_C={x:!0,y:!0,corner:!0},LC=x.forwardRef(function(l,s){const{render:u,className:f,overflowEdgeThreshold:d,style:m,...y}=l,{xStart:p,xEnd:g,yStart:b,yEnd:S}=UC(d),j=ci(),E=Mo(),O=Mo(),{nonce:T,disableStyleElements:A}=zC(),[k,B]=x.useState(!1),[K,D]=x.useState(!1),[G,ae]=x.useState(!1),[V,H]=x.useState(!1),[ee,Q]=x.useState(!1),[se,re]=x.useState(vx),[ue,le]=x.useState(vx),[P,R]=x.useState(DC),[$,Y]=x.useState(_C),F=x.useRef(null),I=x.useRef(null),N=x.useRef(null),_=x.useRef(null),Z=x.useRef(null),te=x.useRef(null),ie=x.useRef(null),oe=x.useRef(null),ce=x.useRef(0),ge=x.useRef(0),ye=x.useRef(0),Xe=x.useRef(0),Be=x.useRef("vertical"),tt=x.useRef(kC),ft=x.useRef(null);function we(Ae){const Ke=Ae?ae:D,Je=Ae?E:O;Ke(!0),Je.start(MC,()=>{Ke(!1)})}const Nt=qe(Ae=>{const Ke=Ae.x-tt.current.x,Je=Ae.y-tt.current.y;tt.current=Ae,Je!==0&&we(!0),Ke!==0&&we(!1)}),Bt=qe(()=>{const Ae=I.current;Ae&&ft.current===null&&(ft.current=Ae.style.scrollSnapType,Ae.style.scrollSnapType="none")}),di=qe(Ae=>{if(Ae.button!==0)return;if(oe.current!==null){const rn=Be.current==="vertical"?Z.current:te.current;if(rn!=null&&rn.hasPointerCapture(oe.current))return}oe.current=Ae.pointerId,ce.current=Ae.clientY,ge.current=Ae.clientX,Be.current=Ae.currentTarget.getAttribute("data-orientation");const Ke=I.current;Ke&&(ye.current=Ke.scrollTop,Xe.current=Ke.scrollLeft,Bt());const Je=Be.current==="vertical"?Z.current:te.current;Je==null||Je.setPointerCapture(Ae.pointerId)}),Va=qe(Ae=>{if(Ae.pointerId!==oe.current)return;oe.current=null,(Be.current==="vertical"?ae:D)(!1),ft.current!==null&&(I.current&&(I.current.style.scrollSnapType=ft.current),ft.current=null);const Ke=Be.current==="vertical"?Z.current:te.current;Ke!=null&&Ke.hasPointerCapture(Ae.pointerId)&&Ke.releasePointerCapture(Ae.pointerId)}),Pn=qe(Ae=>{if(Ae.pointerId!==oe.current)return;if(Ae.buttons%2===0){Va(Ae);return}const Ke=I.current;if(!Ke)return;const Je=Be.current==="vertical",rn=Je?Z.current:te.current,da=Je?N.current:_.current;if(!rn||!da)return;const hi=Je?"y":"x",mi=Tl(da,"padding",hi),Wn=Tl(rn,"margin",hi),Mt=Je?rn.offsetHeight:rn.offsetWidth,Et=(Je?da.offsetHeight:da.offsetWidth)-Mt-mi-Wn,pi=Je?Ae.clientY-ce.current:Ae.clientX-ge.current,zs=Et<=0?0:pi/Et,ks=Je?Ke.scrollHeight:Ke.scrollWidth,ea=Je?Ke.clientHeight:Ke.clientWidth,ma=(Je?ye.current:Xe.current)+zs*(ks-ea);Je?Ke.scrollTop=ma:Ke.scrollLeft=ma,Ae.preventDefault(),we(Je)});function In(Ae){H(Ae.pointerType==="touch")}function qn(Ae){if(In(Ae),Ae.pointerType!=="touch"){const Ke=wh(F.current,Ae.target);B(Ke)}}const fa=x.useMemo(()=>({scrolling:K||G,hasOverflowX:!$.x,hasOverflowY:!$.y,overflowXStart:P.xStart,overflowXEnd:P.xEnd,overflowYStart:P.yStart,overflowYEnd:P.yEnd,cornerHidden:$.corner}),[K,G,$.x,$.y,$.corner,P]),Al={role:"presentation",onPointerEnter:qn,onPointerMove:qn,onPointerDown:In,onPointerLeave(){B(!1)},style:{position:"relative","--scroll-area-corner-height":`${se.height}px`,"--scroll-area-corner-width":`${se.width}px`}},Rt=qt("div",l,{state:fa,ref:[s,F],props:[Al,y],stateAttributesMapping:Rh}),Os=x.useMemo(()=>({handlePointerDown:di,handlePointerMove:Pn,handlePointerUp:Va,handleScroll:Nt,disableViewportSnap:Bt,cornerSize:se,setCornerSize:re,thumbSize:ue,setThumbSize:le,hasMeasuredScrollbar:ee,setHasMeasuredScrollbar:Q,touchModality:V,cornerRef:ie,scrollingX:K,scrollingY:G,hovering:k,setHovering:B,viewportRef:I,scrollbarYRef:N,scrollbarXRef:_,thumbYRef:Z,thumbXRef:te,rootId:j,hiddenState:$,setHiddenState:Y,overflowEdges:P,setOverflowEdges:R,viewportState:fa,overflowEdgeThreshold:{xStart:p,xEnd:g,yStart:b,yEnd:S}}),[di,Pn,Va,Nt,Bt,se,ue,ee,V,K,G,k,j,$,P,fa,p,g,b,S]);return r.jsxs(yv.Provider,{value:Os,children:[!A&&xv.getElement(T),Rt]})});function UC(a){const l=typeof a=="number"?{xStart:a,xEnd:a,yStart:a,yEnd:a}:a;return{xStart:Math.max(0,(l==null?void 0:l.xStart)||0),xEnd:Math.max(0,(l==null?void 0:l.xEnd)||0),yStart:Math.max(0,(l==null?void 0:l.yStart)||0),yEnd:Math.max(0,(l==null?void 0:l.yEnd)||0)}}const HC=x.createContext(void 0),qC=x.createContext(void 0);function Mh(){const a=x.useContext(qC);return(a==null?void 0:a.direction)??"ltr"}function vv(a,l=Number.MIN_SAFE_INTEGER,s=Number.MAX_SAFE_INTEGER){return Math.max(l,Math.min(a,s))}const bx=1;function Sx(a,l){if(l<=0)return 0;const s=vv(a,0,l),u=s,f=l-s,d=u<=bx,m=f<=bx;return d&&m?u<=f?0:l:d?0:m?l:s}const bv=["--scroll-area-overflow-x-start","--scroll-area-overflow-x-end","--scroll-area-overflow-y-start","--scroll-area-overflow-y-end"];let jx=!1;function BC(){jx||Eh||(typeof CSS<"u"&&"registerProperty"in CSS&&bv.forEach(a=>{try{CSS.registerProperty({name:a,syntax:"<length>",inherits:!1,initialValue:"0px"})}catch{}}),jx=!0)}const QC=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,{viewportRef:y,scrollbarYRef:p,scrollbarXRef:g,thumbYRef:b,thumbXRef:S,cornerRef:j,cornerSize:E,setCornerSize:O,setThumbSize:T,rootId:A,setHiddenState:k,hiddenState:B,setHasMeasuredScrollbar:K,handleScroll:D,touchModality:G,setHovering:ae,setOverflowEdges:V,overflowEdgeThreshold:H,viewportState:ee}=Yo(),Q=Mh(),se=x.useRef(!0),re=x.useRef([NaN,NaN,NaN,NaN]),ue=Mo(),le=Mo(),P=qe(()=>{const I=y.current,N=p.current,_=g.current,Z=b.current,te=S.current,ie=j.current;if(!I)return;const oe=I.scrollHeight,ce=I.scrollWidth,ge=I.clientHeight,ye=I.clientWidth,Xe=I.scrollTop,Be=I.scrollLeft,tt=re.current,ft=Number.isNaN(tt[0]);if(tt[0]=ge,tt[1]=oe,tt[2]=ye,tt[3]=ce,ft&&K(!0),oe===0||ce===0)return;const we=YC(I),Nt=we.y,Bt=we.x,di=ye/ce,Va=ge/oe,Pn=Math.max(0,ce-ye),In=Math.max(0,oe-ge);let qn=0,fa=0;Bt||(qn=Sx(Q==="rtl"?-Be:Be,Pn),fa=Pn-qn);const Al=Nt?0:Sx(Xe,In),Rt=Nt?0:In-Al,Os=Bt?0:ye,Ae=Nt?0:ge;let Ke=0,Je=0;!Bt&&!Nt&&(Ke=(N==null?void 0:N.offsetWidth)||0,Je=(_==null?void 0:_.offsetHeight)||0);const rn=E.width===0&&E.height===0,da=rn?Ke:0,hi=rn?Je:0,mi=Tl(_,"padding","x"),Wn=Tl(N,"padding","y"),Mt=Tl(te,"margin","x"),vn=Tl(Z,"margin","y"),Et=Os-mi-Mt,pi=Ae-Wn-vn,zs=_?Math.min(_.offsetWidth-da,Et):Et,ks=N?Math.min(N.offsetHeight-hi,pi):pi,ea=Math.max(Kd,zs*di),ha=Math.max(Kd,ks*Va);if(T(At=>fo(At,{width:ea,height:ha})),N&&Z){const At=N.offsetHeight-ha-Wn-vn,Bn=Nx(Z,"--scroll-area-thumb-height",Xe,In,oe,ha,At);Z.style.transform=`translate3d(0,${Bn}px,0)`}if(_&&te){const At=_.offsetWidth-ea-mi-Mt,Bn=Q==="rtl"?-Be:Be,Vr=Nx(te,"--scroll-area-thumb-width",Bn,Pn,ce,ea,At);te.style.transform=`translate3d(${Q==="rtl"?-Vr:Vr}px,0,0)`}const ma=[qn,fa,Al,Rt];bv.forEach((At,Bn)=>{I.style.setProperty(At,`${ma[Bn]}px`)}),ie&&O(At=>fo(At,{width:Ke,height:Je})),k(At=>fo(At,we));const pa={xStart:!Bt&&qn>H.xStart,xEnd:!Bt&&fa>H.xEnd,yStart:!Nt&&Al>H.yStart,yEnd:!Nt&&Rt>H.yEnd};V(At=>fo(At,pa))});Ve(()=>{BC()},[]),Ve(()=>{queueMicrotask(P)},[P,B,Q,H.xStart,H.xEnd,H.yStart,H.yEnd]),Ve(()=>{var I;(I=y.current)!=null&&I.matches(":hover")&&ae(!0)},[y,ae]),Ve(()=>{const I=y.current;if(typeof ResizeObserver>"u"||!I)return;let N=!1;const _=new ResizeObserver(()=>{if(!N){N=!0;const Z=re.current;if(Z[0]===I.clientHeight&&Z[1]===I.scrollHeight&&Z[2]===I.clientWidth&&Z[3]===I.scrollWidth)return}P()});return _.observe(I),le.start(0,()=>{const Z=I.getAnimations({subtree:!0});Z.length!==0&&Promise.allSettled(Z.map(te=>te.finished)).then(P).catch(()=>{})}),()=>{_.disconnect(),le.clear()}},[P,y,le]);function R(){se.current=!1}const $={role:"presentation",...A&&{"data-id":`${A}-viewport`},tabIndex:B.x&&B.y?-1:0,className:xv.className,style:{overflow:"scroll"},onScroll(){y.current&&(P(),(G||!se.current)&&D({x:y.current.scrollLeft,y:y.current.scrollTop}),ue.start(100,()=>{se.current=!0}))},onWheel:R,onPointerMove:R,onPointerEnter:R,onKeyDown:R},Y=qt("div",l,{ref:[s,y],state:ee,props:[$,m],stateAttributesMapping:Rh}),F=x.useMemo(()=>({computeThumbPosition:P}),[P]);return r.jsx(HC.Provider,{value:F,children:Y})});function YC(a){const l=a.clientHeight>=a.scrollHeight,s=a.clientWidth>=a.scrollWidth;return{y:l,x:s,corner:l||s}}function fo(a,l){for(const s in l)if(a[s]!==l[s])return l;return a}function Nx(a,l,s,u,f,d,m){const y=vv(s,0,u),p=s-y,g=Math.max(Kd,d*f/(f+Math.abs(p)));return a.style.setProperty(l,p?`${g}px`:""),(u?y/u*m:0)+(p>0?d-g:0)}function Sv(a,l,s,u){return a.addEventListener(l,s,u),()=>{a.removeEventListener(l,s,u)}}const jv=x.createContext(void 0);function GC(){const a=x.useContext(jv);if(a===void 0)throw new Error(Ya(54));return a}const VC=x.forwardRef(function(l,s){const{render:u,className:f,orientation:d="vertical",keepMounted:m=!1,style:y,...p}=l,{hovering:g,scrollingX:b,scrollingY:S,hiddenState:j,scrollbarYRef:E,scrollbarXRef:O,viewportRef:T,thumbYRef:A,thumbXRef:k,handlePointerDown:B,handlePointerUp:K,handleScroll:D,disableViewportSnap:G,rootId:ae,thumbSize:V,hasMeasuredScrollbar:H,viewportState:ee}=Yo(),Q=d==="vertical",se={...ee,hovering:g,scrolling:Q?S:b,orientation:d},re=Mh(),ue=!H&&!m,le=Q?j.y:j.x,P=m||!le;x.useEffect(()=>{if(!P)return;const Y=T.current,F=Q?E.current:O.current;if(!F)return;function I(N){if(!Y||N.ctrlKey)return;const _=!Q,Z=_?"scrollLeft":"scrollTop",te=_?N.deltaX:N.deltaY;if(te===0)return;const ie=_?Y.scrollWidth-Y.clientWidth:Y.scrollHeight-Y.clientHeight,oe=_&&re==="rtl"?-ie:0,ce=_&&re==="rtl"?0:ie,ge=Y[Z];ge<=oe&&te<0||ge>=ce&&te>0||(N.preventDefault(),Y[Z]=Math.min(ce,Math.max(oe,ge+te)),D({x:Y.scrollLeft,y:Y.scrollTop}))}return Sv(F,"wheel",I,{passive:!1})},[re,D,Q,O,E,P,T]);const R={...ae&&{"data-id":`${ae}-scrollbar`},onPointerDown(Y){if(Y.button!==0)return;const F=Vd(Y.nativeEvent),I=Q?A.current:k.current;if(I&&wh(I,F))return;const N=T.current;if(!N)return;const _=Q?E.current:O.current;if(!I||!_)return;const Z=Q?"y":"x",te=Tl(I,"margin",Z),ie=Tl(_,"padding",Z),oe=Q?I.offsetHeight:I.offsetWidth,ce=_.getBoundingClientRect(),ge=Q?Y.clientY-ce.top-oe/2-ie+te/2:Y.clientX-ce.left-oe/2-ie+te/2,ye=Q?N.scrollHeight:N.scrollWidth,Xe=Q?N.clientHeight:N.clientWidth,tt=(Q?_.offsetHeight:_.offsetWidth)-oe-ie-te;if(tt<=0)return;const ft=ge/tt,we=ye-Xe;G(),Q?N.scrollTop=ft*we:re==="rtl"?N.scrollLeft=-(1-ft)*we:N.scrollLeft=ft*we,D({x:N.scrollLeft,y:N.scrollTop}),B(Y)},onPointerUp:K,onPointerCancel:K,style:{position:"absolute",touchAction:"none",WebkitUserSelect:"none",userSelect:"none",visibility:ue?"hidden":void 0,...Q?{top:0,bottom:"var(--scroll-area-corner-height)",insetInlineEnd:0,"--scroll-area-thumb-height":`${V.height}px`}:{insetInlineStart:0,insetInlineEnd:"var(--scroll-area-corner-width)",bottom:0,"--scroll-area-thumb-width":`${V.width}px`}}},$=qt("div",l,{ref:[s,Q?E:O],state:se,props:[R,p],stateAttributesMapping:Rh});return P?r.jsx(jv.Provider,{value:d,children:$}):null}),XC=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,{thumbYRef:y,thumbXRef:p,handlePointerDown:g,handlePointerMove:b,handlePointerUp:S,scrollingX:j,scrollingY:E,hasMeasuredScrollbar:O}=Yo(),T=GC(),A=T==="vertical";return qt("div",l,{ref:[s,A?y:p],state:{scrolling:A?E:j,orientation:T},props:[{onPointerDown:g,onPointerMove:b,onPointerUp:S,onPointerCancel:S,style:{visibility:O?void 0:"hidden",...A?{height:"var(--scroll-area-thumb-height)"}:{width:"var(--scroll-area-thumb-width)"}}},m]})}),KC=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,{cornerRef:y,cornerSize:p,hiddenState:g}=Yo(),b=qt("div",l,{ref:[s,y],props:[{style:{position:"absolute",bottom:0,insetInlineEnd:0,width:p.width,height:p.height}},m]});return g.corner?null:b});function _n({className:a,...l}){return r.jsx("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:r.jsx("table",{"data-slot":"table",className:ve("w-full caption-bottom text-sm",a),...l})})}function Ln({className:a,...l}){return r.jsx("thead",{"data-slot":"table-header",className:ve("[&_tr]:border-b",a),...l})}function Un({className:a,...l}){return r.jsx("tbody",{"data-slot":"table-body",className:ve("[&_tr:last-child]:border-0",a),...l})}function ct({className:a,...l}){return r.jsx("tr",{"data-slot":"table-row",className:ve("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",a),...l})}function je({className:a,...l}){return r.jsx("th",{"data-slot":"table-head",className:ve("h-12 px-3 text-left align-middle text-xs font-medium tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0",a),...l})}function Ne({className:a,...l}){return r.jsx("td",{"data-slot":"table-cell",className:ve("p-3 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",a),...l})}const Nv=x.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function $C(){return x.useContext(Nv)}function Ev(a={}){const{guess:l,label:s,metadata:u,textRef:f,index:d}=a,{register:m,unregister:y,subscribeMapChange:p,nextIndexRef:g}=$C(),b=x.useRef(-1),[S,j]=x.useState(d==null&&l?()=>{if(b.current===-1){const A=g.current;g.current+=1,b.current=A}return b.current}:-1),E=d??S,O=x.useRef(null),T=x.useCallback(A=>{const k=O.current;k&&y(k),O.current=A,A&&m(A,{metadata:u??null,index:d??null,label:s,textRef:f})},[d,m,y,u,s,f]);return Ve(()=>{if(d==null)return p(A=>{var B;const k=O.current?(B=A.get(O.current))==null?void 0:B.index:null;k!=null&&j(k)})},[d,p]),{ref:T,index:E}}function ZC(a){const l=ca(FC,a).current;return l.next=a,Ve(l.effect),l}function FC(a){const l={current:a,next:a,effect:()=>{l.current=l.next}};return l}const wv={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},JC={...wv,position:"fixed",top:0,left:0},PC={...wv,position:"absolute"},$d="ArrowUp",Zd="ArrowDown",Fd="ArrowLeft",Jd="ArrowRight",Pd="Home",Id="End",IC=new Set([$d,Zd,Fd,Jd,Pd,Id]),WC="Shift",e3=[WC,"Control","Alt","Meta"];function t3(a){return Ho(a)&&a.tagName==="INPUT"}function Ex(a){return!!(t3(a)&&a.selectionStart!=null||Ho(a)&&a.tagName==="TEXTAREA")}function wx(a,l,s,u){if(!a||!l||!l.scrollTo)return;let f=a.scrollLeft,d=a.scrollTop;const m=a.clientWidth<a.scrollWidth,y=a.clientHeight<a.scrollHeight;if(m&&u!=="vertical"){const p=Cx(a,l,"left"),g=ho(a),b=ho(l);s==="ltr"&&(p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight?f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight:p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft&&(f=p-b.scrollMarginLeft-g.scrollPaddingLeft)),s==="rtl"&&(p-b.scrollMarginLeft<a.scrollLeft+g.scrollPaddingLeft?f=p-b.scrollMarginLeft-g.scrollPaddingLeft:p+l.offsetWidth+b.scrollMarginRight>a.scrollLeft+a.clientWidth-g.scrollPaddingRight&&(f=p+l.offsetWidth+b.scrollMarginRight-a.clientWidth+g.scrollPaddingRight))}if(y&&u!=="horizontal"){const p=Cx(a,l,"top"),g=ho(a),b=ho(l);p-b.scrollMarginTop<a.scrollTop+g.scrollPaddingTop?d=p-b.scrollMarginTop-g.scrollPaddingTop:p+l.offsetHeight+b.scrollMarginBottom>a.scrollTop+a.clientHeight-g.scrollPaddingBottom&&(d=p+l.offsetHeight+b.scrollMarginBottom-a.clientHeight+g.scrollPaddingBottom)}a.scrollTo({left:f,top:d,behavior:"auto"})}function Cx(a,l,s){const u=s==="left"?"offsetLeft":"offsetTop";let f=0;for(;l.offsetParent&&(f+=l[u],l.offsetParent!==a);)l=l.offsetParent;return f}function ho(a){const l=getComputedStyle(a);return{scrollMarginTop:parseFloat(l.scrollMarginTop)||0,scrollMarginRight:parseFloat(l.scrollMarginRight)||0,scrollMarginBottom:parseFloat(l.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(l.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(l.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(l.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(l.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(l.scrollPaddingLeft)||0}}function n3(a){return V0(19)?a:a?"true":void 0}function Cv(a){const{children:l,elementsRef:s,labelsRef:u,onMapChange:f}=a,d=qe(f),[,m]=x.useState(!1),y=ca(l3).current,p=ca(a3).current,g=x.useRef(0),b=x.useRef(!0),S=x.useRef([]),j=x.useRef(null),E=qe(()=>{b.current||(b.current=!0,m(G=>!G))}),O=qe((G,ae)=>{p.set(G,ae),E()}),T=qe(G=>{p.delete(G),E()}),A=qe(G=>{const ae=new Map;return s.current.length=0,u&&(u.current.length=0),G.forEach(V=>{var H,ee;ae.set(V.element,{...V.registration.metadata??{},index:V.index}),s.current[V.index]=V.element,u&&(u.current[V.index]=V.registration.label!==void 0?V.registration.label:((ee=(H=V.registration.textRef)==null?void 0:H.current)==null?void 0:ee.textContent)??V.element.textContent)}),g.current=s.current.length,ae});function k(G){var H;if((H=j.current)==null||H.disconnect(),j.current=null,typeof MutationObserver!="function"||G.length<2)return;const ae=new MutationObserver(ee=>{if(!r3(ee))return;let Q=null;for(const se of G)if(se.isConnected){if(Q&&Tv(Q,se)>0){ae.disconnect(),E();return}Q=se}});j.current=ae;const V=new Set;for(let ee=1;ee<G.length;ee+=1){const Q=s3(G[ee-1],G[ee]);Q&&V.add(Q)}V.forEach(ee=>ae.observe(ee,{childList:!0}))}const B=qe(()=>{const[G,ae]=i3(p),V=A(G);k(ae),S.current=G,b.current=!1,y.forEach(H=>H(V)),d(V)});Ve(()=>(b.current||A(S.current),()=>{s.current=[],u&&(u.current=[])}),[s,u,A]),Ve(()=>{b.current&&B()}),Ve(()=>()=>{var G;(G=j.current)==null||G.disconnect(),b.current=!0},[]);const K=qe(G=>(y.add(G),()=>{y.delete(G)})),D=x.useMemo(()=>({register:O,unregister:T,subscribeMapChange:K,nextIndexRef:g}),[O,T,K,g]);return r.jsx(Nv.Provider,{value:D,children:l})}function a3(){return new Map}function l3(){return new Set}function i3(a){const l=new Set,s=[],u=[];a.forEach((d,m)=>{if(!m.isConnected)return;const y=d.index,p={index:y??-1,element:m,registration:d};y===null?u.push(p):y>=0&&(l.add(y),s.push(p))});let f=0;return u.sort((d,m)=>Tv(d.element,m.element)),u.forEach(d=>{for(;l.has(f);)f+=1;d.index=f,s.push(d),f+=1}),l.size>0&&s.sort((d,m)=>d.index-m.index),[s,u.map(d=>d.element)]}function s3(a,l){let s=a.parentElement;for(;s&&!s.contains(l);)s=s.parentElement;return s}function r3(a){for(const l of a)for(let s=0;s<l.removedNodes.length;s+=1)if(l.removedNodes[s].isConnected)return!0;return!1}function Tv(a,l){return a.compareDocumentPosition(l)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function u3(a,l){const s=x.useRef(a),u=qe(l);Ve(()=>{s.current!==a&&u(s.current),s.current=a},[a,u])}function o3(a={}){const{highlightItemOnHover:l,highlightedIndex:s,onHighlightedIndexChange:u}=Sh(),{ref:f,index:d}=Ev(a),m=s===d,y=x.useRef(null),p=Ss(f,y);return{compositeProps:{tabIndex:m?0:-1,onFocus(){u(d)},onMouseMove(){const b=y.current;if(!l||!b)return;const S=b.hasAttribute("disabled")||b.ariaDisabled==="true";!m&&!S&&b.focus()}},compositeRef:p,index:d}}function c3(a){return a==null||a.hasAttribute("disabled")||a.getAttribute("aria-disabled")==="true"}const Rv="data-composite-item-active",f3=[];function d3(a){const{loopFocus:l=!0,orientation:s="both",grid:u,onLoop:f,direction:d,highlightedIndex:m,onHighlightedIndexChange:y,rootRef:p,enableHomeAndEndKeys:g=!1,stopEventPropagation:b,disabledIndices:S,modifierKeys:j=f3}=a,[E,O]=x.useState(0),T=u!=null,A=x.useRef(null),k=Ss(A,p),B=x.useRef([]),K=x.useRef(!1),D=m??E,G=qe((Q,se=!1)=>{if((y??O)(Q),se){const re=B.current[Q];wx(A.current,re,d,s)}}),ae=qe(Q=>{var le;if(Q.size===0||K.current)return;K.current=!0;const se=Array.from(Q.keys()),re=se.find(P=>P==null?void 0:P.hasAttribute(Rv))??null,ue=re?((le=Q.get(re))==null?void 0:le.index)??-1:-1;if(ue!==-1)G(ue);else if(Xd(se,D,S)){const P=zr(se,{disabledIndices:S});bd(se,P)||G(P)}wx(A.current,re,d,s)});Ve(()=>{if(S==null||m!=null||!K.current)return;const Q=B.current;if(Xd(Q,D,S)){const se=zr(Q,{disabledIndices:S});bd(Q,se)||G(se)}},[S,m,D,B,G]);const V=qe((Q,se,re)=>f?f(Q,se,re,B):re),H=qe(Q=>{const se=Q.key===Pd||Q.key===Id;if(!IC.has(Q.key)||!g&&se||h3(Q,j)||!A.current)return;const ue=d==="rtl",le=ue?Fd:Jd,P=ue?Jd:Fd,R=s==="vertical"?Zd:le,$=s==="vertical"?$d:P,Y=Vd(Q.nativeEvent);if(Y!=null&&Ex(Y)&&!c3(Y)){const te=Y.selectionStart,ie=Y.selectionEnd,oe=Y.value;if(te==null||Q.shiftKey||te!==ie||Q.key!==$&&te<oe.length||Q.key!==R&&te>0)return}let F=D;const I=gC(B,S),N=yC(B,S);u!=null&&(F=u({disabledIndices:S,elementsRef:B,event:Q,highlightedIndex:D,loopFocus:l,maxIndex:N,minIndex:I,onLoop:V,orientation:s,rtl:ue}));const _=s!=="vertical"&&Q.key===le||s!=="horizontal"&&Q.key===Zd,Z=s!=="vertical"&&Q.key===P||s!=="horizontal"&&Q.key===$d;g&&(Q.key===Pd?F=I:Q.key===Id&&(F=N)),F===D&&(_||Z)&&(l&&F===N&&_?(F=I,f&&(F=f(Q,D,F,B))):l&&F===I&&Z?(F=N,f&&(F=f(Q,D,F,B))):F=zr(B.current,{startingIndex:F,decrement:Z,disabledIndices:S})),F!==D&&!bd(B.current,F)&&(b&&Q.stopPropagation(),(T||se||_||Z)&&Q.preventDefault(),G(F,!0),queueMicrotask(()=>{var te;(te=B.current[F])==null||te.focus()}))});return{props:{ref:k,onFocus(Q){const se=A.current,re=Vd(Q.nativeEvent);!se||re==null||!Ex(re)||re.setSelectionRange(0,re.value.length)},onKeyDown:H},highlightedIndex:D,onHighlightedIndexChange:G,elementsRef:B,onMapChange:ae,relayKeyboardEvent:H}}function h3(a,l){for(const s of e3)if(!l.includes(s)&&a.getModifierState(s))return!0;return!1}function m3(a){const{render:l,className:s,style:u,refs:f=To,props:d=To,state:m=Ha,stateAttributesMapping:y,highlightedIndex:p,onHighlightedIndexChange:g,orientation:b,grid:S,loopFocus:j,onLoop:E,enableHomeAndEndKeys:O,onMapChange:T,stopEventPropagation:A=!0,rootRef:k,disabledIndices:B,modifierKeys:K,highlightItemOnHover:D=!1,tag:G="div",...ae}=a,V=Mh(),{props:H,highlightedIndex:ee,onHighlightedIndexChange:Q,elementsRef:se,onMapChange:re,relayKeyboardEvent:ue}=d3({grid:S,loopFocus:j,onLoop:E,orientation:b,highlightedIndex:p,onHighlightedIndexChange:g,rootRef:k,stopEventPropagation:A,enableHomeAndEndKeys:O,direction:V,disabledIndices:B,modifierKeys:K}),le=qt(G,a,{state:m,ref:f,props:[H,...d,ae],stateAttributesMapping:y}),P=x.useMemo(()=>({highlightedIndex:ee,onHighlightedIndexChange:Q,highlightItemOnHover:D,relayKeyboardEvent:ue}),[ee,Q,D,ue]);return r.jsx(sv.Provider,{value:P,children:r.jsx(Cv,{elementsRef:se,onMapChange:R=>{T==null||T(R),re(R)},children:le})})}const Mv=x.createContext(void 0);function p3(){const a=x.useContext(Mv);if(a===void 0)throw new Error(Ya(63));return a}const Av={...rv,checked(a){return a?{"data-checked":""}:{"data-unchecked":""}}},g3=x.forwardRef(function(l,s){const{checked:u,className:f,defaultChecked:d,"aria-labelledby":m,form:y,id:p,inputRef:g,name:b,nativeButton:S=!1,onCheckedChange:j,readOnly:E=!1,required:O=!1,disabled:T=!1,render:A,uncheckedValue:k,value:B,style:K,...D}=l,{clearErrors:G}=uv(),{state:ae,setTouched:V,setDirty:H,validityData:ee,setFilled:Q,setFocused:se,validationMode:re,disabled:ue,name:le,validation:P}=jh(),{labelId:R}=Nh(),$=ue||T,Y=le??b,F=x.useRef(null),I=Ss(F,g,P.inputRef),N=x.useRef(null),_=ci(),Z=ov({id:p,implicit:!1,controlRef:N}),te=S?void 0:Z,[ie,oe]=Bo({controlled:u,default:!!d,name:"Switch",state:"checked"});gv(N,_,ie,void 0,!$,b),Ve(()=>{F.current&&Q(F.current.checked)},[Q]),u3(ie,()=>{G(Y),H(ie!==ee.initialValue),Q(ie),P.change(ie)});const{getButtonProps:ce,buttonRef:ge}=qo({disabled:$,native:S}),ye=cC(m,R,F,!S,te),Xe={id:S?Z:_,role:"switch","aria-checked":ie,"aria-readonly":E||void 0,"aria-required":O||void 0,"aria-labelledby":ye,onFocus(){$||se(!0)},onBlur(){const we=F.current;!we||$||(V(!0),se(!1),re==="onBlur"&&P.commit(we.checked))},onClick(we){if(E||$)return;we.preventDefault();const Nt=F.current;Nt&&So(Nt,we)}},Be={...P.getValidationProps($),checked:ie,disabled:$,form:y,id:te,name:Y,required:O,style:Y?PC:JC,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:I,onChange(we){if(we.nativeEvent.defaultPrevented)return;if(E){we.preventDefault();return}const Nt=we.currentTarget.checked,Bt=As(Qo,we.nativeEvent);j==null||j(Nt,Bt),!Bt.isCanceled&&oe(Nt)},onClick(we){we.stopPropagation()},onFocus(){var we;(we=N.current)==null||we.focus()},...B!==void 0?{value:B}:Ha},tt=x.useMemo(()=>({...ae,checked:ie,disabled:$,readOnly:E,required:O}),[ae,ie,$,E,O]),ft=qt("span",l,{state:tt,ref:[s,N,ge],props:[Xe,D,ce,we=>P.getValidationProps($,we)],stateAttributesMapping:Av});return r.jsxs(Mv.Provider,{value:tt,children:[ft,!ie&&Y&&k!==void 0&&r.jsx("input",{type:"hidden",form:y,name:Y,value:k,disabled:$}),r.jsx("input",{...Be,suppressHydrationWarning:!0})]})}),y3=x.forwardRef(function(l,s){const{render:u,className:f,style:d,...m}=l,y=p3();return qt("span",l,{state:y,ref:s,stateAttributesMapping:Av,props:m})}),Ov=x.createContext(void 0);function Ah(){const a=x.useContext(Ov);if(a===void 0)throw new Error(Ya(64));return a}const Go={tabActivationDirection:a=>({"data-activation-direction":a})},x3=x.forwardRef(function(l,s){const{className:u,defaultValue:f=0,onValueChange:d,orientation:m="horizontal",render:y,value:p,style:g,...b}=l,S=l.defaultValue!==void 0,j=x.useRef([]),[E,O]=x.useState(()=>new Map),[T,A]=Bo({controlled:p,default:f,name:"Tabs",state:"value"}),k=p!==void 0,[B,K]=x.useState(()=>new Map),D=x.useRef(void 0),G=x.useCallback(ge=>Wd(B,ge),[B]),[ae,V]=x.useState(()=>({previousValue:T,tabActivationDirection:"none"})),{previousValue:H,tabActivationDirection:ee}=ae;let Q=ee,se=!1;H!==T&&(Q=Tx(H,T,m,B),se=H!=null&&T!=null&&G(T)==null);const re=se?H:T,ue=H!==re||ee!==Q;Ve(()=>{ue&&V({previousValue:re,tabActivationDirection:Q})},[re,ue,Q]);const le=qe((ge,ye)=>{const Xe=Tx(T,ge,m,B);ye.activationDirection=Xe,d==null||d(ge,ye),!ye.isCanceled&&A(ge)}),P=qe((ge,ye)=>{d==null||d(ge,As(ye,void 0,void 0,{activationDirection:"none"}))}),R=qe((ge,ye)=>(O(Xe=>{const Be=new Map(Xe);return Be.set(ge,ye),Be}),()=>{O(Xe=>{if(Xe.get(ge)!==ye)return Xe;const Be=new Map(Xe);return Be.delete(ge),Be})})),$=x.useCallback(ge=>E.get(ge),[E]),Y=x.useCallback(ge=>{for(const ye of B.values())if(ge===ye.value)return ye.id},[B]),F=x.useMemo(()=>({getTabElementBySelectedValue:G,getTabIdByPanelValue:Y,getTabPanelIdByValue:$,onValueChange:le,orientation:m,registerMountedTabPanel:R,setTabMap:K,tabActivationDirection:Q,value:T}),[G,Y,$,le,m,R,K,Q,T]),I=x.useMemo(()=>{for(const ge of B.values())if(ge.value===T)return ge},[B,T]),N=x.useMemo(()=>{for(const ge of B.values())if(!ge.disabled)return ge.value},[B]),_=x.useRef(!S),Z=x.useRef(f),te=x.useRef(S),ie=x.useRef(!1);Ve(()=>{var tt;if(k)return;function ge(ft,we){A(ft),V({previousValue:ft,tabActivationDirection:"none"}),P(ft,we),_.current=!1}if(B.size===0){ie.current&&T!==null&&!((tt=D.current)!=null&&tt.isConnected)&&ge(null,yx);return}ie.current=!0,D.current=B.keys().next().value;const ye=I==null?void 0:I.disabled,Xe=I==null&&T!==null;if(!ye&&T===Z.current&&(te.current=!1),te.current&&ye&&T===Z.current)return;const Be=_.current;if(ye||Xe){const ft=N??null;if(T===ft){_.current=!1;return}let we=yx;Be?we=xx:ye&&(we=CC),ge(ft,we);return}Be&&I!=null&&(P(T,xx),_.current=!1)},[N,k,P,I,A,B,T]);const ce=qt("div",l,{state:{orientation:m,tabActivationDirection:Q},ref:s,props:b,stateAttributesMapping:Go});return r.jsx(Ov.Provider,{value:F,children:r.jsx(Cv,{elementsRef:j,children:ce})})});function Wd(a,l){for(const[s,u]of a.entries())if(l===u.value)return s;return null}function Tx(a,l,s,u){if(a==null||l==null)return"none";const[f,d,m]=s==="horizontal"?["left","left","right"]:["top","up","down"],y=Wd(u,a),p=Wd(u,l);if(y==null||p==null)return y!==p&&(typeof a=="number"||typeof a=="string")&&typeof a==typeof l?l>a?m:d:"none";const g=y.getBoundingClientRect()[f],b=p.getBoundingClientRect()[f];return b<g?d:b>g?m:"none"}const zv=x.createContext(void 0);function v3(){const a=x.useContext(zv);if(a===void 0)throw new Error(Ya(65));return a}const b3=x.forwardRef(function(l,s){const{className:u,disabled:f=!1,render:d,value:m,id:y,nativeButton:p=!0,style:g,...b}=l,{value:S,getTabPanelIdByValue:j,onValueChange:E,orientation:O,tabActivationDirection:T}=Ah(),{activateOnFocus:A,registerTabResizeObserverElement:k,tabsListElement:B}=v3(),{highlightedIndex:K,onHighlightedIndexChange:D}=Sh(),G=ci(y),ae=x.useMemo(()=>({disabled:f,id:G,value:m}),[f,G,m]),{compositeProps:V,compositeRef:H,index:ee}=o3({metadata:ae}),Q=m===S,se=x.useRef(!1),re=x.useRef(null),ue=qe(ie=>{var oe;(oe=re.current)==null||oe.call(re),re.current=ie?k(ie):null});Ve(()=>{if(se.current){se.current=!1;return}if(!(Q&&ee>-1&&K!==ee))return;const ie=B;if(ie!=null){const oe=fv(Gd(ie));if(oe&&wh(ie,oe))return}f||D(ee)},[Q,ee,K,D,f,B]);const{getButtonProps:le,buttonRef:P}=qo({disabled:f,native:p,focusableWhenDisabled:!0}),R=j(m),$=x.useRef(!1),Y=x.useRef(!1);function F(ie){E(m,As(Qo,ie.nativeEvent,void 0,{activationDirection:"none"}))}function I(ie){Q||f||F(ie)}function N(ie){Q||f||A&&(!$.current||Y.current)&&F(ie)}function _(ie){if(Q||f)return;$.current=!0,Y.current=ie.button===0;const oe=Gd(ie.currentTarget);function ce(){$.current=!1,Y.current=!1,oe.removeEventListener("pointerup",ce),oe.removeEventListener("pointercancel",ce)}oe.addEventListener("pointerup",ce),oe.addEventListener("pointercancel",ce)}return qt("button",l,{state:{disabled:f,active:Q,orientation:O,tabActivationDirection:T},ref:[s,P,H,ue],props:[V,{role:"tab","aria-controls":R,"aria-selected":Q,id:G,onClick:I,onFocus:N,onPointerDown:_,[Rv]:Q?"":void 0,onKeyDownCapture(){se.current=!0}},b,le],stateAttributesMapping:Go})}),S3={...Go,...Th},j3=x.forwardRef(function(l,s){const{className:u,value:f,render:d,keepMounted:m=!1,style:y,...p}=l,{value:g,getTabIdByPanelValue:b,orientation:S,tabActivationDirection:j,registerMountedTabPanel:E}=Ah(),O=ci(),{ref:T,index:A}=Ev(),k=f===g,{mounted:B,transitionStatus:K,setMounted:D}=pv(k),G=!B,ae=b(f),V={hidden:G,orientation:S,tabActivationDirection:j,transitionStatus:K},H=x.useRef(null),ee=qt("div",l,{state:V,ref:[s,T,H],props:[{"aria-labelledby":ae,hidden:G,id:O,role:"tabpanel",tabIndex:k?0:-1,inert:n3(!k),"data-index":A},p],stateAttributesMapping:S3});return mv({open:k,ref:H,onComplete(){k||D(!1)}}),Ve(()=>{if(!(O==null||G&&!m))return E(f,O)},[G,m,f,O,E]),m||B?ee:null}),N3=x.forwardRef(function(l,s){const{activateOnFocus:u=!1,className:f,loopFocus:d=!0,render:m,style:y,...p}=l,{orientation:g,setTabMap:b,tabActivationDirection:S}=Ah(),[j,E]=x.useState(0),[O,T]=x.useState(null),A=x.useRef(new Set),k=x.useRef(new Set),B=x.useRef(null);Ve(()=>{if(typeof ResizeObserver>"u")return;const H=new ResizeObserver(()=>{A.current.forEach(ee=>{ee()})});return B.current=H,O&&H.observe(O),k.current.forEach(ee=>{H.observe(ee)}),()=>{H.disconnect(),B.current=null}},[O]);const K=qe(H=>(A.current.add(H),()=>{A.current.delete(H)})),D=qe(H=>{var ee;return k.current.add(H),(ee=B.current)==null||ee.observe(H),()=>{var Q;k.current.delete(H),(Q=B.current)==null||Q.unobserve(H)}}),G={orientation:g,tabActivationDirection:S},ae={"aria-orientation":g==="vertical"?"vertical":void 0,role:"tablist"},V=x.useMemo(()=>({activateOnFocus:u,registerIndicatorUpdateListener:K,registerTabResizeObserverElement:D,tabsListElement:O}),[u,K,D,O]);return r.jsx(zv.Provider,{value:V,children:r.jsx(m3,{render:m,className:f,style:y,state:G,refs:[s,T],props:[ae,p],stateAttributesMapping:Go,highlightedIndex:j,enableHomeAndEndKeys:!0,loopFocus:d,orientation:g,onHighlightedIndexChange:E,onMapChange:b,disabledIndices:To})})});function E3(a){const{open:l,defaultOpen:s,onOpenChange:u,disabled:f}=a,[d,m]=Bo({controlled:l,default:s,name:"Collapsible",state:"open"}),{mounted:y,setMounted:p,transitionStatus:g}=pv(d,!0,!0),b=ci(),[S,j]=x.useState(),E=S===null?void 0:S??b,O=qe(T=>{const A=!d,k=As(wC,T.nativeEvent);u(A,k),!k.isCanceled&&m(A)});return x.useMemo(()=>({defaultPanelId:b,disabled:f,handleTrigger:O,mounted:y,open:d,panelId:E,setMounted:p,setOpen:m,setPanelIdState:j,transitionStatus:g}),[b,f,O,y,d,E,p,m,j,g])}const kv=x.createContext(void 0);function Dv(){const a=x.useContext(kv);if(a===void 0)throw new Error(Ya(15));return a}let Oh=(function(a){return a.open="data-open",a.closed="data-closed",a[a.startingStyle=gx.startingStyle]="startingStyle",a[a.endingStyle=gx.endingStyle]="endingStyle",a})({}),w3=(function(a){return a.panelOpen="data-panel-open",a})({});const C3={[Oh.open]:""},T3={[Oh.closed]:""},R3={open(a){return a?{[w3.panelOpen]:""}:null}},M3={open(a){return a?C3:T3}},Mr={height:void 0,width:void 0};function A3(a){const{externalRef:l,hiddenUntilFound:s,id:u,keepMounted:f,mounted:d,onOpenChange:m,open:y,setMounted:p,setOpen:g,transitionStatus:b}=a,S=x.useRef(null),j=x.useRef(null),[E,O]=x.useState(Mr),T=x.useRef(Mr),A=x.useRef(!1),k=x.useRef(y),B=x.useRef(!1),[K,D]=x.useState(!1),G=x.useRef(null),ae=Ss(l,S),V=ZC(y),H=hv(S),ee=!y&&!d,Q=K?"idle":b,se=y&&(k.current||B.current),re=!y&&d&&j.current==="css-animation"&&E.height===void 0&&E.width===void 0?T.current:E,ue=s&&ee&&j.current!=="css-animation",le=qe((F,I=!0)=>{I&&(T.current=F),O(F)}),P=qe(()=>{var F;(F=G.current)==null||F.call(G),G.current=null}),R=qe(F=>{P(),G.current=()=>{G.current=null,F()}}),$=qe(()=>{y&&d&&j.current==="css-animation"&&(B.current=!0)});Ve(()=>{!K||b==="starting"||D(!1)},[K,b]),x.useEffect(()=>()=>{$(),P()},[$,P]),Ve(()=>{const F=S.current;if(!F)return;!y&&G.current&&P();const I=O3(F,se);if(j.current=I,y&&b==="idle"&&k.current&&I==="css-animation"){T.current=ns(F);return}if(y&&b==="starting"){const Z=A.current;if(A.current=!1,I==="none"){le(ns(F)),D(!0);return}if(I==="css-transition"){const oe=z3(F);if(le(ns(F)),!Z)return oe;const ce=mo(F,"transition-duration","0s");return R(ce),D(!0),oe}le(ns(F));const te=mo(F,"animation-name","none");if(!Z){te();return}const ie=mo(F,"animation-duration","0s");te(),R(ie),D(!0);return}if(!y&&d&&(b==="idle"||b==="starting")){if(k.current=!1,B.current=!1,I==="none"){le(Mr,!1),p(!1);return}le(ns(F));return}if(b!=="ending")return;if(I==="none"){p(!1);return}const N=ns(F);if(!(N.height>0||N.width>0)){p(!1);return}le(N),I==="css-animation"&&mo(F,"animation-name","none")()},[d,y,P,le,p,R,se,b]),mv({enabled:y&&d&&Q==="idle",open:!0,ref:S,onComplete(){y&&le(Mr,!1)}}),x.useEffect(()=>{if(y||!d||Q!=="ending"||!S.current)return;const I=new AbortController;let N=-1;function _(){V.current||(p(!1),le(Mr,!1))}return N=gn.request(()=>{H(_,I.signal)}),()=>{gn.cancel(N),I.abort()}},[V,d,y,Q,H,le,p]),Ve(()=>{const F=S.current;!F||!s||!ee||F.setAttribute("hidden","until-found")},[ee,s]),x.useEffect(function(){const I=S.current;if(!I)return;function N(_){const Z=As(Qo,_);m(!0,Z),!Z.isCanceled&&(A.current=!0,g(!0))}return Sv(I,"beforematch",N)},[m,g]);const Y=f||s||d||y;return{height:re.height,props:{...ue?{[Oh.startingStyle]:""}:void 0,hidden:ee,id:u},ref:ae,shouldPreventOpenAnimation:se,shouldRender:Y,transitionStatus:Q,width:re.width}}function ns(a){return{height:a.scrollHeight,width:a.scrollWidth}}function O3(a,l){const s=Ms(a).getComputedStyle(a),u=(s.animationName.split(",").map(d=>d.trim()).some(d=>d!==""&&d!=="none")||l)&&Rx(s.animationDuration),f=Rx(s.transitionDuration);return u&&f||f?"css-transition":u?"css-animation":"none"}function Rx(a){return a.split(",").map(l=>l.trim()).some(l=>l!==""&&Number.parseFloat(l)>0)}function mo(a,l,s){const u=a.style.getPropertyValue(l),f=a.style.getPropertyPriority(l);return a.style.setProperty(l,s),()=>{if(u===""){a.style.removeProperty(l);return}a.style.setProperty(l,u,f)}}function z3(a){const l={"justify-content":a.style.justifyContent,"align-items":a.style.alignItems,"align-content":a.style.alignContent,"justify-items":a.style.justifyItems};Object.keys(l).forEach(f=>{a.style.setProperty(f,"initial","important")});function s(){Object.entries(l).forEach(([f,d])=>{if(d===""){a.style.removeProperty(f);return}a.style.setProperty(f,d)})}const u=gn.request(s);return()=>{gn.cancel(u),s()}}const _v={...M3,...Th},k3=x.forwardRef(function(l,s){const{render:u,className:f,defaultOpen:d=!1,disabled:m=!1,onOpenChange:y,open:p,style:g,...b}=l,S=qe(y),j=E3({open:p,defaultOpen:d,onOpenChange:S,disabled:m}),E=x.useMemo(()=>({open:j.open,disabled:j.disabled,transitionStatus:j.transitionStatus}),[j.open,j.disabled,j.transitionStatus]),O=x.useMemo(()=>({...j,onOpenChange:S,state:E}),[j,S,E]),T=qt("div",l,{state:E,ref:s,props:b,stateAttributesMapping:_v});return r.jsx(kv.Provider,{value:O,children:T})}),D3={...R3,...Th},_3=x.forwardRef(function(l,s){const{panelId:u,open:f,handleTrigger:d,state:m,disabled:y}=Dv(),{className:p,disabled:g=y,render:b,nativeButton:S=!0,style:j,...E}=l,{getButtonProps:O,buttonRef:T}=qo({disabled:g,focusableWhenDisabled:!0,native:S});return qt("button",l,{state:m,ref:[s,T],props:[{"aria-controls":f?u:void 0,"aria-expanded":f,onClick:d},E,O],stateAttributesMapping:D3})});let Mx=(function(a){return a.collapsiblePanelHeight="--collapsible-panel-height",a.collapsiblePanelWidth="--collapsible-panel-width",a})({});const L3=x.forwardRef(function(l,s){const{className:u,hiddenUntilFound:f,keepMounted:d,render:m,id:y,style:p,...g}=l,{defaultPanelId:b,mounted:S,onOpenChange:j,open:E,setMounted:O,setPanelIdState:T,setOpen:A,state:k,transitionStatus:B}=Dv(),K=f??!1,D=d??!1,G=y||void 0,ae=G??b;Ve(()=>(T($=>G??($===null?void 0:$)),()=>{T($=>$===G?null:$)}),[G,T]);const{height:V,props:H,ref:ee,shouldPreventOpenAnimation:Q,shouldRender:se,transitionStatus:re,width:ue}=A3({externalRef:s,hiddenUntilFound:K,id:ae,keepMounted:D,mounted:S,onOpenChange:j,open:E,setMounted:O,setOpen:A,transitionStatus:B}),le={...k,transitionStatus:re},P=X0(p,le),R=qt("div",{...l,style:void 0},{state:le,ref:ee,props:[H,{style:{[Mx.collapsiblePanelHeight]:V===void 0?"auto":`${V}px`,[Mx.collapsiblePanelWidth]:ue===void 0?"auto":`${ue}px`}},g,P?{style:P}:void 0,Q?{style:{animationName:"none"}}:void 0],stateAttributesMapping:_v});return se?R:null});function Lv(a){var l,s,u="";if(typeof a=="string"||typeof a=="number")u+=a;else if(typeof a=="object")if(Array.isArray(a)){var f=a.length;for(l=0;l<f;l++)a[l]&&(s=Lv(a[l]))&&(u&&(u+=" "),u+=s)}else for(s in a)a[s]&&(u&&(u+=" "),u+=s);return u}function U3(){for(var a,l,s=0,u="",f=arguments.length;s<f;s++)(a=arguments[s])&&(l=Lv(a))&&(u&&(u+=" "),u+=l);return u}const Ax=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,Ox=U3,zh=(a,l)=>s=>{var u;if((l==null?void 0:l.variants)==null)return Ox(a,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:f,defaultVariants:d}=l,m=Object.keys(f).map(g=>{const b=s==null?void 0:s[g],S=d==null?void 0:d[g];if(b===null)return null;const j=Ax(b)||Ax(S);return f[g][j]}),y=s&&Object.entries(s).reduce((g,b)=>{let[S,j]=b;return j===void 0||(g[S]=j),g},{}),p=l==null||(u=l.compoundVariants)===null||u===void 0?void 0:u.reduce((g,b)=>{let{class:S,className:j,...E}=b;return Object.entries(E).every(O=>{let[T,A]=O;return Array.isArray(A)?A.includes({...d,...y}[T]):{...d,...y}[T]===A})?[...g,S,j]:g},[]);return Ox(a,m,p,s==null?void 0:s.class,s==null?void 0:s.className)},H3=zh("inline-flex w-fit shrink-0 items-center justify-center gap-1.5 overflow-hidden rounded-none border px-2 py-0.5 text-[0.625rem] font-semibold uppercase tracking-widest whitespace-nowrap transition-colors focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive [&>svg]:pointer-events-none [&>svg]:size-3",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/80",destructive:"border-destructive/20 bg-destructive/10 text-destructive [a&]:hover:bg-destructive/20",outline:"border-border text-foreground [a&]:hover:bg-muted [a&]:hover:text-foreground"}},defaultVariants:{variant:"default"}});function q3({className:a,variant:l="default",render:s,...u}){return zE({defaultTagName:"span",props:Uo({className:ve(H3({variant:l}),a)},u),render:s,state:{slot:"badge",variant:l}})}const B3={default:"text-muted-foreground bg-muted border-border",success:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400",error:"text-red-700 bg-red-500/10 border-red-500/25 dark:text-red-400",warning:"text-amber-700 bg-amber-500/10 border-amber-500/25 dark:text-amber-400",purple:"text-purple-700 bg-purple-500/10 border-purple-500/25 dark:text-purple-400",blue:"text-blue-700 bg-blue-500/10 border-blue-500/25 dark:text-blue-400",orange:"text-orange-700 bg-orange-500/10 border-orange-500/25 dark:text-orange-400",emerald:"text-emerald-700 bg-emerald-500/10 border-emerald-500/25 dark:text-emerald-400"};function Ml({className:a,icon:l,variant:s="default",children:u,...f}){return r.jsxs("div",{"data-slot":"tag",className:ve("inline-flex items-center gap-1.5 rounded-none border px-2.5 py-1 text-[0.625rem] font-semibold uppercase tracking-widest [&_svg]:h-3 [&_svg]:w-3",B3[s],a),...f,children:[l&&r.jsx("span",{className:"flex-shrink-0",children:l}),r.jsx("span",{className:"leading-none",children:u})]})}const Q3=zh("group/button relative inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-none border border-transparent bg-clip-padding text-xs font-semibold uppercase tracking-widest transition-all outline-none select-none cursor-pointer focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",primary:"bg-primary text-primary-foreground hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",outline:"border-border bg-transparent hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-input/30",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",danger:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",success:"bg-emerald-500/10 text-emerald-700 hover:bg-emerald-500/20 dark:bg-emerald-500/15 dark:text-emerald-400 dark:hover:bg-emerald-500/25",link:"text-primary underline underline-offset-4 hover:underline",icon:"border-border bg-transparent hover:bg-muted hover:text-foreground dark:hover:bg-input/30"},size:{default:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",xs:"h-7 gap-1 px-3 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2 [&_svg:not([class*='size-'])]:size-3",sm:"h-9 gap-1 px-4 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",md:"h-10 gap-1.5 px-6 has-data-[icon=inline-end]:pr-4 has-data-[icon=inline-start]:pl-4",lg:"h-11 gap-1.5 px-8 has-data-[icon=inline-end]:pr-5 has-data-[icon=inline-start]:pl-5",icon:"size-10","icon-xs":"size-7 [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-9","icon-md":"size-10","icon-lg":"size-11"}},defaultVariants:{variant:"default",size:"default"}});function De({className:a,variant:l="default",size:s="default",isLoading:u=!1,children:f,disabled:d,render:m,nativeButton:y,...p}){const g=y??(m===void 0||x.isValidElement(m)&&m.type==="button");return r.jsxs(eC,{"data-slot":"button",className:ve(Q3({variant:l,size:s,className:a})),disabled:d===!0||u,render:m,nativeButton:g,...p,children:[u&&r.jsx(_w,{className:"size-3.5 animate-spin"}),f]})}const Y3={sm:"h-9 text-xs",md:"h-10 text-sm",lg:"h-11 text-base"};function oa({className:a,label:l,error:s,leftIcon:u,rightContent:f,inputSize:d="md","aria-invalid":m,...y}){const p=!!s||m!==void 0&&m!==!1&&m!=="false";return r.jsxs("div",{className:"w-full",children:[l&&r.jsx("label",{className:"mb-2 block text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:l}),r.jsxs("div",{className:ve("flex items-center gap-2 border border-transparent border-b-input bg-transparent transition-[color,border-color] focus-within:border-b-ring",p&&"border-b-destructive focus-within:border-b-destructive",a),children:[u&&r.jsx(u,{className:"size-3.5 shrink-0 text-muted-foreground"}),r.jsx(RC,{"data-slot":"input","aria-invalid":p||void 0,className:ve("w-full min-w-0 flex-1 border-0 bg-transparent px-0 py-1 outline-none placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50","file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground",Y3[d]),...y}),f&&r.jsx("div",{className:"shrink-0",children:f})]}),s&&r.jsx("p",{className:"mt-2 text-xs text-destructive",children:s})]})}function Uv({className:a,children:l,...s}){return r.jsxs(LC,{"data-slot":"scroll-area",className:ve("relative",a),...s,children:[r.jsx(QC,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:l}),r.jsx(G3,{}),r.jsx(KC,{})]})}function G3({className:a,orientation:l="vertical",...s}){return r.jsx(VC,{"data-slot":"scroll-area-scrollbar","data-orientation":l,orientation:l,className:ve("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",a),...s,children:r.jsx(XC,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-none bg-border"})})}ve("flex items-center justify-between gap-2 rounded-none border border-border bg-transparent px-3 py-2 text-xs font-semibold uppercase tracking-widest transition-colors","hover:bg-muted focus:outline-none focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 data-popup-open:bg-muted");function Sd({className:a,size:l="default",...s}){return r.jsx(g3,{"data-slot":"switch","data-size":l,className:ve("peer group/switch relative inline-flex shrink-0 items-center rounded-none border transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 data-[size=default]:h-4.5 data-[size=default]:w-8.25 data-[size=sm]:h-3.5 data-[size=sm]:w-6.25 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-unchecked:border-input/50 data-unchecked:bg-input data-disabled:cursor-not-allowed data-disabled:opacity-50",a),...s,children:r.jsx(y3,{"data-slot":"switch-thumb",className:"pointer-events-none block bg-background ring-0 transition-transform group-data-[size=default]/switch:size-3.5 group-data-[size=sm]/switch:size-2.5 data-checked:translate-x-[calc(100%+2px)] dark:data-checked:bg-primary-foreground data-unchecked:translate-x-0.25 dark:data-unchecked:bg-foreground"})})}function Hv({className:a,orientation:l="horizontal",...s}){return r.jsx(x3,{"data-slot":"tabs","data-orientation":l,className:ve("group/tabs flex gap-2 data-horizontal:flex-col",a),...s})}const V3=zh("group/tabs-list inline-flex w-fit items-center justify-center p-1 text-muted-foreground group-data-horizontal/tabs:h-10 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col",{variants:{variant:{default:"bg-muted",line:"gap-1 bg-transparent"}},defaultVariants:{variant:"default"}});function qv({className:a,variant:l="default",...s}){return r.jsx(N3,{"data-slot":"tabs-list","data-variant":l,className:ve(V3({variant:l}),a),...s})}function kr({className:a,...l}){return r.jsx(b3,{"data-slot":"tabs-trigger",className:ve("relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-2 border border-transparent px-4 py-1.5 text-xs font-semibold tracking-wider whitespace-nowrap text-foreground/60 uppercase transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-4 group-data-vertical/tabs:py-2 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3.5","group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent","data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground","after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",a),...l})}function Dr({className:a,...l}){return r.jsx(j3,{"data-slot":"tabs-content",className:ve("flex-1 text-sm outline-none",a),...l})}function zn({className:a,...l}){return r.jsx("label",{"data-slot":"label",className:ve("flex items-center gap-2 text-xs font-semibold tracking-wide uppercase select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 peer-data-[slot=checkbox]:text-sm peer-data-[slot=checkbox]:font-normal peer-data-[slot=checkbox]:tracking-normal peer-data-[slot=checkbox]:normal-case peer-data-[slot=radio-group-item]:text-sm peer-data-[slot=radio-group-item]:font-normal peer-data-[slot=radio-group-item]:tracking-normal peer-data-[slot=radio-group-item]:normal-case peer-data-[slot=switch]:text-sm peer-data-[slot=switch]:font-normal peer-data-[slot=switch]:tracking-normal peer-data-[slot=switch]:normal-case",a),...l})}function X3({className:a,...l}){return r.jsx("textarea",{"data-slot":"textarea",className:ve("flex field-sizing-content min-h-16 w-full resize-none rounded-none border border-transparent border-b-input bg-transparent px-0 py-3 text-base transition-[color,border-color] outline-none placeholder:text-muted-foreground focus-visible:border-b-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-b-destructive md:text-sm dark:aria-invalid:border-b-destructive/50",a),...l})}function Bv({...a}){return r.jsx(k3,{"data-slot":"collapsible",...a})}function Qv({...a}){return r.jsx(_3,{"data-slot":"collapsible-trigger",...a})}function Yv({...a}){return r.jsx(L3,{"data-slot":"collapsible-content",...a})}new Uint8Array(new Uint16Array([1]).buffer)[0];const K3=["prompt_tokens","completion_tokens","input_tokens","output_tokens","inputTokens","outputTokens","inputTokens.total","outputTokens.total","cost","cost_usd_total","cost_details.total_cost"],$3=new Set(["model","modelId","provider","type","status","message.model","metadata.used_model","metadata.used_provider","providerMetadata.llmgateway.usedModel","providerMetadata.llmgateway.usedProvider","providerMetadata.llmgateway.provider",...K3.flatMap(a=>["usage","message.usage","providerMetadata.llmgateway.usage","providerMetadata.llmgateway","providerMetadata.gateway"].map(l=>`${l}.${a}`))]),Gv=new Set([...$3].flatMap(a=>{const l=a.split(".");return l.map((s,u)=>l.slice(0,u+1).join("."))}));Gv.add("choices");Gv.add("error");var zx;(function(a){a.STATIC="static",a.DYNAMIC="dynamic"})(zx||(zx={}));var ls;(function(a){a.SMALL="small",a.DEFAULT="default",a.LARGE="large",a.XLARGE="xlarge"})(ls||(ls={}));ls.SMALL+"",ls.DEFAULT+"",ls.LARGE+"",ls.XLARGE+"";var kx;(function(a){a.INFO="info",a.ERROR="error",a.WARNING="warning"})(kx||(kx={}));ve("relative overflow-hidden","dark:bg-[#1a1a1a] bg-white","border dark:border-white/[0.08] border-gray-200","backdrop-blur-xl","rounded-2xl","dark:shadow-[0_8px_32px_rgba(0,0,0,0.4)] shadow-[0_2px_8px_rgba(0,0,0,0.04)]");function Z3({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(z0,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(A0,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function F3({table:a,onInsertText:l}){const[s,u]=x.useState(!1);return r.jsxs(Bv,{open:s,onOpenChange:u,children:[r.jsxs(Qv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(M0,{className:"h-4 w-4 shrink-0"}):r.jsx(ui,{className:"h-4 w-4 shrink-0"}),r.jsx(_o,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Yv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx(Z3,{column:f,onInsertText:l},f.name))})})]})}function J3({onInsertText:a}){const{data:l,isLoading:s,refetch:u}=it({queryKey:["auth-schema"],queryFn:rE,staleTime:3e4}),f=(l==null?void 0:l.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Auth Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>u(),disabled:s,children:r.jsx(Gr,{className:ve("h-4 w-4",s&&"animate-spin")})})]}),r.jsx(Uv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:s?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):f.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:f.map(d=>r.jsx(F3,{table:d,onInsertText:a},d.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function P3(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function I3(a){if(a<60)return`${a} seconds`;if(a<3600)return`${Math.floor(a/60)} minutes`;if(a<86400){const s=Math.floor(a/3600);return`${s} hour${s>1?"s":""}`}const l=Math.floor(a/86400);return`${l} day${l>1?"s":""}`}function W3({settings:a,onUpdate:l,isUpdating:s}){var ae;const[u,f]=x.useState(a.sessionTokenExpiry.toString()),[d,m]=x.useState(a.sessionUpdateAge.toString()),[y,p]=x.useState(((ae=a.sessionMaxLifetime)==null?void 0:ae.toString())??""),[g,b]=x.useState(a.sessionCookieCacheMaxAge.toString()),[S,j]=x.useState(a.allowSignups),[E,O]=x.useState(a.requireEmailVerification),[T,A]=x.useState(a.requireName),[k,B]=x.useState(a.cookieDomain??""),K={sessionTokenExpiry:parseInt(u,10),sessionUpdateAge:parseInt(d,10),sessionMaxLifetime:y.trim()===""?null:parseInt(y,10),sessionCookieCacheMaxAge:parseInt(g,10)},D=()=>{l({...K,allowSignups:S,requireEmailVerification:E,requireName:T,cookieDomain:k.trim()||null})},G=K.sessionTokenExpiry!==a.sessionTokenExpiry||K.sessionUpdateAge!==a.sessionUpdateAge||K.sessionMaxLifetime!==a.sessionMaxLifetime||K.sessionCookieCacheMaxAge!==a.sessionCookieCacheMaxAge||S!==a.allowSignups||E!==a.requireEmailVerification||T!==a.requireName||(k.trim()||null)!==a.cookieDomain;return r.jsxs("div",{className:"space-y-6",children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionTokenExpiry",children:"Idle Session Lifetime (seconds)"}),r.jsx(oa,{id:"sessionTokenExpiry",type:"number",min:300,max:7776e3,value:u,onChange:V=>f(V.target.value)}),r.jsxs("p",{className:"text-xs text-muted-foreground",children:["Current: ",I3(parseInt(u,10)||0)," (min: 5 minutes, max: 90 days)"]})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionUpdateAge",children:"Session Refresh Interval (seconds)"}),r.jsx(oa,{id:"sessionUpdateAge",type:"number",min:0,value:d,onChange:V=>m(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"A used session is extended to the full expiry at most this often. 0 disables renewal. Positive intervals must be shorter than the idle lifetime."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionMaxLifetime",children:"Maximum Session Age (seconds)"}),r.jsx(oa,{id:"sessionMaxLifetime",type:"number",min:3600,max:3456e4,placeholder:"34560000 (400 days)",value:y,onChange:V=>p(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Sessions end this long after sign-in, however active. Empty allows up to 400 days."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"sessionCookieCacheMaxAge",children:"Session Cookie Cache (seconds)"}),r.jsx(oa,{id:"sessionCookieCacheMaxAge",type:"number",min:0,max:600,value:g,onChange:V=>b(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"/me answers from a signed cookie for this long. Revocation can be delayed by this duration. 0 turns it off."})]}),r.jsxs("div",{className:"space-y-2",children:[r.jsx(zn,{htmlFor:"cookieDomain",children:"Shared session domain"}),r.jsx(oa,{id:"cookieDomain",placeholder:"myapp.localhost",value:k,onChange:V=>B(V.target.value)}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Share one session across subdomains, e.g. app.myapp.localhost and api.myapp.localhost. Leave empty to keep sessions on one host."})]}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zn,{children:"Allow Signups"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Allow new users to create accounts"})]}),r.jsx(Sd,{checked:S,onCheckedChange:j})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zn,{children:"Require Email Verification"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Users must verify their email before accessing the app"})]}),r.jsx(Sd,{checked:E,onCheckedChange:O})]}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"space-y-0.5",children:[r.jsx(zn,{children:"Require Name"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"Require users to enter their name during sign up"})]}),r.jsx(Sd,{checked:T,onCheckedChange:A})]})]}),r.jsx("div",{className:"flex justify-end",children:r.jsx(De,{onClick:D,disabled:!G||s,children:s?"Saving...":"Save Settings"})})]})}function e4(){var ue,le,P,R,$,Y;const a=Ns(),[l,s]=x.useState("settings"),[u,f]=x.useState(""),[d,m]=x.useState(null),[y,p]=x.useState(null),[g,b]=x.useState(null),[S,j]=x.useState(0),E=50,T=((le=(ue=it({queryKey:["config"],queryFn:Lo,staleTime:6e4}).data)==null?void 0:ue.auth)==null?void 0:le.binding)||"AUTH",A=it({queryKey:["auth-settings"],queryFn:oE,staleTime:0}),k=vs({mutationFn:cE,onSuccess:()=>{a.invalidateQueries({queryKey:["auth-settings"]})}}),B=F=>{k.mutate(F)},K=x.useCallback(F=>{f(I=>I+F)},[]),D=vs({mutationFn:F=>uE(F),onSuccess:F=>{m(F),p(null)},onError:F=>{p(F instanceof Error?F.message:"Failed to execute query"),m(null)}}),G=()=>{u.trim()&&D.mutate(u)},ae=it({queryKey:["auth-tables"],queryFn:iE,staleTime:0,gcTime:0}),V=it({queryKey:["auth-tableData",g,E,S],queryFn:()=>sE(g,E,S),staleTime:0,gcTime:0,enabled:!!g}),H=((P=ae.data)==null?void 0:P.tables)||[],ee=((R=V.data)==null?void 0:R.data)||[],Q=(($=V.data)==null?void 0:$.columns)||[],se=((Y=V.data)==null?void 0:Y.total)||0,re=F=>{b(F),j(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Auth: ",T]}),r.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/50 p-4",children:[r.jsx(O0,{className:"h-5 w-5 mt-0.5 text-blue-500 shrink-0"}),r.jsxs("div",{children:[r.jsx("p",{className:"font-medium",children:"Ploy Auth Database"}),r.jsx("p",{className:"text-sm text-muted-foreground",children:"This is the Ploy Auth database containing user accounts and refresh tokens. Password hashes are hidden for security. Only SELECT queries are allowed."})]})]}),r.jsxs(Hv,{value:l,onValueChange:s,children:[r.jsxs(qv,{children:[r.jsxs(kr,{value:"settings",children:[r.jsx(MN,{className:"mr-2 h-4 w-4"}),"Settings"]}),r.jsx(kr,{value:"query",children:"SQL Editor"}),r.jsx(kr,{value:"tables",children:"Tables"})]}),r.jsx(Dr,{value:"settings",className:"mt-4",children:r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Auth Settings"}),r.jsx(kt,{children:"Configure authentication settings for local development."})]}),r.jsx(ut,{children:A.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):A.data?r.jsx(W3,{settings:A.data,onUpdate:B,isUpdating:k.isPending}):r.jsx("p",{className:"text-muted-foreground",children:"Failed to load settings"})})]})}),r.jsx(Dr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute read-only SELECT queries against auth tables"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:u,onChange:F=>f(F.target.value),onKeyDown:F=>{(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&G()},placeholder:"SELECT * FROM auth_users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute (SELECT only)"}),r.jsxs(De,{onClick:G,disabled:D.isPending||!u.trim(),children:[r.jsx(ph,{className:"mr-2 h-4 w-4"}),D.isPending?"Executing...":"Execute"]})]})]})]}),y&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:y})})}),d&&r.jsx(iv,{results:d.results,meta:d.meta,error:d.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(J3,{onInsertText:K})})]})}),r.jsx(Dr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>ae.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:ae.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):H.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:H.map(F=>r.jsxs("button",{onClick:()=>re(F.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${g===F.name?"bg-muted font-medium":""}`,children:[r.jsx(_o,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:F.name})]},F.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:g||"Select a Table"}),g&&r.jsxs(kt,{children:[se," total rows"]})]}),r.jsx(ut,{children:g?V.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):ee.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsx(ct,{children:Q.map(F=>r.jsx(je,{className:"font-mono",children:F},F))})}),r.jsx(Un,{children:ee.map((F,I)=>r.jsx(ct,{children:Q.map(N=>r.jsx(Ne,{className:"font-mono text-sm",children:P3(F[N])},N))},I))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",S+1," -"," ",Math.min(S+E,se)," of ",se]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:S===0,onClick:()=>j(Math.max(0,S-E)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:S+E>=se,onClick:()=>j(S+E),children:["Next",r.jsx(ui,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}function Hn(){return r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})})}function sn({children:a}){return r.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:a})}function fi({id:a}){return r.jsxs("span",{className:"font-mono text-xs",children:[a.slice(0,8),"..."]})}function Vt({title:a,value:l,icon:s,isLoading:u}){return r.jsxs(rt,{children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-sm font-medium",children:a}),s]}),r.jsx(ut,{children:r.jsx("div",{className:"text-2xl font-bold",children:u?r.jsx(Dn,{className:"h-5 w-5 animate-spin"}):l})})]})}function Ga({title:a,children:l}){return r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("h2",{className:"text-3xl font-bold tracking-tight",children:a}),l]})}function t4(a){const l='<base target="_blank">';return/<head[^>]*>/i.test(a)?a.replace(/<head[^>]*>/i,s=>`${s}${l}`):`${l}${a}`}function n4({receive:a,inbox:l}){var g,b;const s=Ns(),u=(g=a[0])!=null&&g.startsWith("*@")?`test${a[0].slice(1)}`:a[0]??(l?"inbox@in.ploy.email":""),[f,d]=x.useState({from:"sender@example.com",to:u,subject:"Hello",text:"This is a test email from the Ploy dev dashboard."}),m=vs({mutationFn:mE,onSuccess:async()=>{await s.invalidateQueries({queryKey:["auth-emails"]})}}),y=S=>j=>{d({...f,[S]:j.target.value})},p=(b=m.data)==null?void 0:b.result;return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Send test email"}),r.jsx(kt,{children:"Delivers an email to your worker's email() handler, as if it arrived at an address in email.receive or the project's inbox address. Replies and forwards land in the inbox below."})]}),r.jsx(ut,{children:r.jsxs("form",{className:"grid gap-3 md:grid-cols-2",onSubmit:S=>{S.preventDefault(),m.mutate(f)},children:[r.jsxs("div",{className:"space-y-1",children:[r.jsx(zn,{htmlFor:"test-email-from",children:"From"}),r.jsx(oa,{id:"test-email-from",value:f.from,onChange:y("from")})]}),r.jsxs("div",{className:"space-y-1",children:[r.jsx(zn,{htmlFor:"test-email-to",children:"To"}),r.jsx(oa,{id:"test-email-to",value:f.to,onChange:y("to")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(zn,{htmlFor:"test-email-subject",children:"Subject"}),r.jsx(oa,{id:"test-email-subject",value:f.subject,onChange:y("subject")})]}),r.jsxs("div",{className:"space-y-1 md:col-span-2",children:[r.jsx(zn,{htmlFor:"test-email-text",children:"Text"}),r.jsx(X3,{id:"test-email-text",rows:3,value:f.text,onChange:y("text")})]}),r.jsxs("div",{className:"flex items-center gap-3 md:col-span-2",children:[r.jsxs(De,{type:"submit",size:"sm",disabled:m.isPending,children:[r.jsx(TN,{className:"mr-2 h-4 w-4"}),"Send"]}),r.jsx("span",{className:"text-sm text-muted-foreground",children:m.error?m.error.message:p!=null&&p.rejected?`Rejected: ${p.rejected}`:p!=null&&p.relayed?"Relayed to the original sender":p!=null&&p.success?"Handled by email()":(p==null?void 0:p.error)??""})]})]})})]})}function a4({id:a}){const{data:l,isLoading:s}=it({queryKey:["auth-email",a],queryFn:()=>dE(a)});if(s)return r.jsx(Hn,{});if(!l)return r.jsx(sn,{children:"Email not found"});const{email:u}=l;return r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"space-y-1 text-sm",children:[u.from&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"From: "}),u.from]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"To: "}),u.to]}),u.cc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Cc: "}),u.cc]}),u.bcc&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Bcc: "}),u.bcc]}),u.replyTo&&r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Reply-To: "}),u.replyTo]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-muted-foreground",children:"Subject: "}),u.subject]}),r.jsx("div",{className:"text-muted-foreground",children:new Date(u.createdAt).toLocaleString()})]}),u.html?r.jsx("iframe",{title:u.subject,sandbox:"allow-popups allow-popups-to-escape-sandbox",srcDoc:t4(u.html),className:"h-[560px] w-full rounded-md border bg-white"}):null,r.jsxs("details",{className:"text-sm",open:!u.html,children:[r.jsx("summary",{className:"cursor-pointer text-muted-foreground",children:"Plain text"}),r.jsx("pre",{className:"mt-2 whitespace-pre-wrap rounded-md bg-muted p-3 font-mono text-xs",children:u.text})]})]})}function l4(){var g;const a=Ns(),[l,s]=x.useState(null),{data:u,isLoading:f}=it({queryKey:["auth-emails"],queryFn:fE,refetchInterval:3e3}),{data:d}=it({queryKey:["config"],queryFn:Lo}),m=vs({mutationFn:hE,onSuccess:async()=>{s(null),await a.invalidateQueries({queryKey:["auth-emails"]})}}),y=(u==null?void 0:u.emails)??[],p=l??((g=y[0])==null?void 0:g.id)??null;return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:"Emails",children:r.jsxs(De,{variant:"outline",size:"sm",disabled:y.length===0||m.isPending,onClick:()=>{m.mutate()},children:[r.jsx(L0,{className:"mr-2 h-4 w-4"}),"Clear inbox"]})}),(d==null?void 0:d.email)&&r.jsx(n4,{receive:d.email.receive??[],inbox:d.email.inbox??!1}),r.jsxs("div",{className:"grid gap-4 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Inbox"}),r.jsx(kt,{children:"Emails from Ploy Auth and from your worker's email binding. Under ploy dev nothing is sent; every email lands here."})]}),r.jsx(ut,{children:f?r.jsx(Hn,{}):y.length===0?r.jsx(sn,{children:"No emails yet. Send one from your worker, sign up or request a password reset to see one."}):r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Time"}),r.jsx(je,{children:"Type"}),r.jsx(je,{children:"To"}),r.jsx(je,{children:"Subject"})]})}),r.jsx(Un,{children:y.map(b=>r.jsxs(ct,{className:ve("cursor-pointer",b.id===p&&"bg-muted"),onClick:()=>{s(b.id)},children:[r.jsx(Ne,{className:"whitespace-nowrap text-xs text-muted-foreground",children:new Date(b.createdAt).toLocaleTimeString()}),r.jsx(Ne,{children:r.jsx(q3,{variant:"outline",children:b.purpose==="worker"?"Worker":"Auth"})}),r.jsx(Ne,{className:"text-sm",children:b.to}),r.jsx(Ne,{className:"text-sm",children:b.subject})]},b.id))})]})})]}),r.jsx(rt,{children:r.jsx(ut,{className:"pt-6",children:p?r.jsx(a4,{id:p}):r.jsx(sn,{children:"Select an email to preview it"})})})]})]})})}const po=20;function i4(a){if(a===null)return"Never";const l=a-Math.floor(Date.now()/1e3);return l<=0?"Expired":l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function s4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Cache Entries"}),r.jsx(kt,{children:"Key-value entries in this cache store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"}),r.jsx(je,{children:"Expires"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:i4(s.expiresAt)})]},s.key))})]}):r.jsx(sn,{children:"No entries in this cache store"})})]})}function r4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["cacheEntries",l,s,f],queryFn:()=>FN(l,po,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,S=Math.floor(s/po)+1,j=E=>{E.preventDefault(),d(m),u(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Cache: ${l}`}),r.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[r.jsx(oa,{placeholder:"Search by key...",value:m,onChange:E=>y(E.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(_0,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),u(0)},children:"Clear"})]}),r.jsx(s4,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",S]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(Math.max(0,s-po)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(s+po),disabled:!b,children:["Next",r.jsx(ui,{className:"h-4 w-4"})]})]})]})]})})}const u4={PENDING:{variant:"default",icon:r.jsx(oi,{className:"h-3 w-3"}),label:"Pending"},RUNNING:{variant:"blue",icon:r.jsx(Dn,{className:"h-3 w-3 animate-spin"}),label:"Running"},COMPLETED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(Cs,{className:"h-3 w-3"}),label:"Failed"},CANCELLED:{variant:"default",icon:r.jsx(Qj,{className:"h-3 w-3"}),label:"Cancelled"}},o4={PENDING:{variant:"default",icon:r.jsx(oi,{className:"h-3 w-3"}),label:"Pending"},PROCESSING:{variant:"blue",icon:r.jsx(Dn,{className:"h-3 w-3 animate-spin"}),label:"Processing"},ACKNOWLEDGED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Acknowledged"},FAILED:{variant:"error",icon:r.jsx(Cs,{className:"h-3 w-3"}),label:"Failed"},DEAD_LETTER:{variant:"orange",icon:r.jsx(Wj,{className:"h-3 w-3"}),label:"Dead Letter"}};function kh({status:a}){const l=u4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const c4={PENDING:{variant:"default",icon:r.jsx(oi,{className:"h-3 w-3"}),label:"Pending"},FIRED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Fired"},COMPLETED:{variant:"success",icon:r.jsx(Rl,{className:"h-3 w-3"}),label:"Completed"},FAILED:{variant:"error",icon:r.jsx(Cs,{className:"h-3 w-3"}),label:"Failed"}};function Vv({status:a}){const l=c4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}function f4({status:a}){const l=o4[a];return l?r.jsx(Ml,{variant:l.variant,icon:l.icon,children:l.label}):r.jsx(Ml,{children:a})}const d4={provisioning:{variant:"blue",icon:r.jsx(Dn,{className:"h-3 w-3 animate-spin"}),label:"Provisioning"},active:{variant:"success",icon:r.jsx(T0,{className:"h-3 w-3"}),label:"Active"},idle:{variant:"default",icon:r.jsx(D0,{className:"h-3 w-3"}),label:"Idle"},sleeping:{variant:"warning",icon:r.jsx(k0,{className:"h-3 w-3"}),label:"Sleeping"},stopped:{variant:"default",icon:r.jsx(_N,{className:"h-3 w-3"}),label:"Stopped"},destroyed:{variant:"error",icon:r.jsx(L0,{className:"h-3 w-3"}),label:"Destroyed"}};function h4({status:a,active:l}){const u=d4[a==="running"?l?"active":"idle":a];return u?r.jsx(Ml,{variant:u.variant,icon:u.icon,children:u.label}):r.jsx(Ml,{children:a})}function m4({executions:a,cronExpression:l,isLoading:s}){const u=(a==null?void 0:a.filter(d=>d.status==="COMPLETED").length)??0,f=(a==null?void 0:a.filter(d=>d.status==="FAILED").length)??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[r.jsx(Vt,{title:"Schedule",value:l??"-",icon:r.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}),isLoading:s}),r.jsx(Vt,{title:"Completed",value:u,icon:r.jsx(Rl,{className:"h-4 w-4 text-green-500"}),isLoading:s}),r.jsx(Vt,{title:"Failed",value:f,icon:r.jsx(Cs,{className:"h-4 w-4 text-red-500"}),isLoading:s})]})}function p4({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent cron handler executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Triggered"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Completed"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(kh,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.triggeredAt})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:s.completedAt?r.jsx(yn,{timestamp:s.completedAt}):"-"})]},s.id))})]}):r.jsx(sn,{children:"No cron executions yet"})})]})}function g4(){const{binding:a}=Qa(),l=a||"",s=Ns(),{data:u,isLoading:f}=it({queryKey:["cronExecutions",l],queryFn:()=>aE(l,20),enabled:!!l,refetchInterval:5e3}),d=vs({mutationFn:()=>lE(l),onSettled:()=>{s.invalidateQueries({queryKey:["cronExecutions",l]})}});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Cron: ${l}`,children:r.jsxs(De,{size:"sm",disabled:!l||d.isPending,onClick:()=>{d.mutate()},children:[r.jsx(ph,{className:"h-4 w-4 mr-1"}),d.isPending?"Running...":"Run now"]})}),r.jsx(m4,{executions:u==null?void 0:u.executions,cronExpression:u==null?void 0:u.cronExpression,isLoading:f}),r.jsx(p4,{executions:u==null?void 0:u.executions,isLoading:f})]})})}function y4({column:a,onInsertText:l}){return r.jsxs("button",{onClick:()=>l==null?void 0:l(a.name),className:"flex w-full items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-muted",title:`Click to insert "${a.name}"`,children:[a.primaryKey?r.jsx(z0,{className:"h-3 w-3 shrink-0 text-yellow-500"}):r.jsx(A0,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),r.jsx("span",{className:"truncate font-mono",children:a.name}),r.jsxs("span",{className:"ml-auto truncate text-muted-foreground",children:[a.type,a.notNull&&!a.primaryKey&&" NOT NULL"]})]})}function x4({table:a,onInsertText:l}){const[s,u]=x.useState(!1);return r.jsxs(Bv,{open:s,onOpenChange:u,children:[r.jsxs(Qv,{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm hover:bg-muted",children:[s?r.jsx(M0,{className:"h-4 w-4 shrink-0"}):r.jsx(ui,{className:"h-4 w-4 shrink-0"}),r.jsx(_o,{className:"h-4 w-4 shrink-0 text-blue-500"}),r.jsx("span",{className:"truncate font-medium cursor-pointer",onClick:f=>{f.stopPropagation(),l==null||l(a.name)},title:`Click to insert "${a.name}"`,children:a.name}),r.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[a.columns.length," cols"]})]}),r.jsx(Yv,{children:r.jsx("div",{className:"ml-4 border-l pl-2",children:a.columns.map(f=>r.jsx(y4,{column:f,onInsertText:l},f.name))})})]})}function v4({bindingName:a,onInsertText:l}){const{data:s,isLoading:u,refetch:f}=it({queryKey:["schema",a],queryFn:()=>$N(a),staleTime:3e4}),d=(s==null?void 0:s.tables)||[];return r.jsxs("div",{className:"flex h-full flex-col border-l bg-card",children:[r.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[r.jsx("h3",{className:"text-sm font-semibold",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>f(),disabled:u,children:r.jsx(Gr,{className:ve("h-4 w-4",u&&"animate-spin")})})]}),r.jsx(Uv,{className:"flex-1",children:r.jsx("div",{className:"p-2",children:u?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"Loading schema..."}):d.length===0?r.jsx("p",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-0.5",children:d.map(m=>r.jsx(x4,{table:m,onInsertText:l},m.name))})})}),r.jsx("div",{className:"border-t px-3 py-2 text-xs text-muted-foreground",children:"Click table/column names to insert"})]})}function b4(a){return a===null?"NULL":a===void 0?"":typeof a=="object"?JSON.stringify(a):String(a)}function S4(){var ee,Q,se,re;const{binding:a}=Qa(),l=a||"",[s,u]=x.useState("query"),[f,d]=x.useState(""),[m,y]=x.useState(null),[p,g]=x.useState(null),[b,S]=x.useState(null),[j,E]=x.useState(0),O=50,T=x.useCallback(ue=>{d(le=>le+ue)},[]),A=vs({mutationFn:ue=>VN(l,ue),onSuccess:ue=>{y(ue),g(null)},onError:ue=>{g(ue instanceof Error?ue.message:"Failed to execute query"),y(null)}}),k=()=>{f.trim()&&A.mutate(f)},B=it({queryKey:["tables",l],queryFn:()=>XN(l),staleTime:0,gcTime:0,enabled:!!l}),K=it({queryKey:["tableData",l,b,O,j],queryFn:()=>KN(l,b,O,j),staleTime:0,gcTime:0,enabled:!!l&&!!b}),D=((ee=B.data)==null?void 0:ee.tables)||[],G=((Q=K.data)==null?void 0:Q.data)||[],ae=((se=K.data)==null?void 0:se.columns)||[],V=((re=K.data)==null?void 0:re.total)||0,H=ue=>{S(ue),E(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Database: ",l]}),r.jsxs(Hv,{value:s,onValueChange:u,children:[r.jsxs(qv,{children:[r.jsx(kr,{value:"query",children:"SQL Editor"}),r.jsx(kr,{value:"tables",children:"Tables"})]}),r.jsx(Dr,{value:"query",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-0 lg:grid-cols-[1fr_280px]",children:[r.jsxs("div",{className:"space-y-4",children:[r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"SQL Query"}),r.jsx(kt,{children:"Execute SQL queries against your database"})]}),r.jsxs(ut,{className:"space-y-4",children:[r.jsx("textarea",{value:f,onChange:ue=>d(ue.target.value),onKeyDown:ue=>{(ue.metaKey||ue.ctrlKey)&&ue.key==="Enter"&&k()},placeholder:"SELECT * FROM users LIMIT 10;",className:"w-full h-32 p-2 font-mono text-sm border rounded bg-background"}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-xs text-muted-foreground",children:"Press Cmd/Ctrl + Enter to execute"}),r.jsxs(De,{onClick:k,disabled:A.isPending||!f.trim(),children:[r.jsx(ph,{className:"mr-2 h-4 w-4"}),A.isPending?"Executing...":"Execute"]})]})]})]}),p&&r.jsx(rt,{className:"border-destructive/50",children:r.jsx(ut,{className:"pt-6",children:r.jsx("p",{className:"font-mono text-sm text-destructive",children:p})})}),m&&r.jsx(iv,{results:m.results,meta:m.meta,error:m.error})]}),r.jsx("div",{className:"hidden h-[500px] lg:block",children:r.jsx(v4,{bindingName:l,onInsertText:T})})]})}),r.jsx(Dr,{value:"tables",className:"mt-4",children:r.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-4",children:[r.jsxs(rt,{className:"md:col-span-1",children:[r.jsxs(yt,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[r.jsx(xt,{className:"text-base",children:"Tables"}),r.jsx(De,{variant:"ghost",size:"icon",onClick:()=>B.refetch(),className:"h-8 w-8",children:r.jsx(Gr,{className:"h-4 w-4"})})]}),r.jsx(ut,{children:B.isLoading?r.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading..."}):D.length===0?r.jsx("p",{className:"text-sm text-muted-foreground",children:"No tables found"}):r.jsx("div",{className:"space-y-1",children:D.map(ue=>r.jsxs("button",{onClick:()=>H(ue.name),className:`flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors hover:bg-muted ${b===ue.name?"bg-muted font-medium":""}`,children:[r.jsx(_o,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"truncate",children:ue.name})]},ue.name))})})]}),r.jsxs(rt,{className:"md:col-span-3",children:[r.jsxs(yt,{children:[r.jsx(xt,{children:b||"Select a Table"}),b&&r.jsxs(kt,{children:[V," total rows"]})]}),r.jsx(ut,{children:b?K.isLoading?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):G.length===0?r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"No data in this table"}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"overflow-x-auto rounded-md border",children:r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsx(ct,{children:ae.map(ue=>r.jsx(je,{className:"font-mono",children:ue},ue))})}),r.jsx(Un,{children:G.map((ue,le)=>r.jsx(ct,{children:ae.map(P=>r.jsx(Ne,{className:"font-mono text-sm",children:b4(ue[P])},P))},le))})]})}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Showing ",j+1," -"," ",Math.min(j+O,V)," of ",V]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",disabled:j===0,onClick:()=>E(Math.max(0,j-O)),children:[r.jsx(Yr,{className:"mr-1 h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",disabled:j+O>=V,onClick:()=>E(j+O),children:["Next",r.jsx(ui,{className:"ml-1 h-4 w-4"})]})]})]})]}):r.jsx("p",{className:"py-8 text-center text-muted-foreground",children:"Select a table from the list to view its data"})})]})]})})]})]})})}const Fl=20;function j4(a){return a<1024?`${a} B`:a<1024*1024?`${(a/1024).toFixed(1)} KB`:a<1024*1024*1024?`${(a/(1024*1024)).toFixed(1)} MB`:`${(a/(1024*1024*1024)).toFixed(1)} GB`}function N4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Files"}),r.jsx(kt,{children:"Stored files with metadata (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Size"}),r.jsx(je,{children:"Content Type"}),r.jsx(je,{children:"Created At"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:j4(s.size)}),r.jsx(Ne,{className:"font-mono text-xs text-muted-foreground",children:s.contentType}),r.jsx(Ne,{className:"text-sm text-muted-foreground",children:s.createdAt})]},s.key))})]}):r.jsx(sn,{children:"No files in this storage"})})]})}function E4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(0),{data:f,isLoading:d}=it({queryKey:["fileStorageEntries",l,s],queryFn:()=>pE(l,Fl,s),enabled:!!l,refetchInterval:5e3}),m=(f==null?void 0:f.total)??0,y=Math.floor(s/Fl)+1,p=Math.ceil(m/Fl);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`File Storage: ${l}`}),r.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4",children:r.jsx(Vt,{title:"Total Files",value:m})}),r.jsx(N4,{entries:f==null?void 0:f.entries,isLoading:d}),m>Fl&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",y," of ",p]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(Math.max(0,s-Fl)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(s+Fl),disabled:s+Fl>=m,children:["Next",r.jsx(ui,{className:"h-4 w-4"})]})]})]})]})})}function w4({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Processing",value:(a==null?void 0:a.processing)??0,icon:r.jsx(Dn,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Acknowledged",value:(a==null?void 0:a.acknowledged)??0,icon:r.jsx(Rl,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Failed",value:(a==null?void 0:a.failed)??0,icon:r.jsx(Cs,{className:"h-4 w-4 text-red-500"}),isLoading:l}),r.jsx(Vt,{title:"Dead Letter",value:(a==null?void 0:a.deadLetter)??0,icon:r.jsx(xN,{className:"h-4 w-4 text-orange-500"}),isLoading:l})]})}function C4({messages:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Messages"}),r.jsx(kt,{children:"Latest messages in this queue (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Attempt"}),r.jsx(je,{children:"Created"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(f4,{status:s.status})}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:JSON.stringify(s.payload)}),r.jsx(Ne,{children:s.attempt}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No messages in this queue"})})]})}function T4(){const{binding:a}=Qa(),l=a||"",{data:s,isLoading:u}=it({queryKey:["queueMetrics",l],queryFn:()=>JN(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["queueMessages",l],queryFn:()=>PN(l,10),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Queue: ${l}`}),r.jsx(w4,{metrics:s==null?void 0:s.metrics,isLoading:u}),r.jsx(C4,{messages:f==null?void 0:f.messages,isLoading:d})]})})}function R4({sandboxes:a,isLoading:l}){const s=(a==null?void 0:a.length)??0,u=(a==null?void 0:a.filter(y=>y.active).length)??0,f=(a==null?void 0:a.filter(y=>y.status==="running"&&!y.active).length)??0,d=(a==null?void 0:a.filter(y=>y.status==="sleeping").length)??0,m=(a==null?void 0:a.reduce((y,p)=>y+p.sessionCount,0))??0;return r.jsxs("div",{className:"grid gap-4 md:grid-cols-5",children:[r.jsx(Vt,{title:"Sandboxes",value:s,icon:r.jsx(R0,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Active",value:u,icon:r.jsx(T0,{className:"h-4 w-4 text-green-500"}),isLoading:l}),r.jsx(Vt,{title:"Idle",value:f,icon:r.jsx(D0,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Sleeping",value:d,icon:r.jsx(k0,{className:"h-4 w-4 text-orange-500"}),isLoading:l}),r.jsx(Vt,{title:"Sessions",value:m,icon:r.jsx(kN,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l})]})}function M4({sandboxes:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Sandboxes"}),r.jsx(kt,{children:"Live sandbox instances launched via env.<binding>.get(id) (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Image"}),r.jsx(je,{children:"Sessions"}),r.jsx(je,{children:"Container"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-xs",children:s.externalId}),r.jsx(Ne,{children:r.jsx(h4,{status:s.status,active:s.active})}),r.jsx(Ne,{className:"font-mono text-xs",children:s.image}),r.jsx(Ne,{children:s.sessionCount}),r.jsx(Ne,{children:s.containerId?r.jsx(fi,{id:s.containerId}):r.jsx("span",{className:"text-muted-foreground",children:"—"})})]},s.id))})]}):r.jsx(sn,{children:"No sandboxes yet — call env.<binding>.get(id) from your worker to launch one"})})]})}function A4(){const{data:a,isLoading:l}=it({queryKey:["sandboxes"],queryFn:GN,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:"Sandboxes"}),r.jsx(R4,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l}),r.jsx(M4,{sandboxes:a==null?void 0:a.sandboxes,isLoading:l})]})})}const go=20;function O4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"State Entries"}),r.jsx(kt,{children:"Key-value entries in this state store (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Key"}),r.jsx(je,{children:"Value"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{className:"font-mono text-sm",children:s.key}),r.jsx(Ne,{className:"max-w-[400px] truncate font-mono text-xs text-muted-foreground",children:s.value})]},s.key))})]}):r.jsx(sn,{children:"No entries in this state store"})})]})}function z4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(0),[f,d]=x.useState(""),[m,y]=x.useState(""),{data:p,isLoading:g}=it({queryKey:["stateEntries",l,s,f],queryFn:()=>ZN(l,go,s,f),enabled:!!l,refetchInterval:5e3}),b=(p==null?void 0:p.hasMore)??!1,S=Math.floor(s/go)+1,j=E=>{E.preventDefault(),d(m),u(0)};return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`State: ${l}`}),r.jsxs("form",{onSubmit:j,className:"flex gap-2",children:[r.jsx(oa,{placeholder:"Search by key...",value:m,onChange:E=>y(E.target.value),className:"max-w-sm"}),r.jsxs(De,{type:"submit",variant:"outline",size:"sm",children:[r.jsx(_0,{className:"h-4 w-4 mr-1"}),"Search"]}),f&&r.jsx(De,{type:"button",variant:"ghost",size:"sm",onClick:()=>{d(""),y(""),u(0)},children:"Clear"})]}),r.jsx(O4,{entries:p==null?void 0:p.entries,isLoading:g}),(s>0||b)&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("p",{className:"text-sm text-muted-foreground",children:["Page ",S]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(Math.max(0,s-go)),disabled:s===0,children:[r.jsx(Yr,{className:"h-4 w-4"}),"Previous"]}),r.jsxs(De,{variant:"outline",size:"sm",onClick:()=>u(s+go),disabled:!b,children:["Next",r.jsx(ui,{className:"h-4 w-4"})]})]})]})]})})}function k4(a){if(a<1e3)return`${a}ms`;const l=Math.floor(a/1e3);if(l<60)return`${l}s`;const s=Math.floor(l/60),u=l%60;if(s<60)return u===0?`${s}m`:`${s}m ${u}s`;const f=Math.floor(s/60),d=s%60;if(f<24)return d===0?`${f}h`:`${f}h ${d}m`;const m=Math.floor(f/24),y=f%24;return y===0?`${m}d`:`${m}d ${y}h`}function D4({metrics:a,isLoading:l}){return r.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[r.jsx(Vt,{title:"Pending",value:(a==null?void 0:a.pending)??0,icon:r.jsx(oi,{className:"h-4 w-4 text-muted-foreground"}),isLoading:l}),r.jsx(Vt,{title:"Fired",value:(a==null?void 0:a.fired)??0,icon:r.jsx(Rl,{className:"h-4 w-4 text-green-500"}),isLoading:l})]})}function _4({entries:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Scheduled Timers"}),r.jsx(kt,{children:"Timer entries scheduled by your worker (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Interval"}),r.jsx(je,{children:"Payload"}),r.jsx(je,{children:"Created"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.id})}),r.jsx(Ne,{children:r.jsx(Vv,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{className:"text-xs",children:s.intervalMs!==void 0&&s.intervalMs!==null?r.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.jsx(EN,{className:"h-3 w-3"}),k4(s.intervalMs)]}):"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate font-mono text-xs",children:s.payload!==void 0&&s.payload!==null?JSON.stringify(s.payload):"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timers scheduled"})})]})}function L4({executions:a,isLoading:l}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Execution History"}),r.jsx(kt,{children:"Recent timer handler executions"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"Timer ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Scheduled Time"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Error"}),r.jsx(je,{children:"Executed"})]})}),r.jsx(Un,{children:a.map(s=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:s.timerId})}),r.jsx(Ne,{children:r.jsx(Vv,{status:s.status})}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.scheduledTime})}),r.jsx(Ne,{children:s.durationMs!==void 0&&s.durationMs!==null?`${s.durationMs}ms`:"-"}),r.jsx(Ne,{className:"max-w-[200px] truncate text-xs text-red-500",children:s.error??"-"}),r.jsx(Ne,{children:r.jsx(yn,{timestamp:s.createdAt})})]},s.id))})]}):r.jsx(sn,{children:"No timer executions yet"})})]})}function U4(){const{binding:a}=Qa(),l=a||"",{data:s,isLoading:u}=it({queryKey:["timerMetrics",l],queryFn:()=>tE(l),enabled:!!l,refetchInterval:5e3}),{data:f,isLoading:d}=it({queryKey:["timerEntries",l],queryFn:()=>eE(l,20),enabled:!!l,refetchInterval:5e3}),{data:m,isLoading:y}=it({queryKey:["timerExecutions",l],queryFn:()=>nE(l,20),enabled:!!l,refetchInterval:5e3});return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Timers: ${l}`}),r.jsx(D4,{metrics:s==null?void 0:s.metrics,isLoading:u}),r.jsx(_4,{entries:f==null?void 0:f.entries,isLoading:d}),r.jsx(L4,{executions:m==null?void 0:m.executions,isLoading:y})]})})}function Or(a){return a!=null}function H4(a,l){const s=[];a&&Or(a.input)&&s.push("execution-input"),a&&Or(a.output)&&s.push("execution-output");for(const u of l)Or(u.input)&&s.push(`${u.id}-input`),Or(u.output)&&s.push(`${u.id}-output`);return s}function Ao({id:a,label:l,value:s,isOpen:u,onToggle:f}){return Or(s)?r.jsxs("details",{className:"mt-2",open:u,onToggle:d=>{f(a,d.currentTarget.open)},children:[r.jsx("summary",{className:"text-xs text-muted-foreground cursor-pointer hover:text-foreground",children:l}),r.jsx("pre",{className:"mt-1 p-2 rounded bg-muted text-xs font-mono overflow-x-auto",children:JSON.stringify(s,null,2)})]}):null}function q4({status:a}){switch(a){case"COMPLETED":return r.jsx(Rl,{className:"h-5 w-5 text-green-500"});case"RUNNING":return r.jsx(Dn,{className:"h-5 w-5 text-blue-500 animate-spin"});case"FAILED":return r.jsx(Cs,{className:"h-5 w-5 text-red-500"});case"PENDING":default:return r.jsx(oi,{className:"h-5 w-5 text-gray-400"})}}function B4(a){switch(a){case"COMPLETED":return"bg-green-500";case"RUNNING":return"bg-blue-500";case"FAILED":return"bg-red-500";case"PENDING":default:return"bg-gray-300 dark:bg-gray-600"}}function Q4(a){return a.attempt!==null&&a.attempt!==void 0&&a.maxRetries!==null&&a.maxRetries!==void 0&&(a.attempt>1||a.status!=="COMPLETED")}function Y4({steps:a,openIoSectionIds:l,onToggleIoSection:s}){if(a.length===0)return r.jsx(sn,{children:"No steps recorded for this execution"});const u=a.reduce((f,d)=>f+(d.durationMs||0),0);return r.jsxs("div",{className:"space-y-4",children:[u>0&&r.jsxs("div",{className:"mb-6",children:[r.jsxs("div",{className:"flex items-center justify-between text-sm text-muted-foreground mb-2",children:[r.jsx("span",{children:"Total Duration"}),r.jsx("span",{children:as(u)})]}),r.jsx("div",{className:"h-3 bg-muted rounded-full overflow-hidden flex",children:a.map((f,d)=>{const m=f.durationMs?f.durationMs/u*100:0;return r.jsx("div",{className:ve(B4(f.status),"h-full transition-all",d>0&&"border-l border-background"),style:{width:`${m}%`},title:`${f.stepName}: ${as(f.durationMs)}`},f.id)})})]}),r.jsx("div",{className:"relative",children:a.map((f,d)=>{const m=Q4(f);return r.jsxs("div",{className:"relative pb-6 last:pb-0",children:[d<a.length-1&&r.jsx("div",{className:ve("absolute left-[9px] top-6 w-0.5 h-full -ml-px",f.status==="COMPLETED"?"bg-green-200 dark:bg-green-900":"bg-muted")}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"flex-shrink-0 relative z-10 bg-background",children:r.jsx(q4,{status:f.status})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"font-medium",children:f.stepName}),r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(Step ",f.stepIndex+1,")"]}),m&&r.jsxs("span",{className:ve("inline-flex items-center gap-1 text-xs px-1.5 py-0.5 rounded-full font-mono",f.attempt!==null&&f.attempt!==void 0&&f.attempt>1?f.status==="FAILED"?"bg-red-100 text-red-700 dark:bg-red-950 dark:text-red-300":"bg-yellow-100 text-yellow-700 dark:bg-yellow-950 dark:text-yellow-300":"bg-muted text-muted-foreground"),children:[r.jsx(Gr,{className:"h-3 w-3"}),f.attempt,"/",(f.maxRetries??0)+1]})]}),r.jsx("span",{className:"text-sm font-mono text-muted-foreground",children:as(f.durationMs)})]}),f.errorMessage&&r.jsx("div",{className:"mt-2 p-2 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:f.errorMessage}),f.retryAttempts&&f.retryAttempts.length>0&&r.jsxs("div",{className:"mt-2 space-y-2",children:[r.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"Previous failures"}),f.retryAttempts.map(y=>r.jsxs("div",{className:"rounded border border-yellow-200 bg-yellow-50 px-3 py-2 dark:border-yellow-900 dark:bg-yellow-950/40",children:[r.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 text-xs text-yellow-800 dark:text-yellow-200",children:[r.jsxs("span",{className:"font-medium",children:["Attempt ",y.attempt," failed"]}),r.jsx("span",{className:"font-mono",children:as(y.durationMs??null)})]}),r.jsx("pre",{className:"whitespace-pre-wrap text-xs font-mono text-yellow-900 dark:text-yellow-100",children:y.errorMessage})]},`${f.id}-${y.attempt}`))]}),r.jsx(Ao,{id:`${f.id}-input`,label:"View input",value:f.input,isOpen:l.has(`${f.id}-input`),onToggle:s}),r.jsx(Ao,{id:`${f.id}-output`,label:"View output",value:f.output,isOpen:l.has(`${f.id}-output`),onToggle:s}),r.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:r.jsx(yn,{timestamp:f.createdAt})})]})]})]},f.id)})})]})}function G4(){const{binding:a,executionId:l}=Qa(),s=a||"",u=l||"",{data:f,isLoading:d}=it({queryKey:["workflowExecution",s,u],queryFn:()=>WN(s,u),enabled:!!s&&!!u,refetchInterval:5e3}),m=f==null?void 0:f.execution,y=(f==null?void 0:f.steps)||[],p=H4(m??null,y),[g,b]=x.useState(()=>new Set),S=p.length>0&&p.every(O=>g.has(O));function j(O,T){b(A=>{const k=new Set(A);return T?k.add(O):k.delete(O),k})}function E(){b(()=>S?new Set:new Set(p))}return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsxs("div",{className:"flex items-start justify-between gap-4",children:[r.jsxs("div",{className:"flex items-center gap-4",children:[r.jsx(Gt,{to:`/workflows/${s}`,children:r.jsxs(De,{variant:"ghost",size:"sm",children:[r.jsx(qj,{className:"mr-2 h-4 w-4"}),"Back"]})}),r.jsxs("h2",{className:"text-3xl font-bold tracking-tight",children:["Execution: ",r.jsx(fi,{id:u})]})]}),p.length>0&&r.jsxs(De,{variant:"ghost",size:"sm",onClick:E,children:[S?r.jsx(Fj,{className:"h-4 w-4"}):r.jsx(Pj,{className:"h-4 w-4"}),S?"Collapse All I/O":"Expand All I/O"]})]}),d?r.jsx(Hn,{}):m?r.jsxs(r.Fragment,{children:[r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx(xt,{children:"Execution Details"}),r.jsx(kt,{children:m.startedAt?r.jsxs(r.Fragment,{children:["Started ",r.jsx(yn,{timestamp:m.startedAt})]}):"Not started yet"})]}),r.jsx(kh,{status:m.status})]})}),r.jsxs(ut,{children:[r.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Duration"}),r.jsx("p",{className:"font-mono",children:as(m.durationMs)})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Steps Completed"}),r.jsxs("p",{className:"font-mono",children:[m.stepsCompleted," / ",m.stepsCount]})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Created"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.createdAt})})]}),m.completedAt&&r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Completed"}),r.jsx("p",{className:"font-mono text-sm",children:r.jsx(yn,{timestamp:m.completedAt})})]})]}),m.errorMessage&&r.jsx("div",{className:"mt-4 p-3 rounded bg-red-50 dark:bg-red-950 text-red-700 dark:text-red-300 text-sm font-mono",children:m.errorMessage}),r.jsxs("div",{className:"mt-4 grid gap-3 md:grid-cols-2",children:[r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Input"}),r.jsx(Ao,{id:"execution-input",label:"View execution input",value:m.input,isOpen:g.has("execution-input"),onToggle:j})]}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm text-muted-foreground",children:"Execution Output"}),r.jsx(Ao,{id:"execution-output",label:"View execution output",value:m.output,isOpen:g.has("execution-output"),onToggle:j})]})]})]})]}),r.jsxs(rt,{children:[r.jsx(yt,{children:r.jsxs("div",{children:[r.jsx(xt,{children:"Steps"}),r.jsx(kt,{children:"Workflow step execution timeline"})]})}),r.jsx(ut,{children:r.jsx(Y4,{steps:y,openIoSectionIds:g,onToggleIoSection:j})})]})]}):r.jsx(sn,{children:"Execution not found"})]})})}const jd=20,V4=[{value:"",label:"All statuses"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"},{value:"cancelled",label:"Cancelled"}],X4=[{value:"",label:"All time"},{value:"1h",label:"Last hour"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"},{value:"30d",label:"Last 30 days"}];function K4({executions:a,isLoading:l,bindingName:s}){return r.jsxs(rt,{children:[r.jsxs(yt,{children:[r.jsx(xt,{children:"Recent Executions"}),r.jsx(kt,{children:"Workflow executions (auto-refreshes every 5 seconds)"})]}),r.jsx(ut,{children:l?r.jsx(Hn,{}):a!=null&&a.length?r.jsxs(_n,{children:[r.jsx(Ln,{children:r.jsxs(ct,{children:[r.jsx(je,{children:"ID"}),r.jsx(je,{children:"Status"}),r.jsx(je,{children:"Steps"}),r.jsx(je,{children:"Duration"}),r.jsx(je,{children:"Started"}),r.jsx(je,{})]})}),r.jsx(Un,{children:a.map(u=>r.jsxs(ct,{children:[r.jsx(Ne,{children:r.jsx(fi,{id:u.id})}),r.jsx(Ne,{children:r.jsx(kh,{status:u.status})}),r.jsx(Ne,{children:r.jsxs("span",{className:"text-sm",children:[u.stepsCompleted,"/",u.stepsCount]})}),r.jsx(Ne,{className:"text-sm",children:as(u.durationMs)}),r.jsx(Ne,{children:u.startedAt?r.jsx(yn,{timestamp:u.startedAt}):"-"}),r.jsx(Ne,{children:r.jsx(Gt,{to:`/workflows/${s}/${u.id}`,className:"flex items-center text-sm text-primary hover:underline",children:"View"})})]},u.id))})]}):r.jsx(sn,{children:"No executions for this workflow"})})]})}function $4(){const{binding:a}=Qa(),l=a||"",[s,u]=x.useState(""),[f,d]=x.useState(""),[m,y]=x.useState(0),p=m*jd,{data:g,isLoading:b}=it({queryKey:["workflowExecutions",l,s,f,m],queryFn:()=>IN(l,jd,p,s||void 0,f||void 0),enabled:!!l,refetchInterval:5e3}),S=g?Math.ceil(g.total/jd):0,j=()=>y(0);return r.jsx("div",{className:"flex flex-col",children:r.jsxs("div",{className:"flex-1 space-y-4 pt-6",children:[r.jsx(Ga,{title:`Workflow: ${l}`}),r.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[r.jsx("select",{value:s,onChange:E=>{u(E.target.value),j()},className:"text-sm border rounded px-2 py-1 bg-background",children:V4.map(E=>r.jsx("option",{value:E.value,children:E.label},E.value))}),r.jsx("select",{value:f,onChange:E=>{d(E.target.value),j()},className:"text-sm border rounded px-2 py-1 bg-background",children:X4.map(E=>r.jsx("option",{value:E.value,children:E.label},E.value))}),g&&r.jsxs("span",{className:"text-sm text-muted-foreground",children:[g.total," total"]})]}),r.jsx(K4,{executions:g==null?void 0:g.executions,isLoading:b,bindingName:l}),S>1&&r.jsxs("div",{className:"flex items-center justify-between pt-2",children:[r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m===0,onClick:()=>y(E=>E-1),children:"Previous"}),r.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",m+1," of ",S]}),r.jsx("button",{className:"text-sm px-3 py-1 border rounded disabled:opacity-40",disabled:m>=S-1,onClick:()=>y(E=>E+1),children:"Next"})]})]})})}function Z4(){const a=Fn(),{data:l,isLoading:s}=it({queryKey:["config"],queryFn:Lo,staleTime:6e4}),u=l!=null&&l.db?Object.keys(l.db):[],f=l!=null&&l.queue?Object.keys(l.queue):[],d=l!=null&&l.state?Object.keys(l.state):[],m=l!=null&&l.cache?Object.keys(l.cache):[],y=l!=null&&l.fs?Object.keys(l.fs):[],p=l!=null&&l.workflow?Object.keys(l.workflow):[],g=l!=null&&l.cron?Object.keys(l.cron):[],b=l!=null&&l.timer?Object.keys(l.timer):[],S=l!=null&&l.sandbox?Object.keys(l.sandbox):[];return r.jsxs("aside",{className:"fixed inset-y-0 left-0 z-10 w-64 flex flex-col border-r bg-background",children:[r.jsx("div",{className:"flex h-14 items-center border-b px-4",children:r.jsxs(Gt,{to:"/",className:"flex items-center gap-2 font-semibold",children:[r.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground",children:"P"}),r.jsx("span",{children:"Ploy Dev"})]})}),r.jsx("nav",{className:"flex-1 overflow-auto p-4",children:s?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx(Dn,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"space-y-6",children:[u.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Database"}),r.jsx("div",{className:"space-y-1",children:u.map(j=>{const E=a.pathname===`/db/${j}`;return r.jsx(Gt,{to:`/db/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(iN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),(l==null?void 0:l.auth)&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Auth"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth",children:r.jsxs(De,{variant:a.pathname==="/auth"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth"&&"bg-muted"),children:[r.jsx(ON,{className:"mr-2 h-4 w-4"}),r.jsx("span",{className:"flex-1 text-left",children:l.auth.binding}),r.jsx(O0,{className:"h-3.5 w-3.5 text-muted-foreground",title:"Ploy Auth tables (users & sessions)"})]})})})]}),((l==null?void 0:l.auth)||(l==null?void 0:l.email))&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Email"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/auth/emails",children:r.jsxs(De,{variant:a.pathname==="/auth/emails"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/auth/emails"&&"bg-muted"),children:[r.jsx(gN,{className:"mr-2 h-4 w-4"}),"Emails"]})})})]}),f.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Queues"}),r.jsx("div",{className:"space-y-1",children:f.map(j=>{const E=a.pathname===`/queues/${j}`;return r.jsx(Gt,{to:`/queues/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(fN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),d.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"State"}),r.jsx("div",{className:"space-y-1",children:d.map(j=>{const E=a.pathname===`/state/${j}`;return r.jsx(Gt,{to:`/state/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(Uj,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),m.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cache"}),r.jsx("div",{className:"space-y-1",children:m.map(j=>{const E=a.pathname===`/cache/${j}`;return r.jsx(Gt,{to:`/cache/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(QN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),y.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"File Storage"}),r.jsx("div",{className:"space-y-1",children:y.map(j=>{const E=a.pathname===`/fs/${j}`;return r.jsx(Gt,{to:`/fs/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(rN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),p.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Workflows"}),r.jsx("div",{className:"space-y-1",children:p.map(j=>{const E=a.pathname.startsWith(`/workflows/${j}`);return r.jsx(Gt,{to:`/workflows/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(oN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),g.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Cron"}),r.jsx("div",{className:"space-y-1",children:g.map(j=>{const E=a.pathname===`/cron/${j}`;return r.jsx(Gt,{to:`/cron/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(HN,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),b.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Timers"}),r.jsx("div",{className:"space-y-1",children:b.map(j=>{const E=a.pathname===`/timers/${j}`;return r.jsx(Gt,{to:`/timers/${j}`,children:r.jsxs(De,{variant:E?"secondary":"ghost",className:ve("w-full justify-start",E&&"bg-muted"),children:[r.jsx(Gj,{className:"mr-2 h-4 w-4"}),j]})},j)})})]}),S.length>0&&r.jsxs("div",{children:[r.jsx("h3",{className:"mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Sandboxes"}),r.jsx("div",{className:"space-y-1",children:r.jsx(Gt,{to:"/sandboxes",children:r.jsxs(De,{variant:a.pathname==="/sandboxes"?"secondary":"ghost",className:ve("w-full justify-start",a.pathname==="/sandboxes"&&"bg-muted"),children:[r.jsx(R0,{className:"mr-2 h-4 w-4"}),"Sandboxes"]})})})]}),u.length===0&&f.length===0&&d.length===0&&m.length===0&&y.length===0&&p.length===0&&g.length===0&&b.length===0&&S.length===0&&!(l!=null&&l.auth)&&r.jsx("div",{className:"px-2 py-4 text-center text-sm text-muted-foreground",children:"No bindings configured in ploy.yaml"})]})})]})}function F4(){const{data:a,isLoading:l}=it({queryKey:["config"],queryFn:Lo,staleTime:6e4});if(!l&&a){const s=a.db?Object.keys(a.db):[],u=a.queue?Object.keys(a.queue):[],f=a.state?Object.keys(a.state):[],d=a.fs?Object.keys(a.fs):[],m=a.workflow?Object.keys(a.workflow):[];if(s.length>0)return r.jsx(ia,{to:`/db/${s[0]}`,replace:!0});if(a.auth)return r.jsx(ia,{to:"/auth",replace:!0});if(u.length>0)return r.jsx(ia,{to:`/queues/${u[0]}`,replace:!0});if(f.length>0)return r.jsx(ia,{to:`/state/${f[0]}`,replace:!0});const y=a.cache?Object.keys(a.cache):[];if(y.length>0)return r.jsx(ia,{to:`/cache/${y[0]}`,replace:!0});if(d.length>0)return r.jsx(ia,{to:`/fs/${d[0]}`,replace:!0});if(m.length>0)return r.jsx(ia,{to:`/workflows/${m[0]}`,replace:!0});const p=a.cron?Object.keys(a.cron):[];if(p.length>0)return r.jsx(ia,{to:`/cron/${p[0]}`,replace:!0});const g=a.timer?Object.keys(a.timer):[];if(g.length>0)return r.jsx(ia,{to:`/timers/${g[0]}`,replace:!0});if((a.sandbox?Object.keys(a.sandbox):[]).length>0)return r.jsx(ia,{to:"/sandboxes",replace:!0})}return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[r.jsx("h1",{className:"text-2xl font-bold mb-4",children:"Ploy Dev Dashboard"}),l?r.jsx(Dn,{className:"h-6 w-6 animate-spin text-muted-foreground"}):r.jsx("p",{className:"text-muted-foreground",children:"Configure database, queue, or workflow bindings in ploy.yaml to get started."})]})}function J4(){return r.jsxs("div",{className:"min-h-screen bg-background",children:[r.jsx(Z4,{}),r.jsx("main",{className:"pl-64",children:r.jsx("div",{className:"container mx-auto px-6 py-4",children:r.jsxs(J2,{children:[r.jsx(nn,{path:"/",element:r.jsx(F4,{})}),r.jsx(nn,{path:"/db/:binding",element:r.jsx(S4,{})}),r.jsx(nn,{path:"/auth",element:r.jsx(e4,{})}),r.jsx(nn,{path:"/auth/emails",element:r.jsx(l4,{})}),r.jsx(nn,{path:"/queues/:binding",element:r.jsx(T4,{})}),r.jsx(nn,{path:"/state/:binding",element:r.jsx(z4,{})}),r.jsx(nn,{path:"/cache/:binding",element:r.jsx(r4,{})}),r.jsx(nn,{path:"/fs/:binding",element:r.jsx(E4,{})}),r.jsx(nn,{path:"/cron/:binding",element:r.jsx(g4,{})}),r.jsx(nn,{path:"/timers/:binding",element:r.jsx(U4,{})}),r.jsx(nn,{path:"/workflows/:binding",element:r.jsx($4,{})}),r.jsx(nn,{path:"/workflows/:binding/:executionId",element:r.jsx(G4,{})}),r.jsx(nn,{path:"/sandboxes",element:r.jsx(A4,{})})]})})})]})}function Xv(){const a=window.matchMedia("(prefers-color-scheme: dark)").matches;document.documentElement.classList.toggle("dark",a)}Xv();window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",Xv);const P4=new wS({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}});JS.createRoot(document.getElementById("root")).render(r.jsx(x.StrictMode,{children:r.jsx(kS,{client:P4,children:r.jsx(bj,{children:r.jsx(J4,{})})})}));
|