@xenon-device-management/xenon 1.7.8 → 1.7.9
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/lib/package.json +1 -1
- package/lib/public/assets/{ApiKeyGate-CIMnrDKN.js → ApiKeyGate-DstjGHCV.js} +1 -1
- package/lib/public/assets/{BugReportButton-CFNkTEj5.js → BugReportButton-CCFNeE8T.js} +1 -1
- package/lib/public/assets/DeviceMosaicView-CeSU4Cin.js +2 -0
- package/lib/public/assets/{EmptyState-3J4zUCeR.js → EmptyState-BLKITXvX.js} +1 -1
- package/lib/public/assets/{FieldGroup-BdvaWOEM.js → FieldGroup-DnJ8AU1V.js} +1 -1
- package/lib/public/assets/{Modal-CeNm3NM-.js → Modal-QVER5CZo.js} +1 -1
- package/lib/public/assets/{SegmentedControl-Cl42j2ax.js → SegmentedControl-C2vcRRnn.js} +1 -1
- package/lib/public/assets/{SettingCard-B3xu2l8i.js → SettingCard-BCRyZfOg.js} +1 -1
- package/lib/public/assets/{Table-CkcGkMjT.js → Table-CEvMaA5P.js} +1 -1
- package/lib/public/assets/{activity-BYi0BtwO.js → activity-C9XYmP_g.js} +1 -1
- package/lib/public/assets/{ai-settings-DHOxT3ue.js → ai-settings-CUkrWRb4.js} +1 -1
- package/lib/public/assets/{api-keys-Be44eRg5.js → api-keys-DOEqEyCC.js} +1 -1
- package/lib/public/assets/{apps-DsFaDQU3.js → apps-kS8notsd.js} +1 -1
- package/lib/public/assets/{arrow-left-BRvWdMzn.js → arrow-left-USNjWr3g.js} +1 -1
- package/lib/public/assets/{arrow-up-right-BthaIjf2.js → arrow-up-right-CA-0ObXb.js} +1 -1
- package/lib/public/assets/{auth-shell-CiY1Fb_Q.js → auth-shell-0GDuDM6t.js} +1 -1
- package/lib/public/assets/{builds-page-xxI2XsMX.js → builds-page-B3hcVeUY.js} +2 -2
- package/lib/public/assets/{button-BUSnG3AU.js → button-30pnTauc.js} +1 -1
- package/lib/public/assets/{check-DASytmhL.js → check-CVbtgHOC.js} +1 -1
- package/lib/public/assets/{chevron-right-lA_Y5Vqx.js → chevron-right-BpHMOuL1.js} +1 -1
- package/lib/public/assets/{circle-check-CxRFDz8L.js → circle-check-BR3SeBx6.js} +1 -1
- package/lib/public/assets/{circle-x-B5bLByiX.js → circle-x-BISG5iH-.js} +1 -1
- package/lib/public/assets/{clock-DdjFBcBN.js → clock-BiZmZWEe.js} +1 -1
- package/lib/public/assets/{copy-B3wI9WZm.js → copy-E317aAW3.js} +1 -1
- package/lib/public/assets/{device-explorer-DBSC2Xkl.js → device-explorer-DTj4kvcs.js} +8 -8
- package/lib/public/assets/{download-DYcq16U1.js → download-Blklg-SX.js} +1 -1
- package/lib/public/assets/{forgot-password-CaisZCxC.js → forgot-password-Bwo7pGp7.js} +1 -1
- package/lib/public/assets/{funnel-2ldyqswZ.js → funnel-C8pl8r9F.js} +1 -1
- package/lib/public/assets/{index-DM2pqF7I.js → index-Doq8HO3X.js} +14 -14
- package/lib/public/assets/index-TkL430dq.css +1 -0
- package/lib/public/assets/{layers-D_RHPrLx.js → layers-C2U3k-wh.js} +1 -1
- package/lib/public/assets/{lock-BzKCICOV.js → lock-pCxyVW83.js} +1 -1
- package/lib/public/assets/{login-BkJy_Qbu.js → login-Cn6qENaF.js} +1 -1
- package/lib/public/assets/{maintenance-settings-Clcz28G3.js → maintenance-settings-DybzeKfb.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-B_67dFA-.js → mouse-pointer-2-cmVLOY6H.js} +1 -1
- package/lib/public/assets/overview-Dqw_olJm.js +11 -0
- package/lib/public/assets/{page-header-2famIGMK.js → page-header-Qk9pGEaH.js} +1 -1
- package/lib/public/assets/{plus-C4rQY5cd.js → plus-DkzZBN8d.js} +1 -1
- package/lib/public/assets/{profile-page-BM7-oXtu.js → profile-page-D_BlUsba.js} +1 -1
- package/lib/public/assets/{reset-password-YseXfavA.js → reset-password-vxmC3PEa.js} +1 -1
- package/lib/public/assets/{runbook-page-9qkCJTja.js → runbook-page-rzVHVBte.js} +1 -1
- package/lib/public/assets/{selector-detail-page-BxJG3Usf.js → selector-detail-page-DUPHHW7E.js} +1 -1
- package/lib/public/assets/{selector-health-DQ_ojvhV.js → selector-health-CS_wYWYA.js} +1 -1
- package/lib/public/assets/{selector-health-page-D71FAyov.js → selector-health-page-CQT_ghIj.js} +1 -1
- package/lib/public/assets/{session-detail-page-BQSKLyXA.js → session-detail-page-Md2BJeDW.js} +1 -1
- package/lib/public/assets/{settings-C6zUseAY.js → settings-DcRs-Ksu.js} +1 -1
- package/lib/public/assets/{shield-DJRDBT2Q.js → shield-DKOl26Qj.js} +1 -1
- package/lib/public/assets/{shield-alert-B_LM0Wik.js → shield-alert-B6RlIJqv.js} +1 -1
- package/lib/public/assets/status-pill-outline-Df9QaRNJ.js +1 -0
- package/lib/public/assets/{tablet-DncjPSb9.js → tablet-1xXXhpqC.js} +1 -1
- package/lib/public/assets/{teams-Dfx9GeXT.js → teams-DnBnZECm.js} +1 -1
- package/lib/public/assets/{trash-2-DkY5zvbC.js → trash-2-D-ONhY9W.js} +1 -1
- package/lib/public/assets/{useSocket-gPuNFv-1.js → useSocket-D9iZtppJ.js} +1 -1
- package/lib/public/assets/{users-CVZ-pVEk.js → users-BFrjP_42.js} +1 -1
- package/lib/public/assets/{webhook-settings-CETgsTNf.js → webhook-settings-DgJKt5Wf.js} +1 -1
- package/lib/public/assets/{zap-DjPJtSrl.js → zap-C8F21kM1.js} +1 -1
- package/lib/public/index.html +2 -2
- package/package.json +1 -1
- package/lib/public/assets/DeviceMosaicView-Bh2_5WSI.js +0 -2
- package/lib/public/assets/index-DTv2hJI9.css +0 -1
- package/lib/public/assets/overview-BIM2QTtX.js +0 -11
- package/lib/public/assets/status-pill-outline-DlXhhbCd.js +0 -1
package/lib/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e}from"./index-
|
|
1
|
+
import{r as n,j as e}from"./index-Doq8HO3X.js";function x({children:c}){const[i,s]=n.useState(null),[o,l]=n.useState(""),[r,a]=n.useState(null);if(n.useEffect(()=>{fetch("/xenon/api/health").then(()=>fetch("/xenon/api/sessions",{credentials:"include"})).then(t=>s(t.status!==401)).catch(()=>s(!1))},[]),i===null)return e.jsx("div",{style:{padding:40},children:"Loading…"});if(i)return e.jsx(e.Fragment,{children:c});async function u(t){t.preventDefault(),a(null);const d=await fetch("/xenon/api/auth/dashboard-session",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({apiKey:o.trim()})});if(d.ok)s(!0);else{const p=await d.json().catch(()=>({}));a(p.error||"Invalid key")}}return e.jsxs("div",{style:{maxWidth:420,margin:"120px auto",padding:24},children:[e.jsx("h2",{children:"Sign in to Xenon"}),e.jsxs("p",{children:["Paste an API key. First-time setup: the bootstrap key is in"," ",e.jsx("code",{children:"~/.cache/xenon/bootstrap-key.txt"})," on the server."]}),e.jsxs("form",{onSubmit:u,children:[e.jsx("input",{type:"password",value:o,onChange:t=>l(t.target.value),placeholder:"API key",style:{width:"100%",padding:8,boxSizing:"border-box"},autoFocus:!0}),e.jsx("button",{type:"submit",style:{marginTop:12,padding:"8px 16px"},children:"Continue"})]}),r&&e.jsx("p",{style:{color:"crimson",marginTop:12},children:r})]})}export{x as ApiKeyGate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as u,j as t,X as E}from"./index-Doq8HO3X.js";import{A as X,I as ge}from"./keycodes-bIEJfQzr.js";function be(e,r){return e!=="auto"?e:r<=1?"1":r===2?"2x1":r<=4?"2x2":"3x2"}const ve={selected:new Set,layout:"2x2",tiles:[],groupId:null,recording:!1,startedAt:null,annotateMode:!1,shape:"RECT",color:"#ff3333",errorBanner:null};function ye(e,r){switch(r.type){case"SET_LAYOUT":return{...e,layout:r.layout};case"TOGGLE_SELECTED":{const n=new Set(e.selected);return n.has(r.udid)?n.delete(r.udid):n.add(r.udid),{...e,selected:n}}case"CLEAR_SELECTED":return{...e,selected:new Set};case"SET_TILES":return{...e,tiles:r.tiles};case"ADD_TILE":return e.tiles.some(n=>n.udid===r.tile.udid)?e:{...e,tiles:[...e.tiles,r.tile]};case"REMOVE_TILE":return{...e,tiles:e.tiles.filter(n=>n.udid!==r.udid)};case"BIND_RECORDING_IDS":{const n=e.tiles.map(d=>({...d,recordingId:r.map[d.udid]??d.recordingId}));return{...e,tiles:n}}case"START_RECORDING":{const n=e.tiles.map(d=>({...d,recordingId:r.tileIds[d.udid]??d.recordingId}));return{...e,groupId:r.groupId,recording:!0,startedAt:r.startedAt,tiles:n}}case"STOP_RECORDING":{const n=e.tiles.map(d=>({...d,recordingId:void 0}));return{...e,recording:!1,tiles:n}}case"SET_ANNOTATE_MODE":return{...e,annotateMode:r.enabled};case"SET_SHAPE":return{...e,shape:r.shape};case"SET_COLOR":return{...e,color:r.color};case"SET_ERROR_BANNER":return{...e,errorBanner:r.message};default:return e}}const re=u.createContext(null);function we(){const e=u.useContext(re);if(!e)throw new Error("useMosaic must be used inside <MosaicContext.Provider>");return e}function Ne(){return u.useReducer(ye,ve)}function Re(e){switch(e){case"automation":return"In automation";case"manual_other":return"Manual control by another user";case"manual_self":return"In your mosaic";case"recording_other_group":return"Recording in another group";default:return e?"Busy":null}}const q=[{id:"ios",label:"iOS",match:e=>e==="ios"},{id:"android",label:"Android",match:e=>e==="android"},{id:"tvos",label:"tvOS",match:e=>e==="tvos"},{id:"androidtv",label:"Android TV",match:e=>e==="androidtv"||e==="android-tv"},{id:"other",label:"Other",match:()=>!0}];function je(e){return e?e==="androidtv"||e==="android-tv"?"ANDROID TV":e.toUpperCase():""}function Ee({devices:e,inMosaic:r,onToggle:n}){const[d,b]=u.useState(""),[m,y]=u.useState({}),w=u.useMemo(()=>{const f=d.trim().toLowerCase();return f?e.filter(g=>g.udid.toLowerCase().includes(f)||(g.name??"").toLowerCase().includes(f)||(g.platform??"").toLowerCase().includes(f)):e},[e,d]),v=u.useMemo(()=>{const f=q.map(o=>({id:o.id,label:o.label,rows:[]})),g=o=>f.find((c,s)=>q[s].match(o))??f[f.length-1];for(const o of w)g((o.platform??"").toLowerCase()).rows.push(o);return f.filter(o=>o.rows.length>0)},[w]);return e.length===0?t.jsx("div",{className:"text-xs text-[var(--text-dim)] p-3",children:"No devices online."}):t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"relative",children:[t.jsx("span",{"aria-hidden":!0,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-dim)] text-xs",children:"⌕"}),t.jsx("input",{type:"text",value:d,placeholder:"Filter devices...",onChange:f=>b(f.target.value),className:"w-full pl-7 pr-2 py-1.5 text-xs rounded border border-[var(--border)] bg-transparent placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--accent,#3b82f6)]"})]}),v.map(f=>{const g=m[f.id];return t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsxs("button",{type:"button",onClick:()=>y(o=>({...o,[f.id]:!o[f.id]})),className:"flex items-center justify-between w-full text-[10px] uppercase tracking-wider text-[var(--text-dim)] hover:text-white px-1 py-0.5",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{"aria-hidden":!0,className:`inline-block transition-transform ${g?"-rotate-90":"rotate-0"}`,children:"▾"}),f.label]}),t.jsx("span",{children:f.rows.length})]}),!g&&t.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:f.rows.map(o=>{const c=o.busyReason==="manual_self",s=r.has(o.udid),x=!!o.busy&&!c&&!s||!!o.offline,j=o.offline?"Offline":Re(o.busyReason),i=!x;return t.jsx("li",{children:t.jsxs("button",{type:"button",disabled:x,draggable:!x,onDragStart:l=>{l.dataTransfer.effectAllowed="copy",l.dataTransfer.setData("application/x-xenon-udid",o.udid),l.dataTransfer.setData("text/plain",o.udid)},onClick:()=>n(o.udid),className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-left border transition-colors ${x?"opacity-60 cursor-not-allowed border-transparent":s?"border-emerald-500/40 bg-emerald-500/5 hover:bg-emerald-500/10":"border-transparent hover:border-[var(--border)] hover:bg-[var(--surface-2,rgba(255,255,255,0.04))]"}`,title:x?`${j} — release first`:s?"Click to remove from mosaic (or drag to a cell)":"Click to add to mosaic (or drag to a cell)",children:[t.jsx("span",{"aria-hidden":!0,className:`inline-flex items-center justify-center w-4 h-4 text-xs ${s?"text-emerald-400":"text-[var(--text-dim)]"}`,children:s?"●":"○"}),t.jsx("span",{"aria-hidden":!0,className:`inline-block w-1.5 h-1.5 rounded-full ${o.offline?"bg-zinc-600":i?"bg-emerald-400 shadow-[0_0_4px_rgba(52,211,153,0.7)]":"bg-yellow-500"}`}),t.jsx("span",{className:"font-medium flex-1 truncate text-[13px]",children:o.name??o.udid}),o.platform&&t.jsx("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-[var(--surface-2,rgba(255,255,255,0.06))] text-[var(--text-dim)]",children:je(o.platform)})]})},o.udid)})})]},f.id)}),d&&v.length===0&&t.jsxs("div",{className:"text-xs text-[var(--text-dim)] px-1 py-2",children:['No devices match "',d,'".']}),t.jsxs("div",{className:"text-[10px] text-[var(--text-dim)] px-1 pt-2 flex items-center gap-3",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 inline-block"})," available"]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-yellow-500 inline-block"})," in use"]}),t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-zinc-600 inline-block"})," offline"]})]})]})}const Te=[{id:"1",label:"1",icon:t.jsx(Ce,{})},{id:"2x1",label:"2×1",icon:t.jsx(ke,{})},{id:"2x2",label:"2×2",icon:t.jsx(Ie,{})},{id:"3x2",label:"3×2",icon:t.jsx(_e,{})},{id:"auto",label:"Auto",icon:t.jsx(De,{})}];function Se({value:e,onChange:r}){return t.jsx("div",{role:"tablist",className:"inline-flex border border-[var(--border)] rounded-md overflow-hidden text-xs bg-[var(--surface-1,rgba(255,255,255,0.02))]",children:Te.map(n=>{const d=e===n.id;return t.jsxs("button",{role:"tab","aria-selected":d,onClick:()=>r(n.id),className:`flex items-center gap-1.5 px-2.5 py-1.5 border-r border-[var(--border)] last:border-r-0 transition-colors ${d?"bg-[var(--surface-2,#2a2a2a)] text-white":"text-[var(--text-dim)] hover:bg-[var(--surface-2,rgba(255,255,255,0.04))] hover:text-white"}`,title:`Layout: ${n.label}`,children:[t.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:n.icon}),t.jsx("span",{children:n.label})]},n.id)})})}function k(e){return t.jsx("rect",{rx:1.2,ry:1.2,fill:"currentColor",...e})}function Ce(){return t.jsx("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:k({x:2,y:2,width:10,height:10})})}function ke(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[k({x:1.5,y:3,width:5,height:8}),k({x:7.5,y:3,width:5,height:8})]})}function Ie(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[k({x:1.5,y:1.5,width:5,height:5}),k({x:7.5,y:1.5,width:5,height:5}),k({x:1.5,y:7.5,width:5,height:5}),k({x:7.5,y:7.5,width:5,height:5})]})}function _e(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[k({x:1,y:1.5,width:3.3,height:5}),k({x:5.35,y:1.5,width:3.3,height:5}),k({x:9.7,y:1.5,width:3.3,height:5}),k({x:1,y:7.5,width:3.3,height:5}),k({x:5.35,y:7.5,width:3.3,height:5}),k({x:9.7,y:7.5,width:3.3,height:5})]})}function De(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[t.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1.5"}),t.jsx("circle",{cx:"7",cy:"7",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Ae({enabled:e,shape:r,color:n,onCommit:d}){const b=u.useRef(null),[m,y]=u.useState(null);u.useEffect(()=>{const c=b.current;if(!c)return;const s=()=>{c.width=c.clientWidth,c.height=c.clientHeight,w()};s();const x=new ResizeObserver(s);return x.observe(c),()=>x.disconnect()},[]);const w=u.useCallback(()=>{const c=b.current;if(!c)return;const s=c.getContext("2d");if(s&&(s.clearRect(0,0,c.width,c.height),!!m)){if(s.strokeStyle=n,s.lineWidth=3,r==="RECT"||r==="ARROW"||r==="FREEHAND")s.strokeRect(Math.min(m.startX,m.curX),Math.min(m.startY,m.curY),Math.abs(m.curX-m.startX),Math.abs(m.curY-m.startY));else if(r==="CIRCLE"){const x=Math.hypot(m.curX-m.startX,m.curY-m.startY);s.beginPath(),s.arc(m.startX,m.startY,x,0,Math.PI*2),s.stroke()}}},[m,n,r]);u.useEffect(()=>{w()},[m,w]);const v=c=>{const x=b.current.getBoundingClientRect();return{px:c.clientX-x.left,py:c.clientY-x.top,w:x.width,h:x.height}},f=c=>{if(!e)return;const s=v(c);y({startX:s.px,startY:s.py,curX:s.px,curY:s.py})},g=c=>{if(!m)return;const s=v(c);y({...m,curX:s.px,curY:s.py})},o=c=>{if(!m||!e)return;const s=v(c),x=Math.min(m.startX,s.px)/s.w,j=Math.min(m.startY,s.py)/s.h,i=Math.abs(s.px-m.startX)/s.w,l=Math.abs(s.py-m.startY)/s.h;i>.005&&l>.005&&d({shape:r,color:n,geometry:{x,y:j,w:i,h:l}}),y(null)};return t.jsx("canvas",{ref:b,style:{position:"absolute",inset:0,pointerEvents:e?"auto":"none",cursor:e?"crosshair":"default"},onMouseDown:f,onMouseMove:g,onMouseUp:o,onMouseLeave:()=>y(null)})}const Me=3,Oe=45e3,Z=[2e3,5e3,1e4];function $e(e){const r=Math.max(0,Math.min(e,Z.length-1));return Z[r]}function Le(e){return e<Me}function Q(e){const r=(e.lastError||"").toLowerCase();return/did not find test app|not installed|webdriveragentrunner|applicationverification/.test(r)?"WebDriverAgent is not installed on this device. Install and trust WDA, then retry.":/unsupported ios version|manualpairingtunnelstart/.test(r)?"This device’s iOS version is not supported for live streaming on this host.":/econnrefused|econnreset|connection reset|tunnel/.test(r)?"Lost the connection to the device tunnel. Reconnect the device, then retry.":e.lastError&&e.lastError.trim()?e.lastError.trim():"We couldn’t start the live stream for this device."}const Be=10,Pe=500;function Ue({udid:e,name:r,recordingId:n,annotateMode:d,shape:b,color:m,aspect:y="9 / 16",screenWidth:w,screenHeight:v,platform:f,onAnnotation:g,onRemove:o}){const[c,s]=u.useState("connecting"),[x,j]=u.useState(0),i=u.useRef(0),l=u.useRef(null),[p,R]=u.useState(""),[O,M]=u.useState([]),[N,T]=u.useState(!1),S=u.useRef(null),L=u.useRef(null),B=f==="android"||f==="androidtv"||f==="android-tv",oe=f==="ios"||f==="tvos",U=!d&&!!w&&!!v,G=(a,h,C)=>{const D=w,_=v,A=Math.min(1,Math.max(0,(a-C.left)/C.width)),I=Math.min(1,Math.max(0,(h-C.top)/C.height));return{x:Math.round(A*D),y:Math.round(I*_)}},ae=(a,h,C)=>{const D=Date.now()+Math.random(),_=a-C.left,A=h-C.top;M(I=>[...I,{id:D,x:_,y:A}]),window.setTimeout(()=>{M(I=>I.filter(Y=>Y.id!==D))},500)},ie=a=>{if(!U||c!=="live"||a.button!==0)return;const h=a.currentTarget;h.setPointerCapture(a.pointerId),L.current={startX:a.clientX,startY:a.clientY,startTime:Date.now(),rect:h.getBoundingClientRect()},ae(a.clientX,a.clientY,L.current.rect),h.focus()},ce=async a=>{var V,J;const h=L.current;if(L.current=null,!h||!U)return;try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}const C=a.clientX-h.startX,D=a.clientY-h.startY,_=Math.hypot(C,D),A=Date.now()-h.startTime,I=G(h.startX,h.startY,h.rect),Y=_<Be;try{if(Y&&A<Pe)await E.tap(e,I.x,I.y);else if(Y)await((J=(V=E).touchAndHold)==null?void 0:J.call(V,e,I.x,I.y,A));else{const W=G(a.clientX,a.clientY,h.rect);await E.swipe(e,I.x,I.y,W.x,W.y)}}catch(W){console.error(`[DeviceTile] gesture failed for ${e}`,W)}},le=()=>{L.current=null},de=async a=>{if(!U||c!=="live"||a.metaKey||a.ctrlKey||a.altKey)return;const h=a.key;try{if(h.length===1){a.preventDefault(),await E.typeText(e,h);return}if(h==="Backspace"){a.preventDefault(),B?await E.pressKey(e,67):await E.typeText(e,"\b");return}if(h==="Enter"){a.preventDefault(),B?await E.pressKey(e,66):await E.typeText(e,`
|
|
2
|
+
`);return}if(h==="Tab"){a.preventDefault(),await E.typeText(e," ");return}h==="Escape"&&B&&(a.preventDefault(),await E.pressKey(e,X.BACK))}catch(C){console.error(`[DeviceTile] keystroke "${h}" failed for ${e}`,C)}},ue=()=>E.pressKey(e,B?X.HOME:ge.HOME).catch(a=>console.error(`[DeviceTile] home failed for ${e}`,a)),fe=()=>E.pressKey(e,X.BACK).catch(a=>console.error(`[DeviceTile] back failed for ${e}`,a)),me=()=>E.pressKey(e,X.APP_SWITCH).catch(a=>console.error(`[DeviceTile] app-switch failed for ${e}`,a)),xe=async()=>{try{const a=await E.getScreenshot(e),h=(a==null?void 0:a.screenshot)??(a==null?void 0:a.value)??a;if(!h)return;const C=await fetch(`data:image/png;base64,${h}`).then(A=>A.blob()),D=URL.createObjectURL(C),_=document.createElement("a");_.href=D,_.download=`${r||e}-${Date.now()}.png`,document.body.appendChild(_),_.click(),_.remove(),setTimeout(()=>URL.revokeObjectURL(D),1e3)}catch(a){console.error(`[DeviceTile] screenshot failed for ${e}`,a)}};u.useEffect(()=>{console.log(`[DeviceTile] Rendering ${e} in state: ${c}`)},[e,c]);const he=`/xenon/api/control/${encodeURIComponent(e)}/stream?t=${x}`,z=u.useCallback(async()=>{try{const a=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/status`);if(!a.ok)throw new Error(String(a.status));const h=await a.json();R(Q({lastError:h==null?void 0:h.lastError,status:h==null?void 0:h.status}))}catch{R(Q({}))}},[e]),H=u.useCallback(()=>{const a=i.current;Le(a)?(i.current=a+1,l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{s("connecting"),j(Date.now())},$e(a))):(s("unavailable"),z())},[z]);u.useEffect(()=>{if(c!=="connecting")return;const a=setTimeout(H,Oe);return()=>clearTimeout(a)},[c,x,H]),u.useEffect(()=>()=>{l.current&&clearTimeout(l.current)},[]);const pe=()=>{l.current&&clearTimeout(l.current),i.current=0,R(""),s("connecting"),j(Date.now())},P=!!n,K=r||e.slice(0,16)+"…";return t.jsxs("div",{className:"flex items-stretch justify-center w-full h-full min-h-0 min-w-0 gap-2",children:[t.jsxs("div",{className:"relative bg-[#000] rounded-lg overflow-hidden border border-[var(--border)] group max-h-full max-w-full self-center",style:{aspectRatio:y,height:"100%"},children:[c==="connecting"&&t.jsxs("div",{className:"flex flex-col items-center justify-center bg-neutral-900 text-neutral-400 absolute inset-0 z-20",children:[t.jsx("div",{className:"relative flex items-center justify-center",children:t.jsx("div",{className:"w-12 h-12 border-4 border-neutral-800 border-t-neutral-400 rounded-full animate-spin"})}),t.jsx("div",{className:"mt-4 font-bold text-neutral-200",children:"Starting Stream…"}),t.jsx("div",{className:"text-[10px] mt-1 text-neutral-500 opacity-60 font-mono",children:e}),t.jsx("div",{className:"text-[10px] mt-4 text-neutral-400 bg-white/5 px-2 py-1 rounded",children:"Waiting for device connection..."})]}),c==="unavailable"&&t.jsx("div",{className:"flex items-center justify-center bg-black text-neutral-400 absolute inset-0 z-20",children:t.jsxs("div",{className:"text-center p-6",children:[t.jsx("div",{className:"text-5xl mb-4 opacity-20",children:"📵"}),t.jsx("div",{className:"font-bold text-white text-lg",children:"Connection Failed"}),t.jsx("p",{className:"text-xs mt-2 text-neutral-500 leading-relaxed max-w-[240px] mx-auto",children:p||"We couldn’t start the live stream for this device."}),t.jsx("button",{className:"mt-6 text-sm font-semibold px-6 py-2.5 rounded-full bg-red-600 hover:bg-red-500 text-white transition-all shadow-[0_0_20px_rgba(220,38,38,0.3)] active:scale-95",onClick:pe,children:"Retry Connection"})]})}),t.jsx("img",{src:he,alt:K,className:"absolute inset-0 w-full h-full object-contain bg-black select-none pointer-events-none",draggable:!1,style:{opacity:c==="live"?1:0,transition:"opacity 0.3s ease-in-out"},onLoad:()=>{console.log(`[DeviceTile] Image LOADED for ${e}`),i.current=0,l.current&&clearTimeout(l.current),s("live")},onError:a=>{console.error(`[DeviceTile] Image ERROR for ${e}`,a),H()}},x),U&&c==="live"&&t.jsx("div",{ref:S,className:`absolute inset-0 z-10 touch-none outline-none ${N?"ring-2 ring-emerald-400/60 ring-inset rounded-lg":""}`,tabIndex:0,onPointerDown:ie,onPointerUp:ce,onPointerCancel:le,onKeyDown:de,onFocus:()=>T(!0),onBlur:()=>T(!1)}),t.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none overflow-hidden",children:O.map(a=>t.jsx("span",{className:"absolute block w-10 h-10 rounded-full border-2 border-emerald-300/80 animate-ping",style:{left:a.x-20,top:a.y-20}},a.id))}),P&&d&&t.jsx(Ae,{enabled:!0,shape:b,color:m,onCommit:a=>g(n,a)}),P&&t.jsx("div",{className:"absolute top-3 left-3 z-30 pointer-events-none",children:t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-red-600 text-white text-[9px] font-black shadow-lg",children:"REC"})}),t.jsxs("div",{className:"absolute top-3 left-3 z-30 flex flex-col gap-1.5 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:[c==="live"&&!P&&t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-emerald-500 text-black text-[9px] font-black shadow-lg w-fit",children:"LIVE"}),t.jsx("span",{className:"px-2 py-1 rounded bg-black/80 text-white text-[11px] font-medium backdrop-blur-md border border-white/10 shadow-xl truncate max-w-[180px]",children:K})]})]}),t.jsx(Ye,{streamState:c,recording:P,isIOS:oe,isAndroid:B,platform:f,onClose:!P&&o?()=>o(e):void 0,sendHome:ue,sendBack:fe,sendAppSwitch:me,captureScreenshot:xe,displayName:K})]})}function Ye({streamState:e,recording:r,isIOS:n,isAndroid:d,platform:b,onClose:m,sendHome:y,sendBack:w,sendAppSwitch:v,captureScreenshot:f,displayName:g}){const o=e==="live";return!m&&!o?null:t.jsxs("div",{className:"self-stretch w-9 flex flex-col items-center justify-between gap-1 py-2 rounded-lg bg-black/40 border border-white/10 backdrop-blur-md text-white",children:[t.jsx("div",{className:"flex flex-col items-center gap-1",children:m&&t.jsx("button",{type:"button","aria-label":`Remove ${g} from mosaic`,title:"Remove from mosaic",onClick:m,className:"w-7 h-7 flex items-center justify-center rounded-md hover:bg-red-600/70 transition-colors text-base leading-none",children:"×"})}),o&&t.jsxs("div",{className:"flex flex-col items-center gap-1.5 my-auto",children:[(d||n)&&t.jsx("button",{type:"button",title:`Home${b?` (${b})`:""}`,onClick:y,className:"w-7 h-7 flex items-center justify-center rounded-md hover:bg-white/15 transition-colors text-sm",children:"⌂"}),d&&t.jsx("button",{type:"button",title:"Back",onClick:w,className:"w-7 h-7 flex items-center justify-center rounded-md hover:bg-white/15 transition-colors text-sm",children:"‹"}),d&&t.jsx("button",{type:"button",title:"Recent apps",onClick:v,className:"w-7 h-7 flex items-center justify-center rounded-md hover:bg-white/15 transition-colors text-sm",children:"▢"})]}),o&&t.jsx("div",{className:"flex flex-col items-center gap-1",children:t.jsx("button",{type:"button",title:"Screenshot",onClick:f,className:"w-7 h-7 flex items-center justify-center rounded-md hover:bg-white/15 transition-colors text-sm",children:"⎙"})})]})}const We={1:"1fr","2x1":"1fr 1fr","2x2":"1fr 1fr","3x2":"1fr 1fr 1fr"},Xe={1:"1fr","2x1":"1fr","2x2":"1fr 1fr","3x2":"1fr 1fr"},Fe={1:1,"2x1":2,"2x2":4,"3x2":6};function He({layout:e,tiles:r,annotateMode:n,shape:d,color:b,onAnnotation:m,onRemove:y,onDropDevice:w}){const v=be(e,r.length),f=Fe[v];r.length;const g=r.length,o=e==="auto"?Math.max(g,1):f,c=Math.max(0,o-g);return t.jsxs("div",{style:{display:"grid",gap:8,gridTemplateColumns:We[v],gridTemplateRows:Xe[v]},className:"h-full",children:[r.map(s=>t.jsx(Ue,{udid:s.udid,name:s.name,mjpegPort:s.mjpegPort,recordingId:s.recordingId,aspect:s.aspect,screenWidth:s.screenWidth,screenHeight:s.screenHeight,platform:s.platform,annotateMode:n,shape:d,color:b,onAnnotation:m,onRemove:y},s.udid)),Array.from({length:c},(s,x)=>t.jsx(Ke,{onDropDevice:w},`empty-${x}`))]})}function Ke({onDropDevice:e}){const[r,n]=u.useState(!1);return t.jsxs("div",{onDragOver:d=>{e&&(d.preventDefault(),d.dataTransfer.dropEffect="copy",r||n(!0))},onDragLeave:()=>n(!1),onDrop:d=>{if(n(!1),!e)return;d.preventDefault();const b=d.dataTransfer.getData("application/x-xenon-udid")||d.dataTransfer.getData("text/plain");b&&e(b)},className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors ${r?"border-emerald-500/60 bg-emerald-500/5":"border-[var(--border)] bg-[var(--surface-1,rgba(255,255,255,0.02))]"} text-[var(--text-dim)] min-h-[120px]`,children:[t.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-xl ${r?"bg-emerald-500/15 text-emerald-300":"bg-white/5 text-white/60"}`,children:"+"}),t.jsx("div",{className:"text-xs font-medium",children:"Drag device here"}),t.jsx("div",{className:"text-[10px] opacity-70",children:"or click one in the panel"})]})}const $="/xenon/api/recordings";class ne extends Error{constructor(r){super(r.message??r.error),this.body=r}}async function F(e,r){const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:r?JSON.stringify(r):void 0});if(n.status===409)throw new ne(await n.json());if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}function Ge(e,r){return F($,{udids:e,...r})}function ze(e){return F(`${$}/${encodeURIComponent(e)}/stop`)}function se(e,r,n,d,b){return F(`${$}/${encodeURIComponent(e)}/bookmark`,{recordingId:r,timecodeMs:n,label:d,note:b})}function Ve(e,r){return F(`${$}/${encodeURIComponent(e)}/annotation`,r)}function Je(e){return`${$}/${encodeURIComponent(e)}/bundle.zip`}function qe(e){return`${$}/${encodeURIComponent(e)}/composite.mp4`}function Ze({selectedUdids:e}){const{state:r,dispatch:n}=we(),d=async()=>{if(!(r.recording||e.length===0))try{const o=await Ge(e),c={};for(const s of o.recordings)c[s.udid]=s.id;n({type:"START_RECORDING",groupId:o.groupId,startedAt:Date.now(),tileIds:c}),n({type:"SET_ERROR_BANNER",message:null})}catch(o){if(o instanceof ne)if(o.body.error==="device_busy"){const c=(o.body.busyDevices??[]).map(s=>`${s.udid} (${s.reason})`).join(", ");n({type:"SET_ERROR_BANNER",message:`Cannot start — these devices are busy: ${c}`})}else n({type:"SET_ERROR_BANNER",message:`Server-wide recording cap reached (${o.body.active}/${o.body.limit}).`});else n({type:"SET_ERROR_BANNER",message:`Recording failed: ${o.message}`})}},b=async()=>{if(r.groupId)try{await ze(r.groupId)}catch(o){n({type:"SET_ERROR_BANNER",message:`Stop failed: ${o.message}`})}finally{n({type:"STOP_RECORDING"})}},m=async()=>{var x;if(!r.groupId||!r.recording)return;const o=window.prompt("Bookmark label?");if(!o)return;const c=r.startedAt?Date.now()-r.startedAt:0,s=(x=r.tiles.find(j=>j.recordingId))==null?void 0:x.recordingId;if(s)try{await se(r.groupId,s,c,o)}catch(j){n({type:"SET_ERROR_BANNER",message:`Bookmark failed: ${j.message}`})}},y=()=>n({type:"SET_ANNOTATE_MODE",enabled:!r.annotateMode}),w=!r.recording&&e.length>0,v=r.recording,f=r.groupId&&!r.recording,g=f&&r.tiles.length>=2;return t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("button",{onClick:d,disabled:!w,className:"px-3 py-1.5 text-sm rounded bg-red-600 text-white disabled:opacity-40 disabled:cursor-not-allowed",children:["● ",e.length>1?"Record All":"Record"]}),t.jsx("button",{onClick:b,disabled:!v,className:"px-3 py-1.5 text-sm rounded border border-[var(--border)] disabled:opacity-40 disabled:cursor-not-allowed",children:"⏹ Stop"}),t.jsx("button",{onClick:m,disabled:!v,className:"px-3 py-1.5 text-sm rounded border border-[var(--border)] disabled:opacity-40 disabled:cursor-not-allowed",children:"🔖 Bookmark"}),t.jsx("button",{onClick:y,disabled:!r.recording,className:`px-3 py-1.5 text-sm rounded border ${r.annotateMode?"bg-[var(--accent,#3b82f6)] text-white border-transparent":"border-[var(--border)]"} disabled:opacity-40 disabled:cursor-not-allowed`,children:"✎ Annotate"}),g&&t.jsx("a",{href:qe(r.groupId),className:"ml-2 px-3 py-1.5 text-sm rounded border border-[var(--border)] hover:bg-[var(--surface-2,#1a1a1a)]",download:`mosaic-${r.groupId}.mp4`,children:"⤓ Composite mp4"}),f&&t.jsx("a",{href:Je(r.groupId),className:`${g?"ml-1":"ml-2"} px-3 py-1.5 text-sm rounded border border-[var(--border)] hover:bg-[var(--surface-2,#1a1a1a)]`,download:!0,children:"⤓ Proof bundle"})]})}function Qe({remainingSec:e,onContinue:r,onReleaseNow:n}){return t.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"idle-warning-title",className:"fixed inset-0 z-40 bg-black/60 flex items-center justify-center",children:t.jsxs("div",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-lg w-full max-w-md p-6",children:[t.jsx("h3",{id:"idle-warning-title",className:"text-base font-semibold mb-2",children:"Are you still there?"}),t.jsxs("p",{className:"text-sm text-[var(--text-dim)] mb-4",children:["Your devices will be released in"," ",t.jsxs("span",{className:"text-[var(--text)] font-mono font-semibold",children:[e,"s"]})," due to inactivity. Click ",t.jsx("strong",{children:"Continue Session"})," to keep them locked."]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:n,className:"h-9 px-3 rounded-md border border-[var(--border)] text-sm text-[var(--text-dim)] hover:text-[var(--text)]",children:"Release now"}),t.jsx("button",{type:"button",autoFocus:!0,onClick:r,className:"h-9 px-4 rounded-md bg-[var(--green)] text-black text-sm font-medium",children:"Continue Session"})]})]})})}const ee=["mousemove","mousedown","keydown","touchstart","wheel"];function et({idleAfterMs:e,warningSec:r,onWarning:n,onTimeout:d,enabled:b}){const[m,y]=u.useState(!1),[w,v]=u.useState(null),f=u.useRef(null),g=u.useRef(null),o=u.useRef(!1),c=u.useRef(n),s=u.useRef(d);c.current=n,s.current=d;function x(){f.current&&(clearTimeout(f.current),f.current=null),g.current&&(clearInterval(g.current),g.current=null)}function j(){o.current=!0,y(!0),v(r),c.current(r);let p=r;g.current=setInterval(()=>{p-=1,p<=0?(x(),o.current=!1,y(!1),v(null),s.current()):v(p)},1e3)}function i(){x(),o.current=!1,y(!1),v(null);const p=e-r*1e3;f.current=setTimeout(j,Math.max(0,p))}function l(){b&&i()}return u.useEffect(()=>{if(!b){x(),o.current=!1,y(!1),v(null);return}function p(){o.current||i()}return ee.forEach(R=>window.addEventListener(R,p,{passive:!0})),i(),()=>{ee.forEach(R=>window.removeEventListener(R,p)),x()}},[b,e,r]),{warning:m,remainingSec:w,reset:l}}const tt=5*60*1e3,rt=30;function te(e){if(!e)return"9 / 16";const r=Number(e.screenWidth),n=Number(e.screenHeight);if(Number.isFinite(r)&&Number.isFinite(n)&&r>0&&n>0)return`${r} / ${n}`;const d=(e.platform||"").toLowerCase();return d==="tvos"||d==="androidtv"||d==="android-tv"?"16 / 9":"9 / 16"}function nt(e,r,n){return n?e===`manual_${n}_${r}`:!1}function st(e,r){if(e.busy)return e.session_id?e.session_id.startsWith("manual_")?nt(e.session_id,e.udid,r)?"manual_self":"manual_other":"automation":"unknown"}function ot(e,r){return{udid:e.udid,name:e.name,platform:e.platform,busy:e.busy,busyReason:st(e,r),mjpegServerPort:e.mjpegServerPort,offline:!!e.offline}}function ct(){const[e,r]=Ne(),[n,d]=u.useState([]),[b,m]=u.useState(0),[y,w]=u.useState(null);u.useEffect(()=>{let i=!1;return fetch("/xenon/api/auth/me",{credentials:"include"}).then(l=>l.ok?l.json():null).then(l=>{!i&&(l!=null&&l.userId)&&w(l.userId)}).catch(()=>{}),()=>{i=!0}},[]),u.useEffect(()=>{let i=!1;const l=async()=>{try{const R=await E.getDevices();i||d(Array.isArray(R)?R:[])}catch{}};l();const p=window.setInterval(l,5e3);return()=>{i=!0,window.clearInterval(p)}},[b]),u.useEffect(()=>{let i=!1;return(async()=>{try{const l=await E.getDevices(),p=(Array.isArray(l)?l:[]).filter(N=>{var T;return N.busy&&((T=N.session_id)==null?void 0:T.startsWith("manual_"))});if(p.length===0)return;const O=(await Promise.all(p.map(async N=>{try{const T=await fetch(`/xenon/api/control/${encodeURIComponent(N.udid)}/stream/status`);if(!T.ok)return null;const S=await T.json();return(S==null?void 0:S.status)==="running"?N:null}catch{return null}}))).filter(N=>N!==null);if(i||O.length===0)return;const M=O.map(N=>{const T=Number(N.screenWidth),S=Number(N.screenHeight);return{udid:N.udid,name:N.name,mjpegPort:0,aspect:te(N),screenWidth:Number.isFinite(T)&&T>0?T:void 0,screenHeight:Number.isFinite(S)&&S>0?S:void 0,platform:N.platform}});r({type:"SET_TILES",tiles:M})}catch{}})(),()=>{i=!0}},[]),u.useEffect(()=>{const i=async l=>{var N,T;if(l.key!=="b"&&l.key!=="B")return;const p=(N=l.target)==null?void 0:N.tagName;if(p==="INPUT"||p==="TEXTAREA"||p==="SELECT"||!e.recording||!e.groupId)return;const R=window.prompt("Bookmark label?");if(!R)return;const O=e.startedAt?Date.now()-e.startedAt:0,M=(T=e.tiles.find(S=>S.recordingId))==null?void 0:T.recordingId;if(M)try{await se(e.groupId,M,O,R)}catch(S){r({type:"SET_ERROR_BANNER",message:`Bookmark failed: ${S.message}`})}};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e.recording,e.groupId,e.startedAt,e.tiles,r]);const v=u.useMemo(()=>new Set(e.tiles.map(i=>i.udid)),[e.tiles]),f=u.useMemo(()=>n.map(i=>ot(i,y)),[n,y]),g=i=>{const l=Number(i.screenWidth),p=Number(i.screenHeight);return{udid:i.udid,name:i.name,mjpegPort:0,aspect:te(i),screenWidth:Number.isFinite(l)&&l>0?l:void 0,screenHeight:Number.isFinite(p)&&p>0?p:void 0,platform:i.platform}},o=async i=>{if(e.tiles.some(R=>R.udid===i)){await c(i);return}if(e.recording){r({type:"SET_ERROR_BANNER",message:"Stop recording before changing the mosaic layout."});return}const p=n.find(R=>R.udid===i);p&&(r({type:"ADD_TILE",tile:g(p)}),fetch(`/xenon/api/control/${encodeURIComponent(i)}/stream/start`,{method:"POST"}).catch(()=>{}))},c=async i=>{r({type:"REMOVE_TILE",udid:i});try{await fetch(`/xenon/api/control/${encodeURIComponent(i)}/stream/stop`,{method:"POST"})}catch{}m(l=>l+1)},s=async(i,l)=>{if(e.groupId)try{await Ve(e.groupId,{recordingId:i,timecodeMs:e.startedAt?Date.now()-e.startedAt:0,shape:l.shape,geometry:JSON.stringify(l.geometry),color:l.color,text:l.text})}catch(p){r({type:"SET_ERROR_BANNER",message:`Annotation failed: ${p.message}`})}},x=()=>{for(const i of e.tiles){const l=`/xenon/api/control/${encodeURIComponent(i.udid)}/stream/stop`;try{navigator.sendBeacon?navigator.sendBeacon(l):fetch(l,{method:"POST",keepalive:!0}).catch(()=>{})}catch{}}e.tiles.forEach(i=>r({type:"REMOVE_TILE",udid:i.udid}))},j=et({idleAfterMs:tt,warningSec:rt,enabled:e.tiles.length>0,onWarning:()=>{},onTimeout:()=>{x()}});return t.jsxs(re.Provider,{value:{state:e,dispatch:r},children:[t.jsxs("div",{className:"flex flex-col h-full p-4 gap-3",children:[t.jsxs("header",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("h1",{className:"text-base font-semibold",children:"Live Devices"}),t.jsx(Se,{value:e.layout,onChange:i=>r({type:"SET_LAYOUT",layout:i})})]}),t.jsx(Ze,{selectedUdids:e.tiles.map(i=>i.udid)})]}),e.errorBanner&&t.jsxs("div",{role:"alert",className:"text-sm rounded border border-red-500/40 bg-red-500/10 text-red-100 px-3 py-2 flex items-center gap-2",children:[t.jsx("span",{className:"flex-1",children:e.errorBanner}),t.jsx("button",{className:"text-xs opacity-80 hover:opacity-100",onClick:()=>r({type:"SET_ERROR_BANNER",message:null}),children:"Dismiss"})]}),t.jsxs("div",{className:"grid grid-cols-[260px_1fr] gap-3 flex-1 min-h-0",children:[t.jsxs("aside",{className:"flex flex-col gap-2 border border-[var(--border)] rounded p-3 overflow-y-auto min-h-0",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs uppercase tracking-wide text-[var(--text-dim)]",children:"Devices"}),t.jsx("button",{className:"text-xs underline opacity-70 hover:opacity-100",onClick:()=>m(i=>i+1),children:"Refresh"})]}),t.jsx(Ee,{devices:f,inMosaic:v,onToggle:o}),t.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-dim)] leading-relaxed",children:"Click a device to add it to the mosaic. Click again (or use the × on the tile) to remove it."})]}),t.jsx("main",{className:"border border-[var(--border)] rounded p-2 overflow-y-auto h-full min-h-0",children:t.jsx(He,{layout:e.layout,tiles:e.tiles,annotateMode:e.annotateMode,shape:e.shape,color:e.color,onAnnotation:s,onRemove:c,onDropDevice:o})})]})]}),j.warning&&j.remainingSec!==null&&t.jsx(Qe,{remainingSec:j.remainingSec,onContinue:j.reset,onReleaseNow:x})]})}export{ct as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./index-
|
|
1
|
+
import{j as s}from"./index-Doq8HO3X.js";const i=({icon:e,title:m,description:t,action:a})=>s.jsxs("div",{className:"empty-state",children:[e&&s.jsx("div",{className:"empty-state-icon",children:e}),s.jsx("div",{className:"empty-state-title",children:m}),t&&s.jsx("div",{className:"empty-state-desc",children:t}),a&&s.jsx("div",{className:"empty-state-action",children:a})]});export{i as E};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./index-
|
|
1
|
+
import{j as s}from"./index-Doq8HO3X.js";const r=({label:e,description:l,children:c,error:a,htmlFor:d})=>s.jsxs("div",{className:"fg",children:[s.jsx("label",{className:"fg-label",htmlFor:d,children:e}),l&&s.jsx("div",{className:"fg-desc",children:l}),s.jsx("div",{className:"fg-control",children:c}),a&&s.jsx("div",{className:"fg-error",children:a})]});export{r as F};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as i,j as h,h as at,R as xe,i as it,n as st}from"./index-DM2pqF7I.js";function me(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function De(...e){return t=>{let n=!1;const r=e.map(o=>{const a=me(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():me(e[o],null)}}}}function I(...e){return i.useCallback(De(...e),e)}function Oe(e){const t=ct(e),n=i.forwardRef((r,o)=>{const{children:a,...c}=r,s=i.Children.toArray(a),d=s.find(lt);if(d){const u=d.props.children,f=s.map(v=>v===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:v);return h.jsx(t,{...c,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,f):null})}return h.jsx(t,{...c,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function ct(e){const t=i.forwardRef((n,r)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const c=ft(o),s=dt(a,o.props);return o.type!==i.Fragment&&(s.ref=r?De(r,c):c),i.cloneElement(o,s)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ut=Symbol("radix.slottable");function lt(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ut}function dt(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...s)=>{const d=a(...s);return o(...s),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ft(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var vt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],D=vt.reduce((e,t)=>{const n=Oe(`Primitive.${t}`),r=i.forwardRef((o,a)=>{const{asChild:c,...s}=o,d=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(d,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mt(e,t){e&&at.flushSync(()=>e.dispatchEvent(t))}function ht(e,t){const n=i.createContext(t),r=a=>{const{children:c,...s}=a,d=i.useMemo(()=>s,Object.values(s));return h.jsx(n.Provider,{value:d,children:c})};r.displayName=e+"Provider";function o(a){const c=i.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function pt(e,t=[]){let n=[];function r(a,c){const s=i.createContext(c),d=n.length;n=[...n,c];const u=v=>{var y;const{scope:m,children:g,...w}=v,l=((y=m==null?void 0:m[e])==null?void 0:y[d])||s,p=i.useMemo(()=>w,Object.values(w));return h.jsx(l.Provider,{value:p,children:g})};u.displayName=a+"Provider";function f(v,m){var l;const g=((l=m==null?void 0:m[e])==null?void 0:l[d])||s,w=i.useContext(g);if(w)return w;if(c!==void 0)return c;throw new Error(`\`${v}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=n.map(c=>i.createContext(c));return function(s){const d=(s==null?void 0:s[e])||a;return i.useMemo(()=>({[`__scope${e}`]:{...s,[e]:d}}),[s,d])}};return o.scopeName=e,[r,gt(o,...t)]}function gt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const c=r.reduce((s,{useScope:d,scopeName:u})=>{const v=d(a)[`__scope${u}`];return{...s,...v}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function B(e){const t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var U=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{};function A(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function yt(e,t=globalThis==null?void 0:globalThis.document){const n=B(e);i.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Et="DismissableLayer",ce="dismissableLayer.update",bt="dismissableLayer.pointerDownOutside",Ct="dismissableLayer.focusOutside",he,Ae=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Te=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:s,...d}=e,u=i.useContext(Ae),[f,v]=i.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=i.useState({}),w=I(t,E=>v(E)),l=Array.from(u.layers),[p]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=l.indexOf(p),b=f?l.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,R=Rt(E=>{const T=E.target,L=[...u.branches].some(W=>W.contains(T));!S||L||(o==null||o(E),c==null||c(E),E.defaultPrevented||s==null||s())},m),N=Nt(E=>{const T=E.target;[...u.branches].some(W=>W.contains(T))||(a==null||a(E),c==null||c(E),E.defaultPrevented||s==null||s())},m);return yt(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&s&&(E.preventDefault(),s()))},m),i.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(he=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),pe(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=he)}},[f,m,n,u]),i.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),pe())},[f,u]),i.useEffect(()=>{const E=()=>g({});return document.addEventListener(ce,E),()=>document.removeEventListener(ce,E)},[]),h.jsx(D.div,{...d,ref:w,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:A(e.onFocusCapture,N.onFocusCapture),onBlurCapture:A(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:A(e.onPointerDownCapture,R.onPointerDownCapture)})});Te.displayName=Et;var St="DismissableLayerBranch",wt=i.forwardRef((e,t)=>{const n=i.useContext(Ae),r=i.useRef(null),o=I(t,r);return i.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),h.jsx(D.div,{...e,ref:o})});wt.displayName=St;function Rt(e,t=globalThis==null?void 0:globalThis.document){const n=B(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let d=function(){Me(bt,n,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Nt(e,t=globalThis==null?void 0:globalThis.document){const n=B(e),r=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!r.current&&Me(Ct,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function pe(){const e=new CustomEvent(ce);document.dispatchEvent(e)}function Me(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?mt(o,a):o.dispatchEvent(a)}var Pt=xe[" useId ".trim().toString()]||(()=>{}),xt=0;function ee(e){const[t,n]=i.useState(Pt());return U(()=>{n(r=>r??String(xt++))},[e]),e||(t?`radix-${t}`:"")}var Dt=xe[" useInsertionEffect ".trim().toString()]||U;function Ot({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,c]=At({defaultProp:t,onChange:n}),s=e!==void 0,d=s?e:o;{const f=i.useRef(e!==void 0);i.useEffect(()=>{const v=f.current;v!==s&&console.warn(`${r} is changing from ${v?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=s},[s,r])}const u=i.useCallback(f=>{var v;if(s){const m=Tt(f)?f(e):f;m!==e&&((v=c.current)==null||v.call(c,m))}else a(f)},[s,e,a,c]);return[d,u]}function At({defaultProp:e,onChange:t}){const[n,r]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Dt(()=>{a.current=t},[t]),i.useEffect(()=>{var c;o.current!==n&&((c=a.current)==null||c.call(a,n),o.current=n)},[n,o]),[n,r,a]}function Tt(e){return typeof e=="function"}var te="focusScope.autoFocusOnMount",ne="focusScope.autoFocusOnUnmount",ge={bubbles:!1,cancelable:!0},Mt="FocusScope",Ie=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...c}=e,[s,d]=i.useState(null),u=B(o),f=B(a),v=i.useRef(null),m=I(t,l=>d(l)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let l=function(C){if(g.paused||!s)return;const S=C.target;s.contains(S)?v.current=S:O(v.current,{select:!0})},p=function(C){if(g.paused||!s)return;const S=C.relatedTarget;S!==null&&(s.contains(S)||O(v.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&O(s)};document.addEventListener("focusin",l),document.addEventListener("focusout",p);const b=new MutationObserver(y);return s&&b.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",l),document.removeEventListener("focusout",p),b.disconnect()}}},[r,s,g.paused]),i.useEffect(()=>{if(s){Ee.add(g);const l=document.activeElement;if(!s.contains(l)){const y=new CustomEvent(te,ge);s.addEventListener(te,u),s.dispatchEvent(y),y.defaultPrevented||(It(jt(Le(s)),{select:!0}),document.activeElement===l&&O(s))}return()=>{s.removeEventListener(te,u),setTimeout(()=>{const y=new CustomEvent(ne,ge);s.addEventListener(ne,f),s.dispatchEvent(y),y.defaultPrevented||O(l??document.body,{select:!0}),s.removeEventListener(ne,f),Ee.remove(g)},0)}}},[s,u,f,g]);const w=i.useCallback(l=>{if(!n&&!r||g.paused)return;const p=l.key==="Tab"&&!l.altKey&&!l.ctrlKey&&!l.metaKey,y=document.activeElement;if(p&&y){const b=l.currentTarget,[C,S]=Lt(b);C&&S?!l.shiftKey&&y===S?(l.preventDefault(),n&&O(C,{select:!0})):l.shiftKey&&y===C&&(l.preventDefault(),n&&O(S,{select:!0})):y===b&&l.preventDefault()}},[n,r,g.paused]);return h.jsx(D.div,{tabIndex:-1,...c,ref:m,onKeyDown:w})});Ie.displayName=Mt;function It(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(O(r,{select:t}),document.activeElement!==n)return}function Lt(e){const t=Le(e),n=ye(t,e),r=ye(t.reverse(),e);return[n,r]}function Le(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ye(e,t){for(const n of e)if(!_t(n,{upTo:t}))return n}function _t(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ft(e){return e instanceof HTMLInputElement&&"select"in e}function O(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ft(e)&&t&&e.select()}}var Ee=kt();function kt(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=be(e,t),e.unshift(t)},remove(t){var n;e=be(e,t),(n=e[0])==null||n.resume()}}}function be(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jt(e){return e.filter(t=>t.tagName!=="A")}var Wt="Portal",_e=i.forwardRef((e,t)=>{var s;const{container:n,...r}=e,[o,a]=i.useState(!1);U(()=>a(!0),[]);const c=n||o&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return c?it.createPortal(h.jsx(D.div,{...r,ref:t}),c):null});_e.displayName=Wt;function Bt(e,t){return i.useReducer((n,r)=>t[n][r]??n,e)}var q=e=>{const{present:t,children:n}=e,r=Ut(t),o=typeof n=="function"?n({present:r.isPresent}):i.Children.only(n),a=I(r.ref,$t(o));return typeof n=="function"||r.isPresent?i.cloneElement(o,{ref:a}):null};q.displayName="Presence";function Ut(e){const[t,n]=i.useState(),r=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),c=e?"mounted":"unmounted",[s,d]=Bt(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const u=V(r.current);a.current=s==="mounted"?u:"none"},[s]),U(()=>{const u=r.current,f=o.current;if(f!==e){const m=a.current,g=V(u);e?d("MOUNT"):g==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(f&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),U(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,v=g=>{const l=V(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&l&&(d("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},m=g=>{g.target===t&&(a.current=V(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",v),t.addEventListener("animationend",v),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",v),t.removeEventListener("animationend",v)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:i.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function V(e){return(e==null?void 0:e.animationName)||"none"}function $t(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var re=0;function Vt(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ce()),document.body.insertAdjacentElement("beforeend",e[1]??Ce()),re++,()=>{re===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),re--}},[])}function Ce(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var x=function(){return x=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},x.apply(this,arguments)};function Fe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Kt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var H="right-scroll-bar-position",z="width-before-scroll-bar",Gt="with-scroll-bars-hidden",Xt="--removed-body-scroll-bar-size";function oe(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Yt(e,t){var n=i.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Ht=typeof window<"u"?i.useLayoutEffect:i.useEffect,Se=new WeakMap;function zt(e,t){var n=Yt(null,function(r){return e.forEach(function(o){return oe(o,r)})});return Ht(function(){var r=Se.get(n);if(r){var o=new Set(r),a=new Set(e),c=n.current;o.forEach(function(s){a.has(s)||oe(s,null)}),a.forEach(function(s){o.has(s)||oe(s,c)})}Se.set(n,e)},[e]),n}function Zt(e){return e}function qt(e,t){t===void 0&&(t=Zt);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var c=t(a,r);return n.push(c),function(){n=n.filter(function(s){return s!==c})}},assignSyncMedium:function(a){for(r=!0;n.length;){var c=n;n=[],c.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){r=!0;var c=[];if(n.length){var s=n;n=[],s.forEach(a),c=n}var d=function(){var f=c;c=[],f.forEach(a)},u=function(){return Promise.resolve().then(d)};u(),n={push:function(f){c.push(f),u()},filter:function(f){return c=c.filter(f),n}}}};return o}function Qt(e){e===void 0&&(e={});var t=qt(null);return t.options=x({async:!0,ssr:!1},e),t}var ke=function(e){var t=e.sideCar,n=Fe(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return i.createElement(r,x({},n))};ke.isSideCarExport=!0;function Jt(e,t){return e.useMedium(t),ke}var je=Qt(),ae=function(){},Q=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.useState({onScrollCapture:ae,onWheelCapture:ae,onTouchMoveCapture:ae}),o=r[0],a=r[1],c=e.forwardProps,s=e.children,d=e.className,u=e.removeScrollBar,f=e.enabled,v=e.shards,m=e.sideCar,g=e.noRelative,w=e.noIsolation,l=e.inert,p=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,S=Fe(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=m,N=zt([n,t]),E=x(x({},S),o);return i.createElement(i.Fragment,null,f&&i.createElement(R,{sideCar:je,removeScrollBar:u,shards:v,noRelative:g,noIsolation:w,inert:l,setCallbacks:a,allowPinchZoom:!!p,lockRef:n,gapMode:C}),c?i.cloneElement(i.Children.only(s),x(x({},E),{ref:N})):i.createElement(b,x({},E,{className:d,ref:N}),s))});Q.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Q.classNames={fullWidth:z,zeroRight:H};var en=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=en();return t&&e.setAttribute("nonce",t),e}function nn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var on=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tn())&&(nn(t,n),rn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},an=function(){var e=on();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},We=function(){var e=an(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},sn={left:0,top:0,right:0,gap:0},ie=function(e){return parseInt(e||"",10)||0},cn=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ie(n),ie(r),ie(o)]},un=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return sn;var t=cn(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ln=We(),j="data-scroll-locked",dn=function(e,t,n,r){var o=e.left,a=e.top,c=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
1
|
+
import{r as i,j as h,h as at,R as xe,i as it,n as st}from"./index-Doq8HO3X.js";function me(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function De(...e){return t=>{let n=!1;const r=e.map(o=>{const a=me(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():me(e[o],null)}}}}function I(...e){return i.useCallback(De(...e),e)}function Oe(e){const t=ct(e),n=i.forwardRef((r,o)=>{const{children:a,...c}=r,s=i.Children.toArray(a),d=s.find(lt);if(d){const u=d.props.children,f=s.map(v=>v===d?i.Children.count(u)>1?i.Children.only(null):i.isValidElement(u)?u.props.children:null:v);return h.jsx(t,{...c,ref:o,children:i.isValidElement(u)?i.cloneElement(u,void 0,f):null})}return h.jsx(t,{...c,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function ct(e){const t=i.forwardRef((n,r)=>{const{children:o,...a}=n;if(i.isValidElement(o)){const c=ft(o),s=dt(a,o.props);return o.type!==i.Fragment&&(s.ref=r?De(r,c):c),i.cloneElement(o,s)}return i.Children.count(o)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ut=Symbol("radix.slottable");function lt(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ut}function dt(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...s)=>{const d=a(...s);return o(...s),d}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function ft(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var vt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],D=vt.reduce((e,t)=>{const n=Oe(`Primitive.${t}`),r=i.forwardRef((o,a)=>{const{asChild:c,...s}=o,d=c?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),h.jsx(d,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mt(e,t){e&&at.flushSync(()=>e.dispatchEvent(t))}function ht(e,t){const n=i.createContext(t),r=a=>{const{children:c,...s}=a,d=i.useMemo(()=>s,Object.values(s));return h.jsx(n.Provider,{value:d,children:c})};r.displayName=e+"Provider";function o(a){const c=i.useContext(n);if(c)return c;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function pt(e,t=[]){let n=[];function r(a,c){const s=i.createContext(c),d=n.length;n=[...n,c];const u=v=>{var y;const{scope:m,children:g,...w}=v,l=((y=m==null?void 0:m[e])==null?void 0:y[d])||s,p=i.useMemo(()=>w,Object.values(w));return h.jsx(l.Provider,{value:p,children:g})};u.displayName=a+"Provider";function f(v,m){var l;const g=((l=m==null?void 0:m[e])==null?void 0:l[d])||s,w=i.useContext(g);if(w)return w;if(c!==void 0)return c;throw new Error(`\`${v}\` must be used within \`${a}\``)}return[u,f]}const o=()=>{const a=n.map(c=>i.createContext(c));return function(s){const d=(s==null?void 0:s[e])||a;return i.useMemo(()=>({[`__scope${e}`]:{...s,[e]:d}}),[s,d])}};return o.scopeName=e,[r,gt(o,...t)]}function gt(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const c=r.reduce((s,{useScope:d,scopeName:u})=>{const v=d(a)[`__scope${u}`];return{...s,...v}},{});return i.useMemo(()=>({[`__scope${t.scopeName}`]:c}),[c])}};return n.scopeName=t.scopeName,n}function B(e){const t=i.useRef(e);return i.useEffect(()=>{t.current=e}),i.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var U=globalThis!=null&&globalThis.document?i.useLayoutEffect:()=>{};function A(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function yt(e,t=globalThis==null?void 0:globalThis.document){const n=B(e);i.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var Et="DismissableLayer",ce="dismissableLayer.update",bt="dismissableLayer.pointerDownOutside",Ct="dismissableLayer.focusOutside",he,Ae=i.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Te=i.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:c,onDismiss:s,...d}=e,u=i.useContext(Ae),[f,v]=i.useState(null),m=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=i.useState({}),w=I(t,E=>v(E)),l=Array.from(u.layers),[p]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=l.indexOf(p),b=f?l.indexOf(f):-1,C=u.layersWithOutsidePointerEventsDisabled.size>0,S=b>=y,R=Rt(E=>{const T=E.target,L=[...u.branches].some(W=>W.contains(T));!S||L||(o==null||o(E),c==null||c(E),E.defaultPrevented||s==null||s())},m),N=Nt(E=>{const T=E.target;[...u.branches].some(W=>W.contains(T))||(a==null||a(E),c==null||c(E),E.defaultPrevented||s==null||s())},m);return yt(E=>{b===u.layers.size-1&&(r==null||r(E),!E.defaultPrevented&&s&&(E.preventDefault(),s()))},m),i.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(he=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),pe(),()=>{n&&u.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=he)}},[f,m,n,u]),i.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),pe())},[f,u]),i.useEffect(()=>{const E=()=>g({});return document.addEventListener(ce,E),()=>document.removeEventListener(ce,E)},[]),h.jsx(D.div,{...d,ref:w,style:{pointerEvents:C?S?"auto":"none":void 0,...e.style},onFocusCapture:A(e.onFocusCapture,N.onFocusCapture),onBlurCapture:A(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:A(e.onPointerDownCapture,R.onPointerDownCapture)})});Te.displayName=Et;var St="DismissableLayerBranch",wt=i.forwardRef((e,t)=>{const n=i.useContext(Ae),r=i.useRef(null),o=I(t,r);return i.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),h.jsx(D.div,{...e,ref:o})});wt.displayName=St;function Rt(e,t=globalThis==null?void 0:globalThis.document){const n=B(e),r=i.useRef(!1),o=i.useRef(()=>{});return i.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let d=function(){Me(bt,n,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);r.current=!1},c=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(c),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function Nt(e,t=globalThis==null?void 0:globalThis.document){const n=B(e),r=i.useRef(!1);return i.useEffect(()=>{const o=a=>{a.target&&!r.current&&Me(Ct,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function pe(){const e=new CustomEvent(ce);document.dispatchEvent(e)}function Me(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?mt(o,a):o.dispatchEvent(a)}var Pt=xe[" useId ".trim().toString()]||(()=>{}),xt=0;function ee(e){const[t,n]=i.useState(Pt());return U(()=>{n(r=>r??String(xt++))},[e]),e||(t?`radix-${t}`:"")}var Dt=xe[" useInsertionEffect ".trim().toString()]||U;function Ot({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,c]=At({defaultProp:t,onChange:n}),s=e!==void 0,d=s?e:o;{const f=i.useRef(e!==void 0);i.useEffect(()=>{const v=f.current;v!==s&&console.warn(`${r} is changing from ${v?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),f.current=s},[s,r])}const u=i.useCallback(f=>{var v;if(s){const m=Tt(f)?f(e):f;m!==e&&((v=c.current)==null||v.call(c,m))}else a(f)},[s,e,a,c]);return[d,u]}function At({defaultProp:e,onChange:t}){const[n,r]=i.useState(e),o=i.useRef(n),a=i.useRef(t);return Dt(()=>{a.current=t},[t]),i.useEffect(()=>{var c;o.current!==n&&((c=a.current)==null||c.call(a,n),o.current=n)},[n,o]),[n,r,a]}function Tt(e){return typeof e=="function"}var te="focusScope.autoFocusOnMount",ne="focusScope.autoFocusOnUnmount",ge={bubbles:!1,cancelable:!0},Mt="FocusScope",Ie=i.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...c}=e,[s,d]=i.useState(null),u=B(o),f=B(a),v=i.useRef(null),m=I(t,l=>d(l)),g=i.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;i.useEffect(()=>{if(r){let l=function(C){if(g.paused||!s)return;const S=C.target;s.contains(S)?v.current=S:O(v.current,{select:!0})},p=function(C){if(g.paused||!s)return;const S=C.relatedTarget;S!==null&&(s.contains(S)||O(v.current,{select:!0}))},y=function(C){if(document.activeElement===document.body)for(const R of C)R.removedNodes.length>0&&O(s)};document.addEventListener("focusin",l),document.addEventListener("focusout",p);const b=new MutationObserver(y);return s&&b.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",l),document.removeEventListener("focusout",p),b.disconnect()}}},[r,s,g.paused]),i.useEffect(()=>{if(s){Ee.add(g);const l=document.activeElement;if(!s.contains(l)){const y=new CustomEvent(te,ge);s.addEventListener(te,u),s.dispatchEvent(y),y.defaultPrevented||(It(jt(Le(s)),{select:!0}),document.activeElement===l&&O(s))}return()=>{s.removeEventListener(te,u),setTimeout(()=>{const y=new CustomEvent(ne,ge);s.addEventListener(ne,f),s.dispatchEvent(y),y.defaultPrevented||O(l??document.body,{select:!0}),s.removeEventListener(ne,f),Ee.remove(g)},0)}}},[s,u,f,g]);const w=i.useCallback(l=>{if(!n&&!r||g.paused)return;const p=l.key==="Tab"&&!l.altKey&&!l.ctrlKey&&!l.metaKey,y=document.activeElement;if(p&&y){const b=l.currentTarget,[C,S]=Lt(b);C&&S?!l.shiftKey&&y===S?(l.preventDefault(),n&&O(C,{select:!0})):l.shiftKey&&y===C&&(l.preventDefault(),n&&O(S,{select:!0})):y===b&&l.preventDefault()}},[n,r,g.paused]);return h.jsx(D.div,{tabIndex:-1,...c,ref:m,onKeyDown:w})});Ie.displayName=Mt;function It(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(O(r,{select:t}),document.activeElement!==n)return}function Lt(e){const t=Le(e),n=ye(t,e),r=ye(t.reverse(),e);return[n,r]}function Le(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function ye(e,t){for(const n of e)if(!_t(n,{upTo:t}))return n}function _t(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Ft(e){return e instanceof HTMLInputElement&&"select"in e}function O(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Ft(e)&&t&&e.select()}}var Ee=kt();function kt(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=be(e,t),e.unshift(t)},remove(t){var n;e=be(e,t),(n=e[0])==null||n.resume()}}}function be(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function jt(e){return e.filter(t=>t.tagName!=="A")}var Wt="Portal",_e=i.forwardRef((e,t)=>{var s;const{container:n,...r}=e,[o,a]=i.useState(!1);U(()=>a(!0),[]);const c=n||o&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return c?it.createPortal(h.jsx(D.div,{...r,ref:t}),c):null});_e.displayName=Wt;function Bt(e,t){return i.useReducer((n,r)=>t[n][r]??n,e)}var q=e=>{const{present:t,children:n}=e,r=Ut(t),o=typeof n=="function"?n({present:r.isPresent}):i.Children.only(n),a=I(r.ref,$t(o));return typeof n=="function"||r.isPresent?i.cloneElement(o,{ref:a}):null};q.displayName="Presence";function Ut(e){const[t,n]=i.useState(),r=i.useRef(null),o=i.useRef(e),a=i.useRef("none"),c=e?"mounted":"unmounted",[s,d]=Bt(c,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return i.useEffect(()=>{const u=V(r.current);a.current=s==="mounted"?u:"none"},[s]),U(()=>{const u=r.current,f=o.current;if(f!==e){const m=a.current,g=V(u);e?d("MOUNT"):g==="none"||(u==null?void 0:u.display)==="none"?d("UNMOUNT"):d(f&&m!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),U(()=>{if(t){let u;const f=t.ownerDocument.defaultView??window,v=g=>{const l=V(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&l&&(d("ANIMATION_END"),!o.current)){const p=t.style.animationFillMode;t.style.animationFillMode="forwards",u=f.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=p)})}},m=g=>{g.target===t&&(a.current=V(r.current))};return t.addEventListener("animationstart",m),t.addEventListener("animationcancel",v),t.addEventListener("animationend",v),()=>{f.clearTimeout(u),t.removeEventListener("animationstart",m),t.removeEventListener("animationcancel",v),t.removeEventListener("animationend",v)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:i.useCallback(u=>{r.current=u?getComputedStyle(u):null,n(u)},[])}}function V(e){return(e==null?void 0:e.animationName)||"none"}function $t(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var re=0;function Vt(){i.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Ce()),document.body.insertAdjacentElement("beforeend",e[1]??Ce()),re++,()=>{re===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),re--}},[])}function Ce(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var x=function(){return x=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},x.apply(this,arguments)};function Fe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Kt(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var H="right-scroll-bar-position",z="width-before-scroll-bar",Gt="with-scroll-bars-hidden",Xt="--removed-body-scroll-bar-size";function oe(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Yt(e,t){var n=i.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var Ht=typeof window<"u"?i.useLayoutEffect:i.useEffect,Se=new WeakMap;function zt(e,t){var n=Yt(null,function(r){return e.forEach(function(o){return oe(o,r)})});return Ht(function(){var r=Se.get(n);if(r){var o=new Set(r),a=new Set(e),c=n.current;o.forEach(function(s){a.has(s)||oe(s,null)}),a.forEach(function(s){o.has(s)||oe(s,c)})}Se.set(n,e)},[e]),n}function Zt(e){return e}function qt(e,t){t===void 0&&(t=Zt);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var c=t(a,r);return n.push(c),function(){n=n.filter(function(s){return s!==c})}},assignSyncMedium:function(a){for(r=!0;n.length;){var c=n;n=[],c.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){r=!0;var c=[];if(n.length){var s=n;n=[],s.forEach(a),c=n}var d=function(){var f=c;c=[],f.forEach(a)},u=function(){return Promise.resolve().then(d)};u(),n={push:function(f){c.push(f),u()},filter:function(f){return c=c.filter(f),n}}}};return o}function Qt(e){e===void 0&&(e={});var t=qt(null);return t.options=x({async:!0,ssr:!1},e),t}var ke=function(e){var t=e.sideCar,n=Fe(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return i.createElement(r,x({},n))};ke.isSideCarExport=!0;function Jt(e,t){return e.useMedium(t),ke}var je=Qt(),ae=function(){},Q=i.forwardRef(function(e,t){var n=i.useRef(null),r=i.useState({onScrollCapture:ae,onWheelCapture:ae,onTouchMoveCapture:ae}),o=r[0],a=r[1],c=e.forwardProps,s=e.children,d=e.className,u=e.removeScrollBar,f=e.enabled,v=e.shards,m=e.sideCar,g=e.noRelative,w=e.noIsolation,l=e.inert,p=e.allowPinchZoom,y=e.as,b=y===void 0?"div":y,C=e.gapMode,S=Fe(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),R=m,N=zt([n,t]),E=x(x({},S),o);return i.createElement(i.Fragment,null,f&&i.createElement(R,{sideCar:je,removeScrollBar:u,shards:v,noRelative:g,noIsolation:w,inert:l,setCallbacks:a,allowPinchZoom:!!p,lockRef:n,gapMode:C}),c?i.cloneElement(i.Children.only(s),x(x({},E),{ref:N})):i.createElement(b,x({},E,{className:d,ref:N}),s))});Q.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Q.classNames={fullWidth:z,zeroRight:H};var en=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function tn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=en();return t&&e.setAttribute("nonce",t),e}function nn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var on=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tn())&&(nn(t,n),rn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},an=function(){var e=on();return function(t,n){i.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},We=function(){var e=an(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},sn={left:0,top:0,right:0,gap:0},ie=function(e){return parseInt(e||"",10)||0},cn=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ie(n),ie(r),ie(o)]},un=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return sn;var t=cn(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ln=We(),j="data-scroll-locked",dn=function(e,t,n,r){var o=e.left,a=e.top,c=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
2
2
|
.`.concat(Gt,` {
|
|
3
3
|
overflow: hidden `).concat(r,`;
|
|
4
4
|
padding-right: `).concat(s,"px ").concat(r,`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./index-
|
|
1
|
+
import{j as t}from"./index-Doq8HO3X.js";function r({segments:a,value:n,onChange:l,size:s="md"}){return t.jsx("div",{className:`seg seg-${s}`,role:"tablist",children:a.map(e=>t.jsxs("button",{role:"tab","aria-selected":e.value===n,className:`seg-btn${e.value===n?" seg-btn-active":""}`,onClick:()=>l(e.value),type:"button",children:[t.jsx("span",{children:e.label}),typeof e.count=="number"&&t.jsx("span",{className:"seg-count",children:e.count})]},e.value))})}export{r as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./index-
|
|
1
|
+
import{j as t}from"./index-Doq8HO3X.js";const x=({className:s,...a})=>t.jsx("table",{className:`tbl${s?" "+s:""}`,...a}),j=s=>t.jsx("thead",{...s}),c=s=>t.jsx("tbody",{...s}),e=s=>t.jsx("tr",{...s}),n=s=>t.jsx("th",{...s}),T=s=>t.jsx("td",{...s});export{x as T,j as a,e as b,n as c,c as d,T as e};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as p,m as E,r as d,X as m,j as e,s as N,v as k,y as z}from"./index-
|
|
1
|
+
import{g as p,m as E,r as d,X as m,j as e,s as N,v as k,y as z}from"./index-Doq8HO3X.js";/* empty css */import{S as T,A as I}from"./SettingCard-BCRyZfOg.js";import{P as F}from"./page-header-Qk9pGEaH.js";import{L as S}from"./lock-pCxyVW83.js";import{C as b}from"./circle-check-BR3SeBx6.js";import{A as U}from"./activity-C9XYmP_g.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as ne,r as a,j as e,v as F,K as $,p as re}from"./index-DM2pqF7I.js";/* empty css */import{a as z}from"./time-B8FIgwPE.js";import{T as le,a as oe,b as L,c as l,d as ce,e as o}from"./Table-CkcGkMjT.js";import{F as m}from"./FieldGroup-BdvaWOEM.js";import{P as O}from"./page-header-2famIGMK.js";import{M as H}from"./Modal-CeNm3NM-.js";import{S as de}from"./shield-alert-B_LM0Wik.js";import{P as g}from"./plus-C4rQY5cd.js";import{T as me}from"./trash-2-DkY5zvbC.js";import{C as pe}from"./check-DASytmhL.js";import{C as he}from"./copy-B3wI9WZm.js";const M=["read","sessions","devices","admin"],B={"7d":"7 days","30d":"30 days","90d":"90 days","1y":"1 year",never:"No expiry"},xe={"7d":7,"30d":30,"90d":90,"1y":365};function U(i){return i==="never"?null:new Date(Date.now()+xe[i]*864e5).toISOString()}function W(i){if(!i)return"Never";const n=Date.now()-new Date(i).getTime();return n<6e4?"Just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}const _e=()=>{const{toast:i}=ne(),[n,v]=a.useState([]),[b,Y]=a.useState([]),[q,w]=a.useState(!0),[J,N]=a.useState(!1),[X,d]=a.useState(!1),[r,y]=a.useState(null),[k,C]=a.useState(null),[S,T]=a.useState(!1),[p,_]=a.useState(""),[j,A]=a.useState({read:!0,sessions:!0,devices:!1,admin:!1}),[I,R]=a.useState(300),[P,E]=a.useState(""),[h,K]=a.useState("30d"),[x,D]=a.useState(!1),G=s=>{var t;return s?((t=b.find(c=>c.id===s))==null?void 0:t.name)||s.slice(0,8):"Shared"},f=async()=>{w(!0);try{const[s,t]=await Promise.all([fetch("/xenon/api/apikeys",{credentials:"include"}),fetch("/xenon/api/teams",{credentials:"include"})]);if(s.status===403){N(!0),v([]);return}if(!s.ok)throw new Error(`HTTP ${s.status}`);v(await s.json()),t.ok&&Y(await t.json()),N(!1)}catch(s){i(`Failed to load API keys: ${s.message}`,"error")}finally{w(!1)}};a.useEffect(()=>{f()},[]);const Q=()=>{_(""),A({read:!0,sessions:!0,devices:!1,admin:!1}),R(300),E(""),K("30d")},V=async()=>{const s=M.filter(t=>j[t]);if(!p.trim()){i("Key name is required","error");return}if(s.length===0){i("Select at least one scope","error");return}D(!0);try{const t=await fetch("/xenon/api/apikeys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim(),scopes:s,rateLimit:I,teamId:P||null,expiresAt:U(h)})});if(!t.ok)throw new Error(`HTTP ${t.status}`);const c=await t.json();d(!1),Q(),y({name:p.trim(),raw:c.key}),await f()}catch(t){i(`Create failed: ${t.message}`,"error")}finally{D(!1)}},Z=async s=>{C(s);try{const t=await fetch(`/xenon/api/apikeys/${s}`,{method:"DELETE",credentials:"include"});if(!t.ok)throw new Error(`HTTP ${t.status}`);i("Key revoked","success"),await f()}catch(t){i(`Revoke failed: ${t.message}`,"error")}finally{C(null)}},ee=async s=>{try{await navigator.clipboard.writeText(s),T(!0),setTimeout(()=>T(!1),1500)}catch{i("Copy failed — select the text manually","error")}};if(q)return e.jsxs("div",{className:"settings-loading",children:[e.jsx(F,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading API keys…"})]});if(J)return e.jsx("div",{className:"settings-container",children:e.jsx(O,{icon:de,title:"API Keys",subtitle:e.jsxs(e.Fragment,{children:["Your key lacks the ",e.jsx("code",{children:"admin"})," scope. Ask an administrator to issue an admin key so you can manage access for other users."]})})});const se=n.length,te=n.filter(s=>s.scopes.includes("admin")).length,ae=n.filter(s=>s.lastUsedAt&&Date.now()-new Date(s.lastUsedAt).getTime()<864e5).length;return e.jsxs("div",{className:"settings-container",children:[e.jsx(O,{icon:$,title:"API Keys",subtitle:e.jsxs(e.Fragment,{children:["Issue scoped credentials for humans (dashboard login) and machines (CI, WebDriver clients via ",e.jsx("code",{children:"xenon:accessKey"}),"). Keys are shown only once at creation — copy the value before closing the dialog."]}),action:e.jsxs("button",{type:"button",className:"page-header-action",onClick:()=>d(!0),children:[e.jsx(g,{size:16}),e.jsx("span",{children:"Create new key"})]})}),e.jsxs("div",{className:"settings-content",children:[n.length>0&&e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:se}),e.jsx("div",{className:"stat-strip__label",children:"Total keys"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value stat-strip__value--accent",children:te}),e.jsx("div",{className:"stat-strip__label",children:"Admin scope"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:ae}),e.jsx("div",{className:"stat-strip__label",children:"Active in last 24h"})]})]}),n.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state__icon",children:e.jsx($,{size:28})}),e.jsx("h3",{className:"empty-state__title",children:"No API keys yet"}),e.jsx("p",{className:"empty-state__copy",children:"Issue your first key to authenticate WebDriver clients or CI pipelines. Keys are shown only once at creation — copy the value before closing the dialog."}),e.jsxs("button",{type:"button",className:"page-header-action empty-state__action",onClick:()=>d(!0),children:[e.jsx(g,{size:16}),e.jsx("span",{children:"Create your first key"})]})]}):e.jsx("div",{className:"data-card",children:e.jsxs(le,{children:[e.jsx(oe,{children:e.jsxs(L,{children:[e.jsx(l,{children:"Name"}),e.jsx(l,{children:"Team"}),e.jsx(l,{children:"Scopes"}),e.jsx(l,{children:"Rate limit"}),e.jsx(l,{children:"Last used"}),e.jsx(l,{children:"Created"}),e.jsx(l,{children:"Expires"}),e.jsx(l,{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx(ce,{children:n.map(s=>e.jsxs(L,{children:[e.jsxs(o,{children:[e.jsx("strong",{children:s.name}),e.jsx("div",{className:"row-meta-mono",children:s.id.slice(0,8)})]}),e.jsx(o,{children:e.jsx("span",{className:`pill-chip ${s.teamId?"pill-chip--team":"pill-chip--shared"}`,children:G(s.teamId)})}),e.jsx(o,{children:e.jsx("div",{className:"scope-chips",children:s.scopes.split(",").map(t=>{const c=t.trim(),ie=c==="admin";return e.jsx("span",{className:`pill-chip ${ie?"pill-chip--admin":"pill-chip--scope"}`,children:c},t)})})}),e.jsxs(o,{className:"row-mono",children:[s.rateLimit,"/min"]}),e.jsx(o,{className:"row-mono",children:W(s.lastUsedAt)}),e.jsx(o,{className:"row-mono",children:W(s.createdAt)}),e.jsx(o,{className:"row-mono",children:s.expiresAt?new Date(s.expiresAt).getTime()<=Date.now()?e.jsx("span",{style:{color:"var(--red)"},children:"expired"}):z(s.expiresAt):"Never"}),e.jsx(o,{style:{textAlign:"right"},children:e.jsxs("button",{type:"button",className:"row-action row-action--danger",disabled:k===s.id,onClick:()=>{window.confirm(`Revoke "${s.name}"? Any client using this key will immediately fail.`)&&Z(s.id)},children:[e.jsx(me,{size:13}),k===s.id?"Revoking…":"Revoke"]})})]},s.id))})]})})]}),e.jsx(H,{open:X,title:"Create API key",width:520,onClose:()=>d(!1),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"reset-btn",onClick:()=>d(!1),disabled:x,children:"Cancel"}),e.jsxs("button",{className:"save-btn",onClick:V,disabled:x,children:[x?e.jsx(F,{className:"animate-spin",size:18}):e.jsx(g,{size:18}),x?"Creating…":"Create key"]})]}),children:e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(m,{label:"Name",htmlFor:"apikey-name",children:e.jsx("input",{id:"apikey-name",type:"text",value:p,onChange:s=>_(s.target.value),placeholder:"alice-laptop, ci-main, etc.",style:u,autoFocus:!0})}),e.jsx(m,{label:"Scopes",description:e.jsxs(e.Fragment,{children:[e.jsx("code",{children:"admin"})," grants full access including API-key management."," ",e.jsx("code",{children:"sessions"})," is required for WebDriver ",e.jsx("code",{children:"xenon:accessKey"}),"."]}),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:M.map(s=>e.jsxs("label",{style:ue,children:[e.jsx("input",{type:"checkbox",checked:j[s],onChange:t=>A({...j,[s]:t.target.checked})}),e.jsx("span",{children:s})]},s))})}),e.jsx(m,{label:"Rate limit (requests/min)",htmlFor:"apikey-ratelimit",children:e.jsx("input",{id:"apikey-ratelimit",type:"number",min:10,step:10,value:I,onChange:s=>R(parseInt(s.target.value)||300),style:u})}),e.jsx(m,{label:"Default team",description:e.jsxs(e.Fragment,{children:["Keys without a team can only reach shared-pool devices. Admins can override at session time via ",e.jsx("code",{children:"xenon:team"}),"."]}),htmlFor:"apikey-team",children:e.jsxs("select",{id:"apikey-team",value:P,onChange:s=>E(s.target.value),style:u,children:[e.jsx("option",{value:"",children:"No team (shared pool only)"}),b.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})}),e.jsx(m,{label:"Expires after",description:h==="never"?"Key never expires. Rotate manually when needed.":`Key will stop working on ${z(U(h))}.`,htmlFor:"apikey-expiry",children:e.jsx("select",{id:"apikey-expiry",value:h,onChange:s=>K(s.target.value),style:u,children:Object.keys(B).map(s=>e.jsx("option",{value:s,children:B[s]},s))})})]})}),e.jsx(H,{open:!!r,title:r?`Key created: ${r.name}`:"",width:560,onClose:()=>y(null),closeOnOverlayClick:!1,footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"save-btn",onClick:()=>r&&ee(r.raw),disabled:!r,children:[S?e.jsx(pe,{size:18}):e.jsx(he,{size:18}),S?"Copied":"Copy to clipboard"]}),e.jsx("button",{className:"reset-btn",onClick:()=>y(null),children:"I've saved it"})]}),children:r&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{background:"var(--status-busy-bg)",border:"1px solid var(--status-busy-border)",borderRadius:6,padding:12,display:"flex",gap:8,alignItems:"flex-start"},children:[e.jsx(re,{size:18,style:{flexShrink:0,marginTop:2}}),e.jsxs("div",{children:[e.jsx("strong",{children:"This key will not be shown again."})," Copy it now and store it in your password manager, CI secret store, or client config."]})]}),e.jsx("div",{style:{fontFamily:"monospace",padding:12,background:"rgba(0,0,0,0.3)",borderRadius:6,wordBreak:"break-all",fontSize:"0.9em"},children:r.raw})]})})]})},u={width:"100%",padding:"8px 12px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"inherit",fontSize:"0.95em",boxSizing:"border-box"},ue={display:"flex",alignItems:"center",gap:6,padding:"6px 12px",background:"rgba(255,255,255,0.04)",borderRadius:6,cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em"};export{_e as ApiKeys};
|
|
1
|
+
import{m as ne,r as a,j as e,v as F,K as $,p as re}from"./index-Doq8HO3X.js";/* empty css */import{a as z}from"./time-B8FIgwPE.js";import{T as le,a as oe,b as L,c as l,d as ce,e as o}from"./Table-CEvMaA5P.js";import{F as m}from"./FieldGroup-DnJ8AU1V.js";import{P as O}from"./page-header-Qk9pGEaH.js";import{M as H}from"./Modal-QVER5CZo.js";import{S as de}from"./shield-alert-B6RlIJqv.js";import{P as g}from"./plus-DkzZBN8d.js";import{T as me}from"./trash-2-D-ONhY9W.js";import{C as pe}from"./check-CVbtgHOC.js";import{C as he}from"./copy-E317aAW3.js";const M=["read","sessions","devices","admin"],B={"7d":"7 days","30d":"30 days","90d":"90 days","1y":"1 year",never:"No expiry"},xe={"7d":7,"30d":30,"90d":90,"1y":365};function U(i){return i==="never"?null:new Date(Date.now()+xe[i]*864e5).toISOString()}function W(i){if(!i)return"Never";const n=Date.now()-new Date(i).getTime();return n<6e4?"Just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:`${Math.floor(n/864e5)}d ago`}const _e=()=>{const{toast:i}=ne(),[n,v]=a.useState([]),[b,Y]=a.useState([]),[q,w]=a.useState(!0),[J,N]=a.useState(!1),[X,d]=a.useState(!1),[r,y]=a.useState(null),[k,C]=a.useState(null),[S,T]=a.useState(!1),[p,_]=a.useState(""),[j,A]=a.useState({read:!0,sessions:!0,devices:!1,admin:!1}),[I,R]=a.useState(300),[P,E]=a.useState(""),[h,K]=a.useState("30d"),[x,D]=a.useState(!1),G=s=>{var t;return s?((t=b.find(c=>c.id===s))==null?void 0:t.name)||s.slice(0,8):"Shared"},f=async()=>{w(!0);try{const[s,t]=await Promise.all([fetch("/xenon/api/apikeys",{credentials:"include"}),fetch("/xenon/api/teams",{credentials:"include"})]);if(s.status===403){N(!0),v([]);return}if(!s.ok)throw new Error(`HTTP ${s.status}`);v(await s.json()),t.ok&&Y(await t.json()),N(!1)}catch(s){i(`Failed to load API keys: ${s.message}`,"error")}finally{w(!1)}};a.useEffect(()=>{f()},[]);const Q=()=>{_(""),A({read:!0,sessions:!0,devices:!1,admin:!1}),R(300),E(""),K("30d")},V=async()=>{const s=M.filter(t=>j[t]);if(!p.trim()){i("Key name is required","error");return}if(s.length===0){i("Select at least one scope","error");return}D(!0);try{const t=await fetch("/xenon/api/apikeys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim(),scopes:s,rateLimit:I,teamId:P||null,expiresAt:U(h)})});if(!t.ok)throw new Error(`HTTP ${t.status}`);const c=await t.json();d(!1),Q(),y({name:p.trim(),raw:c.key}),await f()}catch(t){i(`Create failed: ${t.message}`,"error")}finally{D(!1)}},Z=async s=>{C(s);try{const t=await fetch(`/xenon/api/apikeys/${s}`,{method:"DELETE",credentials:"include"});if(!t.ok)throw new Error(`HTTP ${t.status}`);i("Key revoked","success"),await f()}catch(t){i(`Revoke failed: ${t.message}`,"error")}finally{C(null)}},ee=async s=>{try{await navigator.clipboard.writeText(s),T(!0),setTimeout(()=>T(!1),1500)}catch{i("Copy failed — select the text manually","error")}};if(q)return e.jsxs("div",{className:"settings-loading",children:[e.jsx(F,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading API keys…"})]});if(J)return e.jsx("div",{className:"settings-container",children:e.jsx(O,{icon:de,title:"API Keys",subtitle:e.jsxs(e.Fragment,{children:["Your key lacks the ",e.jsx("code",{children:"admin"})," scope. Ask an administrator to issue an admin key so you can manage access for other users."]})})});const se=n.length,te=n.filter(s=>s.scopes.includes("admin")).length,ae=n.filter(s=>s.lastUsedAt&&Date.now()-new Date(s.lastUsedAt).getTime()<864e5).length;return e.jsxs("div",{className:"settings-container",children:[e.jsx(O,{icon:$,title:"API Keys",subtitle:e.jsxs(e.Fragment,{children:["Issue scoped credentials for humans (dashboard login) and machines (CI, WebDriver clients via ",e.jsx("code",{children:"xenon:accessKey"}),"). Keys are shown only once at creation — copy the value before closing the dialog."]}),action:e.jsxs("button",{type:"button",className:"page-header-action",onClick:()=>d(!0),children:[e.jsx(g,{size:16}),e.jsx("span",{children:"Create new key"})]})}),e.jsxs("div",{className:"settings-content",children:[n.length>0&&e.jsxs("div",{className:"stat-strip",children:[e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:se}),e.jsx("div",{className:"stat-strip__label",children:"Total keys"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value stat-strip__value--accent",children:te}),e.jsx("div",{className:"stat-strip__label",children:"Admin scope"})]}),e.jsxs("div",{className:"stat-strip__cell",children:[e.jsx("div",{className:"stat-strip__value",children:ae}),e.jsx("div",{className:"stat-strip__label",children:"Active in last 24h"})]})]}),n.length===0?e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-state__icon",children:e.jsx($,{size:28})}),e.jsx("h3",{className:"empty-state__title",children:"No API keys yet"}),e.jsx("p",{className:"empty-state__copy",children:"Issue your first key to authenticate WebDriver clients or CI pipelines. Keys are shown only once at creation — copy the value before closing the dialog."}),e.jsxs("button",{type:"button",className:"page-header-action empty-state__action",onClick:()=>d(!0),children:[e.jsx(g,{size:16}),e.jsx("span",{children:"Create your first key"})]})]}):e.jsx("div",{className:"data-card",children:e.jsxs(le,{children:[e.jsx(oe,{children:e.jsxs(L,{children:[e.jsx(l,{children:"Name"}),e.jsx(l,{children:"Team"}),e.jsx(l,{children:"Scopes"}),e.jsx(l,{children:"Rate limit"}),e.jsx(l,{children:"Last used"}),e.jsx(l,{children:"Created"}),e.jsx(l,{children:"Expires"}),e.jsx(l,{style:{textAlign:"right"},children:"Actions"})]})}),e.jsx(ce,{children:n.map(s=>e.jsxs(L,{children:[e.jsxs(o,{children:[e.jsx("strong",{children:s.name}),e.jsx("div",{className:"row-meta-mono",children:s.id.slice(0,8)})]}),e.jsx(o,{children:e.jsx("span",{className:`pill-chip ${s.teamId?"pill-chip--team":"pill-chip--shared"}`,children:G(s.teamId)})}),e.jsx(o,{children:e.jsx("div",{className:"scope-chips",children:s.scopes.split(",").map(t=>{const c=t.trim(),ie=c==="admin";return e.jsx("span",{className:`pill-chip ${ie?"pill-chip--admin":"pill-chip--scope"}`,children:c},t)})})}),e.jsxs(o,{className:"row-mono",children:[s.rateLimit,"/min"]}),e.jsx(o,{className:"row-mono",children:W(s.lastUsedAt)}),e.jsx(o,{className:"row-mono",children:W(s.createdAt)}),e.jsx(o,{className:"row-mono",children:s.expiresAt?new Date(s.expiresAt).getTime()<=Date.now()?e.jsx("span",{style:{color:"var(--red)"},children:"expired"}):z(s.expiresAt):"Never"}),e.jsx(o,{style:{textAlign:"right"},children:e.jsxs("button",{type:"button",className:"row-action row-action--danger",disabled:k===s.id,onClick:()=>{window.confirm(`Revoke "${s.name}"? Any client using this key will immediately fail.`)&&Z(s.id)},children:[e.jsx(me,{size:13}),k===s.id?"Revoking…":"Revoke"]})})]},s.id))})]})})]}),e.jsx(H,{open:X,title:"Create API key",width:520,onClose:()=>d(!1),footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"reset-btn",onClick:()=>d(!1),disabled:x,children:"Cancel"}),e.jsxs("button",{className:"save-btn",onClick:V,disabled:x,children:[x?e.jsx(F,{className:"animate-spin",size:18}):e.jsx(g,{size:18}),x?"Creating…":"Create key"]})]}),children:e.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[e.jsx(m,{label:"Name",htmlFor:"apikey-name",children:e.jsx("input",{id:"apikey-name",type:"text",value:p,onChange:s=>_(s.target.value),placeholder:"alice-laptop, ci-main, etc.",style:u,autoFocus:!0})}),e.jsx(m,{label:"Scopes",description:e.jsxs(e.Fragment,{children:[e.jsx("code",{children:"admin"})," grants full access including API-key management."," ",e.jsx("code",{children:"sessions"})," is required for WebDriver ",e.jsx("code",{children:"xenon:accessKey"}),"."]}),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:M.map(s=>e.jsxs("label",{style:ue,children:[e.jsx("input",{type:"checkbox",checked:j[s],onChange:t=>A({...j,[s]:t.target.checked})}),e.jsx("span",{children:s})]},s))})}),e.jsx(m,{label:"Rate limit (requests/min)",htmlFor:"apikey-ratelimit",children:e.jsx("input",{id:"apikey-ratelimit",type:"number",min:10,step:10,value:I,onChange:s=>R(parseInt(s.target.value)||300),style:u})}),e.jsx(m,{label:"Default team",description:e.jsxs(e.Fragment,{children:["Keys without a team can only reach shared-pool devices. Admins can override at session time via ",e.jsx("code",{children:"xenon:team"}),"."]}),htmlFor:"apikey-team",children:e.jsxs("select",{id:"apikey-team",value:P,onChange:s=>E(s.target.value),style:u,children:[e.jsx("option",{value:"",children:"No team (shared pool only)"}),b.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))]})}),e.jsx(m,{label:"Expires after",description:h==="never"?"Key never expires. Rotate manually when needed.":`Key will stop working on ${z(U(h))}.`,htmlFor:"apikey-expiry",children:e.jsx("select",{id:"apikey-expiry",value:h,onChange:s=>K(s.target.value),style:u,children:Object.keys(B).map(s=>e.jsx("option",{value:s,children:B[s]},s))})})]})}),e.jsx(H,{open:!!r,title:r?`Key created: ${r.name}`:"",width:560,onClose:()=>y(null),closeOnOverlayClick:!1,footer:e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"save-btn",onClick:()=>r&&ee(r.raw),disabled:!r,children:[S?e.jsx(pe,{size:18}):e.jsx(he,{size:18}),S?"Copied":"Copy to clipboard"]}),e.jsx("button",{className:"reset-btn",onClick:()=>y(null),children:"I've saved it"})]}),children:r&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{background:"var(--status-busy-bg)",border:"1px solid var(--status-busy-border)",borderRadius:6,padding:12,display:"flex",gap:8,alignItems:"flex-start"},children:[e.jsx(re,{size:18,style:{flexShrink:0,marginTop:2}}),e.jsxs("div",{children:[e.jsx("strong",{children:"This key will not be shown again."})," Copy it now and store it in your password manager, CI secret store, or client config."]})]}),e.jsx("div",{style:{fontFamily:"monospace",padding:12,background:"rgba(0,0,0,0.3)",borderRadius:6,wordBreak:"break-all",fontSize:"0.9em"},children:r.raw})]})})]})},u={width:"100%",padding:"8px 12px",background:"rgba(0,0,0,0.3)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:6,color:"inherit",fontSize:"0.95em",boxSizing:"border-box"},ue={display:"flex",alignItems:"center",gap:6,padding:"6px 12px",background:"rgba(255,255,255,0.04)",borderRadius:6,cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em"};export{_e as ApiKeys};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as x,j as e,m as q,r,X as l,S,o as W,v as H,n as X}from"./index-
|
|
1
|
+
import{g as x,j as e,m as q,r,X as l,S,o as W,v as H,n as X}from"./index-Doq8HO3X.js";import{f as K}from"./time-B8FIgwPE.js";import{c as Z,a as J,P as Q,B as D,U as ee,T as se}from"./button-30pnTauc.js";import{P as ae}from"./page-header-Qk9pGEaH.js";import{C as te}from"./check-CVbtgHOC.js";import{C as re}from"./copy-E317aAW3.js";import{Z as ie}from"./zap-C8F21kM1.js";import{D as ne}from"./download-Blklg-SX.js";import{T as ce}from"./trash-2-D-ONhY9W.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./index-
|
|
1
|
+
import{j as e}from"./index-Doq8HO3X.js";function i({children:s}){return e.jsxs("div",{className:"min-h-screen w-full grid grid-cols-1 md:grid-cols-2 bg-[var(--bg)] text-[var(--text)]",children:[e.jsxs("aside",{className:"relative hidden md:flex flex-col justify-center px-12 overflow-hidden bg-gradient-to-br from-[#0a0e1a] via-[#131a2e] to-[#1a2548]",children:[e.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:"radial-gradient(circle at 80% 20%, rgba(99,102,241,0.18), transparent 60%)"}}),e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:"/xenon/logo.svg",alt:"Xenon Logo",className:"h-8 w-auto object-contain mb-4"}),e.jsx("div",{className:"text-3xl font-semibold tracking-tight mb-2",children:"Xenon"}),e.jsx("p",{className:"text-sm text-[var(--text-dim)] max-w-sm leading-relaxed mb-8",children:"Enterprise-grade Appium device lab orchestration with AI self-healing, live device streaming, and proof-pack recording."}),e.jsx("div",{className:"flex flex-wrap gap-2 max-w-sm",children:["Self-healing tests","Live device streaming","Hub-node scaling","Proof-pack recording"].map(a=>e.jsx("span",{className:"text-[11px] px-2.5 py-1 rounded-full bg-white/5 border border-white/10 text-[var(--text-muted)]",children:a},a))})]})]}),e.jsx("main",{className:"flex items-center justify-center",children:e.jsx("div",{className:"w-full max-w-sm px-6",children:s})})]})}export{i as A};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{g as
|
|
1
|
+
import{g as O,j as e,o as L,k as y,T as _,S as z,r as f,u as G,c as H,m as X,M as Q,X as V}from"./index-Doq8HO3X.js";import{f as E,s as R,b as $,a as A,d as q,p as J,o as K,S as W,h as Y,c as Z,e as T,u as ee}from"./status-pill-outline-Df9QaRNJ.js";import{A as te}from"./activity-C9XYmP_g.js";import{C as se}from"./circle-x-BISG5iH-.js";import{C as re}from"./circle-check-BR3SeBx6.js";import{C as ae}from"./clock-BiZmZWEe.js";import{D as ne}from"./download-Blklg-SX.js";import{C as le}from"./chevron-right-BpHMOuL1.js";import{T as oe,M as ie}from"./tablet-1xXXhpqC.js";import{P as de}from"./page-header-Qk9pGEaH.js";import"./useSocket-D9iZtppJ.js";import"./time-B8FIgwPE.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const de=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],ce=F("refresh-ccw",de),xe={neutral:"bg-[var(--surface-2)] text-[var(--text-muted)] border-[var(--border)]",green:"bg-[var(--green)]/15 text-[var(--green)] border-[var(--green)]/30",red:"bg-[var(--red)]/15 text-[var(--red)] border-[var(--red)]/30",amber:"bg-[var(--amber)]/15 text-[var(--amber)] border-[var(--amber)]/30"},C=({value:t,tone:a="neutral",label:r})=>e.jsx("span",{title:r,"aria-label":r,className:`inline-flex items-center justify-center min-w-[18px] h-[18px] px-1.5 rounded-full border text-[10px] font-mono font-medium ${xe[a]}`,children:t}),ue={passed:{Icon:se,label:"PASSED",tint:"text-[var(--green)]"},failed:{Icon:te,label:"FAILED",tint:"text-[var(--red)]"},running:{Icon:ee,label:"RUNNING",tint:"text-[var(--amber)]"}},S=({kind:t,value:a})=>{const{Icon:r,label:l,tint:d}=ue[t];return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1 py-2 rounded-md border border-[var(--border)] bg-[var(--bg)]",children:[e.jsx(r,{className:`h-3.5 w-3.5 ${d}`}),e.jsx("span",{className:`text-[9px] font-mono font-semibold tracking-wider ${d}`,children:l}),e.jsx("span",{className:"text-sm font-semibold text-[var(--text)] tabular-nums",children:a})]})},I={all:"All time","24h":"Last 24 hours","7d":"Last 7 days","30d":"Last 30 days"},me=({builds:t,selectedBuildId:a,onSelect:r,search:l,onSearchChange:d,timeFilter:c,onTimeFilterChange:u})=>{const o=t.filter(s=>{const n=(s.name??"")+" "+s.id;if(l&&!n.toLowerCase().includes(l.toLowerCase()))return!1;if(c!=="all"){const p={"24h":864e5,"7d":6048e5,"30d":2592e6},g=Date.parse(String(s.createdAt));if(!Number.isFinite(g)||Date.now()-g>p[c])return!1}return!0}),i=l.trim().length>0||c!=="all",h=o.reduce((s,n)=>(s.passed+=n.passedCount||0,s.failed+=n.failedCount||0,s.running+=n.runningCount||0,s),{passed:0,failed:0,running:0});return e.jsxs("aside",{className:"w-[280px] shrink-0 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col",children:[e.jsxs("div",{className:"p-3 space-y-2 border-b border-[var(--border)]",children:[e.jsxs("div",{className:"relative",children:[e.jsx(E,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--text-dim)]"}),e.jsx("input",{type:"text",value:l,onChange:s=>d(s.target.value),placeholder:"Find builds…",className:"w-full h-8 pl-8 pr-2 rounded-md bg-[var(--bg)] border border-[var(--border)] text-xs text-[var(--text)] placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--border-strong)]"})]}),e.jsx("select",{value:c,onChange:s=>u(s.target.value),className:"w-full h-8 px-2 rounded-md bg-[var(--bg)] border border-[var(--border)] text-xs text-[var(--text-muted)]",children:Object.keys(I).map(s=>e.jsx("option",{value:s,children:I[s]},s))})]}),e.jsxs("div",{className:"p-3 flex items-stretch gap-2 border-b border-[var(--border)]",children:[e.jsx(S,{kind:"passed",value:h.passed}),e.jsx(S,{kind:"failed",value:h.failed}),e.jsx(S,{kind:"running",value:h.running})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.length===0&&e.jsx("div",{className:"px-4 py-8 text-center text-xs text-[var(--text-dim)]",children:i?"No builds match.":"No builds yet — sessions will appear here after your first test run."}),o.map(s=>{const n=s.id===a;return e.jsxs("button",{type:"button",onClick:()=>r(s.id),className:`w-full text-left relative px-4 py-3 border-b border-[var(--border)] transition-colors ${n?"bg-[var(--surface-2)]":"hover:bg-[var(--surface-2)]/60"}`,children:[n&&e.jsx("span",{className:"absolute left-0 top-2 bottom-2 w-[3px] rounded-r bg-[var(--green)]"}),e.jsx("div",{className:"text-xs font-semibold text-[var(--text)] truncate",children:s.name||"Unnamed build"}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 font-mono text-[9px] text-[var(--text-dim)]",children:[e.jsx(re,{className:"h-3 w-3"}),R(s.createdAt)]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[s.passedCount>0&&e.jsx(C,{value:s.passedCount,tone:"green",label:`${s.passedCount} passed`}),s.failedCount>0&&e.jsx(C,{value:s.failedCount,tone:"red",label:`${s.failedCount} failed`}),s.runningCount>0&&e.jsx(C,{value:s.runningCount,tone:"amber",label:`${s.runningCount} running`}),s.sessionCount===0&&e.jsx("span",{className:"text-[10px] font-mono text-[var(--text-dim)]",children:"empty"})]}),e.jsx("div",{className:"mt-1 font-mono text-[9px] text-[var(--text-dim)] truncate",children:$(s.id,10,4)})]},s.id)})]})]})},pe={neutral:"bg-[var(--text-dim)]",green:"bg-[var(--green)]",red:"bg-[var(--red)]",amber:"bg-[var(--amber)]",blue:"bg-[var(--blue)]"},y=({label:t,count:a,active:r,onClick:l,tone:d="neutral",bullet:c=!0})=>e.jsxs("button",{type:"button",onClick:l,"aria-pressed":r,className:`inline-flex items-center gap-2 h-8 px-3 rounded-md border text-[11px] font-semibold uppercase tracking-wider transition-colors cursor-pointer ${r?"bg-[var(--surface-2)] border-[var(--border-strong)] text-[var(--text)]":"bg-transparent border-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-2)]/50"}`,children:[c&&d!=="neutral"&&e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${pe[d]}`}),e.jsx("span",{children:t}),typeof a=="number"&&e.jsx("span",{className:"font-mono text-[10px] text-[var(--text-dim)]",children:a})]}),he=({sessions:t,active:a,onChange:r,search:l,onSearchChange:d,totalMatching:c,totalUnfiltered:u})=>{const o=A(t);return e.jsxs("div",{className:"bg-[var(--surface)]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-4 pt-3 pb-2",children:[e.jsx(y,{label:"ALL",count:o.all,active:a==="all",onClick:()=>r("all"),tone:"neutral",bullet:!1}),e.jsx(y,{label:"PASSED",count:o.passed,active:a==="passed",onClick:()=>r("passed"),tone:"green"}),e.jsx(y,{label:"FAILED",count:o.failed,active:a==="failed",onClick:()=>r("failed"),tone:"red"}),e.jsx(y,{label:"RUNNING",count:o.running,active:a==="running",onClick:()=>r("running"),tone:"amber"})]}),e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-3 border-b border-[var(--border)]",children:[e.jsxs("div",{className:"relative flex-1 max-w-xl",children:[e.jsx(E,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--text-dim)]"}),e.jsx("input",{type:"text",value:l,onChange:i=>d(i.target.value),placeholder:"Search sessions by ID, name, or device…",className:"w-full h-8 pl-8 pr-2 rounded-md bg-[var(--bg)] border border-[var(--border)] text-xs text-[var(--text)] placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--border-strong)]"})]}),e.jsxs("span",{className:"text-[10px] font-mono text-[var(--text-dim)] whitespace-nowrap",children:[c," of ",u," sessions"]})]})]})};function fe(t){return(t.split("-")[0]||t).slice(0,8).toUpperCase()}const ve=({build:t,failedCount:a,selectedCount:r,onRetryFailed:l,onExport:d})=>{const c=a>0||r>0,[u,o]=w.useState(!1),i=w.useRef(null);w.useEffect(()=>{const s=n=>{i.current&&!i.current.contains(n.target)&&o(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const h=c?`Retry ${r||a} session${(r||a)===1?"":"s"}`:"No failed sessions to retry";return e.jsxs("header",{className:"flex items-start justify-between gap-4 px-4 py-3 border-b border-[var(--border)] bg-[var(--surface)]",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-widest text-[var(--text-dim)]",children:[e.jsx("span",{children:"Build"}),e.jsxs("span",{className:"font-mono text-[var(--green)]",title:t.id,children:["#",fe(t.id)]})]}),e.jsx("h1",{className:"mt-0.5 text-sm font-semibold text-[var(--text)]",children:t.name||"Unnamed build"})]}),e.jsxs("div",{className:"flex items-center gap-2",ref:i,children:[e.jsxs("button",{type:"button",onClick:l,disabled:!c,title:h,className:"inline-flex items-center gap-1.5 h-8 px-3 rounded-md border border-[var(--border)] text-xs text-[var(--text)] hover:border-[var(--border-strong)] hover:bg-[var(--surface-2)] transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(ce,{className:"h-3.5 w-3.5"}),"Retry failed"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>o(s=>!s),className:"inline-flex items-center gap-1.5 h-8 px-3 rounded-md border border-[var(--border)] text-xs text-[var(--text)] hover:border-[var(--border-strong)] hover:bg-[var(--surface-2)] transition-colors",children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Export"]}),u&&e.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 rounded-md border border-[var(--border)] bg-[var(--surface)] shadow-lg overflow-hidden z-20",children:[e.jsx("button",{type:"button",onClick:()=>{o(!1),d("json")},className:"w-full text-left px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--surface-2)]",children:"Export as JSON"}),e.jsx("button",{type:"button",onClick:()=>{o(!1),d("csv")},className:"w-full text-left px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--surface-2)]",children:"Export as CSV"})]})]})]})]})};function be({platform:t}){const a=(t||"").toLowerCase();return a.includes("tv")?e.jsx(M,{className:"h-3.5 w-3.5"}):a.includes("pad")||a.includes("tablet")?e.jsx(le,{className:"h-3.5 w-3.5"}):a.includes("android")||a.includes("ios")?e.jsx(O,{className:"h-3.5 w-3.5"}):e.jsx(oe,{className:"h-3.5 w-3.5"})}function ge(t){switch(k(t)){case"running":return{label:"RUNNING",tone:"running"};case"failed":return{label:"FAILED",tone:"failed"};case"passed":return{label:"PASSED",tone:"passed"};default:return{label:(t||"").toUpperCase(),tone:"offline"}}}const je=({session:t,selected:a,onToggleSelect:r,onOpen:l})=>{const d=k(t.status)==="failed",c=ge(t.status),u=Q(t),o=d&&t.failure_reason?t.failure_reason:t.name??"";return e.jsxs("tr",{onClick:l,className:"group border-b border-[var(--border)] hover:bg-[var(--surface-2)] cursor-pointer transition-colors align-top",children:[e.jsx("td",{className:"px-3 py-3",onClick:i=>i.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:a,onChange:r,"aria-label":`Select session ${t.id}`})}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsxs("div",{className:"font-mono text-xs text-[var(--green)]",title:t.id,children:["#",$(t.id,14,4)]}),o&&e.jsx("div",{className:"mt-0.5 text-[11px] text-[var(--text-muted)] truncate max-w-[420px]",title:o,children:o})]}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text)]",children:[e.jsx(be,{platform:t.device_platform}),e.jsx("span",{className:"truncate max-w-[160px]",children:u})]}),t.node_id&&e.jsxs("div",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:["node-",t.node_id]})]}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--text)]",children:V(t)}),t.device_version&&e.jsx("div",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:J(t)})]}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(K,{label:c.label,tone:c.tone})}),e.jsx("td",{className:"px-3 py-3 font-mono text-[11px] text-[var(--text-muted)] whitespace-nowrap",children:R(t.startTime)}),e.jsx("td",{className:"px-3 py-3 font-mono text-[11px] text-[var(--text-muted)] whitespace-nowrap text-right",children:W(Y(t))}),e.jsx("td",{className:"px-3 py-3 text-right",children:e.jsx(ne,{className:"inline h-4 w-4 text-[var(--text-dim)] group-hover:text-[var(--text)]"})})]})};function Ne(t,a){return a==="all"?!0:k(t.status)===a}const ye=({sessions:t,statusFilter:a,searchQuery:r,selectedIds:l,onToggleSelect:d,onToggleSelectAll:c,onOpenRow:u,buildHasNoSessions:o})=>{const i=b.useMemo(()=>{const n=r.trim().toLowerCase();return t.filter(p=>!(!Ne(p,a)||n&&!(p.id+" "+(p.name??"")+" "+(p.device_name??"")+" "+(p.device_platform??"")+" "+(p.device_version??"")+" "+(p.node_id??"")).toLowerCase().includes(n)))},[t,a,r]);if(o)return e.jsx("div",{className:"px-4 py-12 text-center text-xs text-[var(--text-dim)]",children:"No sessions in this build yet. Trigger one from your test runner."});if(i.length===0)return e.jsx("div",{className:"px-4 py-12 text-center text-xs text-[var(--text-dim)]",children:"No sessions match the current filters."});const h=i.length>0&&i.every(n=>l.has(n.id)),s=i.some(n=>l.has(n.id));return e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-left table-fixed",children:[e.jsx("thead",{className:"sticky top-0 bg-[var(--surface)] border-b border-[var(--border)] z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 w-[36px]",children:e.jsx("input",{type:"checkbox","aria-label":"Select all visible",checked:h,ref:n=>{n&&(n.indeterminate=s&&!h)},onChange:()=>c(i.map(n=>n.id))})}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium",children:"Session"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium",children:"Device · Node"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium w-[108px]",children:"Platform"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium w-[104px]",children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium w-[160px]",children:"Start Time"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium text-right w-[92px]",children:"Duration"}),e.jsx("th",{className:"px-3 py-2 w-[32px]"})]})}),e.jsx("tbody",{children:i.map(n=>e.jsx(je,{session:n,selected:l.has(n.id),onToggleSelect:()=>d(n.id),onOpen:()=>u(n)},n.id))})]})})},De=()=>{const t=z(),{buildId:a}=G(),r=Z(),{toast:l}=H(),[d,c]=b.useState("all"),[u,o]=b.useState("all"),[i,h]=b.useState(""),[s,n]=b.useState(new Set);w.useEffect(()=>{a&&a!==r.selectedBuildId&&(r.selectBuild(a),n(new Set))},[a,r]);const p=x=>t(`/builds/${x}`),g=x=>t(`/builds/${r.selectedBuildId}/sessions/${x.id}`),T=b.useCallback(x=>{n(m=>{const f=new Set(m);return f.has(x)?f.delete(x):f.add(x),f})},[]),D=b.useCallback(x=>{n(m=>{const f=x.length>0&&x.every(v=>m.has(v)),j=new Set(m);return f?x.forEach(v=>j.delete(v)):x.forEach(v=>j.add(v)),j})},[]),L=r.builds.find(x=>x.id===r.selectedBuildId)||null,P=A(r.sessions),U=()=>{l("Bulk retry lands in a future release.","info")},_=async x=>{if(r.selectedBuildId)try{const m=s.size>0?Array.from(s):void 0,{blob:f,filename:j}=await q.exportBuild(r.selectedBuildId,x,m),v=URL.createObjectURL(f),N=document.createElement("a");N.href=v,N.download=j,document.body.appendChild(N),N.click(),document.body.removeChild(N),URL.revokeObjectURL(v);const B=m?m.length:"all";l(`Exported ${B} session${B===1?"":"s"} as ${x.toUpperCase()}.`,"success")}catch(m){const f=m instanceof Error?m.message:String(m);l(`Export failed: ${f}`,"error")}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(ie,{icon:X,title:"Sessions",subtitle:"Builds and the test sessions recorded against them."}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(me,{builds:r.builds,selectedBuildId:r.selectedBuildId,onSelect:p,search:r.searchQuery,onSearchChange:r.setSearchQuery,timeFilter:d,onTimeFilterChange:c}),e.jsx("section",{className:"flex-1 flex flex-col min-w-0",children:L?e.jsxs(e.Fragment,{children:[e.jsx(ve,{build:L,failedCount:P.failed,selectedCount:s.size,onRetryFailed:U,onExport:_}),e.jsx(he,{sessions:r.sessions,active:u,onChange:o,search:i,onSearchChange:h,totalMatching:r.sessions.length,totalUnfiltered:r.sessions.length}),e.jsx(ye,{sessions:r.sessions,statusFilter:u,searchQuery:i,selectedIds:s,onToggleSelect:T,onToggleSelectAll:D,onOpenRow:g,buildHasNoSessions:r.sessions.length===0})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-[var(--text-dim)]",children:"Select a build from the left to see its sessions."})})]})]})};export{De as BuildsPage,De as default};
|
|
6
|
+
*/const ce=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}]],xe=O("refresh-ccw",ce),ue={neutral:"bg-[var(--surface-2)] text-[var(--text-muted)] border-[var(--border)]",green:"bg-[var(--green)]/15 text-[var(--green)] border-[var(--green)]/30",red:"bg-[var(--red)]/15 text-[var(--red)] border-[var(--red)]/30",amber:"bg-[var(--amber)]/15 text-[var(--amber)] border-[var(--amber)]/30"},C=({value:t,tone:a="neutral",label:r})=>e.jsx("span",{title:r,"aria-label":r,className:`inline-flex items-center justify-center min-w-[18px] h-[18px] px-1.5 rounded-full border text-[10px] font-mono font-medium ${ue[a]}`,children:t}),me={passed:{Icon:re,label:"PASSED",tint:"text-[var(--green)]"},failed:{Icon:se,label:"FAILED",tint:"text-[var(--red)]"},running:{Icon:te,label:"RUNNING",tint:"text-[var(--amber)]"}},S=({kind:t,value:a})=>{const{Icon:r,label:l,tint:d}=me[t];return e.jsxs("div",{className:"flex-1 flex flex-col items-center gap-1 py-2 rounded-md border border-[var(--border)] bg-[var(--bg)]",children:[e.jsx(r,{className:`h-3.5 w-3.5 ${d}`}),e.jsx("span",{className:`text-[9px] font-mono font-semibold tracking-wider ${d}`,children:l}),e.jsx("span",{className:"text-sm font-semibold text-[var(--text)] tabular-nums",children:a})]})},I={all:"All time","24h":"Last 24 hours","7d":"Last 7 days","30d":"Last 30 days"},pe=({builds:t,selectedBuildId:a,onSelect:r,search:l,onSearchChange:d,timeFilter:c,onTimeFilterChange:u})=>{const o=t.filter(s=>{const n=(s.name??"")+" "+s.id;if(l&&!n.toLowerCase().includes(l.toLowerCase()))return!1;if(c!=="all"){const w={"24h":864e5,"7d":6048e5,"30d":2592e6},j=Date.parse(String(s.createdAt));if(!Number.isFinite(j)||Date.now()-j>w[c])return!1}return!0}),i=l.trim().length>0||c!=="all",p=o.reduce((s,n)=>(s.passed+=n.passedCount||0,s.failed+=n.failedCount||0,s.running+=n.runningCount||0,s),{passed:0,failed:0,running:0});return e.jsxs("aside",{className:"w-[280px] shrink-0 border-r border-[var(--border)] bg-[var(--surface)] flex flex-col",children:[e.jsxs("div",{className:"p-3 space-y-2 border-b border-[var(--border)]",children:[e.jsxs("div",{className:"relative",children:[e.jsx(L,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--text-dim)]"}),e.jsx("input",{type:"text",value:l,onChange:s=>d(s.target.value),placeholder:"Find builds…",className:"w-full h-8 pl-8 pr-2 rounded-md bg-[var(--bg)] border border-[var(--border)] text-xs text-[var(--text)] placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--border-strong)]"})]}),e.jsx("select",{value:c,onChange:s=>u(s.target.value),className:"w-full h-8 px-2 rounded-md bg-[var(--bg)] border border-[var(--border)] text-xs text-[var(--text-muted)]",children:Object.keys(I).map(s=>e.jsx("option",{value:s,children:I[s]},s))})]}),e.jsxs("div",{className:"p-3 flex items-stretch gap-2 border-b border-[var(--border)]",children:[e.jsx(S,{kind:"passed",value:p.passed}),e.jsx(S,{kind:"failed",value:p.failed}),e.jsx(S,{kind:"running",value:p.running})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[o.length===0&&e.jsx("div",{className:"px-4 py-8 text-center text-xs text-[var(--text-dim)]",children:i?"No builds match.":"No builds yet — sessions will appear here after your first test run."}),o.map(s=>{const n=s.id===a;return e.jsxs("button",{type:"button",onClick:()=>r(s.id),className:`w-full text-left relative px-4 py-3 border-b border-[var(--border)] transition-colors ${n?"bg-[var(--surface-2)]":"hover:bg-[var(--surface-2)]/60"}`,children:[n&&e.jsx("span",{className:"absolute left-0 top-2 bottom-2 w-[3px] rounded-r bg-[var(--green)]"}),e.jsx("div",{className:"text-xs font-semibold text-[var(--text)] truncate",children:s.name||"Unnamed build"}),e.jsxs("div",{className:"mt-1 flex items-center gap-1 font-mono text-[9px] text-[var(--text-dim)]",children:[e.jsx(ae,{className:"h-3 w-3"}),E(s.createdAt)]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5",children:[s.passedCount>0&&e.jsx(C,{value:s.passedCount,tone:"green",label:`${s.passedCount} passed`}),s.failedCount>0&&e.jsx(C,{value:s.failedCount,tone:"red",label:`${s.failedCount} failed`}),s.runningCount>0&&e.jsx(C,{value:s.runningCount,tone:"amber",label:`${s.runningCount} running`}),s.sessionCount===0&&e.jsx("span",{className:"text-[10px] font-mono text-[var(--text-dim)]",children:"empty"})]}),e.jsx("div",{className:"mt-1 font-mono text-[9px] text-[var(--text-dim)] truncate",children:R(s.id,10,4)})]},s.id)})]})]})},he={neutral:"bg-[var(--text-dim)]",green:"bg-[var(--green)]",red:"bg-[var(--red)]",amber:"bg-[var(--amber)]",blue:"bg-[var(--blue)]"},N=({label:t,count:a,active:r,onClick:l,tone:d="neutral",bullet:c=!0})=>e.jsxs("button",{type:"button",onClick:l,"aria-pressed":r,className:`inline-flex items-center gap-2 h-8 px-3 rounded-md border text-[11px] font-semibold uppercase tracking-wider transition-colors cursor-pointer ${r?"bg-[var(--surface-2)] border-[var(--border-strong)] text-[var(--text)]":"bg-transparent border-transparent text-[var(--text-muted)] hover:text-[var(--text)] hover:bg-[var(--surface-2)]/50"}`,children:[c&&d!=="neutral"&&e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${he[d]}`}),e.jsx("span",{children:t}),typeof a=="number"&&e.jsx("span",{className:"font-mono text-[10px] text-[var(--text-dim)]",children:a})]}),ve=({sessions:t,active:a,onChange:r,search:l,onSearchChange:d,totalMatching:c,totalUnfiltered:u})=>{const o=$(t);return e.jsxs("div",{className:"bg-[var(--surface)]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-4 pt-3 pb-2",children:[e.jsx(N,{label:"ALL",count:o.all,active:a==="all",onClick:()=>r("all"),tone:"neutral",bullet:!1}),e.jsx(N,{label:"PASSED",count:o.passed,active:a==="passed",onClick:()=>r("passed"),tone:"green"}),e.jsx(N,{label:"FAILED",count:o.failed,active:a==="failed",onClick:()=>r("failed"),tone:"red"}),e.jsx(N,{label:"RUNNING",count:o.running,active:a==="running",onClick:()=>r("running"),tone:"amber"})]}),e.jsxs("div",{className:"flex items-center gap-4 px-4 pb-3 border-b border-[var(--border)]",children:[e.jsxs("div",{className:"relative flex-1 max-w-xl",children:[e.jsx(L,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-[var(--text-dim)]"}),e.jsx("input",{type:"text",value:l,onChange:i=>d(i.target.value),placeholder:"Search sessions by ID, name, or device…",className:"w-full h-8 pl-8 pr-2 rounded-md bg-[var(--bg)] border border-[var(--border)] text-xs text-[var(--text)] placeholder:text-[var(--text-dim)] focus:outline-none focus:border-[var(--border-strong)]"})]}),e.jsxs("span",{className:"text-[10px] font-mono text-[var(--text-dim)] whitespace-nowrap",children:[c," of ",u," sessions"]})]})]})};function fe(t){return(t.split("-")[0]||t).slice(0,8).toUpperCase()}const be=({build:t,failedCount:a,selectedCount:r,onRetryFailed:l,onExport:d})=>{const c=a>0||r>0,[u,o]=y.useState(!1),i=y.useRef(null);y.useEffect(()=>{const s=n=>{i.current&&!i.current.contains(n.target)&&o(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[]);const p=c?`Retry ${r||a} session${(r||a)===1?"":"s"}`:"No failed sessions to retry";return e.jsxs("header",{className:"flex items-start justify-between gap-4 px-4 py-3 border-b border-[var(--border)] bg-[var(--surface)]",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-widest text-[var(--text-dim)]",children:[e.jsx("span",{children:"Build"}),e.jsxs("span",{className:"font-mono text-[var(--green)]",title:t.id,children:["#",fe(t.id)]})]}),e.jsx("h1",{className:"mt-0.5 text-sm font-semibold text-[var(--text)]",children:t.name||"Unnamed build"})]}),e.jsxs("div",{className:"flex items-center gap-2",ref:i,children:[e.jsxs("button",{type:"button",onClick:l,disabled:!c,title:p,className:"inline-flex items-center gap-1.5 h-8 px-3 rounded-md border border-[var(--border)] text-xs text-[var(--text)] hover:border-[var(--border-strong)] hover:bg-[var(--surface-2)] transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[e.jsx(xe,{className:"h-3.5 w-3.5"}),"Retry failed"]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>o(s=>!s),className:"inline-flex items-center gap-1.5 h-8 px-3 rounded-md border border-[var(--border)] text-xs text-[var(--text)] hover:border-[var(--border-strong)] hover:bg-[var(--surface-2)] transition-colors",children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),"Export"]}),u&&e.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 rounded-md border border-[var(--border)] bg-[var(--surface)] shadow-lg overflow-hidden z-20",children:[e.jsx("button",{type:"button",onClick:()=>{o(!1),d("json")},className:"w-full text-left px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--surface-2)]",children:"Export as JSON"}),e.jsx("button",{type:"button",onClick:()=>{o(!1),d("csv")},className:"w-full text-left px-3 py-2 text-xs text-[var(--text)] hover:bg-[var(--surface-2)]",children:"Export as CSV"})]})]})]})]})};function ge({platform:t}){const a=(t||"").toLowerCase();return a.includes("tv")?e.jsx(_,{className:"h-3.5 w-3.5"}):a.includes("pad")||a.includes("tablet")?e.jsx(oe,{className:"h-3.5 w-3.5"}):a.includes("android")||a.includes("ios")?e.jsx(z,{className:"h-3.5 w-3.5"}):e.jsx(ie,{className:"h-3.5 w-3.5"})}function je(t){switch(A(t)){case"running":return{label:"RUNNING",tone:"running"};case"failed":return{label:"FAILED",tone:"failed"};case"passed":return{label:"PASSED",tone:"passed"};default:return{label:(t||"").toUpperCase(),tone:"offline"}}}const Ne=({session:t,selected:a,onToggleSelect:r,onOpen:l})=>{const d=A(t.status)==="failed",c=je(t.status),u=q(t),o=d&&t.failure_reason?t.failure_reason:t.name??"";return e.jsxs("tr",{onClick:l,className:"group border-b border-[var(--border)] hover:bg-[var(--surface-2)] cursor-pointer transition-colors align-top",children:[e.jsx("td",{className:"px-3 py-3",onClick:i=>i.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:a,onChange:r,"aria-label":`Select session ${t.id}`})}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsxs("div",{className:"font-mono text-xs text-[var(--green)]",title:t.id,children:["#",R(t.id,14,4)]}),o&&e.jsx("div",{className:"mt-0.5 text-[11px] text-[var(--text-muted)] truncate max-w-[420px]",title:o,children:o})]}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[var(--text)]",children:[e.jsx(ge,{platform:t.device_platform}),e.jsx("span",{className:"truncate max-w-[160px]",children:u})]}),t.node_id&&e.jsxs("div",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:["node-",t.node_id]})]}),e.jsxs("td",{className:"px-3 py-3",children:[e.jsx("div",{className:"text-xs text-[var(--text)]",children:J(t)}),t.device_version&&e.jsx("div",{className:"mt-0.5 font-mono text-[10px] text-[var(--text-dim)]",children:K(t)})]}),e.jsx("td",{className:"px-3 py-3",children:e.jsx(W,{label:c.label,tone:c.tone})}),e.jsx("td",{className:"px-3 py-3 font-mono text-[11px] text-[var(--text-muted)] whitespace-nowrap",children:E(t.startTime)}),e.jsx("td",{className:"px-3 py-3 font-mono text-[11px] text-[var(--text-muted)] whitespace-nowrap text-right",children:Y(Z(t))}),e.jsx("td",{className:"px-3 py-3 text-right",children:e.jsx(le,{className:"inline h-4 w-4 text-[var(--text-dim)] group-hover:text-[var(--text)]"})})]})},ye=({sessions:t,statusFilter:a,searchQuery:r,selectedIds:l,onToggleSelect:d,onToggleSelectAll:c,onOpenRow:u,buildHasNoSessions:o})=>{const i=f.useMemo(()=>T(t,a,r),[t,a,r]);if(o)return e.jsx("div",{className:"px-4 py-12 text-center text-xs text-[var(--text-dim)]",children:"No sessions in this build yet. Trigger one from your test runner."});if(i.length===0)return e.jsx("div",{className:"px-4 py-12 text-center text-xs text-[var(--text-dim)]",children:"No sessions match the current filters."});const p=i.length>0&&i.every(n=>l.has(n.id)),s=i.some(n=>l.has(n.id));return e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("table",{className:"w-full text-left table-fixed",children:[e.jsx("thead",{className:"sticky top-0 bg-[var(--surface)] border-b border-[var(--border)] z-10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-3 py-2 w-[36px]",children:e.jsx("input",{type:"checkbox","aria-label":"Select all visible",checked:p,ref:n=>{n&&(n.indeterminate=s&&!p)},onChange:()=>c(i.map(n=>n.id))})}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium",children:"Session"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium",children:"Device · Node"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium w-[108px]",children:"Platform"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium w-[104px]",children:"Status"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium w-[160px]",children:"Start Time"}),e.jsx("th",{className:"px-3 py-2 text-[10px] uppercase tracking-wider text-[var(--text-dim)] font-medium text-right w-[92px]",children:"Duration"}),e.jsx("th",{className:"px-3 py-2 w-[32px]"})]})}),e.jsx("tbody",{children:i.map(n=>e.jsx(Ne,{session:n,selected:l.has(n.id),onToggleSelect:()=>d(n.id),onOpen:()=>u(n)},n.id))})]})})},De=()=>{const t=G(),{buildId:a}=H(),r=ee(),{toast:l}=X(),[d,c]=f.useState("all"),[u,o]=f.useState("all"),[i,p]=f.useState(""),[s,n]=f.useState(new Set);y.useEffect(()=>{a&&a!==r.selectedBuildId&&(r.selectBuild(a),n(new Set))},[a,r]);const w=x=>t(`/builds/${x}`),j=x=>t(`/builds/${r.selectedBuildId}/sessions/${x.id}`),D=f.useCallback(x=>{n(m=>{const h=new Set(m);return h.has(x)?h.delete(x):h.add(x),h})},[]),P=f.useCallback(x=>{n(m=>{const h=x.length>0&&x.every(v=>m.has(v)),b=new Set(m);return h?x.forEach(v=>b.delete(v)):x.forEach(v=>b.add(v)),b})},[]),k=r.builds.find(x=>x.id===r.selectedBuildId)||null,U=$(r.sessions),F=()=>{l("Bulk retry lands in a future release.","info")},M=async x=>{if(r.selectedBuildId)try{const m=s.size>0?Array.from(s):void 0,{blob:h,filename:b}=await V.exportBuild(r.selectedBuildId,x,m),v=URL.createObjectURL(h),g=document.createElement("a");g.href=v,g.download=b,document.body.appendChild(g),g.click(),document.body.removeChild(g),URL.revokeObjectURL(v);const B=m?m.length:"all";l(`Exported ${B} session${B===1?"":"s"} as ${x.toUpperCase()}.`,"success")}catch(m){const h=m instanceof Error?m.message:String(m);l(`Export failed: ${h}`,"error")}};return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(de,{icon:Q,title:"Sessions",subtitle:"Builds and the test sessions recorded against them."}),e.jsxs("div",{className:"flex flex-1 min-h-0",children:[e.jsx(pe,{builds:r.builds,selectedBuildId:r.selectedBuildId,onSelect:w,search:r.searchQuery,onSearchChange:r.setSearchQuery,timeFilter:d,onTimeFilterChange:c}),e.jsx("section",{className:"flex-1 flex flex-col min-w-0",children:k?e.jsxs(e.Fragment,{children:[e.jsx(be,{build:k,failedCount:U.failed,selectedCount:s.size,onRetryFailed:F,onExport:M}),e.jsx(ve,{sessions:r.sessions,active:u,onChange:o,search:i,onSearchChange:p,totalMatching:T(r.sessions,u,i).length,totalUnfiltered:r.sessions.length}),e.jsx(ye,{sessions:r.sessions,statusFilter:u,searchQuery:i,selectedIds:s,onToggleSelect:D,onToggleSelectAll:P,onOpenRow:j,buildHasNoSessions:r.sessions.length===0})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-xs text-[var(--text-dim)]",children:"Select a build from the left to see its sessions."})})]})]})};export{De as BuildsPage,De as default};
|