@xenon-device-management/xenon 2.13.1 → 2.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/lib/package.json +1 -1
  2. package/lib/public/assets/{AnnotationOverlay-Cvpkk4r9.js → AnnotationOverlay-BXruClDk.js} +1 -1
  3. package/lib/public/assets/{ApiKeyGate-Bhn5ZtVM.js → ApiKeyGate-qTS4LPLC.js} +1 -1
  4. package/lib/public/assets/{BugReportButton-BA6aEjTC.js → BugReportButton-BoGhlI7F.js} +1 -1
  5. package/lib/public/assets/{DeviceMosaicView-ChhHnpFQ.js → DeviceMosaicView-8J0oYqMM.js} +1 -1
  6. package/lib/public/assets/{EmptyState-CgzbuUvO.js → EmptyState-Cr17PdDv.js} +1 -1
  7. package/lib/public/assets/{FieldGroup-BHc_5qNc.js → FieldGroup-Bvn08svv.js} +1 -1
  8. package/lib/public/assets/{FilterMenu-D7OMGuRc.js → FilterMenu-DDSO8aDf.js} +1 -1
  9. package/lib/public/assets/{Menu-C173JJ0l.js → Menu-B-Qn2X3T.js} +1 -1
  10. package/lib/public/assets/{Modal-ChvVUI3B.js → Modal-Cg9V5JYU.js} +1 -1
  11. package/lib/public/assets/{RecordingPage-Dhw4d_O6.js → RecordingPage-BTUs9VTW.js} +1 -1
  12. package/lib/public/assets/{RecordingsPage-z97ftGK-.js → RecordingsPage-DYcfxITK.js} +1 -1
  13. package/lib/public/assets/{SegmentedControl-DbXhBGZC.js → SegmentedControl-Zy7suhT5.js} +1 -1
  14. package/lib/public/assets/{SettingCard-C908GgiI.js → SettingCard-CWYmycoe.js} +1 -1
  15. package/lib/public/assets/{Table-B1DB_ZN-.js → Table-io9fwa98.js} +1 -1
  16. package/lib/public/assets/{activity-Css0xNvp.js → activity-Bdf_uIWl.js} +1 -1
  17. package/lib/public/assets/{ai-settings-BMQK3-yN.js → ai-settings-Bce5SJob.js} +1 -1
  18. package/lib/public/assets/{api-keys-CbJ42eDQ.js → api-keys-CPqtVpm3.js} +1 -1
  19. package/lib/public/assets/{apps-DW1pw2re.js → apps-BgZan0H9.js} +1 -1
  20. package/lib/public/assets/{arrow-left-Dpog9L0F.js → arrow-left-B27ckB31.js} +1 -1
  21. package/lib/public/assets/{arrow-right-CsBIlSIw.js → arrow-right-DOF8ITCz.js} +1 -1
  22. package/lib/public/assets/{arrow-up-right-z1tRQE4R.js → arrow-up-right-eFG5KTFS.js} +1 -1
  23. package/lib/public/assets/{auth-shell-mXiX5vNk.js → auth-shell-DlC3_27j.js} +2 -2
  24. package/lib/public/assets/{builds-page-BcFn23bE.js → builds-page-BuXpPfKo.js} +1 -1
  25. package/lib/public/assets/{button-Cq_zHETv.js → button-fIW8owMI.js} +1 -1
  26. package/lib/public/assets/{calendar-CKxABX9q.js → calendar-WNjmrF-a.js} +1 -1
  27. package/lib/public/assets/{check-C7xu-hGU.js → check-BdTh1Sq7.js} +1 -1
  28. package/lib/public/assets/{chevron-right-BiqfdCGA.js → chevron-right-B4BKlsqk.js} +1 -1
  29. package/lib/public/assets/{circle-check-CyBjjPxR.js → circle-check-zJU80_EF.js} +1 -1
  30. package/lib/public/assets/{circle-x-6gMRcx6z.js → circle-x-5Uwquo0h.js} +1 -1
  31. package/lib/public/assets/{clock-U1rDTT1h.js → clock-BtUprDsZ.js} +1 -1
  32. package/lib/public/assets/{copy-BIM0ZX0L.js → copy-DGSbZI3u.js} +1 -1
  33. package/lib/public/assets/{device-explorer-DSpAA_t9.js → device-explorer-C-KnhMHI.js} +1 -1
  34. package/lib/public/assets/{download-DDBRXnAZ.js → download-WG6l7BgD.js} +1 -1
  35. package/lib/public/assets/{forgot-password-Dpg7yxM8.js → forgot-password-DnudqFFo.js} +1 -1
  36. package/lib/public/assets/{index-BTYMAqNW.css → index-Bxoxt9sV.css} +1 -1
  37. package/lib/public/assets/{index-BGBqohfQ.js → index-DI1fGIyj.js} +2 -2
  38. package/lib/public/assets/{index-BQ2luT7L.js → index-HDQVe1gi.js} +1 -1
  39. package/lib/public/assets/{input-BvB1cjHE.js → input-BjDRKCea.js} +1 -1
  40. package/lib/public/assets/{line-chart-m78VggnW.js → line-chart-C0zdgd0v.js} +1 -1
  41. package/lib/public/assets/{list-checks-cY7o1QTL.js → list-checks-BdW5CjM8.js} +1 -1
  42. package/lib/public/assets/{lock-loz8txQm.js → lock-Dy3L4I8E.js} +1 -1
  43. package/lib/public/assets/{login-BYOvz4lx.js → login-BHbY9CLG.js} +1 -1
  44. package/lib/public/assets/{maintenance-settings-BxbA7SkB.js → maintenance-settings-zDVlOMVK.js} +1 -1
  45. package/lib/public/assets/{monitor-C4HPHb6s.js → monitor-8xjkeHHi.js} +1 -1
  46. package/lib/public/assets/{mouse-pointer-2-BkdKtCzi.js → mouse-pointer-2-CXdKMXQ8.js} +1 -1
  47. package/lib/public/assets/{network-C5e0MIWo.js → network-Cj8JOKON.js} +1 -1
  48. package/lib/public/assets/{overview-tlu8ijGd.js → overview-CTg7F0im.js} +1 -1
  49. package/lib/public/assets/{page-header-FXPlo6az.js → page-header--aTyJXq6.js} +1 -1
  50. package/lib/public/assets/{play-CWdk0_Sy.js → play-B-FodgHV.js} +1 -1
  51. package/lib/public/assets/{plus-B2xCnntV.js → plus-CsIk10Cq.js} +1 -1
  52. package/lib/public/assets/{profile-page-D080qzr4.js → profile-page-DkFKkMfl.js} +1 -1
  53. package/lib/public/assets/{recording-group-store-B75435xR.js → recording-group-store-WVM3hoXn.js} +1 -1
  54. package/lib/public/assets/{reset-password-D3u4Mbvn.js → reset-password-I2-zqLlI.js} +1 -1
  55. package/lib/public/assets/{runbook-page-hPRZMy7s.js → runbook-page-DJTVCJX7.js} +1 -1
  56. package/lib/public/assets/{select-12RThAXc.js → select-DvCSv25z.js} +1 -1
  57. package/lib/public/assets/{selector-detail-redirect-uQwvV7EQ.js → selector-detail-redirect-BLVfMJs_.js} +1 -1
  58. package/lib/public/assets/{selector-health-page-CThoxDFO.js → selector-health-page-oqadRokn.js} +1 -1
  59. package/lib/public/assets/session-detail-page-CGn55Pvl.js +4 -0
  60. package/lib/public/assets/{settings-C1VIluuT.js → settings-MsVU2ukE.js} +1 -1
  61. package/lib/public/assets/{stat-tile-B02WEte8.js → stat-tile-DV9Ix-4O.js} +1 -1
  62. package/lib/public/assets/{tablet-Dj30VGZl.js → tablet-6b_SEN2X.js} +1 -1
  63. package/lib/public/assets/{teams-uL4fjTDR.js → teams-BjZyfuHh.js} +1 -1
  64. package/lib/public/assets/{trash-2-B54e-TfY.js → trash-2-CTZpPSdd.js} +1 -1
  65. package/lib/public/assets/{upload-B3k8WCSP.js → upload-P3XzwQUb.js} +1 -1
  66. package/lib/public/assets/{use-builds-data-BFn90NH3.js → use-builds-data-1cOCMf-z.js} +1 -1
  67. package/lib/public/assets/{use-password-reset-mode-DL2TmWZ0.js → use-password-reset-mode-DgF9w088.js} +1 -1
  68. package/lib/public/assets/{users-DjQSucKb.js → users-CiNTKUiz.js} +1 -1
  69. package/lib/public/assets/{users-CqBuxMlX.js → users-DMF9Mk5H.js} +1 -1
  70. package/lib/public/assets/{video-off-T0rlt0GA.js → video-off-CHp1KU_T.js} +1 -1
  71. package/lib/public/assets/{webhook-settings-DAHgnJyZ.js → webhook-settings-DiS8geIm.js} +1 -1
  72. package/lib/public/assets/{zap-gBHqutZV.js → zap-DRz0tDq5.js} +1 -1
  73. package/lib/public/index.html +2 -2
  74. package/lib/schema.json +0 -25
  75. package/lib/src/app/routers/control.js +19 -4
  76. package/lib/src/app/routers/streamStartConflict.js +3 -0
  77. package/lib/src/data-service/device-service.js +40 -0
  78. package/lib/src/data-service/device-store.js +4 -1
  79. package/lib/src/data-service/prisma-store.js +2 -1
  80. package/lib/src/device-utils.js +63 -13
  81. package/lib/src/middleware/deviceAccessGuard.js +63 -9
  82. package/lib/src/services/ServerManager.js +3 -0
  83. package/lib/src/services/SessionLifecycleService.js +16 -4
  84. package/lib/src/services/device-access/SessionOwnerResolver.js +26 -0
  85. package/lib/src/services/device-access/deviceAccessPolicy.js +38 -6
  86. package/lib/src/services/device-access/leaseHold.js +26 -0
  87. package/lib/src/services/device-access/ticketActorAccess.js +6 -0
  88. package/lib/src/services/lease/activeLeases.js +37 -0
  89. package/lib/src/services/recording/busy-precheck.js +24 -3
  90. package/lib/test/unit/device-access-lease.spec.js +270 -0
  91. package/lib/test/unit/lease/allocate-lease-branch.spec.js +22 -0
  92. package/lib/test/unit/lease/session-lease-proof.spec.js +59 -0
  93. package/lib/test/unit/lease-held-phone.spec.js +196 -0
  94. package/lib/test/unit/partial-config-file.spec.js +100 -0
  95. package/lib/test/unit/schema-required-args.spec.js +21 -16
  96. package/lib/tsconfig.tsbuildinfo +1 -1
  97. package/package.json +1 -1
  98. package/schema.json +0 -25
  99. package/scripts/generate-types-from-schema.js +6 -0
  100. package/scripts/lib/always-present-plugin-args.js +39 -0
  101. package/lib/public/assets/session-detail-page-Bc02YjMm.js +0 -4
package/lib/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xenon-device-management/xenon",
3
- "version": "2.13.1",
3
+ "version": "2.13.2",
4
4
  "description": "Xenon - Intelligent Mobile Infrastructure. A self-healing device orchestration platform for Appium.",
5
5
  "main": "./lib/src/index.js",
6
6
  "exports": {
@@ -1 +1 @@
1
- import{r as w,j as _}from"./index-BGBqohfQ.js";const F=1600;function j(t,r){const e=F/Math.max(t,r);return{w:Math.round(t*e),h:Math.round(r*e)}}function B(t,r,e,s=document){if(r<=0||e<=0)return null;const{w:o,h:f}=j(r,e),l=s.createElement("canvas");l.width=o,l.height=f;const y=l.getContext("2d");if(!y)return null;y.scale(o/r,f/e),Y(y,r,e,t);try{return l.toDataURL("image/png")}catch{return null}}function U(t,r,e){const s={left:0,top:0,width:t,height:r};if(!e||!(e>0)||t<=0||r<=0)return s;const o=t/r;if(Math.abs(o-e)<1e-6)return s;if(e>o){const l=t/e;return{left:0,top:(r-l)/2,width:t,height:l}}const f=r*e;return{left:(t-f)/2,top:0,width:f,height:r}}const G=(t,r)=>t===r||!!t&&!!r&&t.left===r.left&&t.top===r.top&&t.width===r.width&&t.height===r.height,J=2,q=2e3;function D(t,r,e){if(t.length>=q)return t;const s=t[t.length-1];return s&&Math.hypot(r-s[0],e-s[1])<J?t:[...t,[r,e]]}function $(t,r){const e=(t||"#ff3333").trim();if(/^#[0-9a-fA-F]{6}$/.test(e)){const s=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),f=parseInt(e.slice(5,7),16);return`rgba(${s},${o},${f},${r})`}return e}function Y(t,r,e,s){var S;const o=s.geometry,f=s.color||"#ff3333",l=Math.max(4,Math.round(Math.min(r,e)*.008));if(t.lineCap="round",t.lineJoin="round",s.shape==="CIRCLE"){const h=(o.x??0)*r,M=(o.y??0)*e,p=Math.max(2,(o.w??0)*r),a=Math.max(2,(o.h??0)*e);t.beginPath(),t.ellipse(h,M,p,a,0,0,Math.PI*2),t.fillStyle=$(f,.22),t.fill(),t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",t.stroke(),t.beginPath(),t.ellipse(h,M,p,a,0,0,Math.PI*2),t.lineWidth=l,t.strokeStyle=f,t.stroke();return}if(s.shape==="ARROW"){const h=(o.x??0)*r,M=(o.y??0)*e,p=h+(o.w??0)*r,a=M+(o.h??0)*e;t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",t.beginPath(),t.moveTo(h,M),t.lineTo(p,a),t.stroke(),t.lineWidth=l,t.strokeStyle=f,t.beginPath(),t.moveTo(h,M),t.lineTo(p,a),t.stroke();const P=Math.atan2(a-M,p-h),k=Math.max(14,l*3);t.fillStyle=f,t.beginPath(),t.moveTo(p,a),t.lineTo(p-k*Math.cos(P-.4),a-k*Math.sin(P-.4)),t.lineTo(p-k*Math.cos(P+.4),a-k*Math.sin(P+.4)),t.closePath(),t.fill();return}if(s.shape==="TEXT"&&s.text){const h=Math.max(16,Math.round(Math.min(r,e)*.035));t.font=`bold ${h}px sans-serif`,t.lineWidth=3,t.strokeStyle="rgba(0,0,0,0.65)",t.strokeText(s.text,(o.x??0)*r,(o.y??0)*e),t.fillStyle=f,t.fillText(s.text,(o.x??0)*r,(o.y??0)*e);return}if(s.shape==="FREEHAND"&&(((S=o.points)==null?void 0:S.length)??0)>=2){const h=o.points,M=()=>{t.beginPath(),t.moveTo(h[0][0]*r,h[0][1]*e);for(let p=1;p<h.length;p++)t.lineTo(h[p][0]*r,h[p][1]*e)};t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",M(),t.stroke(),t.lineWidth=l,t.strokeStyle=f,M(),t.stroke();return}const y=(o.x??0)*r,R=(o.y??0)*e,c=Math.max(2,(o.w??0)*r),g=Math.max(2,(o.h??0)*e);t.fillStyle=$(f,.22),t.fillRect(y,R,c,g),t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",t.strokeRect(y,R,c,g),t.lineWidth=l,t.strokeStyle=f,t.strokeRect(y,R,c,g)}function O(t,r,e,s,o){if(s<=0||o<=0)return null;if(t==="CIRCLE"){const c=Math.hypot(e.curX-e.startX,e.curY-e.startY);return c<=4?null:{shape:t,color:r,geometry:{x:e.startX/s,y:e.startY/o,w:c/s,h:c/o}}}if(t==="ARROW"){const c=e.curX-e.startX,g=e.curY-e.startY;return Math.hypot(c,g)<=6?null:{shape:t,color:r,geometry:{x:e.startX/s,y:e.startY/o,w:c/s,h:g/o}}}if(t==="FREEHAND"){if(e.points.length<2)return null;const c=e.points.map(M=>M[0]),g=e.points.map(M=>M[1]),S=Math.min(...c),h=Math.min(...g);return{shape:t,color:r,geometry:{x:S/s,y:h/o,w:Math.max(.005,(Math.max(...c)-S)/s),h:Math.max(.005,(Math.max(...g)-h)/o),points:e.points.map(([M,p])=>[M/s,p/o])}}}const f=Math.min(e.startX,e.curX)/s,l=Math.min(e.startY,e.curY)/o,y=Math.abs(e.curX-e.startX)/s,R=Math.abs(e.curY-e.startY)/o;return y<=.005||R<=.005?null:{shape:t,color:r,geometry:{x:f,y:l,w:y,h:R}}}function K({enabled:t,shape:r,color:e,onCommit:s,committed:o,onCommittedChange:f,mediaAspect:l}){const y=w.useRef(null),[R,c]=w.useState(null),[g,S]=w.useState([]),[h,M]=w.useState(null),p=o??g,a=w.useRef(p),P=w.useRef(R),k=w.useRef(r),X=w.useRef(e),I=w.useRef(t);a.current=p,P.current=R,k.current=r,X.current=e,I.current=t;const b=w.useCallback(n=>{const i=n(a.current);a.current=i,f?f(i):S(i)},[f]),T=w.useCallback(()=>{const n=y.current;if(!n)return;const i=n.getContext("2d");if(!i)return;i.clearRect(0,0,n.width,n.height);for(const m of a.current)Y(i,n.width,n.height,m);const u=P.current;if(u){const m=O(k.current,X.current,u,n.width,n.height);m&&Y(i,n.width,n.height,m)}},[]);w.useEffect(()=>{const n=y.current;if(!n)return;const i=()=>{const m=Math.max(1,Math.round(n.clientWidth)),d=Math.max(1,Math.round(n.clientHeight));(n.width!==m||n.height!==d)&&(n.width=m,n.height=d),T()};i();const u=new ResizeObserver(i);return u.observe(n),()=>u.disconnect()},[T]),w.useEffect(()=>{T()},[R,p,T]),w.useEffect(()=>{var m;const n=(m=y.current)==null?void 0:m.parentElement;if(!n)return;const i=()=>{const d=l?U(n.clientWidth,n.clientHeight,l):null;M(E=>G(E,d)?E:d)};i();const u=new ResizeObserver(i);return u.observe(n),()=>u.disconnect()},[l]),w.useEffect(()=>{var i;if(t)return;c(null);const n=y.current;if(n&&n.hasPointerCapture)try{for(let u=0;u<8;u++)(i=n.hasPointerCapture)!=null&&i.call(n,u)&&n.releasePointerCapture(u)}catch{}},[t]);const C=n=>{const u=y.current.getBoundingClientRect();return{px:n.clientX-u.left,py:n.clientY-u.top,w:u.width,h:u.height}},z=n=>{const i=P.current;if(!i||!I.current){c(null);return}const u=y.current;if(!u||u.width<=0){c(null);return}const m=C(n),d=O(k.current,X.current,{...i,curX:m.px,curY:m.py,points:D(i.points,m.px,m.py)},m.w,m.h);d&&(b(E=>[...E,d]),s(d,B(d,m.w,m.h))),c(null)},N=n=>{if(!t||n.button!==0)return;n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId);const i=C(n);c({startX:i.px,startY:i.py,curX:i.px,curY:i.py,points:[[i.px,i.py]]})},L=n=>{if(!P.current)return;const i=C(n);c(u=>u&&{...u,curX:i.px,curY:i.py,points:D(u.points,i.px,i.py)})},A=n=>{try{n.currentTarget.releasePointerCapture(n.pointerId)}catch{}z(n)};return _.jsx("canvas",{ref:y,style:{position:"absolute",...h?{left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`}:{inset:0,width:"100%",height:"100%"},pointerEvents:t?"auto":"none",cursor:t?"crosshair":"default",zIndex:t?40:25},onPointerDown:N,onPointerMove:L,onPointerUp:A,onPointerCancel:A})}export{K as A,U as f,Y as p};
1
+ import{r as w,j as _}from"./index-DI1fGIyj.js";const F=1600;function j(t,r){const e=F/Math.max(t,r);return{w:Math.round(t*e),h:Math.round(r*e)}}function B(t,r,e,s=document){if(r<=0||e<=0)return null;const{w:o,h:f}=j(r,e),l=s.createElement("canvas");l.width=o,l.height=f;const y=l.getContext("2d");if(!y)return null;y.scale(o/r,f/e),Y(y,r,e,t);try{return l.toDataURL("image/png")}catch{return null}}function U(t,r,e){const s={left:0,top:0,width:t,height:r};if(!e||!(e>0)||t<=0||r<=0)return s;const o=t/r;if(Math.abs(o-e)<1e-6)return s;if(e>o){const l=t/e;return{left:0,top:(r-l)/2,width:t,height:l}}const f=r*e;return{left:(t-f)/2,top:0,width:f,height:r}}const G=(t,r)=>t===r||!!t&&!!r&&t.left===r.left&&t.top===r.top&&t.width===r.width&&t.height===r.height,J=2,q=2e3;function D(t,r,e){if(t.length>=q)return t;const s=t[t.length-1];return s&&Math.hypot(r-s[0],e-s[1])<J?t:[...t,[r,e]]}function $(t,r){const e=(t||"#ff3333").trim();if(/^#[0-9a-fA-F]{6}$/.test(e)){const s=parseInt(e.slice(1,3),16),o=parseInt(e.slice(3,5),16),f=parseInt(e.slice(5,7),16);return`rgba(${s},${o},${f},${r})`}return e}function Y(t,r,e,s){var S;const o=s.geometry,f=s.color||"#ff3333",l=Math.max(4,Math.round(Math.min(r,e)*.008));if(t.lineCap="round",t.lineJoin="round",s.shape==="CIRCLE"){const h=(o.x??0)*r,M=(o.y??0)*e,p=Math.max(2,(o.w??0)*r),a=Math.max(2,(o.h??0)*e);t.beginPath(),t.ellipse(h,M,p,a,0,0,Math.PI*2),t.fillStyle=$(f,.22),t.fill(),t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",t.stroke(),t.beginPath(),t.ellipse(h,M,p,a,0,0,Math.PI*2),t.lineWidth=l,t.strokeStyle=f,t.stroke();return}if(s.shape==="ARROW"){const h=(o.x??0)*r,M=(o.y??0)*e,p=h+(o.w??0)*r,a=M+(o.h??0)*e;t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",t.beginPath(),t.moveTo(h,M),t.lineTo(p,a),t.stroke(),t.lineWidth=l,t.strokeStyle=f,t.beginPath(),t.moveTo(h,M),t.lineTo(p,a),t.stroke();const P=Math.atan2(a-M,p-h),k=Math.max(14,l*3);t.fillStyle=f,t.beginPath(),t.moveTo(p,a),t.lineTo(p-k*Math.cos(P-.4),a-k*Math.sin(P-.4)),t.lineTo(p-k*Math.cos(P+.4),a-k*Math.sin(P+.4)),t.closePath(),t.fill();return}if(s.shape==="TEXT"&&s.text){const h=Math.max(16,Math.round(Math.min(r,e)*.035));t.font=`bold ${h}px sans-serif`,t.lineWidth=3,t.strokeStyle="rgba(0,0,0,0.65)",t.strokeText(s.text,(o.x??0)*r,(o.y??0)*e),t.fillStyle=f,t.fillText(s.text,(o.x??0)*r,(o.y??0)*e);return}if(s.shape==="FREEHAND"&&(((S=o.points)==null?void 0:S.length)??0)>=2){const h=o.points,M=()=>{t.beginPath(),t.moveTo(h[0][0]*r,h[0][1]*e);for(let p=1;p<h.length;p++)t.lineTo(h[p][0]*r,h[p][1]*e)};t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",M(),t.stroke(),t.lineWidth=l,t.strokeStyle=f,M(),t.stroke();return}const y=(o.x??0)*r,R=(o.y??0)*e,c=Math.max(2,(o.w??0)*r),g=Math.max(2,(o.h??0)*e);t.fillStyle=$(f,.22),t.fillRect(y,R,c,g),t.lineWidth=l+2,t.strokeStyle="rgba(0,0,0,0.55)",t.strokeRect(y,R,c,g),t.lineWidth=l,t.strokeStyle=f,t.strokeRect(y,R,c,g)}function O(t,r,e,s,o){if(s<=0||o<=0)return null;if(t==="CIRCLE"){const c=Math.hypot(e.curX-e.startX,e.curY-e.startY);return c<=4?null:{shape:t,color:r,geometry:{x:e.startX/s,y:e.startY/o,w:c/s,h:c/o}}}if(t==="ARROW"){const c=e.curX-e.startX,g=e.curY-e.startY;return Math.hypot(c,g)<=6?null:{shape:t,color:r,geometry:{x:e.startX/s,y:e.startY/o,w:c/s,h:g/o}}}if(t==="FREEHAND"){if(e.points.length<2)return null;const c=e.points.map(M=>M[0]),g=e.points.map(M=>M[1]),S=Math.min(...c),h=Math.min(...g);return{shape:t,color:r,geometry:{x:S/s,y:h/o,w:Math.max(.005,(Math.max(...c)-S)/s),h:Math.max(.005,(Math.max(...g)-h)/o),points:e.points.map(([M,p])=>[M/s,p/o])}}}const f=Math.min(e.startX,e.curX)/s,l=Math.min(e.startY,e.curY)/o,y=Math.abs(e.curX-e.startX)/s,R=Math.abs(e.curY-e.startY)/o;return y<=.005||R<=.005?null:{shape:t,color:r,geometry:{x:f,y:l,w:y,h:R}}}function K({enabled:t,shape:r,color:e,onCommit:s,committed:o,onCommittedChange:f,mediaAspect:l}){const y=w.useRef(null),[R,c]=w.useState(null),[g,S]=w.useState([]),[h,M]=w.useState(null),p=o??g,a=w.useRef(p),P=w.useRef(R),k=w.useRef(r),X=w.useRef(e),I=w.useRef(t);a.current=p,P.current=R,k.current=r,X.current=e,I.current=t;const b=w.useCallback(n=>{const i=n(a.current);a.current=i,f?f(i):S(i)},[f]),T=w.useCallback(()=>{const n=y.current;if(!n)return;const i=n.getContext("2d");if(!i)return;i.clearRect(0,0,n.width,n.height);for(const m of a.current)Y(i,n.width,n.height,m);const u=P.current;if(u){const m=O(k.current,X.current,u,n.width,n.height);m&&Y(i,n.width,n.height,m)}},[]);w.useEffect(()=>{const n=y.current;if(!n)return;const i=()=>{const m=Math.max(1,Math.round(n.clientWidth)),d=Math.max(1,Math.round(n.clientHeight));(n.width!==m||n.height!==d)&&(n.width=m,n.height=d),T()};i();const u=new ResizeObserver(i);return u.observe(n),()=>u.disconnect()},[T]),w.useEffect(()=>{T()},[R,p,T]),w.useEffect(()=>{var m;const n=(m=y.current)==null?void 0:m.parentElement;if(!n)return;const i=()=>{const d=l?U(n.clientWidth,n.clientHeight,l):null;M(E=>G(E,d)?E:d)};i();const u=new ResizeObserver(i);return u.observe(n),()=>u.disconnect()},[l]),w.useEffect(()=>{var i;if(t)return;c(null);const n=y.current;if(n&&n.hasPointerCapture)try{for(let u=0;u<8;u++)(i=n.hasPointerCapture)!=null&&i.call(n,u)&&n.releasePointerCapture(u)}catch{}},[t]);const C=n=>{const u=y.current.getBoundingClientRect();return{px:n.clientX-u.left,py:n.clientY-u.top,w:u.width,h:u.height}},z=n=>{const i=P.current;if(!i||!I.current){c(null);return}const u=y.current;if(!u||u.width<=0){c(null);return}const m=C(n),d=O(k.current,X.current,{...i,curX:m.px,curY:m.py,points:D(i.points,m.px,m.py)},m.w,m.h);d&&(b(E=>[...E,d]),s(d,B(d,m.w,m.h))),c(null)},N=n=>{if(!t||n.button!==0)return;n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId);const i=C(n);c({startX:i.px,startY:i.py,curX:i.px,curY:i.py,points:[[i.px,i.py]]})},L=n=>{if(!P.current)return;const i=C(n);c(u=>u&&{...u,curX:i.px,curY:i.py,points:D(u.points,i.px,i.py)})},A=n=>{try{n.currentTarget.releasePointerCapture(n.pointerId)}catch{}z(n)};return _.jsx("canvas",{ref:y,style:{position:"absolute",...h?{left:`${h.left}px`,top:`${h.top}px`,width:`${h.width}px`,height:`${h.height}px`}:{inset:0,width:"100%",height:"100%"},pointerEvents:t?"auto":"none",cursor:t?"crosshair":"default",zIndex:t?40:25},onPointerDown:N,onPointerMove:L,onPointerUp:A,onPointerCancel:A})}export{K as A,U as f,Y as p};
@@ -1 +1 @@
1
- import{r as n,j as e,o as h}from"./index-BGBqohfQ.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};
1
+ import{r as n,j as e,o as h}from"./index-DI1fGIyj.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};
@@ -1,4 +1,4 @@
1
- import{c as g,j as o,r as f,t as m,f as b}from"./index-BGBqohfQ.js";/**
1
+ import{c as g,j as o,r as f,t as m,f as b}from"./index-DI1fGIyj.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,2 +1,2 @@
1
- import{r as l,j as t,z as $e,w as Oe,X as k,v as Pe,e as Me,_ as Le,T as Be,$ as He}from"./index-BGBqohfQ.js";import{C as xe,M as We,A as ee,H as ze,b as Ue,S as be,a as Fe,I as Ve,e as Ke,u as Ge,f as Ye,h as ve,c as Xe,d as qe}from"./recording-group-store-B75435xR.js";import{p as Je}from"./labels-C21SA4JG.js";import{C as Ze}from"./circle-check-CyBjjPxR.js";import{f as Qe,A as et}from"./AnnotationOverlay-Cvpkk4r9.js";import{V as tt}from"./video-off-T0rlt0GA.js";import{P as rt}from"./plus-B2xCnntV.js";import{a as nt}from"./SegmentedControl-DbXhBGZC.js";import{v as st,a as ot,c as at,s as it,R as ct,b as lt,g as dt,d as le,e as ut}from"./recordings-BWe1ydXm.js";import{D as se}from"./download-DDBRXnAZ.js";import{B as de}from"./button-Cq_zHETv.js";import{C as ft}from"./clock-U1rDTT1h.js";import{a as ht}from"./page-header-FXPlo6az.js";import"./utils-CDN07tui.js";function pt(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}],Y={available:"bg-[var(--color-success)]",inUse:"bg-[var(--color-warning)]",offline:"bg-[rgb(var(--rgb-offline))]"},mt=[["available",Y.available],["in use",Y.inUse],["offline",Y.offline]];function fe(e){return Je(e)}function gt({devices:e,inMosaic:n,onToggle:r,status:o="ready"}){const[h,j]=l.useState(""),[d,N]=l.useState({}),p=l.useMemo(()=>{const c=h.trim().toLowerCase();return c?e.filter(b=>b.udid.toLowerCase().includes(c)||(b.name??"").toLowerCase().includes(c)||(b.altName??"").toLowerCase().includes(c)||(b.platform??"").toLowerCase().includes(c)):e},[e,h]),w=l.useMemo(()=>{const c=ue.map(u=>({id:u.id,label:u.label,rows:[]})),b=u=>c.find((S,v)=>ue[v].match(u))??c[c.length-1];for(const u of p)b((u.platform??"").toLowerCase()).rows.push(u);return c.filter(u=>u.rows.length>0)},[p]);if(e.length===0){const c=o==="loading"?"Loading devices…":o==="error"?"Couldn’t load devices. Retrying…":"No devices online.";return t.jsx("div",{role:"status",className:"text-xs text-[var(--text-dim)] p-3",children:c})}return t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"relative",children:[t.jsx($e,{"aria-hidden":!0,size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-dim)]"}),t.jsx("input",{type:"text",value:h,placeholder:"Filter devices...",onChange:c=>j(c.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)]"})]}),w.map(c=>{const b=d[c.id];return t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsxs("button",{type:"button","aria-expanded":!b,onClick:()=>N(u=>({...u,[c.id]:!u[c.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:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Oe,{"aria-hidden":!0,size:12,className:`transition-transform ${b?"-rotate-90":"rotate-0"}`}),c.label]}),t.jsx("span",{children:c.rows.length})]}),!b&&t.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:c.rows.map(u=>{const S=u.busyReason==="manual_self",v=n.has(u.udid),g=!!u.busy&&!S&&!v||!!u.offline,E=u.offline?"Offline":pt(u.busyReason),$=!g,C=[u.name??u.udid,u.platform&&fe(u.platform)].concat(g&&E?[E]:[]).filter(Boolean).join(", ");return t.jsx("li",{children:t.jsxs("button",{type:"button",disabled:g,draggable:!g,onDragStart:y=>{y.dataTransfer.effectAllowed="copy",y.dataTransfer.setData("application/x-xenon-udid",u.udid),y.dataTransfer.setData("text/plain",u.udid)},onClick:()=>r(u.udid),"aria-label":C,"aria-pressed":v,className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-left border transition-colors ${g?"opacity-60 cursor-not-allowed border-transparent":v?"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:g?`${E} — release first`:v?"Click to remove from the grid":"Click to add to the grid (or drag to a cell)",children:[v?t.jsx(Ze,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--color-accent-soft)]"}):t.jsx(xe,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--text-dim)]"}),t.jsx("span",{"aria-hidden":!0,className:`inline-block w-1.5 h-1.5 rounded-full ${u.offline?Y.offline:$?Y.available:Y.inUse}`}),t.jsx("span",{className:"font-medium flex-1 truncate text-[13px]",children:u.name??u.udid}),u.platform&&t.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded bg-[var(--surface-2)] text-[var(--text-dim)]",children:fe(u.platform)})]})},u.udid)})})]},c.id)}),h&&w.length===0&&t.jsxs("div",{className:"text-xs text-[var(--text-dim)] px-1 py-2",children:['No devices match "',h,'".']}),t.jsx("div",{className:"text-[10px] text-[var(--text-dim)] px-1 pt-2 flex items-center gap-3",children:mt.map(([c,b])=>t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full inline-block ${b}`}),c]},c))})]})}const xt=[{id:"1",label:"1",icon:t.jsx(vt,{})},{id:"2x1",label:"2×1",icon:t.jsx(yt,{})},{id:"2x2",label:"2×2",icon:t.jsx(wt,{})},{id:"3x2",label:"3×2",icon:t.jsx(Nt,{})},{id:"auto",label:"Auto",icon:t.jsx(jt,{})}];function bt({value:e,onChange:n}){return t.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:xt.map(r=>{const o=e===r.id;return t.jsxs("button",{role:"tab","aria-selected":o,onClick:()=>n(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:[t.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:r.icon}),t.jsx("span",{children:r.label})]},r.id)})})}function B(e){return t.jsx("rect",{rx:1.2,ry:1.2,fill:"currentColor",...e})}function vt(){return t.jsx("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:B({x:2,y:2,width:10,height:10})})}function yt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[B({x:1.5,y:3,width:5,height:8}),B({x:7.5,y:3,width:5,height:8})]})}function wt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[B({x:1.5,y:1.5,width:5,height:5}),B({x:7.5,y:1.5,width:5,height:5}),B({x:1.5,y:7.5,width:5,height:5}),B({x:7.5,y:7.5,width:5,height:5})]})}function Nt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[B({x:1,y:1.5,width:3.3,height:5}),B({x:5.35,y:1.5,width:3.3,height:5}),B({x:9.7,y:1.5,width:3.3,height:5}),B({x:1,y:7.5,width:3.3,height:5}),B({x:5.35,y:7.5,width:3.3,height:5}),B({x:9.7,y:7.5,width:3.3,height:5})]})}function jt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[t.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1.5"}),t.jsx("circle",{cx:"7",cy:"7",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Et(e,n,r,o,h,j,d=!1){const N=Qe(r.width,r.height,j);let p=(e-r.left-N.left)/N.width,w=(n-r.top-N.top)/N.height;return!(p>=0&&p<=1&&w>=0&&w<=1)&&!d?null:(p=Math.min(1,Math.max(0,p)),w=Math.min(1,Math.max(0,w)),{x:Math.round(p*o),y:Math.round(w*h)})}const Rt=5e3;function St(e,n){if(e.httpStatus===404)return{ended:!0,startedAt:n};if(e.httpStatus!==200)return{ended:!1,startedAt:n};const r=e.body??{};return r.status!=="running"?{ended:!0,startedAt:n}:n&&r.startedAt&&r.startedAt!==n?{ended:!0,startedAt:n}:{ended:!1,startedAt:n??r.startedAt}}function Ct(e,n,r,o=Rt){const h=l.useRef(r);h.current=r,l.useEffect(()=>{if(!n)return;let j=!1,d=!1,N;const p=async()=>{if(!(d||j)){d=!0;try{const c=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/status`),b=c.ok?await c.json().catch(()=>{}):void 0;if(j)return;const u=St({httpStatus:c.status,body:b},N);N=u.startedAt,u.ended&&(j=!0,h.current())}catch{}finally{d=!1}}};p();const w=setInterval(p,o);return()=>{j=!0,clearInterval(w)}},[e,n,o])}const Tt=3,Dt=45e3,he=[2e3,5e3,1e4];function kt(e){const n=Math.max(0,Math.min(e,he.length-1));return he[n]}function At(e){return e<Tt}function pe(e){var r;const n=(e.lastError||"").toLowerCase();if(/did not find test app|not installed|webdriveragentrunner|applicationverification/.test(n))return"WebDriverAgent is not installed on this device. Install and trust WDA, then retry.";if(/unsupported ios version|manualpairingtunnelstart/.test(n))return"This device’s iOS version is not supported for live streaming on this host.";if(/port range for purpose 'tunnel' is exhausted/.test(n))return"No free tunnel ports on this host (12100–12199 are in use). Stop another iPhone’s preview, then retry.";if(/go-ios tunnel .* exited before it was ready/.test(n)){const o=(r=/exited before it was ready \([^)]*\): (.+)$/.exec(e.lastError||""))==null?void 0:r[1];return`The device tunnel stopped while starting${o?` (go-ios: ${o.trim()})`:""}. Retry; if it keeps failing, unlock the iPhone and check it trusts this Mac.`}return/go-ios tunnel .* came up on port/.test(n)?"The device tunnel started on an unexpected port and was stopped. Retry.":/econnrefused|econnreset|connection reset|tunnel/.test(n)?"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 It(e){for(let n=0;n+4<e.length;n++){const r=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1,o=e[n]===0&&e[n+1]===0&&e[n+2]===1;if(!r&&!o)continue;const h=n+(r?4:3);if((e[h]&31)===7){const j=d=>d.toString(16).padStart(2,"0");return`avc1.${j(e[h+1])}${j(e[h+2])}${j(e[h+3])}`}}return"avc1.42e01e"}const _t=({wsUrl:e,onFatal:n,onReady:r,onFrameSize:o,className:h})=>{const j=l.useRef(null),d=l.useRef(n);d.current=n;const N=l.useRef(r);N.current=r;const p=l.useRef(o);return p.current=o,l.useEffect(()=>{var C;const w=window,c=j.current;if(typeof w.VideoDecoder>"u"||!c){(C=d.current)==null||C.call(d);return}const b=c.getContext("2d");let u=!1,S=!1,v=!0,g=0;const E=new w.VideoDecoder({output:y=>{var T,O;if(u){y.close();return}(c.width!==y.displayWidth||c.height!==y.displayHeight)&&(c.width=y.displayWidth,c.height=y.displayHeight,(T=p.current)==null||T.call(p,y.displayWidth,y.displayHeight)),b==null||b.drawImage(y,0,0),y.close(),v&&(v=!1,(O=N.current)==null||O.call(N))},error:()=>{var y;return(y=d.current)==null?void 0:y.call(d)}}),$=new WebSocket(e);return $.binaryType="arraybuffer",$.onerror=()=>{var y;return(y=d.current)==null?void 0:y.call(d)},$.onclose=()=>{var y;u||(y=d.current)==null||y.call(d)},$.onmessage=y=>{var m;const T=y.data,O=new DataView(T).getUint8(0),z=new Uint8Array(T,1);if(O===0){if(S)return;try{E.configure({codec:It(z),optimizeForLatency:!0}),S=!0}catch{(m=d.current)==null||m.call(d)}return}if(!(!S||E.state!=="configured"))try{E.decode(new w.EncodedVideoChunk({type:O===1?"key":"delta",timestamp:g,data:z})),g+=11111}catch{}},()=>{u=!0;try{$.close()}catch{}try{E.state!=="closed"&&E.close()}catch{}}},[e]),t.jsx("canvas",{ref:j,className:h,style:{width:"100%",height:"100%",objectFit:"contain",display:"block"}})};function $t(e,n,r){return(e==="android"||e==="androidtv"||e==="android-tv")&&n==="h264"&&r?"h264":"mjpeg"}const Ot=10,Pt=500;function Mt({udid:e,name:n,recordingId:r,annotateMode:o,shape:h,color:j,aspect:d="9 / 16",screenWidth:N,screenHeight:p,platform:w,onAnnotation:c,overlayAnnotations:b,onOverlayAnnotationsChange:u,onRemove:S}){const[v,g]=l.useState("connecting"),[E,$]=l.useState(),C=l.useCallback((a,f)=>{if(!(a>0)||!(f>0))return;const I=a/f;$(_=>_!==void 0&&Math.abs(_-I)<.001?_:I)},[]),[y,T]=l.useState(0),[O,z]=l.useState(null),m=l.useRef(0),s=l.useRef(null),[i,x]=l.useState(""),[R,H]=l.useState([]),[F,P]=l.useState(!1),U=l.useRef(null),W=l.useRef(null),M=w==="android"||w==="androidtv"||w==="android-tv",D=w==="ios"||w==="tvos";l.useEffect(()=>{let a=!1;if(r){z(null),g("connecting"),T(Date.now()),k.startStream(e).catch(()=>{});return}const f=typeof window.VideoDecoder<"u";return(async()=>{try{const I=encodeURIComponent(e),_=await fetch(`/xenon/api/control/${I}/stream/status`);if(!_.ok)return;const A=await _.json();if($t(w||"",A==null?void 0:A.type,f)!=="h264"||!(A!=null&&A.h264Path))return;const K=await fetch(`/xenon/api/control/${I}/stream/ticket`,{method:"POST"});if(!K.ok)return;const{ticket:L}=await K.json();if(a||!L)return;const Z=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}${A.h264Path}?ticket=${encodeURIComponent(L)}`;z(Z)}catch{}})(),()=>{a=!0}},[e,w,r]);const V=!o&&!!N&&!!p,re=(a,f,I,_=!1)=>Et(a,f,I,N,p,E,_),je=(a,f,I)=>{const _=Date.now()+Math.random(),A=a-I.left,K=f-I.top;H(L=>[...L,{id:_,x:A,y:K}]),window.setTimeout(()=>{H(L=>L.filter(q=>q.id!==_))},500)},Ee=a=>{if(!V||v==="unavailable"||a.button!==0)return;const f=a.currentTarget;f.focus(),re(a.clientX,a.clientY,f.getBoundingClientRect())&&(f.setPointerCapture(a.pointerId),W.current={startX:a.clientX,startY:a.clientY,startTime:Date.now(),rect:f.getBoundingClientRect()},je(a.clientX,a.clientY,W.current.rect))},Re=async a=>{var Z,ce;const f=W.current;if(W.current=null,!f||!V)return;try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}const I=a.clientX-f.startX,_=a.clientY-f.startY,A=Math.hypot(I,_),K=Date.now()-f.startTime,L=re(f.startX,f.startY,f.rect,!0),q=A<Ot;try{if(q&&K<Pt)await k.tap(e,L.x,L.y);else if(q)await((ce=(Z=k).touchAndHold)==null?void 0:ce.call(Z,e,L.x,L.y,K));else{const Q=re(a.clientX,a.clientY,f.rect,!0);await k.swipe(e,L.x,L.y,Q.x,Q.y)}}catch(Q){console.error(`[DeviceTile] gesture failed for ${e}`,Q)}},Se=()=>{W.current=null},Ce=async a=>{if(!V||v==="unavailable"||a.metaKey||a.ctrlKey||a.altKey)return;const f=a.key;try{if(f.length===1){a.preventDefault(),await k.typeText(e,f);return}if(f==="Backspace"){a.preventDefault(),M?await k.pressKey(e,67):await k.typeText(e,"\b");return}if(f==="Enter"){a.preventDefault(),M?await k.pressKey(e,66):await k.typeText(e,`
1
+ import{r as l,j as t,z as $e,w as Oe,X as k,v as Pe,e as Me,_ as Le,T as Be,$ as He}from"./index-DI1fGIyj.js";import{C as xe,M as We,A as ee,H as ze,b as Ue,S as be,a as Fe,I as Ve,e as Ke,u as Ge,f as Ye,h as ve,c as Xe,d as qe}from"./recording-group-store-WVM3hoXn.js";import{p as Je}from"./labels-C21SA4JG.js";import{C as Ze}from"./circle-check-zJU80_EF.js";import{f as Qe,A as et}from"./AnnotationOverlay-BXruClDk.js";import{V as tt}from"./video-off-CHp1KU_T.js";import{P as rt}from"./plus-CsIk10Cq.js";import{a as nt}from"./SegmentedControl-Zy7suhT5.js";import{v as st,a as ot,c as at,s as it,R as ct,b as lt,g as dt,d as le,e as ut}from"./recordings-BWe1ydXm.js";import{D as se}from"./download-WG6l7BgD.js";import{B as de}from"./button-fIW8owMI.js";import{C as ft}from"./clock-BtUprDsZ.js";import{a as ht}from"./page-header--aTyJXq6.js";import"./utils-CDN07tui.js";function pt(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}],Y={available:"bg-[var(--color-success)]",inUse:"bg-[var(--color-warning)]",offline:"bg-[rgb(var(--rgb-offline))]"},mt=[["available",Y.available],["in use",Y.inUse],["offline",Y.offline]];function fe(e){return Je(e)}function gt({devices:e,inMosaic:n,onToggle:r,status:o="ready"}){const[h,j]=l.useState(""),[d,N]=l.useState({}),p=l.useMemo(()=>{const c=h.trim().toLowerCase();return c?e.filter(b=>b.udid.toLowerCase().includes(c)||(b.name??"").toLowerCase().includes(c)||(b.altName??"").toLowerCase().includes(c)||(b.platform??"").toLowerCase().includes(c)):e},[e,h]),w=l.useMemo(()=>{const c=ue.map(u=>({id:u.id,label:u.label,rows:[]})),b=u=>c.find((S,v)=>ue[v].match(u))??c[c.length-1];for(const u of p)b((u.platform??"").toLowerCase()).rows.push(u);return c.filter(u=>u.rows.length>0)},[p]);if(e.length===0){const c=o==="loading"?"Loading devices…":o==="error"?"Couldn’t load devices. Retrying…":"No devices online.";return t.jsx("div",{role:"status",className:"text-xs text-[var(--text-dim)] p-3",children:c})}return t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("div",{className:"relative",children:[t.jsx($e,{"aria-hidden":!0,size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-[var(--text-dim)]"}),t.jsx("input",{type:"text",value:h,placeholder:"Filter devices...",onChange:c=>j(c.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)]"})]}),w.map(c=>{const b=d[c.id];return t.jsxs("section",{className:"flex flex-col gap-1",children:[t.jsxs("button",{type:"button","aria-expanded":!b,onClick:()=>N(u=>({...u,[c.id]:!u[c.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:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Oe,{"aria-hidden":!0,size:12,className:`transition-transform ${b?"-rotate-90":"rotate-0"}`}),c.label]}),t.jsx("span",{children:c.rows.length})]}),!b&&t.jsx("ul",{className:"flex flex-col gap-1 text-sm",children:c.rows.map(u=>{const S=u.busyReason==="manual_self",v=n.has(u.udid),g=!!u.busy&&!S&&!v||!!u.offline,E=u.offline?"Offline":pt(u.busyReason),$=!g,C=[u.name??u.udid,u.platform&&fe(u.platform)].concat(g&&E?[E]:[]).filter(Boolean).join(", ");return t.jsx("li",{children:t.jsxs("button",{type:"button",disabled:g,draggable:!g,onDragStart:y=>{y.dataTransfer.effectAllowed="copy",y.dataTransfer.setData("application/x-xenon-udid",u.udid),y.dataTransfer.setData("text/plain",u.udid)},onClick:()=>r(u.udid),"aria-label":C,"aria-pressed":v,className:`w-full flex items-center gap-2 px-2 py-1.5 rounded text-left border transition-colors ${g?"opacity-60 cursor-not-allowed border-transparent":v?"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:g?`${E} — release first`:v?"Click to remove from the grid":"Click to add to the grid (or drag to a cell)",children:[v?t.jsx(Ze,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--color-accent-soft)]"}):t.jsx(xe,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--text-dim)]"}),t.jsx("span",{"aria-hidden":!0,className:`inline-block w-1.5 h-1.5 rounded-full ${u.offline?Y.offline:$?Y.available:Y.inUse}`}),t.jsx("span",{className:"font-medium flex-1 truncate text-[13px]",children:u.name??u.udid}),u.platform&&t.jsx("span",{className:"text-[11px] px-1.5 py-0.5 rounded bg-[var(--surface-2)] text-[var(--text-dim)]",children:fe(u.platform)})]})},u.udid)})})]},c.id)}),h&&w.length===0&&t.jsxs("div",{className:"text-xs text-[var(--text-dim)] px-1 py-2",children:['No devices match "',h,'".']}),t.jsx("div",{className:"text-[10px] text-[var(--text-dim)] px-1 pt-2 flex items-center gap-3",children:mt.map(([c,b])=>t.jsxs("span",{className:"inline-flex items-center gap-1",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full inline-block ${b}`}),c]},c))})]})}const xt=[{id:"1",label:"1",icon:t.jsx(vt,{})},{id:"2x1",label:"2×1",icon:t.jsx(yt,{})},{id:"2x2",label:"2×2",icon:t.jsx(wt,{})},{id:"3x2",label:"3×2",icon:t.jsx(Nt,{})},{id:"auto",label:"Auto",icon:t.jsx(jt,{})}];function bt({value:e,onChange:n}){return t.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:xt.map(r=>{const o=e===r.id;return t.jsxs("button",{role:"tab","aria-selected":o,onClick:()=>n(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:[t.jsx("span",{className:"w-3.5 h-3.5 inline-flex items-center justify-center",children:r.icon}),t.jsx("span",{children:r.label})]},r.id)})})}function B(e){return t.jsx("rect",{rx:1.2,ry:1.2,fill:"currentColor",...e})}function vt(){return t.jsx("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:B({x:2,y:2,width:10,height:10})})}function yt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[B({x:1.5,y:3,width:5,height:8}),B({x:7.5,y:3,width:5,height:8})]})}function wt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[B({x:1.5,y:1.5,width:5,height:5}),B({x:7.5,y:1.5,width:5,height:5}),B({x:1.5,y:7.5,width:5,height:5}),B({x:7.5,y:7.5,width:5,height:5})]})}function Nt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",children:[B({x:1,y:1.5,width:3.3,height:5}),B({x:5.35,y:1.5,width:3.3,height:5}),B({x:9.7,y:1.5,width:3.3,height:5}),B({x:1,y:7.5,width:3.3,height:5}),B({x:5.35,y:7.5,width:3.3,height:5}),B({x:9.7,y:7.5,width:3.3,height:5})]})}function jt(){return t.jsxs("svg",{viewBox:"0 0 14 14",className:"w-3.5 h-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",children:[t.jsx("rect",{x:"2",y:"2",width:"10",height:"10",rx:"1.5"}),t.jsx("circle",{cx:"7",cy:"7",r:"1.5",fill:"currentColor",stroke:"none"})]})}function Et(e,n,r,o,h,j,d=!1){const N=Qe(r.width,r.height,j);let p=(e-r.left-N.left)/N.width,w=(n-r.top-N.top)/N.height;return!(p>=0&&p<=1&&w>=0&&w<=1)&&!d?null:(p=Math.min(1,Math.max(0,p)),w=Math.min(1,Math.max(0,w)),{x:Math.round(p*o),y:Math.round(w*h)})}const Rt=5e3;function St(e,n){if(e.httpStatus===404)return{ended:!0,startedAt:n};if(e.httpStatus!==200)return{ended:!1,startedAt:n};const r=e.body??{};return r.status!=="running"?{ended:!0,startedAt:n}:n&&r.startedAt&&r.startedAt!==n?{ended:!0,startedAt:n}:{ended:!1,startedAt:n??r.startedAt}}function Ct(e,n,r,o=Rt){const h=l.useRef(r);h.current=r,l.useEffect(()=>{if(!n)return;let j=!1,d=!1,N;const p=async()=>{if(!(d||j)){d=!0;try{const c=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/status`),b=c.ok?await c.json().catch(()=>{}):void 0;if(j)return;const u=St({httpStatus:c.status,body:b},N);N=u.startedAt,u.ended&&(j=!0,h.current())}catch{}finally{d=!1}}};p();const w=setInterval(p,o);return()=>{j=!0,clearInterval(w)}},[e,n,o])}const Tt=3,Dt=45e3,he=[2e3,5e3,1e4];function kt(e){const n=Math.max(0,Math.min(e,he.length-1));return he[n]}function At(e){return e<Tt}function pe(e){var r;const n=(e.lastError||"").toLowerCase();if(/did not find test app|not installed|webdriveragentrunner|applicationverification/.test(n))return"WebDriverAgent is not installed on this device. Install and trust WDA, then retry.";if(/unsupported ios version|manualpairingtunnelstart/.test(n))return"This device’s iOS version is not supported for live streaming on this host.";if(/port range for purpose 'tunnel' is exhausted/.test(n))return"No free tunnel ports on this host (12100–12199 are in use). Stop another iPhone’s preview, then retry.";if(/go-ios tunnel .* exited before it was ready/.test(n)){const o=(r=/exited before it was ready \([^)]*\): (.+)$/.exec(e.lastError||""))==null?void 0:r[1];return`The device tunnel stopped while starting${o?` (go-ios: ${o.trim()})`:""}. Retry; if it keeps failing, unlock the iPhone and check it trusts this Mac.`}return/go-ios tunnel .* came up on port/.test(n)?"The device tunnel started on an unexpected port and was stopped. Retry.":/econnrefused|econnreset|connection reset|tunnel/.test(n)?"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 It(e){for(let n=0;n+4<e.length;n++){const r=e[n]===0&&e[n+1]===0&&e[n+2]===0&&e[n+3]===1,o=e[n]===0&&e[n+1]===0&&e[n+2]===1;if(!r&&!o)continue;const h=n+(r?4:3);if((e[h]&31)===7){const j=d=>d.toString(16).padStart(2,"0");return`avc1.${j(e[h+1])}${j(e[h+2])}${j(e[h+3])}`}}return"avc1.42e01e"}const _t=({wsUrl:e,onFatal:n,onReady:r,onFrameSize:o,className:h})=>{const j=l.useRef(null),d=l.useRef(n);d.current=n;const N=l.useRef(r);N.current=r;const p=l.useRef(o);return p.current=o,l.useEffect(()=>{var C;const w=window,c=j.current;if(typeof w.VideoDecoder>"u"||!c){(C=d.current)==null||C.call(d);return}const b=c.getContext("2d");let u=!1,S=!1,v=!0,g=0;const E=new w.VideoDecoder({output:y=>{var T,O;if(u){y.close();return}(c.width!==y.displayWidth||c.height!==y.displayHeight)&&(c.width=y.displayWidth,c.height=y.displayHeight,(T=p.current)==null||T.call(p,y.displayWidth,y.displayHeight)),b==null||b.drawImage(y,0,0),y.close(),v&&(v=!1,(O=N.current)==null||O.call(N))},error:()=>{var y;return(y=d.current)==null?void 0:y.call(d)}}),$=new WebSocket(e);return $.binaryType="arraybuffer",$.onerror=()=>{var y;return(y=d.current)==null?void 0:y.call(d)},$.onclose=()=>{var y;u||(y=d.current)==null||y.call(d)},$.onmessage=y=>{var m;const T=y.data,O=new DataView(T).getUint8(0),z=new Uint8Array(T,1);if(O===0){if(S)return;try{E.configure({codec:It(z),optimizeForLatency:!0}),S=!0}catch{(m=d.current)==null||m.call(d)}return}if(!(!S||E.state!=="configured"))try{E.decode(new w.EncodedVideoChunk({type:O===1?"key":"delta",timestamp:g,data:z})),g+=11111}catch{}},()=>{u=!0;try{$.close()}catch{}try{E.state!=="closed"&&E.close()}catch{}}},[e]),t.jsx("canvas",{ref:j,className:h,style:{width:"100%",height:"100%",objectFit:"contain",display:"block"}})};function $t(e,n,r){return(e==="android"||e==="androidtv"||e==="android-tv")&&n==="h264"&&r?"h264":"mjpeg"}const Ot=10,Pt=500;function Mt({udid:e,name:n,recordingId:r,annotateMode:o,shape:h,color:j,aspect:d="9 / 16",screenWidth:N,screenHeight:p,platform:w,onAnnotation:c,overlayAnnotations:b,onOverlayAnnotationsChange:u,onRemove:S}){const[v,g]=l.useState("connecting"),[E,$]=l.useState(),C=l.useCallback((a,f)=>{if(!(a>0)||!(f>0))return;const I=a/f;$(_=>_!==void 0&&Math.abs(_-I)<.001?_:I)},[]),[y,T]=l.useState(0),[O,z]=l.useState(null),m=l.useRef(0),s=l.useRef(null),[i,x]=l.useState(""),[R,H]=l.useState([]),[F,P]=l.useState(!1),U=l.useRef(null),W=l.useRef(null),M=w==="android"||w==="androidtv"||w==="android-tv",D=w==="ios"||w==="tvos";l.useEffect(()=>{let a=!1;if(r){z(null),g("connecting"),T(Date.now()),k.startStream(e).catch(()=>{});return}const f=typeof window.VideoDecoder<"u";return(async()=>{try{const I=encodeURIComponent(e),_=await fetch(`/xenon/api/control/${I}/stream/status`);if(!_.ok)return;const A=await _.json();if($t(w||"",A==null?void 0:A.type,f)!=="h264"||!(A!=null&&A.h264Path))return;const K=await fetch(`/xenon/api/control/${I}/stream/ticket`,{method:"POST"});if(!K.ok)return;const{ticket:L}=await K.json();if(a||!L)return;const Z=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}${A.h264Path}?ticket=${encodeURIComponent(L)}`;z(Z)}catch{}})(),()=>{a=!0}},[e,w,r]);const V=!o&&!!N&&!!p,re=(a,f,I,_=!1)=>Et(a,f,I,N,p,E,_),je=(a,f,I)=>{const _=Date.now()+Math.random(),A=a-I.left,K=f-I.top;H(L=>[...L,{id:_,x:A,y:K}]),window.setTimeout(()=>{H(L=>L.filter(q=>q.id!==_))},500)},Ee=a=>{if(!V||v==="unavailable"||a.button!==0)return;const f=a.currentTarget;f.focus(),re(a.clientX,a.clientY,f.getBoundingClientRect())&&(f.setPointerCapture(a.pointerId),W.current={startX:a.clientX,startY:a.clientY,startTime:Date.now(),rect:f.getBoundingClientRect()},je(a.clientX,a.clientY,W.current.rect))},Re=async a=>{var Z,ce;const f=W.current;if(W.current=null,!f||!V)return;try{a.currentTarget.releasePointerCapture(a.pointerId)}catch{}const I=a.clientX-f.startX,_=a.clientY-f.startY,A=Math.hypot(I,_),K=Date.now()-f.startTime,L=re(f.startX,f.startY,f.rect,!0),q=A<Ot;try{if(q&&K<Pt)await k.tap(e,L.x,L.y);else if(q)await((ce=(Z=k).touchAndHold)==null?void 0:ce.call(Z,e,L.x,L.y,K));else{const Q=re(a.clientX,a.clientY,f.rect,!0);await k.swipe(e,L.x,L.y,Q.x,Q.y)}}catch(Q){console.error(`[DeviceTile] gesture failed for ${e}`,Q)}},Se=()=>{W.current=null},Ce=async a=>{if(!V||v==="unavailable"||a.metaKey||a.ctrlKey||a.altKey)return;const f=a.key;try{if(f.length===1){a.preventDefault(),await k.typeText(e,f);return}if(f==="Backspace"){a.preventDefault(),M?await k.pressKey(e,67):await k.typeText(e,"\b");return}if(f==="Enter"){a.preventDefault(),M?await k.pressKey(e,66):await k.typeText(e,`
2
2
  `);return}if(f==="Tab"){a.preventDefault(),await k.typeText(e," ");return}f==="Escape"&&M&&(a.preventDefault(),await k.pressKey(e,ee.BACK))}catch(I){console.error(`[DeviceTile] keystroke "${f}" failed for ${e}`,I)}},Te=()=>k.pressKey(e,M?ee.HOME:Ve.HOME).catch(a=>console.error(`[DeviceTile] home failed for ${e}`,a)),De=()=>k.pressKey(e,ee.BACK).catch(a=>console.error(`[DeviceTile] back failed for ${e}`,a)),ke=()=>k.pressKey(e,ee.APP_SWITCH).catch(a=>console.error(`[DeviceTile] app-switch failed for ${e}`,a)),Ae=async()=>{try{const a=await k.getScreenshot(e),f=(a==null?void 0:a.screenshot)??(a==null?void 0:a.value)??a;if(!f)return;const I=await fetch(`data:image/png;base64,${f}`).then(K=>K.blob()),_=URL.createObjectURL(I),A=document.createElement("a");A.href=_,A.download=`${n||e}-${Date.now()}.png`,document.body.appendChild(A),A.click(),A.remove(),setTimeout(()=>URL.revokeObjectURL(_),1e3)}catch(a){console.error(`[DeviceTile] screenshot failed for ${e}`,a)}};l.useEffect(()=>{console.log(`[DeviceTile] Rendering ${e} in state: ${v}`)},[e,v]);const Ie=`/xenon/api/control/${encodeURIComponent(e)}/stream?t=${y}`,ie=l.useCallback(async()=>{try{const a=await fetch(`/xenon/api/control/${encodeURIComponent(e)}/stream/status`);if(!a.ok)throw new Error(String(a.status));const f=await a.json();x(pe({lastError:f==null?void 0:f.lastError,status:f==null?void 0:f.status}))}catch{x(pe({}))}},[e]),ne=l.useCallback(()=>{const a=m.current;At(a)?(m.current=a+1,s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{g("connecting"),T(Date.now())},kt(a))):(g("unavailable"),ie())},[ie]);l.useEffect(()=>{if(v!=="connecting")return;const a=setTimeout(ne,Dt);return()=>clearTimeout(a)},[v,y,ne]),Ct(e,v==="live"&&!O,()=>{console.warn(`[DeviceTile] MJPEG stream ended for ${e}; reconnecting`),g("connecting"),T(Date.now())}),l.useEffect(()=>()=>{s.current&&clearTimeout(s.current)},[]);const _e=()=>{s.current&&clearTimeout(s.current),m.current=0,x(""),g("connecting"),T(Date.now())},X=!!r,J=n||e.slice(0,16)+"…";return t.jsxs("div",{className:"flex items-stretch justify-center w-full h-full min-h-0 min-w-0 gap-2",children:[t.jsxs("div",{className:"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:d,height:"100%"},children:[v==="connecting"&&t.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:[t.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"}),t.jsx("div",{className:"font-semibold text-[var(--text)]",children:"Starting stream…"}),t.jsx("div",{className:"text-xs text-[var(--text-dim)] truncate max-w-full",children:J}),t.jsx("div",{className:"text-[11px] mt-3 text-[var(--text-dim)] leading-snug",children:D?"iPhone streams can take up to 20 seconds to start.":"Connecting to the device…"})]}),v==="unavailable"&&t.jsx("div",{role:"alert",className:"flex items-center justify-center bg-[var(--black)] text-[var(--text-dim)] absolute inset-0 z-20",children:t.jsxs("div",{className:"text-center p-6",children:[t.jsx(tt,{"aria-hidden":!0,size:36,className:"mx-auto mb-3 text-[var(--text-dim)]"}),t.jsx("div",{className:"font-semibold text-[var(--text)]",children:"Connection failed"}),t.jsx("p",{className:"text-xs mt-2 text-[var(--text-dim)] leading-relaxed max-w-[240px] mx-auto",children:i||"We couldn’t start the live stream for this device."}),t.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:_e,children:"Retry"})]})}),O?t.jsx(_t,{wsUrl:O,className:"absolute inset-0 w-full h-full object-contain bg-black select-none pointer-events-none",onReady:()=>g("live"),onFrameSize:C,onFatal:()=>{console.warn(`[DeviceTile] H.264 fatal for ${e}; falling back to MJPEG`),z(null),g("connecting"),T(Date.now())}}):t.jsx(We,{src:Ie,alt:J,className:"absolute inset-0 w-full h-full object-contain bg-black select-none pointer-events-none",draggable:!1,style:{opacity:v==="live"?1:0,transition:"opacity 0.3s ease-in-out"},onLoad:a=>{console.log(`[DeviceTile] Image LOADED for ${e}`),C(a.currentTarget.naturalWidth,a.currentTarget.naturalHeight),m.current=0,s.current&&clearTimeout(s.current),g("live")},onError:a=>{console.error(`[DeviceTile] Image ERROR for ${e}`,a),ne()}},y),V&&v!=="unavailable"&&t.jsx("div",{ref:U,className:`absolute inset-0 z-[35] touch-none outline-none ${F?"ring-2 ring-[rgb(var(--rgb-accent)/0.6)] ring-inset rounded-lg":""}`,tabIndex:0,onPointerDown:Ee,onPointerUp:Re,onPointerCancel:Se,onKeyDown:Ce,onFocus:()=>P(!0),onBlur:()=>P(!1)}),t.jsx("div",{className:"absolute inset-0 z-20 pointer-events-none overflow-hidden",children:R.map(a=>t.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))}),X&&t.jsx(et,{enabled:o,shape:h,color:j,committed:b,mediaAspect:E,onCommittedChange:u,onCommit:(a,f)=>c(r,a,f)}),X&&o&&v==="live"&&t.jsx("div",{className:"absolute top-3 left-14 right-3 z-30 flex justify-end pointer-events-none",children:t.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 · Esc to stop"})}),X&&t.jsx("div",{className:"absolute top-3 left-3 z-30 pointer-events-none",children:t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-[var(--red-600)] text-white text-[9px] font-black shadow-lg",children:"REC"})}),t.jsxs("div",{className:"absolute top-3 left-3 z-30 flex flex-col gap-1.5 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-150",children:[v==="live"&&t.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"}),t.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:J})]})]}),t.jsx(Lt,{streamState:v,recording:X,isIOS:D,isAndroid:M,onClose:!X&&S?()=>S(e):void 0,sendHome:Te,sendBack:De,sendAppSwitch:ke,captureScreenshot:Ae,displayName:J})]})}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 Lt({streamState:e,recording:n,isIOS:r,isAndroid:o,onClose:h,sendHome:j,sendBack:d,sendAppSwitch:N,captureScreenshot:p,displayName:w}){const c=e==="live";return!h&&!c?null:t.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:[t.jsx("div",{className:"flex flex-col items-center gap-1",children:h&&t.jsx("button",{type:"button","aria-label":`Remove ${w}`,title:"Remove from the grid",onClick:h,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:t.jsx(Pe,{"aria-hidden":!0,size:16})})}),c&&t.jsxs("div",{className:"flex flex-col items-center gap-1.5 my-auto",children:[(o||r)&&t.jsx("button",{type:"button","aria-label":"Home",title:"Home",onClick:j,className:te,children:t.jsx(ze,{"aria-hidden":!0,size:15})}),o&&t.jsx("button",{type:"button","aria-label":"Back",title:"Back",onClick:d,className:te,children:t.jsx(Ue,{"aria-hidden":!0,size:16})}),o&&t.jsx("button",{type:"button","aria-label":"Recent apps",title:"Recent apps",onClick:N,className:te,children:t.jsx(be,{"aria-hidden":!0,size:13})})]}),c&&t.jsx("div",{className:"flex flex-col items-center gap-1",children:t.jsx("button",{type:"button","aria-label":"Screenshot",title:"Screenshot",onClick:p,className:te,children:t.jsx(Fe,{"aria-hidden":!0,size:15})})})]})}const Bt={1:"1fr","2x1":"1fr 1fr","2x2":"1fr 1fr","3x2":"1fr 1fr 1fr"},Ht={1:"1fr","2x1":"1fr","2x2":"1fr 1fr","3x2":"1fr 1fr"},Wt={1:1,"2x1":2,"2x2":4,"3x2":6};function zt({layout:e,tiles:n,annotateMode:r,shape:o,color:h,onAnnotation:j,overlayAnnotationsByRecording:d,onOverlayAnnotationsChange:N,onRemove:p,onDropDevice:w}){const c=Ke(e,n.length),b=Wt[c];n.length;const u=n.length,S=e==="auto"?Math.max(u,1):b,v=Math.max(0,S-u);return t.jsxs("div",{style:{display:"grid",gap:8,gridTemplateColumns:Bt[c],gridTemplateRows:Ht[c]},className:"h-full",children:[n.map(g=>t.jsx(Mt,{udid:g.udid,name:g.name,mjpegPort:g.mjpegPort,recordingId:g.recordingId,aspect:g.aspect,screenWidth:g.screenWidth,screenHeight:g.screenHeight,platform:g.platform,annotateMode:r,shape:o,color:h,overlayAnnotations:g.recordingId?d==null?void 0:d[g.recordingId]:void 0,onOverlayAnnotationsChange:g.recordingId&&N?E=>N(g.recordingId,E):void 0,onAnnotation:j,onRemove:p},g.udid)),Array.from({length:v},(g,E)=>t.jsx(Ut,{onDropDevice:w},`empty-${E}`))]})}function Ut({onDropDevice:e}){const[n,r]=l.useState(!1);return t.jsxs("div",{onDragOver:o=>{e&&(o.preventDefault(),o.dataTransfer.dropEffect="copy",n||r(!0))},onDragLeave:()=>r(!1),onDrop:o=>{if(r(!1),!e)return;o.preventDefault();const h=o.dataTransfer.getData("application/x-xenon-udid")||o.dataTransfer.getData("text/plain");h&&e(h)},className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed transition-colors ${n?"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:[t.jsx("div",{"aria-hidden":"true",className:`w-8 h-8 rounded-full flex items-center justify-center ${n?"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:t.jsx(rt,{size:16})}),t.jsx("div",{className:"text-xs font-medium",children:"Drag a device here"}),t.jsx("div",{className:"text-[10px] opacity-70",children:"or click one in the list"})]})}function Ft(e,n){return n==="starting"?"Starting…":e<=1?"Record":`Record ${e} devices`}const G={"aria-hidden":!0,size:14,className:"shrink-0"};function Vt({selectedUdids:e,onClearMarks:n}){const{state:r,dispatch:o}=Ge(),[h,j]=l.useState(()=>Date.now());l.useEffect(()=>{if(r.recordingPhase!=="recording"&&r.recordingPhase!=="stopping")return;j(Date.now());const m=window.setInterval(()=>j(Date.now()),250);return()=>window.clearInterval(m)},[r.recordingPhase]);const d=r.startedAt&&(r.recordingPhase==="recording"||r.recordingPhase==="stopping")?h-r.startedAt:0,N=r.recordingPhase==="starting"||r.recordingPhase==="stopping",p=r.recordingPhase==="idle"&&e.length>0&&!N,w=r.recordingPhase==="recording"||r.recording&&r.tiles.some(m=>!!m.recordingId),c=w&&!N,b=c,u=b&&r.annotateMode,S=!!r.groupId&&r.recordingPhase==="idle",v=e.length>1||r.downloadableVideoCount>1,g=S&&r.compositeEnabled,E=S&&!r.compositeEnabled&&(r.downloadableVideoCount===1||r.downloadableVideoCount===0&&e.length<=1),$=async()=>{var m;if(p){o({type:"SET_RECORDING_PHASE",phase:"starting"}),o({type:"SET_BANNER",banner:null});try{const s=await it(e);if(!((m=s.recordings)!=null&&m.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 i={};for(const R of s.recordings)i[R.udid]=R.id;const x=e.length-s.recordings.length;o({type:"START_RECORDING",groupId:s.groupId,startedAt:Date.now(),tileIds:i,compositeEnabled:s.compositeEnabled===!0}),x>0?o({type:"SET_BANNER",banner:{tone:"error",message:`Recording started on ${s.recordings.length} of ${e.length} devices (${x} failed).`}}):o({type:"SET_BANNER",banner:null})}catch(s){if(o({type:"SET_RECORDING_PHASE",phase:"idle"}),s instanceof ct)if(s.body.error==="device_busy"){const i=(s.body.busyDevices??[]).map(x=>`${x.udid} (${x.reason})`).join(", ");o({type:"SET_BANNER",banner:{tone:"error",message:`Cannot start — these devices are busy: ${i}`}})}else o({type:"SET_BANNER",banner:{tone:"error",message:`Server-wide recording cap reached (${s.body.active}/${s.body.limit}).`}});else o({type:"SET_BANNER",banner:{tone:"error",message:`Recording failed: ${s.message}`}})}}},C=async()=>{if(!(!r.groupId||r.recordingPhase!=="recording")){o({type:"SET_RECORDING_PHASE",phase:"stopping"});try{const m=await lt(r.groupId),s=(m.recordings??[]).filter(x=>x.status==="STOPPED"&&(x.sizeBytes??0)>=1024),i=(m.recordings??[]).filter(x=>x.status!=="STOPPED");o({type:"STOP_RECORDING",downloadableVideoCount:s.length,compositeEnabled:r.compositeEnabled}),s.length===0?o({type:"SET_BANNER",banner:{tone:"error",message:i.length>0?`Recording failed on ${i.length} device(s). Nothing to download.`:"Recording stopped but no playable video was produced."}}):i.length>0?o({type:"SET_BANNER",banner:{tone:"info",message:`${s.length} ready, ${i.length} failed. Download with the button above.`}}):o({type:"SET_BANNER",banner:{tone:"info",message:s.length===1?"Video ready. Download it with the button above.":`${s.length} videos ready. Download them with the button above.`}})}catch(m){o({type:"STOP_RECORDING"}),o({type:"SET_BANNER",banner:{tone:"error",message:`Stop failed: ${m.message}`}})}}},y=m=>{const s=m==="annotate";s&&!b||s!==r.annotateMode&&o({type:"SET_ANNOTATE_MODE",enabled:s})};l.useEffect(()=>{if(!r.annotateMode)return;const m=s=>{var x;if(s.key!=="Escape"||s.repeat)return;const i=s.target;i&&((x=i.closest)!=null&&x.call(i,"input, textarea, select")||i.isContentEditable)||o({type:"SET_ANNOTATE_MODE",enabled:!1})};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[r.annotateMode,o]);const T=()=>{b&&n()},O=Object.values(r.overlayAnnotations).some(m=>((m==null?void 0:m.length)??0)>0),z=[{id:"RECT",label:"Rect"},{id:"CIRCLE",label:"Circle"},{id:"ARROW",label:"Arrow"},{id:"FREEHAND",label:"Draw"}];return t.jsxs("div",{className:"flex items-center gap-2 flex-wrap justify-end",children:[r.recordingPhase==="recording"||r.recordingPhase==="stopping"?t.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:[t.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-[var(--red)] animate-pulse"}),"REC ",Ye(d),r.recordingPhase==="stopping"?" · Stopping…":""]}):t.jsxs("button",{type:"button",onClick:$,disabled:!p,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:[t.jsx(xe,{...G,size:10,fill:"currentColor"}),Ft(e.length,r.recordingPhase)]}),t.jsxs("button",{type:"button",onClick:C,disabled:!c,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:[t.jsx(be,{...G,size:12}),r.recordingPhase==="stopping"?"Stopping…":"Stop"]}),t.jsx(nt,{size:"sm",value:r.annotateMode?"annotate":"interact",onChange:y,segments:[{value:"interact",label:"Interact",title:"Tap, swipe and type on the devices (Esc)",keyShortcuts:"Escape"},{value:"annotate",label:"Annotate",title:b?"Draw marks on the recording":"Start recording to annotate",disabled:!b}]}),w&&t.jsxs("div",{className:"flex items-center gap-1 ml-1 pl-2 border-l border-[var(--border)]",children:[z.map(m=>t.jsx("button",{type:"button",disabled:!u,"aria-pressed":r.shape===m.id,onClick:()=>o({type:"SET_SHAPE",shape:m.id}),className:`px-2 py-1 text-xs rounded border disabled:opacity-40 disabled:cursor-not-allowed ${r.shape===m.id?"bg-[var(--surface-2)] border-[var(--color-info)] text-[rgb(var(--rgb-fg))]":"border-[var(--border)] opacity-80 hover:opacity-100"}`,children:m.label},m.id)),t.jsx("input",{type:"color",value:r.color,disabled:!u,onChange:m=>o({type:"SET_COLOR",color:m.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"}),t.jsx("button",{type:"button",onClick:T,disabled:!b||!O,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&&E&&t.jsxs("a",{href:st(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:[t.jsx(se,{...G}),"Download video"]}),S&&!E&&t.jsxs("a",{href:ot(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:[t.jsx(se,{...G}),"Download ",v?"videos":"video"]}),g&&t.jsxs("a",{href:at(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:[t.jsx(se,{...G}),"Side-by-side"]}),S&&r.groupId&&t.jsxs(Me,{to:`/recordings/${encodeURIComponent(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)]",children:[t.jsx(Le,{...G}),"Open in Recordings"]})]})}function Kt({remainingSec:e,onContinue:n,onReleaseNow:r}){return t.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"idle-warning-title",className:"fixed inset-0 z-40 bg-black/60 flex items-center justify-center",children:t.jsxs("div",{className:"bg-[var(--bg)] border border-[var(--border)] rounded-lg w-full max-w-md p-6",children:[t.jsx("h3",{id:"idle-warning-title",className:"text-base font-semibold mb-2",children:"Are you still there?"}),t.jsxs("p",{className:"text-sm text-[var(--text-dim)] mb-4",children:["Your devices will be released in"," ",t.jsxs("span",{className:"text-[var(--text)] font-mono font-semibold",children:[e,"s"]})," due to inactivity. Click ",t.jsx("strong",{children:"Continue Session"})," to keep them locked."]}),t.jsxs("div",{className:"flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick: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"}),t.jsx("button",{type:"button",autoFocus:!0,onClick:n,className:"h-9 px-4 rounded-md bg-[var(--color-accent)] text-[var(--color-on-accent)] text-sm font-medium",children:"Continue session"})]})]})})}function Gt({message:e,onRestore:n,onDismiss:r}){return t.jsxs("div",{role:"status",className:"text-sm rounded border border-[var(--border)] bg-[var(--surface-2)] text-[var(--text)] px-3 py-2 flex items-center gap-2",children:[t.jsx(ft,{"aria-hidden":!0,size:14,className:"shrink-0 text-[var(--text-dim)]"}),t.jsx("span",{className:"flex-1",children:e}),n&&t.jsx(de,{variant:"tonal",size:"sm",onClick:n,children:"Restore devices"}),t.jsx(de,{variant:"ghost",size:"sm",onClick:r,children:"Dismiss"})]})}function ye(e){var n;return((n=e.marketingName)==null?void 0:n.trim())||e.name||e.udid}function we(e){if(!e)return"9 / 16";const n=Number(e.screenWidth),r=Number(e.screenHeight);if(Number.isFinite(n)&&Number.isFinite(r)&&n>0&&r>0)return`${n} / ${r}`;const o=(e.platform||"").toLowerCase();return o==="tvos"||o==="androidtv"||o==="android-tv"?"16 / 9":"9 / 16"}function oe(e){const n=Number(e.screenWidth),r=Number(e.screenHeight);return{udid:e.udid,name:ye(e),mjpegPort:0,aspect:we(e),screenWidth:Number.isFinite(n)&&n>0?n:void 0,screenHeight:Number.isFinite(r)&&r>0?r:void 0,platform:e.platform}}function Yt(e,n){return n?"blocked":e?"remove":"add"}function ae(e,n,r){return!r||!e?!1:e===`manual_${r}_${n}`}function Xt(e,n){if(!e.busy)return;const r=ve(e);return r?r.startsWith("manual_")?ae(r,e.udid,n)?"manual_self":"manual_other":"automation":"unknown"}function qt(e,n){return e.busy?ae(ve(e),e.udid,n):!1}function Jt(e,n){return e>0&&n==="idle"}function Zt(e,n,r){const o=[],h=[];for(const j of e){const d=n.find(p=>p.udid===j.udid),N=(d==null?void 0:d.name)||j.name||j.udid;d?d.offline?h.push({name:N,reason:"offline"}):d.busy&&!ae(d.session_id,d.udid,r)?h.push({name:N,reason:"in_use"}):o.push(d):h.push({name:N,reason:"gone"})}return{restore:o,skipped:h}}const Ne=(e,n)=>`${e} ${n}${e===1?"":"s"}`;function Qt(e,n){return`Released ${Ne(e,"device")} after ${n} minutes without activity.`}const er={in_use:"is now in use by someone else.",offline:"is offline.",gone:"is no longer connected."};function tr(e,n){return n.length===0?null:[e>0?`Restored ${Ne(e,"device")}.`:"No devices restored.",...n.map(o=>`${o.name} ${er[o.reason]}`)].join(" ")}function rr(){let e=Promise.resolve();return{enqueue(n){const r=e.then(n,n);return e=r.then(()=>{},()=>{}),r}}}const me=["mousemove","mousedown","keydown","touchstart","wheel"];function nr({idleAfterMs:e,warningSec:n,onWarning:r,onTimeout:o,enabled:h}){const[j,d]=l.useState(!1),[N,p]=l.useState(null),w=l.useRef(null),c=l.useRef(null),b=l.useRef(!1),u=l.useRef(r),S=l.useRef(o);u.current=r,S.current=o;function v(){w.current&&(clearTimeout(w.current),w.current=null),c.current&&(clearInterval(c.current),c.current=null)}function g(){b.current=!0,d(!0),p(n),u.current(n);let C=n;c.current=setInterval(()=>{C-=1,C<=0?(v(),b.current=!1,d(!1),p(null),S.current()):p(C)},1e3)}function E(){v(),b.current=!1,d(!1),p(null);const C=e-n*1e3;w.current=setTimeout(g,Math.max(0,C))}function $(){h&&E()}return l.useEffect(()=>{if(!h){v(),b.current=!1,d(!1),p(null);return}function C(){b.current||E()}return me.forEach(y=>window.addEventListener(y,C,{passive:!0})),E(),()=>{me.forEach(y=>window.removeEventListener(y,C)),v()}},[h,e,n]),{warning:j,remainingSec:N,reset:$}}const ge=5*60*1e3,sr=30;function or(e,n){return{udid:e.udid,name:ye(e),altName:e.name,platform:e.platform,busy:e.busy,busyReason:Xt(e,n),mjpegServerPort:e.mjpegServerPort,offline:!!e.offline}}function yr(){const[e,n]=Xe(),[r,o]=l.useState([]),[h,j]=l.useState("loading"),[d,N]=l.useState(0),[p,w]=l.useState(null),c=l.useRef(!1),b=l.useRef(rr());l.useEffect(()=>{let s=!1;return fetch("/xenon/api/auth/me",{credentials:"include"}).then(i=>i.ok?i.json():null).then(i=>{!s&&(i!=null&&i.userId)&&w(i.userId)}).catch(()=>{}),()=>{s=!0}},[]),l.useEffect(()=>{let s=!1;const i=async()=>{try{const R=await k.getDevices();if(s)return;o(Array.isArray(R)?R:[]),j("ready")}catch{s||j("error")}};i();const x=window.setInterval(i,5e3);return()=>{s=!0,window.clearInterval(x)}},[d]),l.useEffect(()=>{let s=!1;if(!(!p||c.current))return c.current=!0,(async()=>{var R;let i=[],x=[];try{const H=await k.getDevices();i=Array.isArray(H)?H:[];const F=i.filter(U=>qt(U,p));if(x=(await Promise.all(F.map(async U=>{try{const W=await fetch(`/xenon/api/control/${encodeURIComponent(U.udid)}/stream/status`);if(!W.ok)return null;const M=await W.json();return(M==null?void 0:M.status)==="running"?U:null}catch{return null}}))).filter(U=>U!==null).map(oe),s)return;x.length>0&&n({type:"SET_TILES",tiles:x})}catch{}try{const{serverNow:H,groups:F}=await dt(),P=F[0];if(s||!P)return;const U=new Set(x.map(D=>D.udid)),W=P.recordings.filter(D=>!U.has(D.udid)).map(D=>i.find(V=>V.udid===D.udid)).filter(D=>!!D).map(oe);W.length>0&&n({type:"SET_TILES",tiles:[...x,...W]});const M={};for(const D of P.annotations){let V;try{V=JSON.parse(D.geometry)}catch{continue}(M[R=D.recordingId]??(M[R]=[])).push({shape:D.shape,color:D.color,geometry:V,text:D.text??void 0})}n({type:"REHYDRATE_RECORDING",groupId:P.groupId,startedAt:Date.now()-(H-Date.parse(P.startedAt)),tileIds:Object.fromEntries(P.recordings.map(D=>[D.udid,D.id])),compositeEnabled:P.compositeEnabled,overlayAnnotations:M})}catch{}})(),()=>{s=!0}},[p,n]),l.useEffect(()=>{for(const s of e.tiles){if(s.screenWidth&&s.screenHeight)continue;const i=r.find(H=>H.udid===s.udid);if(!i)continue;const x=Number(i.screenWidth),R=Number(i.screenHeight);Number.isFinite(x)&&x>0&&Number.isFinite(R)&&R>0&&n({type:"PATCH_TILE_DIMS",udid:s.udid,screenWidth:x,screenHeight:R,aspect:we(i)})}},[r,e.tiles,n]);const u=l.useMemo(()=>new Set(e.tiles.map(s=>s.udid)),[e.tiles]),S=l.useMemo(()=>r.map(s=>or(s,p)),[r,p]),v=async s=>{n({type:"ADD_TILE",tile:oe(s)});const i=await k.startStream(s.udid).catch(()=>null);He(i)&&n({type:"REMOVE_TILE",udid:s.udid})},g=async s=>{const i=Yt(e.tiles.some(R=>R.udid===s),e.recording);if(i==="blocked"){n({type:"SET_ERROR_BANNER",message:"Stop recording before changing the devices on the grid."});return}if(i==="remove"){await E(s);return}const x=r.find(R=>R.udid===s);x&&await v(x)},E=async s=>{n({type:"REMOVE_TILE",udid:s});try{await fetch(`/xenon/api/control/${encodeURIComponent(s)}/stream/leave`,{method:"POST"})}catch{}N(i=>i+1)},$=(s,i,x)=>{if(!e.groupId)return;const R=e.groupId,H=e.startedAt?Date.now()-e.startedAt:0,F={recordingId:s,timecodeMs:H,shape:i.shape,geometry:JSON.stringify(i.geometry),color:i.color,text:i.text};b.current.enqueue(async()=>{try{return await le(R,x?{...F,image:x}:F)}catch(P){if(!x)throw P;return le(R,F)}}).catch(P=>n({type:"SET_ERROR_BANNER",message:`Annotation failed: ${P.message}`}))},C=()=>{if(!e.groupId)return;const s=e.groupId,i=e.startedAt?Date.now()-e.startedAt:0;n({type:"CLEAR_OVERLAY_ANNOTATIONS"}),b.current.enqueue(()=>ut(s,i)).catch(()=>n({type:"SET_ERROR_BANNER",message:"Couldn't clear marks from the recording. They will still appear in the video."}))},y=()=>{for(const s of e.tiles){const i=`/xenon/api/control/${encodeURIComponent(s.udid)}/stream/leave`;try{navigator.sendBeacon?navigator.sendBeacon(i):fetch(i,{method:"POST",keepalive:!0}).catch(()=>{})}catch{}}e.tiles.forEach(s=>n({type:"REMOVE_TILE",udid:s.udid}))},[T,O]=l.useState(null),z=async()=>{const s=T==null?void 0:T.tiles;if(!s)return;const i=Zt(s,r,p);for(const R of i.restore)await v(R);const x=tr(i.restore.length,i.skipped);O(x?{message:x,tiles:null}:null),N(R=>R+1)},m=nr({idleAfterMs:ge,warningSec:sr,enabled:Jt(e.tiles.length,e.recordingPhase),onWarning:()=>{},onTimeout:()=>{const s=e.tiles;y(),O({message:Qt(s.length,ge/6e4),tiles:s})}});return t.jsxs(qe.Provider,{value:{state:e,dispatch:n},children:[t.jsxs("div",{className:"flex flex-col h-full p-4 gap-3",children:[t.jsxs("header",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(ht,{icon:Be,children:"Live devices"}),t.jsx(bt,{value:e.layout,onChange:s=>n({type:"SET_LAYOUT",layout:s})})]}),t.jsx(Vt,{selectedUdids:e.tiles.map(s=>s.udid),onClearMarks:C})]}),e.banner&&t.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:[t.jsx("span",{className:"flex-1",children:e.banner.message}),t.jsx("button",{type:"button",className:"text-xs opacity-80 hover:opacity-100",onClick:()=>n({type:"SET_BANNER",banner:null}),children:"Dismiss"})]}),T&&t.jsx(Gt,{message:T.message,onRestore:T.tiles&&!e.recording?z:void 0,onDismiss:()=>O(null)}),t.jsxs("div",{className:"grid grid-cols-[260px_1fr] gap-3 flex-1 min-h-0",children:[t.jsxs("aside",{className:"flex flex-col gap-2 border border-[var(--border)] rounded p-3 overflow-y-auto min-h-0",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-[var(--text-dim)]",children:"Devices"}),t.jsx("button",{className:"text-xs underline opacity-70 hover:opacity-100",onClick:()=>N(s=>s+1),children:"Refresh"})]}),t.jsx(gt,{devices:S,inMosaic:u,onToggle:g,status:h}),t.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."})]}),t.jsx("main",{className:"border border-[var(--border)] rounded p-2 overflow-y-auto h-full min-h-0",children:t.jsx(zt,{layout:e.layout,tiles:e.tiles,annotateMode:e.annotateMode,shape:e.shape,color:e.color,overlayAnnotationsByRecording:e.overlayAnnotations,onOverlayAnnotationsChange:(s,i)=>n({type:"SET_OVERLAY_ANNOTATIONS",recordingId:s,annotations:i}),onAnnotation:$,onRemove:E,onDropDevice:g})})]})]}),m.warning&&m.remainingSec!==null&&t.jsx(Kt,{remainingSec:m.remainingSec,onContinue:m.reset,onReleaseNow:y})]})}export{yr as default};
@@ -1 +1 @@
1
- import{j as s}from"./index-BGBqohfQ.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
+ import{j as s}from"./index-DI1fGIyj.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-BGBqohfQ.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
+ import{j as s}from"./index-DI1fGIyj.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 +1 @@
1
- import{r as t,j as s,v as d}from"./index-BGBqohfQ.js";import{P as b,M as C,a as g}from"./Menu-C173JJ0l.js";import{P as k}from"./plus-B2xCnntV.js";function F({name:a,value:r,anyValue:o,options:u,onChange:f}){const[m,p]=t.useState(!1),x=t.useRef(null),h=t.useRef(null),c=r!==o,l=u.find(e=>e.value===r),n=()=>{var e;p(!1),(e=h.current)==null||e.focus()},j=t.useCallback(e=>{const i=(e==null?void 0:e.querySelector('[aria-checked="true"]'))??(e==null?void 0:e.querySelector('[role="menuitemradio"]'));i==null||i.focus()},[]);return s.jsxs("span",{ref:x,className:`fm${c?" fm-set":""}`,children:[s.jsx("button",{ref:h,type:"button",className:"fm-trigger","aria-haspopup":"menu","aria-expanded":m,onClick:()=>p(e=>!e),children:c?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"fm-name",children:[a,":"]})," ",(l==null?void 0:l.label)??r]}):s.jsxs(s.Fragment,{children:[s.jsx(k,{size:12,"aria-hidden":"true"}),a]})}),c&&s.jsx("button",{type:"button",className:"fm-clear","aria-label":`Clear ${a.toLowerCase()} filter`,onClick:()=>{f(o),n()},children:s.jsx(d,{size:12,"aria-hidden":"true"})}),s.jsx(b,{open:m,onClose:n,anchorRef:x,placement:"bottom-start",children:s.jsx("div",{ref:j,children:s.jsx(C,{children:u.map(e=>s.jsx(g,{checked:e.value===r,note:e.note,trailing:s.jsx("span",{className:"fm-count",children:e.count}),onClick:()=>{f(e.value),n()},children:e.label},e.value))})})})]})}export{F};
1
+ import{r as t,j as s,v as d}from"./index-DI1fGIyj.js";import{P as b,M as C,a as g}from"./Menu-B-Qn2X3T.js";import{P as k}from"./plus-CsIk10Cq.js";function F({name:a,value:r,anyValue:o,options:u,onChange:f}){const[m,p]=t.useState(!1),x=t.useRef(null),h=t.useRef(null),c=r!==o,l=u.find(e=>e.value===r),n=()=>{var e;p(!1),(e=h.current)==null||e.focus()},j=t.useCallback(e=>{const i=(e==null?void 0:e.querySelector('[aria-checked="true"]'))??(e==null?void 0:e.querySelector('[role="menuitemradio"]'));i==null||i.focus()},[]);return s.jsxs("span",{ref:x,className:`fm${c?" fm-set":""}`,children:[s.jsx("button",{ref:h,type:"button",className:"fm-trigger","aria-haspopup":"menu","aria-expanded":m,onClick:()=>p(e=>!e),children:c?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"fm-name",children:[a,":"]})," ",(l==null?void 0:l.label)??r]}):s.jsxs(s.Fragment,{children:[s.jsx(k,{size:12,"aria-hidden":"true"}),a]})}),c&&s.jsx("button",{type:"button",className:"fm-clear","aria-label":`Clear ${a.toLowerCase()} filter`,onClick:()=>{f(o),n()},children:s.jsx(d,{size:12,"aria-hidden":"true"})}),s.jsx(b,{open:m,onClose:n,anchorRef:x,placement:"bottom-start",children:s.jsx("div",{ref:j,children:s.jsx(C,{children:u.map(e=>s.jsx(g,{checked:e.value===r,note:e.note,trailing:s.jsx("span",{className:"fm-count",children:e.count}),onClick:()=>{f(e.value),n()},children:e.label},e.value))})})})]})}export{F};
@@ -1 +1 @@
1
- import{r as x,x as Ve,j as C,a3 as Ye,a2 as Ke,R as Z}from"./index-BGBqohfQ.js";import{P as lt,b as ht,a as st,u as ce,f as Nt,i as Xe,D as Ge,g as Ut,d as Ue,e as tt,c as qe}from"./index-BQ2luT7L.js";import{C as Ze}from"./check-C7xu-hGU.js";const Je=["top","right","bottom","left"],U=Math.min,j=Math.max,gt=Math.round,mt=Math.floor,V=t=>({x:t,y:t}),Qe={left:"right",right:"left",bottom:"top",top:"bottom"};function Tt(t,e,n){return j(t,U(e,n))}function K(t,e){return typeof t=="function"?t(e):t}function X(t){return t.split("-")[0]}function ot(t){return t.split("-")[1]}function Ft(t){return t==="x"?"y":"x"}function Lt(t){return t==="y"?"height":"width"}function z(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function _t(t){return Ft(z(t))}function tn(t,e,n){n===void 0&&(n=!1);const o=ot(t),r=_t(t),i=Lt(r);let s=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=wt(s)),[s,wt(s)]}function en(t){const e=wt(t);return[Dt(t),e,Dt(e)]}function Dt(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const qt=["left","right"],Zt=["right","left"],nn=["top","bottom"],on=["bottom","top"];function rn(t,e,n){switch(t){case"top":case"bottom":return n?e?Zt:qt:e?qt:Zt;case"left":case"right":return e?nn:on;default:return[]}}function sn(t,e,n,o){const r=ot(t);let i=rn(X(t),n==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(Dt)))),i}function wt(t){const e=X(t);return Qe[e]+t.slice(e.length)}function cn(t){return{top:0,right:0,bottom:0,left:0,...t}}function le(t){return typeof t!="number"?cn(t):{top:t,right:t,bottom:t,left:t}}function xt(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function Jt(t,e,n){let{reference:o,floating:r}=t;const i=z(e),s=_t(e),c=Lt(s),l=X(e),f=i==="y",a=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,m=o[c]/2-r[c]/2;let d;switch(l){case"top":d={x:a,y:o.y-r.height};break;case"bottom":d={x:a,y:o.y+o.height};break;case"right":d={x:o.x+o.width,y:u};break;case"left":d={x:o.x-r.width,y:u};break;default:d={x:o.x,y:o.y}}switch(ot(e)){case"start":d[s]-=m*(n&&f?-1:1);break;case"end":d[s]+=m*(n&&f?-1:1);break}return d}async function ln(t,e){var n;e===void 0&&(e={});const{x:o,y:r,platform:i,rects:s,elements:c,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:a="viewport",elementContext:u="floating",altBoundary:m=!1,padding:d=0}=K(e,t),p=le(d),h=c[m?u==="floating"?"reference":"floating":u],w=xt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(h)))==null||n?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:f,rootBoundary:a,strategy:l})),b=u==="floating"?{x:o,y:r,width:s.floating.width,height:s.floating.height}:s.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),v=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},A=xt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:y,strategy:l}):b);return{top:(w.top-A.top+p.top)/v.y,bottom:(A.bottom-w.bottom+p.bottom)/v.y,left:(w.left-A.left+p.left)/v.x,right:(A.right-w.right+p.right)/v.x}}const an=50,fn=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=n,c=s.detectOverflow?s:{...s,detectOverflow:ln},l=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:t,floating:e,strategy:r}),{x:a,y:u}=Jt(f,o,l),m=o,d=0;const p={};for(let g=0;g<i.length;g++){const h=i[g];if(!h)continue;const{name:w,fn:b}=h,{x:y,y:v,data:A,reset:R}=await b({x:a,y:u,initialPlacement:o,placement:m,strategy:r,middlewareData:p,rects:f,platform:c,elements:{reference:t,floating:e}});a=y??a,u=v??u,p[w]={...p[w],...A},R&&d<an&&(d++,typeof R=="object"&&(R.placement&&(m=R.placement),R.rects&&(f=R.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:r}):R.rects),{x:a,y:u}=Jt(f,m,l)),g=-1)}return{x:a,y:u,placement:m,strategy:r,middlewareData:p}},un=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:r,rects:i,platform:s,elements:c,middlewareData:l}=e,{element:f,padding:a=0}=K(t,e)||{};if(f==null)return{};const u=le(a),m={x:n,y:o},d=_t(r),p=Lt(d),g=await s.getDimensions(f),h=d==="y",w=h?"top":"left",b=h?"bottom":"right",y=h?"clientHeight":"clientWidth",v=i.reference[p]+i.reference[d]-m[d]-i.floating[p],A=m[d]-i.reference[d],R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f));let P=R?R[y]:0;(!P||!await(s.isElement==null?void 0:s.isElement(R)))&&(P=c.floating[y]||i.floating[p]);const O=v/2-A/2,L=P/2-g[p]/2-1,D=U(u[w],L),M=U(u[b],L),F=D,I=P-g[p]-M,T=P/2-g[p]/2+O,$=Tt(F,T,I),E=!l.arrow&&ot(r)!=null&&T!==$&&i.reference[p]/2-(T<F?D:M)-g[p]/2<0,N=E?T<F?T-F:T-I:0;return{[d]:m[d]+N,data:{[d]:$,centerOffset:T-$-N,...E&&{alignmentOffset:N}},reset:E}}}),dn=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:r,middlewareData:i,rects:s,initialPlacement:c,platform:l,elements:f}=e,{mainAxis:a=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...h}=K(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=X(r),b=z(c),y=X(c)===c,v=await(l.isRTL==null?void 0:l.isRTL(f.floating)),A=m||(y||!g?[wt(c)]:en(c)),R=p!=="none";!m&&R&&A.push(...sn(c,g,p,v));const P=[c,...A],O=await l.detectOverflow(e,h),L=[];let D=((o=i.flip)==null?void 0:o.overflows)||[];if(a&&L.push(O[w]),u){const T=tn(r,s,v);L.push(O[T[0]],O[T[1]])}if(D=[...D,{placement:r,overflows:L}],!L.every(T=>T<=0)){var M,F;const T=(((M=i.flip)==null?void 0:M.index)||0)+1,$=P[T];if($&&(!(u==="alignment"?b!==z($):!1)||D.every(S=>z(S.placement)===b?S.overflows[0]>0:!0)))return{data:{index:T,overflows:D},reset:{placement:$}};let E=(F=D.filter(N=>N.overflows[0]<=0).sort((N,S)=>N.overflows[1]-S.overflows[1])[0])==null?void 0:F.placement;if(!E)switch(d){case"bestFit":{var I;const N=(I=D.filter(S=>{if(R){const _=z(S.placement);return _===b||_==="y"}return!0}).map(S=>[S.placement,S.overflows.filter(_=>_>0).reduce((_,B)=>_+B,0)]).sort((S,_)=>S[1]-_[1])[0])==null?void 0:I[0];N&&(E=N);break}case"initialPlacement":E=c;break}if(r!==E)return{reset:{placement:E}}}return{}}}};function Qt(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function te(t){return Je.some(e=>t[e]>=0)}const mn=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:o}=e,{strategy:r="referenceHidden",...i}=K(t,e);switch(r){case"referenceHidden":{const s=await o.detectOverflow(e,{...i,elementContext:"reference"}),c=Qt(s,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:te(c)}}}case"escaped":{const s=await o.detectOverflow(e,{...i,altBoundary:!0}),c=Qt(s,n.floating);return{data:{escapedOffsets:c,escaped:te(c)}}}default:return{}}}}},ae=new Set(["left","top"]);async function pn(t,e){const{placement:n,platform:o,elements:r}=t,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=X(n),c=ot(n),l=z(n)==="y",f=ae.has(s)?-1:1,a=i&&l?-1:1,u=K(e,t);let{mainAxis:m,crossAxis:d,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof p=="number"&&(d=c==="end"?p*-1:p),l?{x:d*a,y:m*f}:{x:m*f,y:d*a}}const hn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:s,middlewareData:c}=e,l=await pn(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+l.x,y:i+l.y,data:{...l,placement:s}}}}},gn=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:r,platform:i}=e,{mainAxis:s=!0,crossAxis:c=!1,limiter:l={fn:w=>{let{x:b,y}=w;return{x:b,y}}},...f}=K(t,e),a={x:n,y:o},u=await i.detectOverflow(e,f),m=z(X(r)),d=Ft(m);let p=a[d],g=a[m];if(s){const w=d==="y"?"top":"left",b=d==="y"?"bottom":"right",y=p+u[w],v=p-u[b];p=Tt(y,p,v)}if(c){const w=m==="y"?"top":"left",b=m==="y"?"bottom":"right",y=g+u[w],v=g-u[b];g=Tt(y,g,v)}const h=l.fn({...e,[d]:p,[m]:g});return{...h,data:{x:h.x-n,y:h.y-o,enabled:{[d]:s,[m]:c}}}}}},wn=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:o,placement:r,rects:i,middlewareData:s}=e,{offset:c=0,mainAxis:l=!0,crossAxis:f=!0}=K(t,e),a={x:n,y:o},u=z(r),m=Ft(u);let d=a[m],p=a[u];const g=K(c,e),h=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const y=m==="y"?"height":"width",v=i.reference[m]-i.floating[y]+h.mainAxis,A=i.reference[m]+i.reference[y]-h.mainAxis;d<v?d=v:d>A&&(d=A)}if(f){var w,b;const y=m==="y"?"width":"height",v=ae.has(X(r)),A=i.reference[u]-i.floating[y]+(v&&((w=s.offset)==null?void 0:w[u])||0)+(v?0:h.crossAxis),R=i.reference[u]+i.reference[y]+(v?0:((b=s.offset)==null?void 0:b[u])||0)-(v?h.crossAxis:0);p<A?p=A:p>R&&(p=R)}return{[m]:d,[u]:p}}}},xn=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,o;const{placement:r,rects:i,platform:s,elements:c}=e,{apply:l=()=>{},...f}=K(t,e),a=await s.detectOverflow(e,f),u=X(r),m=ot(r),d=z(r)==="y",{width:p,height:g}=i.floating;let h,w;u==="top"||u==="bottom"?(h=u,w=m===(await(s.isRTL==null?void 0:s.isRTL(c.floating))?"start":"end")?"left":"right"):(w=u,h=m==="end"?"top":"bottom");const b=g-a.top-a.bottom,y=p-a.left-a.right,v=U(g-a[h],b),A=U(p-a[w],y),R=!e.middlewareData.shift;let P=v,O=A;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=y),(o=e.middlewareData.shift)!=null&&o.enabled.y&&(P=b),R&&!m){const D=j(a.left,0),M=j(a.right,0),F=j(a.top,0),I=j(a.bottom,0);d?O=p-2*(D!==0||M!==0?D+M:j(a.left,a.right)):P=g-2*(F!==0||I!==0?F+I:j(a.top,a.bottom))}await l({...e,availableWidth:O,availableHeight:P});const L=await s.getDimensions(c.floating);return p!==L.width||g!==L.height?{reset:{rects:!0}}:{}}}};function bt(){return typeof window<"u"}function rt(t){return fe(t)?(t.nodeName||"").toLowerCase():"#document"}function k(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Y(t){var e;return(e=(fe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function fe(t){return bt()?t instanceof Node||t instanceof k(t).Node:!1}function W(t){return bt()?t instanceof Element||t instanceof k(t).Element:!1}function G(t){return bt()?t instanceof HTMLElement||t instanceof k(t).HTMLElement:!1}function ee(t){return!bt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof k(t).ShadowRoot}function at(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&r!=="inline"&&r!=="contents"}function yn(t){return/^(table|td|th)$/.test(rt(t))}function Rt(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const vn=/transform|translate|scale|rotate|perspective|filter/,bn=/paint|layout|strict|content/,J=t=>!!t&&t!=="none";let St;function $t(t){const e=W(t)?H(t):t;return J(e.transform)||J(e.translate)||J(e.scale)||J(e.rotate)||J(e.perspective)||!jt()&&(J(e.backdropFilter)||J(e.filter))||vn.test(e.willChange||"")||bn.test(e.contain||"")}function Rn(t){let e=q(t);for(;G(e)&&!nt(e);){if($t(e))return e;if(Rt(e))return null;e=q(e)}return null}function jt(){return St==null&&(St=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),St}function nt(t){return/^(html|body|#document)$/.test(rt(t))}function H(t){return k(t).getComputedStyle(t)}function At(t){return W(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function q(t){if(rt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||ee(t)&&t.host||Y(t);return ee(e)?e.host:e}function ue(t){const e=q(t);return nt(e)?t.ownerDocument?t.ownerDocument.body:t.body:G(e)&&at(e)?e:ue(e)}function ct(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=ue(t),i=r===((o=t.ownerDocument)==null?void 0:o.body),s=k(r);if(i){const c=It(s);return e.concat(s,s.visualViewport||[],at(r)?r:[],c&&n?ct(c):[])}else return e.concat(r,ct(r,[],n))}function It(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function de(t){const e=H(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=G(t),i=r?t.offsetWidth:n,s=r?t.offsetHeight:o,c=gt(n)!==i||gt(o)!==s;return c&&(n=i,o=s),{width:n,height:o,$:c}}function kt(t){return W(t)?t:t.contextElement}function et(t){const e=kt(t);if(!G(e))return V(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=de(e);let s=(i?gt(n.width):n.width)/o,c=(i?gt(n.height):n.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const An=V(0);function me(t){const e=k(t);return!jt()||!e.visualViewport?An:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Cn(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==k(t)?!1:e}function Q(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=kt(t);let s=V(1);e&&(o?W(o)&&(s=et(o)):s=et(t));const c=Cn(i,n,o)?me(i):V(0);let l=(r.left+c.x)/s.x,f=(r.top+c.y)/s.y,a=r.width/s.x,u=r.height/s.y;if(i){const m=k(i),d=o&&W(o)?k(o):o;let p=m,g=It(p);for(;g&&o&&d!==p;){const h=et(g),w=g.getBoundingClientRect(),b=H(g),y=w.left+(g.clientLeft+parseFloat(b.paddingLeft))*h.x,v=w.top+(g.clientTop+parseFloat(b.paddingTop))*h.y;l*=h.x,f*=h.y,a*=h.x,u*=h.y,l+=y,f+=v,p=k(g),g=It(p)}}return xt({width:a,height:u,x:l,y:f})}function Ct(t,e){const n=At(t).scrollLeft;return e?e.left+n:Q(Y(t)).left+n}function pe(t,e){const n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-Ct(t,n),r=n.top+e.scrollTop;return{x:o,y:r}}function Sn(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i=r==="fixed",s=Y(o),c=e?Rt(e.floating):!1;if(o===s||c&&i)return n;let l={scrollLeft:0,scrollTop:0},f=V(1);const a=V(0),u=G(o);if((u||!u&&!i)&&((rt(o)!=="body"||at(s))&&(l=At(o)),u)){const d=Q(o);f=et(o),a.x=d.x+o.clientLeft,a.y=d.y+o.clientTop}const m=s&&!u&&!i?pe(s,l):V(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-l.scrollLeft*f.x+a.x+m.x,y:n.y*f.y-l.scrollTop*f.y+a.y+m.y}}function On(t){return Array.from(t.getClientRects())}function Pn(t){const e=Y(t),n=At(t),o=t.ownerDocument.body,r=j(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=j(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+Ct(t);const c=-n.scrollTop;return H(o).direction==="rtl"&&(s+=j(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:c}}const ne=25;function En(t,e){const n=k(t),o=Y(t),r=n.visualViewport;let i=o.clientWidth,s=o.clientHeight,c=0,l=0;if(r){i=r.width,s=r.height;const a=jt();(!a||a&&e==="fixed")&&(c=r.offsetLeft,l=r.offsetTop)}const f=Ct(o);if(f<=0){const a=o.ownerDocument,u=a.body,m=getComputedStyle(u),d=a.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,p=Math.abs(o.clientWidth-u.clientWidth-d);p<=ne&&(i-=p)}else f<=ne&&(i+=f);return{width:i,height:s,x:c,y:l}}function Tn(t,e){const n=Q(t,!0,e==="fixed"),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=G(t)?et(t):V(1),s=t.clientWidth*i.x,c=t.clientHeight*i.y,l=r*i.x,f=o*i.y;return{width:s,height:c,x:l,y:f}}function oe(t,e,n){let o;if(e==="viewport")o=En(t,n);else if(e==="document")o=Pn(Y(t));else if(W(e))o=Tn(e,n);else{const r=me(t);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return xt(o)}function he(t,e){const n=q(t);return n===e||!W(n)||nt(n)?!1:H(n).position==="fixed"||he(n,e)}function Dn(t,e){const n=e.get(t);if(n)return n;let o=ct(t,[],!1).filter(c=>W(c)&&rt(c)!=="body"),r=null;const i=H(t).position==="fixed";let s=i?q(t):t;for(;W(s)&&!nt(s);){const c=H(s),l=$t(s);!l&&c.position==="fixed"&&(r=null),(i?!l&&!r:!l&&c.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||at(s)&&!l&&he(t,s))?o=o.filter(a=>a!==s):r=c,s=q(s)}return e.set(t,o),o}function In(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const s=[...n==="clippingAncestors"?Rt(e)?[]:Dn(e,this._c):[].concat(n),o],c=oe(e,s[0],r);let l=c.top,f=c.right,a=c.bottom,u=c.left;for(let m=1;m<s.length;m++){const d=oe(e,s[m],r);l=j(d.top,l),f=U(d.right,f),a=U(d.bottom,a),u=j(d.left,u)}return{width:f-u,height:a-l,x:u,y:l}}function Mn(t){const{width:e,height:n}=de(t);return{width:e,height:n}}function Nn(t,e,n){const o=G(e),r=Y(e),i=n==="fixed",s=Q(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const l=V(0);function f(){l.x=Ct(r)}if(o||!o&&!i)if((rt(e)!=="body"||at(r))&&(c=At(e)),o){const d=Q(e,!0,i,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}else r&&f();i&&!o&&r&&f();const a=r&&!o&&!i?pe(r,c):V(0),u=s.left+c.scrollLeft-l.x-a.x,m=s.top+c.scrollTop-l.y-a.y;return{x:u,y:m,width:s.width,height:s.height}}function Ot(t){return H(t).position==="static"}function re(t,e){if(!G(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Y(t)===n&&(n=n.ownerDocument.body),n}function ge(t,e){const n=k(t);if(Rt(t))return n;if(!G(t)){let r=q(t);for(;r&&!nt(r);){if(W(r)&&!Ot(r))return r;r=q(r)}return n}let o=re(t,e);for(;o&&yn(o)&&Ot(o);)o=re(o,e);return o&&nt(o)&&Ot(o)&&!$t(o)?n:o||Rn(t)||n}const Fn=async function(t){const e=this.getOffsetParent||ge,n=this.getDimensions,o=await n(t.floating);return{reference:Nn(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Ln(t){return H(t).direction==="rtl"}const _n={convertOffsetParentRelativeRectToViewportRelativeRect:Sn,getDocumentElement:Y,getClippingRect:In,getOffsetParent:ge,getElementRects:Fn,getClientRects:On,getDimensions:Mn,getScale:et,isElement:W,isRTL:Ln};function we(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function $n(t,e){let n=null,o;const r=Y(t);function i(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function s(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),i();const f=t.getBoundingClientRect(),{left:a,top:u,width:m,height:d}=f;if(c||e(),!m||!d)return;const p=mt(u),g=mt(r.clientWidth-(a+m)),h=mt(r.clientHeight-(u+d)),w=mt(a),y={rootMargin:-p+"px "+-g+"px "+-h+"px "+-w+"px",threshold:j(0,U(1,l))||1};let v=!0;function A(R){const P=R[0].intersectionRatio;if(P!==l){if(!v)return s();P?s(!1,P):o=setTimeout(()=>{s(!1,1e-7)},1e3)}P===1&&!we(f,t.getBoundingClientRect())&&s(),v=!1}try{n=new IntersectionObserver(A,{...y,root:r.ownerDocument})}catch{n=new IntersectionObserver(A,y)}n.observe(t)}return s(!0),i}function jn(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,f=kt(t),a=r||i?[...f?ct(f):[],...e?ct(e):[]]:[];a.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const u=f&&c?$n(f,n):null;let m=-1,d=null;s&&(d=new ResizeObserver(w=>{let[b]=w;b&&b.target===f&&d&&e&&(d.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=d)==null||y.observe(e)})),n()}),f&&!l&&d.observe(f),e&&d.observe(e));let p,g=l?Q(t):null;l&&h();function h(){const w=Q(t);g&&!we(g,w)&&n(),g=w,p=requestAnimationFrame(h)}return n(),()=>{var w;a.forEach(b=>{r&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),u==null||u(),(w=d)==null||w.disconnect(),d=null,l&&cancelAnimationFrame(p)}}const kn=hn,Wn=gn,Hn=dn,Bn=xn,zn=mn,ie=un,Vn=wn,Yn=(t,e,n)=>{const o=new Map,r={platform:_n,...n},i={...r.platform,_c:o};return fn(t,e,{...r,platform:i})};var Kn=typeof document<"u",Xn=function(){},pt=Kn?x.useLayoutEffect:Xn;function yt(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,o,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(o=n;o--!==0;)if(!yt(t[o],e[o]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(e,r[o]))return!1;for(o=n;o--!==0;){const i=r[o];if(!(i==="_owner"&&t.$$typeof)&&!yt(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function xe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function se(t,e){const n=xe(t);return Math.round(e*n)/n}function Pt(t){const e=x.useRef(t);return pt(()=>{e.current=t}),e}function Gn(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:i,floating:s}={},transform:c=!0,whileElementsMounted:l,open:f}=t,[a,u]=x.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[m,d]=x.useState(o);yt(m,o)||d(o);const[p,g]=x.useState(null),[h,w]=x.useState(null),b=x.useCallback(S=>{S!==R.current&&(R.current=S,g(S))},[]),y=x.useCallback(S=>{S!==P.current&&(P.current=S,w(S))},[]),v=i||p,A=s||h,R=x.useRef(null),P=x.useRef(null),O=x.useRef(a),L=l!=null,D=Pt(l),M=Pt(r),F=Pt(f),I=x.useCallback(()=>{if(!R.current||!P.current)return;const S={placement:e,strategy:n,middleware:m};M.current&&(S.platform=M.current),Yn(R.current,P.current,S).then(_=>{const B={..._,isPositioned:F.current!==!1};T.current&&!yt(O.current,B)&&(O.current=B,Ve.flushSync(()=>{u(B)}))})},[m,e,n,M,F]);pt(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,u(S=>({...S,isPositioned:!1})))},[f]);const T=x.useRef(!1);pt(()=>(T.current=!0,()=>{T.current=!1}),[]),pt(()=>{if(v&&(R.current=v),A&&(P.current=A),v&&A){if(D.current)return D.current(v,A,I);I()}},[v,A,I,D,L]);const $=x.useMemo(()=>({reference:R,floating:P,setReference:b,setFloating:y}),[b,y]),E=x.useMemo(()=>({reference:v,floating:A}),[v,A]),N=x.useMemo(()=>{const S={position:n,left:0,top:0};if(!E.floating)return S;const _=se(E.floating,a.x),B=se(E.floating,a.y);return c?{...S,transform:"translate("+_+"px, "+B+"px)",...xe(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:B}},[n,c,E.floating,a.x,a.y]);return x.useMemo(()=>({...a,update:I,refs:$,elements:E,floatingStyles:N}),[a,I,$,E,N])}const Un=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:o,padding:r}=typeof t=="function"?t(n):t;return o&&e(o)?o.current!=null?ie({element:o.current,padding:r}).fn(n):{}:o?ie({element:o,padding:r}).fn(n):{}}}},qn=(t,e)=>{const n=kn(t);return{name:n.name,fn:n.fn,options:[t,e]}},Zn=(t,e)=>{const n=Wn(t);return{name:n.name,fn:n.fn,options:[t,e]}},Jn=(t,e)=>({fn:Vn(t).fn,options:[t,e]}),Qn=(t,e)=>{const n=Hn(t);return{name:n.name,fn:n.fn,options:[t,e]}},to=(t,e)=>{const n=Bn(t);return{name:n.name,fn:n.fn,options:[t,e]}},eo=(t,e)=>{const n=zn(t);return{name:n.name,fn:n.fn,options:[t,e]}},no=(t,e)=>{const n=Un(t);return{name:n.name,fn:n.fn,options:[t,e]}};var oo="Arrow",ye=x.forwardRef((t,e)=>{const{children:n,width:o=10,height:r=5,...i}=t;return C.jsx(lt.svg,{...i,ref:e,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});ye.displayName=oo;var ro=ye;function io(t){const[e,n]=x.useState(void 0);return ht(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const i=r[0];let s,c;if("borderBoxSize"in i){const l=i.borderBoxSize,f=Array.isArray(l)?l[0]:l;s=f.inlineSize,c=f.blockSize}else s=t.offsetWidth,c=t.offsetHeight;n({width:s,height:c})});return o.observe(t,{box:"border-box"}),()=>o.unobserve(t)}else n(void 0)},[t]),e}var Wt="Popper",[ve]=Nt(Wt),[so,be]=ve(Wt),Re=t=>{const{__scopePopper:e,children:n}=t,[o,r]=x.useState(null);return C.jsx(so,{scope:e,anchor:o,onAnchorChange:r,children:n})};Re.displayName=Wt;var Ae="PopperAnchor",Ce=x.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:o,...r}=t,i=be(Ae,n),s=x.useRef(null),c=st(e,s),l=x.useRef(null);return x.useEffect(()=>{const f=l.current;l.current=(o==null?void 0:o.current)||s.current,f!==l.current&&i.onAnchorChange(l.current)}),o?null:C.jsx(lt.div,{...r,ref:c})});Ce.displayName=Ae;var Ht="PopperContent",[co,lo]=ve(Ht),Se=x.forwardRef((t,e)=>{var Bt,zt,Vt,Yt,Kt,Xt;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:i="center",alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:f=[],collisionPadding:a=0,sticky:u="partial",hideWhenDetached:m=!1,updatePositionStrategy:d="optimized",onPlaced:p,...g}=t,h=be(Ht,n),[w,b]=x.useState(null),y=st(e,it=>b(it)),[v,A]=x.useState(null),R=io(v),P=(R==null?void 0:R.width)??0,O=(R==null?void 0:R.height)??0,L=o+(i!=="center"?"-"+i:""),D=typeof a=="number"?a:{top:0,right:0,bottom:0,left:0,...a},M=Array.isArray(f)?f:[f],F=M.length>0,I={padding:D,boundary:M.filter(uo),altBoundary:F},{refs:T,floatingStyles:$,placement:E,isPositioned:N,middlewareData:S}=Gn({strategy:"fixed",placement:L,whileElementsMounted:(...it)=>jn(...it,{animationFrame:d==="always"}),elements:{reference:h.anchor},middleware:[qn({mainAxis:r+O,alignmentAxis:s}),l&&Zn({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Jn():void 0,...I}),l&&Qn({...I}),to({...I,apply:({elements:it,rects:Gt,availableWidth:We,availableHeight:He})=>{const{width:Be,height:ze}=Gt.reference,dt=it.floating.style;dt.setProperty("--radix-popper-available-width",`${We}px`),dt.setProperty("--radix-popper-available-height",`${He}px`),dt.setProperty("--radix-popper-anchor-width",`${Be}px`),dt.setProperty("--radix-popper-anchor-height",`${ze}px`)}}),v&&no({element:v,padding:c}),mo({arrowWidth:P,arrowHeight:O}),m&&eo({strategy:"referenceHidden",...I})]}),[_,B]=Pe(E),ut=ce(p);ht(()=>{N&&(ut==null||ut())},[N,ut]);const Le=(Bt=S.arrow)==null?void 0:Bt.x,_e=(zt=S.arrow)==null?void 0:zt.y,$e=((Vt=S.arrow)==null?void 0:Vt.centerOffset)!==0,[je,ke]=x.useState();return ht(()=>{w&&ke(window.getComputedStyle(w).zIndex)},[w]),C.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:N?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:je,"--radix-popper-transform-origin":[(Yt=S.transformOrigin)==null?void 0:Yt.x,(Kt=S.transformOrigin)==null?void 0:Kt.y].join(" "),...((Xt=S.hide)==null?void 0:Xt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:C.jsx(co,{scope:n,placedSide:_,onArrowChange:A,arrowX:Le,arrowY:_e,shouldHideArrow:$e,children:C.jsx(lt.div,{"data-side":_,"data-align":B,...g,ref:y,style:{...g.style,animation:N?void 0:"none"}})})})});Se.displayName=Ht;var Oe="PopperArrow",ao={top:"bottom",right:"left",bottom:"top",left:"right"},fo=x.forwardRef(function(e,n){const{__scopePopper:o,...r}=e,i=lo(Oe,o),s=ao[i.placedSide];return C.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:C.jsx(ro,{...r,ref:n,style:{...r.style,display:"block"}})})});fo.displayName=Oe;function uo(t){return t!==null}var mo=t=>({name:"transformOrigin",options:t,fn(e){var h,w,b;const{placement:n,rects:o,middlewareData:r}=e,s=((h=r.arrow)==null?void 0:h.centerOffset)!==0,c=s?0:t.arrowWidth,l=s?0:t.arrowHeight,[f,a]=Pe(n),u={start:"0%",center:"50%",end:"100%"}[a],m=(((w=r.arrow)==null?void 0:w.x)??0)+c/2,d=(((b=r.arrow)==null?void 0:b.y)??0)+l/2;let p="",g="";return f==="bottom"?(p=s?u:`${m}px`,g=`${-l}px`):f==="top"?(p=s?u:`${m}px`,g=`${o.floating.height+l}px`):f==="right"?(p=`${-l}px`,g=s?u:`${d}px`):f==="left"&&(p=`${o.floating.width+l}px`,g=s?u:`${d}px`),{data:{x:p,y:g}}}});function Pe(t){const[e,n="center"]=t.split("-");return[e,n]}var po=Re,ho=Ce,go=Se,wo=Symbol.for("react.lazy"),vt=Ye[" use ".trim().toString()];function xo(t){return typeof t=="object"&&t!==null&&"then"in t}function Ee(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===wo&&"_payload"in t&&xo(t._payload)}function yo(t){const e=vo(t),n=x.forwardRef((o,r)=>{let{children:i,...s}=o;Ee(i)&&typeof vt=="function"&&(i=vt(i._payload));const c=x.Children.toArray(i),l=c.find(Ro);if(l){const f=l.props.children,a=c.map(u=>u===l?x.Children.count(f)>1?x.Children.only(null):x.isValidElement(f)?f.props.children:null:u);return C.jsx(e,{...s,ref:r,children:x.isValidElement(f)?x.cloneElement(f,void 0,a):null})}return C.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function vo(t){const e=x.forwardRef((n,o)=>{let{children:r,...i}=n;if(Ee(r)&&typeof vt=="function"&&(r=vt(r._payload)),x.isValidElement(r)){const s=Co(r),c=Ao(i,r.props);return r.type!==x.Fragment&&(c.ref=o?Xe(o,s):s),x.cloneElement(r,c)}return x.Children.count(r)>1?x.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var bo=Symbol("radix.slottable");function Ro(t){return x.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===bo}function Ao(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...c)=>{const l=i(...c);return r(...c),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function Co(t){var o,r;let e=(o=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var So=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Oo=So.reduce((t,e)=>{const n=yo(`Primitive.${e}`),o=x.forwardRef((r,i)=>{const{asChild:s,...c}=r,l=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(l,{...c,ref:i})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{}),Po="Portal",Te=x.forwardRef((t,e)=>{var c;const{container:n,...o}=t,[r,i]=x.useState(!1);ht(()=>i(!0),[]);const s=n||r&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return s?Ke.createPortal(C.jsx(Oo.div,{...o,ref:e}),s):null});Te.displayName=Po;const Ko=({open:t,onClose:e,anchorRef:n,placement:o="bottom-end",children:r})=>{const i=x.useRef(null);if(x.useEffect(()=>{if(!t)return;const f=a=>{var u,m;t&&((u=i.current)!=null&&u.contains(a.target)||(m=n.current)!=null&&m.contains(a.target)||e())};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[t,e,n]),!t)return null;const s=o.startsWith("top")?"top":"bottom",c=o.endsWith("end")?"end":"start",l=o.startsWith("top")?8:4;return C.jsxs(po,{children:[C.jsx(ho,{virtualRef:n}),C.jsx(Te,{children:C.jsx(Ge,{onEscapeKeyDown:f=>{f.preventDefault(),e()},onPointerDownOutside:f=>{var a;if((a=n.current)!=null&&a.contains(f.target)){f.preventDefault();return}e()},children:C.jsx(go,{ref:i,side:s,align:c,sideOffset:l,className:`popover popover-${o}`,role:"dialog",children:r})})})]})};function Eo(t){const e=t+"CollectionProvider",[n,o]=Nt(e),[r,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:h,children:w}=g,b=Z.useRef(null),y=Z.useRef(new Map).current;return C.jsx(r,{scope:h,itemMap:y,collectionRef:b,children:w})};s.displayName=e;const c=t+"CollectionSlot",l=Ut(c),f=Z.forwardRef((g,h)=>{const{scope:w,children:b}=g,y=i(c,w),v=st(h,y.collectionRef);return C.jsx(l,{ref:v,children:b})});f.displayName=c;const a=t+"CollectionItemSlot",u="data-radix-collection-item",m=Ut(a),d=Z.forwardRef((g,h)=>{const{scope:w,children:b,...y}=g,v=Z.useRef(null),A=st(h,v),R=i(a,w);return Z.useEffect(()=>(R.itemMap.set(v,{ref:v,...y}),()=>void R.itemMap.delete(v))),C.jsx(m,{[u]:"",ref:A,children:b})});d.displayName=a;function p(g){const h=i(t+"CollectionConsumer",g);return Z.useCallback(()=>{const b=h.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${u}]`));return Array.from(h.itemMap.values()).sort((R,P)=>y.indexOf(R.ref.current)-y.indexOf(P.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:s,Slot:f,ItemSlot:d},p,o]}var To=x.createContext(void 0);function Do(t){const e=x.useContext(To);return t||e||"ltr"}var Et="rovingFocusGroup.onEntryFocus",Io={bubbles:!1,cancelable:!0},ft="RovingFocusGroup",[Mt,De,Mo]=Eo(ft),[No]=Nt(ft,[Mo]),[Fo,Lo]=No(ft),Ie=x.forwardRef((t,e)=>C.jsx(Mt.Provider,{scope:t.__scopeRovingFocusGroup,children:C.jsx(Mt.Slot,{scope:t.__scopeRovingFocusGroup,children:C.jsx(_o,{...t,ref:e})})}));Ie.displayName=ft;var _o=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:r=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:f,preventScrollOnEntryFocus:a=!1,...u}=t,m=x.useRef(null),d=st(e,m),p=Do(i),[g,h]=qe({prop:s,defaultProp:c??null,onChange:l,caller:ft}),[w,b]=x.useState(!1),y=ce(f),v=De(n),A=x.useRef(!1),[R,P]=x.useState(0);return x.useEffect(()=>{const O=m.current;if(O)return O.addEventListener(Et,y),()=>O.removeEventListener(Et,y)},[y]),C.jsx(Fo,{scope:n,orientation:o,dir:p,loop:r,currentTabStopId:g,onItemFocus:x.useCallback(O=>h(O),[h]),onItemShiftTab:x.useCallback(()=>b(!0),[]),onFocusableItemAdd:x.useCallback(()=>P(O=>O+1),[]),onFocusableItemRemove:x.useCallback(()=>P(O=>O-1),[]),children:C.jsx(lt.div,{tabIndex:w||R===0?-1:0,"data-orientation":o,...u,ref:d,style:{outline:"none",...t.style},onMouseDown:tt(t.onMouseDown,()=>{A.current=!0}),onFocus:tt(t.onFocus,O=>{const L=!A.current;if(O.target===O.currentTarget&&L&&!w){const D=new CustomEvent(Et,Io);if(O.currentTarget.dispatchEvent(D),!D.defaultPrevented){const M=v().filter(E=>E.focusable),F=M.find(E=>E.active),I=M.find(E=>E.id===g),$=[F,I,...M].filter(Boolean).map(E=>E.ref.current);Fe($,a)}}A.current=!1}),onBlur:tt(t.onBlur,()=>b(!1))})})}),Me="RovingFocusGroupItem",Ne=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:r=!1,tabStopId:i,children:s,...c}=t,l=Ue(),f=i||l,a=Lo(Me,n),u=a.currentTabStopId===f,m=De(n),{onFocusableItemAdd:d,onFocusableItemRemove:p,currentTabStopId:g}=a;return x.useEffect(()=>{if(o)return d(),()=>p()},[o,d,p]),C.jsx(Mt.ItemSlot,{scope:n,id:f,focusable:o,active:r,children:C.jsx(lt.span,{tabIndex:u?0:-1,"data-orientation":a.orientation,...c,ref:e,onMouseDown:tt(t.onMouseDown,h=>{o?a.onItemFocus(f):h.preventDefault()}),onFocus:tt(t.onFocus,()=>a.onItemFocus(f)),onKeyDown:tt(t.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){a.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const w=ko(h,a.orientation,a.dir);if(w!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let y=m().filter(v=>v.focusable).map(v=>v.ref.current);if(w==="last")y.reverse();else if(w==="prev"||w==="next"){w==="prev"&&y.reverse();const v=y.indexOf(h.currentTarget);y=a.loop?Wo(y,v+1):y.slice(v+1)}setTimeout(()=>Fe(y))}}),children:typeof s=="function"?s({isCurrentTabStop:u,hasTabStop:g!=null}):s})})});Ne.displayName=Me;var $o={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jo(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ko(t,e,n){const o=jo(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return $o[o]}function Fe(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}function Wo(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var Ho=Ie,Bo=Ne;const Xo=({icon:t,children:e,onClick:n,danger:o,disabled:r,checked:i,checkbox:s,note:c,trailing:l})=>C.jsx(Bo,{asChild:!0,focusable:!r,active:!1,children:C.jsxs("button",{type:"button",role:i===void 0?"menuitem":s?"menuitemcheckbox":"menuitemradio","aria-checked":i,className:`menu-item${o?" menu-item-danger":""}`,onClick:n,disabled:r,children:[i!==void 0&&C.jsx("span",{className:"menu-item-check","aria-hidden":"true",children:i&&C.jsx(Ze,{size:12})}),t&&C.jsx("span",{className:"menu-item-icon",children:t}),C.jsxs("span",{className:"menu-item-label",children:[e,c&&C.jsx("span",{className:"menu-item-note",children:c})]}),l!==void 0&&C.jsx("span",{className:"menu-item-trailing",children:l})]})}),Go=()=>C.jsx("div",{className:"menu-divider",role:"separator"}),Uo=({children:t})=>C.jsx(Ho,{asChild:!0,orientation:"vertical",loop:!0,children:C.jsx("div",{className:"menu",role:"menu",children:t})});export{Uo as M,Ko as P,Xo as a,Go as b};
1
+ import{r as x,x as Ve,j as C,a3 as Ye,a2 as Ke,R as Z}from"./index-DI1fGIyj.js";import{P as lt,b as ht,a as st,u as ce,f as Nt,i as Xe,D as Ge,g as Ut,d as Ue,e as tt,c as qe}from"./index-HDQVe1gi.js";import{C as Ze}from"./check-BdTh1Sq7.js";const Je=["top","right","bottom","left"],U=Math.min,j=Math.max,gt=Math.round,mt=Math.floor,V=t=>({x:t,y:t}),Qe={left:"right",right:"left",bottom:"top",top:"bottom"};function Tt(t,e,n){return j(t,U(e,n))}function K(t,e){return typeof t=="function"?t(e):t}function X(t){return t.split("-")[0]}function ot(t){return t.split("-")[1]}function Ft(t){return t==="x"?"y":"x"}function Lt(t){return t==="y"?"height":"width"}function z(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function _t(t){return Ft(z(t))}function tn(t,e,n){n===void 0&&(n=!1);const o=ot(t),r=_t(t),i=Lt(r);let s=r==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(s=wt(s)),[s,wt(s)]}function en(t){const e=wt(t);return[Dt(t),e,Dt(e)]}function Dt(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const qt=["left","right"],Zt=["right","left"],nn=["top","bottom"],on=["bottom","top"];function rn(t,e,n){switch(t){case"top":case"bottom":return n?e?Zt:qt:e?qt:Zt;case"left":case"right":return e?nn:on;default:return[]}}function sn(t,e,n,o){const r=ot(t);let i=rn(X(t),n==="start",o);return r&&(i=i.map(s=>s+"-"+r),e&&(i=i.concat(i.map(Dt)))),i}function wt(t){const e=X(t);return Qe[e]+t.slice(e.length)}function cn(t){return{top:0,right:0,bottom:0,left:0,...t}}function le(t){return typeof t!="number"?cn(t):{top:t,right:t,bottom:t,left:t}}function xt(t){const{x:e,y:n,width:o,height:r}=t;return{width:o,height:r,top:n,left:e,right:e+o,bottom:n+r,x:e,y:n}}function Jt(t,e,n){let{reference:o,floating:r}=t;const i=z(e),s=_t(e),c=Lt(s),l=X(e),f=i==="y",a=o.x+o.width/2-r.width/2,u=o.y+o.height/2-r.height/2,m=o[c]/2-r[c]/2;let d;switch(l){case"top":d={x:a,y:o.y-r.height};break;case"bottom":d={x:a,y:o.y+o.height};break;case"right":d={x:o.x+o.width,y:u};break;case"left":d={x:o.x-r.width,y:u};break;default:d={x:o.x,y:o.y}}switch(ot(e)){case"start":d[s]-=m*(n&&f?-1:1);break;case"end":d[s]+=m*(n&&f?-1:1);break}return d}async function ln(t,e){var n;e===void 0&&(e={});const{x:o,y:r,platform:i,rects:s,elements:c,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:a="viewport",elementContext:u="floating",altBoundary:m=!1,padding:d=0}=K(e,t),p=le(d),h=c[m?u==="floating"?"reference":"floating":u],w=xt(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(h)))==null||n?h:h.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:f,rootBoundary:a,strategy:l})),b=u==="floating"?{x:o,y:r,width:s.floating.width,height:s.floating.height}:s.reference,y=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),v=await(i.isElement==null?void 0:i.isElement(y))?await(i.getScale==null?void 0:i.getScale(y))||{x:1,y:1}:{x:1,y:1},A=xt(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:b,offsetParent:y,strategy:l}):b);return{top:(w.top-A.top+p.top)/v.y,bottom:(A.bottom-w.bottom+p.bottom)/v.y,left:(w.left-A.left+p.left)/v.x,right:(A.right-w.right+p.right)/v.x}}const an=50,fn=async(t,e,n)=>{const{placement:o="bottom",strategy:r="absolute",middleware:i=[],platform:s}=n,c=s.detectOverflow?s:{...s,detectOverflow:ln},l=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:t,floating:e,strategy:r}),{x:a,y:u}=Jt(f,o,l),m=o,d=0;const p={};for(let g=0;g<i.length;g++){const h=i[g];if(!h)continue;const{name:w,fn:b}=h,{x:y,y:v,data:A,reset:R}=await b({x:a,y:u,initialPlacement:o,placement:m,strategy:r,middlewareData:p,rects:f,platform:c,elements:{reference:t,floating:e}});a=y??a,u=v??u,p[w]={...p[w],...A},R&&d<an&&(d++,typeof R=="object"&&(R.placement&&(m=R.placement),R.rects&&(f=R.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:r}):R.rects),{x:a,y:u}=Jt(f,m,l)),g=-1)}return{x:a,y:u,placement:m,strategy:r,middlewareData:p}},un=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:r,rects:i,platform:s,elements:c,middlewareData:l}=e,{element:f,padding:a=0}=K(t,e)||{};if(f==null)return{};const u=le(a),m={x:n,y:o},d=_t(r),p=Lt(d),g=await s.getDimensions(f),h=d==="y",w=h?"top":"left",b=h?"bottom":"right",y=h?"clientHeight":"clientWidth",v=i.reference[p]+i.reference[d]-m[d]-i.floating[p],A=m[d]-i.reference[d],R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f));let P=R?R[y]:0;(!P||!await(s.isElement==null?void 0:s.isElement(R)))&&(P=c.floating[y]||i.floating[p]);const O=v/2-A/2,L=P/2-g[p]/2-1,D=U(u[w],L),M=U(u[b],L),F=D,I=P-g[p]-M,T=P/2-g[p]/2+O,$=Tt(F,T,I),E=!l.arrow&&ot(r)!=null&&T!==$&&i.reference[p]/2-(T<F?D:M)-g[p]/2<0,N=E?T<F?T-F:T-I:0;return{[d]:m[d]+N,data:{[d]:$,centerOffset:T-$-N,...E&&{alignmentOffset:N}},reset:E}}}),dn=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:r,middlewareData:i,rects:s,initialPlacement:c,platform:l,elements:f}=e,{mainAxis:a=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...h}=K(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const w=X(r),b=z(c),y=X(c)===c,v=await(l.isRTL==null?void 0:l.isRTL(f.floating)),A=m||(y||!g?[wt(c)]:en(c)),R=p!=="none";!m&&R&&A.push(...sn(c,g,p,v));const P=[c,...A],O=await l.detectOverflow(e,h),L=[];let D=((o=i.flip)==null?void 0:o.overflows)||[];if(a&&L.push(O[w]),u){const T=tn(r,s,v);L.push(O[T[0]],O[T[1]])}if(D=[...D,{placement:r,overflows:L}],!L.every(T=>T<=0)){var M,F;const T=(((M=i.flip)==null?void 0:M.index)||0)+1,$=P[T];if($&&(!(u==="alignment"?b!==z($):!1)||D.every(S=>z(S.placement)===b?S.overflows[0]>0:!0)))return{data:{index:T,overflows:D},reset:{placement:$}};let E=(F=D.filter(N=>N.overflows[0]<=0).sort((N,S)=>N.overflows[1]-S.overflows[1])[0])==null?void 0:F.placement;if(!E)switch(d){case"bestFit":{var I;const N=(I=D.filter(S=>{if(R){const _=z(S.placement);return _===b||_==="y"}return!0}).map(S=>[S.placement,S.overflows.filter(_=>_>0).reduce((_,B)=>_+B,0)]).sort((S,_)=>S[1]-_[1])[0])==null?void 0:I[0];N&&(E=N);break}case"initialPlacement":E=c;break}if(r!==E)return{reset:{placement:E}}}return{}}}};function Qt(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function te(t){return Je.some(e=>t[e]>=0)}const mn=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:o}=e,{strategy:r="referenceHidden",...i}=K(t,e);switch(r){case"referenceHidden":{const s=await o.detectOverflow(e,{...i,elementContext:"reference"}),c=Qt(s,n.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:te(c)}}}case"escaped":{const s=await o.detectOverflow(e,{...i,altBoundary:!0}),c=Qt(s,n.floating);return{data:{escapedOffsets:c,escaped:te(c)}}}default:return{}}}}},ae=new Set(["left","top"]);async function pn(t,e){const{placement:n,platform:o,elements:r}=t,i=await(o.isRTL==null?void 0:o.isRTL(r.floating)),s=X(n),c=ot(n),l=z(n)==="y",f=ae.has(s)?-1:1,a=i&&l?-1:1,u=K(e,t);let{mainAxis:m,crossAxis:d,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&typeof p=="number"&&(d=c==="end"?p*-1:p),l?{x:d*a,y:m*f}:{x:m*f,y:d*a}}const hn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:r,y:i,placement:s,middlewareData:c}=e,l=await pn(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:r+l.x,y:i+l.y,data:{...l,placement:s}}}}},gn=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:r,platform:i}=e,{mainAxis:s=!0,crossAxis:c=!1,limiter:l={fn:w=>{let{x:b,y}=w;return{x:b,y}}},...f}=K(t,e),a={x:n,y:o},u=await i.detectOverflow(e,f),m=z(X(r)),d=Ft(m);let p=a[d],g=a[m];if(s){const w=d==="y"?"top":"left",b=d==="y"?"bottom":"right",y=p+u[w],v=p-u[b];p=Tt(y,p,v)}if(c){const w=m==="y"?"top":"left",b=m==="y"?"bottom":"right",y=g+u[w],v=g-u[b];g=Tt(y,g,v)}const h=l.fn({...e,[d]:p,[m]:g});return{...h,data:{x:h.x-n,y:h.y-o,enabled:{[d]:s,[m]:c}}}}}},wn=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:o,placement:r,rects:i,middlewareData:s}=e,{offset:c=0,mainAxis:l=!0,crossAxis:f=!0}=K(t,e),a={x:n,y:o},u=z(r),m=Ft(u);let d=a[m],p=a[u];const g=K(c,e),h=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(l){const y=m==="y"?"height":"width",v=i.reference[m]-i.floating[y]+h.mainAxis,A=i.reference[m]+i.reference[y]-h.mainAxis;d<v?d=v:d>A&&(d=A)}if(f){var w,b;const y=m==="y"?"width":"height",v=ae.has(X(r)),A=i.reference[u]-i.floating[y]+(v&&((w=s.offset)==null?void 0:w[u])||0)+(v?0:h.crossAxis),R=i.reference[u]+i.reference[y]+(v?0:((b=s.offset)==null?void 0:b[u])||0)-(v?h.crossAxis:0);p<A?p=A:p>R&&(p=R)}return{[m]:d,[u]:p}}}},xn=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,o;const{placement:r,rects:i,platform:s,elements:c}=e,{apply:l=()=>{},...f}=K(t,e),a=await s.detectOverflow(e,f),u=X(r),m=ot(r),d=z(r)==="y",{width:p,height:g}=i.floating;let h,w;u==="top"||u==="bottom"?(h=u,w=m===(await(s.isRTL==null?void 0:s.isRTL(c.floating))?"start":"end")?"left":"right"):(w=u,h=m==="end"?"top":"bottom");const b=g-a.top-a.bottom,y=p-a.left-a.right,v=U(g-a[h],b),A=U(p-a[w],y),R=!e.middlewareData.shift;let P=v,O=A;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=y),(o=e.middlewareData.shift)!=null&&o.enabled.y&&(P=b),R&&!m){const D=j(a.left,0),M=j(a.right,0),F=j(a.top,0),I=j(a.bottom,0);d?O=p-2*(D!==0||M!==0?D+M:j(a.left,a.right)):P=g-2*(F!==0||I!==0?F+I:j(a.top,a.bottom))}await l({...e,availableWidth:O,availableHeight:P});const L=await s.getDimensions(c.floating);return p!==L.width||g!==L.height?{reset:{rects:!0}}:{}}}};function bt(){return typeof window<"u"}function rt(t){return fe(t)?(t.nodeName||"").toLowerCase():"#document"}function k(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Y(t){var e;return(e=(fe(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function fe(t){return bt()?t instanceof Node||t instanceof k(t).Node:!1}function W(t){return bt()?t instanceof Element||t instanceof k(t).Element:!1}function G(t){return bt()?t instanceof HTMLElement||t instanceof k(t).HTMLElement:!1}function ee(t){return!bt()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof k(t).ShadowRoot}function at(t){const{overflow:e,overflowX:n,overflowY:o,display:r}=H(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&r!=="inline"&&r!=="contents"}function yn(t){return/^(table|td|th)$/.test(rt(t))}function Rt(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const vn=/transform|translate|scale|rotate|perspective|filter/,bn=/paint|layout|strict|content/,J=t=>!!t&&t!=="none";let St;function $t(t){const e=W(t)?H(t):t;return J(e.transform)||J(e.translate)||J(e.scale)||J(e.rotate)||J(e.perspective)||!jt()&&(J(e.backdropFilter)||J(e.filter))||vn.test(e.willChange||"")||bn.test(e.contain||"")}function Rn(t){let e=q(t);for(;G(e)&&!nt(e);){if($t(e))return e;if(Rt(e))return null;e=q(e)}return null}function jt(){return St==null&&(St=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),St}function nt(t){return/^(html|body|#document)$/.test(rt(t))}function H(t){return k(t).getComputedStyle(t)}function At(t){return W(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function q(t){if(rt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||ee(t)&&t.host||Y(t);return ee(e)?e.host:e}function ue(t){const e=q(t);return nt(e)?t.ownerDocument?t.ownerDocument.body:t.body:G(e)&&at(e)?e:ue(e)}function ct(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=ue(t),i=r===((o=t.ownerDocument)==null?void 0:o.body),s=k(r);if(i){const c=It(s);return e.concat(s,s.visualViewport||[],at(r)?r:[],c&&n?ct(c):[])}else return e.concat(r,ct(r,[],n))}function It(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function de(t){const e=H(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const r=G(t),i=r?t.offsetWidth:n,s=r?t.offsetHeight:o,c=gt(n)!==i||gt(o)!==s;return c&&(n=i,o=s),{width:n,height:o,$:c}}function kt(t){return W(t)?t:t.contextElement}function et(t){const e=kt(t);if(!G(e))return V(1);const n=e.getBoundingClientRect(),{width:o,height:r,$:i}=de(e);let s=(i?gt(n.width):n.width)/o,c=(i?gt(n.height):n.height)/r;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const An=V(0);function me(t){const e=k(t);return!jt()||!e.visualViewport?An:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Cn(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==k(t)?!1:e}function Q(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=kt(t);let s=V(1);e&&(o?W(o)&&(s=et(o)):s=et(t));const c=Cn(i,n,o)?me(i):V(0);let l=(r.left+c.x)/s.x,f=(r.top+c.y)/s.y,a=r.width/s.x,u=r.height/s.y;if(i){const m=k(i),d=o&&W(o)?k(o):o;let p=m,g=It(p);for(;g&&o&&d!==p;){const h=et(g),w=g.getBoundingClientRect(),b=H(g),y=w.left+(g.clientLeft+parseFloat(b.paddingLeft))*h.x,v=w.top+(g.clientTop+parseFloat(b.paddingTop))*h.y;l*=h.x,f*=h.y,a*=h.x,u*=h.y,l+=y,f+=v,p=k(g),g=It(p)}}return xt({width:a,height:u,x:l,y:f})}function Ct(t,e){const n=At(t).scrollLeft;return e?e.left+n:Q(Y(t)).left+n}function pe(t,e){const n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-Ct(t,n),r=n.top+e.scrollTop;return{x:o,y:r}}function Sn(t){let{elements:e,rect:n,offsetParent:o,strategy:r}=t;const i=r==="fixed",s=Y(o),c=e?Rt(e.floating):!1;if(o===s||c&&i)return n;let l={scrollLeft:0,scrollTop:0},f=V(1);const a=V(0),u=G(o);if((u||!u&&!i)&&((rt(o)!=="body"||at(s))&&(l=At(o)),u)){const d=Q(o);f=et(o),a.x=d.x+o.clientLeft,a.y=d.y+o.clientTop}const m=s&&!u&&!i?pe(s,l):V(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-l.scrollLeft*f.x+a.x+m.x,y:n.y*f.y-l.scrollTop*f.y+a.y+m.y}}function On(t){return Array.from(t.getClientRects())}function Pn(t){const e=Y(t),n=At(t),o=t.ownerDocument.body,r=j(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=j(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+Ct(t);const c=-n.scrollTop;return H(o).direction==="rtl"&&(s+=j(e.clientWidth,o.clientWidth)-r),{width:r,height:i,x:s,y:c}}const ne=25;function En(t,e){const n=k(t),o=Y(t),r=n.visualViewport;let i=o.clientWidth,s=o.clientHeight,c=0,l=0;if(r){i=r.width,s=r.height;const a=jt();(!a||a&&e==="fixed")&&(c=r.offsetLeft,l=r.offsetTop)}const f=Ct(o);if(f<=0){const a=o.ownerDocument,u=a.body,m=getComputedStyle(u),d=a.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,p=Math.abs(o.clientWidth-u.clientWidth-d);p<=ne&&(i-=p)}else f<=ne&&(i+=f);return{width:i,height:s,x:c,y:l}}function Tn(t,e){const n=Q(t,!0,e==="fixed"),o=n.top+t.clientTop,r=n.left+t.clientLeft,i=G(t)?et(t):V(1),s=t.clientWidth*i.x,c=t.clientHeight*i.y,l=r*i.x,f=o*i.y;return{width:s,height:c,x:l,y:f}}function oe(t,e,n){let o;if(e==="viewport")o=En(t,n);else if(e==="document")o=Pn(Y(t));else if(W(e))o=Tn(e,n);else{const r=me(t);o={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return xt(o)}function he(t,e){const n=q(t);return n===e||!W(n)||nt(n)?!1:H(n).position==="fixed"||he(n,e)}function Dn(t,e){const n=e.get(t);if(n)return n;let o=ct(t,[],!1).filter(c=>W(c)&&rt(c)!=="body"),r=null;const i=H(t).position==="fixed";let s=i?q(t):t;for(;W(s)&&!nt(s);){const c=H(s),l=$t(s);!l&&c.position==="fixed"&&(r=null),(i?!l&&!r:!l&&c.position==="static"&&!!r&&(r.position==="absolute"||r.position==="fixed")||at(s)&&!l&&he(t,s))?o=o.filter(a=>a!==s):r=c,s=q(s)}return e.set(t,o),o}function In(t){let{element:e,boundary:n,rootBoundary:o,strategy:r}=t;const s=[...n==="clippingAncestors"?Rt(e)?[]:Dn(e,this._c):[].concat(n),o],c=oe(e,s[0],r);let l=c.top,f=c.right,a=c.bottom,u=c.left;for(let m=1;m<s.length;m++){const d=oe(e,s[m],r);l=j(d.top,l),f=U(d.right,f),a=U(d.bottom,a),u=j(d.left,u)}return{width:f-u,height:a-l,x:u,y:l}}function Mn(t){const{width:e,height:n}=de(t);return{width:e,height:n}}function Nn(t,e,n){const o=G(e),r=Y(e),i=n==="fixed",s=Q(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const l=V(0);function f(){l.x=Ct(r)}if(o||!o&&!i)if((rt(e)!=="body"||at(r))&&(c=At(e)),o){const d=Q(e,!0,i,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}else r&&f();i&&!o&&r&&f();const a=r&&!o&&!i?pe(r,c):V(0),u=s.left+c.scrollLeft-l.x-a.x,m=s.top+c.scrollTop-l.y-a.y;return{x:u,y:m,width:s.width,height:s.height}}function Ot(t){return H(t).position==="static"}function re(t,e){if(!G(t)||H(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Y(t)===n&&(n=n.ownerDocument.body),n}function ge(t,e){const n=k(t);if(Rt(t))return n;if(!G(t)){let r=q(t);for(;r&&!nt(r);){if(W(r)&&!Ot(r))return r;r=q(r)}return n}let o=re(t,e);for(;o&&yn(o)&&Ot(o);)o=re(o,e);return o&&nt(o)&&Ot(o)&&!$t(o)?n:o||Rn(t)||n}const Fn=async function(t){const e=this.getOffsetParent||ge,n=this.getDimensions,o=await n(t.floating);return{reference:Nn(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function Ln(t){return H(t).direction==="rtl"}const _n={convertOffsetParentRelativeRectToViewportRelativeRect:Sn,getDocumentElement:Y,getClippingRect:In,getOffsetParent:ge,getElementRects:Fn,getClientRects:On,getDimensions:Mn,getScale:et,isElement:W,isRTL:Ln};function we(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function $n(t,e){let n=null,o;const r=Y(t);function i(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function s(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),i();const f=t.getBoundingClientRect(),{left:a,top:u,width:m,height:d}=f;if(c||e(),!m||!d)return;const p=mt(u),g=mt(r.clientWidth-(a+m)),h=mt(r.clientHeight-(u+d)),w=mt(a),y={rootMargin:-p+"px "+-g+"px "+-h+"px "+-w+"px",threshold:j(0,U(1,l))||1};let v=!0;function A(R){const P=R[0].intersectionRatio;if(P!==l){if(!v)return s();P?s(!1,P):o=setTimeout(()=>{s(!1,1e-7)},1e3)}P===1&&!we(f,t.getBoundingClientRect())&&s(),v=!1}try{n=new IntersectionObserver(A,{...y,root:r.ownerDocument})}catch{n=new IntersectionObserver(A,y)}n.observe(t)}return s(!0),i}function jn(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:r=!0,ancestorResize:i=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,f=kt(t),a=r||i?[...f?ct(f):[],...e?ct(e):[]]:[];a.forEach(w=>{r&&w.addEventListener("scroll",n,{passive:!0}),i&&w.addEventListener("resize",n)});const u=f&&c?$n(f,n):null;let m=-1,d=null;s&&(d=new ResizeObserver(w=>{let[b]=w;b&&b.target===f&&d&&e&&(d.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var y;(y=d)==null||y.observe(e)})),n()}),f&&!l&&d.observe(f),e&&d.observe(e));let p,g=l?Q(t):null;l&&h();function h(){const w=Q(t);g&&!we(g,w)&&n(),g=w,p=requestAnimationFrame(h)}return n(),()=>{var w;a.forEach(b=>{r&&b.removeEventListener("scroll",n),i&&b.removeEventListener("resize",n)}),u==null||u(),(w=d)==null||w.disconnect(),d=null,l&&cancelAnimationFrame(p)}}const kn=hn,Wn=gn,Hn=dn,Bn=xn,zn=mn,ie=un,Vn=wn,Yn=(t,e,n)=>{const o=new Map,r={platform:_n,...n},i={...r.platform,_c:o};return fn(t,e,{...r,platform:i})};var Kn=typeof document<"u",Xn=function(){},pt=Kn?x.useLayoutEffect:Xn;function yt(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,o,r;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(o=n;o--!==0;)if(!yt(t[o],e[o]))return!1;return!0}if(r=Object.keys(t),n=r.length,n!==Object.keys(e).length)return!1;for(o=n;o--!==0;)if(!{}.hasOwnProperty.call(e,r[o]))return!1;for(o=n;o--!==0;){const i=r[o];if(!(i==="_owner"&&t.$$typeof)&&!yt(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function xe(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function se(t,e){const n=xe(t);return Math.round(e*n)/n}function Pt(t){const e=x.useRef(t);return pt(()=>{e.current=t}),e}function Gn(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:o=[],platform:r,elements:{reference:i,floating:s}={},transform:c=!0,whileElementsMounted:l,open:f}=t,[a,u]=x.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[m,d]=x.useState(o);yt(m,o)||d(o);const[p,g]=x.useState(null),[h,w]=x.useState(null),b=x.useCallback(S=>{S!==R.current&&(R.current=S,g(S))},[]),y=x.useCallback(S=>{S!==P.current&&(P.current=S,w(S))},[]),v=i||p,A=s||h,R=x.useRef(null),P=x.useRef(null),O=x.useRef(a),L=l!=null,D=Pt(l),M=Pt(r),F=Pt(f),I=x.useCallback(()=>{if(!R.current||!P.current)return;const S={placement:e,strategy:n,middleware:m};M.current&&(S.platform=M.current),Yn(R.current,P.current,S).then(_=>{const B={..._,isPositioned:F.current!==!1};T.current&&!yt(O.current,B)&&(O.current=B,Ve.flushSync(()=>{u(B)}))})},[m,e,n,M,F]);pt(()=>{f===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,u(S=>({...S,isPositioned:!1})))},[f]);const T=x.useRef(!1);pt(()=>(T.current=!0,()=>{T.current=!1}),[]),pt(()=>{if(v&&(R.current=v),A&&(P.current=A),v&&A){if(D.current)return D.current(v,A,I);I()}},[v,A,I,D,L]);const $=x.useMemo(()=>({reference:R,floating:P,setReference:b,setFloating:y}),[b,y]),E=x.useMemo(()=>({reference:v,floating:A}),[v,A]),N=x.useMemo(()=>{const S={position:n,left:0,top:0};if(!E.floating)return S;const _=se(E.floating,a.x),B=se(E.floating,a.y);return c?{...S,transform:"translate("+_+"px, "+B+"px)",...xe(E.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:_,top:B}},[n,c,E.floating,a.x,a.y]);return x.useMemo(()=>({...a,update:I,refs:$,elements:E,floatingStyles:N}),[a,I,$,E,N])}const Un=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:o,padding:r}=typeof t=="function"?t(n):t;return o&&e(o)?o.current!=null?ie({element:o.current,padding:r}).fn(n):{}:o?ie({element:o,padding:r}).fn(n):{}}}},qn=(t,e)=>{const n=kn(t);return{name:n.name,fn:n.fn,options:[t,e]}},Zn=(t,e)=>{const n=Wn(t);return{name:n.name,fn:n.fn,options:[t,e]}},Jn=(t,e)=>({fn:Vn(t).fn,options:[t,e]}),Qn=(t,e)=>{const n=Hn(t);return{name:n.name,fn:n.fn,options:[t,e]}},to=(t,e)=>{const n=Bn(t);return{name:n.name,fn:n.fn,options:[t,e]}},eo=(t,e)=>{const n=zn(t);return{name:n.name,fn:n.fn,options:[t,e]}},no=(t,e)=>{const n=Un(t);return{name:n.name,fn:n.fn,options:[t,e]}};var oo="Arrow",ye=x.forwardRef((t,e)=>{const{children:n,width:o=10,height:r=5,...i}=t;return C.jsx(lt.svg,{...i,ref:e,width:o,height:r,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:C.jsx("polygon",{points:"0,0 30,0 15,10"})})});ye.displayName=oo;var ro=ye;function io(t){const[e,n]=x.useState(void 0);return ht(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const o=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;const i=r[0];let s,c;if("borderBoxSize"in i){const l=i.borderBoxSize,f=Array.isArray(l)?l[0]:l;s=f.inlineSize,c=f.blockSize}else s=t.offsetWidth,c=t.offsetHeight;n({width:s,height:c})});return o.observe(t,{box:"border-box"}),()=>o.unobserve(t)}else n(void 0)},[t]),e}var Wt="Popper",[ve]=Nt(Wt),[so,be]=ve(Wt),Re=t=>{const{__scopePopper:e,children:n}=t,[o,r]=x.useState(null);return C.jsx(so,{scope:e,anchor:o,onAnchorChange:r,children:n})};Re.displayName=Wt;var Ae="PopperAnchor",Ce=x.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:o,...r}=t,i=be(Ae,n),s=x.useRef(null),c=st(e,s),l=x.useRef(null);return x.useEffect(()=>{const f=l.current;l.current=(o==null?void 0:o.current)||s.current,f!==l.current&&i.onAnchorChange(l.current)}),o?null:C.jsx(lt.div,{...r,ref:c})});Ce.displayName=Ae;var Ht="PopperContent",[co,lo]=ve(Ht),Se=x.forwardRef((t,e)=>{var Bt,zt,Vt,Yt,Kt,Xt;const{__scopePopper:n,side:o="bottom",sideOffset:r=0,align:i="center",alignOffset:s=0,arrowPadding:c=0,avoidCollisions:l=!0,collisionBoundary:f=[],collisionPadding:a=0,sticky:u="partial",hideWhenDetached:m=!1,updatePositionStrategy:d="optimized",onPlaced:p,...g}=t,h=be(Ht,n),[w,b]=x.useState(null),y=st(e,it=>b(it)),[v,A]=x.useState(null),R=io(v),P=(R==null?void 0:R.width)??0,O=(R==null?void 0:R.height)??0,L=o+(i!=="center"?"-"+i:""),D=typeof a=="number"?a:{top:0,right:0,bottom:0,left:0,...a},M=Array.isArray(f)?f:[f],F=M.length>0,I={padding:D,boundary:M.filter(uo),altBoundary:F},{refs:T,floatingStyles:$,placement:E,isPositioned:N,middlewareData:S}=Gn({strategy:"fixed",placement:L,whileElementsMounted:(...it)=>jn(...it,{animationFrame:d==="always"}),elements:{reference:h.anchor},middleware:[qn({mainAxis:r+O,alignmentAxis:s}),l&&Zn({mainAxis:!0,crossAxis:!1,limiter:u==="partial"?Jn():void 0,...I}),l&&Qn({...I}),to({...I,apply:({elements:it,rects:Gt,availableWidth:We,availableHeight:He})=>{const{width:Be,height:ze}=Gt.reference,dt=it.floating.style;dt.setProperty("--radix-popper-available-width",`${We}px`),dt.setProperty("--radix-popper-available-height",`${He}px`),dt.setProperty("--radix-popper-anchor-width",`${Be}px`),dt.setProperty("--radix-popper-anchor-height",`${ze}px`)}}),v&&no({element:v,padding:c}),mo({arrowWidth:P,arrowHeight:O}),m&&eo({strategy:"referenceHidden",...I})]}),[_,B]=Pe(E),ut=ce(p);ht(()=>{N&&(ut==null||ut())},[N,ut]);const Le=(Bt=S.arrow)==null?void 0:Bt.x,_e=(zt=S.arrow)==null?void 0:zt.y,$e=((Vt=S.arrow)==null?void 0:Vt.centerOffset)!==0,[je,ke]=x.useState();return ht(()=>{w&&ke(window.getComputedStyle(w).zIndex)},[w]),C.jsx("div",{ref:T.setFloating,"data-radix-popper-content-wrapper":"",style:{...$,transform:N?$.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:je,"--radix-popper-transform-origin":[(Yt=S.transformOrigin)==null?void 0:Yt.x,(Kt=S.transformOrigin)==null?void 0:Kt.y].join(" "),...((Xt=S.hide)==null?void 0:Xt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:C.jsx(co,{scope:n,placedSide:_,onArrowChange:A,arrowX:Le,arrowY:_e,shouldHideArrow:$e,children:C.jsx(lt.div,{"data-side":_,"data-align":B,...g,ref:y,style:{...g.style,animation:N?void 0:"none"}})})})});Se.displayName=Ht;var Oe="PopperArrow",ao={top:"bottom",right:"left",bottom:"top",left:"right"},fo=x.forwardRef(function(e,n){const{__scopePopper:o,...r}=e,i=lo(Oe,o),s=ao[i.placedSide];return C.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[s]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:C.jsx(ro,{...r,ref:n,style:{...r.style,display:"block"}})})});fo.displayName=Oe;function uo(t){return t!==null}var mo=t=>({name:"transformOrigin",options:t,fn(e){var h,w,b;const{placement:n,rects:o,middlewareData:r}=e,s=((h=r.arrow)==null?void 0:h.centerOffset)!==0,c=s?0:t.arrowWidth,l=s?0:t.arrowHeight,[f,a]=Pe(n),u={start:"0%",center:"50%",end:"100%"}[a],m=(((w=r.arrow)==null?void 0:w.x)??0)+c/2,d=(((b=r.arrow)==null?void 0:b.y)??0)+l/2;let p="",g="";return f==="bottom"?(p=s?u:`${m}px`,g=`${-l}px`):f==="top"?(p=s?u:`${m}px`,g=`${o.floating.height+l}px`):f==="right"?(p=`${-l}px`,g=s?u:`${d}px`):f==="left"&&(p=`${o.floating.width+l}px`,g=s?u:`${d}px`),{data:{x:p,y:g}}}});function Pe(t){const[e,n="center"]=t.split("-");return[e,n]}var po=Re,ho=Ce,go=Se,wo=Symbol.for("react.lazy"),vt=Ye[" use ".trim().toString()];function xo(t){return typeof t=="object"&&t!==null&&"then"in t}function Ee(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===wo&&"_payload"in t&&xo(t._payload)}function yo(t){const e=vo(t),n=x.forwardRef((o,r)=>{let{children:i,...s}=o;Ee(i)&&typeof vt=="function"&&(i=vt(i._payload));const c=x.Children.toArray(i),l=c.find(Ro);if(l){const f=l.props.children,a=c.map(u=>u===l?x.Children.count(f)>1?x.Children.only(null):x.isValidElement(f)?f.props.children:null:u);return C.jsx(e,{...s,ref:r,children:x.isValidElement(f)?x.cloneElement(f,void 0,a):null})}return C.jsx(e,{...s,ref:r,children:i})});return n.displayName=`${t}.Slot`,n}function vo(t){const e=x.forwardRef((n,o)=>{let{children:r,...i}=n;if(Ee(r)&&typeof vt=="function"&&(r=vt(r._payload)),x.isValidElement(r)){const s=Co(r),c=Ao(i,r.props);return r.type!==x.Fragment&&(c.ref=o?Xe(o,s):s),x.cloneElement(r,c)}return x.Children.count(r)>1?x.Children.only(null):null});return e.displayName=`${t}.SlotClone`,e}var bo=Symbol("radix.slottable");function Ro(t){return x.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===bo}function Ao(t,e){const n={...e};for(const o in e){const r=t[o],i=e[o];/^on[A-Z]/.test(o)?r&&i?n[o]=(...c)=>{const l=i(...c);return r(...c),l}:r&&(n[o]=r):o==="style"?n[o]={...r,...i}:o==="className"&&(n[o]=[r,i].filter(Boolean).join(" "))}return{...t,...n}}function Co(t){var o,r;let e=(o=Object.getOwnPropertyDescriptor(t.props,"ref"))==null?void 0:o.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=(r=Object.getOwnPropertyDescriptor(t,"ref"))==null?void 0:r.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}var So=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Oo=So.reduce((t,e)=>{const n=yo(`Primitive.${e}`),o=x.forwardRef((r,i)=>{const{asChild:s,...c}=r,l=s?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),C.jsx(l,{...c,ref:i})});return o.displayName=`Primitive.${e}`,{...t,[e]:o}},{}),Po="Portal",Te=x.forwardRef((t,e)=>{var c;const{container:n,...o}=t,[r,i]=x.useState(!1);ht(()=>i(!0),[]);const s=n||r&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return s?Ke.createPortal(C.jsx(Oo.div,{...o,ref:e}),s):null});Te.displayName=Po;const Ko=({open:t,onClose:e,anchorRef:n,placement:o="bottom-end",children:r})=>{const i=x.useRef(null);if(x.useEffect(()=>{if(!t)return;const f=a=>{var u,m;t&&((u=i.current)!=null&&u.contains(a.target)||(m=n.current)!=null&&m.contains(a.target)||e())};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[t,e,n]),!t)return null;const s=o.startsWith("top")?"top":"bottom",c=o.endsWith("end")?"end":"start",l=o.startsWith("top")?8:4;return C.jsxs(po,{children:[C.jsx(ho,{virtualRef:n}),C.jsx(Te,{children:C.jsx(Ge,{onEscapeKeyDown:f=>{f.preventDefault(),e()},onPointerDownOutside:f=>{var a;if((a=n.current)!=null&&a.contains(f.target)){f.preventDefault();return}e()},children:C.jsx(go,{ref:i,side:s,align:c,sideOffset:l,className:`popover popover-${o}`,role:"dialog",children:r})})})]})};function Eo(t){const e=t+"CollectionProvider",[n,o]=Nt(e),[r,i]=n(e,{collectionRef:{current:null},itemMap:new Map}),s=g=>{const{scope:h,children:w}=g,b=Z.useRef(null),y=Z.useRef(new Map).current;return C.jsx(r,{scope:h,itemMap:y,collectionRef:b,children:w})};s.displayName=e;const c=t+"CollectionSlot",l=Ut(c),f=Z.forwardRef((g,h)=>{const{scope:w,children:b}=g,y=i(c,w),v=st(h,y.collectionRef);return C.jsx(l,{ref:v,children:b})});f.displayName=c;const a=t+"CollectionItemSlot",u="data-radix-collection-item",m=Ut(a),d=Z.forwardRef((g,h)=>{const{scope:w,children:b,...y}=g,v=Z.useRef(null),A=st(h,v),R=i(a,w);return Z.useEffect(()=>(R.itemMap.set(v,{ref:v,...y}),()=>void R.itemMap.delete(v))),C.jsx(m,{[u]:"",ref:A,children:b})});d.displayName=a;function p(g){const h=i(t+"CollectionConsumer",g);return Z.useCallback(()=>{const b=h.collectionRef.current;if(!b)return[];const y=Array.from(b.querySelectorAll(`[${u}]`));return Array.from(h.itemMap.values()).sort((R,P)=>y.indexOf(R.ref.current)-y.indexOf(P.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:s,Slot:f,ItemSlot:d},p,o]}var To=x.createContext(void 0);function Do(t){const e=x.useContext(To);return t||e||"ltr"}var Et="rovingFocusGroup.onEntryFocus",Io={bubbles:!1,cancelable:!0},ft="RovingFocusGroup",[Mt,De,Mo]=Eo(ft),[No]=Nt(ft,[Mo]),[Fo,Lo]=No(ft),Ie=x.forwardRef((t,e)=>C.jsx(Mt.Provider,{scope:t.__scopeRovingFocusGroup,children:C.jsx(Mt.Slot,{scope:t.__scopeRovingFocusGroup,children:C.jsx(_o,{...t,ref:e})})}));Ie.displayName=ft;var _o=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:o,loop:r=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:f,preventScrollOnEntryFocus:a=!1,...u}=t,m=x.useRef(null),d=st(e,m),p=Do(i),[g,h]=qe({prop:s,defaultProp:c??null,onChange:l,caller:ft}),[w,b]=x.useState(!1),y=ce(f),v=De(n),A=x.useRef(!1),[R,P]=x.useState(0);return x.useEffect(()=>{const O=m.current;if(O)return O.addEventListener(Et,y),()=>O.removeEventListener(Et,y)},[y]),C.jsx(Fo,{scope:n,orientation:o,dir:p,loop:r,currentTabStopId:g,onItemFocus:x.useCallback(O=>h(O),[h]),onItemShiftTab:x.useCallback(()=>b(!0),[]),onFocusableItemAdd:x.useCallback(()=>P(O=>O+1),[]),onFocusableItemRemove:x.useCallback(()=>P(O=>O-1),[]),children:C.jsx(lt.div,{tabIndex:w||R===0?-1:0,"data-orientation":o,...u,ref:d,style:{outline:"none",...t.style},onMouseDown:tt(t.onMouseDown,()=>{A.current=!0}),onFocus:tt(t.onFocus,O=>{const L=!A.current;if(O.target===O.currentTarget&&L&&!w){const D=new CustomEvent(Et,Io);if(O.currentTarget.dispatchEvent(D),!D.defaultPrevented){const M=v().filter(E=>E.focusable),F=M.find(E=>E.active),I=M.find(E=>E.id===g),$=[F,I,...M].filter(Boolean).map(E=>E.ref.current);Fe($,a)}}A.current=!1}),onBlur:tt(t.onBlur,()=>b(!1))})})}),Me="RovingFocusGroupItem",Ne=x.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:o=!0,active:r=!1,tabStopId:i,children:s,...c}=t,l=Ue(),f=i||l,a=Lo(Me,n),u=a.currentTabStopId===f,m=De(n),{onFocusableItemAdd:d,onFocusableItemRemove:p,currentTabStopId:g}=a;return x.useEffect(()=>{if(o)return d(),()=>p()},[o,d,p]),C.jsx(Mt.ItemSlot,{scope:n,id:f,focusable:o,active:r,children:C.jsx(lt.span,{tabIndex:u?0:-1,"data-orientation":a.orientation,...c,ref:e,onMouseDown:tt(t.onMouseDown,h=>{o?a.onItemFocus(f):h.preventDefault()}),onFocus:tt(t.onFocus,()=>a.onItemFocus(f)),onKeyDown:tt(t.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){a.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const w=ko(h,a.orientation,a.dir);if(w!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let y=m().filter(v=>v.focusable).map(v=>v.ref.current);if(w==="last")y.reverse();else if(w==="prev"||w==="next"){w==="prev"&&y.reverse();const v=y.indexOf(h.currentTarget);y=a.loop?Wo(y,v+1):y.slice(v+1)}setTimeout(()=>Fe(y))}}),children:typeof s=="function"?s({isCurrentTabStop:u,hasTabStop:g!=null}):s})})});Ne.displayName=Me;var $o={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function jo(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function ko(t,e,n){const o=jo(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(o))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(o)))return $o[o]}function Fe(t,e=!1){const n=document.activeElement;for(const o of t)if(o===n||(o.focus({preventScroll:e}),document.activeElement!==n))return}function Wo(t,e){return t.map((n,o)=>t[(e+o)%t.length])}var Ho=Ie,Bo=Ne;const Xo=({icon:t,children:e,onClick:n,danger:o,disabled:r,checked:i,checkbox:s,note:c,trailing:l})=>C.jsx(Bo,{asChild:!0,focusable:!r,active:!1,children:C.jsxs("button",{type:"button",role:i===void 0?"menuitem":s?"menuitemcheckbox":"menuitemradio","aria-checked":i,className:`menu-item${o?" menu-item-danger":""}`,onClick:n,disabled:r,children:[i!==void 0&&C.jsx("span",{className:"menu-item-check","aria-hidden":"true",children:i&&C.jsx(Ze,{size:12})}),t&&C.jsx("span",{className:"menu-item-icon",children:t}),C.jsxs("span",{className:"menu-item-label",children:[e,c&&C.jsx("span",{className:"menu-item-note",children:c})]}),l!==void 0&&C.jsx("span",{className:"menu-item-trailing",children:l})]})}),Go=()=>C.jsx("div",{className:"menu-divider",role:"separator"}),Uo=({children:t})=>C.jsx(Ho,{asChild:!0,orientation:"vertical",loop:!0,children:C.jsx("div",{className:"menu",role:"menu",children:t})});export{Uo as M,Ko as P,Xo as a,Go as b};
@@ -1,4 +1,4 @@
1
- import{r as c,j as f,a2 as ze,v as Ze}from"./index-BGBqohfQ.js";import{u as de,a as k,P,b as oe,c as qe,d as Z,e as _,f as Qe,g as Je,D as et,h as tt}from"./index-BQ2luT7L.js";var q="focusScope.autoFocusOnMount",Q="focusScope.autoFocusOnUnmount",fe={bubbles:!1,cancelable:!0},nt="FocusScope",Se=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=e,[i,d]=c.useState(null),l=de(o),h=de(a),v=c.useRef(null),p=k(t,u=>d(u)),g=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let u=function(b){if(g.paused||!i)return;const C=b.target;i.contains(C)?v.current=C:D(v.current,{select:!0})},m=function(b){if(g.paused||!i)return;const C=b.relatedTarget;C!==null&&(i.contains(C)||D(v.current,{select:!0}))},y=function(b){if(document.activeElement===document.body)for(const S of b)S.removedNodes.length>0&&D(i)};document.addEventListener("focusin",u),document.addEventListener("focusout",m);const E=new MutationObserver(y);return i&&E.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",u),document.removeEventListener("focusout",m),E.disconnect()}}},[r,i,g.paused]),c.useEffect(()=>{if(i){me.add(g);const u=document.activeElement;if(!i.contains(u)){const y=new CustomEvent(q,fe);i.addEventListener(q,l),i.dispatchEvent(y),y.defaultPrevented||(rt(ut(we(i)),{select:!0}),document.activeElement===u&&D(i))}return()=>{i.removeEventListener(q,l),setTimeout(()=>{const y=new CustomEvent(Q,fe);i.addEventListener(Q,h),i.dispatchEvent(y),y.defaultPrevented||D(u??document.body,{select:!0}),i.removeEventListener(Q,h),me.remove(g)},0)}}},[i,l,h,g]);const w=c.useCallback(u=>{if(!n&&!r||g.paused)return;const m=u.key==="Tab"&&!u.altKey&&!u.ctrlKey&&!u.metaKey,y=document.activeElement;if(m&&y){const E=u.currentTarget,[b,C]=ot(E);b&&C?!u.shiftKey&&y===C?(u.preventDefault(),n&&D(b,{select:!0})):u.shiftKey&&y===b&&(u.preventDefault(),n&&D(C,{select:!0})):y===E&&u.preventDefault()}},[n,r,g.paused]);return f.jsx(P.div,{tabIndex:-1,...s,ref:p,onKeyDown:w})});Se.displayName=nt;function rt(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(D(r,{select:t}),document.activeElement!==n)return}function ot(e){const t=we(e),n=ve(t,e),r=ve(t.reverse(),e);return[n,r]}function we(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 ve(e,t){for(const n of e)if(!at(n,{upTo:t}))return n}function at(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 it(e){return e instanceof HTMLInputElement&&"select"in e}function D(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&it(e)&&t&&e.select()}}var me=ct();function ct(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=he(e,t),e.unshift(t)},remove(t){var n;e=he(e,t),(n=e[0])==null||n.resume()}}}function he(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ut(e){return e.filter(t=>t.tagName!=="A")}var st="Portal",Ne=c.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,a]=c.useState(!1);oe(()=>a(!0),[]);const s=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return s?ze.createPortal(f.jsx(P.div,{...r,ref:t}),s):null});Ne.displayName=st;function lt(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var X=e=>{const{present:t,children:n}=e,r=dt(t),o=typeof n=="function"?n({present:r.isPresent}):c.Children.only(n),a=k(r.ref,ft(o));return typeof n=="function"||r.isPresent?c.cloneElement(o,{ref:a}):null};X.displayName="Presence";function dt(e){const[t,n]=c.useState(),r=c.useRef(null),o=c.useRef(e),a=c.useRef("none"),s=e?"mounted":"unmounted",[i,d]=lt(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{const l=L(r.current);a.current=i==="mounted"?l:"none"},[i]),oe(()=>{const l=r.current,h=o.current;if(h!==e){const p=a.current,g=L(l);e?d("MOUNT"):g==="none"||(l==null?void 0:l.display)==="none"?d("UNMOUNT"):d(h&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),oe(()=>{if(t){let l;const h=t.ownerDocument.defaultView??window,v=g=>{const u=L(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&u&&(d("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",l=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},p=g=>{g.target===t&&(a.current=L(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",v),t.addEventListener("animationend",v),()=>{h.clearTimeout(l),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",v),t.removeEventListener("animationend",v)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:c.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function L(e){return(e==null?void 0:e.animationName)||"none"}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 J=0;function vt(){c.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ge()),document.body.insertAdjacentElement("beforeend",e[1]??ge()),J++,()=>{J===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),J--}},[])}function ge(){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 R=function(){return R=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},R.apply(this,arguments)};function Re(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 mt(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 G="right-scroll-bar-position",H="width-before-scroll-bar",ht="with-scroll-bars-hidden",gt="--removed-body-scroll-bar-size";function ee(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function pt(e,t){var n=c.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 yt=typeof window<"u"?c.useLayoutEffect:c.useEffect,pe=new WeakMap;function Et(e,t){var n=pt(null,function(r){return e.forEach(function(o){return ee(o,r)})});return yt(function(){var r=pe.get(n);if(r){var o=new Set(r),a=new Set(e),s=n.current;o.forEach(function(i){a.has(i)||ee(i,null)}),a.forEach(function(i){o.has(i)||ee(i,s)})}pe.set(n,e)},[e]),n}function bt(e){return e}function Ct(e,t){t===void 0&&(t=bt);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 s=t(a,r);return n.push(s),function(){n=n.filter(function(i){return i!==s})}},assignSyncMedium:function(a){for(r=!0;n.length;){var s=n;n=[],s.forEach(a)}n={push:function(i){return a(i)},filter:function(){return n}}},assignMedium:function(a){r=!0;var s=[];if(n.length){var i=n;n=[],i.forEach(a),s=n}var d=function(){var h=s;s=[],h.forEach(a)},l=function(){return Promise.resolve().then(d)};l(),n={push:function(h){s.push(h),l()},filter:function(h){return s=s.filter(h),n}}}};return o}function St(e){e===void 0&&(e={});var t=Ct(null);return t.options=R({async:!0,ssr:!1},e),t}var Ae=function(e){var t=e.sideCar,n=Re(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 c.createElement(r,R({},n))};Ae.isSideCarExport=!0;function wt(e,t){return e.useMedium(t),Ae}var xe=St(),te=function(){},Y=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:te,onWheelCapture:te,onTouchMoveCapture:te}),o=r[0],a=r[1],s=e.forwardProps,i=e.children,d=e.className,l=e.removeScrollBar,h=e.enabled,v=e.shards,p=e.sideCar,g=e.noRelative,w=e.noIsolation,u=e.inert,m=e.allowPinchZoom,y=e.as,E=y===void 0?"div":y,b=e.gapMode,C=Re(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,A=Et([n,t]),x=R(R({},C),o);return c.createElement(c.Fragment,null,h&&c.createElement(S,{sideCar:xe,removeScrollBar:l,shards:v,noRelative:g,noIsolation:w,inert:u,setCallbacks:a,allowPinchZoom:!!m,lockRef:n,gapMode:b}),s?c.cloneElement(c.Children.only(i),R(R({},x),{ref:A})):c.createElement(E,R({},x,{className:d,ref:A}),i))});Y.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Y.classNames={fullWidth:H,zeroRight:G};var Nt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Rt(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Nt();return t&&e.setAttribute("nonce",t),e}function At(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Dt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Rt())&&(At(t,n),xt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ot=function(){var e=Dt();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},De=function(){var e=Ot(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Pt={left:0,top:0,right:0,gap:0},ne=function(e){return parseInt(e||"",10)||0},Tt=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[ne(n),ne(r),ne(o)]},Mt=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Pt;var t=Tt(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])}},It=De(),F="data-scroll-locked",Ft=function(e,t,n,r){var o=e.left,a=e.top,s=e.right,i=e.gap;return n===void 0&&(n="margin"),`
1
+ import{r as c,j as f,a2 as ze,v as Ze}from"./index-DI1fGIyj.js";import{u as de,a as k,P,b as oe,c as qe,d as Z,e as _,f as Qe,g as Je,D as et,h as tt}from"./index-HDQVe1gi.js";var q="focusScope.autoFocusOnMount",Q="focusScope.autoFocusOnUnmount",fe={bubbles:!1,cancelable:!0},nt="FocusScope",Se=c.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...s}=e,[i,d]=c.useState(null),l=de(o),h=de(a),v=c.useRef(null),p=k(t,u=>d(u)),g=c.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;c.useEffect(()=>{if(r){let u=function(b){if(g.paused||!i)return;const C=b.target;i.contains(C)?v.current=C:D(v.current,{select:!0})},m=function(b){if(g.paused||!i)return;const C=b.relatedTarget;C!==null&&(i.contains(C)||D(v.current,{select:!0}))},y=function(b){if(document.activeElement===document.body)for(const S of b)S.removedNodes.length>0&&D(i)};document.addEventListener("focusin",u),document.addEventListener("focusout",m);const E=new MutationObserver(y);return i&&E.observe(i,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",u),document.removeEventListener("focusout",m),E.disconnect()}}},[r,i,g.paused]),c.useEffect(()=>{if(i){me.add(g);const u=document.activeElement;if(!i.contains(u)){const y=new CustomEvent(q,fe);i.addEventListener(q,l),i.dispatchEvent(y),y.defaultPrevented||(rt(ut(we(i)),{select:!0}),document.activeElement===u&&D(i))}return()=>{i.removeEventListener(q,l),setTimeout(()=>{const y=new CustomEvent(Q,fe);i.addEventListener(Q,h),i.dispatchEvent(y),y.defaultPrevented||D(u??document.body,{select:!0}),i.removeEventListener(Q,h),me.remove(g)},0)}}},[i,l,h,g]);const w=c.useCallback(u=>{if(!n&&!r||g.paused)return;const m=u.key==="Tab"&&!u.altKey&&!u.ctrlKey&&!u.metaKey,y=document.activeElement;if(m&&y){const E=u.currentTarget,[b,C]=ot(E);b&&C?!u.shiftKey&&y===C?(u.preventDefault(),n&&D(b,{select:!0})):u.shiftKey&&y===b&&(u.preventDefault(),n&&D(C,{select:!0})):y===E&&u.preventDefault()}},[n,r,g.paused]);return f.jsx(P.div,{tabIndex:-1,...s,ref:p,onKeyDown:w})});Se.displayName=nt;function rt(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(D(r,{select:t}),document.activeElement!==n)return}function ot(e){const t=we(e),n=ve(t,e),r=ve(t.reverse(),e);return[n,r]}function we(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 ve(e,t){for(const n of e)if(!at(n,{upTo:t}))return n}function at(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 it(e){return e instanceof HTMLInputElement&&"select"in e}function D(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&it(e)&&t&&e.select()}}var me=ct();function ct(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=he(e,t),e.unshift(t)},remove(t){var n;e=he(e,t),(n=e[0])==null||n.resume()}}}function he(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function ut(e){return e.filter(t=>t.tagName!=="A")}var st="Portal",Ne=c.forwardRef((e,t)=>{var i;const{container:n,...r}=e,[o,a]=c.useState(!1);oe(()=>a(!0),[]);const s=n||o&&((i=globalThis==null?void 0:globalThis.document)==null?void 0:i.body);return s?ze.createPortal(f.jsx(P.div,{...r,ref:t}),s):null});Ne.displayName=st;function lt(e,t){return c.useReducer((n,r)=>t[n][r]??n,e)}var X=e=>{const{present:t,children:n}=e,r=dt(t),o=typeof n=="function"?n({present:r.isPresent}):c.Children.only(n),a=k(r.ref,ft(o));return typeof n=="function"||r.isPresent?c.cloneElement(o,{ref:a}):null};X.displayName="Presence";function dt(e){const[t,n]=c.useState(),r=c.useRef(null),o=c.useRef(e),a=c.useRef("none"),s=e?"mounted":"unmounted",[i,d]=lt(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return c.useEffect(()=>{const l=L(r.current);a.current=i==="mounted"?l:"none"},[i]),oe(()=>{const l=r.current,h=o.current;if(h!==e){const p=a.current,g=L(l);e?d("MOUNT"):g==="none"||(l==null?void 0:l.display)==="none"?d("UNMOUNT"):d(h&&p!==g?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,d]),oe(()=>{if(t){let l;const h=t.ownerDocument.defaultView??window,v=g=>{const u=L(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&u&&(d("ANIMATION_END"),!o.current)){const m=t.style.animationFillMode;t.style.animationFillMode="forwards",l=h.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=m)})}},p=g=>{g.target===t&&(a.current=L(r.current))};return t.addEventListener("animationstart",p),t.addEventListener("animationcancel",v),t.addEventListener("animationend",v),()=>{h.clearTimeout(l),t.removeEventListener("animationstart",p),t.removeEventListener("animationcancel",v),t.removeEventListener("animationend",v)}}else d("ANIMATION_END")},[t,d]),{isPresent:["mounted","unmountSuspended"].includes(i),ref:c.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function L(e){return(e==null?void 0:e.animationName)||"none"}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 J=0;function vt(){c.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??ge()),document.body.insertAdjacentElement("beforeend",e[1]??ge()),J++,()=>{J===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),J--}},[])}function ge(){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 R=function(){return R=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},R.apply(this,arguments)};function Re(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 mt(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 G="right-scroll-bar-position",H="width-before-scroll-bar",ht="with-scroll-bars-hidden",gt="--removed-body-scroll-bar-size";function ee(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function pt(e,t){var n=c.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 yt=typeof window<"u"?c.useLayoutEffect:c.useEffect,pe=new WeakMap;function Et(e,t){var n=pt(null,function(r){return e.forEach(function(o){return ee(o,r)})});return yt(function(){var r=pe.get(n);if(r){var o=new Set(r),a=new Set(e),s=n.current;o.forEach(function(i){a.has(i)||ee(i,null)}),a.forEach(function(i){o.has(i)||ee(i,s)})}pe.set(n,e)},[e]),n}function bt(e){return e}function Ct(e,t){t===void 0&&(t=bt);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 s=t(a,r);return n.push(s),function(){n=n.filter(function(i){return i!==s})}},assignSyncMedium:function(a){for(r=!0;n.length;){var s=n;n=[],s.forEach(a)}n={push:function(i){return a(i)},filter:function(){return n}}},assignMedium:function(a){r=!0;var s=[];if(n.length){var i=n;n=[],i.forEach(a),s=n}var d=function(){var h=s;s=[],h.forEach(a)},l=function(){return Promise.resolve().then(d)};l(),n={push:function(h){s.push(h),l()},filter:function(h){return s=s.filter(h),n}}}};return o}function St(e){e===void 0&&(e={});var t=Ct(null);return t.options=R({async:!0,ssr:!1},e),t}var Ae=function(e){var t=e.sideCar,n=Re(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 c.createElement(r,R({},n))};Ae.isSideCarExport=!0;function wt(e,t){return e.useMedium(t),Ae}var xe=St(),te=function(){},Y=c.forwardRef(function(e,t){var n=c.useRef(null),r=c.useState({onScrollCapture:te,onWheelCapture:te,onTouchMoveCapture:te}),o=r[0],a=r[1],s=e.forwardProps,i=e.children,d=e.className,l=e.removeScrollBar,h=e.enabled,v=e.shards,p=e.sideCar,g=e.noRelative,w=e.noIsolation,u=e.inert,m=e.allowPinchZoom,y=e.as,E=y===void 0?"div":y,b=e.gapMode,C=Re(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=p,A=Et([n,t]),x=R(R({},C),o);return c.createElement(c.Fragment,null,h&&c.createElement(S,{sideCar:xe,removeScrollBar:l,shards:v,noRelative:g,noIsolation:w,inert:u,setCallbacks:a,allowPinchZoom:!!m,lockRef:n,gapMode:b}),s?c.cloneElement(c.Children.only(i),R(R({},x),{ref:A})):c.createElement(E,R({},x,{className:d,ref:A}),i))});Y.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Y.classNames={fullWidth:H,zeroRight:G};var Nt=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function Rt(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=Nt();return t&&e.setAttribute("nonce",t),e}function At(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function xt(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var Dt=function(){var e=0,t=null;return{add:function(n){e==0&&(t=Rt())&&(At(t,n),xt(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},Ot=function(){var e=Dt();return function(t,n){c.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},De=function(){var e=Ot(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},Pt={left:0,top:0,right:0,gap:0},ne=function(e){return parseInt(e||"",10)||0},Tt=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[ne(n),ne(r),ne(o)]},Mt=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return Pt;var t=Tt(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])}},It=De(),F="data-scroll-locked",Ft=function(e,t,n,r){var o=e.left,a=e.top,s=e.right,i=e.gap;return n===void 0&&(n="margin"),`
2
2
  .`.concat(ht,` {
3
3
  overflow: hidden `).concat(r,`;
4
4
  padding-right: `).concat(i,"px ").concat(r,`;
@@ -1 +1 @@
1
- import{r as c,i as J,u as Q,b as X,t as ee,j as e,e as B,A as te,_ as ne}from"./index-BGBqohfQ.js";import{f as q,a as re,c as se,h as ae,i as Z,j as ie,k as oe,m as ce}from"./recordings-BWe1ydXm.js";import{P as le}from"./page-header-FXPlo6az.js";import{B as I}from"./button-Cq_zHETv.js";import{E as L}from"./EmptyState-CgzbuUvO.js";import{M as ue}from"./Modal-ChvVUI3B.js";import{P as de,M as fe,a as me}from"./Menu-C173JJ0l.js";import{A as ge}from"./AnnotationOverlay-Cvpkk4r9.js";import{t as O,v as pe,R as he,P as be,n as ye,c as U,o as ve,a as R,f as ke,p as xe,S as V,b as je,d as Me}from"./recordings-n-GTW3aT.js";import{A as we}from"./arrow-left-Dpog9L0F.js";import{T as Re}from"./trash-2-B54e-TfY.js";import{P as Se,a as Ne}from"./play-CWdk0_Sy.js";import{D as Ee}from"./download-DDBRXnAZ.js";import"./utils-CDN07tui.js";import"./index-BQ2luT7L.js";import"./check-C7xu-hGU.js";function Ce(n){const t=[{key:"zip",label:"All videos (zip)",url:re(n.groupId)}];return n.hasComposite&&t.push({key:"composite",label:"Side-by-side video",url:se(n.groupId)}),t.push({key:"bundle",label:"Proof bundle",url:ae(n.groupId)}),n.phones.filter(l=>l.status!=="FAILED"&&l.status!=="DISCARDED").forEach(l=>{t.push({key:`video-${l.recordingId}`,label:`${l.name}: video`,url:Z(n.groupId,l.recordingId,!0)}),l.annotationCount>0&&t.push({key:`annotated-${l.recordingId}`,label:`${l.name}: video with annotations`,url:ie(n.groupId,l.recordingId)})}),t}function Ie(n,t){return t?t.role==="ADMIN"||t.role==="SUPER_ADMIN"?!0:!!n.startedBy&&!!t.userId&&n.startedBy.id===t.userId:!1}function De(n){if(n instanceof q){if(n.code==="not_owner")return"Only the person who recorded it, or an admin, can delete it.";if(n.code==="recording_in_progress")return"It’s still recording. Stop it on Live devices first.";if(n.status===404)return"It was already deleted, or it’s on phones you can’t see."}return`Couldn’t delete the recording: ${n instanceof Error?n.message:String(n)}`}function Ae(n){const t=document.createElement("a");t.href=n,t.download="",document.body.appendChild(t),t.click(),document.body.removeChild(t)}const Te={now:()=>performance.now(),schedule:n=>window.requestAnimationFrame(()=>n()),cancel:n=>window.cancelAnimationFrame(n)},Pe=100,_e=3,Fe=.05;function W(n){return n.ended||Number.isFinite(n.duration)&&n.currentTime>=n.duration-Fe}function Le(n,t=Te){const l=c.useRef(new Map),v=c.useRef(new Map),u=c.useRef(new Map),d=c.useRef({baseMs:0,since:null,running:!1,waiting:!1}),p=c.useRef(null),S=c.useRef(-1/0),k=c.useRef(n);k.current=n;const[D,w]=c.useState({timeMs:0,playing:!1,waiting:!1}),x=()=>d.current.since===null?d.current.baseMs:d.current.baseMs+(t.now()-d.current.since),h=(s,a)=>{l.current.forEach((i,M)=>{var _;const m=v.current.get(M);if(!m||i.error)return;const T=O(s,m.offsetMs,m.durationMs);let C=T==="before"?0:T==="after"?m.durationMs:pe(s,m.offsetMs);Number.isFinite(i.duration)&&(C=Math.min(C,i.duration*1e3));const $=d.current.running?he:be;ye(i.currentTime*1e3,C,$)&&(i.currentTime=C/1e3),a&&T==="playing"?i.paused&&!W(i)&&((_=i.play())==null||_.catch(()=>{})):i.paused||i.pause()})},j=s=>Array.from(l.current.entries()).some(([a,i])=>{const M=v.current.get(a);return!!M&&!i.error&&!W(i)&&O(s,M.offsetMs,M.durationMs)==="playing"&&i.readyState<_e}),g=s=>{const a=t.now();!s&&a-S.current<Pe||(S.current=a,w({timeMs:x(),playing:d.current.running,waiting:d.current.waiting}))},b=()=>{p.current!==null&&t.cancel(p.current),p.current=null},A=()=>{p.current=null;const s=d.current;if(!s.running)return;const a=x();if(a>=k.current){Object.assign(s,{baseMs:k.current,since:null,running:!1,waiting:!1}),h(k.current,!1),g(!0);return}const i=j(a);i!==s.waiting?(s.baseMs=a,s.since=i?null:t.now(),s.waiting=i,h(a,!i),g(!0)):(h(a,!i),g(!1)),p.current=t.schedule(A)},N=()=>{const s=d.current;x()>=k.current?s.baseMs=0:s.baseMs=x(),Object.assign(s,{since:t.now(),running:!0,waiting:!1}),h(s.baseMs,!0),g(!0),b(),p.current=t.schedule(A)},y=()=>{const s=d.current;Object.assign(s,{baseMs:x(),since:null,running:!1,waiting:!1}),b(),h(s.baseMs,!1),g(!0)},f=s=>{const a=d.current,i=U(s,k.current);a.baseMs=i,a.since=a.running&&!a.waiting?t.now():null,h(i,a.running&&!a.waiting),g(!0)},P=c.useCallback((s,a)=>{v.current.set(s,a);let i=u.current.get(s);return i||(i=M=>{if(M){l.current.set(s,M);const m=d.current;h(x(),m.running&&!m.waiting)}else l.current.delete(s)},u.current.set(s,i)),i},[]);return c.useEffect(()=>b,[]),{...D,play:N,pause:y,toggle:()=>d.current.running?y():N(),seek:f,bind:P}}const $e=()=>{},Y="Stop the recording on Live devices first.",Be=1e3;function Oe(n){const t=n;return!t||!t.closest?!1:!!t.closest('input:not([type="range"]):not([type="checkbox"]), select, textarea, [contenteditable="true"], [role="dialog"], [role="menu"]')}function Ue({groupId:n,phone:t,timeMs:l,marks:v,showMarks:u,bind:d}){const[p,S]=c.useState(!1),[k,D]=c.useState(void 0),w=t.status==="FAILED"||t.status==="DISCARDED",x=O(l,t.offsetMs,t.durationMs),h=je(v,l).map(Me).filter(g=>g!==null);let j=null;return w?j=`Recording failed: ${t.failReason??"unknown reason"}`:p?j="Video no longer available":x==="before"&&t.offsetMs>=Be&&(j=`Starts at ${R(t.offsetMs)}`),e.jsxs("figure",{className:"rec-tile theme-dark","aria-label":t.name,children:[e.jsx("figcaption",{className:"rec-tile-name",title:t.name,children:t.name}),e.jsxs("div",{className:"rec-tile-screen",children:[!w&&e.jsx("video",{className:"rec-tile-video",muted:!0,playsInline:!0,preload:"auto",src:Z(n,t.recordingId),ref:d(t.recordingId,{offsetMs:t.offsetMs,durationMs:t.durationMs}),onError:()=>S(!0),onLoadedMetadata:g=>{const b=g.currentTarget;b.videoWidth>0&&b.videoHeight>0&&D(b.videoWidth/b.videoHeight)}}),!w&&u&&e.jsx(ge,{enabled:!1,shape:"RECT",color:"currentColor",onCommit:$e,committed:h,mediaAspect:k}),j&&e.jsx("div",{className:"rec-tile-note",children:j})]})]})}function ze({detail:n}){const[t,l]=c.useState(!1),v=c.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{ref:v,variant:"secondary","aria-haspopup":"menu","aria-expanded":t,onClick:()=>l(u=>!u),children:[e.jsx(Ee,{size:14,"aria-hidden":"true"}),"Download"]}),e.jsx(de,{open:t,onClose:()=>l(!1),anchorRef:v,children:e.jsx(fe,{children:Ce(n.summary).map(u=>e.jsx(me,{onClick:()=>{l(!1),Ae(u.url)},children:u.label},u.key))})})]})}function at(){var K;const{groupId:n=""}=J(),t=Q(),{me:l}=X(),{toast:v}=ee(),[u,d]=c.useState(null),[p,S]=c.useState(null),[k,D]=c.useState(0),[w,x]=c.useState(!0),[h,j]=c.useState(!1),[g,b]=c.useState(!1),[A,N]=c.useState(null);c.useEffect(()=>{let r=!0;return S(null),d(null),oe(n).then(o=>r&&d(ve(o))).catch(o=>{r&&S({missing:o instanceof q&&o.status===404,message:o instanceof Error?o.message:String(o)})}),()=>{r=!1}},[n,k]);const y=(u==null?void 0:u.summary.durationMs)??0,f=Le(y),P=c.useRef(f);P.current=f;const s=c.useRef(!0);if(c.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),c.useEffect(()=>{if(!u||u.summary.status==="recording")return;const r=o=>{var F,H;if(o.metaKey||o.ctrlKey||o.altKey||Oe(o.target)||o.key===" "&&((H=(F=o.target)==null?void 0:F.closest)!=null&&H.call(F,"button, a, label")))return;if(o.key===" "&&o.repeat){o.preventDefault();return}const E=P.current;o.key===" "?(o.preventDefault(),E.toggle()):o.key==="ArrowRight"?(o.preventDefault(),E.seek(U(E.timeMs+V,y))):o.key==="ArrowLeft"&&(o.preventDefault(),E.seek(U(E.timeMs-V,y)))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[u,y]),p)return p.missing?e.jsx(L,{title:"This recording isn't available",description:"It may have been deleted, or it's on phones you can't see.",action:e.jsx(B,{className:"rec-link",to:"/recordings",children:"Back to Recordings"})}):e.jsx(L,{title:"Couldn't load this recording",description:p.message,action:e.jsxs(I,{variant:"secondary",onClick:()=>D(r=>r+1),children:[e.jsx(te,{size:14,"aria-hidden":"true"}),"Retry"]})});if(!u)return e.jsx(L,{title:"Loading recording…"});const{summary:a,bookmarks:i,annotations:M}=u,m=a.status==="recording",T=a.phones.map(r=>r.name).join(", "),C=r=>{var o;return((o=a.phones.find(E=>E.recordingId===r))==null?void 0:o.name)??""},$=[T,a.durationMs===null?null:`Length ${R(a.durationMs)}`,`Recorded by ${((K=a.startedBy)==null?void 0:K.name)??"Unknown"}`].filter(Boolean).join(" · "),_=Ie(a,l),z=()=>{j(!1),N(null)},G=async()=>{b(!0),N(null);try{await ce(n)}catch(r){s.current&&(b(!1),N(De(r)));return}v("Recording deleted","success"),s.current&&t("/recordings")};return e.jsxs("div",{className:"rec-page",children:[e.jsx("nav",{className:"rec-backbar",children:e.jsxs(B,{className:"rec-link",to:"/recordings",children:[e.jsx(we,{size:14,"aria-hidden":"true"})," Recordings"]})}),e.jsx(le,{icon:ne,title:ke(a.startedAt),subtitle:$,action:e.jsxs(e.Fragment,{children:[!m&&a.status!=="failed"&&e.jsx(ze,{detail:u}),_&&e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"danger",disabled:m,"aria-describedby":m?"rec-delete-reason":void 0,title:m?Y:void 0,onClick:()=>{N(null),j(!0)},children:[e.jsx(Re,{size:14,"aria-hidden":"true"}),"Delete"]}),m&&e.jsx("span",{id:"rec-delete-reason",className:"sr-only",children:Y})]})]})}),m?e.jsx(L,{title:"Still recording",description:"Stop it on Live devices to play it here.",action:e.jsx(B,{className:"rec-link",to:"/devices/live",children:"Open Live devices"})}):e.jsxs("div",{className:`rec-body${i.length>0?" rec-body--with-list":""}`,children:[e.jsxs("div",{className:"rec-player",children:[e.jsx("div",{className:"rec-grid",children:a.phones.map(r=>e.jsx(Ue,{groupId:n,phone:r,timeMs:f.timeMs,marks:M.filter(o=>o.recordingId===r.recordingId),showMarks:w,bind:f.bind},r.recordingId))}),e.jsxs("div",{className:"rec-transport",children:[e.jsx(I,{variant:"secondary",size:"icon","aria-label":f.playing?"Pause":"Play",onClick:f.toggle,children:f.playing?e.jsx(Se,{size:14,"aria-hidden":"true"}):e.jsx(Ne,{size:14,"aria-hidden":"true"})}),e.jsxs("span",{className:"rec-num rec-clock",children:[R(f.timeMs)," / ",R(y)]}),e.jsxs("div",{className:"rec-timeline",children:[e.jsx("input",{type:"range",className:"rec-range","aria-label":"Timeline","aria-valuetext":`${R(f.timeMs)} of ${R(y)}`,min:0,max:y,step:100,value:f.timeMs,onChange:r=>f.seek(Number(r.target.value))}),i.map(r=>e.jsx("button",{type:"button",className:"rec-mark",style:{left:`${xe(r.timecodeMs,y)}%`},title:r.label,"aria-label":`Bookmark: ${r.label}, ${R(r.timecodeMs)}`,onClick:()=>f.seek(r.timecodeMs)},r.id))]}),e.jsx("span",{role:"status",className:"rec-waiting",children:f.waiting?"Buffering…":""}),a.annotationCount>0&&e.jsxs("label",{className:"rec-toggle",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:r=>x(r.target.checked)}),"Annotations"]})]})]}),i.length>0&&e.jsxs("section",{className:"rec-bookmarks","aria-labelledby":"rec-bookmarks-title",children:[e.jsx("h2",{id:"rec-bookmarks-title",className:"rec-bookmarks-title",children:"Bookmarks"}),e.jsx("ol",{className:"rec-bookmark-list",children:i.map(r=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"rec-bookmark",onClick:()=>f.seek(r.timecodeMs),children:[e.jsx("span",{className:"rec-bookmark-label",children:r.label}),e.jsxs("span",{className:"rec-num rec-bookmark-meta",children:[R(r.timecodeMs)," · ",C(r.recordingId)]})]})},r.id))})]})]}),e.jsxs(ue,{open:h,title:"Delete this recording?",onClose:()=>{g||z()},footer:e.jsxs(e.Fragment,{children:[e.jsx(I,{variant:"secondary",onClick:z,disabled:g,children:"Cancel"}),e.jsx(I,{variant:"danger",onClick:G,disabled:g,children:"Delete"})]}),children:[e.jsx("p",{children:"Its videos, bookmarks and annotations are removed for everyone."}),A&&e.jsx("p",{role:"alert",className:"rec-error",children:A})]})]})}export{at as default};
1
+ import{r as c,i as J,u as Q,b as X,t as ee,j as e,e as B,A as te,_ as ne}from"./index-DI1fGIyj.js";import{f as q,a as re,c as se,h as ae,i as Z,j as ie,k as oe,m as ce}from"./recordings-BWe1ydXm.js";import{P as le}from"./page-header--aTyJXq6.js";import{B as I}from"./button-fIW8owMI.js";import{E as L}from"./EmptyState-Cr17PdDv.js";import{M as ue}from"./Modal-Cg9V5JYU.js";import{P as de,M as fe,a as me}from"./Menu-B-Qn2X3T.js";import{A as ge}from"./AnnotationOverlay-BXruClDk.js";import{t as O,v as pe,R as he,P as be,n as ye,c as U,o as ve,a as R,f as ke,p as xe,S as V,b as je,d as Me}from"./recordings-n-GTW3aT.js";import{A as we}from"./arrow-left-B27ckB31.js";import{T as Re}from"./trash-2-CTZpPSdd.js";import{P as Se,a as Ne}from"./play-B-FodgHV.js";import{D as Ee}from"./download-WG6l7BgD.js";import"./utils-CDN07tui.js";import"./index-HDQVe1gi.js";import"./check-BdTh1Sq7.js";function Ce(n){const t=[{key:"zip",label:"All videos (zip)",url:re(n.groupId)}];return n.hasComposite&&t.push({key:"composite",label:"Side-by-side video",url:se(n.groupId)}),t.push({key:"bundle",label:"Proof bundle",url:ae(n.groupId)}),n.phones.filter(l=>l.status!=="FAILED"&&l.status!=="DISCARDED").forEach(l=>{t.push({key:`video-${l.recordingId}`,label:`${l.name}: video`,url:Z(n.groupId,l.recordingId,!0)}),l.annotationCount>0&&t.push({key:`annotated-${l.recordingId}`,label:`${l.name}: video with annotations`,url:ie(n.groupId,l.recordingId)})}),t}function Ie(n,t){return t?t.role==="ADMIN"||t.role==="SUPER_ADMIN"?!0:!!n.startedBy&&!!t.userId&&n.startedBy.id===t.userId:!1}function De(n){if(n instanceof q){if(n.code==="not_owner")return"Only the person who recorded it, or an admin, can delete it.";if(n.code==="recording_in_progress")return"It’s still recording. Stop it on Live devices first.";if(n.status===404)return"It was already deleted, or it’s on phones you can’t see."}return`Couldn’t delete the recording: ${n instanceof Error?n.message:String(n)}`}function Ae(n){const t=document.createElement("a");t.href=n,t.download="",document.body.appendChild(t),t.click(),document.body.removeChild(t)}const Te={now:()=>performance.now(),schedule:n=>window.requestAnimationFrame(()=>n()),cancel:n=>window.cancelAnimationFrame(n)},Pe=100,_e=3,Fe=.05;function W(n){return n.ended||Number.isFinite(n.duration)&&n.currentTime>=n.duration-Fe}function Le(n,t=Te){const l=c.useRef(new Map),v=c.useRef(new Map),u=c.useRef(new Map),d=c.useRef({baseMs:0,since:null,running:!1,waiting:!1}),p=c.useRef(null),S=c.useRef(-1/0),k=c.useRef(n);k.current=n;const[D,w]=c.useState({timeMs:0,playing:!1,waiting:!1}),x=()=>d.current.since===null?d.current.baseMs:d.current.baseMs+(t.now()-d.current.since),h=(s,a)=>{l.current.forEach((i,M)=>{var _;const m=v.current.get(M);if(!m||i.error)return;const T=O(s,m.offsetMs,m.durationMs);let C=T==="before"?0:T==="after"?m.durationMs:pe(s,m.offsetMs);Number.isFinite(i.duration)&&(C=Math.min(C,i.duration*1e3));const $=d.current.running?he:be;ye(i.currentTime*1e3,C,$)&&(i.currentTime=C/1e3),a&&T==="playing"?i.paused&&!W(i)&&((_=i.play())==null||_.catch(()=>{})):i.paused||i.pause()})},j=s=>Array.from(l.current.entries()).some(([a,i])=>{const M=v.current.get(a);return!!M&&!i.error&&!W(i)&&O(s,M.offsetMs,M.durationMs)==="playing"&&i.readyState<_e}),g=s=>{const a=t.now();!s&&a-S.current<Pe||(S.current=a,w({timeMs:x(),playing:d.current.running,waiting:d.current.waiting}))},b=()=>{p.current!==null&&t.cancel(p.current),p.current=null},A=()=>{p.current=null;const s=d.current;if(!s.running)return;const a=x();if(a>=k.current){Object.assign(s,{baseMs:k.current,since:null,running:!1,waiting:!1}),h(k.current,!1),g(!0);return}const i=j(a);i!==s.waiting?(s.baseMs=a,s.since=i?null:t.now(),s.waiting=i,h(a,!i),g(!0)):(h(a,!i),g(!1)),p.current=t.schedule(A)},N=()=>{const s=d.current;x()>=k.current?s.baseMs=0:s.baseMs=x(),Object.assign(s,{since:t.now(),running:!0,waiting:!1}),h(s.baseMs,!0),g(!0),b(),p.current=t.schedule(A)},y=()=>{const s=d.current;Object.assign(s,{baseMs:x(),since:null,running:!1,waiting:!1}),b(),h(s.baseMs,!1),g(!0)},f=s=>{const a=d.current,i=U(s,k.current);a.baseMs=i,a.since=a.running&&!a.waiting?t.now():null,h(i,a.running&&!a.waiting),g(!0)},P=c.useCallback((s,a)=>{v.current.set(s,a);let i=u.current.get(s);return i||(i=M=>{if(M){l.current.set(s,M);const m=d.current;h(x(),m.running&&!m.waiting)}else l.current.delete(s)},u.current.set(s,i)),i},[]);return c.useEffect(()=>b,[]),{...D,play:N,pause:y,toggle:()=>d.current.running?y():N(),seek:f,bind:P}}const $e=()=>{},Y="Stop the recording on Live devices first.",Be=1e3;function Oe(n){const t=n;return!t||!t.closest?!1:!!t.closest('input:not([type="range"]):not([type="checkbox"]), select, textarea, [contenteditable="true"], [role="dialog"], [role="menu"]')}function Ue({groupId:n,phone:t,timeMs:l,marks:v,showMarks:u,bind:d}){const[p,S]=c.useState(!1),[k,D]=c.useState(void 0),w=t.status==="FAILED"||t.status==="DISCARDED",x=O(l,t.offsetMs,t.durationMs),h=je(v,l).map(Me).filter(g=>g!==null);let j=null;return w?j=`Recording failed: ${t.failReason??"unknown reason"}`:p?j="Video no longer available":x==="before"&&t.offsetMs>=Be&&(j=`Starts at ${R(t.offsetMs)}`),e.jsxs("figure",{className:"rec-tile theme-dark","aria-label":t.name,children:[e.jsx("figcaption",{className:"rec-tile-name",title:t.name,children:t.name}),e.jsxs("div",{className:"rec-tile-screen",children:[!w&&e.jsx("video",{className:"rec-tile-video",muted:!0,playsInline:!0,preload:"auto",src:Z(n,t.recordingId),ref:d(t.recordingId,{offsetMs:t.offsetMs,durationMs:t.durationMs}),onError:()=>S(!0),onLoadedMetadata:g=>{const b=g.currentTarget;b.videoWidth>0&&b.videoHeight>0&&D(b.videoWidth/b.videoHeight)}}),!w&&u&&e.jsx(ge,{enabled:!1,shape:"RECT",color:"currentColor",onCommit:$e,committed:h,mediaAspect:k}),j&&e.jsx("div",{className:"rec-tile-note",children:j})]})]})}function ze({detail:n}){const[t,l]=c.useState(!1),v=c.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsxs(I,{ref:v,variant:"secondary","aria-haspopup":"menu","aria-expanded":t,onClick:()=>l(u=>!u),children:[e.jsx(Ee,{size:14,"aria-hidden":"true"}),"Download"]}),e.jsx(de,{open:t,onClose:()=>l(!1),anchorRef:v,children:e.jsx(fe,{children:Ce(n.summary).map(u=>e.jsx(me,{onClick:()=>{l(!1),Ae(u.url)},children:u.label},u.key))})})]})}function at(){var K;const{groupId:n=""}=J(),t=Q(),{me:l}=X(),{toast:v}=ee(),[u,d]=c.useState(null),[p,S]=c.useState(null),[k,D]=c.useState(0),[w,x]=c.useState(!0),[h,j]=c.useState(!1),[g,b]=c.useState(!1),[A,N]=c.useState(null);c.useEffect(()=>{let r=!0;return S(null),d(null),oe(n).then(o=>r&&d(ve(o))).catch(o=>{r&&S({missing:o instanceof q&&o.status===404,message:o instanceof Error?o.message:String(o)})}),()=>{r=!1}},[n,k]);const y=(u==null?void 0:u.summary.durationMs)??0,f=Le(y),P=c.useRef(f);P.current=f;const s=c.useRef(!0);if(c.useEffect(()=>(s.current=!0,()=>{s.current=!1}),[]),c.useEffect(()=>{if(!u||u.summary.status==="recording")return;const r=o=>{var F,H;if(o.metaKey||o.ctrlKey||o.altKey||Oe(o.target)||o.key===" "&&((H=(F=o.target)==null?void 0:F.closest)!=null&&H.call(F,"button, a, label")))return;if(o.key===" "&&o.repeat){o.preventDefault();return}const E=P.current;o.key===" "?(o.preventDefault(),E.toggle()):o.key==="ArrowRight"?(o.preventDefault(),E.seek(U(E.timeMs+V,y))):o.key==="ArrowLeft"&&(o.preventDefault(),E.seek(U(E.timeMs-V,y)))};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[u,y]),p)return p.missing?e.jsx(L,{title:"This recording isn't available",description:"It may have been deleted, or it's on phones you can't see.",action:e.jsx(B,{className:"rec-link",to:"/recordings",children:"Back to Recordings"})}):e.jsx(L,{title:"Couldn't load this recording",description:p.message,action:e.jsxs(I,{variant:"secondary",onClick:()=>D(r=>r+1),children:[e.jsx(te,{size:14,"aria-hidden":"true"}),"Retry"]})});if(!u)return e.jsx(L,{title:"Loading recording…"});const{summary:a,bookmarks:i,annotations:M}=u,m=a.status==="recording",T=a.phones.map(r=>r.name).join(", "),C=r=>{var o;return((o=a.phones.find(E=>E.recordingId===r))==null?void 0:o.name)??""},$=[T,a.durationMs===null?null:`Length ${R(a.durationMs)}`,`Recorded by ${((K=a.startedBy)==null?void 0:K.name)??"Unknown"}`].filter(Boolean).join(" · "),_=Ie(a,l),z=()=>{j(!1),N(null)},G=async()=>{b(!0),N(null);try{await ce(n)}catch(r){s.current&&(b(!1),N(De(r)));return}v("Recording deleted","success"),s.current&&t("/recordings")};return e.jsxs("div",{className:"rec-page",children:[e.jsx("nav",{className:"rec-backbar",children:e.jsxs(B,{className:"rec-link",to:"/recordings",children:[e.jsx(we,{size:14,"aria-hidden":"true"})," Recordings"]})}),e.jsx(le,{icon:ne,title:ke(a.startedAt),subtitle:$,action:e.jsxs(e.Fragment,{children:[!m&&a.status!=="failed"&&e.jsx(ze,{detail:u}),_&&e.jsxs(e.Fragment,{children:[e.jsxs(I,{variant:"danger",disabled:m,"aria-describedby":m?"rec-delete-reason":void 0,title:m?Y:void 0,onClick:()=>{N(null),j(!0)},children:[e.jsx(Re,{size:14,"aria-hidden":"true"}),"Delete"]}),m&&e.jsx("span",{id:"rec-delete-reason",className:"sr-only",children:Y})]})]})}),m?e.jsx(L,{title:"Still recording",description:"Stop it on Live devices to play it here.",action:e.jsx(B,{className:"rec-link",to:"/devices/live",children:"Open Live devices"})}):e.jsxs("div",{className:`rec-body${i.length>0?" rec-body--with-list":""}`,children:[e.jsxs("div",{className:"rec-player",children:[e.jsx("div",{className:"rec-grid",children:a.phones.map(r=>e.jsx(Ue,{groupId:n,phone:r,timeMs:f.timeMs,marks:M.filter(o=>o.recordingId===r.recordingId),showMarks:w,bind:f.bind},r.recordingId))}),e.jsxs("div",{className:"rec-transport",children:[e.jsx(I,{variant:"secondary",size:"icon","aria-label":f.playing?"Pause":"Play",onClick:f.toggle,children:f.playing?e.jsx(Se,{size:14,"aria-hidden":"true"}):e.jsx(Ne,{size:14,"aria-hidden":"true"})}),e.jsxs("span",{className:"rec-num rec-clock",children:[R(f.timeMs)," / ",R(y)]}),e.jsxs("div",{className:"rec-timeline",children:[e.jsx("input",{type:"range",className:"rec-range","aria-label":"Timeline","aria-valuetext":`${R(f.timeMs)} of ${R(y)}`,min:0,max:y,step:100,value:f.timeMs,onChange:r=>f.seek(Number(r.target.value))}),i.map(r=>e.jsx("button",{type:"button",className:"rec-mark",style:{left:`${xe(r.timecodeMs,y)}%`},title:r.label,"aria-label":`Bookmark: ${r.label}, ${R(r.timecodeMs)}`,onClick:()=>f.seek(r.timecodeMs)},r.id))]}),e.jsx("span",{role:"status",className:"rec-waiting",children:f.waiting?"Buffering…":""}),a.annotationCount>0&&e.jsxs("label",{className:"rec-toggle",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:r=>x(r.target.checked)}),"Annotations"]})]})]}),i.length>0&&e.jsxs("section",{className:"rec-bookmarks","aria-labelledby":"rec-bookmarks-title",children:[e.jsx("h2",{id:"rec-bookmarks-title",className:"rec-bookmarks-title",children:"Bookmarks"}),e.jsx("ol",{className:"rec-bookmark-list",children:i.map(r=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:"rec-bookmark",onClick:()=>f.seek(r.timecodeMs),children:[e.jsx("span",{className:"rec-bookmark-label",children:r.label}),e.jsxs("span",{className:"rec-num rec-bookmark-meta",children:[R(r.timecodeMs)," · ",C(r.recordingId)]})]})},r.id))})]})]}),e.jsxs(ue,{open:h,title:"Delete this recording?",onClose:()=>{g||z()},footer:e.jsxs(e.Fragment,{children:[e.jsx(I,{variant:"secondary",onClick:z,disabled:g,children:"Cancel"}),e.jsx(I,{variant:"danger",onClick:G,disabled:g,children:"Delete"})]}),children:[e.jsx("p",{children:"Its videos, bookmarks and annotations are removed for everyone."}),A&&e.jsx("p",{role:"alert",className:"rec-error",children:A})]})]})}export{at as default};