@xenon-device-management/xenon 1.22.2 → 1.22.3
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-Snh2iZH5.js → ApiKeyGate-bHtvfyNp.js} +1 -1
- package/lib/public/assets/{BugReportButton-Sk0KGufH.js → BugReportButton-DFK28wAC.js} +1 -1
- package/lib/public/assets/DeviceMosaicView-C4Yrz2PA.js +7 -0
- package/lib/public/assets/{EmptyState-CQun3BJE.js → EmptyState-aXHIYg04.js} +1 -1
- package/lib/public/assets/{FieldGroup-DmYZP2j7.js → FieldGroup-C_DwE2dP.js} +1 -1
- package/lib/public/assets/{Modal-C5W8lMJ6.js → Modal-BCbDzIzg.js} +1 -1
- package/lib/public/assets/{SegmentedControl-BIzlKyUd.js → SegmentedControl-BPjRPFXH.js} +1 -1
- package/lib/public/assets/{SettingCard-DAFqQw7S.js → SettingCard-BJ8-ywEG.js} +1 -1
- package/lib/public/assets/{Table-DRkkM4OR.js → Table-C7XQ4gI0.js} +1 -1
- package/lib/public/assets/{activity-B6x69oOy.js → activity-Bv16pTkN.js} +1 -1
- package/lib/public/assets/{ai-settings-CSZQis7F.js → ai-settings-BpXcUQm3.js} +1 -1
- package/lib/public/assets/{api-keys-4ddjSngL.js → api-keys-HzfbVxL2.js} +1 -1
- package/lib/public/assets/{apps-CePIfnu9.js → apps-CtyCtiVx.js} +1 -1
- package/lib/public/assets/{arrow-left-CaOe18yC.js → arrow-left-TEnyrpa4.js} +1 -1
- package/lib/public/assets/{arrow-right-FEQsqDvH.js → arrow-right-ILl07Dxb.js} +1 -1
- package/lib/public/assets/{arrow-up-right-Dnszb73S.js → arrow-up-right-BOGBb0NS.js} +1 -1
- package/lib/public/assets/{auth-shell-Vq1rYIVD.js → auth-shell-D3PWn3HG.js} +2 -2
- package/lib/public/assets/{builds-page-FfsUegKZ.js → builds-page-BsKfrrMf.js} +1 -1
- package/lib/public/assets/{button-DrqhMLZ0.js → button-Kv_nqg_I.js} +1 -1
- package/lib/public/assets/{calendar-BuRuUa7q.js → calendar-DnjXodK3.js} +1 -1
- package/lib/public/assets/{check-DYccNk73.js → check-DvGXlj1A.js} +1 -1
- package/lib/public/assets/chevron-left-CZDYD4H3.js +6 -0
- package/lib/public/assets/{chevron-right-C6ny35i3.js → chevron-right-CuPozn4T.js} +1 -1
- package/lib/public/assets/{circle-check-Cokzy9a2.js → circle-check-CBxV3geR.js} +1 -1
- package/lib/public/assets/{circle-x-BhUzyxKR.js → circle-x-X-nHBZnY.js} +1 -1
- package/lib/public/assets/{clock-BCG0drfS.js → clock-lLny_RuH.js} +1 -1
- package/lib/public/assets/{copy-BKOm9hko.js → copy-CYjhxjiV.js} +1 -1
- package/lib/public/assets/{device-explorer-CIjs3BXP.js → device-explorer-ClkV_k7q.js} +43 -63
- package/lib/public/assets/{download-R2k7Nd4P.js → download-2y5oRiK2.js} +1 -1
- package/lib/public/assets/{forgot-password-CiZcr-gB.js → forgot-password-BouiRKS-.js} +1 -1
- package/lib/public/assets/{funnel-SD4F5IdR.js → funnel-DozJGkC5.js} +1 -1
- package/lib/public/assets/{index-BHDlQcd6.js → index-4PUiCXoJ.js} +2 -2
- package/lib/public/assets/{index-C7S8Y7Fj.css → index-BYvkQIjW.css} +1 -1
- package/lib/public/assets/{input-Ilib6feD.js → input-Cg5C6lE3.js} +1 -1
- package/lib/public/assets/keycodes-paeodb9g.js +21 -0
- package/lib/public/assets/layers-CVD3KYnj.js +6 -0
- package/lib/public/assets/{lock-s9ZhGDFF.js → lock-DnyJ9riq.js} +1 -1
- package/lib/public/assets/{login-EkaxK7K5.js → login-BMa0mDmt.js} +1 -1
- package/lib/public/assets/{maintenance-settings-yYhZaU7n.js → maintenance-settings-EezUAUBC.js} +1 -1
- package/lib/public/assets/{mouse-pointer-2-C6yy1DTx.js → mouse-pointer-2-k4GDYFXz.js} +1 -1
- package/lib/public/assets/{network-B8fPwmW9.js → network-ULTYYDWq.js} +1 -1
- package/lib/public/assets/{overview-DrTe5eJi.js → overview-DM4y4MtE.js} +1 -1
- package/lib/public/assets/{page-header-DhD-Kua9.js → page-header-DgX21Ndv.js} +1 -1
- package/lib/public/assets/{plus-B75ovH3O.js → plus-DaUKFcvv.js} +1 -1
- package/lib/public/assets/{profile-page-C2p5rB3x.js → profile-page-dcPePTH5.js} +1 -1
- package/lib/public/assets/{reset-password-tCemYrqV.js → reset-password-Ct5IlHB3.js} +1 -1
- package/lib/public/assets/{runbook-page-Dq3wdSII.js → runbook-page-C5jLKOAy.js} +1 -1
- package/lib/public/assets/{select-Cfv-njLE.js → select-HMxRDgs7.js} +1 -1
- package/lib/public/assets/selector-detail-page-BhlyEw8l.js +1 -0
- package/lib/public/assets/{selector-health-BP45B44s.js → selector-health-DQlTiNJV.js} +1 -1
- package/lib/public/assets/{selector-health-page-D-8SdN_l.js → selector-health-page-Cd1Mm_DB.js} +1 -1
- package/lib/public/assets/{session-detail-page-Dm4tnoTT.js → session-detail-page-BU8Y3HnL.js} +3 -8
- package/lib/public/assets/{settings-ChfaAd8F.js → settings-k_Xaf5kj.js} +1 -1
- package/lib/public/assets/{status-pill-outline-CLa0C1Sg.js → status-pill-outline-C5m6HFzT.js} +1 -1
- package/lib/public/assets/{tablet-0sIFwy2Z.js → tablet-2ogUZZch.js} +1 -1
- package/lib/public/assets/{teams-BFhWbK5i.js → teams-C2AfSO30.js} +1 -1
- package/lib/public/assets/{trash-2-BcQxmJP-.js → trash-2-BDdM7yPO.js} +1 -1
- package/lib/public/assets/{upload-BucqEWub.js → upload-C1vqAOQK.js} +1 -1
- package/lib/public/assets/{use-password-reset-mode-XoxXVCzm.js → use-password-reset-mode-Cw6xu19K.js} +1 -1
- package/lib/public/assets/{users-DyB6E3FF.js → users-C5jlnASB.js} +1 -1
- package/lib/public/assets/{users-B7uveXL_.js → users-CsatJcoI.js} +1 -1
- package/lib/public/assets/video-off-CAdNNByI.js +6 -0
- package/lib/public/assets/{webhook-settings-qoHAETzC.js → webhook-settings-D9Yjj-J6.js} +1 -1
- package/lib/public/assets/{zap-CqGOjAjn.js → zap-CduRPXBS.js} +1 -1
- package/lib/public/index.html +2 -2
- package/package.json +1 -1
- package/lib/public/assets/DeviceMosaicView-O292tZkA.js +0 -2
- package/lib/public/assets/keycodes-bIEJfQzr.js +0 -1
- package/lib/public/assets/layers-CLuKN5Oy.js +0 -11
- package/lib/public/assets/selector-detail-page-8xf4CxH5.js +0 -1
package/lib/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e,o as h}from"./index-
|
|
1
|
+
import{r as n,j as e,o as h}from"./index-4PUiCXoJ.js";function y({children:c}){const[i,s]=n.useState(null),[o,l]=n.useState(""),[a,r]=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(),r(null);const d=await fetch("/xenon/api/auth/dashboard-session",{method:"POST",headers:{"Content-Type":"application/json",...h},credentials:"include",body:JSON.stringify({apiKey:o.trim()})});if(d.ok)s(!0);else{const p=await d.json().catch(()=>({}));r(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"})]}),a&&e.jsx("p",{style:{color:"crimson",marginTop:12},children:a})]})}export{y as ApiKeyGate};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{c as $e,r as c,j as n,z as Le,B as Be,X as $,y as Ue,T as Ye,Y as ze}from"./index-4PUiCXoJ.js";import{p as Ve}from"./labels-C21SA4JG.js";import{C as Xe}from"./circle-check-CBxV3geR.js";import{C as ye,A as ee,H as Fe,S as we,a as Ge,I as He}from"./keycodes-paeodb9g.js";import{V as We}from"./video-off-CAdNNByI.js";import{C as Ke}from"./chevron-left-CZDYD4H3.js";import{P as Je}from"./plus-DaUKFcvv.js";import{D as se}from"./download-2y5oRiK2.js";import{a as qe}from"./page-header-DgX21Ndv.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const Ze=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],Qe=$e("pencil",Ze);function et(e,t){return e!=="auto"?e:t<=1?"1":t===2?"2x1":t<=4?"2x2":"3x2"}const tt={selected:new Set,layout:"auto",tiles:[],groupId:null,compositeEnabled:!1,downloadableVideoCount:0,recordingPhase:"idle",recording:!1,startedAt:null,annotateMode:!1,shape:"RECT",color:"#ff3333",overlayAnnotations:{},errorBanner:null,banner:null};function rt(e,t){var r;switch(t.type){case"SET_LAYOUT":return{...e,layout:t.layout};case"TOGGLE_SELECTED":{const o=new Set(e.selected);return o.has(t.udid)?o.delete(t.udid):o.add(t.udid),{...e,selected:o}}case"CLEAR_SELECTED":return{...e,selected:new Set};case"SET_TILES":return{...e,tiles:t.tiles};case"ADD_TILE":return e.tiles.some(o=>o.udid===t.tile.udid)?e:{...e,tiles:[...e.tiles,t.tile]};case"PATCH_TILE_DIMS":{let o=!1;const s=e.tiles.map(p=>p.udid!==t.udid||p.screenWidth&&p.screenHeight?p:(o=!0,{...p,screenWidth:t.screenWidth,screenHeight:t.screenHeight,aspect:t.aspect??p.aspect}));return o?{...e,tiles:s}:e}case"REMOVE_TILE":return e.recordingPhase!=="idle"?e:{...e,tiles:e.tiles.filter(o=>o.udid!==t.udid)};case"BIND_RECORDING_IDS":{const o=e.tiles.map(s=>({...s,recordingId:t.map[s.udid]??s.recordingId}));return{...e,tiles:o}}case"SET_RECORDING_PHASE":{const o=t.phase;return{...e,recordingPhase:o,recording:o==="recording"||o==="stopping"}}case"START_RECORDING":{const o=e.tiles.map(s=>({...s,recordingId:t.tileIds[s.udid]??s.recordingId}));return{...e,groupId:t.groupId,compositeEnabled:t.compositeEnabled===!0,downloadableVideoCount:0,recordingPhase:"recording",recording:!0,annotateMode:!0,startedAt:t.startedAt,overlayAnnotations:{},tiles:o}}case"REHYDRATE_RECORDING":{const o=e.tiles.map(s=>({...s,recordingId:t.tileIds[s.udid]??s.recordingId}));return{...e,groupId:t.groupId,compositeEnabled:t.compositeEnabled,downloadableVideoCount:0,recordingPhase:"recording",recording:!0,annotateMode:!1,startedAt:t.startedAt,overlayAnnotations:t.overlayAnnotations,tiles:o}}case"STOP_RECORDING":{const o=e.tiles.map(s=>({...s,recordingId:void 0}));return{...e,recording:!1,recordingPhase:"idle",annotateMode:!1,overlayAnnotations:{},downloadableVideoCount:t.downloadableVideoCount??e.downloadableVideoCount,compositeEnabled:t.compositeEnabled!==void 0?t.compositeEnabled:e.compositeEnabled,tiles:o}}case"SET_ANNOTATE_MODE":return{...e,annotateMode:t.enabled};case"SET_SHAPE":return{...e,shape:t.shape};case"SET_COLOR":return{...e,color:t.color};case"SET_OVERLAY_ANNOTATIONS":return{...e,overlayAnnotations:{...e.overlayAnnotations,[t.recordingId]:t.annotations}};case"CLEAR_OVERLAY_ANNOTATIONS":return{...e,overlayAnnotations:{}};case"SET_ERROR_BANNER":return{...e,errorBanner:t.message,banner:t.message?{tone:"error",message:t.message}:null};case"SET_BANNER":return{...e,banner:t.banner,errorBanner:((r=t.banner)==null?void 0:r.tone)==="error"?t.banner.message:null};default:return e}}const Ee=c.createContext(null);function nt(){const e=c.useContext(Ee);if(!e)throw new Error("useMosaic must be used inside <MosaicContext.Provider>");return e}function ot(){return c.useReducer(rt,tt)}function st(e){const t=Math.max(0,Math.floor(e/1e3)),r=Math.floor(t/3600),o=Math.floor(t%3600/60),s=t%60;return r>0?`${r}:${String(o).padStart(2,"0")}:${String(s).padStart(2,"0")}`:`${o}:${String(s).padStart(2,"0")}`}function it(e){switch(e){case"automation":return"In automation";case"manual_other":return"Manual control by another user";case"manual_self":return"On your grid";case"recording_other_group":return"Recording in another group";default:return e?"Busy":null}}const ue=[{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}],H={available:"bg-[var(--color-success)]",inUse:"bg-[var(--color-warning)]",offline:"bg-[rgb(var(--rgb-offline))]"},at=[["available",H.available],["in use",H.inUse],["offline",H.offline]];function fe(e){return Ve(e)}function ct({devices:e,inMosaic:t,onToggle:r,status:o="ready"}){const[s,p]=c.useState(""),[u,y]=c.useState({}),w=c.useMemo(()=>{const l=s.trim().toLowerCase();return l?e.filter(N=>N.udid.toLowerCase().includes(l)||(N.name??"").toLowerCase().includes(l)||(N.platform??"").toLowerCase().includes(l)):e},[e,s]),m=c.useMemo(()=>{const l=ue.map(i=>({id:i.id,label:i.label,rows:[]})),N=i=>l.find((S,g)=>ue[g].match(i))??l[l.length-1];for(const i of w)N((i.platform??"").toLowerCase()).rows.push(i);return l.filter(i=>i.rows.length>0)},[w]);if(e.length===0){const l=o==="loading"?"Loading devices…":o==="error"?"Couldn’t load devices. Retrying…":"No devices online.";return n.jsx("div",{role:"status",className:"text-xs text-[var(--text-dim)] p-3",children:l})}return n.jsxs("div",{className:"flex flex-col gap-2",children:[n.jsxs("div",{className:"relative",children:[n.jsx(Le,{"aria-hidden":!0,size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-dim)]"}),n.jsx("input",{type:"text",value:s,placeholder:"Filter devices...",onChange:l=>p(l.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(--color-info)]"})]}),m.map(l=>{const N=u[l.id];return n.jsxs("section",{className:"flex flex-col gap-1",children:[n.jsxs("button",{type:"button","aria-expanded":!N,onClick:()=>y(i=>({...i,[l.id]:!i[l.id]})),className:"flex items-center justify-between w-full text-[11px] text-[var(--text-dim)] hover:text-[rgb(var(--rgb-fg))] px-1 py-0.5",children:[n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(Be,{"aria-hidden":!0,size:12,className:`transition-transform ${N?"-rotate-90":"rotate-0"}`}),l.label]}),n.jsx("span",{children:l.rows.length})]}),!N&&n.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:l.rows.map(i=>{const S=i.busyReason==="manual_self",g=t.has(i.udid),x=!!i.busy&&!S&&!g||!!i.offline,C=i.offline?"Offline":it(i.busyReason),_=!x,M=[i.name??i.udid,i.platform&&fe(i.platform)].concat(x&&C?[C]:[]).filter(Boolean).join(", ");return n.jsx("li",{children:n.jsxs("button",{type:"button",disabled:x,draggable:!x,onDragStart:T=>{T.dataTransfer.effectAllowed="copy",T.dataTransfer.setData("application/x-xenon-udid",i.udid),T.dataTransfer.setData("text/plain",i.udid)},onClick:()=>r(i.udid),"aria-label":M,"aria-pressed":g,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":g?"border-[rgb(var(--rgb-accent)/0.4)] bg-[rgb(var(--rgb-accent)/0.05)] hover:bg-[rgb(var(--rgb-accent)/0.1)]":"border-transparent hover:border-[var(--border)] hover:bg-[var(--surface-2)]"}`,title:x?`${C} — release first`:g?"Click to remove from the grid":"Click to add to the grid (or drag to a cell)",children:[g?n.jsx(Xe,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--color-accent-soft)]"}):n.jsx(ye,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--text-dim)]"}),n.jsx("span",{"aria-hidden":!0,className:`inline-block w-1.5 h-1.5 rounded-full ${i.offline?H.offline:_?H.available:H.inUse}`}),n.jsx("span",{className:"font-medium flex-1 truncate text-[13px]",children:i.name??i.udid}),i.platform&&n.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded bg-[var(--surface-2)] text-[var(--text-dim)]",children:fe(i.platform)})]})},i.udid)})})]},l.id)}),s&&m.length===0&&n.jsxs("div",{className:"text-xs text-[var(--text-dim)] px-1 py-2",children:['No devices match "',s,'".']}),n.jsx("div",{className:"text-[10px] text-[var(--text-dim)] px-1 pt-2 flex items-center gap-3",children:at.map(([l,N])=>n.jsxs("span",{className:"inline-flex items-center gap-1",children:[n.jsx("span",{className:`w-1.5 h-1.5 rounded-full inline-block ${N}`}),l]},l))})]})}const lt=[{id:"1",label:"1",icon:n.jsx(ut,{})},{id:"2x1",label:"2×1",icon:n.jsx(ft,{})},{id:"2x2",label:"2×2",icon:n.jsx(ht,{})},{id:"3x2",label:"3×2",icon:n.jsx(pt,{})},{id:"auto",label:"Auto",icon:n.jsx(mt,{})}];function dt({value:e,onChange:t}){return n.jsx("div",{role:"tablist",className:"inline-flex border border-[var(--border)] rounded-md overflow-hidden text-xs bg-[rgb(var(--rgb-white)/0.02)]",children:lt.map(r=>{const o=e===r.id;return n.jsxs("button",{role:"tab","aria-selected":o,onClick:()=>t(r.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 ${o?"bg-[var(--surface-2)] text-[rgb(var(--rgb-fg))]":"text-[var(--text-dim)] hover:bg-[var(--surface-2)] hover:text-[rgb(var(--rgb-fg))]"}`,title:`Layout: ${r.label}`,children:[n.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:r.icon}),n.jsx("span",{children:r.label})]},r.id)})})}function z(e){return n.jsx("rect",{rx:1.2,ry:1.2,fill:"currentColor",...e})}function ut(){return n.jsx("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:z({x:2,y:2,width:10,height:10})})}function ft(){return n.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[z({x:1.5,y:3,width:5,height:8}),z({x:7.5,y:3,width:5,height:8})]})}function ht(){return n.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[z({x:1.5,y:1.5,width:5,height:5}),z({x:7.5,y:1.5,width:5,height:5}),z({x:1.5,y:7.5,width:5,height:5}),z({x:7.5,y:7.5,width:5,height:5})]})}function pt(){return n.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[z({x:1,y:1.5,width:3.3,height:5}),z({x:5.35,y:1.5,width:3.3,height:5}),z({x:9.7,y:1.5,width:3.3,height:5}),z({x:1,y:7.5,width:3.3,height:5}),z({x:5.35,y:7.5,width:3.3,height:5}),z({x:9.7,y:7.5,width:3.3,height:5})]})}function mt(){return n.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[n.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1.5"}),n.jsx("circle",{cx:"7",cy:"7",r:"1.5",fill:"currentColor",stroke:"none"})]})}const gt=1600;function xt(e,t){const r=gt/Math.max(e,t);return{w:Math.round(e*r),h:Math.round(t*r)}}function bt(e,t,r,o=document){if(t<=0||r<=0)return null;const{w:s,h:p}=xt(t,r),u=o.createElement("canvas");u.width=s,u.height=p;const y=u.getContext("2d");if(!y)return null;y.scale(s/t,p/r),ae(y,t,r,e);try{return u.toDataURL("image/png")}catch{return null}}function Ne(e,t,r){const o={left:0,top:0,width:e,height:t};if(!r||!(r>0)||e<=0||t<=0)return o;const s=e/t;if(Math.abs(s-r)<1e-6)return o;if(r>s){const u=e/r;return{left:0,top:(t-u)/2,width:e,height:u}}const p=t*r;return{left:(e-p)/2,top:0,width:p,height:t}}const vt=(e,t)=>e===t||!!e&&!!t&&e.left===t.left&&e.top===t.top&&e.width===t.width&&e.height===t.height,yt=2,wt=2e3;function he(e,t,r){if(e.length>=wt)return e;const o=e[e.length-1];return o&&Math.hypot(t-o[0],r-o[1])<yt?e:[...e,[t,r]]}function pe(e,t){const r=(e||"#ff3333").trim();if(/^#[0-9a-fA-F]{6}$/.test(r)){const o=parseInt(r.slice(1,3),16),s=parseInt(r.slice(3,5),16),p=parseInt(r.slice(5,7),16);return`rgba(${o},${s},${p},${t})`}return r}function ae(e,t,r,o){var N;const s=o.geometry,p=o.color||"#ff3333",u=Math.max(4,Math.round(Math.min(t,r)*.008));if(e.lineCap="round",e.lineJoin="round",o.shape==="CIRCLE"){const i=(s.x??0)*t,S=(s.y??0)*r,g=Math.max(2,(s.w??0)*t),x=Math.max(2,(s.h??0)*r);e.beginPath(),e.ellipse(i,S,g,x,0,0,Math.PI*2),e.fillStyle=pe(p,.22),e.fill(),e.lineWidth=u+2,e.strokeStyle="rgba(0,0,0,0.55)",e.stroke(),e.beginPath(),e.ellipse(i,S,g,x,0,0,Math.PI*2),e.lineWidth=u,e.strokeStyle=p,e.stroke();return}if(o.shape==="ARROW"){const i=(s.x??0)*t,S=(s.y??0)*r,g=i+(s.w??0)*t,x=S+(s.h??0)*r;e.lineWidth=u+2,e.strokeStyle="rgba(0,0,0,0.55)",e.beginPath(),e.moveTo(i,S),e.lineTo(g,x),e.stroke(),e.lineWidth=u,e.strokeStyle=p,e.beginPath(),e.moveTo(i,S),e.lineTo(g,x),e.stroke();const C=Math.atan2(x-S,g-i),_=Math.max(14,u*3);e.fillStyle=p,e.beginPath(),e.moveTo(g,x),e.lineTo(g-_*Math.cos(C-.4),x-_*Math.sin(C-.4)),e.lineTo(g-_*Math.cos(C+.4),x-_*Math.sin(C+.4)),e.closePath(),e.fill();return}if(o.shape==="TEXT"&&o.text){const i=Math.max(16,Math.round(Math.min(t,r)*.035));e.font=`bold ${i}px sans-serif`,e.lineWidth=3,e.strokeStyle="rgba(0,0,0,0.65)",e.strokeText(o.text,(s.x??0)*t,(s.y??0)*r),e.fillStyle=p,e.fillText(o.text,(s.x??0)*t,(s.y??0)*r);return}if(o.shape==="FREEHAND"&&(((N=s.points)==null?void 0:N.length)??0)>=2){const i=s.points,S=()=>{e.beginPath(),e.moveTo(i[0][0]*t,i[0][1]*r);for(let g=1;g<i.length;g++)e.lineTo(i[g][0]*t,i[g][1]*r)};e.lineWidth=u+2,e.strokeStyle="rgba(0,0,0,0.55)",S(),e.stroke(),e.lineWidth=u,e.strokeStyle=p,S(),e.stroke();return}const y=(s.x??0)*t,w=(s.y??0)*r,m=Math.max(2,(s.w??0)*t),l=Math.max(2,(s.h??0)*r);e.fillStyle=pe(p,.22),e.fillRect(y,w,m,l),e.lineWidth=u+2,e.strokeStyle="rgba(0,0,0,0.55)",e.strokeRect(y,w,m,l),e.lineWidth=u,e.strokeStyle=p,e.strokeRect(y,w,m,l)}function me(e,t,r,o,s){if(o<=0||s<=0)return null;if(e==="CIRCLE"){const m=Math.hypot(r.curX-r.startX,r.curY-r.startY);return m<=4?null:{shape:e,color:t,geometry:{x:r.startX/o,y:r.startY/s,w:m/o,h:m/s}}}if(e==="ARROW"){const m=r.curX-r.startX,l=r.curY-r.startY;return Math.hypot(m,l)<=6?null:{shape:e,color:t,geometry:{x:r.startX/o,y:r.startY/s,w:m/o,h:l/s}}}if(e==="FREEHAND"){if(r.points.length<2)return null;const m=r.points.map(S=>S[0]),l=r.points.map(S=>S[1]),N=Math.min(...m),i=Math.min(...l);return{shape:e,color:t,geometry:{x:N/o,y:i/s,w:Math.max(.005,(Math.max(...m)-N)/o),h:Math.max(.005,(Math.max(...l)-i)/s),points:r.points.map(([S,g])=>[S/o,g/s])}}}const p=Math.min(r.startX,r.curX)/o,u=Math.min(r.startY,r.curY)/s,y=Math.abs(r.curX-r.startX)/o,w=Math.abs(r.curY-r.startY)/s;return y<=.005||w<=.005?null:{shape:e,color:t,geometry:{x:p,y:u,w:y,h:w}}}function Et({enabled:e,shape:t,color:r,onCommit:o,committed:s,onCommittedChange:p,mediaAspect:u}){const y=c.useRef(null),[w,m]=c.useState(null),[l,N]=c.useState([]),[i,S]=c.useState(null),g=s??l,x=c.useRef(g),C=c.useRef(w),_=c.useRef(t),M=c.useRef(r),T=c.useRef(e);x.current=g,C.current=w,_.current=t,M.current=r,T.current=e;const P=c.useCallback(f=>{const E=f(x.current);x.current=E,p?p(E):N(E)},[p]),d=c.useCallback(()=>{const f=y.current;if(!f)return;const E=f.getContext("2d");if(!E)return;E.clearRect(0,0,f.width,f.height);for(const I of x.current)ae(E,f.width,f.height,I);const j=C.current;if(j){const I=me(_.current,M.current,j,f.width,f.height);I&&ae(E,f.width,f.height,I)}},[]);c.useEffect(()=>{const f=y.current;if(!f)return;const E=()=>{const I=Math.max(1,Math.round(f.clientWidth)),O=Math.max(1,Math.round(f.clientHeight));(f.width!==I||f.height!==O)&&(f.width=I,f.height=O),d()};E();const j=new ResizeObserver(E);return j.observe(f),()=>j.disconnect()},[d]),c.useEffect(()=>{d()},[w,g,d]),c.useEffect(()=>{var I;const f=(I=y.current)==null?void 0:I.parentElement;if(!f)return;const E=()=>{const O=u?Ne(f.clientWidth,f.clientHeight,u):null;S(D=>vt(D,O)?D:O)};E();const j=new ResizeObserver(E);return j.observe(f),()=>j.disconnect()},[u]),c.useEffect(()=>{var E;if(e)return;m(null);const f=y.current;if(f&&f.hasPointerCapture)try{for(let j=0;j<8;j++)(E=f.hasPointerCapture)!=null&&E.call(f,j)&&f.releasePointerCapture(j)}catch{}},[e]);const v=f=>{const j=y.current.getBoundingClientRect();return{px:f.clientX-j.left,py:f.clientY-j.top,w:j.width,h:j.height}},h=f=>{const E=C.current;if(!E||!T.current){m(null);return}const j=y.current;if(!j||j.width<=0){m(null);return}const I=v(f),O=me(_.current,M.current,{...E,curX:I.px,curY:I.py,points:he(E.points,I.px,I.py)},I.w,I.h);O&&(P(D=>[...D,O]),o(O,bt(O,I.w,I.h))),m(null)},b=f=>{if(!e||f.button!==0)return;f.preventDefault(),f.currentTarget.setPointerCapture(f.pointerId);const E=v(f);m({startX:E.px,startY:E.py,curX:E.px,curY:E.py,points:[[E.px,E.py]]})},A=f=>{if(!C.current)return;const E=v(f);m(j=>j&&{...j,curX:E.px,curY:E.py,points:he(j.points,E.px,E.py)})},k=f=>{try{f.currentTarget.releasePointerCapture(f.pointerId)}catch{}h(f)};return n.jsx("canvas",{ref:y,style:{position:"absolute",...i?{left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`}:{inset:0,width:"100%",height:"100%"},pointerEvents:e?"auto":"none",cursor:e?"crosshair":"default",zIndex:e?40:25},onPointerDown:b,onPointerMove:A,onPointerUp:k,onPointerCancel:k})}function Nt(e,t,r,o,s,p,u=!1){const y=Ne(r.width,r.height,p);let w=(e-r.left-y.left)/y.width,m=(t-r.top-y.top)/y.height;return!(w>=0&&w<=1&&m>=0&&m<=1)&&!u?null:(w=Math.min(1,Math.max(0,w)),m=Math.min(1,Math.max(0,m)),{x:Math.round(w*o),y:Math.round(m*s)})}const Rt=5e3;function St(e,t){if(e.httpStatus===404)return{ended:!0,startedAt:t};if(e.httpStatus!==200)return{ended:!1,startedAt:t};const r=e.body??{};return r.status!=="running"?{ended:!0,startedAt:t}:t&&r.startedAt&&r.startedAt!==t?{ended:!0,startedAt:t}:{ended:!1,startedAt:t??r.startedAt}}function Tt(e,t,r,o=Rt){const s=c.useRef(r);s.current=r,c.useEffect(()=>{if(!t)return;let p=!1,u=!1,y;const w=async()=>{if(!(u||p)){u=!0;try{const l=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/status`),N=l.ok?await l.json().catch(()=>{}):void 0;if(p)return;const i=St({httpStatus:l.status,body:N},y);y=i.startedAt,i.ended&&(p=!0,s.current())}catch{}finally{u=!1}}};w();const m=setInterval(w,o);return()=>{p=!0,clearInterval(m)}},[e,t,o])}const jt=3,Ct=45e3,ge=[2e3,5e3,1e4];function At(e){const t=Math.max(0,Math.min(e,ge.length-1));return ge[t]}function It(e){return e<jt}function xe(e){const t=(e.lastError||"").toLowerCase();return/did not find test app|not installed|webdriveragentrunner|applicationverification/.test(t)?"WebDriverAgent is not installed on this device. Install and trust WDA, then retry.":/unsupported ios version|manualpairingtunnelstart/.test(t)?"This device’s iOS version is not supported for live streaming on this host.":/econnrefused|econnreset|connection reset|tunnel/.test(t)?"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."}function Dt(e){for(let t=0;t+4<e.length;t++){const r=e[t]===0&&e[t+1]===0&&e[t+2]===0&&e[t+3]===1,o=e[t]===0&&e[t+1]===0&&e[t+2]===1;if(!r&&!o)continue;const s=t+(r?4:3);if((e[s]&31)===7){const p=u=>u.toString(16).padStart(2,"0");return`avc1.${p(e[s+1])}${p(e[s+2])}${p(e[s+3])}`}}return"avc1.42e01e"}const kt=({wsUrl:e,onFatal:t,onReady:r,onFrameSize:o,className:s})=>{const p=c.useRef(null),u=c.useRef(t);u.current=t;const y=c.useRef(r);y.current=r;const w=c.useRef(o);return w.current=o,c.useEffect(()=>{var M;const m=window,l=p.current;if(typeof m.VideoDecoder>"u"||!l){(M=u.current)==null||M.call(u);return}const N=l.getContext("2d");let i=!1,S=!1,g=!0,x=0;const C=new m.VideoDecoder({output:T=>{var P,d;if(i){T.close();return}(l.width!==T.displayWidth||l.height!==T.displayHeight)&&(l.width=T.displayWidth,l.height=T.displayHeight,(P=w.current)==null||P.call(w,T.displayWidth,T.displayHeight)),N==null||N.drawImage(T,0,0),T.close(),g&&(g=!1,(d=y.current)==null||d.call(y))},error:()=>{var T;return(T=u.current)==null?void 0:T.call(u)}}),_=new WebSocket(e);return _.binaryType="arraybuffer",_.onerror=()=>{var T;return(T=u.current)==null?void 0:T.call(u)},_.onclose=()=>{var T;i||(T=u.current)==null||T.call(u)},_.onmessage=T=>{var h;const P=T.data,d=new DataView(P).getUint8(0),v=new Uint8Array(P,1);if(d===0){if(S)return;try{C.configure({codec:Dt(v),optimizeForLatency:!0}),S=!0}catch{(h=u.current)==null||h.call(u)}return}if(!(!S||C.state!=="configured"))try{C.decode(new m.EncodedVideoChunk({type:d===1?"key":"delta",timestamp:x,data:v})),x+=11111}catch{}},()=>{i=!0;try{_.close()}catch{}try{C.state!=="closed"&&C.close()}catch{}}},[e]),n.jsx("canvas",{ref:p,className:s,style:{width:"100%",height:"100%",objectFit:"contain",display:"block"}})};function _t(e,t,r){return(e==="android"||e==="androidtv"||e==="android-tv")&&t==="h264"&&r?"h264":"mjpeg"}const Mt=10,Ot=500;function Pt({udid:e,name:t,recordingId:r,annotateMode:o,shape:s,color:p,aspect:u="9 / 16",screenWidth:y,screenHeight:w,platform:m,onAnnotation:l,overlayAnnotations:N,onOverlayAnnotationsChange:i,onRemove:S}){const[g,x]=c.useState("connecting"),[C,_]=c.useState(),M=c.useCallback((a,R)=>{if(!(a>0)||!(R>0))return;const B=a/R;_(U=>U!==void 0&&Math.abs(U-B)<.001?U:B)},[]),[T,P]=c.useState(0),[d,v]=c.useState(null),h=c.useRef(0),b=c.useRef(null),[A,k]=c.useState(""),[f,E]=c.useState([]),[j,I]=c.useState(!1),O=c.useRef(null),D=c.useRef(null),V=m==="android"||m==="androidtv"||m==="android-tv",ce=m==="ios"||m==="tvos";c.useEffect(()=>{let a=!1;if(r){v(null),x("connecting"),P(Date.now()),$.startStream(e).catch(()=>{});return}const R=typeof window.VideoDecoder<"u";return(async()=>{try{const B=encodeURIComponent(e),U=await fetch(`/xenon/api/control/${B}/stream/status`);if(!U.ok)return;const L=await U.json();if(_t(m||"",L==null?void 0:L.type,R)!=="h264"||!(L!=null&&L.h264Path))return;const X=await fetch(`/xenon/api/control/${B}/stream/ticket`,{method:"POST"});if(!X.ok)return;const{ticket:Y}=await X.json();if(a||!Y)return;const Z=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}${L.h264Path}?ticket=${encodeURIComponent(Y)}`;v(Z)}catch{}})(),()=>{a=!0}},[e,m,r]);const J=!o&&!!y&&!!w,ne=(a,R,B,U=!1)=>Nt(a,R,B,y,w,C,U),Te=(a,R,B)=>{const U=Date.now()+Math.random(),L=a-B.left,X=R-B.top;E(Y=>[...Y,{id:U,x:L,y:X}]),window.setTimeout(()=>{E(Y=>Y.filter(K=>K.id!==U))},500)},je=a=>{if(!J||g==="unavailable"||a.button!==0)return;const R=a.currentTarget;R.focus(),ne(a.clientX,a.clientY,R.getBoundingClientRect())&&(R.setPointerCapture(a.pointerId),D.current={startX:a.clientX,startY:a.clientY,startTime:Date.now(),rect:R.getBoundingClientRect()},Te(a.clientX,a.clientY,D.current.rect))},Ce=async a=>{var Z,de;const R=D.current;if(D.current=null,!R||!J)return;try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}const B=a.clientX-R.startX,U=a.clientY-R.startY,L=Math.hypot(B,U),X=Date.now()-R.startTime,Y=ne(R.startX,R.startY,R.rect,!0),K=L<Mt;try{if(K&&X<Ot)await $.tap(e,Y.x,Y.y);else if(K)await((de=(Z=$).touchAndHold)==null?void 0:de.call(Z,e,Y.x,Y.y,X));else{const Q=ne(a.clientX,a.clientY,R.rect,!0);await $.swipe(e,Y.x,Y.y,Q.x,Q.y)}}catch(Q){console.error(`[DeviceTile] gesture failed for ${e}`,Q)}},Ae=()=>{D.current=null},Ie=async a=>{if(!J||g==="unavailable"||a.metaKey||a.ctrlKey||a.altKey)return;const R=a.key;try{if(R.length===1){a.preventDefault(),await $.typeText(e,R);return}if(R==="Backspace"){a.preventDefault(),V?await $.pressKey(e,67):await $.typeText(e,"\b");return}if(R==="Enter"){a.preventDefault(),V?await $.pressKey(e,66):await $.typeText(e,`
|
|
7
|
+
`);return}if(R==="Tab"){a.preventDefault(),await $.typeText(e," ");return}R==="Escape"&&V&&(a.preventDefault(),await $.pressKey(e,ee.BACK))}catch(B){console.error(`[DeviceTile] keystroke "${R}" failed for ${e}`,B)}},De=()=>$.pressKey(e,V?ee.HOME:He.HOME).catch(a=>console.error(`[DeviceTile] home failed for ${e}`,a)),ke=()=>$.pressKey(e,ee.BACK).catch(a=>console.error(`[DeviceTile] back failed for ${e}`,a)),_e=()=>$.pressKey(e,ee.APP_SWITCH).catch(a=>console.error(`[DeviceTile] app-switch failed for ${e}`,a)),Me=async()=>{try{const a=await $.getScreenshot(e),R=(a==null?void 0:a.screenshot)??(a==null?void 0:a.value)??a;if(!R)return;const B=await fetch(`data:image/png;base64,${R}`).then(X=>X.blob()),U=URL.createObjectURL(B),L=document.createElement("a");L.href=U,L.download=`${t||e}-${Date.now()}.png`,document.body.appendChild(L),L.click(),L.remove(),setTimeout(()=>URL.revokeObjectURL(U),1e3)}catch(a){console.error(`[DeviceTile] screenshot failed for ${e}`,a)}};c.useEffect(()=>{console.log(`[DeviceTile] Rendering ${e} in state: ${g}`)},[e,g]);const Oe=`/xenon/api/control/${encodeURIComponent(e)}/stream?t=${T}`,le=c.useCallback(async()=>{try{const a=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/status`);if(!a.ok)throw new Error(String(a.status));const R=await a.json();k(xe({lastError:R==null?void 0:R.lastError,status:R==null?void 0:R.status}))}catch{k(xe({}))}},[e]),oe=c.useCallback(()=>{const a=h.current;It(a)?(h.current=a+1,b.current&&clearTimeout(b.current),b.current=setTimeout(()=>{x("connecting"),P(Date.now())},At(a))):(x("unavailable"),le())},[le]);c.useEffect(()=>{if(g!=="connecting")return;const a=setTimeout(oe,Ct);return()=>clearTimeout(a)},[g,T,oe]),Tt(e,g==="live"&&!d,()=>{console.warn(`[DeviceTile] MJPEG stream ended for ${e}; reconnecting`),x("connecting"),P(Date.now())}),c.useEffect(()=>()=>{b.current&&clearTimeout(b.current)},[]);const Pe=()=>{b.current&&clearTimeout(b.current),h.current=0,k(""),x("connecting"),P(Date.now())},W=!!r,q=t||e.slice(0,16)+"…";return n.jsxs("div",{className:"flex items-stretch justify-center w-full h-full min-h-0 min-w-0 gap-2",children:[n.jsxs("div",{className:"theme-dark relative bg-[var(--black)] rounded-lg overflow-hidden border border-[var(--border)] group max-h-full max-w-full self-center",style:{aspectRatio:u,height:"100%"},children:[g==="connecting"&&n.jsxs("div",{role:"status","aria-live":"polite",className:"flex flex-col items-center justify-center gap-1 px-4 text-center bg-[rgb(var(--rgb-well)/0.8)] text-[var(--text-dim)] absolute inset-0 z-20 pointer-events-none",children:[n.jsx("div",{"aria-hidden":!0,className:"w-10 h-10 mb-3 border-4 border-[var(--border)] border-t-[var(--text-dim)] rounded-full animate-spin"}),n.jsx("div",{className:"font-semibold text-[var(--text)]",children:"Starting stream…"}),n.jsx("div",{className:"text-xs text-[var(--text-dim)] truncate max-w-full",children:q}),n.jsx("div",{className:"text-[11px] mt-3 text-[var(--text-dim)] leading-snug",children:ce?"iPhone streams can take up to 20 seconds to start.":"Connecting to the device…"})]}),g==="unavailable"&&n.jsx("div",{role:"alert",className:"flex items-center justify-center bg-[var(--black)] text-[var(--text-dim)] absolute inset-0 z-20",children:n.jsxs("div",{className:"text-center p-6",children:[n.jsx(We,{"aria-hidden":!0,size:36,className:"mx-auto mb-3 text-[var(--text-dim)]"}),n.jsx("div",{className:"font-semibold text-[var(--text)]",children:"Connection failed"}),n.jsx("p",{className:"text-xs mt-2 text-[var(--text-dim)] leading-relaxed max-w-[240px] mx-auto",children:A||"We couldn’t start the live stream for this device."}),n.jsx("button",{type:"button",className:"mt-5 text-sm font-semibold px-4 py-2 rounded bg-[var(--color-accent)] hover:bg-[var(--color-accent-strong)] text-[var(--color-on-accent)] transition-colors",onClick:Pe,children:"Retry"})]})}),d?n.jsx(kt,{wsUrl:d,className:"absolute inset-0 w-full h-full object-contain bg-black select-none pointer-events-none",onReady:()=>x("live"),onFrameSize:M,onFatal:()=>{console.warn(`[DeviceTile] H.264 fatal for ${e}; falling back to MJPEG`),v(null),x("connecting"),P(Date.now())}}):n.jsx("img",{src:Oe,alt:q,className:"absolute inset-0 w-full h-full object-contain bg-black select-none pointer-events-none",draggable:!1,style:{opacity:g==="live"?1:0,transition:"opacity 0.3s ease-in-out"},onLoad:a=>{console.log(`[DeviceTile] Image LOADED for ${e}`),M(a.currentTarget.naturalWidth,a.currentTarget.naturalHeight),h.current=0,b.current&&clearTimeout(b.current),x("live")},onError:a=>{console.error(`[DeviceTile] Image ERROR for ${e}`,a),oe()}},T),J&&g!=="unavailable"&&n.jsx("div",{ref:O,className:`absolute inset-0 z-[35] touch-none outline-none ${j?"ring-2 ring-[rgb(var(--rgb-accent)/0.6)] ring-inset rounded-lg":""}`,tabIndex:0,onPointerDown:je,onPointerUp:Ce,onPointerCancel:Ae,onKeyDown:Ie,onFocus:()=>I(!0),onBlur:()=>I(!1)}),n.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none overflow-hidden",children:f.map(a=>n.jsx("span",{className:"absolute block w-10 h-10 rounded-full border-2 border-[var(--color-accent-soft)] animate-ping",style:{left:a.x-20,top:a.y-20}},a.id))}),W&&n.jsx(Et,{enabled:o,shape:s,color:p,committed:N,mediaAspect:C,onCommittedChange:i,onCommit:(a,R)=>l(r,a,R)}),W&&o&&g==="live"&&n.jsx("div",{className:"absolute top-3 left-14 right-3 z-30 flex justify-end pointer-events-none",children:n.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-[var(--color-info)] text-white text-[10px] font-semibold shadow-lg whitespace-nowrap overflow-hidden text-ellipsis",children:"Annotating · drag to mark"})}),W&&n.jsx("div",{className:"absolute top-3 left-3 z-30 pointer-events-none",children:n.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-[var(--red-600)] text-white text-[9px] font-black shadow-lg",children:"REC"})}),n.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:[g==="live"&&n.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-[var(--color-success)] text-[var(--color-on-success)] text-[11px] font-semibold shadow-lg w-fit",children:"Live"}),n.jsx("span",{className:"px-2 py-1 rounded bg-[rgb(var(--rgb-well)/0.8)] text-[var(--text)] text-[11px] font-medium backdrop-blur-md border border-[rgb(var(--rgb-fg)/0.1)] shadow-xl truncate max-w-[180px]",children:q})]})]}),n.jsx($t,{streamState:g,recording:W,isIOS:ce,isAndroid:V,onClose:!W&&S?()=>S(e):void 0,sendHome:De,sendBack:ke,sendAppSwitch:_e,captureScreenshot:Me,displayName:q})]})}const te="w-7 h-7 flex items-center justify-center rounded-md hover:bg-[var(--surface-2)] hover:text-[var(--text)] transition-colors";function $t({streamState:e,recording:t,isIOS:r,isAndroid:o,onClose:s,sendHome:p,sendBack:u,sendAppSwitch:y,captureScreenshot:w,displayName:m}){const l=e==="live";return!s&&!l?null:n.jsxs("div",{className:"self-stretch w-9 flex flex-col items-center justify-between gap-1 py-2 rounded-lg bg-[var(--surface)] border border-[var(--border)] text-[var(--text-dim)]",children:[n.jsx("div",{className:"flex flex-col items-center gap-1",children:s&&n.jsx("button",{type:"button","aria-label":`Remove ${m}`,title:"Remove from the grid",onClick:s,className:"w-7 h-7 flex items-center justify-center rounded-md hover:bg-[rgb(var(--rgb-red)/0.15)] hover:text-[var(--color-danger)] transition-colors",children:n.jsx(Ue,{"aria-hidden":!0,size:16})})}),l&&n.jsxs("div",{className:"flex flex-col items-center gap-1.5 my-auto",children:[(o||r)&&n.jsx("button",{type:"button","aria-label":"Home",title:"Home",onClick:p,className:te,children:n.jsx(Fe,{"aria-hidden":!0,size:15})}),o&&n.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:u,className:te,children:n.jsx(Ke,{"aria-hidden":!0,size:16})}),o&&n.jsx("button",{type:"button","aria-label":"Recent apps",title:"Recent apps",onClick:y,className:te,children:n.jsx(we,{"aria-hidden":!0,size:13})})]}),l&&n.jsx("div",{className:"flex flex-col items-center gap-1",children:n.jsx("button",{type:"button","aria-label":"Screenshot",title:"Screenshot",onClick:w,className:te,children:n.jsx(Ge,{"aria-hidden":!0,size:15})})})]})}const Lt={1:"1fr","2x1":"1fr 1fr","2x2":"1fr 1fr","3x2":"1fr 1fr 1fr"},Bt={1:"1fr","2x1":"1fr","2x2":"1fr 1fr","3x2":"1fr 1fr"},Ut={1:1,"2x1":2,"2x2":4,"3x2":6};function Yt({layout:e,tiles:t,annotateMode:r,shape:o,color:s,onAnnotation:p,overlayAnnotationsByRecording:u,onOverlayAnnotationsChange:y,onRemove:w,onDropDevice:m}){const l=et(e,t.length),N=Ut[l];t.length;const i=t.length,S=e==="auto"?Math.max(i,1):N,g=Math.max(0,S-i);return n.jsxs("div",{style:{display:"grid",gap:8,gridTemplateColumns:Lt[l],gridTemplateRows:Bt[l]},className:"h-full",children:[t.map(x=>n.jsx(Pt,{udid:x.udid,name:x.name,mjpegPort:x.mjpegPort,recordingId:x.recordingId,aspect:x.aspect,screenWidth:x.screenWidth,screenHeight:x.screenHeight,platform:x.platform,annotateMode:r,shape:o,color:s,overlayAnnotations:x.recordingId?u==null?void 0:u[x.recordingId]:void 0,onOverlayAnnotationsChange:x.recordingId&&y?C=>y(x.recordingId,C):void 0,onAnnotation:p,onRemove:w},x.udid)),Array.from({length:g},(x,C)=>n.jsx(zt,{onDropDevice:m},`empty-${C}`))]})}function zt({onDropDevice:e}){const[t,r]=c.useState(!1);return n.jsxs("div",{onDragOver:o=>{e&&(o.preventDefault(),o.dataTransfer.dropEffect="copy",t||r(!0))},onDragLeave:()=>r(!1),onDrop:o=>{if(r(!1),!e)return;o.preventDefault();const s=o.dataTransfer.getData("application/x-xenon-udid")||o.dataTransfer.getData("text/plain");s&&e(s)},className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors ${t?"border-[rgb(var(--rgb-accent)/0.6)] bg-[rgb(var(--rgb-accent)/0.05)]":"border-[var(--border)] bg-[rgb(var(--rgb-fg)/0.02)]"} text-[var(--text-dim)] min-h-[120px]`,children:[n.jsx("div",{"aria-hidden":"true",className:`w-8 h-8 rounded-full flex items-center justify-center ${t?"bg-[rgb(var(--rgb-accent)/0.15)] text-[var(--color-accent-soft)]":"bg-[rgb(var(--rgb-fg)/0.05)] text-[rgb(var(--rgb-fg)/0.6)]"}`,children:n.jsx(Je,{size:16})}),n.jsx("div",{className:"text-xs font-medium",children:"Drag a device here"}),n.jsx("div",{className:"text-[10px] opacity-70",children:"or click one in the list"})]})}const F="/xenon/api/recordings";class Re extends Error{constructor(t){super(t.message??t.error),this.body=t}}async function re(e,t){const r=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:t?JSON.stringify(t):void 0});if(r.status===409)throw new Re(await r.json());if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}function Vt(e,t){return re(F,{udids:e,...t})}function Xt(e){return re(`${F}/${encodeURIComponent(e)}/stop`)}function be(e,t){return re(`${F}/${encodeURIComponent(e)}/annotation`,t)}function Ft(e,t){return re(`${F}/${encodeURIComponent(e)}/annotations/clear`,{timecodeMs:t})}async function Gt(){const e=await fetch(`${F}/active`);if(!e.ok)throw new Error(`HTTP ${e.status}`);return e.json()}function Ht(e){return`${F}/${encodeURIComponent(e)}/videos.zip`}function Wt(e,t){return`${F}/${encodeURIComponent(e)}/video.mp4`}function Kt(e){return`${F}/${encodeURIComponent(e)}/composite.mp4`}function Jt(e,t){return t==="starting"?"Starting…":e<=1?"Record":`Record ${e} devices`}const G={"aria-hidden":!0,size:14,className:"shrink-0"};function qt({selectedUdids:e,onClearMarks:t}){const{state:r,dispatch:o}=nt(),[s,p]=c.useState(()=>Date.now());c.useEffect(()=>{if(r.recordingPhase!=="recording"&&r.recordingPhase!=="stopping")return;p(Date.now());const h=window.setInterval(()=>p(Date.now()),250);return()=>window.clearInterval(h)},[r.recordingPhase]);const u=r.startedAt&&(r.recordingPhase==="recording"||r.recordingPhase==="stopping")?s-r.startedAt:0,y=r.recordingPhase==="starting"||r.recordingPhase==="stopping",w=r.recordingPhase==="idle"&&e.length>0&&!y,m=r.recordingPhase==="recording"||r.recording&&r.tiles.some(h=>!!h.recordingId),l=m&&!y,N=l,i=N&&r.annotateMode,S=!!r.groupId&&r.recordingPhase==="idle",g=e.length>1||r.downloadableVideoCount>1,x=S&&r.compositeEnabled,C=S&&!r.compositeEnabled&&(r.downloadableVideoCount===1||r.downloadableVideoCount===0&&e.length<=1),_=async()=>{var h;if(w){o({type:"SET_RECORDING_PHASE",phase:"starting"}),o({type:"SET_BANNER",banner:null});try{const b=await Vt(e);if(!((h=b.recordings)!=null&&h.length)){o({type:"SET_RECORDING_PHASE",phase:"idle"}),o({type:"SET_BANNER",banner:{tone:"error",message:"Recording did not start. Check that live preview is working, then try again."}});return}const A={};for(const f of b.recordings)A[f.udid]=f.id;const k=e.length-b.recordings.length;o({type:"START_RECORDING",groupId:b.groupId,startedAt:Date.now(),tileIds:A,compositeEnabled:b.compositeEnabled===!0}),k>0?o({type:"SET_BANNER",banner:{tone:"error",message:`Recording started on ${b.recordings.length} of ${e.length} devices (${k} failed).`}}):o({type:"SET_BANNER",banner:null})}catch(b){if(o({type:"SET_RECORDING_PHASE",phase:"idle"}),b instanceof Re)if(b.body.error==="device_busy"){const A=(b.body.busyDevices??[]).map(k=>`${k.udid} (${k.reason})`).join(", ");o({type:"SET_BANNER",banner:{tone:"error",message:`Cannot start — these devices are busy: ${A}`}})}else o({type:"SET_BANNER",banner:{tone:"error",message:`Server-wide recording cap reached (${b.body.active}/${b.body.limit}).`}});else o({type:"SET_BANNER",banner:{tone:"error",message:`Recording failed: ${b.message}`}})}}},M=async()=>{if(!(!r.groupId||r.recordingPhase!=="recording")){o({type:"SET_RECORDING_PHASE",phase:"stopping"});try{const h=await Xt(r.groupId),b=(h.recordings??[]).filter(k=>k.status==="STOPPED"&&(k.sizeBytes??0)>=1024),A=(h.recordings??[]).filter(k=>k.status!=="STOPPED");o({type:"STOP_RECORDING",downloadableVideoCount:b.length,compositeEnabled:r.compositeEnabled}),b.length===0?o({type:"SET_BANNER",banner:{tone:"error",message:A.length>0?`Recording failed on ${A.length} device(s). Nothing to download.`:"Recording stopped but no playable video was produced."}}):A.length>0?o({type:"SET_BANNER",banner:{tone:"info",message:`${b.length} ready, ${A.length} failed. Download with the button above.`}}):o({type:"SET_BANNER",banner:{tone:"info",message:b.length===1?"Video ready. Download it with the button above.":`${b.length} videos ready. Download them with the button above.`}})}catch(h){o({type:"STOP_RECORDING"}),o({type:"SET_BANNER",banner:{tone:"error",message:`Stop failed: ${h.message}`}})}}},T=()=>{N&&o({type:"SET_ANNOTATE_MODE",enabled:!r.annotateMode})},P=()=>{N&&t()},d=Object.values(r.overlayAnnotations).some(h=>((h==null?void 0:h.length)??0)>0),v=[{id:"RECT",label:"Rect"},{id:"CIRCLE",label:"Circle"},{id:"ARROW",label:"Arrow"},{id:"FREEHAND",label:"Draw"}];return n.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[r.recordingPhase==="recording"||r.recordingPhase==="stopping"?n.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs font-mono tabular-nums bg-[rgb(var(--rgb-red-600)/0.2)] text-[var(--red-200)] border border-[rgb(var(--rgb-red)/0.4)]",title:"Recording elapsed time",children:[n.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-[var(--red)] animate-pulse"}),"REC ",st(u),r.recordingPhase==="stopping"?" · Stopping…":""]}):n.jsxs("button",{type:"button",onClick:_,disabled:!w,title:e.length===0?"Add a device to the grid first":"Record every device on the grid",className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded bg-[var(--red-600)] text-white disabled:opacity-40 disabled:cursor-not-allowed light:disabled:bg-transparent light:disabled:text-[var(--text)] light:disabled:ring-1 light:disabled:ring-inset light:disabled:ring-[color:var(--border)]",children:[n.jsx(ye,{...G,size:10,fill:"currentColor"}),Jt(e.length,r.recordingPhase)]}),n.jsxs("button",{type:"button",onClick:M,disabled:!l,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded border border-[var(--border)] disabled:opacity-40 disabled:cursor-not-allowed",children:[n.jsx(we,{...G,size:12}),r.recordingPhase==="stopping"?"Stopping…":"Stop"]}),n.jsxs("button",{type:"button",onClick:T,disabled:!N,title:N?r.annotateMode?"Exit annotate mode (tap/swipe resumes)":"Draw on the live screen — saved with the recording":"Start recording to annotate",className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded border ${r.annotateMode?"bg-[var(--color-info)] text-white border-transparent":"border-[var(--border)]"} disabled:opacity-40 disabled:cursor-not-allowed`,children:[n.jsx(Qe,{...G}),"Annotate"]}),m&&n.jsxs("div",{className:"flex items-center gap-1 ml-1 pl-2 border-l border-[var(--border)]",children:[v.map(h=>n.jsx("button",{type:"button",disabled:!i,"aria-pressed":r.shape===h.id,onClick:()=>o({type:"SET_SHAPE",shape:h.id}),className:`px-2 py-1 text-xs rounded border disabled:opacity-40 disabled:cursor-not-allowed ${r.shape===h.id?"bg-[var(--surface-2)] border-[var(--color-info)] text-[rgb(var(--rgb-fg))]":"border-[var(--border)] opacity-80 hover:opacity-100"}`,children:h.label},h.id)),n.jsx("input",{type:"color",value:r.color,disabled:!i,onChange:h=>o({type:"SET_COLOR",color:h.target.value}),title:"Annotation color","aria-label":"Annotation color",className:"w-7 h-7 rounded border border-[var(--border)] bg-transparent cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"}),n.jsx("button",{type:"button",onClick:P,disabled:!N||!d,title:"Clear marks from the preview and the recording",className:"px-2 py-1 text-xs rounded border border-[var(--border)] hover:bg-[var(--surface-2)] disabled:opacity-40 disabled:cursor-not-allowed",children:"Clear marks"})]}),S&&C&&n.jsxs("a",{href:Wt(r.groupId),className:"ml-1 inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded border border-[var(--border)] hover:bg-[var(--surface-2)]",download:!0,children:[n.jsx(se,{...G}),"Download video"]}),S&&!C&&n.jsxs("a",{href:Ht(r.groupId),className:"ml-1 inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded border border-[var(--border)] hover:bg-[var(--surface-2)]",download:`videos-${r.groupId}.zip`,title:"ZIP of mp4 files only (no JSON extras)",children:[n.jsx(se,{...G}),"Download ",g?"videos":"video"]}),x&&n.jsxs("a",{href:Kt(r.groupId),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded border border-[var(--border)] hover:bg-[var(--surface-2)]",download:`side-by-side-${r.groupId}.mp4`,title:"All devices in one side-by-side video",children:[n.jsx(se,{...G}),"Side-by-side"]})]})}function Zt({remainingSec:e,onContinue:t,onReleaseNow:r}){return n.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:n.jsxs("div",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-lg w-full max-w-md p-6",children:[n.jsx("h3",{id:"idle-warning-title",className:"text-base font-semibold mb-2",children:"Are you still there?"}),n.jsxs("p",{className:"text-sm text-[var(--text-dim)] mb-4",children:["Your devices will be released in"," ",n.jsxs("span",{className:"text-[var(--text)] font-mono font-semibold",children:[e,"s"]})," due to inactivity. Click ",n.jsx("strong",{children:"Continue Session"})," to keep them locked."]}),n.jsxs("div",{className:"flex justify-end gap-2",children:[n.jsx("button",{type:"button",onClick:r,className:"h-9 px-3 rounded-md border border-[var(--border)] text-sm text-[var(--text-dim)] hover:text-[var(--text)]",children:"Release now"}),n.jsx("button",{type:"button",autoFocus:!0,onClick:t,className:"h-9 px-4 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] text-sm font-medium",children:"Continue session"})]})]})})}function Se(e,t,r){return!r||!e?!1:e===`manual_${r}_${t}`}function Qt(e,t){return e.busy?Se(e.session_id,e.udid,t):!1}function er(){let e=Promise.resolve();return{enqueue(t){const r=e.then(t,t);return e=r.then(()=>{},()=>{}),r}}}const ve=["mousemove","mousedown","keydown","touchstart","wheel"];function tr({idleAfterMs:e,warningSec:t,onWarning:r,onTimeout:o,enabled:s}){const[p,u]=c.useState(!1),[y,w]=c.useState(null),m=c.useRef(null),l=c.useRef(null),N=c.useRef(!1),i=c.useRef(r),S=c.useRef(o);i.current=r,S.current=o;function g(){m.current&&(clearTimeout(m.current),m.current=null),l.current&&(clearInterval(l.current),l.current=null)}function x(){N.current=!0,u(!0),w(t),i.current(t);let M=t;l.current=setInterval(()=>{M-=1,M<=0?(g(),N.current=!1,u(!1),w(null),S.current()):w(M)},1e3)}function C(){g(),N.current=!1,u(!1),w(null);const M=e-t*1e3;m.current=setTimeout(x,Math.max(0,M))}function _(){s&&C()}return c.useEffect(()=>{if(!s){g(),N.current=!1,u(!1),w(null);return}function M(){N.current||C()}return ve.forEach(T=>window.addEventListener(T,M,{passive:!0})),C(),()=>{ve.forEach(T=>window.removeEventListener(T,M)),g()}},[s,e,t]),{warning:p,remainingSec:y,reset:_}}const rr=5*60*1e3,nr=30;function ie(e){if(!e)return"9 / 16";const t=Number(e.screenWidth),r=Number(e.screenHeight);if(Number.isFinite(t)&&Number.isFinite(r)&&t>0&&r>0)return`${t} / ${r}`;const o=(e.platform||"").toLowerCase();return o==="tvos"||o==="androidtv"||o==="android-tv"?"16 / 9":"9 / 16"}function or(e,t){if(e.busy)return e.session_id?e.session_id.startsWith("manual_")?Se(e.session_id,e.udid,t)?"manual_self":"manual_other":"automation":"unknown"}function sr(e,t){return{udid:e.udid,name:e.name,platform:e.platform,busy:e.busy,busyReason:or(e,t),mjpegServerPort:e.mjpegServerPort,offline:!!e.offline}}function mr(){const[e,t]=ot(),[r,o]=c.useState([]),[s,p]=c.useState("loading"),[u,y]=c.useState(0),[w,m]=c.useState(null),l=c.useRef(!1),N=c.useRef(er());c.useEffect(()=>{let d=!1;return fetch("/xenon/api/auth/me",{credentials:"include"}).then(v=>v.ok?v.json():null).then(v=>{!d&&(v!=null&&v.userId)&&m(v.userId)}).catch(()=>{}),()=>{d=!0}},[]),c.useEffect(()=>{let d=!1;const v=async()=>{try{const b=await $.getDevices();if(d)return;o(Array.isArray(b)?b:[]),p("ready")}catch{d||p("error")}};v();const h=window.setInterval(v,5e3);return()=>{d=!0,window.clearInterval(h)}},[u]),c.useEffect(()=>{let d=!1;if(!w||l.current)return;l.current=!0;const v=h=>{const b=Number(h.screenWidth),A=Number(h.screenHeight);return{udid:h.udid,name:h.name,mjpegPort:0,aspect:ie(h),screenWidth:Number.isFinite(b)&&b>0?b:void 0,screenHeight:Number.isFinite(A)&&A>0?A:void 0,platform:h.platform}};return(async()=>{var A;let h=[],b=[];try{const k=await $.getDevices();h=Array.isArray(k)?k:[];const f=h.filter(j=>Qt(j,w));if(b=(await Promise.all(f.map(async j=>{try{const I=await fetch(`/xenon/api/control/${encodeURIComponent(j.udid)}/stream/status`);if(!I.ok)return null;const O=await I.json();return(O==null?void 0:O.status)==="running"?j:null}catch{return null}}))).filter(j=>j!==null).map(v),d)return;b.length>0&&t({type:"SET_TILES",tiles:b})}catch{}try{const{serverNow:k,groups:f}=await Gt(),E=f[0];if(d||!E)return;const j=new Set(b.map(D=>D.udid)),I=E.recordings.filter(D=>!j.has(D.udid)).map(D=>h.find(V=>V.udid===D.udid)).filter(D=>!!D).map(v);I.length>0&&t({type:"SET_TILES",tiles:[...b,...I]});const O={};for(const D of E.annotations){let V;try{V=JSON.parse(D.geometry)}catch{continue}(O[A=D.recordingId]??(O[A]=[])).push({shape:D.shape,color:D.color,geometry:V,text:D.text??void 0})}t({type:"REHYDRATE_RECORDING",groupId:E.groupId,startedAt:Date.now()-(k-Date.parse(E.startedAt)),tileIds:Object.fromEntries(E.recordings.map(D=>[D.udid,D.id])),compositeEnabled:E.compositeEnabled,overlayAnnotations:O})}catch{}})(),()=>{d=!0}},[w,t]),c.useEffect(()=>{for(const d of e.tiles){if(d.screenWidth&&d.screenHeight)continue;const v=r.find(A=>A.udid===d.udid);if(!v)continue;const h=Number(v.screenWidth),b=Number(v.screenHeight);Number.isFinite(h)&&h>0&&Number.isFinite(b)&&b>0&&t({type:"PATCH_TILE_DIMS",udid:d.udid,screenWidth:h,screenHeight:b,aspect:ie(v)})}},[r,e.tiles,t]);const i=c.useMemo(()=>new Set(e.tiles.map(d=>d.udid)),[e.tiles]),S=c.useMemo(()=>r.map(d=>sr(d,w)),[r,w]),g=d=>{const v=Number(d.screenWidth),h=Number(d.screenHeight);return{udid:d.udid,name:d.name,mjpegPort:0,aspect:ie(d),screenWidth:Number.isFinite(v)&&v>0?v:void 0,screenHeight:Number.isFinite(h)&&h>0?h:void 0,platform:d.platform}},x=async d=>{if(e.tiles.some(A=>A.udid===d)){await C(d);return}if(e.recording){t({type:"SET_ERROR_BANNER",message:"Stop recording before changing the devices on the grid."});return}const h=r.find(A=>A.udid===d);if(!h)return;t({type:"ADD_TILE",tile:g(h)});const b=await $.startStream(d).catch(()=>null);ze(b)&&t({type:"REMOVE_TILE",udid:d})},C=async d=>{t({type:"REMOVE_TILE",udid:d});try{await fetch(`/xenon/api/control/${encodeURIComponent(d)}/stream/stop`,{method:"POST"})}catch{}y(v=>v+1)},_=(d,v,h)=>{if(!e.groupId)return;const b=e.groupId,A=e.startedAt?Date.now()-e.startedAt:0,k={recordingId:d,timecodeMs:A,shape:v.shape,geometry:JSON.stringify(v.geometry),color:v.color,text:v.text};N.current.enqueue(async()=>{try{return await be(b,h?{...k,image:h}:k)}catch(f){if(!h)throw f;return be(b,k)}}).catch(f=>t({type:"SET_ERROR_BANNER",message:`Annotation failed: ${f.message}`}))},M=()=>{if(!e.groupId)return;const d=e.groupId,v=e.startedAt?Date.now()-e.startedAt:0;t({type:"CLEAR_OVERLAY_ANNOTATIONS"}),N.current.enqueue(()=>Ft(d,v)).catch(()=>t({type:"SET_ERROR_BANNER",message:"Couldn't clear marks from the recording. They will still appear in the video."}))},T=()=>{for(const d of e.tiles){const v=`/xenon/api/control/${encodeURIComponent(d.udid)}/stream/stop`;try{navigator.sendBeacon?navigator.sendBeacon(v):fetch(v,{method:"POST",keepalive:!0}).catch(()=>{})}catch{}}e.tiles.forEach(d=>t({type:"REMOVE_TILE",udid:d.udid}))},P=tr({idleAfterMs:rr,warningSec:nr,enabled:e.tiles.length>0,onWarning:()=>{},onTimeout:()=>{T()}});return n.jsxs(Ee.Provider,{value:{state:e,dispatch:t},children:[n.jsxs("div",{className:"flex flex-col h-full p-4 gap-3",children:[n.jsxs("header",{className:"flex items-center justify-between gap-3",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(qe,{icon:Ye,children:"Live devices"}),n.jsx(dt,{value:e.layout,onChange:d=>t({type:"SET_LAYOUT",layout:d})})]}),n.jsx(qt,{selectedUdids:e.tiles.map(d=>d.udid),onClearMarks:M})]}),e.banner&&n.jsxs("div",{role:"alert",className:`text-sm rounded border px-3 py-2 flex items-center gap-2 ${e.banner.tone==="error"?"border-[rgb(var(--rgb-red)/0.4)] bg-[rgb(var(--rgb-red)/0.1)] text-[var(--red-100)]":"border-[rgb(var(--rgb-success)/0.4)] bg-[rgb(var(--rgb-success)/0.1)] text-[var(--text)]"}`,children:[n.jsx("span",{className:"flex-1",children:e.banner.message}),n.jsx("button",{type:"button",className:"text-xs opacity-80 hover:opacity-100",onClick:()=>t({type:"SET_BANNER",banner:null}),children:"Dismiss"})]}),n.jsxs("div",{className:"grid grid-cols-[260px_1fr] gap-3 flex-1 min-h-0",children:[n.jsxs("aside",{className:"flex flex-col gap-2 border border-[var(--border)] rounded p-3 overflow-y-auto min-h-0",children:[n.jsxs("div",{className:"flex items-center justify-between",children:[n.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Devices"}),n.jsx("button",{className:"text-xs underline opacity-70 hover:opacity-100",onClick:()=>y(d=>d+1),children:"Refresh"})]}),n.jsx(ct,{devices:S,inMosaic:i,onToggle:x,status:s}),n.jsx("p",{className:"mt-2 text-[11px] text-[var(--text-dim)] leading-relaxed",children:"Click a device to add it to the grid. Record captures every device on the grid; after Stop, download the video."})]}),n.jsx("main",{className:"border border-[var(--border)] rounded p-2 overflow-y-auto h-full min-h-0",children:n.jsx(Yt,{layout:e.layout,tiles:e.tiles,annotateMode:e.annotateMode,shape:e.shape,color:e.color,overlayAnnotationsByRecording:e.overlayAnnotations,onOverlayAnnotationsChange:(d,v)=>t({type:"SET_OVERLAY_ANNOTATIONS",recordingId:d,annotations:v}),onAnnotation:_,onRemove:C,onDropDevice:x})})]})]}),P.warning&&P.remainingSec!==null&&n.jsx(Zt,{remainingSec:P.remainingSec,onContinue:P.reset,onReleaseNow:T})]})}export{mr as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./index-
|
|
1
|
+
import{j as s}from"./index-4PUiCXoJ.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-4PUiCXoJ.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,t as at,R as xe,v as it,y as st}from"./index-BHDlQcd6.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,t as at,R as xe,v as it,y as st}from"./index-4PUiCXoJ.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-4PUiCXoJ.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,4 +1,4 @@
|
|
|
1
|
-
import{c as n,j as s,D as h}from"./index-
|
|
1
|
+
import{c as n,j as s,D as h}from"./index-4PUiCXoJ.js";import{B as r}from"./button-Kv_nqg_I.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 t}from"./index-
|
|
1
|
+
import{j as t}from"./index-4PUiCXoJ.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{c as p,x as z,r as c,X as m,j as e,S as k,D as N,O as I,P as $}from"./index-
|
|
1
|
+
import{c as p,x as z,r as c,X as m,j as e,S as k,D as N,O as I,P as $}from"./index-4PUiCXoJ.js";/* empty css */import{S,A as F}from"./SettingCard-BJ8-ywEG.js";import{P as B}from"./page-header-DgX21Ndv.js";import{L as T}from"./lock-DnyJ9riq.js";import{C as b}from"./circle-check-CBxV3geR.js";import{A as D}from"./activity-Bv16pTkN.js";import"./button-Kv_nqg_I.js";import"./utils-CDN07tui.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{x as le,r as t,j as e,D as $,Q as g,A as oe}from"./index-BHDlQcd6.js";/* empty css */import{a as L}from"./time-B8FIgwPE.js";import{T as ce,a as de,b as z,c as l,d as me,e as o}from"./Table-DRkkM4OR.js";import{F as m}from"./FieldGroup-DmYZP2j7.js";import{P as O}from"./page-header-DhD-Kua9.js";import{M as B}from"./Modal-C5W8lMJ6.js";import{B as u}from"./button-DrqhMLZ0.js";import{I as H}from"./input-Ilib6feD.js";import{S as M}from"./select-Cfv-njLE.js";import{P as v}from"./plus-B75ovH3O.js";import{T as pe}from"./trash-2-BcQxmJP-.js";import{C as he}from"./check-DYccNk73.js";import{C as xe}from"./copy-BKOm9hko.js";import"./utils-CDN07tui.js";const U=["read","sessions","devices","admin"],W={"7d":"7 days","30d":"30 days","90d":"90 days","1y":"1 year",never:"No expiry"},ue={"7d":7,"30d":30,"90d":90,"1y":365};function Y(i){return i==="never"?null:new Date(Date.now()+ue[i]*864e5).toISOString()}function q(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 Pe=()=>{const{toast:i}=le(),[n,w]=t.useState([]),[b,J]=t.useState([]),[X,N]=t.useState(!0),[G,k]=t.useState(!1),[Q,d]=t.useState(!1),[r,y]=t.useState(null),[C,S]=t.useState(null),[T,_]=t.useState(!1),[p,A]=t.useState(""),[j,I]=t.useState({read:!0,sessions:!0,devices:!1,admin:!1}),[R,P]=t.useState(300),[E,D]=t.useState(""),[h,F]=t.useState("30d"),[x,K]=t.useState(!1),V=s=>{var a;return s?((a=b.find(c=>c.id===s))==null?void 0:a.name)||s.slice(0,8):"Shared"},f=async()=>{N(!0);try{const[s,a]=await Promise.all([fetch("/xenon/api/apikeys",{credentials:"include"}),fetch("/xenon/api/teams",{credentials:"include"})]);if(s.status===403){k(!0),w([]);return}if(!s.ok)throw new Error(`HTTP ${s.status}`);w(await s.json()),a.ok&&J(await a.json()),k(!1)}catch(s){i(`Failed to load API keys: ${s.message}`,"error")}finally{N(!1)}};t.useEffect(()=>{f()},[]);const Z=()=>{A(""),I({read:!0,sessions:!0,devices:!1,admin:!1}),P(300),D(""),F("30d")},ee=async()=>{const s=U.filter(a=>j[a]);if(!p.trim()){i("Key name is required","error");return}if(s.length===0){i("Select at least one scope","error");return}K(!0);try{const a=await fetch("/xenon/api/apikeys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim(),scopes:s,rateLimit:R,teamId:E||null,expiresAt:Y(h)})});if(!a.ok)throw new Error(`HTTP ${a.status}`);const c=await a.json();d(!1),Z(),y({name:p.trim(),raw:c.key}),await f()}catch(a){i(`Create failed: ${a.message}`,"error")}finally{K(!1)}},se=async s=>{S(s);try{const a=await fetch(`/xenon/api/apikeys/${s}`,{method:"DELETE",credentials:"include"});if(!a.ok)throw new Error(`HTTP ${a.status}`);i("Key revoked","success"),await f()}catch(a){i(`Revoke failed: ${a.message}`,"error")}finally{S(null)}},ae=async s=>{try{await navigator.clipboard.writeText(s),_(!0),setTimeout(()=>_(!1),1500)}catch{i("Copy failed — select the text manually","error")}};if(X)return e.jsxs("div",{className:"settings-loading",children:[e.jsx($,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading API keys…"})]});if(G)return e.jsx("div",{className:"settings-container",children:e.jsx(O,{icon:g,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 te=n.length,ie=n.filter(s=>s.scopes.includes("admin")).length,ne=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:g,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(v,{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:te}),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:ie}),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:ne}),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(g,{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(v,{size:16}),e.jsx("span",{children:"Create your first key"})]})]}):e.jsx("div",{className:"data-card",children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsxs(z,{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(me,{children:n.map(s=>e.jsxs(z,{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:V(s.teamId)})}),e.jsx(o,{children:e.jsx("div",{className:"scope-chips",children:s.scopes.split(",").map(a=>{const c=a.trim(),re=c==="admin";return e.jsx("span",{className:`pill-chip ${re?"pill-chip--admin":"pill-chip--scope"}`,children:c},a)})})}),e.jsxs(o,{className:"row-mono",children:[s.rateLimit,"/min"]}),e.jsx(o,{className:"row-mono",children:q(s.lastUsedAt)}),e.jsx(o,{className:"row-mono",children:q(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"}):L(s.expiresAt):"Never"}),e.jsx(o,{style:{textAlign:"right"},children:e.jsxs("button",{type:"button",className:"row-action row-action--danger",disabled:C===s.id,onClick:()=>{window.confirm(`Revoke "${s.name}"? Any client using this key will immediately fail.`)&&se(s.id)},children:[e.jsx(pe,{size:13}),C===s.id?"Revoking…":"Revoke"]})})]},s.id))})]})})]}),e.jsx(B,{open:Q,title:"Create API key",width:520,onClose:()=>d(!1),footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",onClick:()=>d(!1),disabled:x,children:"Cancel"}),e.jsxs(u,{variant:"primary",onClick:ee,disabled:x,children:[x?e.jsx($,{className:"animate-spin",size:18}):e.jsx(v,{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(H,{id:"apikey-name",type:"text",value:p,onChange:s=>A(s.target.value),placeholder:"alice-laptop, ci-main, etc.",className:"w-full",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:U.map(s=>e.jsxs("label",{style:ye,children:[e.jsx("input",{type:"checkbox",checked:j[s],onChange:a=>I({...j,[s]:a.target.checked})}),e.jsx("span",{children:s})]},s))})}),e.jsx(m,{label:"Rate limit (requests/min)",htmlFor:"apikey-ratelimit",children:e.jsx(H,{id:"apikey-ratelimit",type:"number",min:10,step:10,value:R,onChange:s=>P(parseInt(s.target.value)||300),className:"w-full"})}),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(M,{id:"apikey-team",value:E,onChange:s=>D(s.target.value),className:"w-full",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 ${L(Y(h))}.`,htmlFor:"apikey-expiry",children:e.jsx(M,{id:"apikey-expiry",value:h,onChange:s=>F(s.target.value),className:"w-full",children:Object.keys(W).map(s=>e.jsx("option",{value:s,children:W[s]},s))})})]})}),e.jsx(B,{open:!!r,title:r?`Key created: ${r.name}`:"",width:560,onClose:()=>y(null),closeOnOverlayClick:!1,footer:e.jsxs(e.Fragment,{children:[e.jsxs(u,{variant:"primary",onClick:()=>r&&ae(r.raw),disabled:!r,children:[T?e.jsx(he,{size:18}):e.jsx(xe,{size:18}),T?"Copied":"Copy to clipboard"]}),e.jsx(u,{variant:"secondary",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(oe,{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:"rgb(var(--rgb-black) / 0.3)",borderRadius:6,wordBreak:"break-all",fontSize:"0.9em"},children:r.raw})]})})]})},ye={display:"flex",alignItems:"center",gap:6,padding:"6px 12px",background:"rgb(var(--rgb-white) / 0.04)",borderRadius:6,cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em"};export{Pe as ApiKeys};
|
|
1
|
+
import{x as le,r as t,j as e,D as $,Q as g,A as oe}from"./index-4PUiCXoJ.js";/* empty css */import{a as L}from"./time-B8FIgwPE.js";import{T as ce,a as de,b as z,c as l,d as me,e as o}from"./Table-C7XQ4gI0.js";import{F as m}from"./FieldGroup-C_DwE2dP.js";import{P as O}from"./page-header-DgX21Ndv.js";import{M as B}from"./Modal-BCbDzIzg.js";import{B as u}from"./button-Kv_nqg_I.js";import{I as H}from"./input-Cg5C6lE3.js";import{S as M}from"./select-HMxRDgs7.js";import{P as v}from"./plus-DaUKFcvv.js";import{T as pe}from"./trash-2-BDdM7yPO.js";import{C as he}from"./check-DvGXlj1A.js";import{C as xe}from"./copy-CYjhxjiV.js";import"./utils-CDN07tui.js";const U=["read","sessions","devices","admin"],W={"7d":"7 days","30d":"30 days","90d":"90 days","1y":"1 year",never:"No expiry"},ue={"7d":7,"30d":30,"90d":90,"1y":365};function Y(i){return i==="never"?null:new Date(Date.now()+ue[i]*864e5).toISOString()}function q(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 Pe=()=>{const{toast:i}=le(),[n,w]=t.useState([]),[b,J]=t.useState([]),[X,N]=t.useState(!0),[G,k]=t.useState(!1),[Q,d]=t.useState(!1),[r,y]=t.useState(null),[C,S]=t.useState(null),[T,_]=t.useState(!1),[p,A]=t.useState(""),[j,I]=t.useState({read:!0,sessions:!0,devices:!1,admin:!1}),[R,P]=t.useState(300),[E,D]=t.useState(""),[h,F]=t.useState("30d"),[x,K]=t.useState(!1),V=s=>{var a;return s?((a=b.find(c=>c.id===s))==null?void 0:a.name)||s.slice(0,8):"Shared"},f=async()=>{N(!0);try{const[s,a]=await Promise.all([fetch("/xenon/api/apikeys",{credentials:"include"}),fetch("/xenon/api/teams",{credentials:"include"})]);if(s.status===403){k(!0),w([]);return}if(!s.ok)throw new Error(`HTTP ${s.status}`);w(await s.json()),a.ok&&J(await a.json()),k(!1)}catch(s){i(`Failed to load API keys: ${s.message}`,"error")}finally{N(!1)}};t.useEffect(()=>{f()},[]);const Z=()=>{A(""),I({read:!0,sessions:!0,devices:!1,admin:!1}),P(300),D(""),F("30d")},ee=async()=>{const s=U.filter(a=>j[a]);if(!p.trim()){i("Key name is required","error");return}if(s.length===0){i("Select at least one scope","error");return}K(!0);try{const a=await fetch("/xenon/api/apikeys",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:p.trim(),scopes:s,rateLimit:R,teamId:E||null,expiresAt:Y(h)})});if(!a.ok)throw new Error(`HTTP ${a.status}`);const c=await a.json();d(!1),Z(),y({name:p.trim(),raw:c.key}),await f()}catch(a){i(`Create failed: ${a.message}`,"error")}finally{K(!1)}},se=async s=>{S(s);try{const a=await fetch(`/xenon/api/apikeys/${s}`,{method:"DELETE",credentials:"include"});if(!a.ok)throw new Error(`HTTP ${a.status}`);i("Key revoked","success"),await f()}catch(a){i(`Revoke failed: ${a.message}`,"error")}finally{S(null)}},ae=async s=>{try{await navigator.clipboard.writeText(s),_(!0),setTimeout(()=>_(!1),1500)}catch{i("Copy failed — select the text manually","error")}};if(X)return e.jsxs("div",{className:"settings-loading",children:[e.jsx($,{className:"animate-spin",size:32}),e.jsx("span",{children:"Loading API keys…"})]});if(G)return e.jsx("div",{className:"settings-container",children:e.jsx(O,{icon:g,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 te=n.length,ie=n.filter(s=>s.scopes.includes("admin")).length,ne=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:g,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(v,{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:te}),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:ie}),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:ne}),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(g,{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(v,{size:16}),e.jsx("span",{children:"Create your first key"})]})]}):e.jsx("div",{className:"data-card",children:e.jsxs(ce,{children:[e.jsx(de,{children:e.jsxs(z,{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(me,{children:n.map(s=>e.jsxs(z,{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:V(s.teamId)})}),e.jsx(o,{children:e.jsx("div",{className:"scope-chips",children:s.scopes.split(",").map(a=>{const c=a.trim(),re=c==="admin";return e.jsx("span",{className:`pill-chip ${re?"pill-chip--admin":"pill-chip--scope"}`,children:c},a)})})}),e.jsxs(o,{className:"row-mono",children:[s.rateLimit,"/min"]}),e.jsx(o,{className:"row-mono",children:q(s.lastUsedAt)}),e.jsx(o,{className:"row-mono",children:q(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"}):L(s.expiresAt):"Never"}),e.jsx(o,{style:{textAlign:"right"},children:e.jsxs("button",{type:"button",className:"row-action row-action--danger",disabled:C===s.id,onClick:()=>{window.confirm(`Revoke "${s.name}"? Any client using this key will immediately fail.`)&&se(s.id)},children:[e.jsx(pe,{size:13}),C===s.id?"Revoking…":"Revoke"]})})]},s.id))})]})})]}),e.jsx(B,{open:Q,title:"Create API key",width:520,onClose:()=>d(!1),footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",onClick:()=>d(!1),disabled:x,children:"Cancel"}),e.jsxs(u,{variant:"primary",onClick:ee,disabled:x,children:[x?e.jsx($,{className:"animate-spin",size:18}):e.jsx(v,{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(H,{id:"apikey-name",type:"text",value:p,onChange:s=>A(s.target.value),placeholder:"alice-laptop, ci-main, etc.",className:"w-full",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:U.map(s=>e.jsxs("label",{style:ye,children:[e.jsx("input",{type:"checkbox",checked:j[s],onChange:a=>I({...j,[s]:a.target.checked})}),e.jsx("span",{children:s})]},s))})}),e.jsx(m,{label:"Rate limit (requests/min)",htmlFor:"apikey-ratelimit",children:e.jsx(H,{id:"apikey-ratelimit",type:"number",min:10,step:10,value:R,onChange:s=>P(parseInt(s.target.value)||300),className:"w-full"})}),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(M,{id:"apikey-team",value:E,onChange:s=>D(s.target.value),className:"w-full",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 ${L(Y(h))}.`,htmlFor:"apikey-expiry",children:e.jsx(M,{id:"apikey-expiry",value:h,onChange:s=>F(s.target.value),className:"w-full",children:Object.keys(W).map(s=>e.jsx("option",{value:s,children:W[s]},s))})})]})}),e.jsx(B,{open:!!r,title:r?`Key created: ${r.name}`:"",width:560,onClose:()=>y(null),closeOnOverlayClick:!1,footer:e.jsxs(e.Fragment,{children:[e.jsxs(u,{variant:"primary",onClick:()=>r&&ae(r.raw),disabled:!r,children:[T?e.jsx(he,{size:18}):e.jsx(xe,{size:18}),T?"Copied":"Copy to clipboard"]}),e.jsx(u,{variant:"secondary",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(oe,{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:"rgb(var(--rgb-black) / 0.3)",borderRadius:6,wordBreak:"break-all",fontSize:"0.9em"},children:r.raw})]})})]})},ye={display:"flex",alignItems:"center",gap:6,padding:"6px 12px",background:"rgb(var(--rgb-white) / 0.04)",borderRadius:6,cursor:"pointer",fontFamily:"monospace",fontSize:"0.9em"};export{Pe as ApiKeys};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as x,j as e,x as H,r,X as o,G as X,q as I,z as K,D as Z,y as J}from"./index-
|
|
1
|
+
import{c as x,j as e,x as H,r,X as o,G as X,q as I,z as K,D as Z,y as J}from"./index-4PUiCXoJ.js";import{f as Q}from"./time-B8FIgwPE.js";import{c as ee,B as w}from"./button-Kv_nqg_I.js";import{c as se}from"./utils-CDN07tui.js";import{P as ae}from"./page-header-DgX21Ndv.js";import{S as te}from"./select-HMxRDgs7.js";import{U as re,T as $}from"./upload-C1vqAOQK.js";import{C as ie}from"./check-DvGXlj1A.js";import{C as ce}from"./copy-CYjhxjiV.js";import{Z as ne}from"./zap-CduRPXBS.js";import{D as le}from"./download-2y5oRiK2.js";import{T as oe}from"./trash-2-BDdM7yPO.js";/**
|
|
2
2
|
* @license lucide-react v0.555.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as i,j as e,n,S as o}from"./index-
|
|
1
|
+
import{c as i,j as e,n,S as o}from"./index-4PUiCXoJ.js";import{N as l}from"./network-ULTYYDWq.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 d=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],c=i("monitor-smartphone",d),x=[{icon:o,title:"Self-healing selectors",body:"Broken locators recover through six escalating tiers before a test fails."},{icon:c,title:"Live Android & iOS devices",body:"Watch, drive and record real devices from the browser."},{icon:l,title:"Hub–node scaling",body:"One hub orchestrates device labs across machines."}];function b({children:t}){return e.jsxs("div",{className:"grid min-h-screen w-full grid-cols-1 bg-[var(--bg)] text-[var(--text)] md:grid-cols-[minmax(0,5fr)_minmax(0,7fr)]",children:[e.jsxs("aside",{className:"relative hidden overflow-hidden border-r border-[rgb(var(--rgb-fg)/0.06)] bg-[var(--surface-sunken)] md:flex md:flex-col",children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_90%_60%_at_0%_0%,rgb(var(--rgb-accent)/0.14),transparent_60%)]"}),e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-[linear-gradient(to_right,rgb(var(--rgb-white)/0.03)_1px,transparent_1px),linear-gradient(to_bottom,rgb(var(--rgb-white)/0.03)_1px,transparent_1px)] bg-[size:48px_48px] [mask-image:linear-gradient(to_bottom,black,transparent_85%)]"}),e.jsxs("div",{className:"relative flex flex-1 flex-col justify-between px-12 py-10",children:[e.jsx(n,{className:"h-8 w-auto self-start object-contain"}),e.jsxs("div",{className:"max-w-md",children:[e.jsxs("h2",{className:"text-4xl font-semibold leading-tight tracking-tight",children:["Your device lab,",e.jsx("br",{}),e.jsx("span",{className:"text-[var(--color-accent)]",children:"under control."})]}),e.jsx("p",{className:"mt-4 text-sm leading-relaxed text-[var(--text-muted)]",children:"Appium orchestration for the devices you own — with self-healing tests, live streaming and recordable proof of what ran."}),e.jsx("ul",{className:"mt-10 space-y-6",children:x.map(({icon:a,title:r,body:s})=>e.jsxs("li",{className:"flex gap-4",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-[var(--accent-border)] bg-[var(--accent-subtle)]",children:e.jsx(a,{className:"h-4 w-4 text-[var(--color-accent)]","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text)]",children:r}),e.jsx("div",{className:"mt-0.5 text-sm text-[var(--text-muted)]",children:s})]})]},r))})]}),e.jsxs("footer",{className:"flex items-center justify-between border-t border-[rgb(var(--rgb-fg)/0.06)] pt-5 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Xenon v","1.22.
|
|
6
|
+
*/const d=[["path",{d:"M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8",key:"10dyio"}],["path",{d:"M10 19v-3.96 3.15",key:"1irgej"}],["path",{d:"M7 19h5",key:"qswx4l"}],["rect",{width:"6",height:"10",x:"16",y:"12",rx:"2",key:"1egngj"}]],c=i("monitor-smartphone",d),x=[{icon:o,title:"Self-healing selectors",body:"Broken locators recover through six escalating tiers before a test fails."},{icon:c,title:"Live Android & iOS devices",body:"Watch, drive and record real devices from the browser."},{icon:l,title:"Hub–node scaling",body:"One hub orchestrates device labs across machines."}];function b({children:t}){return e.jsxs("div",{className:"grid min-h-screen w-full grid-cols-1 bg-[var(--bg)] text-[var(--text)] md:grid-cols-[minmax(0,5fr)_minmax(0,7fr)]",children:[e.jsxs("aside",{className:"relative hidden overflow-hidden border-r border-[rgb(var(--rgb-fg)/0.06)] bg-[var(--surface-sunken)] md:flex md:flex-col",children:[e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_90%_60%_at_0%_0%,rgb(var(--rgb-accent)/0.14),transparent_60%)]"}),e.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 bg-[linear-gradient(to_right,rgb(var(--rgb-white)/0.03)_1px,transparent_1px),linear-gradient(to_bottom,rgb(var(--rgb-white)/0.03)_1px,transparent_1px)] bg-[size:48px_48px] [mask-image:linear-gradient(to_bottom,black,transparent_85%)]"}),e.jsxs("div",{className:"relative flex flex-1 flex-col justify-between px-12 py-10",children:[e.jsx(n,{className:"h-8 w-auto self-start object-contain"}),e.jsxs("div",{className:"max-w-md",children:[e.jsxs("h2",{className:"text-4xl font-semibold leading-tight tracking-tight",children:["Your device lab,",e.jsx("br",{}),e.jsx("span",{className:"text-[var(--color-accent)]",children:"under control."})]}),e.jsx("p",{className:"mt-4 text-sm leading-relaxed text-[var(--text-muted)]",children:"Appium orchestration for the devices you own — with self-healing tests, live streaming and recordable proof of what ran."}),e.jsx("ul",{className:"mt-10 space-y-6",children:x.map(({icon:a,title:r,body:s})=>e.jsxs("li",{className:"flex gap-4",children:[e.jsx("span",{className:"grid h-9 w-9 shrink-0 place-items-center rounded-lg border border-[var(--accent-border)] bg-[var(--accent-subtle)]",children:e.jsx(a,{className:"h-4 w-4 text-[var(--color-accent)]","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--text)]",children:r}),e.jsx("div",{className:"mt-0.5 text-sm text-[var(--text-muted)]",children:s})]})]},r))})]}),e.jsxs("footer",{className:"flex items-center justify-between border-t border-[rgb(var(--rgb-fg)/0.06)] pt-5 text-xs text-[var(--text-muted)]",children:[e.jsxs("span",{children:["Xenon v","1.22.3"," · Self-hosted device lab"]}),e.jsx("a",{href:"/xenon/api-docs",target:"_blank",rel:"noreferrer",className:"text-[var(--text-muted)] underline-offset-4 hover:text-[var(--text)] hover:underline",children:"API docs"})]})]})]}),e.jsx("main",{className:"flex items-center justify-center px-6 py-10",children:e.jsx("div",{className:"w-full max-w-[400px] rounded-xl border border-[var(--border)] bg-[var(--surface)] px-8 py-9 shadow-[var(--shadow-lg)]",children:t})})]})}export{b as A};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as z,j as e,z as E,w as y,T as H,q as X,r as v,u as q,i as Q,x as V,M as G,X as J}from"./index-
|
|
1
|
+
import{c as z,j as e,z as E,w as y,T as H,q as X,r as v,u as q,i as Q,x as V,M as G,X as J}from"./index-4PUiCXoJ.js";import{f as R,s as $,b as T,a as A,d as K,p as W,o as Y,S as Z,h as ee,c as te,e as D,u as se}from"./status-pill-outline-C5m6HFzT.js";import{A as ae}from"./activity-Bv16pTkN.js";import{C as re}from"./circle-x-X-nHBZnY.js";import{C as ne}from"./circle-check-CBxV3geR.js";import{I as P}from"./input-Cg5C6lE3.js";import{S as le}from"./select-HMxRDgs7.js";import{C as oe}from"./clock-lLny_RuH.js";import{B as I}from"./button-Kv_nqg_I.js";import{D as ie}from"./download-2y5oRiK2.js";import{s as ce}from"./labels-C21SA4JG.js";import{C as de}from"./chevron-right-CuPozn4T.js";import{T as xe,M as ue}from"./tablet-2ogUZZch.js";import{P as me}from"./page-header-DgX21Ndv.js";import"./time-B8FIgwPE.js";import"./utils-CDN07tui.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{r as x,j as z}from"./index-
|
|
1
|
+
import{r as x,j as z}from"./index-4PUiCXoJ.js";import{a as j,c as g}from"./utils-CDN07tui.js";const v=a=>typeof a=="boolean"?`${a}`:a===0?"0":a,b=j,k=(a,e)=>t=>{var r;if((e==null?void 0:e.variants)==null)return b(a,t==null?void 0:t.class,t==null?void 0:t.className);const{variants:o,defaultVariants:l}=e,y=Object.keys(o).map(n=>{const s=t==null?void 0:t[n],d=l==null?void 0:l[n];if(s===null)return null;const i=v(s)||v(d);return o[n][i]}),c=t&&Object.entries(t).reduce((n,s)=>{let[d,i]=s;return i===void 0||(n[d]=i),n},{}),f=e==null||(r=e.compoundVariants)===null||r===void 0?void 0:r.reduce((n,s)=>{let{class:d,className:i,...V}=s;return Object.entries(V).every(N=>{let[m,u]=N;return Array.isArray(u)?u.includes({...l,...c}[m]):{...l,...c}[m]===u})?[...n,d,i]:n},[]);return b(a,y,f,t==null?void 0:t.class,t==null?void 0:t.className)},C=k("btn-base",{variants:{variant:{default:"btn-primary",primary:"btn-primary",secondary:"btn-secondary",outline:"btn-secondary",ghost:"btn-ghost",link:"btn-link",destructive:"btn-danger",danger:"btn-danger"},size:{default:"btn-size-md",md:"btn-size-md",sm:"btn-size-sm",lg:"btn-size-lg",icon:"btn-size-icon"}},defaultVariants:{variant:"primary",size:"md"}}),O=x.forwardRef(({className:a,variant:e,size:t,...r},o)=>z.jsx("button",{className:g(C({variant:e,size:t,className:a})),ref:o,...r}));O.displayName="Button";export{O as B,k as c};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{c as e}from"./index-4PUiCXoJ.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const o=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],t=e("chevron-left",o);export{t as C};
|