progon-agent 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/supervisor/cli.js +40 -40
  2. package/extension-bundle.json +3 -3
  3. package/extension-dist/background/background.js +82 -82
  4. package/extension-dist/card/card.html +8 -8
  5. package/extension-dist/card/card.js +3 -3
  6. package/extension-dist/chunks/{shared-CFv6cSrr.js → shared-73iHxv_g.js} +1 -1
  7. package/extension-dist/chunks/{shared-BQbdfGz-.css → shared-BRaGK72I.css} +1 -1
  8. package/extension-dist/chunks/{shared-CNYvsh0O.js → shared-BgEO6Nif.js} +3 -3
  9. package/extension-dist/chunks/shared-ByZxg79I.js +1 -0
  10. package/extension-dist/chunks/{shared-B5dGSIVr.js → shared-C7IWMwZY.js} +1 -1
  11. package/extension-dist/chunks/{shared-C0apd10a.js → shared-CFEBqIm7.js} +3 -3
  12. package/extension-dist/chunks/shared-CKtbh_44.js +199 -0
  13. package/extension-dist/chunks/shared-CSBwVLDL.js +1 -0
  14. package/extension-dist/chunks/{shared-CUdYAeXx.js → shared-CeI71eLt.js} +4 -4
  15. package/extension-dist/chunks/shared-CfjrOLG1.js +336 -0
  16. package/extension-dist/chunks/{shared-Dbbjj01C.js → shared-CwsTFlbT.js} +1 -1
  17. package/extension-dist/chunks/shared-D-c-eSoI.js +1 -0
  18. package/extension-dist/chunks/shared-DXp1f_Ub.css +1 -0
  19. package/extension-dist/chunks/shared-RcZD4SR-.js +1 -0
  20. package/extension-dist/chunks/shared-lM00HeT6.js +98 -0
  21. package/extension-dist/chunks/shared-t8TH2XkL.js +239 -0
  22. package/extension-dist/content/content.css +1 -1
  23. package/extension-dist/content/content.js +206 -206
  24. package/extension-dist/manifest.json +24 -24
  25. package/extension-dist/offscreen/offscreen.html +2 -2
  26. package/extension-dist/offscreen/offscreen.js +1 -1
  27. package/extension-dist/popup/popup.html +8 -8
  28. package/extension-dist/popup/popup.js +3 -3
  29. package/extension-dist/sidepanel/sidepanel.html +11 -11
  30. package/extension-dist/sidepanel/sidepanel.js +1 -1
  31. package/extension-dist/workspace/workspace.html +11 -11
  32. package/extension-dist/workspace/workspace.js +43 -50
  33. package/package.json +2 -2
  34. package/extension-dist/chunks/shared-BAuQl9-k.js +0 -323
  35. package/extension-dist/chunks/shared-BBv6J4oP.js +0 -199
  36. package/extension-dist/chunks/shared-BROt3HHj.js +0 -1
  37. package/extension-dist/chunks/shared-C05lJ8nQ.js +0 -98
  38. package/extension-dist/chunks/shared-C5qHe-zg.js +0 -239
  39. package/extension-dist/chunks/shared-CdFf-X4Y.css +0 -1
  40. package/extension-dist/chunks/shared-CmGrLhdH.js +0 -1
  41. package/extension-dist/chunks/shared-DDyAbNyB.js +0 -1
  42. package/extension-dist/chunks/shared-pdVr5lDK.js +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "manifest_version": 3,
3
3
  "name": "Progon",
4
- "version": "1.9.2",
4
+ "version": "1.10.0",
5
5
  "description": "Progon — visual QA tool with overlay for bug tracking, test recording, and risk zone highlighting",
6
6
  "minimum_chrome_version": "125",
7
7
  "permissions": [
@@ -118,20 +118,20 @@
118
118
  {
119
119
  "resources": [
120
120
  "card/*",
121
- "chunks/shared-B5dGSIVr.js",
122
- "chunks/shared-BBv6J4oP.js",
123
- "chunks/shared-BQbdfGz-.css",
124
- "chunks/shared-BROt3HHj.js",
121
+ "chunks/shared-BRaGK72I.css",
125
122
  "chunks/shared-Beih6ywL.js",
126
- "chunks/shared-C05lJ8nQ.js",
127
- "chunks/shared-C5qHe-zg.js",
128
- "chunks/shared-CUdYAeXx.js",
123
+ "chunks/shared-ByZxg79I.js",
124
+ "chunks/shared-C7IWMwZY.js",
125
+ "chunks/shared-CKtbh_44.js",
126
+ "chunks/shared-CSBwVLDL.js",
127
+ "chunks/shared-CeI71eLt.js",
129
128
  "chunks/shared-CgUMEof2.js",
130
- "chunks/shared-CmGrLhdH.js",
131
- "chunks/shared-DDyAbNyB.js",
129
+ "chunks/shared-D-c-eSoI.js",
132
130
  "chunks/shared-Dk6zuyaK.css",
131
+ "chunks/shared-RcZD4SR-.js",
133
132
  "chunks/shared-hePW80VL.js",
134
- "chunks/shared-pdVr5lDK.js"
133
+ "chunks/shared-lM00HeT6.js",
134
+ "chunks/shared-t8TH2XkL.js"
135
135
  ],
136
136
  "matches": [
137
137
  "<all_urls>"
@@ -141,23 +141,23 @@
141
141
  {
142
142
  "resources": [
143
143
  "workspace/*",
144
- "chunks/shared-BAuQl9-k.js",
145
- "chunks/shared-BBv6J4oP.js",
146
- "chunks/shared-BQbdfGz-.css",
144
+ "chunks/shared-73iHxv_g.js",
145
+ "chunks/shared-BRaGK72I.css",
147
146
  "chunks/shared-Beih6ywL.js",
148
- "chunks/shared-C05lJ8nQ.js",
149
- "chunks/shared-C5qHe-zg.js",
150
- "chunks/shared-CFv6cSrr.js",
151
- "chunks/shared-CNYvsh0O.js",
152
- "chunks/shared-CUdYAeXx.js",
153
- "chunks/shared-CdFf-X4Y.css",
147
+ "chunks/shared-BgEO6Nif.js",
148
+ "chunks/shared-ByZxg79I.js",
149
+ "chunks/shared-CKtbh_44.js",
150
+ "chunks/shared-CSBwVLDL.js",
151
+ "chunks/shared-CeI71eLt.js",
152
+ "chunks/shared-CfjrOLG1.js",
154
153
  "chunks/shared-CgUMEof2.js",
155
- "chunks/shared-CmGrLhdH.js",
156
- "chunks/shared-DDyAbNyB.js",
157
- "chunks/shared-Dbbjj01C.js",
154
+ "chunks/shared-CwsTFlbT.js",
155
+ "chunks/shared-DXp1f_Ub.css",
158
156
  "chunks/shared-Dk6zuyaK.css",
157
+ "chunks/shared-RcZD4SR-.js",
159
158
  "chunks/shared-hePW80VL.js",
160
- "chunks/shared-pdVr5lDK.js"
159
+ "chunks/shared-lM00HeT6.js",
160
+ "chunks/shared-t8TH2XkL.js"
161
161
  ],
162
162
  "matches": [
163
163
  "<all_urls>"
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <title>Progon Offscreen</title>
6
6
  <script type="module" crossorigin src="../offscreen/offscreen.js"></script>
7
- <link rel="modulepreload" crossorigin href="../chunks/shared-C05lJ8nQ.js">
8
- <link rel="modulepreload" crossorigin href="../chunks/shared-Dbbjj01C.js">
7
+ <link rel="modulepreload" crossorigin href="../chunks/shared-lM00HeT6.js">
8
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CwsTFlbT.js">
9
9
  </head>
10
10
  <body>
11
11
  </body>
@@ -1 +1 @@
1
- import{t as e}from"../chunks/shared-C05lJ8nQ.js";import"../chunks/shared-Dbbjj01C.js";var t=2e4,n=`AGENT_RUNTIME_HEARTBEAT`,r=e(`pgs-6c97a01773`),i={type:n};setInterval(()=>{chrome.runtime.sendMessage(i).catch(e=>{r.warn(`pgm-45c13bd730`,{error:e instanceof Error?e.message:String(e)})})},t);
1
+ import{t as e}from"../chunks/shared-lM00HeT6.js";import"../chunks/shared-CwsTFlbT.js";var t=2e4,n=`AGENT_RUNTIME_HEARTBEAT`,r=e(`pgs-6c97a01773`),i={type:n};setInterval(()=>{chrome.runtime.sendMessage(i).catch(e=>{r.warn(`pgm-45c13bd730`,{error:e instanceof Error?e.message:String(e)})})},t);
@@ -5,14 +5,14 @@
5
5
  <title>Progon</title>
6
6
  <script type="module" crossorigin src="../popup/popup.js"></script>
7
7
  <link rel="modulepreload" crossorigin href="../chunks/shared-hePW80VL.js">
8
- <link rel="modulepreload" crossorigin href="../chunks/shared-C05lJ8nQ.js">
9
- <link rel="modulepreload" crossorigin href="../chunks/shared-C5qHe-zg.js">
10
- <link rel="modulepreload" crossorigin href="../chunks/shared-B5dGSIVr.js">
11
- <link rel="modulepreload" crossorigin href="../chunks/shared-CFv6cSrr.js">
12
- <link rel="modulepreload" crossorigin href="../chunks/shared-CNYvsh0O.js">
13
- <link rel="modulepreload" crossorigin href="../chunks/shared-C0apd10a.js">
14
- <link rel="modulepreload" crossorigin href="../chunks/shared-pdVr5lDK.js">
15
- <link rel="stylesheet" crossorigin href="../chunks/shared-BQbdfGz-.css">
8
+ <link rel="modulepreload" crossorigin href="../chunks/shared-lM00HeT6.js">
9
+ <link rel="modulepreload" crossorigin href="../chunks/shared-t8TH2XkL.js">
10
+ <link rel="modulepreload" crossorigin href="../chunks/shared-C7IWMwZY.js">
11
+ <link rel="modulepreload" crossorigin href="../chunks/shared-73iHxv_g.js">
12
+ <link rel="modulepreload" crossorigin href="../chunks/shared-BgEO6Nif.js">
13
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CFEBqIm7.js">
14
+ <link rel="modulepreload" crossorigin href="../chunks/shared-RcZD4SR-.js">
15
+ <link rel="stylesheet" crossorigin href="../chunks/shared-BRaGK72I.css">
16
16
  <link rel="stylesheet" crossorigin href="../popup/popup.css">
17
17
  </head>
18
18
  <body>
@@ -1,11 +1,11 @@
1
- import{r as e}from"../chunks/shared-hePW80VL.js";import{$i as t,$t as n,Ai as r,B as i,Bi as a,Bn as o,Ca as s,Dn as c,Ds as l,Ea as u,Ei as d,F as f,Ft as p,G as m,Ga as h,Gn as g,Gr as _,H as v,Hi as y,Hn as b,Ir as x,Ji as S,Jr as C,K as ee,Ki as w,Kn as T,Lr as E,Nr as D,Ns as O,O as te,Oi as k,On as ne,Or as re,Ps as ie,Qa as A,Qn as ae,Qt as oe,R as se,Ri as ce,Rr as le,Sr as j,Ui as ue,Un as de,V as fe,Vi as pe,Vn as me,Vr as M,Wa as he,Wi as ge,Wr as _e,X as ve,Xa as ye,Xn as be,Yn as xe,Za as N,Zt as Se,_a as Ce,_n as we,_r as P,a as Te,ai as Ee,an as De,ao as Oe,bi as ke,d as Ae,dt as je,eo as Me,er as Ne,fn as Pe,ga as F,gi as Fe,hi as Ie,hn as Le,i as Re,ia as I,j as ze,ks as Be,li as Ve,lo as L,mn as He,mr as Ue,na as We,no as Ge,o as Ke,oo as qe,pn as Je,qn as Ye,r as Xe,ra as R,ro as Ze,sn as Qe,so as z,sr as $e,ta as et,tn as tt,to as nt,tr as rt,va as it,vi as at,vr as ot,wi as st,xi as ct,yi as lt,z as ut,za as dt,zi as B}from"../chunks/shared-C5qHe-zg.js";import{t as V,z as ft}from"../chunks/shared-C05lJ8nQ.js";import{t as pt}from"../chunks/shared-B5dGSIVr.js";import{i as mt,r as ht,t as gt}from"../chunks/shared-CFv6cSrr.js";import{a as _t,c as vt,d as yt,f as bt,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"../chunks/shared-C0apd10a.js";import{a as kt,c as At,d as jt,f as Mt,g as Nt,i as Pt,l as Ft,m as It,n as Lt,p as Rt,t as zt,u as Bt}from"../chunks/shared-CNYvsh0O.js";import{a as Vt,b as Ht,c as Ut,d as Wt,f as Gt,g as Kt,h as qt,i as Jt,l as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,s as tn,t as nn,u as rn,v as an,x as on,y as sn}from"../chunks/shared-pdVr5lDK.js"
1
+ import{r as e}from"../chunks/shared-hePW80VL.js";import{$a as t,$i as n,$t as r,Ai as i,B as a,Bi as o,Bn as s,Ca as c,Dn as l,Ei as u,F as d,Ft as f,G as p,Gn as m,Gr as h,H as g,Ha as _,Hi as v,Hn as y,Ia as b,Ir as x,Ja as S,Ji as C,Jr as ee,K as te,Ki as w,Kn as T,Lo as E,Lr as D,Ls as O,Nr as k,Ns as ne,O as re,Oi as A,On as ie,Or as ae,Qa as j,Qn as oe,Qt as se,R as ce,Ri as M,Rr as le,Rs as ue,Sr as de,Ui as fe,Un as pe,V as me,Va as he,Vi as ge,Vn as _e,Vr as N,Wi as ve,Wr as ye,X as be,Xn as xe,Ya as Se,Yn as Ce,Za as we,Zt as Te,_a as Ee,_n as De,_r as P,a as Oe,ai as ke,an as Ae,bi as je,d as Me,dt as Ne,eo as Pe,er as Fe,fn as Ie,ga as F,gi as Le,hi as Re,hn as ze,i as Be,ia as I,io as L,j as Ve,js as He,li as Ue,mn as We,mr as Ge,na as Ke,no as qe,o as Je,oo as R,pn as Ye,qa as Xe,qn as Ze,r as Qe,ra as z,ro as $e,sn as et,sr as tt,ta as nt,tn as rt,tr as it,va as at,vi as ot,vr as st,wi as ct,xi as lt,yi as ut,z as dt,zi as B}from"../chunks/shared-t8TH2XkL.js";import{V as ft,t as V}from"../chunks/shared-lM00HeT6.js";import{t as pt}from"../chunks/shared-C7IWMwZY.js";import{i as mt,r as ht,t as gt}from"../chunks/shared-73iHxv_g.js";import{a as _t,c as vt,d as yt,f as bt,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"../chunks/shared-CFEBqIm7.js";import{a as kt,c as At,d as jt,f as Mt,g as Nt,i as Pt,l as Ft,m as It,n as Lt,p as Rt,t as zt,u as Bt}from"../chunks/shared-BgEO6Nif.js";import{a as Vt,b as Ht,c as Ut,d as Wt,f as Gt,g as Kt,h as qt,i as Jt,l as Yt,m as Xt,n as Zt,o as Qt,p as $t,r as en,s as tn,t as nn,u as rn,v as an,x as on,y as sn}from"../chunks/shared-RcZD4SR-.js"
2
2
  /**
3
3
  * @license lucide-react v0.574.0 - ISC
4
4
  *
5
5
  * This source code is licensed under the ISC license.
6
6
  * See the LICENSE file in the root directory of this source tree.
7
7
  */
8
- ;var cn=R(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),ln=R(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),un=R(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),dn=R(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),fn=R(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),pn=R(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),H=/* @__PURE__ */ e(h(),1),U=he()
8
+ ;var cn=z(`arrow-left-right`,[[`path`,{d:`M8 3 4 7l4 4`,key:`9rb6wj`}],[`path`,{d:`M4 7h16`,key:`6tx8e3`}],[`path`,{d:`m16 21 4-4-4-4`,key:`siv7j2`}],[`path`,{d:`M20 17H4`,key:`h6l3hr`}]]),ln=z(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),un=z(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),dn=z(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),fn=z(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),pn=z(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),H=/* @__PURE__ */ e(_(),1),U=he()
9
9
  /**
10
10
  * @license lucide-react v0.574.0 - ISC
11
11
  *
@@ -36,4 +36,4 @@ import{r as e}from"../chunks/shared-hePW80VL.js";import{$i as t,$t as n,Ai as r,
36
36
  * This source code is licensed under the ISC license.
37
37
  * See the LICENSE file in the root directory of this source tree.
38
38
  */
39
- ;function mn({off:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`mr-auto flex items-center gap-2 text-body-md font-semibold tracking-(--tracking-brand) text-fg-primary`,children:[/* @__PURE__ */ (0,U.jsx)(Bt,{className:_(`size-5 [transition:filter_var(--motion-medium)_var(--ease-out),opacity_var(--motion-medium)_var(--ease-out)]`,e&&`opacity-50 grayscale`)}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:t(`popup.brand`)})]})}function hn({children:e}){return/* @__PURE__ */ (0,U.jsx)(`header`,{className:`flex h-12 flex-none items-center gap-1 border-b border-stroke-light bg-(--color-bg-window-header) pr-2 pl-3.5`,children:e})}function gn({children:e,className:t}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:_(`grid min-h-0 flex-1 grid-cols-1 content-start gap-4 overflow-y-auto px-3 pt-3 pb-4 [scrollbar-width:thin]`,t),children:e})}function _n(){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`popup-loading`,children:[/* @__PURE__ */ (0,U.jsxs)(hn,{children:[/* @__PURE__ */ (0,U.jsx)(mn,{off:!1}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`ml-2 size-7 rounded-md`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`ml-2 size-6 rounded-full`})]}),/* @__PURE__ */ (0,U.jsx)(gn,{children:/* @__PURE__ */ (0,U.jsx)(vn,{})})]})}function vn(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":e(`shell.loading`),className:`grid gap-2.5 rounded-lg border border-stroke bg-surface-card pt-3 pr-3 pb-3.5 pl-3.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`size-8.5 rounded-md`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid flex-1 gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-2.5 w-12`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3.5 w-[62%]`})]})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3 w-[60%]`})}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5.5 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5.5 w-20.5 rounded-full`})]})]}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-2.5 w-37.5`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-21 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-27.5 rounded-full`})]})]})]})}function yn({value:e,options:t,onChange:n,ariaLabel:r,size:i,fullWidth:a,className:o}){return/* @__PURE__ */ (0,U.jsx)(g,{value:e,options:t,onValueChange:n,"aria-label":r,size:i,fullWidth:a,className:o})}var bn=V(`pgs-4d9951d24e`);function xn(e){let t=0,n=Promise.resolve(),r=null;async function i(n,i,a){if(n!==t)return;if(e.signedInUserId()!==a){bn.warn(`pgm-4b072233de`,{locale:i});return}let o=new AbortController;r=o;try{await e.save(i,o.signal)}catch(r){if(o.signal.aborted){bn.info(`pgm-7aaa461c83`,{locale:i});return}if(n===t){e.onFailure(i,r);return}bn.warn(`pgm-f93a88619e`,{locale:i,error:r})}finally{r=null}}return{write(e,r){t+=1;let a=t;n=n.then(()=>i(a,e,r)).catch(t=>{bn.error(`pgm-1491eca8c6`,{locale:e,error:t})})},discardPending(){t+=1,r==null||r.abort()}}}var Sn=V(`pgs-b78fd5fe0f`),Cn=(0,H.createContext)(null);function wn({user:e,children:t}){let{t:n}=F(),r=x(),[i]=(0,H.useState)(()=>Dn(e.id));return(0,H.useEffect)(()=>{i.setFailureReport((e,t)=>{Sn.error(`pgm-0f28f45227`,{locale:e,error:t instanceof Error?t.message:String(t)}),r.show({id:`popup-profile-language`,variant:`error`,message:n(`popup.language.profileSaveFailed`),action:{label:n(`common.retry`),onAction:()=>i.retryShownLocale()}})})}),(0,H.useEffect)(()=>(i.start(),()=>i.end()),[i]),/* @__PURE__ */ (0,U.jsx)(Cn,{value:i.profileLocale,children:t})}function Tn(){return(0,H.useContext)(Cn)}function En(){let e=(0,H.useContext)(Cn);if(e===null)throw Error(`useSignedInProfileLocale() is used outside the signed-in popup`);return e}function Dn(e){let t=!1,n=null,r=xn({save:async(e,t)=>{await z.preferences.update({locale:e},{signal:t})},signedInUserId:()=>t?e:null,onFailure:(e,t)=>{if(n===null)throw Error(`A profile language write failed before the popup was rendered`);n(e,t)}});return{profileLocale:{write:t=>r.write(t,e),discardPending:()=>r.discardPending()},setFailureReport:e=>{n=e},retryShownLocale:()=>{t&&r.write(A(),e)},start:()=>{t=!0},end:()=>{t=!1,r.discardPending()}}}function On(e){let t=nt(e);return(0,H.useSyncExternalStore)(t.subscribe,t.getState)}var kn=V(`pgs-520a54a8e3`);function W(e){let t=On(e);if(t.status===`failed`)throw t.error;return t.status===`ready`?t.value:void 0}function An(){let{t:e}=F(),t=x();return(0,H.useCallback)(function n(r){r.run().catch(i=>{kn.error(r.log.message,{...r.log.context,error:i instanceof Error?i.message:String(i)}),t.show({id:r.id,variant:`error`,message:r.message,detail:r.detail,action:{label:e(`common.retry`),onAction:()=>n(r)}})})},[e,t])}function G(){let{t:e}=F(),t=An();return(0,H.useCallback)((n,r)=>t({id:`setting-${n}`,run:()=>Ge(n,r),log:{message:`A setting was not stored`,context:{key:n}},message:e(`popup.settings.saveFailed`)}),[e,t])}function jn({size:e,fullWidth:t}){let{t:n}=F(),r=An(),i=Tn();return/* @__PURE__ */ (0,U.jsx)(yn,{value:A(),options:ft.map(e=>({value:e,label:n(`common.languageNames.${e}`)})),onChange:e=>r({id:`popup-language`,run:async()=>{await Me(e)!==`superseded`&&(i==null||i.write(e))},log:{message:`The language was not switched or not stored`,context:{locale:e}},message:n(`popup.settings.saveFailed`)}),ariaLabel:n(`popup.languageGroup`),size:e,fullWidth:t})}function Mn(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:/* @__PURE__ */ (0,U.jsx)(Ft,{subtitle:e(`shell.signIn.subtitlePopup`),footer:/* @__PURE__ */ (0,U.jsx)(jn,{size:`sm`})})})}var Nn=V(`pgs-d05703aaa3`);function Pn({user:e}){let{t}=F(),n=x(),[r,i]=(0,H.useState)(!1),a=En(),o=`${e.firstName} ${e.lastName}`;return/* @__PURE__ */ (0,U.jsxs)(te,{label:t(`popup.header.account`,{name:o}),align:`end`,className:`w-59`,trigger:/* @__PURE__ */ (0,U.jsx)(E,{"aria-label":t(`popup.header.account`,{name:o}),icon:/* @__PURE__ */ (0,U.jsx)(gt,{firstName:e.firstName,lastName:e.lastName,email:e.email,size:`sm`,unknownLabel:t(`popup.header.unknownUser`)}),"data-testid":`popup-account`}),children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-px px-2.5 py-2`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`text-body-sm font-semibold text-fg-primary`,children:o}),/* @__PURE__ */ (0,U.jsxs)(`small`,{className:`text-xs text-fg-muted`,children:[e.email,` \u00B7 `,e.company.name]})]}),/* @__PURE__ */ (0,U.jsx)(f,{}),/* @__PURE__ */ (0,U.jsx)(ze,{label:t(`popup.header.openWeb`),icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onSelect:()=>s()}),/* @__PURE__ */ (0,U.jsx)(f,{}),/* @__PURE__ */ (0,U.jsx)(ze,{label:t(`popup.header.signOut`),icon:/* @__PURE__ */ (0,U.jsx)(un,{"aria-hidden":`true`}),tone:`danger`,disabled:r,onSelect:()=>{r||(i(!0),a.discardPending(),z.auth.logout().catch(e=>{Nn.error(`pgm-4db83b7ea3`,{error:e instanceof Error?e.message:String(e)}),n.show({id:`popup-sign-out`,variant:`error`,message:t(`popup.header.signOutFailed`)})}).finally(()=>i(!1)))},"data-testid":`popup-sign-out`})]})}function Fn({enabled:e}){let{t}=F(),n=An();return/* @__PURE__ */ (0,U.jsx)(I,{relationship:`description`,content:t(e?`popup.header.switchOn`:`popup.header.switchOff`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex`,children:/* @__PURE__ */ (0,U.jsx)(o,{"aria-label":t(`popup.header.switchLabel`),checked:e,onChange:e=>n({id:`popup-power-switch`,run:()=>Ge(`enabled`,e),log:{message:`The extension switch was not stored`,context:{enabled:e}},message:t(`popup.header.switchFailed`),detail:t(`popup.header.switchFailedDetail`)}),className:`p-1.5`,"data-testid":`popup-power-switch`})})})}function In({user:e,onOpenSettings:t,notificationCounts:n,onOpenNotifications:r}){let{t:i}=F(),a=W(`enabled`);return/* @__PURE__ */ (0,U.jsxs)(hn,{children:[/* @__PURE__ */ (0,U.jsx)(mn,{off:a===!1}),a===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(Fn,{enabled:a}),/* @__PURE__ */ (0,U.jsx)(wt,{host:`popup`,t:i,counts:a===!1?null:n,onClick:r}),/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:i(`popup.header.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(E,{icon:/* @__PURE__ */ (0,U.jsx)(bt,{"aria-hidden":`true`}),onClick:t,"data-testid":`popup-open-settings`})}),/* @__PURE__ */ (0,U.jsx)(Pn,{user:e})]})}var Ln=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:r,className:i,nativeButton:a=!0,disabled:o=!1,id:s,style:l,...u}=e,{state:d,disabled:f,setTouched:m,setFocused:h,validationMode:g,validation:_}=Ae(),{labelId:v}=Ke(),y=on(),b=y.useState(`selectionMode`),x=y.useState(`disabled`),S=y.useState(`readOnly`),C=y.useState(`required`),ee=y.useState(`positionerElement`),w=y.useState(`listElement`),T=y.useState(`popupId`),E=y.useState(`triggerProps`),D=y.useState(`inputInsidePopup`),O=y.useState(`id`),te=y.useState(`labelId`),k=y.useState(`open`),re=y.useState(`selectedValue`),ie=y.useState(`activeIndex`),A=y.useState(`selectedIndex`),ae=y.useState(`hasSelectedValue`),se=sn(),ce=Ht(),le=tt(),j=f||x||o,ue=$t(),de=Xt(y);Te({id:D?s:void 0});let fe=D?s??O:s,pe=Re(v,te),me;k&&D?me=T??an(O):k&&(me=w==null?void 0:w.id);let M=H.useRef(``);function he(e){M.current=e.pointerType}let{reference:ge}=je(se,{enabled:!k&&!S&&!x&&b===`single`,listRef:y.context.labelsRef,activeIndex:ie,selectedIndex:A,onMatch(e){let t=y.context.valuesRef.current[e];t!==void 0&&y.context.setSelectedValue(t,De(ne))}}),{reference:_e}=p(se,{enabled:!x,event:`mousedown`}),{buttonRef:ye,getButtonProps:be}=Pe({native:a,disabled:j}),xe={...d,readOnly:S,open:k,disabled:j,popupSide:de,listEmpty:ue,placeholder:b!==`none`&&!ae},N=Le(e=>{y.set(`triggerElement`,e)});return $e(`button`,e,{ref:[t,ye,N],state:xe,props:[E,_e,ge,{id:fe,tabIndex:D?0:-1,role:D?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":D?`dialog`:`listbox`,"aria-controls":me,"aria-required":D&&C||void 0,"aria-readonly":D&&S||void 0,"aria-labelledby":pe,onPointerDown:he,onPointerEnter:he,onFocus(){h(!0),!j&&le.start(0,y.context.forceMount)},onBlur(e){if(!Se(ee,e.relatedTarget)&&(m(!0),h(!1),g===`onBlur`)){let e=b===`none`?ce:re;_.commit(e)}},onMouseDown(e){if(j)return;if(D||se.set(`domReferenceElement`,e.currentTarget),y.context.forceMount(),M.current!==`touch`){var t;(t=y.context.inputRef.current)==null||t.focus(),D||e.preventDefault()}if(k)return;let n=Je(e.currentTarget);function r(e){let t=y.state.triggerElement;if(!t)return;let n=oe(e),r=y.state.positionerElement,i=y.state.listElement;Se(t,n)||Se(r,n)||Se(i,n)||ve(e,t)||y.context.setOpen(!1,De(we,e))}D&&n.addEventListener(`mouseup`,r,{once:!0})},onKeyDown(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){var t;n(e),y.context.setOpen(!0,De(c,e.nativeEvent)),(t=y.context.inputRef.current)==null||t.focus()}}},_.getValidationProps(j,u),be],stateAttributesMapping:qt})}),Rn=/*#__PURE__*/ H.createContext(void 0);function zn(){let e=H.useContext(Rn);if(e===void 0)throw Error(Ue(18));return e}var Bn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,items:a,...o}=e,s=on().useState(`grid`),[c,l]=H.useState(),u=H.useMemo(()=>({labelId:c,setLabelId:l,items:a}),[c,l,a]),d=$e(`div`,e,{ref:t,props:[{role:s?`rowgroup`:`group`,"aria-labelledby":c},o]}),f=/*#__PURE__*/ (0,U.jsx)(Rn.Provider,{value:u,children:d});return a?/*#__PURE__*/ (0,U.jsx)(rn,{items:a,children:f}):f}),Vn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=zn(),c=Qe(a);return He(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),$e(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),Hn=/^[^\p{L}\p{N}]*(\p{L})/u;function Un(e){let t=e.trim().split(/\s+/).flatMap(e=>{var t;let n=(t=Hn.exec(e))==null?void 0:t[1];return n===void 0?[]:[n.toLocaleUpperCase()]}).slice(0,2).join(``);return t===``?null:t}var Wn=`grid shrink-0 place-items-center font-semibold tracking-(--tracking-snug) select-none`,Gn=`bg-(image:--btn-primary-fill) text-fg-on-accent`,Kn=`bg-(--color-bg-tertiary) text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,qn=`shadow-[var(--shadow-primary-inset),var(--shadow-tile-primary-glow)]`,Jn={22:`size-5.5 rounded-sm text-(length:--text-2xs) [&_svg]:size-3`,26:`size-6.5 rounded-md text-xs [&_svg]:size-3.5`,32:`size-8 rounded-md text-sm [&_svg]:size-4`,40:`size-10 rounded-lg text-base [&_svg]:size-4.5`},Yn=/* @__PURE__ */ new Set([26,32,40]);function Xn({name:e,size:t,drained:n=!1,className:r}){let i=e===null?null:Un(e),a=n?Kn:_(Gn,Yn.has(t)&&qn);return/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,"data-size":t,"data-drained":n||void 0,className:_(Wn,Jn[t],a,r),children:i??/* @__PURE__ */ (0,U.jsx)(Rt,{})})}var Zn=5,Qn=3,$n=`grid shrink-0 place-items-center rounded-md border border-solid border-[color-mix(in_srgb,var(--color-primary)_28%,transparent)] bg-(--color-bg-primary-tint-10) text-sm font-semibold tracking-(--tracking-snug) text-(--color-primary-text)`,er=`grid shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted [&_svg]:size-4`,tr=`group/trigger flex h-11.5 w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md border border-solid border-transparent bg-transparent pr-2 pl-1.25 text-left font-sans outline-none [transition:background-color_var(--motion-short)_var(--ease-out),border-color_var(--motion-short)_var(--ease-out)] hover:border-stroke hover:bg-surface-hover-layer focus-visible:border-stroke-focus focus-visible:ring-3 focus-visible:ring-focus-ring data-popup-open:border-stroke-focus data-popup-open:bg-surface-secondary`,nr=`group/trigger inline-flex h-9 min-w-0 shrink-0 cursor-pointer items-center gap-2 rounded-full border-0 bg-transparent pr-2.25 pl-1.25 font-sans text-body-sm font-semibold tracking-(--tracking-control) text-fg-primary [transition:background-color_var(--motion-short)_var(--ease-out)] hover:bg-surface-hover-layer data-popup-open:bg-surface-hover-layer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-stroke-focus`,rr={header:`min-w-0 max-w-45 truncate`,"header-narrow":`min-w-0 max-w-30 truncate`},ir=`grid size-6.5 shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted`,ar=`grid grid-cols-[minmax(0,1fr)] gap-px overflow-y-auto overscroll-contain outline-none`,or={popup:`w-75`,list:`max-h-[min(--spacing(80),var(--available-height))]`,search:_(ae(`default`,!1,`page`,`sm`,`search`),`m-0.5 mb-1.5`),rowTile:null,row:`data-selected:bg-(--color-bg-primary-tint-10) [&>svg:last-child]:text-(--color-primary-text)`},sr={full:{popup:`w-(--anchor-width)`,list:`max-h-[min(--spacing(52),var(--available-height))]`,search:_(ae(`default`,!1,`page`,`popup-search`),`mb-1`),rowTile:`grid size-5.5 shrink-0 place-items-center rounded-sm bg-surface-hover-layer text-caption font-semibold text-fg-secondary`,row:``},header:or,"header-narrow":or,"header-tile":or};function cr({value:e,onValueChange:t,list:n,labels:r,variant:a=`full`,recent:o,footerActions:s,open:c,onOpenChange:l,autoFocus:u,"data-testid":d}){let f=dt(),p=(0,H.useId)(),h=(0,H.useId)(),[g,b]=(0,H.useState)(``),[x,S]=(0,H.useState)(!1),C=c??x,w=sr[a],T=n.state===`ready`?n.projects:null,E=(0,H.useMemo)(()=>T===null?/* @__PURE__ */ new Map:new Map(T.map(e=>[e.id,e])),[T]),D=(0,H.useMemo)(()=>{if(T===null||o===void 0||g.trim()!==``||T.length<=Zn)return null;let e=new Set(o.ids),t=T.filter(t=>e.has(t.id));return t.length===0?null:[{heading:o.heading,items:t},{heading:o.restHeading,items:T.filter(t=>!e.has(t.id))}]},[T,o,g]),O=T===null?[]:D??T,te=e=>{c===void 0&&S(e),l==null||l(e),e||b(``)},k=e=>{let t=Un(e.name);return/* @__PURE__ */ (0,U.jsxs)(Jt,{value:e,className:_(v,w.row),children:[w.rowTile===null?/* @__PURE__ */ (0,U.jsx)(Xn,{name:e.name,size:22}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:w.rowTile,"aria-hidden":`true`,children:t??/* @__PURE__ */ (0,U.jsx)(Rt,{className:`size-3`})}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:_(m,`truncate`),children:e.name}),/* @__PURE__ */ (0,U.jsx)(We,{"aria-hidden":`true`,className:ee})]},e.id)},ne=n.state===`loading`?/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,"aria-label":r.loading,className:`grid gap-px`,children:Array.from({length:Qn},(e,t)=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2.5 px-2.5 py-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`size-5.5 rounded-sm`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3 w-[60%]`})]},t))}):n.state===`error`?/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`grid justify-items-center gap-2 pb-2`,children:[/* @__PURE__ */ (0,U.jsx)(`p`,{className:_(se,`m-0 pb-0`),children:n.message}),/* @__PURE__ */ (0,U.jsx)(M,{variant:`secondary`,size:`sm`,onClick:n.onRetry,children:r.retry})]}):/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(en,{children:/* @__PURE__ */ (0,U.jsx)(`div`,{className:se,children:r.empty})}),/* @__PURE__ */ (0,U.jsx)(Ut,{"aria-label":r.label,className:_(ar,w.list),children:D===null?k:e=>/* @__PURE__ */ (0,U.jsxs)(Bn,{items:e.items,children:[/* @__PURE__ */ (0,U.jsx)(Vn,{className:ut,children:e.heading}),/* @__PURE__ */ (0,U.jsx)(Yt,{children:k})]},e.heading)})]}),re=_(e===null?er:$n,`size-8.5`),ie=e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{className:ir,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(lr,{name:null})}):/* @__PURE__ */ (0,U.jsx)(Xn,{name:e.name,size:26}),A=/* @__PURE__ */ (0,U.jsx)(et,{"aria-hidden":`true`,className:_(`shrink-0 text-fg-muted [transition:transform_var(--motion-medium)_var(--ease-out)] group-data-popup-open/trigger:rotate-180`,a===`full`?`size-4`:`size-3.25`)}),ae=a===`header-tile`?/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${p} ${h}`,className:nr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:p,className:`sr-only`,children:r.label}),ie,/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`sr-only`,children:e===null?r.placeholder:e.name}),A]}):a===`header`||a===`header-narrow`?/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${p} ${h}`,className:nr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:p,className:`sr-only`,children:r.label}),ie,e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:_(rr[a],`font-medium text-fg-secondary`),children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(ce,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:rr[a],children:e.name})}),A]}):/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${p} ${h}`,className:tr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:re,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(lr,{name:(e==null?void 0:e.name)??null})}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`grid min-w-0 flex-1 leading-(--leading-picker)`,children:[/* @__PURE__ */ (0,U.jsx)(`small`,{id:p,className:`text-(length:--text-picker-label) text-fg-muted`,children:r.label}),e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`truncate text-base font-medium tracking-(--tracking-snug) text-fg-secondary`,children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(ce,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:h,className:`truncate text-base font-semibold tracking-(--tracking-heading) text-fg-primary`,children:e.name})})]}),A]});return/* @__PURE__ */ (0,U.jsxs)(Kt,{items:O,value:e,onValueChange:e=>{if(e===null)return;let n=E.get(e.id);if(n===void 0)throw Error(`ProjectPicker: chosen project ${e.id} is not in the list`);t(n)},itemToStringLabel:e=>e.name,isItemEqualToValue:(e,t)=>e.id===t.id,inputValue:g,onInputValueChange:b,open:C,onOpenChange:te,autoHighlight:!0,children:[a===`header-tile`?/* @__PURE__ */ (0,U.jsx)(I,{relationship:`none`,content:e===null?r.placeholder:e.name,placement:`bottom`,children:ae}):ae,/* @__PURE__ */ (0,U.jsx)(tn,{container:f,children:/* @__PURE__ */ (0,U.jsx)(Qt,{side:`bottom`,align:`start`,sideOffset:a===`full`?4:8,collisionPadding:8,positionMethod:`fixed`,className:fe,children:/* @__PURE__ */ (0,U.jsxs)(Vt,{"data-project-picker":``,"aria-label":r.placeholder,className:_(i,w.popup),children:[/* @__PURE__ */ (0,U.jsxs)(Wt,{className:w.search,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:xe,children:/* @__PURE__ */ (0,U.jsx)(y,{"aria-hidden":`true`})}),/* @__PURE__ */ (0,U.jsx)(Gt,{placeholder:r.search,"aria-label":r.search,className:be})]}),ne,s!==void 0&&/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`div`,{className:`mx-(--menu-padding) my-1 h-px border-0 bg-stroke-light`,role:`separator`}),s.map(e=>/* @__PURE__ */ (0,U.jsxs)(`button`,{type:`button`,"data-testid":e.testId,className:_(`group/opt flex min-h-(--menu-row-height) w-full cursor-pointer select-none items-center gap-(--menu-row-gap) rounded-(--menu-row-radius) border-0 bg-transparent px-(--menu-row-padding-x) py-(--menu-row-padding-y) text-left font-sans text-[length:var(--text-body-sm)] leading-normal outline-hidden [transition:background-color_var(--motion-instant)_var(--ease-out)] data-disabled:cursor-not-allowed data-disabled:opacity-disabled [&_svg]:size-(--menu-icon-size) [&_svg]:shrink-0 text-fg-primary data-highlighted:bg-surface-elevated-hover active:bg-surface-elevated-active data-selected:font-medium`,`hover:bg-surface-elevated-hover focus-visible:bg-surface-elevated-hover`),onClick:()=>{te(!1),e.onSelect()},children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex shrink-0 text-fg-muted`,children:e.icon}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.label})]},e.label))]})]})})})]})}function lr({name:e}){let t=e===null?null:Un(e);return t===null?/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`,className:`size-4`}):/* @__PURE__ */ (0,U.jsx)(U.Fragment,{children:t})}var ur=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function dr({host:e,applicationName:t,environmentName:n,newApplication:r,newEnvironment:i,replaced:a,fresh:o}){let s=e=>e.trim()===``?`\u2026`:e.trim(),c={host:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e}),application:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(t)}),environment:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(n)}),old:/* @__PURE__ */ (0,U.jsx)(`span`,{children:a===null?``:a.address}),b:/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`})},l;l=a===null?r&&i?`popup.site.bindSay.both`:r?`popup.site.bindSay.newApplication`:i?`popup.site.bindSay.newEnvironment`:`popup.site.bindSay.free`:o===`taken`?`popup.site.bindSay.freshTaken`:o===`changed`?`popup.site.bindSay.freshChanged`:`popup.site.bindSay.replace`;let u=`${l}|${t}|${n}|${a===null?``:a.address}`;return a===null?/* @__PURE__ */ (0,U.jsx)(`p`,{"aria-live":`polite`,className:`m-0 min-w-0 text-(length:--text-compact) leading-normal text-fg-secondary text-pretty wrap-anywhere ${ur}`,"data-testid":`popup-bind-consequence`,children:/* @__PURE__ */ (0,U.jsx)(Ce,{i18nKey:l,components:c})},u):/* @__PURE__ */ (0,U.jsx)(`div`,{role:o===null?void 0:`alert`,"aria-live":o===null?`polite`:void 0,className:ur,"data-testid":`popup-bind-consequence`,"data-replace":`true`,children:/* @__PURE__ */ (0,U.jsx)(Ne,{tone:`warning`,title:/* @__PURE__ */ (0,U.jsx)(Ce,{i18nKey:l,components:c})})},u)}var fr={local:`dev`,dev:`dev`,staging:`staging`,prod:`production`},pr=/* @__PURE__ */ new WeakMap;function mr(e,t){return`${e}|${t}`}function hr(e){let t=pr.get(e);if(t!==void 0)return t;let n=new Map(e.map(e=>[mr(e.applicationId,e.environmentId),e]));return pr.set(e,n),n}function gr(e,t,n){let r=hr(e).get(mr(t,n));return r===void 0?null:r}function _r(e,t,n){return n===null||t.kind!==`existing`||n.kind!==`existing`?null:gr(e.cells,t.id,n.id)}function vr(e){return e.trim().toLowerCase()}function yr(e,t){let n=vr(t);if(n===``)return null;let r=e.find(e=>vr(e.name)===n);return r===void 0?null:r}function br(e,t,n){let r=e.environments.filter(n=>t===null||gr(e.cells,t,n.id)===null),i=r.find(e=>e.envType===n.type)??r.find(e=>e.isDefault)??r.at(0);return i===void 0?{choice:{kind:`new`,name:yr(e.environments,n.name)===null?n.name:``},allTaken:e.environments.length>0}:{choice:{kind:`existing`,id:i.id},allTaken:!1}}var xr=/* @__PURE__ */ new Set([`targets.cell_exists`,`targets.modified_concurrently`,`targets.host_conflict`,`targets.not_found`]);function Sr(e){return e instanceof l&&e.errorCode!==void 0?e.errorCode:null}function Cr(e){return e instanceof Error?e.message:String(e)}function wr(e,t,n){return{application:e.application.kind===`new`&&n.application===null?yr(t.applications,e.application.name):null,environment:e.environment!==null&&e.environment.kind===`new`&&n.environment===null?yr(t.environments,e.environment.name):null}}function Tr(e){let t=Sr(e);return t!==null&&xr.has(t)}function Er(e){return e.application!==null&&e.environment!==null?`both`:e.application===null?e.environment===null?null:`environment`:`application`}function Dr(e,t){let n=Er(e);return n===null?t:N.t(`popup.site.createdNotBound.${n}`,{application:e.application,environment:e.environment,reason:t})}function K(e,t){let n=Er(t);if(n===null)return ye(N,e,`popup.site.bindFailed`);let r={application:t.application,environment:t.environment},i=N.t(`popup.site.bindPartial.${n}`,r),a=ye(N,e,`popup.site.bindPartial.${n}`,r);return a===i?a:Dr(t,a)}function Or(e,t,n,r,i){let{defaultApplicationId:a,proposal:o}=i,s=e.application,c=s.kind===`existing`&&!t.applications.some(e=>e.id===s.id)?{kind:`existing`,id:a}:s;if(!t.applications.some(e=>e.id===a))throw Error(`The default application ${a} left the project`);let l={...e,lists:t,application:c},u=e.environment;if(u!==null&&u.kind===`existing`&&!t.environments.some(e=>e.id===u.id)){let e=br(t,c.kind===`existing`?c.id:null,o);l={...l,environment:e.choice,environmentAllTaken:e.allTaken,environmentChosen:!1}}let d=Sr(n),f=_r(t,l.application,l.environment);return d===`targets.cell_exists`?{...l,fresh:f===null?null:`taken`,failure:null}:d===`targets.modified_concurrently`?{...l,fresh:f===null?null:`changed`,failure:null}:d===`targets.host_conflict`?{...l,fresh:null,failure:kr(n,l,r,i.host)}:{...l,fresh:null,failure:K(n,r)}}function kr(e,t,n,r){var i;let a=e instanceof l&&typeof((i=e.params)==null?void 0:i.applicationId)==`string`?e.params.applicationId:null,o=t.lists.applications.find(e=>e.id===a),s=t.environment,c=s!==null&&s.kind===`existing`?t.lists.environments.find(e=>e.id===s.id):void 0;return o===void 0||c===void 0?K(e,n):Dr(n,N.t(`popup.site.hostConflict`,{host:r,application:o.name,environment:c.name}))}var q=V(`pgs-e9b150372c`);function Ar(e){let{defaultApplicationId:t,host:n,proposal:r,requests:i}=e,[a,o]=(0,H.useState)(()=>{let n=br(e.lists,t,r);return{lists:e.lists,application:{kind:`existing`,id:t},environment:n.choice,environmentChosen:!1,environmentAllTaken:n.allTaken,problem:null,failure:null,fresh:null,pending:!1,createUnsettled:!1,focus:null}}),s=(0,H.useRef)(!1),c=(0,H.useRef)(0),u=()=>(c.current+=1,c.current),d=(e,t)=>({target:e,field:t,seq:u()}),f=(e,t)=>{if(e.environmentChosen&&e.environment!==null)return{environment:e.environment,environmentAllTaken:e.environmentAllTaken};let n=br(e.lists,t.kind===`existing`?t.id:null,r);return{environment:n.choice,environmentAllTaken:n.allTaken}},p=(e,t)=>({...e,application:t,...f(e,t),problem:null,failure:null,fresh:null}),m=(e,t)=>({...e,environment:t,environmentChosen:!0,environmentAllTaken:!1,problem:null,failure:null,fresh:null}),h=(e,t)=>{s.current||o(n=>{if(e===`application`)return t===`new`?{...p(n,{kind:`new`,name:``}),focus:d(`input`,e)}:p(n,{kind:`existing`,id:t});if(t!==`new`)return m(n,{kind:`existing`,id:t});let i=yr(n.lists.environments,r.name)!==null;return{...m(n,{kind:`new`,name:i?``:r.name}),focus:d(`input`,e)}})},g=(e,t)=>{o(n=>{let r=e===`application`?n.application:n.environment;if(r===null||r.kind!==`new`)throw Error(`The ${e} field is not a new name, it cannot be renamed`);let i={kind:`new`,name:t};return{...n,...e===`application`?{application:i}:{environment:i},problem:n.problem!==null&&n.problem.field===e?null:n.problem}})},_=e=>{s.current||o(n=>{if(e===`application`)return{...p(n,{kind:`existing`,id:t}),focus:d(`trigger`,e)};if(n.lists.environments.length===0)throw Error(`A project without environments has no list to go back to`);let i=br(n.lists,n.application.kind===`existing`?n.application.id:null,r),a=i.choice.kind===`existing`?i.choice:null;return{...m(n,a),focus:d(`trigger`,e)}})},v=(e,t)=>{o(n=>({...e===`application`?p(n,{kind:`existing`,id:t}):m(n,{kind:`existing`,id:t}),focus:d(`trigger`,e)}))},y=async a=>{let s={application:null,environment:null},c=a;if(c.createUnsettled)try{c=x(c,await i.readLists(),s)}catch(e){q.error(`pgm-9a173522f2`,{error:Cr(e)}),o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:u()}}));return}let d=c.environment;if(d===null)throw Error(`The bind press ran with no environment chosen`);let f=null;try{let t;if(c.application.kind===`new`){f=`application`;let n=await i.createApplication(c.application.name.trim());f=null,s.application=n.name,t=n.id,o(e=>({...e,lists:{...e.lists,applications:[...e.lists.applications,n]},application:{kind:`existing`,id:n.id}})),e.onApplicationCreated()}else t=c.application.id;let n;if(d.kind===`new`){f=`environment`;let t=await i.createEnvironment(d.name.trim(),c.lists.environments.length===0);f=null,s.environment=t.name,n=t.id,o(e=>({...e,lists:{...e.lists,environments:[...e.lists.environments,t]},environment:{kind:`existing`,id:t.id},environmentAllTaken:!1})),e.onEnvironmentCreated()}else n=d.id;let r=_r(c.lists,c.application,d);r===null?await i.createCell(t,n):await i.replaceCell(r)}catch(e){if(q.error(`pgm-53ab6bb5fe`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null,status:e instanceof l?e.status:null,code:Sr(e),error:Cr(e)}),f!==null){await b(c,s,e);return}if(Tr(e))try{let a=await i.readLists();o(i=>({...Or(i,a,e,s,{defaultApplicationId:t,proposal:r,host:n}),focus:{target:`submit`,seq:u()}}));return}catch(e){q.error(`pgm-a2654be732`,{error:Cr(e)})}o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:u()}}));return}q.info(`pgm-dfe3d492ed`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null}),await e.onBound()},b=async(e,t,n)=>{let r;try{r=await i.readLists()}catch(e){q.error(`pgm-200d50f185`,{error:Cr(e)}),o(e=>({...e,createUnsettled:!0,failure:K(n,t),focus:{target:`submit`,seq:u()}}));return}x(e,r,t),o(e=>({...e,failure:K(n,t),focus:{target:`submit`,seq:u()}}))},x=(t,n,r)=>{let i=wr(t,n,r);i.application!==null&&(r.application=i.application.name,e.onApplicationCreated()),i.environment!==null&&(r.environment=i.environment.name,e.onEnvironmentCreated()),(i.application!==null||i.environment!==null)&&q.info(`pgm-52181e7844`,{application:i.application!==null,environment:i.environment!==null});let a=e=>({...e,lists:n,createUnsettled:!1,...i.application===null?{}:{application:{kind:`existing`,id:i.application.id}},...i.environment===null?{}:{environment:{kind:`existing`,id:i.environment.id},environmentAllTaken:!1}});return o(a),a(t)};return{state:a,choose:h,rename:g,backToList:_,chooseExisting:v,submit:()=>{if(!s.current){if(a.environment===null){o(e=>({...e,problem:{field:`environment`,kind:`unchosen`},focus:d(`trigger`,`environment`)}));return}for(let e of[`application`,`environment`]){let t=e===`application`?a.application:a.environment;if(t.kind!==`new`)continue;if(t.name.trim()===``){o(t=>({...t,problem:{field:e,kind:`empty`},focus:d(`input`,e)}));return}let n=yr(e===`application`?a.lists.applications:a.lists.environments,t.name);if(n!==null){o(t=>({...t,problem:{field:e,kind:`duplicate`,id:n.id,name:n.name},focus:d(`input`,e)}));return}}s.current=!0,o(e=>({...e,pending:!0,failure:null,fresh:null,problem:null})),e.onPressStarted(),y(a).finally(()=>{s.current=!1,o(e=>({...e,pending:!1})),e.onPressEnded()})}}}}var jr=V(`pgs-e9b150372c`),Mr=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function Nr(e){let{t:n}=F(),r=Ar(e),{state:i}=r,o=(0,H.useId)(),s=e=>`${o}-${e}`,c=(0,H.useRef)(null),l=(0,H.useRef)(null),u=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=i.focus;if(e===null)return;let t;if(t=e.target===`submit`?u.current:e.target===`input`?(e.field===`application`?c:l).current:document.getElementById(`${o}-${e.field}`),t===null){jr.warn(`pgm-9d57cb6e57`,{target:e.target});return}t.focus()},[i.focus,o]);let{lists:d,application:f,environment:p,pending:m,problem:h}=i,g=f.kind===`new`?f.name:Pr(d.applications,f.id),_=p===null?``:p.kind===`new`?p.name:Pr(d.environments,p.id),v=_r(d,f,p),y=e=>{if(h!==null&&h.field===e)return h.kind===`empty`?n(e===`application`?`popup.site.emptyApplication`:`popup.site.emptyEnvironment`):h.kind===`unchosen`?n(`popup.site.environmentRequired`):/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`min-w-0 wrap-anywhere`,children:[n(e===`application`?`popup.site.duplicateApplication`:`popup.site.duplicateEnvironment`,{name:h.name}),` `,/* @__PURE__ */ (0,U.jsx)(M,{variant:`link`,size:`xs`,onClick:()=>r.chooseExisting(e,h.id),"data-testid":`popup-bind-${e}-choose-existing`,children:n(`popup.site.chooseExisting`)})]})},b=(e,t,i)=>{let o=e===`application`||d.environments.length>0;return/* @__PURE__ */ (0,U.jsx)(Ye,{ref:e===`application`?c:l,id:s(e),size:`sm`,fieldClassName:`grid-cols-1`,label:n(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),placeholder:n(e===`application`?`popup.site.newApplicationPlaceholder`:`popup.site.newEnvironmentPlaceholder`),autoComplete:`off`,value:t,onValueChange:t=>r.rename(e,t),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),r.submit()):t.key===`Escape`&&o&&(t.preventDefault(),r.backToList(e))},disabled:m,leading:/* @__PURE__ */ (0,U.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5 text-fg-link`}),trailing:o?/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:n(`popup.site.backToList`),placement:`top`,children:/* @__PURE__ */ (0,U.jsx)(E,{size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(a,{"aria-hidden":`true`}),onClick:()=>r.backToList(e),disabled:m,"data-testid":`popup-bind-${e}-back`})}):void 0,hint:i,error:y(e),className:Mr,"data-testid":`popup-bind-${e}-name`},`${e}-new`)},x=e=>({options:[{value:`new`,label:n(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),icon:/* @__PURE__ */ (0,U.jsx)(ge,{"aria-hidden":`true`,className:`text-fg-link`})}]}),S=f.kind===`new`?b(`application`,f.name,void 0):/* @__PURE__ */ (0,U.jsx)(Xe,{id:s(`application`),size:`sm`,fieldClassName:`grid-cols-1`,label:n(`popup.site.applicationLabel`),value:f.id,onValueChange:e=>r.choose(`application`,e),disabled:m,groups:[{options:d.applications.map(e=>({value:e.id,label:e.name}))},x(`application`)],"data-testid":`popup-bind-application`},`application-list`),C;d.environments.length===0?C=n(`popup.site.noEnvironmentsHint`):i.environmentAllTaken&&(C=/* @__PURE__ */ (0,U.jsx)(`span`,{className:`wrap-anywhere`,children:n(`popup.site.allTakenHint`,{application:g.trim()===``?`\u2026`:g.trim()})}));let ee=p!==null&&p.kind===`new`?b(`environment`,p.name,C):/* @__PURE__ */ (0,U.jsx)(Xe,{id:s(`environment`),size:`sm`,fieldClassName:`grid-cols-1`,label:n(`popup.site.environmentLabel`),value:p===null?null:p.id,placeholder:n(`popup.site.environmentPlaceholder`),error:y(`environment`),onValueChange:e=>r.choose(`environment`,e),disabled:m,groups:[{options:d.environments.map(e=>{let t=f.kind===`existing`?gr(d.cells,f.id,e.id):null;return t===null?{value:e.id,label:e.name}:{value:e.id,label:e.name,description:n(`popup.site.taken`,{address:t.address})}})},x(`environment`)],"data-testid":`popup-bind-environment`},`environment-list`);return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`group`,"aria-label":n(`popup.site.bind`),"aria-busy":m,className:`grid min-w-0 grid-cols-1 gap-2.5 rounded-md border border-stroke-light bg-surface-modal-inset px-3 pt-2.5 pb-3`,"data-testid":`popup-bind-form`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2.5`,children:[S,ee]}),h===null&&p!==null&&/* @__PURE__ */ (0,U.jsx)(dr,{host:e.host,applicationName:g,environmentName:_,newApplication:f.kind===`new`,newEnvironment:p.kind===`new`,replaced:v,fresh:i.fresh}),i.failure!==null&&/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-1.5 text-(length:--text-compact) leading-(--leading-caption) text-fg-error`,"data-testid":`popup-bind-failure`,children:[/* @__PURE__ */ (0,U.jsx)(t,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:i.failure})]}),/* @__PURE__ */ (0,U.jsx)(M,{ref:u,size:`sm`,icon:v===null?/* @__PURE__ */ (0,U.jsx)(w,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(cn,{"aria-hidden":`true`}),loading:m,onClick:r.submit,className:`justify-self-end`,"data-testid":`popup-bind-submit`,children:n(v===null?`popup.site.bind`:`popup.site.replace`)})]})}function Pr(e,t){let n=e.find(e=>e.id===t);if(n===void 0)throw Error(`The bind form chose ${t}, absent from its list`);return n.name}function J({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{"aria-live":`polite`,className:`grid grid-cols-1 gap-2 border-t border-stroke-light py-2.5 pr-3 pl-3.5 animate-ui-fade-in motion-reduce:animate-none`,"data-testid":`popup-site`,children:e})}function Y({host:e}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-body-sm text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(S,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-fg-muted`}),/* @__PURE__ */ (0,U.jsx)(`b`,{className:`min-w-0 truncate font-medium text-fg-primary`,children:e})]})}var Fr=`inline-flex h-6 items-center rounded-full border border-stroke bg-surface-hover-layer text-xs text-fg-primary`;function Ir({applicationName:e,environmentName:t}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{"aria-label":n(`popup.site.cellLabel`),className:`flex flex-wrap items-center gap-1.5`,"data-testid":`popup-site-cell`,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:_(Fr,`px-2.25 font-medium`),children:e}),/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-fg-muted`,children:`\u00D7`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:_(Fr,`px-2.5 font-semibold animate-[popup-environment-in_var(--motion-long)_var(--ease-out)_both]`),children:t})]})}function Lr({children:e,hintName:t,hint:n,tone:r=`default`,icon:i}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:_(`flex min-w-0 items-center gap-1.5 [&>svg]:size-3.5 [&>svg]:shrink-0`,r===`warning`&&`text-fg-warning`),children:[i,/* @__PURE__ */ (0,U.jsx)(`p`,{className:_(`m-0 min-w-0 text-(length:--text-compact) leading-normal [&_b]:font-semibold [&_b]:text-fg-primary`,r===`warning`?`text-inherit`:r===`muted`?`text-fg-muted`:`text-fg-secondary`),children:e}),/* @__PURE__ */ (0,U.jsx)(B,{name:t,text:n,placement:`bottom-start`})]})}var Rr=V(`pgs-f048f86b7e`);function zr({projectId:e,host:t,environments:n,chosenId:r,onChosen:i}){let{t:a}=F(),o=x(),[s,c]=(0,H.useState)(!1);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Lr,{hintName:a(`popup.site.more`,{about:a(`popup.site.environmentChoice`)}),hint:a(`popup.site.environmentChoiceHint`),children:a(`popup.site.environmentChoice`)}),/* @__PURE__ */ (0,U.jsx)(Xe,{size:`sm`,"aria-label":a(`popup.site.environmentLabel`),placeholder:a(`popup.site.environmentPlaceholder`),value:r,onValueChange:t=>{s||(c(!0),z.environments.setActive(O(e),`extension`,t).then(()=>{Rr.info(`pgm-f54cd7418d`,{projectId:e}),i()}).catch(t=>{Rr.error(`pgm-effdde2b56`,{projectId:e,error:t instanceof Error?t.message:String(t)}),o.show({id:`popup-environment-choice`,variant:`error`,message:a(`popup.site.environmentFailed`)})}).finally(()=>c(!1)))},disabled:s,options:n.map(e=>({value:e.id,label:e.name,description:t})),"data-testid":`popup-site-environment`})]})}function Br(e){let t=e.toLowerCase();return/(^|\/\/|\.)dev\./.test(t)?`dev`:/stag/.test(t)?`staging`:/localhost|127\.0/.test(t)?`local`:`prod`}function Vr(e){let t=e.toLowerCase();return/prod/.test(t)?`production`:/stag/.test(t)?`staging`:/dev|local|\u043B\u043E\u043A\u0430\u043B/.test(t)?`dev`:`custom`}function Hr(e){let t=Br(e);return{key:`popup.site.environmentSuggestion.${t}`,type:fr[t]}}function Ur(e){return{targetId:e.id,applicationId:e.applicationId,environmentId:e.environmentId,baseUrl:e.baseUrl,hostPattern:e.hostPattern}}function Wr(e,t,n){let{targets:r,applications:i,environments:a}=t,o=r.find(e=>e.baseUrl===null&&e.hostPattern===null);if(o!==void 0)return{kind:`inconsistent`,reason:`Cell ${o.id} has neither an origin nor a host pattern`};let s=mt(n.href,r.map(Ur),null);switch(s.kind){case`matched`:{let t=Kr(i,s.applicationId),n=Kr(a,s.environmentId);return t===null||n===null?qr(e,t===null?s.applicationId:s.environmentId):{kind:`matched`,applicationName:t,environmentName:n}}case`ambiguous_application`:{let t=Kr(a,s.environmentId);return t===null?qr(e,s.environmentId):{kind:`ambiguous`,environmentName:t}}case`environment_choice`:{let t=s.environmentIds.find(e=>!a.some(t=>t.id===e));return t===void 0?{kind:`environmentChoice`,environments:a.filter(e=>s.environmentIds.includes(e.id)).map(e=>({id:e.id,name:e.name}))}:qr(e,t)}case`unknown_host`:case`no_targets`:{let n=i.find(e=>e.isDefault);return n===void 0?{kind:`inconsistent`,reason:`Project ${e} has no default application`}:{kind:`bind`,reason:s.kind,lists:Xr(t),defaultApplicationId:n.id}}case`unsupported_url`:return{kind:`unsupported`}}}function Gr(e,t){if(e.source!==`user_preference`||e.environmentId===null)return null;let n=e.environmentId;return t.some(e=>e.id===n)?n:null}function Kr(e,t){let n=e.find(e=>e.id===t);return n===void 0?null:n.name}function qr(e,t){return{kind:`inconsistent`,reason:`A cell of project ${e} names ${t}, absent from the lists read`}}async function Jr(e,t){let n=O(t),[r,i,a]=await Promise.all([e.targets.listAll(n),e.applications.byProject(n),e.environments.list(n)]);return{targets:r,applications:i,environments:a}}async function Yr(e,t){return Xr(await Jr(e,t))}function Xr(e){return{applications:e.applications.map(Zr),environments:e.environments.map(Qr),cells:e.targets.map($r)}}function Zr(e){return{id:e.id,name:e.name}}function Qr(e){return{id:e.id,name:e.name,envType:e.envType,isDefault:e.isDefault}}function $r(e){let t;if(e.baseUrl!==null)t=new URL(e.baseUrl).host;else if(e.hostPattern!==null)t=e.hostPattern;else throw Error(`Cell ${e.id} has neither an origin nor a host pattern`);return{id:e.id,applicationId:e.applicationId,environmentId:e.environmentId,address:t,hostPattern:e.hostPattern,updatedAt:e.updatedAt}}async function ei(e,t,n){return Zr(await e.applications.create({projectId:O(t),name:n}))}async function ti(e,t,n,r){return Qr(await e.environments.create({projectId:O(t),name:n,envType:Vr(n),isDefault:r}))}async function ni(e,t,n,r,i){await e.targets.create(O(t),{applicationId:Be(r),environmentId:i,baseUrl:n})}async function ri(e,t,n,r){let i=r.hostPattern!==null&&ht(n,[{targetId:r.id,applicationId:r.applicationId,environmentId:r.environmentId,baseUrl:null,hostPattern:r.hostPattern}]).length>0;await e.targets.update(O(t),r.id,{baseUrl:n,...r.hostPattern===null||i?{}:{hostPattern:null},expectedUpdatedAt:r.updatedAt})}var ii=V(`pgs-c1e3b0bb6f`);function ai({page:e,projects:t,onSelect:n}){let{t:i}=F(),a=st(),{data:o,error:s}=k({key:r(a,`target-matches`,e.href),read:()=>z.targets.match(e.href),freshness:`screen`});if((0,H.useEffect)(()=>{s!==null&&ii.error(`pgm-f294aabbd9`,{error:s.message})},[s]),s!==null||o===void 0)return null;let c=new Set(o.items.map(e=>e.projectId)),l=t.filter(e=>c.has(e.id));return l.length===0?null:/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:e.host}),l.map(e=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface-hover-layer py-2 pr-2 pl-2.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 truncate text-(length:--text-compact) leading-(--leading-caption) text-fg-secondary`,children:[i(`popup.site.suggestion`),` `,/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:i(`popup.site.suggestionProject`,{project:e.name})})]}),/* @__PURE__ */ (0,U.jsx)(M,{variant:`secondary`,size:`sm`,onClick:()=>n(e),"data-testid":`popup-site-suggestion`,children:i(`popup.site.select`)})]},e.id))]})}var oi=V(`pgs-94aad7e91e`),si={phase:`none`};function ci(e,t){let n=d(),[r,i]=(0,H.useState)(si),a=(0,H.useRef)({applications:null,environments:null}),o=(0,H.useMemo)(()=>({kind:`project`,projectId:e}),[e]),s=Ve({projectId:e}),c=ke({projectId:e}),l=ct({projectId:e}),u=t.href,f=(0,H.useMemo)(()=>s.data===void 0||c.data===void 0||l.data===void 0?null:Wr(e,{targets:s.data,applications:c.data,environments:l.data},new URL(u)),[e,s.data,c.data,l.data,u]),p=lt({projectId:e,client:`extension`},{enabled:f!==null&&f.kind===`environmentChoice`}),m=f!==null&&f.kind===`inconsistent`?f.reason:null;(0,H.useEffect)(()=>{m!==null&&oi.error(`pgm-0efc4cf256`,{projectId:e,reason:m})},[m,e]);let h=[s,c,l],g=e=>()=>{for(let t of e)t.reload()},_,v=h.filter(li);if(v.length>0)_={status:`failed`,retry:g(v)};else if(f===null)_={status:`loading`};else if(f.kind===`inconsistent`)_={status:`failed`,retry:g(h)};else if(f.kind===`environmentChoice`){if(li(p))_={status:`failed`,retry:g([p])};else if(p.data===void 0)_={status:`loading`};else{let e=Gr(p.data,f.environments);_={status:`ready`,screen:{...f,chosenId:e}}}}else _={status:`ready`,screen:f};r.phase===`outcome`&&_.status!==`failed`&&i(si);let y=_;return(r.phase===`press`||r.phase===`outcome`&&_.status===`failed`)&&(y={status:`binding`,screen:r.screen,retry:_.status===`failed`?_.retry:null}),{state:y,bindStarted:()=>{let e;if(y.status===`binding`)e=y.screen;else if(y.status===`ready`&&y.screen.kind===`bind`)e=y.screen;else throw Error(`A bind press started while the site strip is ${y.status}`);a.current={applications:null,environments:null},i({phase:`press`,screen:e})},bindEnded:()=>{i(e=>e.phase===`press`?{phase:`outcome`,screen:e.screen}:e)},afterApplicationCreated:()=>{a.current.applications=n.invalidateAfterChange(Fe(o))},afterEnvironmentCreated:()=>{a.current.environments=n.invalidateAfterChange(at(o))},afterBind:async()=>{let e=a.current;a.current={applications:null,environments:null};let t=(e,t)=>e===null?n.invalidateAfterChange(t):e;await Promise.all([t(e.applications,Fe(o)),t(e.environments,at(o))]),await n.invalidateAfterChange(Ee(o)),i(si)},afterEnvironmentChosen:()=>{n.invalidateAfterChange(Ie(o))}}}function li(e){return e.error!==null||e.refreshError!==null}var ui=V(`pgs-3b85b4fc58`);function di({tabId:e,project:t,projects:n,onSelectProject:r}){let i=fi(e);if(i.status!==`read`)return null;let a=i.url,o=a===null?null:u(a),s=o!==null&&o.ok?o.url:null;return t===null?s===null?null:/* @__PURE__ */ (0,U.jsx)(ai,{page:s,projects:n,onSelect:r}):s===null?/* @__PURE__ */ (0,U.jsx)(pi,{}):/* @__PURE__ */ (0,U.jsx)(mi,{project:t,page:s})}function fi(e){let[t,n]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let t=!0;return chrome.tabs.get(e).then(r=>{t&&n({tabId:e,result:{status:`read`,url:r.url??null}})},r=>{ui.error(`pgm-df207305cf`,{tabId:e,error:r instanceof Error?r.message:String(r)}),t&&n({tabId:e,result:{status:`failed`}})}),()=>{t=!1}},[e]),t===null||t.tabId!==e?{status:`reading`}:t.result}function pi(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsx)(J,{children:/* @__PURE__ */ (0,U.jsx)(Lr,{tone:`muted`,hintName:e(`popup.site.more`,{about:e(`popup.site.notSite`)}),hint:e(`popup.site.notSiteHint`),children:e(`popup.site.notSite`)})})}function mi({project:e,page:t}){let{t:n}=F(),r=ci(O(e.id),t),{state:i}=r,a={createApplication:t=>ei(z,e.id,t),createEnvironment:(t,n)=>ti(z,e.id,t,n),createCell:(n,r)=>ni(z,e.id,t.origin,n,r),replaceCell:n=>ri(z,e.id,t.origin,n),readLists:()=>Yr(z,e.id)},o=async()=>{try{let t=await L.call(`REFRESH_PROJECT_TARGETS`,{projectId:e.id});t.success||ui.error(`pgm-ef389a0081`,{projectId:e.id,error:t.error})}catch(t){ui.error(`pgm-fc30de5d00`,{projectId:e.id,error:t instanceof Error?t.message:String(t)})}await r.afterBind()};if(i.status===`failed`)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(gi,{retry:i.retry})]});if(i.status===`loading`)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":n(`popup.site.reading`),className:`flex items-center gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-6 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-6 w-20.5 rounded-full`})]})]});let s=(n,i)=>/* @__PURE__ */ (0,U.jsx)(hi,{project:e,page:t,screen:n,retry:i,requests:a,site:r,onBound:o});if(i.status===`binding`)return s(i.screen,i.retry);let c=i.screen;switch(c.kind){case`unsupported`:return/* @__PURE__ */ (0,U.jsx)(pi,{});case`matched`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Ir,{applicationName:c.applicationName,environmentName:c.environmentName})]});case`ambiguous`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Lr,{tone:`warning`,icon:/* @__PURE__ */ (0,U.jsx)(pe,{"aria-hidden":`true`}),hintName:n(`popup.site.more`,{about:n(`popup.site.ambiguous`,{environment:c.environmentName})}),hint:n(`popup.site.ambiguousHint`),children:n(`popup.site.ambiguous`,{environment:c.environmentName})})]});case`environmentChoice`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(zr,{projectId:e.id,host:t.host,environments:c.environments,chosenId:c.chosenId,onChosen:r.afterEnvironmentChosen})]});case`bind`:return s(c,null)}}function hi({project:e,page:t,screen:n,retry:r,requests:i,site:a,onBound:o}){let{t:s}=F(),c=Hr(t.host);return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),r!==null&&/* @__PURE__ */ (0,U.jsx)(gi,{retry:r}),/* @__PURE__ */ (0,U.jsx)(Lr,{hintName:s(`popup.site.bindMore`),hint:s(`popup.site.bindInfo`),children:/* @__PURE__ */ (0,U.jsx)(Ce,{i18nKey:n.reason===`no_targets`?`popup.site.noTargets`:`popup.site.notBound`,components:{b:/* @__PURE__ */ (0,U.jsx)(`b`,{}),project:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e.name})}})}),/* @__PURE__ */ (0,U.jsx)(Nr,{lists:n.lists,defaultApplicationId:n.defaultApplicationId,host:t.host,proposal:{name:s(c.key),type:c.type},requests:i,onPressStarted:a.bindStarted,onPressEnded:a.bindEnded,onApplicationCreated:a.afterApplicationCreated,onEnvironmentCreated:a.afterEnvironmentCreated,onBound:o})]})}function gi({retry:e}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{role:`alert`,className:`m-0 flex gap-1.5 text-(length:--text-compact) leading-normal text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(t,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:n(`popup.site.readFailed`)})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{children:/* @__PURE__ */ (0,U.jsx)(M,{variant:`secondary`,size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(ue,{"aria-hidden":`true`}),onClick:e,"data-testid":`popup-site-retry`,children:n(`common.retry`)})})]})}var _i=V(`pgs-930365a583`),vi=`all`;function yi({tabId:e,applications:t,applicationId:n}){let{t:r}=F(),i=x();return/* @__PURE__ */ (0,U.jsx)(Xe,{appearance:`inline`,label:r(`popup.application.label`),value:n===null?vi:n,onValueChange:t=>{let n=t===vi?null:t;L.call(`SET_TAB_STATE`,{tabId:e,state:{applicationId:n}}).then(e=>{if(!e.success)throw Error(`SET_TAB_STATE refused: ${e.error}`)}).catch(t=>{_i.error(`pgm-e58825e7fe`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-application`,variant:`error`,message:r(`popup.application.switchFailed`)})})},options:[{value:vi,label:r(`popup.application.all`)},...t.map(e=>({value:e.id,label:e.name}))],"data-testid":`popup-application`})}function bi({run:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2.5 rounded-b-lg border-t border-stroke-light bg-[color-mix(in_srgb,var(--color-info)_8%,transparent)] py-2.25 pr-3 pl-3.5 text-(length:--text-compact) leading-snug`,"data-testid":`popup-run-line`,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-info shadow-(--glow-status-info) animate-pulse-dot`}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:e.kind===`free`?t(`popup.run.free`,{number:e.number}):t(`popup.run.plan`,{plan:e.planName})}),` `,t(`popup.run.where`)]})]})}var xi=V(`pgs-c184079221`);function Si({tabId:e,projects:t,tabProject:n,applicationId:r,run:i,onPick:a,pickerOpen:o,onPickerOpenChange:s}){let{t:c}=F();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":c(`popup.project.contextLabel`),className:`relative rounded-lg border border-(--color-border-overlay) bg-surface-card shadow-(--shadow-context-card)`,"data-testid":`popup-context`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`relative grid p-2`,children:[/* @__PURE__ */ (0,U.jsx)(cr,{value:n===null?null:{id:n.id,name:n.name},onValueChange:a,list:{state:`ready`,projects:t},labels:{label:c(`popup.project.label`),placeholder:c(`popup.project.placeholder`),search:c(`popup.project.search`),empty:c(`popup.project.empty`),loading:c(`popup.project.loading`),retry:c(`common.retry`)},open:o,onOpenChange:s,autoFocus:!0,"data-testid":`popup-project`}),n!==null&&/* @__PURE__ */ (0,U.jsx)(Ci,{tabId:e,projectId:O(n.id),applicationId:r},n.id)]}),/* @__PURE__ */ (0,U.jsx)(di,{tabId:e,project:n,projects:t,onSelectProject:a},`${e}:${n===null?``:n.id}`),i!==null&&/* @__PURE__ */ (0,U.jsx)(bi,{run:i})]})}function Ci({tabId:e,projectId:t,applicationId:n}){let{data:r,error:i}=ke({projectId:t});return(0,H.useEffect)(()=>{i!==null&&xi.error(`pgm-f42292fd59`,{error:i.message})},[i]),i!==null||r===void 0||r.length<=1?null:/* @__PURE__ */ (0,U.jsx)(yi,{tabId:e,applications:r,applicationId:n})}var wi=[{key:`bugs`,tone:`error`},{key:`checklists`,tone:`primary`},...Oe.incidentsEnabled?[{key:`incidents`,tone:`warning`}]:[]],Ti={bugs:`popup.filters.bugs`,checklists:`popup.filters.checklists`,incidents:`popup.filters.incidents`};function Ei(){let{t:e}=F(),t=W(`filters`),n=G();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":e(`popup.filters.title`),className:`grid gap-2`,"data-testid":`popup-filters`,children:[/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`mx-0.5 my-0 text-xs font-medium text-fg-muted`,children:e(`popup.filters.title`)}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t===void 0?wi.map(e=>/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-24 rounded-full`},e.key)):wi.map(r=>/* @__PURE__ */ (0,U.jsx)(Zt,{pressed:t[r.key],tone:r.tone,size:`md`,onClick:()=>n(`filters`,{...t,[r.key]:!t[r.key]}),"data-testid":`popup-filter-${r.key}`,children:e(Ti[r.key])},r.key))})]})}function Di(){let{t:e}=F(),t=G();return/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,children:/* @__PURE__ */ (0,U.jsx)(Ne,{tone:`info`,icon:/* @__PURE__ */ (0,U.jsx)(fn,{"aria-hidden":`true`}),title:e(`popup.paused.title`),actionsPlacement:`below`,actions:/* @__PURE__ */ (0,U.jsx)(rt,{onClick:()=>t(`enabled`,!0),children:e(`popup.paused.enable`)}),"data-testid":`popup-paused`})})}function Oi({projectSwitch:e,currentProjectName:t}){let{t:n}=F(),{question:r,busy:i,confirm:o,cancel:s}=e;if(r===null)return null;let{run:c,target:l}=r,u=c.kind===`free`,d=c.kind===`free`?n(`popup.switchRun.freeText`,{number:c.number,project:l.name}):t===null?n(`popup.switchRun.planTextNoProject`,{plan:c.planName}):n(`popup.switchRun.planText`,{plan:c.planName,project:t});return/* @__PURE__ */ (0,U.jsx)(le,{open:!0,busy:i,onCancel:s,tone:u?`danger`:`warning`,icon:u?/* @__PURE__ */ (0,U.jsx)(a,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(ln,{"aria-hidden":`true`}),title:n(u?`popup.switchRun.freeTitle`:`popup.switchRun.planTitle`),description:d,"data-testid":`popup-project-switch-question`,actions:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(M,{variant:`secondary`,onClick:s,children:n(`popup.switchRun.stay`)}),/* @__PURE__ */ (0,U.jsx)(M,{variant:u?`danger`:`primary`,loading:i,onClick:o,"data-testid":`popup-project-switch-confirm`,children:n(u?`popup.switchRun.freeConfirm`:`popup.switchRun.planConfirm`)})]})})}var ki=V(`pgs-ab0307fe13`);function Ai({tabId:e,projectId:t,currentTestRun:n}){let{t:r}=F(),i=x(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=async t=>{let n=await L.call(`RESTORE_PROJECT`,{tabId:e,projectId:t.id,projectNumber:t.number,applicationId:null});if(!n.success)throw Error(`RESTORE_PROJECT refused: ${n.error}`);ki.info(`pgm-496ade1c1d`,{tabId:e})},u=t=>{ki.error(`pgm-61ab57a774`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-project-switch`,variant:`error`,message:r(`popup.project.switchFailed`)})};return{question:a,busy:s,choose(e){if(e.id!==t){if(n!==null){o({target:e,run:n});return}l(e).catch(u)}},confirm(){a===null||s||(c(!0),l(a.target).catch(u).finally(()=>{c(!1),o(null)}))},cancel(){s||o(null)}}}function ji({user:e,header:t,back:n,strip:r,snapshot:i,projects:a,tabProject:o}){let{t:c}=F(),l=W(`enabled`),[u,d]=(0,H.useState)(!1),{state:f,tabId:p}=i,m=Ai({tabId:p,projectId:f.projectId,currentTestRun:f.currentTestRun}),h;switch(a.state){case`loading`:h=/* @__PURE__ */ (0,U.jsx)(vn,{});break;case`error`:h=/* @__PURE__ */ (0,U.jsx)(Mi,{children:/* @__PURE__ */ (0,U.jsx)(re,{icon:/* @__PURE__ */ (0,U.jsx)(jt,{"aria-hidden":`true`}),title:c(`popup.projects.failedTitle`),description:c(`popup.projects.failedText`),retry:{label:c(`common.retry`),onRetry:a.retry}})});break;case`ready`:{if(a.projects.length===0){h=/* @__PURE__ */ (0,U.jsx)(Mi,{children:/* @__PURE__ */ (0,U.jsx)(de,{icon:/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`}),title:c(`popup.projects.emptyTitle`),description:c(`popup.projects.emptyText`),action:/* @__PURE__ */ (0,U.jsx)(M,{icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onClick:()=>s(),children:c(`popup.projects.openWeb`)})})});break}let t=/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Si,{tabId:p,projects:a.projects,tabProject:o,applicationId:f.applicationId,run:f.currentTestRun,onPick:m.choose,pickerOpen:u,onPickerOpenChange:d}),/* @__PURE__ */ (0,U.jsx)(Ei,{})]});h=o===null?t:/* @__PURE__ */ (0,U.jsx)(At,{user:e,project:{id:O(o.id),number:ie(o.number)},children:t});break}}let g=a.state===`ready`&&a.projects.length>0;return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:_(`flex min-h-0 flex-1 flex-col`,n?Dt:Ct),children:[t,/* @__PURE__ */ (0,U.jsxs)(gn,{className:g&&u?`min-h-90`:void 0,children:[g&&l===!1&&/* @__PURE__ */ (0,U.jsx)(Di,{}),r,h]}),/* @__PURE__ */ (0,U.jsx)(Oi,{projectSwitch:m,currentProjectName:o===null?null:o.name})]})}function Mi({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`grid min-h-84 content-center`,children:e})}function Ni(){let{data:e,loading:t,error:n,reload:r}=C(),i=(0,H.useMemo)(()=>new Map(e===void 0?[]:e.map(e=>[e.id,e])),[e]);return n===null?t||e===void 0?{state:`loading`}:{state:`ready`,projects:e,byId:i}:{state:`error`,error:n,retry:()=>void r()}}var Pi=V(`pgs-aea740cf56`);function Fi({windowId:e,revision:t,back:n,onBack:r,onOpenSettings:i}){let{t:a}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${n?Dt:Ct}`,"data-testid":`popup-notification-feed`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:a(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(E,{icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),onClick:r,autoFocus:!0,"data-testid":`popup-feed-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 mr-auto text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:a(`notifications.feed.title`)}),/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:a(`notifications.feed.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(E,{icon:/* @__PURE__ */ (0,U.jsx)(bt,{"aria-hidden":`true`}),onClick:i,"data-testid":`popup-feed-settings`})})]}),/* @__PURE__ */ (0,U.jsx)(_t,{host:`popup`,api:z.notifications,locale:A(),t:a,revision:t,logger:Pi,onOpenTarget:t=>St(t,e),onOpenSettings:i,onSeen:()=>Ot(`seen`)})]})}var Ii=V(`pgs-a3c52049ce`);function Li({windowId:e,waitingCount:t,revision:n,onOpenFeed:r}){let{t:i}=F();return/* @__PURE__ */ (0,U.jsx)(xt,{api:z.notifications,locale:A(),t:i,waitingCount:t,revision:n,logger:Ii,onOpenTarget:t=>St(t,e),onOpenFeed:r,onSeen:()=>Ot(`seen`)})}function Ri({value:e,onChange:t,labels:n,size:r,fullWidth:i,className:a}){return/* @__PURE__ */ (0,U.jsx)(g,{value:e,onValueChange:t,"aria-label":n.group,size:r,fullWidth:i,className:a,options:[{value:`light`,label:n.light,icon:/* @__PURE__ */ (0,U.jsx)(pn,{"aria-hidden":`true`})},{value:`dark`,label:n.dark,icon:/* @__PURE__ */ (0,U.jsx)(dn,{"aria-hidden":`true`})},{value:`system`,label:n.system,icon:/* @__PURE__ */ (0,U.jsx)(Mt,{"aria-hidden":`true`})}]})}function X({title:e,hint:t,children:n,"data-testid":r}){let{t:i}=F();return/* @__PURE__ */ (0,U.jsxs)(`section`,{className:`grid gap-1.5`,"data-testid":r,children:[/* @__PURE__ */ (0,U.jsxs)(`h3`,{className:`mx-0.5 my-0 flex items-center gap-1 text-xs font-medium text-fg-muted`,children:[e,t!==void 0&&/* @__PURE__ */ (0,U.jsx)(B,{name:i(`popup.site.more`,{about:e}),text:t,placement:`bottom-start`})]}),/* @__PURE__ */ (0,U.jsx)(nn,{kind:`block`,body:`rows`,density:`compact`,children:/* @__PURE__ */ (0,U.jsx)(b,{children:n})})]})}function Z({label:e,below:t,stacked:n=!1,alignStart:r=!1,children:i,"data-testid":a}){return/* @__PURE__ */ (0,U.jsx)(me,{title:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:e}),end:i,stacked:n,alignStart:r,"data-testid":a,children:t})}var zi={on:`bg-success shadow-(--glow-status-success)`,neutral:`bg-fg-muted`,warning:`bg-warning`,error:`bg-error`},Bi={on:`text-fg-muted`,neutral:`text-fg-muted`,warning:`text-fg-warning`,error:`text-fg-error`};function Q({tone:e,announce:t=!1,children:n,action:r,"data-testid":i}){return/* @__PURE__ */ (0,U.jsxs)(`span`,{role:e===`error`?`alert`:t?`status`:void 0,className:_(`flex items-start gap-1.75 text-xs leading-(--leading-caption)`,Bi[e]),"data-testid":i,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:_(`mt-1.25 size-1.75 flex-none rounded-full`,zi[e])}),/* @__PURE__ */ (0,U.jsxs)(`span`,{children:[n,r]})]})}function Vi({onRetry:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[` \u00B7 `,/* @__PURE__ */ (0,U.jsx)(M,{variant:`link`,size:`xs`,onClick:e,children:t(`common.retry`)})]})}var Hi=V(`pgs-6344bc6f0d`);function Ui(e,t){let n=d(),i=(0,H.useMemo)(()=>r({kind:`project`,projectId:e},`discovery-settings`),[e]),a=k({key:i,read:async()=>{let t=await L.call(`REFRESH_DISCOVERY_SETTINGS`,{projectId:e});if(!t.success)throw Error(`REFRESH_DISCOVERY_SETTINGS refused: ${t.error}`);if(t.discoverySettings===null)throw Error(`The service worker could not read the discovery settings`);return t.discoverySettings},freshness:`screen`}),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[u,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),h=(0,H.useRef)(null),g=(0,H.useRef)(!1),_=(0,H.useRef)(!1),v=(0,H.useRef)(null),y=(0,H.useCallback)(async()=>{if(!_.current){_.current=!0,l(!0),f(!1),m(!1);try{for(;h.current!==null||g.current;){let r=h.current;if(r!==null){try{await z.discovery.updateUserSettings(r)}catch(t){Hi.warn(`pgm-6e1d90d469`,{projectId:e,error:t instanceof Error?t.message:String(t)}),v.current=h.current,h.current=null,s(null),f(!0);continue}g.current=!0,h.current===r&&(h.current=null,s(null));continue}g.current=!1;let a=await Wi(e,t);a===null?m(!0):(n.write(i,a),m(!1))}}finally{_.current=!1,l(!1)}}},[n,i,e,t]),b=(0,H.useCallback)(e=>{h.current=e,s(e),y()},[y]),x=(0,H.useCallback)(()=>{let e=v.current;if(e===null)throw Error(`No failed discovery save to retry`);v.current=null,b(e)},[b]),S=(0,H.useCallback)(()=>{g.current=!0,y()},[y]);if(a.error!==null)return{status:`readFailed`,retry:()=>void a.reload()};if(p&&!c)return{status:`readFailed`,retry:S};let C=a.data;return C===void 0?{status:`loading`}:{status:`ready`,settings:C,checked:o===null?C.userEnabled:o,saving:c,saveFailed:u,toggle:b,retrySave:x}}async function Wi(e,t){let n=await L.call(`REFRESH_DISCOVERY_SETTINGS`,{tabId:t,projectId:e}).catch(t=>(Hi.warn(`pgm-8a2d41a868`,{projectId:e,error:t instanceof Error?t.message:String(t)}),null));return n===null?null:n.success?(n.discoverySettings===null&&Hi.warn(`pgm-842d0b7de2`,{projectId:e}),n.discoverySettings):(Hi.warn(`pgm-a943e9be7d`,{projectId:e,error:n.error}),null)}function Gi(e){var t;return((t=e.disabledReasons)==null?void 0:t.includes(`company_disabled`))===!0||!e.companyEnabled}function Ki(e){return e.gatingModel===`company+user+project`&&e.projectEnabled===!1}var $=`popup-discovery-status`;function qi({tabId:e,project:t}){let{t:n}=F();return t===void 0?/* @__PURE__ */ (0,U.jsx)(Zi,{status:/* @__PURE__ */ (0,U.jsx)(Yi,{}),control:/* @__PURE__ */ (0,U.jsx)(Xi,{})}):t===null?/* @__PURE__ */ (0,U.jsx)(Zi,{status:/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.noProject`)}),control:null}):/* @__PURE__ */ (0,U.jsx)(Ji,{tabId:e,project:t})}function Ji({tabId:e,project:t}){let{t:n}=F(),r=Ui(O(t.id),e),i,a=null;switch(r.status){case`loading`:i=/* @__PURE__ */ (0,U.jsx)(Yi,{}),a=/* @__PURE__ */ (0,U.jsx)(Xi,{});break;case`readFailed`:i=/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:r.retry}),children:n(`popup.settings.discoveryStatus.readFailed`)});break;case`ready`:{let{settings:e}=r;i=r.saving?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.saving`)}):r.saveFailed?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:r.retrySave}),children:n(`popup.settings.discoveryStatus.saveFailed`)}):Gi(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.companyOff`)}):Ki(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.projectOff`,{project:t.name})}):e.effectiveEnabled?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`on`,children:n(`popup.settings.discoveryStatus.on`,{project:t.name})}):/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.off`)}),a=/* @__PURE__ */ (0,U.jsx)(o,{"aria-label":n(`popup.settings.discovery`),checked:r.checked,onChange:r.toggle,"data-testid":`popup-discovery-toggle`});break}}return/* @__PURE__ */ (0,U.jsx)(Zi,{status:i,control:a})}function Yi(){return/* @__PURE__ */ (0,U.jsx)(P,{className:`mt-1 h-3 w-40`})}function Xi(){return/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`})}function Zi({status:e,control:t}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[n(`popup.settings.discovery`),/* @__PURE__ */ (0,U.jsx)(B,{name:n(`popup.site.more`,{about:n(`popup.settings.discovery`)}),text:n(`popup.settings.discoveryHint`),placement:`bottom-start`})]}),below:e,alignStart:!0,"data-testid":`popup-discovery`,children:t})}function Qi({children:e}){return/* @__PURE__ */ (0,U.jsx)(`kbd`,{className:`inline-flex shrink-0 items-center rounded-full px-1.5 py-0.75 font-sans text-(length:--text-micro) leading-none font-medium whitespace-nowrap text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,children:e})}var $i=/* @__PURE__ */ new Set([`Control`,`Alt`,`Shift`,`Meta`]);function ea(e){if($i.has(e.key))return null;let t=[];return(e.ctrlKey||e.metaKey)&&t.push(`Ctrl`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`),e.key===` `?t.push(`Space`):t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join(`+`)}function ta(){let{t:e}=F(),t=W(`selectionHotkey`),n=G(),[r,i]=(0,H.useState)(!1);return t===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-(--control-height-sm) w-12 rounded-(--input-radius)`}):/* @__PURE__ */ (0,U.jsx)(T,{size:`sm`,active:r,"aria-label":e(`popup.settings.hotkeyName`,{hotkey:t}),onClick:()=>i(!0),onBlur:()=>i(!1),onKeyDown:e=>{if(!r)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=ea(e);t!==null&&(i(!1),n(`selectionHotkey`,t))},"data-testid":`popup-hotkey`,children:r?/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-(--color-primary-text) animate-pulse-dot`,children:e(`popup.settings.hotkeyCapture`)}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:t.split(`+`).map((e,t)=>/* @__PURE__ */ (0,U.jsx)(Qi,{children:e},`${e}-${t}`))})})}function na(e,t){return t?`element`:e?`window`:`off`}function ra(e){return{isolationWindow:e===`window`,isolationElement:e===`element`}}var ia=Promise.resolve();function aa(e){let t=()=>Ze(ra(e)),n=ia.then(t,t);return ia=n,n}var oa=V(`pgs-fed3bb0e75`),sa={managed:null,company:`popup.settings.modelKeyCompany`,personal:`popup.settings.modelKeyPersonal`};function ca(){let{t:e}=F(),t=x(),n=G(),i=W(`modelPick`),a=(0,H.useMemo)(()=>zt({http:pt(),logger:oa}),[]),o=st(),{data:s,error:c,reload:l}=k({key:r(o,`chat-model-capabilities`),read:()=>a.load(),freshness:`screen`});if((0,H.useEffect)(()=>{c!==null&&(oa.error(`pgm-9665648376`,{error:c.message}),t.show({id:`popup-models`,variant:`error`,message:e(`popup.settings.modelLoadFailed`),action:{label:e(`common.retry`),onAction:()=>void l()}}))},[c,l,e,t]),i===void 0||s===void 0&&c===null)return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),children:/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8 w-37.5 rounded-md`})});let u=s===void 0?[]:s.groups,d=s===void 0||i===null?null:kt(s,i),f=s===void 0?null:Lt(s,d,null);return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),"data-testid":`popup-model`,children:/* @__PURE__ */ (0,U.jsx)(Xe,{size:`sm`,"aria-label":e(`popup.settings.model`),placeholder:e(`popup.settings.modelNone`),value:f===null?null:f.model.selectionId,onValueChange:r=>{for(let i of u){let a=i.models.find(e=>e.selectionId===r);if(a!==void 0){n(`modelPick`,{keySource:i.source,modelId:a.id}),z.aiSettings.updateUser({selectedProvider:i.source,selectedModel:a.id}).catch(n=>{oa.error(`pgm-573d3af0bc`,{error:n instanceof Error?n.message:String(n)}),t.show({id:`popup-model-save`,variant:`error`,message:e(`popup.settings.saveFailed`)})});return}}throw Error(`The AI model Select picked a row it did not render: ${r}`)},className:`w-37.5`,options:u.flatMap(t=>t.models.map(n=>{let r=sa[t.source];return{value:n.selectionId,label:r===null?n.name:`${n.name} \u00B7 ${e(r)}`,disabled:!Pt(n)}}))})})}var la=V(`pgs-cdc66fba2a`),ua={permissions:[`notifications`]};function da(e){return e instanceof Error?e.message:String(e)}function fa(){return[chrome.permissions.onAdded,chrome.permissions.onRemoved]}function pa(e){var t;return((t=e.permissions)==null?void 0:t.includes(`notifications`))===!0}function ma(){let{t:e}=F(),[t,n]=(0,H.useState)(`reading`),r=(0,H.useRef)(!0),i=(0,H.useCallback)(()=>{chrome.permissions.contains(ua).then(e=>{r.current&&n(t=>e?`on`:t===`denied`?`denied`:`off`)},e=>{la.error(`pgm-cbfb085fbb`,{error:da(e)}),r.current&&n(`readFailed`)})},[]);(0,H.useEffect)(()=>{r.current=!0;let e=e=>{pa(e)&&i()},t=fa();for(let n of t)n.addListener(e);return i(),()=>{r.current=!1;for(let n of t)n.removeListener(e)}},[i]);let a=()=>{n(`reading`),i()},s=e=>{if(e){n(`asking`),chrome.permissions.request(ua).then(e=>n(e?`on`:`denied`),e=>{la.error(`pgm-67efc28caa`,{error:da(e)}),n(`off`)});return}chrome.permissions.remove(ua).then(e=>{e||la.error(`pgm-2cbfb59188`),n(e?`off`:`on`)},e=>{la.error(`pgm-ac8845b9f5`,{error:da(e)})})},c=e(`popup.settings.osNotifications`);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[c,/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:c}),text:e(`popup.settings.osNotificationsHint`),placement:`bottom-start`})]}),below:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`small`,{className:`text-xs leading-(--leading-caption) text-fg-muted`,children:e(`popup.settings.osNotificationsWhen`)}),t===`denied`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`neutral`,announce:!0,"data-testid":`popup-os-notifications-denied`,children:e(`popup.settings.osNotificationsDenied`)}),t===`readFailed`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:a}),"data-testid":`popup-os-notifications-read-failed`,children:e(`popup.settings.osNotificationsReadFailed`)})]}),alignStart:!0,"data-testid":`popup-os-notifications`,children:t===`reading`?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):t===`readFailed`?null:/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-fg-muted`,children:[t===`asking`&&/* @__PURE__ */ (0,U.jsx)(_e,{}),/* @__PURE__ */ (0,U.jsx)(o,{"aria-label":c,checked:t===`on`,onChange:s,"data-testid":`popup-os-notifications-switch`})]})})}var ha=V(`pgs-7fed4be7cb`);function ga(){let{t:e}=F(),t=W(`notificationsEnabled`),n=G(),r=e(`popup.settings.notifications`);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(X,{title:e(`popup.settings.groups.notifications`),hint:e(`popup.settings.groups.notificationsHint`),"data-testid":`popup-notification-groups`,children:/* @__PURE__ */ (0,U.jsx)(Tt,{api:z.notifications,locale:A(),t:e,logger:ha,onChanged:()=>Ot(`group_changed`)})}),/* @__PURE__ */ (0,U.jsxs)(X,{title:e(`popup.settings.groups.thisBrowser`),children:[/* @__PURE__ */ (0,U.jsx)(ma,{}),/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[r,/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:r}),text:e(`popup.settings.notificationsHint`),placement:`bottom-start`})]}),children:t===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(o,{"aria-label":r,checked:t,onChange:e=>n(`notificationsEnabled`,e),"data-testid":`popup-notifications`})})]})]})}var _a=/^\d+$/;function va(e){let t=e.trim();return _a.test(t)?Number(t)>qe?`tooLong`:null:`notWholeNumber`}function ya(){let{t:e,i18n:n}=F(),r=W(`autoplayStepPauseMs`),i=G(),[a,o]=(0,H.useState)(null),s=a===null?null:va(a),c=s!==null,l=()=>{if(a===null||c)return;let e=Number(a.trim());o(null),e!==r&&i(`autoplayStepPauseMs`,e)};return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.pause`),alignStart:!0,below:c?/* @__PURE__ */ (0,U.jsxs)(`span`,{role:`alert`,className:`mt-0.5 flex items-start gap-1.5 text-xs leading-(--leading-caption) text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(t,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:s===`tooLong`?e(`popup.settings.pauseTooLong`,{max:new Intl.NumberFormat(n.language).format(qe)}):e(`popup.settings.pauseInvalid`)})]}):void 0,"data-testid":`popup-step-pause`,children:r===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8 w-26 rounded-md`}):/* @__PURE__ */ (0,U.jsx)(Ye,{size:`sm`,inputMode:`numeric`,"aria-label":e(`popup.settings.pauseName`),value:a??String(r),onValueChange:o,onBlur:l,onKeyDown:e=>{e.key===`Enter`&&l()},invalid:c,trailing:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`popup.settings.ms`)}),className:`w-26 [&_input]:text-right [&_input]:tabular-nums`})})}function ba({tabId:e,project:t,onBack:n}){let{t:r}=F(),i=W(`theme`),a=G();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${Ct}`,"data-testid":`popup-settings`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:r(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(E,{icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),onClick:n,autoFocus:!0,"data-testid":`popup-settings-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:r(`popup.settings.title`)})]}),/* @__PURE__ */ (0,U.jsxs)(gn,{children:[/* @__PURE__ */ (0,U.jsx)(ga,{}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.view`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.theme`),stacked:!0,children:i===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(Ri,{value:i,onChange:e=>a(`theme`,e),labels:{group:r(`popup.settings.theme`),light:r(`popup.settings.themeLight`),dark:r(`popup.settings.themeDark`),system:r(`popup.settings.themeSystem`)},fullWidth:!0})}),/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.language`),stacked:!0,children:/* @__PURE__ */ (0,U.jsx)(jn,{fullWidth:!0})})]}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.recording`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.hotkey`),children:/* @__PURE__ */ (0,U.jsx)(ta,{})}),/* @__PURE__ */ (0,U.jsx)(ya,{}),/* @__PURE__ */ (0,U.jsx)(xa,{})]}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.assistant`),children:/* @__PURE__ */ (0,U.jsx)(ca,{})}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.pages`),children:/* @__PURE__ */ (0,U.jsx)(qi,{tabId:e,project:t},t==null?``:t.id)})]})]})}function xa(){let{t:e}=F(),t=An(),n=W(`isolationWindow`),r=W(`isolationElement`),i=n=>{t({id:`popup-isolation`,run:()=>aa(n),log:{message:`Input isolation was not stored`,context:{isolation:n}},message:e(`popup.settings.saveFailed`)})},a=n===void 0||r===void 0?void 0:na(n,r);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[e(`popup.settings.isolation`),/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:e(`popup.settings.isolation`)}),text:e(`popup.settings.isolationHint`),placement:`bottom-start`})]}),stacked:!0,"data-testid":`popup-isolation`,children:a===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(g,{value:a,onValueChange:i,"aria-label":e(`popup.settings.isolation`),fullWidth:!0,options:[{value:`off`,label:e(`popup.settings.isolationOff`)},{value:`window`,label:e(`popup.settings.isolationWindow`)},{value:`element`,label:e(`popup.settings.isolationElement`)}]})})}var Sa=V(`pgs-b5906754fa`);function Ca({user:e}){let t=j(),n=Ni(),r=W(`enabled`),i=vt(e.id),a=Et(),[o,s]=(0,H.useState)({name:`main`,back:!1});if((0,H.useEffect)(()=>{Ot(`surface_opened`)},[]),a===void 0)return/* @__PURE__ */ (0,U.jsx)(_n,{});let c=n.state===`ready`?wa(t,n.byId):null,l=i.status===`ready`?i.snapshot:null,u=i.status===`ready`?i.revision:0,d=()=>s({name:`settings`,back:!1}),f=()=>s({name:`feed`,back:!1}),p=()=>s({name:`main`,back:!0}),m=/* @__PURE__ */ (0,U.jsx)(In,{user:e,onOpenSettings:d,notificationCounts:l,onOpenNotifications:f}),h=r===!0&&l!==null?/* @__PURE__ */ (0,U.jsx)(Li,{windowId:a,waitingCount:l.waitingCount,revision:u,onOpenFeed:f}):null;switch(o.name){case`settings`:{let r=/* @__PURE__ */ (0,U.jsx)(ba,{tabId:t.tabId,project:n.state===`loading`?void 0:c,onBack:p});return c===null?r:/* @__PURE__ */ (0,U.jsx)(At,{user:e,project:{id:O(c.id),number:ie(c.number)},children:r})}case`feed`:return/* @__PURE__ */ (0,U.jsx)(Fi,{windowId:a,revision:u,back:o.back,onBack:p,onOpenSettings:d});case`main`:return/* @__PURE__ */ (0,U.jsx)(ji,{user:e,header:m,back:o.back,strip:h,snapshot:t,projects:n,tabProject:c})}}function wa(e,t){let{projectId:n}=e.state;if(n===null)return null;let r=t.get(n);return r===void 0?(Sa.warn(`pgm-cb1ec83f44`,{tabId:e.tabId}),null):r}function Ta(){return/* @__PURE__ */ (0,U.jsx)(D,{loading:/* @__PURE__ */ (0,U.jsx)(_n,{}),signedOut:/* @__PURE__ */ (0,U.jsx)(Mn,{}),children:e=>/* @__PURE__ */ (0,U.jsx)(wn,{user:e,children:/* @__PURE__ */ (0,U.jsx)(H.Suspense,{fallback:/* @__PURE__ */ (0,U.jsx)(_n,{}),children:/* @__PURE__ */ (0,U.jsx)(Ca,{user:e})})})})}var Ea=V(`pgs-2e3f74b175`),Da=document.getElementById(`popup-root`);Da===null?Ea.error(`pgm-f13077b9ed`):ot({surface:`popup`,root:Da,followedTab:yt(),editorNavigation:it(`popup`),render:()=>/* @__PURE__ */ (0,U.jsx)(Ta,{})}).catch(e=>{Ea.error(`pgm-f4cc990f36`,e)});
39
+ ;function mn({off:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`mr-auto flex items-center gap-2 text-body-md font-semibold tracking-(--tracking-brand) text-fg-primary`,children:[/* @__PURE__ */ (0,U.jsx)(Bt,{className:h(`size-5 [transition:filter_var(--motion-medium)_var(--ease-out),opacity_var(--motion-medium)_var(--ease-out)]`,e&&`opacity-50 grayscale`)}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:t(`popup.brand`)})]})}function hn({children:e}){return/* @__PURE__ */ (0,U.jsx)(`header`,{className:`flex h-12 flex-none items-center gap-1 border-b border-stroke-light bg-(--color-bg-window-header) pr-2 pl-3.5`,children:e})}function gn({children:e,className:t}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:h(`grid min-h-0 flex-1 grid-cols-1 content-start gap-4 overflow-y-auto px-3 pt-3 pb-4 [scrollbar-width:thin]`,t),children:e})}function _n(){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`popup-loading`,children:[/* @__PURE__ */ (0,U.jsxs)(hn,{children:[/* @__PURE__ */ (0,U.jsx)(mn,{off:!1}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`ml-2 size-7 rounded-md`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`ml-2 size-6 rounded-full`})]}),/* @__PURE__ */ (0,U.jsx)(gn,{children:/* @__PURE__ */ (0,U.jsx)(vn,{})})]})}function vn(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":e(`shell.loading`),className:`grid gap-2.5 rounded-lg border border-stroke bg-surface-card pt-3 pr-3 pb-3.5 pl-3.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`size-8.5 rounded-md`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid flex-1 gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-2.5 w-12`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3.5 w-[62%]`})]})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3 w-[60%]`})}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5 pl-1`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5.5 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5.5 w-20.5 rounded-full`})]})]}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-2`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-2.5 w-37.5`}),/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-21 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-27.5 rounded-full`})]})]})]})}function yn({value:e,options:t,onChange:n,ariaLabel:r,size:i,fullWidth:a,className:o}){return/* @__PURE__ */ (0,U.jsx)(m,{value:e,options:t,onValueChange:n,"aria-label":r,size:i,fullWidth:a,className:o})}var bn=V(`pgs-4d9951d24e`);function xn(e){let t=0,n=Promise.resolve(),r=null;async function i(n,i,a){if(n!==t)return;if(e.signedInUserId()!==a){bn.warn(`pgm-4b072233de`,{locale:i});return}let o=new AbortController;r=o;try{await e.save(i,o.signal)}catch(r){if(o.signal.aborted){bn.info(`pgm-7aaa461c83`,{locale:i});return}if(n===t){e.onFailure(i,r);return}bn.warn(`pgm-f93a88619e`,{locale:i,error:r})}finally{r=null}}return{write(e,r){t+=1;let a=t;n=n.then(()=>i(a,e,r)).catch(t=>{bn.error(`pgm-1491eca8c6`,{locale:e,error:t})})},discardPending(){t+=1,r==null||r.abort()}}}var Sn=V(`pgs-b78fd5fe0f`),Cn=(0,H.createContext)(null);function wn({user:e,children:t}){let{t:n}=F(),r=x(),[i]=(0,H.useState)(()=>Dn(e.id));return(0,H.useEffect)(()=>{i.setFailureReport((e,t)=>{Sn.error(`pgm-0f28f45227`,{locale:e,error:t instanceof Error?t.message:String(t)}),r.show({id:`popup-profile-language`,variant:`error`,message:n(`popup.language.profileSaveFailed`),action:{label:n(`common.retry`),onAction:()=>i.retryShownLocale()}})})}),(0,H.useEffect)(()=>(i.start(),()=>i.end()),[i]),/* @__PURE__ */ (0,U.jsx)(Cn,{value:i.profileLocale,children:t})}function Tn(){return(0,H.useContext)(Cn)}function En(){let e=(0,H.useContext)(Cn);if(e===null)throw Error(`useSignedInProfileLocale() is used outside the signed-in popup`);return e}function Dn(e){let t=!1,n=null,r=xn({save:async(e,t)=>{await L.preferences.update({locale:e},{signal:t})},signedInUserId:()=>t?e:null,onFailure:(e,t)=>{if(n===null)throw Error(`A profile language write failed before the popup was rendered`);n(e,t)}});return{profileLocale:{write:t=>r.write(t,e),discardPending:()=>r.discardPending()},setFailureReport:e=>{n=e},retryShownLocale:()=>{t&&r.write(Se(),e)},start:()=>{t=!0},end:()=>{t=!1,r.discardPending()}}}function On(e){let t=j(e);return(0,H.useSyncExternalStore)(t.subscribe,t.getState)}var kn=V(`pgs-520a54a8e3`);function W(e){let t=On(e);if(t.status===`failed`)throw t.error;return t.status===`ready`?t.value:void 0}function An(){let{t:e}=F(),t=x();return(0,H.useCallback)(function n(r){r.run().catch(i=>{kn.error(r.log.message,{...r.log.context,error:i instanceof Error?i.message:String(i)}),t.show({id:r.id,variant:`error`,message:r.message,detail:r.detail,action:{label:e(`common.retry`),onAction:()=>n(r)}})})},[e,t])}function G(){let{t:e}=F(),n=An();return(0,H.useCallback)((r,i)=>n({id:`setting-${r}`,run:()=>t(r,i),log:{message:`A setting was not stored`,context:{key:r}},message:e(`popup.settings.saveFailed`)}),[e,n])}function jn({size:e,fullWidth:t}){let{t:n}=F(),r=An(),i=Tn();return/* @__PURE__ */ (0,U.jsx)(yn,{value:Se(),options:ft.map(e=>({value:e,label:n(`common.languageNames.${e}`)})),onChange:e=>r({id:`popup-language`,run:async()=>{await we(e)!==`superseded`&&(i==null||i.write(e))},log:{message:`The language was not switched or not stored`,context:{locale:e}},message:n(`popup.settings.saveFailed`)}),ariaLabel:n(`popup.languageGroup`),size:e,fullWidth:t})}function Mn(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto`,children:/* @__PURE__ */ (0,U.jsx)(Ft,{subtitle:e(`shell.signIn.subtitlePopup`),footer:/* @__PURE__ */ (0,U.jsx)(jn,{size:`sm`})})})}var Nn=V(`pgs-d05703aaa3`);function Pn({user:e}){let{t}=F(),n=x(),[r,i]=(0,H.useState)(!1),a=En(),o=`${e.firstName} ${e.lastName}`;return/* @__PURE__ */ (0,U.jsxs)(re,{label:t(`popup.header.account`,{name:o}),align:`end`,className:`w-59`,trigger:/* @__PURE__ */ (0,U.jsx)(D,{"aria-label":t(`popup.header.account`,{name:o}),icon:/* @__PURE__ */ (0,U.jsx)(gt,{firstName:e.firstName,lastName:e.lastName,email:e.email,size:`sm`,unknownLabel:t(`popup.header.unknownUser`)}),"data-testid":`popup-account`}),children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid gap-px px-2.5 py-2`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`text-body-sm font-semibold text-fg-primary`,children:o}),/* @__PURE__ */ (0,U.jsxs)(`small`,{className:`text-xs text-fg-muted`,children:[e.email,` \u00B7 `,e.company.name]})]}),/* @__PURE__ */ (0,U.jsx)(d,{}),/* @__PURE__ */ (0,U.jsx)(Ve,{label:t(`popup.header.openWeb`),icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onSelect:()=>c()}),/* @__PURE__ */ (0,U.jsx)(d,{}),/* @__PURE__ */ (0,U.jsx)(Ve,{label:t(`popup.header.signOut`),icon:/* @__PURE__ */ (0,U.jsx)(un,{"aria-hidden":`true`}),tone:`danger`,disabled:r,onSelect:()=>{r||(i(!0),a.discardPending(),L.auth.logout().catch(e=>{Nn.error(`pgm-4db83b7ea3`,{error:e instanceof Error?e.message:String(e)}),n.show({id:`popup-sign-out`,variant:`error`,message:t(`popup.header.signOutFailed`)})}).finally(()=>i(!1)))},"data-testid":`popup-sign-out`})]})}function Fn({enabled:e}){let{t:n}=F(),r=An();return/* @__PURE__ */ (0,U.jsx)(I,{relationship:`description`,content:n(e?`popup.header.switchOn`:`popup.header.switchOff`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex`,children:/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":n(`popup.header.switchLabel`),checked:e,onChange:e=>r({id:`popup-power-switch`,run:()=>t(`enabled`,e),log:{message:`The extension switch was not stored`,context:{enabled:e}},message:n(`popup.header.switchFailed`),detail:n(`popup.header.switchFailedDetail`)}),className:`p-1.5`,"data-testid":`popup-power-switch`})})})}function In({user:e,onOpenSettings:t,notificationCounts:n,onOpenNotifications:r}){let{t:i}=F(),a=W(`enabled`);return/* @__PURE__ */ (0,U.jsxs)(hn,{children:[/* @__PURE__ */ (0,U.jsx)(mn,{off:a===!1}),a===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(Fn,{enabled:a}),/* @__PURE__ */ (0,U.jsx)(wt,{host:`popup`,t:i,counts:a===!1?null:n,onClick:r}),/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:i(`popup.header.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(bt,{"aria-hidden":`true`}),onClick:t,"data-testid":`popup-open-settings`})}),/* @__PURE__ */ (0,U.jsx)(Pn,{user:e})]})}var Ln=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:i,nativeButton:a=!0,disabled:o=!1,id:s,style:c,...u}=e,{state:d,disabled:p,setTouched:m,setFocused:h,validationMode:g,validation:_}=Me(),{labelId:v}=Je(),y=on(),b=y.useState(`selectionMode`),x=y.useState(`disabled`),S=y.useState(`readOnly`),C=y.useState(`required`),ee=y.useState(`positionerElement`),te=y.useState(`listElement`),w=y.useState(`popupId`),T=y.useState(`triggerProps`),E=y.useState(`inputInsidePopup`),D=y.useState(`id`),O=y.useState(`labelId`),k=y.useState(`open`),ne=y.useState(`selectedValue`),re=y.useState(`activeIndex`),A=y.useState(`selectedIndex`),ae=y.useState(`hasSelectedValue`),j=sn(),oe=Ht(),ce=rt(),M=p||x||o,le=$t(),ue=Xt(y);Oe({id:E?s:void 0});let de=E?s??D:s,fe=Be(v,O),pe;k&&E?pe=w??an(D):k&&(pe=te==null?void 0:te.id);let me=H.useRef(``);function he(e){me.current=e.pointerType}let{reference:ge}=Ne(j,{enabled:!k&&!S&&!x&&b===`single`,listRef:y.context.labelsRef,activeIndex:re,selectedIndex:A,onMatch(e){let t=y.context.valuesRef.current[e];t!==void 0&&y.context.setSelectedValue(t,Ae(ie))}}),{reference:_e}=f(j,{enabled:!x,event:`mousedown`}),{buttonRef:N,getButtonProps:ve}=Ie({native:a,disabled:M}),ye={...d,readOnly:S,open:k,disabled:M,popupSide:ue,listEmpty:le,placeholder:b!==`none`&&!ae},xe=ze(e=>{y.set(`triggerElement`,e)});return tt(`button`,e,{ref:[t,N,xe],state:ye,props:[T,_e,ge,{id:de,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":pe,"aria-required":E&&C||void 0,"aria-readonly":E&&S||void 0,"aria-labelledby":fe,onPointerDown:he,onPointerEnter:he,onFocus(){h(!0),!M&&ce.start(0,y.context.forceMount)},onBlur(e){if(!Te(ee,e.relatedTarget)&&(m(!0),h(!1),g===`onBlur`)){let e=b===`none`?oe:ne;_.commit(e)}},onMouseDown(e){if(M)return;if(E||j.set(`domReferenceElement`,e.currentTarget),y.context.forceMount(),me.current!==`touch`){var t;(t=y.context.inputRef.current)==null||t.focus(),E||e.preventDefault()}if(k)return;let n=Ye(e.currentTarget);function r(e){let t=y.state.triggerElement;if(!t)return;let n=se(e),r=y.state.positionerElement,i=y.state.listElement;Te(t,n)||Te(r,n)||Te(i,n)||be(e,t)||y.context.setOpen(!1,Ae(De,e))}E&&n.addEventListener(`mouseup`,r,{once:!0})},onKeyDown(e){if(e.key===`ArrowDown`||e.key===`ArrowUp`){var t;r(e),y.context.setOpen(!0,Ae(l,e.nativeEvent)),(t=y.context.inputRef.current)==null||t.focus()}}},_.getValidationProps(M,u),ve],stateAttributesMapping:qt})}),Rn=/*#__PURE__*/ H.createContext(void 0);function zn(){let e=H.useContext(Rn);if(e===void 0)throw Error(Ge(18));return e}var Bn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,items:a,...o}=e,s=on().useState(`grid`),[c,l]=H.useState(),u=H.useMemo(()=>({labelId:c,setLabelId:l,items:a}),[c,l,a]),d=tt(`div`,e,{ref:t,props:[{role:s?`rowgroup`:`group`,"aria-labelledby":c},o]}),f=/*#__PURE__*/ (0,U.jsx)(Rn.Provider,{value:u,children:d});return a?/*#__PURE__*/ (0,U.jsx)(rn,{items:a,children:f}):f}),Vn=/*#__PURE__*/ H.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,{setLabelId:s}=zn(),c=et(a);return We(()=>(s(c),()=>{s(e=>e===c?void 0:e)}),[c,s]),tt(`div`,e,{ref:t,props:[{id:c,"aria-hidden":!0},o]})}),Hn=/^[^\p{L}\p{N}]*(\p{L})/u;function Un(e){let t=e.trim().split(/\s+/).flatMap(e=>{var t;let n=(t=Hn.exec(e))==null?void 0:t[1];return n===void 0?[]:[n.toLocaleUpperCase()]}).slice(0,2).join(``);return t===``?null:t}var Wn=`grid shrink-0 place-items-center font-semibold tracking-(--tracking-snug) select-none`,Gn=`bg-(image:--btn-primary-fill) text-fg-on-accent`,Kn=`bg-(--color-bg-tertiary) text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,qn=`shadow-[var(--shadow-primary-inset),var(--shadow-tile-primary-glow)]`,Jn={22:`size-5.5 rounded-sm text-(length:--text-2xs) [&_svg]:size-3`,26:`size-6.5 rounded-md text-xs [&_svg]:size-3.5`,32:`size-8 rounded-md text-sm [&_svg]:size-4`,40:`size-10 rounded-lg text-base [&_svg]:size-4.5`},Yn=/* @__PURE__ */ new Set([26,32,40]);function Xn({name:e,size:t,drained:n=!1,className:r}){let i=e===null?null:Un(e),a=n?Kn:h(Gn,Yn.has(t)&&qn);return/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,"data-size":t,"data-drained":n||void 0,className:h(Wn,Jn[t],a,r),children:i??/* @__PURE__ */ (0,U.jsx)(Rt,{})})}var Zn=5,Qn=3,$n=`grid shrink-0 place-items-center rounded-md border border-solid border-[color-mix(in_srgb,var(--color-primary)_28%,transparent)] bg-(--color-bg-primary-tint-10) text-sm font-semibold tracking-(--tracking-snug) text-(--color-primary-text)`,er=`grid shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted [&_svg]:size-4`,tr=`group/trigger flex h-11.5 w-full min-w-0 cursor-pointer items-center gap-2.5 rounded-md border border-solid border-transparent bg-transparent pr-2 pl-1.25 text-left font-sans outline-none [transition:background-color_var(--motion-short)_var(--ease-out),border-color_var(--motion-short)_var(--ease-out)] hover:border-stroke hover:bg-surface-hover-layer focus-visible:border-stroke-focus focus-visible:ring-3 focus-visible:ring-focus-ring data-popup-open:border-stroke-focus data-popup-open:bg-surface-secondary`,nr=`group/trigger inline-flex h-9 min-w-0 shrink-0 cursor-pointer items-center gap-2 rounded-full border-0 bg-transparent pr-2.25 pl-1.25 font-sans text-body-sm font-semibold tracking-(--tracking-control) text-fg-primary [transition:background-color_var(--motion-short)_var(--ease-out)] hover:bg-surface-hover-layer data-popup-open:bg-surface-hover-layer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-stroke-focus`,rr={header:`min-w-0 max-w-45 truncate`,"header-narrow":`min-w-0 max-w-30 truncate`},ir=`grid size-6.5 shrink-0 place-items-center rounded-md border border-dashed border-stroke-hover bg-surface-hover-layer text-fg-muted`,ar=`grid grid-cols-[minmax(0,1fr)] gap-px overflow-y-auto overscroll-contain outline-none`,or={popup:`w-75`,list:`max-h-[min(--spacing(80),var(--available-height))]`,search:h(oe(`default`,!1,`page`,`sm`,`search`),`m-0.5 mb-1.5`),rowTile:null,row:`data-selected:bg-(--color-bg-primary-tint-10) [&>svg:last-child]:text-(--color-primary-text)`},sr={full:{popup:`w-(--anchor-width)`,list:`max-h-[min(--spacing(52),var(--available-height))]`,search:h(oe(`default`,!1,`page`,`popup-search`),`mb-1`),rowTile:`grid size-5.5 shrink-0 place-items-center rounded-sm bg-surface-hover-layer text-caption font-semibold text-fg-secondary`,row:``},header:or,"header-narrow":or,"header-tile":or};function cr({value:e,onValueChange:t,list:n,labels:r,variant:i=`full`,recent:o,footerActions:s,open:c,onOpenChange:l,autoFocus:u,"data-testid":d}){let f=b(),m=(0,H.useId)(),_=(0,H.useId)(),[y,x]=(0,H.useState)(``),[S,C]=(0,H.useState)(!1),ee=c??S,w=sr[i],T=n.state===`ready`?n.projects:null,E=(0,H.useMemo)(()=>T===null?/* @__PURE__ */ new Map:new Map(T.map(e=>[e.id,e])),[T]),D=(0,H.useMemo)(()=>{if(T===null||o===void 0||y.trim()!==``||T.length<=Zn)return null;let e=new Set(o.ids),t=T.filter(t=>e.has(t.id));return t.length===0?null:[{heading:o.heading,items:t},{heading:o.restHeading,items:T.filter(t=>!e.has(t.id))}]},[T,o,y]),O=T===null?[]:D??T,k=e=>{c===void 0&&C(e),l==null||l(e),e||x(``)},ne=e=>{let t=Un(e.name);return/* @__PURE__ */ (0,U.jsxs)(Jt,{value:e,className:h(g,w.row),children:[w.rowTile===null?/* @__PURE__ */ (0,U.jsx)(Xn,{name:e.name,size:22}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:w.rowTile,"aria-hidden":`true`,children:t??/* @__PURE__ */ (0,U.jsx)(Rt,{className:`size-3`})}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:h(p,`truncate`),children:e.name}),/* @__PURE__ */ (0,U.jsx)(Ke,{"aria-hidden":`true`,className:te})]},e.id)},re=n.state===`loading`?/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,"aria-label":r.loading,className:`grid gap-px`,children:Array.from({length:Qn},(e,t)=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-8 items-center gap-2.5 px-2.5 py-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`size-5.5 rounded-sm`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-3 w-[60%]`})]},t))}):n.state===`error`?/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`grid justify-items-center gap-2 pb-2`,children:[/* @__PURE__ */ (0,U.jsx)(`p`,{className:h(ce,`m-0 pb-0`),children:n.message}),/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,size:`sm`,onClick:n.onRetry,children:r.retry})]}):/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(en,{children:/* @__PURE__ */ (0,U.jsx)(`div`,{className:ce,children:r.empty})}),/* @__PURE__ */ (0,U.jsx)(Ut,{"aria-label":r.label,className:h(ar,w.list),children:D===null?ne:e=>/* @__PURE__ */ (0,U.jsxs)(Bn,{items:e.items,children:[/* @__PURE__ */ (0,U.jsx)(Vn,{className:dt,children:e.heading}),/* @__PURE__ */ (0,U.jsx)(Yt,{children:ne})]},e.heading)})]}),A=h(e===null?er:$n,`size-8.5`),ie=e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{className:ir,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(lr,{name:null})}):/* @__PURE__ */ (0,U.jsx)(Xn,{name:e.name,size:26}),ae=/* @__PURE__ */ (0,U.jsx)(nt,{"aria-hidden":`true`,className:h(`shrink-0 text-fg-muted [transition:transform_var(--motion-medium)_var(--ease-out)] group-data-popup-open/trigger:rotate-180`,i===`full`?`size-4`:`size-3.25`)}),j=i===`header-tile`?/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${m} ${_}`,className:nr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:m,className:`sr-only`,children:r.label}),ie,/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:`sr-only`,children:e===null?r.placeholder:e.name}),ae]}):i===`header`||i===`header-narrow`?/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${m} ${_}`,className:nr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{id:m,className:`sr-only`,children:r.label}),ie,e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:h(rr[i],`font-medium text-fg-secondary`),children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(M,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:rr[i],children:e.name})}),ae]}):/* @__PURE__ */ (0,U.jsxs)(Ln,{"data-testid":d,autoFocus:u,"aria-labelledby":`${m} ${_}`,className:tr,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:A,"aria-hidden":`true`,children:/* @__PURE__ */ (0,U.jsx)(lr,{name:(e==null?void 0:e.name)??null})}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`grid min-w-0 flex-1 leading-(--leading-picker)`,children:[/* @__PURE__ */ (0,U.jsx)(`small`,{id:m,className:`text-(length:--text-picker-label) text-fg-muted`,children:r.label}),e===null?/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:`truncate text-base font-medium tracking-(--tracking-snug) text-fg-secondary`,children:r.placeholder}):/* @__PURE__ */ (0,U.jsx)(M,{value:e.name,children:/* @__PURE__ */ (0,U.jsx)(`span`,{id:_,className:`truncate text-base font-semibold tracking-(--tracking-heading) text-fg-primary`,children:e.name})})]}),ae]});return/* @__PURE__ */ (0,U.jsxs)(Kt,{items:O,value:e,onValueChange:e=>{if(e===null)return;let n=E.get(e.id);if(n===void 0)throw Error(`ProjectPicker: chosen project ${e.id} is not in the list`);t(n)},itemToStringLabel:e=>e.name,isItemEqualToValue:(e,t)=>e.id===t.id,inputValue:y,onInputValueChange:x,open:ee,onOpenChange:k,autoHighlight:!0,children:[i===`header-tile`?/* @__PURE__ */ (0,U.jsx)(I,{relationship:`none`,content:e===null?r.placeholder:e.name,placement:`bottom`,children:j}):j,/* @__PURE__ */ (0,U.jsx)(tn,{container:f,children:/* @__PURE__ */ (0,U.jsx)(Qt,{side:`bottom`,align:`start`,sideOffset:i===`full`?4:8,collisionPadding:8,positionMethod:`fixed`,className:me,children:/* @__PURE__ */ (0,U.jsxs)(Vt,{"data-project-picker":``,"aria-label":r.placeholder,className:h(a,w.popup),children:[/* @__PURE__ */ (0,U.jsxs)(Wt,{className:w.search,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:Ce,children:/* @__PURE__ */ (0,U.jsx)(v,{"aria-hidden":`true`})}),/* @__PURE__ */ (0,U.jsx)(Gt,{placeholder:r.search,"aria-label":r.search,className:xe})]}),re,s!==void 0&&/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`div`,{className:`mx-(--menu-padding) my-1 h-px border-0 bg-stroke-light`,role:`separator`}),s.map(e=>/* @__PURE__ */ (0,U.jsxs)(`button`,{type:`button`,"data-testid":e.testId,className:h(`group/opt flex min-h-(--menu-row-height) w-full cursor-pointer select-none items-center gap-(--menu-row-gap) rounded-(--menu-row-radius) border-0 bg-transparent px-(--menu-row-padding-x) py-(--menu-row-padding-y) text-left font-sans text-[length:var(--text-body-sm)] leading-normal outline-hidden [transition:background-color_var(--motion-instant)_var(--ease-out)] data-disabled:cursor-not-allowed data-disabled:opacity-disabled [&_svg]:size-(--menu-icon-size) [&_svg]:shrink-0 text-fg-primary data-highlighted:bg-surface-elevated-hover active:bg-surface-elevated-active data-selected:font-medium`,`hover:bg-surface-elevated-hover focus-visible:bg-surface-elevated-hover`),onClick:()=>{k(!1),e.onSelect()},children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:`inline-flex shrink-0 text-fg-muted`,children:e.icon}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 flex-1`,children:e.label})]},e.label))]})]})})})]})}function lr({name:e}){let t=e===null?null:Un(e);return t===null?/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`,className:`size-4`}):/* @__PURE__ */ (0,U.jsx)(U.Fragment,{children:t})}var ur=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function dr({host:e,applicationName:t,environmentName:n,newApplication:r,newEnvironment:i,replaced:a,fresh:o}){let s=e=>e.trim()===``?`\u2026`:e.trim(),c={host:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e}),application:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(t)}),environment:/* @__PURE__ */ (0,U.jsx)(`span`,{children:s(n)}),old:/* @__PURE__ */ (0,U.jsx)(`span`,{children:a===null?``:a.address}),b:/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`})},l;l=a===null?r&&i?`popup.site.bindSay.both`:r?`popup.site.bindSay.newApplication`:i?`popup.site.bindSay.newEnvironment`:`popup.site.bindSay.free`:o===`taken`?`popup.site.bindSay.freshTaken`:o===`changed`?`popup.site.bindSay.freshChanged`:`popup.site.bindSay.replace`;let u=`${l}|${t}|${n}|${a===null?``:a.address}`;return a===null?/* @__PURE__ */ (0,U.jsx)(`p`,{"aria-live":`polite`,className:`m-0 min-w-0 text-(length:--text-compact) leading-normal text-fg-secondary text-pretty wrap-anywhere ${ur}`,"data-testid":`popup-bind-consequence`,children:/* @__PURE__ */ (0,U.jsx)(Ee,{i18nKey:l,components:c})},u):/* @__PURE__ */ (0,U.jsx)(`div`,{role:o===null?void 0:`alert`,"aria-live":o===null?`polite`:void 0,className:ur,"data-testid":`popup-bind-consequence`,"data-replace":`true`,children:/* @__PURE__ */ (0,U.jsx)(Fe,{tone:`warning`,title:/* @__PURE__ */ (0,U.jsx)(Ee,{i18nKey:l,components:c})})},u)}var fr={local:`dev`,dev:`dev`,staging:`staging`,prod:`production`},pr=/* @__PURE__ */ new WeakMap;function mr(e,t){return`${e}|${t}`}function hr(e){let t=pr.get(e);if(t!==void 0)return t;let n=new Map(e.map(e=>[mr(e.applicationId,e.environmentId),e]));return pr.set(e,n),n}function gr(e,t,n){let r=hr(e).get(mr(t,n));return r===void 0?null:r}function _r(e,t,n){return n===null||t.kind!==`existing`||n.kind!==`existing`?null:gr(e.cells,t.id,n.id)}function vr(e){return e.trim().toLowerCase()}function yr(e,t){let n=vr(t);if(n===``)return null;let r=e.find(e=>vr(e.name)===n);return r===void 0?null:r}function br(e,t,n){let r=e.environments.filter(n=>t===null||gr(e.cells,t,n.id)===null),i=r.find(e=>e.envType===n.type)??r.find(e=>e.isDefault)??r.at(0);return i===void 0?{choice:{kind:`new`,name:yr(e.environments,n.name)===null?n.name:``},allTaken:e.environments.length>0}:{choice:{kind:`existing`,id:i.id},allTaken:!1}}var xr=/* @__PURE__ */ new Set([`targets.cell_exists`,`targets.modified_concurrently`,`targets.host_conflict`,`targets.not_found`]);function Sr(e){return e instanceof He&&e.errorCode!==void 0?e.errorCode:null}function Cr(e){return e instanceof Error?e.message:String(e)}function wr(e,t,n){return{application:e.application.kind===`new`&&n.application===null?yr(t.applications,e.application.name):null,environment:e.environment!==null&&e.environment.kind===`new`&&n.environment===null?yr(t.environments,e.environment.name):null}}function Tr(e){let t=Sr(e);return t!==null&&xr.has(t)}function Er(e){return e.application!==null&&e.environment!==null?`both`:e.application===null?e.environment===null?null:`environment`:`application`}function Dr(e,t){let n=Er(e);return n===null?t:S.t(`popup.site.createdNotBound.${n}`,{application:e.application,environment:e.environment,reason:t})}function K(e,t){let n=Er(t);if(n===null)return Xe(S,e,`popup.site.bindFailed`);let r={application:t.application,environment:t.environment},i=S.t(`popup.site.bindPartial.${n}`,r),a=Xe(S,e,`popup.site.bindPartial.${n}`,r);return a===i?a:Dr(t,a)}function Or(e,t,n,r,i){let{defaultApplicationId:a,proposal:o}=i,s=e.application,c=s.kind===`existing`&&!t.applications.some(e=>e.id===s.id)?{kind:`existing`,id:a}:s;if(!t.applications.some(e=>e.id===a))throw Error(`The default application ${a} left the project`);let l={...e,lists:t,application:c},u=e.environment;if(u!==null&&u.kind===`existing`&&!t.environments.some(e=>e.id===u.id)){let e=br(t,c.kind===`existing`?c.id:null,o);l={...l,environment:e.choice,environmentAllTaken:e.allTaken,environmentChosen:!1}}let d=Sr(n),f=_r(t,l.application,l.environment);return d===`targets.cell_exists`?{...l,fresh:f===null?null:`taken`,failure:null}:d===`targets.modified_concurrently`?{...l,fresh:f===null?null:`changed`,failure:null}:d===`targets.host_conflict`?{...l,fresh:null,failure:kr(n,l,r,i.host)}:{...l,fresh:null,failure:K(n,r)}}function kr(e,t,n,r){var i;let a=e instanceof He&&typeof((i=e.params)==null?void 0:i.applicationId)==`string`?e.params.applicationId:null,o=t.lists.applications.find(e=>e.id===a),s=t.environment,c=s!==null&&s.kind===`existing`?t.lists.environments.find(e=>e.id===s.id):void 0;return o===void 0||c===void 0?K(e,n):Dr(n,S.t(`popup.site.hostConflict`,{host:r,application:o.name,environment:c.name}))}var q=V(`pgs-e9b150372c`);function Ar(e){let{defaultApplicationId:t,host:n,proposal:r,requests:i}=e,[a,o]=(0,H.useState)(()=>{let n=br(e.lists,t,r);return{lists:e.lists,application:{kind:`existing`,id:t},environment:n.choice,environmentChosen:!1,environmentAllTaken:n.allTaken,problem:null,failure:null,fresh:null,pending:!1,createUnsettled:!1,focus:null}}),s=(0,H.useRef)(!1),c=(0,H.useRef)(0),l=()=>(c.current+=1,c.current),u=(e,t)=>({target:e,field:t,seq:l()}),d=(e,t)=>{if(e.environmentChosen&&e.environment!==null)return{environment:e.environment,environmentAllTaken:e.environmentAllTaken};let n=br(e.lists,t.kind===`existing`?t.id:null,r);return{environment:n.choice,environmentAllTaken:n.allTaken}},f=(e,t)=>({...e,application:t,...d(e,t),problem:null,failure:null,fresh:null}),p=(e,t)=>({...e,environment:t,environmentChosen:!0,environmentAllTaken:!1,problem:null,failure:null,fresh:null}),m=(e,t)=>{s.current||o(n=>{if(e===`application`)return t===`new`?{...f(n,{kind:`new`,name:``}),focus:u(`input`,e)}:f(n,{kind:`existing`,id:t});if(t!==`new`)return p(n,{kind:`existing`,id:t});let i=yr(n.lists.environments,r.name)!==null;return{...p(n,{kind:`new`,name:i?``:r.name}),focus:u(`input`,e)}})},h=(e,t)=>{o(n=>{let r=e===`application`?n.application:n.environment;if(r===null||r.kind!==`new`)throw Error(`The ${e} field is not a new name, it cannot be renamed`);let i={kind:`new`,name:t};return{...n,...e===`application`?{application:i}:{environment:i},problem:n.problem!==null&&n.problem.field===e?null:n.problem}})},g=e=>{s.current||o(n=>{if(e===`application`)return{...f(n,{kind:`existing`,id:t}),focus:u(`trigger`,e)};if(n.lists.environments.length===0)throw Error(`A project without environments has no list to go back to`);let i=br(n.lists,n.application.kind===`existing`?n.application.id:null,r),a=i.choice.kind===`existing`?i.choice:null;return{...p(n,a),focus:u(`trigger`,e)}})},_=(e,t)=>{o(n=>({...e===`application`?f(n,{kind:`existing`,id:t}):p(n,{kind:`existing`,id:t}),focus:u(`trigger`,e)}))},v=async a=>{let s={application:null,environment:null},c=a;if(c.createUnsettled)try{c=b(c,await i.readLists(),s)}catch(e){q.error(`pgm-9a173522f2`,{error:Cr(e)}),o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:l()}}));return}let u=c.environment;if(u===null)throw Error(`The bind press ran with no environment chosen`);let d=null;try{let t;if(c.application.kind===`new`){d=`application`;let n=await i.createApplication(c.application.name.trim());d=null,s.application=n.name,t=n.id,o(e=>({...e,lists:{...e.lists,applications:[...e.lists.applications,n]},application:{kind:`existing`,id:n.id}})),e.onApplicationCreated()}else t=c.application.id;let n;if(u.kind===`new`){d=`environment`;let t=await i.createEnvironment(u.name.trim(),c.lists.environments.length===0);d=null,s.environment=t.name,n=t.id,o(e=>({...e,lists:{...e.lists,environments:[...e.lists.environments,t]},environment:{kind:`existing`,id:t.id},environmentAllTaken:!1})),e.onEnvironmentCreated()}else n=u.id;let r=_r(c.lists,c.application,u);r===null?await i.createCell(t,n):await i.replaceCell(r)}catch(e){if(q.error(`pgm-53ab6bb5fe`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null,status:e instanceof He?e.status:null,code:Sr(e),error:Cr(e)}),d!==null){await y(c,s,e);return}if(Tr(e))try{let a=await i.readLists();o(i=>({...Or(i,a,e,s,{defaultApplicationId:t,proposal:r,host:n}),focus:{target:`submit`,seq:l()}}));return}catch(e){q.error(`pgm-a2654be732`,{error:Cr(e)})}o(t=>({...t,failure:K(e,s),focus:{target:`submit`,seq:l()}}));return}q.info(`pgm-dfe3d492ed`,{createdApplication:s.application!==null,createdEnvironment:s.environment!==null}),await e.onBound()},y=async(e,t,n)=>{let r;try{r=await i.readLists()}catch(e){q.error(`pgm-200d50f185`,{error:Cr(e)}),o(e=>({...e,createUnsettled:!0,failure:K(n,t),focus:{target:`submit`,seq:l()}}));return}b(e,r,t),o(e=>({...e,failure:K(n,t),focus:{target:`submit`,seq:l()}}))},b=(t,n,r)=>{let i=wr(t,n,r);i.application!==null&&(r.application=i.application.name,e.onApplicationCreated()),i.environment!==null&&(r.environment=i.environment.name,e.onEnvironmentCreated()),(i.application!==null||i.environment!==null)&&q.info(`pgm-52181e7844`,{application:i.application!==null,environment:i.environment!==null});let a=e=>({...e,lists:n,createUnsettled:!1,...i.application===null?{}:{application:{kind:`existing`,id:i.application.id}},...i.environment===null?{}:{environment:{kind:`existing`,id:i.environment.id},environmentAllTaken:!1}});return o(a),a(t)};return{state:a,choose:m,rename:h,backToList:g,chooseExisting:_,submit:()=>{if(!s.current){if(a.environment===null){o(e=>({...e,problem:{field:`environment`,kind:`unchosen`},focus:u(`trigger`,`environment`)}));return}for(let e of[`application`,`environment`]){let t=e===`application`?a.application:a.environment;if(t.kind!==`new`)continue;if(t.name.trim()===``){o(t=>({...t,problem:{field:e,kind:`empty`},focus:u(`input`,e)}));return}let n=yr(e===`application`?a.lists.applications:a.lists.environments,t.name);if(n!==null){o(t=>({...t,problem:{field:e,kind:`duplicate`,id:n.id,name:n.name},focus:u(`input`,e)}));return}}s.current=!0,o(e=>({...e,pending:!0,failure:null,fresh:null,problem:null})),e.onPressStarted(),v(a).finally(()=>{s.current=!1,o(e=>({...e,pending:!1})),e.onPressEnded()})}}}}var jr=V(`pgs-e9b150372c`),Mr=`animate-[popup-bind-swap_var(--motion-medium)_var(--ease-out)_both] motion-reduce:animate-none`;function Nr(e){let{t}=F(),r=Ar(e),{state:i}=r,a=(0,H.useId)(),s=e=>`${a}-${e}`,c=(0,H.useRef)(null),l=(0,H.useRef)(null),u=(0,H.useRef)(null);(0,H.useEffect)(()=>{let e=i.focus;if(e===null)return;let t;if(t=e.target===`submit`?u.current:e.target===`input`?(e.field===`application`?c:l).current:document.getElementById(`${a}-${e.field}`),t===null){jr.warn(`pgm-9d57cb6e57`,{target:e.target});return}t.focus()},[i.focus,a]);let{lists:d,application:f,environment:p,pending:m,problem:h}=i,g=f.kind===`new`?f.name:Pr(d.applications,f.id),_=p===null?``:p.kind===`new`?p.name:Pr(d.environments,p.id),v=_r(d,f,p),y=e=>{if(h!==null&&h.field===e)return h.kind===`empty`?t(e===`application`?`popup.site.emptyApplication`:`popup.site.emptyEnvironment`):h.kind===`unchosen`?t(`popup.site.environmentRequired`):/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`min-w-0 wrap-anywhere`,children:[t(e===`application`?`popup.site.duplicateApplication`:`popup.site.duplicateEnvironment`,{name:h.name}),` `,/* @__PURE__ */ (0,U.jsx)(N,{variant:`link`,size:`xs`,onClick:()=>r.chooseExisting(e,h.id),"data-testid":`popup-bind-${e}-choose-existing`,children:t(`popup.site.chooseExisting`)})]})},b=(e,n,i)=>{let a=e===`application`||d.environments.length>0;return/* @__PURE__ */ (0,U.jsx)(Ze,{ref:e===`application`?c:l,id:s(e),size:`sm`,fieldClassName:`grid-cols-1`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),placeholder:t(e===`application`?`popup.site.newApplicationPlaceholder`:`popup.site.newEnvironmentPlaceholder`),autoComplete:`off`,value:n,onValueChange:t=>r.rename(e,t),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),r.submit()):t.key===`Escape`&&a&&(t.preventDefault(),r.backToList(e))},disabled:m,leading:/* @__PURE__ */ (0,U.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5 text-fg-link`}),trailing:a?/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:t(`popup.site.backToList`),placement:`top`,children:/* @__PURE__ */ (0,U.jsx)(D,{size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(o,{"aria-hidden":`true`}),onClick:()=>r.backToList(e),disabled:m,"data-testid":`popup-bind-${e}-back`})}):void 0,hint:i,error:y(e),className:Mr,"data-testid":`popup-bind-${e}-name`},`${e}-new`)},x=e=>({options:[{value:`new`,label:t(e===`application`?`popup.site.newApplication`:`popup.site.newEnvironment`),icon:/* @__PURE__ */ (0,U.jsx)(ve,{"aria-hidden":`true`,className:`text-fg-link`})}]}),S=f.kind===`new`?b(`application`,f.name,void 0):/* @__PURE__ */ (0,U.jsx)(Qe,{id:s(`application`),size:`sm`,fieldClassName:`grid-cols-1`,label:t(`popup.site.applicationLabel`),value:f.id,onValueChange:e=>r.choose(`application`,e),disabled:m,groups:[{options:d.applications.map(e=>({value:e.id,label:e.name}))},x(`application`)],"data-testid":`popup-bind-application`},`application-list`),C;d.environments.length===0?C=t(`popup.site.noEnvironmentsHint`):i.environmentAllTaken&&(C=/* @__PURE__ */ (0,U.jsx)(`span`,{className:`wrap-anywhere`,children:t(`popup.site.allTakenHint`,{application:g.trim()===``?`\u2026`:g.trim()})}));let ee=p!==null&&p.kind===`new`?b(`environment`,p.name,C):/* @__PURE__ */ (0,U.jsx)(Qe,{id:s(`environment`),size:`sm`,fieldClassName:`grid-cols-1`,label:t(`popup.site.environmentLabel`),value:p===null?null:p.id,placeholder:t(`popup.site.environmentPlaceholder`),error:y(`environment`),onValueChange:e=>r.choose(`environment`,e),disabled:m,groups:[{options:d.environments.map(e=>{let n=f.kind===`existing`?gr(d.cells,f.id,e.id):null;return n===null?{value:e.id,label:e.name}:{value:e.id,label:e.name,description:t(`popup.site.taken`,{address:n.address})}})},x(`environment`)],"data-testid":`popup-bind-environment`},`environment-list`);return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`group`,"aria-label":t(`popup.site.bind`),"aria-busy":m,className:`grid min-w-0 grid-cols-1 gap-2.5 rounded-md border border-stroke-light bg-surface-modal-inset px-3 pt-2.5 pb-3`,"data-testid":`popup-bind-form`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2.5`,children:[S,ee]}),h===null&&p!==null&&/* @__PURE__ */ (0,U.jsx)(dr,{host:e.host,applicationName:g,environmentName:_,newApplication:f.kind===`new`,newEnvironment:p.kind===`new`,replaced:v,fresh:i.fresh}),i.failure!==null&&/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-1.5 text-(length:--text-compact) leading-(--leading-caption) text-fg-error`,"data-testid":`popup-bind-failure`,children:[/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:`min-w-0 wrap-anywhere`,children:i.failure})]}),/* @__PURE__ */ (0,U.jsx)(N,{ref:u,size:`sm`,icon:v===null?/* @__PURE__ */ (0,U.jsx)(w,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(cn,{"aria-hidden":`true`}),loading:m,onClick:r.submit,className:`justify-self-end`,"data-testid":`popup-bind-submit`,children:t(v===null?`popup.site.bind`:`popup.site.replace`)})]})}function Pr(e,t){let n=e.find(e=>e.id===t);if(n===void 0)throw Error(`The bind form chose ${t}, absent from its list`);return n.name}function J({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{"aria-live":`polite`,className:`grid grid-cols-1 gap-2 border-t border-stroke-light py-2.5 pr-3 pl-3.5 animate-ui-fade-in motion-reduce:animate-none`,"data-testid":`popup-site`,children:e})}function Y({host:e}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-body-sm text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(C,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-fg-muted`}),/* @__PURE__ */ (0,U.jsx)(`b`,{className:`min-w-0 truncate font-medium text-fg-primary`,children:e})]})}var Fr=`inline-flex h-6 items-center rounded-full border border-stroke bg-surface-hover-layer text-xs text-fg-primary`;function Ir({applicationName:e,environmentName:t}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{"aria-label":n(`popup.site.cellLabel`),className:`flex flex-wrap items-center gap-1.5`,"data-testid":`popup-site-cell`,children:[/* @__PURE__ */ (0,U.jsx)(`span`,{className:h(Fr,`px-2.25 font-medium`),children:e}),/* @__PURE__ */ (0,U.jsx)(`span`,{"aria-hidden":`true`,className:`text-xs text-fg-muted`,children:`\u00D7`}),/* @__PURE__ */ (0,U.jsx)(`span`,{className:h(Fr,`px-2.5 font-semibold animate-[popup-environment-in_var(--motion-long)_var(--ease-out)_both]`),children:t})]})}function Lr({children:e,hintName:t,hint:n,tone:r=`default`,icon:i}){return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:h(`flex min-w-0 items-center gap-1.5 [&>svg]:size-3.5 [&>svg]:shrink-0`,r===`warning`&&`text-fg-warning`),children:[i,/* @__PURE__ */ (0,U.jsx)(`p`,{className:h(`m-0 min-w-0 text-(length:--text-compact) leading-normal [&_b]:font-semibold [&_b]:text-fg-primary`,r===`warning`?`text-inherit`:r===`muted`?`text-fg-muted`:`text-fg-secondary`),children:e}),/* @__PURE__ */ (0,U.jsx)(B,{name:t,text:n,placement:`bottom-start`})]})}var Rr=V(`pgs-f048f86b7e`);function zr({projectId:e,host:t,environments:n,chosenId:r,onChosen:i}){let{t:a}=F(),o=x(),[s,c]=(0,H.useState)(!1);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Lr,{hintName:a(`popup.site.more`,{about:a(`popup.site.environmentChoice`)}),hint:a(`popup.site.environmentChoiceHint`),children:a(`popup.site.environmentChoice`)}),/* @__PURE__ */ (0,U.jsx)(Qe,{size:`sm`,"aria-label":a(`popup.site.environmentLabel`),placeholder:a(`popup.site.environmentPlaceholder`),value:r,onValueChange:t=>{s||(c(!0),L.environments.setActive(O(e),`extension`,t).then(()=>{Rr.info(`pgm-f54cd7418d`,{projectId:e}),i()}).catch(t=>{Rr.error(`pgm-effdde2b56`,{projectId:e,error:t instanceof Error?t.message:String(t)}),o.show({id:`popup-environment-choice`,variant:`error`,message:a(`popup.site.environmentFailed`)})}).finally(()=>c(!1)))},disabled:s,options:n.map(e=>({value:e.id,label:e.name,description:t})),"data-testid":`popup-site-environment`})]})}function Br(e){let t=e.toLowerCase();return/(^|\/\/|\.)dev\./.test(t)?`dev`:/stag/.test(t)?`staging`:/localhost|127\.0/.test(t)?`local`:`prod`}function Vr(e){let t=e.toLowerCase();return/prod/.test(t)?`production`:/stag/.test(t)?`staging`:/dev|local|\u043B\u043E\u043A\u0430\u043B/.test(t)?`dev`:`custom`}function Hr(e){let t=Br(e);return{key:`popup.site.environmentSuggestion.${t}`,type:fr[t]}}function Ur(e){return{targetId:e.id,applicationId:e.applicationId,environmentId:e.environmentId,baseUrl:e.baseUrl,hostPattern:e.hostPattern}}function Wr(e,t,n){let{targets:r,applications:i,environments:a}=t,o=r.find(e=>e.baseUrl===null&&e.hostPattern===null);if(o!==void 0)return{kind:`inconsistent`,reason:`Cell ${o.id} has neither an origin nor a host pattern`};let s=mt(n.href,r.map(Ur),null);switch(s.kind){case`matched`:{let t=Kr(i,s.applicationId),n=Kr(a,s.environmentId);return t===null||n===null?qr(e,t===null?s.applicationId:s.environmentId):{kind:`matched`,applicationName:t,environmentName:n}}case`ambiguous_application`:{let t=Kr(a,s.environmentId);return t===null?qr(e,s.environmentId):{kind:`ambiguous`,environmentName:t}}case`environment_choice`:{let t=s.environmentIds.find(e=>!a.some(t=>t.id===e));return t===void 0?{kind:`environmentChoice`,environments:a.filter(e=>s.environmentIds.includes(e.id)).map(e=>({id:e.id,name:e.name}))}:qr(e,t)}case`unknown_host`:case`no_targets`:{let n=i.find(e=>e.isDefault);return n===void 0?{kind:`inconsistent`,reason:`Project ${e} has no default application`}:{kind:`bind`,reason:s.kind,lists:Xr(t),defaultApplicationId:n.id}}case`unsupported_url`:return{kind:`unsupported`}}}function Gr(e,t){if(e.source!==`user_preference`||e.environmentId===null)return null;let n=e.environmentId;return t.some(e=>e.id===n)?n:null}function Kr(e,t){let n=e.find(e=>e.id===t);return n===void 0?null:n.name}function qr(e,t){return{kind:`inconsistent`,reason:`A cell of project ${e} names ${t}, absent from the lists read`}}async function Jr(e,t){let n=O(t),[r,i,a]=await Promise.all([e.targets.listAll(n),e.applications.byProject(n),e.environments.list(n)]);return{targets:r,applications:i,environments:a}}async function Yr(e,t){return Xr(await Jr(e,t))}function Xr(e){return{applications:e.applications.map(Zr),environments:e.environments.map(Qr),cells:e.targets.map($r)}}function Zr(e){return{id:e.id,name:e.name}}function Qr(e){return{id:e.id,name:e.name,envType:e.envType,isDefault:e.isDefault}}function $r(e){let t;if(e.baseUrl!==null)t=new URL(e.baseUrl).host;else if(e.hostPattern!==null)t=e.hostPattern;else throw Error(`Cell ${e.id} has neither an origin nor a host pattern`);return{id:e.id,applicationId:e.applicationId,environmentId:e.environmentId,address:t,hostPattern:e.hostPattern,updatedAt:e.updatedAt}}async function ei(e,t,n){return Zr(await e.applications.create({projectId:O(t),name:n}))}async function ti(e,t,n,r){return Qr(await e.environments.create({projectId:O(t),name:n,envType:Vr(n),isDefault:r}))}async function ni(e,t,n,r,i){await e.targets.create(O(t),{applicationId:ne(r),environmentId:i,baseUrl:n})}async function ri(e,t,n,r){let i=r.hostPattern!==null&&ht(n,[{targetId:r.id,applicationId:r.applicationId,environmentId:r.environmentId,baseUrl:null,hostPattern:r.hostPattern}]).length>0;await e.targets.update(O(t),r.id,{baseUrl:n,...r.hostPattern===null||i?{}:{hostPattern:null},expectedUpdatedAt:r.updatedAt})}var ii=V(`pgs-c1e3b0bb6f`);function ai({page:e,projects:t,onSelect:n}){let{t:r}=F(),a=ct(),{data:o,error:s}=A({key:i(a,`target-matches`,e.href),read:()=>L.targets.match(e.href),freshness:`screen`});if((0,H.useEffect)(()=>{s!==null&&ii.error(`pgm-f294aabbd9`,{error:s.message})},[s]),s!==null||o===void 0)return null;let c=new Set(o.items.map(e=>e.projectId)),l=t.filter(e=>c.has(e.id));return l.length===0?null:/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:e.host}),l.map(e=>/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-surface-hover-layer py-2 pr-2 pl-2.5`,children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{className:`m-0 min-w-0 flex-1 truncate text-(length:--text-compact) leading-(--leading-caption) text-fg-secondary`,children:[r(`popup.site.suggestion`),` `,/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:r(`popup.site.suggestionProject`,{project:e.name})})]}),/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,size:`sm`,onClick:()=>n(e),"data-testid":`popup-site-suggestion`,children:r(`popup.site.select`)})]},e.id))]})}var oi=V(`pgs-94aad7e91e`),si={phase:`none`};function ci(e,t){let n=u(),[r,i]=(0,H.useState)(si),a=(0,H.useRef)({applications:null,environments:null}),o=(0,H.useMemo)(()=>({kind:`project`,projectId:e}),[e]),s=Ue({projectId:e}),c=je({projectId:e}),l=lt({projectId:e}),d=t.href,f=(0,H.useMemo)(()=>s.data===void 0||c.data===void 0||l.data===void 0?null:Wr(e,{targets:s.data,applications:c.data,environments:l.data},new URL(d)),[e,s.data,c.data,l.data,d]),p=ut({projectId:e,client:`extension`},{enabled:f!==null&&f.kind===`environmentChoice`}),m=f!==null&&f.kind===`inconsistent`?f.reason:null;(0,H.useEffect)(()=>{m!==null&&oi.error(`pgm-0efc4cf256`,{projectId:e,reason:m})},[m,e]);let h=[s,c,l],g=e=>()=>{for(let t of e)t.reload()},_,v=h.filter(li);if(v.length>0)_={status:`failed`,retry:g(v)};else if(f===null)_={status:`loading`};else if(f.kind===`inconsistent`)_={status:`failed`,retry:g(h)};else if(f.kind===`environmentChoice`){if(li(p))_={status:`failed`,retry:g([p])};else if(p.data===void 0)_={status:`loading`};else{let e=Gr(p.data,f.environments);_={status:`ready`,screen:{...f,chosenId:e}}}}else _={status:`ready`,screen:f};r.phase===`outcome`&&_.status!==`failed`&&i(si);let y=_;return(r.phase===`press`||r.phase===`outcome`&&_.status===`failed`)&&(y={status:`binding`,screen:r.screen,retry:_.status===`failed`?_.retry:null}),{state:y,bindStarted:()=>{let e;if(y.status===`binding`)e=y.screen;else if(y.status===`ready`&&y.screen.kind===`bind`)e=y.screen;else throw Error(`A bind press started while the site strip is ${y.status}`);a.current={applications:null,environments:null},i({phase:`press`,screen:e})},bindEnded:()=>{i(e=>e.phase===`press`?{phase:`outcome`,screen:e.screen}:e)},afterApplicationCreated:()=>{a.current.applications=n.invalidateAfterChange(Le(o))},afterEnvironmentCreated:()=>{a.current.environments=n.invalidateAfterChange(ot(o))},afterBind:async()=>{let e=a.current;a.current={applications:null,environments:null};let t=(e,t)=>e===null?n.invalidateAfterChange(t):e;await Promise.all([t(e.applications,Le(o)),t(e.environments,ot(o))]),await n.invalidateAfterChange(ke(o)),i(si)},afterEnvironmentChosen:()=>{n.invalidateAfterChange(Re(o))}}}function li(e){return e.error!==null||e.refreshError!==null}var ui=V(`pgs-3b85b4fc58`);function di({tabId:e,project:t,projects:n,onSelectProject:r}){let i=fi(e);if(i.status!==`read`)return null;let a=i.url,o=a===null?null:E(a),s=o!==null&&o.ok?o.url:null;return t===null?s===null?null:/* @__PURE__ */ (0,U.jsx)(ai,{page:s,projects:n,onSelect:r}):s===null?/* @__PURE__ */ (0,U.jsx)(pi,{}):/* @__PURE__ */ (0,U.jsx)(mi,{project:t,page:s})}function fi(e){let[t,n]=(0,H.useState)(null);return(0,H.useEffect)(()=>{let t=!0;return chrome.tabs.get(e).then(r=>{t&&n({tabId:e,result:{status:`read`,url:r.url??null}})},r=>{ui.error(`pgm-df207305cf`,{tabId:e,error:r instanceof Error?r.message:String(r)}),t&&n({tabId:e,result:{status:`failed`}})}),()=>{t=!1}},[e]),t===null||t.tabId!==e?{status:`reading`}:t.result}function pi(){let{t:e}=F();return/* @__PURE__ */ (0,U.jsx)(J,{children:/* @__PURE__ */ (0,U.jsx)(Lr,{tone:`muted`,hintName:e(`popup.site.more`,{about:e(`popup.site.notSite`)}),hint:e(`popup.site.notSiteHint`),children:e(`popup.site.notSite`)})})}function mi({project:e,page:t}){let{t:n}=F(),r=ci(O(e.id),t),{state:i}=r,a={createApplication:t=>ei(L,e.id,t),createEnvironment:(t,n)=>ti(L,e.id,t,n),createCell:(n,r)=>ni(L,e.id,t.origin,n,r),replaceCell:n=>ri(L,e.id,t.origin,n),readLists:()=>Yr(L,e.id)},o=async()=>{try{let t=await R.call(`REFRESH_PROJECT_TARGETS`,{projectId:e.id});t.success||ui.error(`pgm-ef389a0081`,{projectId:e.id,error:t.error})}catch(t){ui.error(`pgm-fc30de5d00`,{projectId:e.id,error:t instanceof Error?t.message:String(t)})}await r.afterBind()};if(i.status===`failed`)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(gi,{retry:i.retry})]});if(i.status===`loading`)return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,"aria-label":n(`popup.site.reading`),className:`flex items-center gap-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(P,{className:`h-6 w-18.5 rounded-full`}),/* @__PURE__ */ (0,U.jsx)(P,{className:`h-6 w-20.5 rounded-full`})]})]});let s=(n,i)=>/* @__PURE__ */ (0,U.jsx)(hi,{project:e,page:t,screen:n,retry:i,requests:a,site:r,onBound:o});if(i.status===`binding`)return s(i.screen,i.retry);let c=i.screen;switch(c.kind){case`unsupported`:return/* @__PURE__ */ (0,U.jsx)(pi,{});case`matched`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Ir,{applicationName:c.applicationName,environmentName:c.environmentName})]});case`ambiguous`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(Lr,{tone:`warning`,icon:/* @__PURE__ */ (0,U.jsx)(ge,{"aria-hidden":`true`}),hintName:n(`popup.site.more`,{about:n(`popup.site.ambiguous`,{environment:c.environmentName})}),hint:n(`popup.site.ambiguousHint`),children:n(`popup.site.ambiguous`,{environment:c.environmentName})})]});case`environmentChoice`:return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),/* @__PURE__ */ (0,U.jsx)(zr,{projectId:e.id,host:t.host,environments:c.environments,chosenId:c.chosenId,onChosen:r.afterEnvironmentChosen})]});case`bind`:return s(c,null)}}function hi({project:e,page:t,screen:n,retry:r,requests:i,site:a,onBound:o}){let{t:s}=F(),c=Hr(t.host);return/* @__PURE__ */ (0,U.jsxs)(J,{children:[/* @__PURE__ */ (0,U.jsx)(Y,{host:t.host}),r!==null&&/* @__PURE__ */ (0,U.jsx)(gi,{retry:r}),/* @__PURE__ */ (0,U.jsx)(Lr,{hintName:s(`popup.site.bindMore`),hint:s(`popup.site.bindInfo`),children:/* @__PURE__ */ (0,U.jsx)(Ee,{i18nKey:n.reason===`no_targets`?`popup.site.noTargets`:`popup.site.notBound`,components:{b:/* @__PURE__ */ (0,U.jsx)(`b`,{}),project:/* @__PURE__ */ (0,U.jsx)(`span`,{children:e.name})}})}),/* @__PURE__ */ (0,U.jsx)(Nr,{lists:n.lists,defaultApplicationId:n.defaultApplicationId,host:t.host,proposal:{name:s(c.key),type:c.type},requests:i,onPressStarted:a.bindStarted,onPressEnded:a.bindEnded,onApplicationCreated:a.afterApplicationCreated,onEnvironmentCreated:a.afterEnvironmentCreated,onBound:o})]})}function gi({retry:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsxs)(`p`,{role:`alert`,className:`m-0 flex gap-1.5 text-(length:--text-compact) leading-normal text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:t(`popup.site.readFailed`)})]}),/* @__PURE__ */ (0,U.jsx)(`div`,{children:/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,size:`sm`,icon:/* @__PURE__ */ (0,U.jsx)(fe,{"aria-hidden":`true`}),onClick:e,"data-testid":`popup-site-retry`,children:t(`common.retry`)})})]})}var _i=V(`pgs-930365a583`),vi=`all`;function yi({tabId:e,applications:t,applicationId:n}){let{t:r}=F(),i=x();return/* @__PURE__ */ (0,U.jsx)(Qe,{appearance:`inline`,label:r(`popup.application.label`),value:n===null?vi:n,onValueChange:t=>{let n=t===vi?null:t;R.call(`SET_TAB_STATE`,{tabId:e,state:{applicationId:n}}).then(e=>{if(!e.success)throw Error(`SET_TAB_STATE refused: ${e.error}`)}).catch(t=>{_i.error(`pgm-e58825e7fe`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-application`,variant:`error`,message:r(`popup.application.switchFailed`)})})},options:[{value:vi,label:r(`popup.application.all`)},...t.map(e=>({value:e.id,label:e.name}))],"data-testid":`popup-application`})}function bi({run:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2.5 rounded-b-lg border-t border-stroke-light bg-[color-mix(in_srgb,var(--color-info)_8%,transparent)] py-2.25 pr-3 pl-3.5 text-(length:--text-compact) leading-snug`,"data-testid":`popup-run-line`,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:`size-2 flex-none rounded-full bg-info shadow-(--glow-status-info) animate-pulse-dot`}),/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`text-fg-secondary`,children:[/* @__PURE__ */ (0,U.jsx)(`b`,{className:`font-semibold text-fg-primary`,children:e.kind===`free`?t(`popup.run.free`,{number:e.number}):t(`popup.run.plan`,{plan:e.planName})}),` `,t(`popup.run.where`)]})]})}var xi=V(`pgs-c184079221`);function Si({tabId:e,projects:t,tabProject:n,applicationId:r,run:i,onPick:a,pickerOpen:o,onPickerOpenChange:s}){let{t:c}=F();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":c(`popup.project.contextLabel`),className:`relative rounded-lg border border-(--color-border-overlay) bg-surface-card shadow-(--shadow-context-card)`,"data-testid":`popup-context`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`relative grid p-2`,children:[/* @__PURE__ */ (0,U.jsx)(cr,{value:n===null?null:{id:n.id,name:n.name},onValueChange:a,list:{state:`ready`,projects:t},labels:{label:c(`popup.project.label`),placeholder:c(`popup.project.placeholder`),search:c(`popup.project.search`),empty:c(`popup.project.empty`),loading:c(`popup.project.loading`),retry:c(`common.retry`)},open:o,onOpenChange:s,autoFocus:!0,"data-testid":`popup-project`}),n!==null&&/* @__PURE__ */ (0,U.jsx)(Ci,{tabId:e,projectId:O(n.id),applicationId:r},n.id)]}),/* @__PURE__ */ (0,U.jsx)(di,{tabId:e,project:n,projects:t,onSelectProject:a},`${e}:${n===null?``:n.id}`),i!==null&&/* @__PURE__ */ (0,U.jsx)(bi,{run:i})]})}function Ci({tabId:e,projectId:t,applicationId:n}){let{data:r,error:i}=je({projectId:t});return(0,H.useEffect)(()=>{i!==null&&xi.error(`pgm-f42292fd59`,{error:i.message})},[i]),i!==null||r===void 0||r.length<=1?null:/* @__PURE__ */ (0,U.jsx)(yi,{tabId:e,applications:r,applicationId:n})}var wi=[{key:`bugs`,tone:`error`},{key:`checklists`,tone:`primary`},...qe.incidentsEnabled?[{key:`incidents`,tone:`warning`}]:[]],Ti={bugs:`popup.filters.bugs`,checklists:`popup.filters.checklists`,incidents:`popup.filters.incidents`};function Ei(){let{t:e}=F(),t=W(`filters`),n=G();return/* @__PURE__ */ (0,U.jsxs)(`section`,{"aria-label":e(`popup.filters.title`),className:`grid gap-2`,"data-testid":`popup-filters`,children:[/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`mx-0.5 my-0 text-xs font-medium text-fg-muted`,children:e(`popup.filters.title`)}),/* @__PURE__ */ (0,U.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:t===void 0?wi.map(e=>/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-24 rounded-full`},e.key)):wi.map(r=>/* @__PURE__ */ (0,U.jsx)(Zt,{pressed:t[r.key],tone:r.tone,size:`md`,onClick:()=>n(`filters`,{...t,[r.key]:!t[r.key]}),"data-testid":`popup-filter-${r.key}`,children:e(Ti[r.key])},r.key))})]})}function Di(){let{t:e}=F(),t=G();return/* @__PURE__ */ (0,U.jsx)(`div`,{role:`status`,children:/* @__PURE__ */ (0,U.jsx)(Fe,{tone:`info`,icon:/* @__PURE__ */ (0,U.jsx)(fn,{"aria-hidden":`true`}),title:e(`popup.paused.title`),actionsPlacement:`below`,actions:/* @__PURE__ */ (0,U.jsx)(it,{onClick:()=>t(`enabled`,!0),children:e(`popup.paused.enable`)}),"data-testid":`popup-paused`})})}function Oi({projectSwitch:e,currentProjectName:t}){let{t:n}=F(),{question:r,busy:i,confirm:a,cancel:s}=e;if(r===null)return null;let{run:c,target:l}=r,u=c.kind===`free`,d=c.kind===`free`?n(`popup.switchRun.freeText`,{number:c.number,project:l.name}):t===null?n(`popup.switchRun.planTextNoProject`,{plan:c.planName}):n(`popup.switchRun.planText`,{plan:c.planName,project:t});return/* @__PURE__ */ (0,U.jsx)(le,{open:!0,busy:i,onCancel:s,tone:u?`danger`:`warning`,icon:u?/* @__PURE__ */ (0,U.jsx)(o,{"aria-hidden":`true`}):/* @__PURE__ */ (0,U.jsx)(ln,{"aria-hidden":`true`}),title:n(u?`popup.switchRun.freeTitle`:`popup.switchRun.planTitle`),description:d,"data-testid":`popup-project-switch-question`,actions:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(N,{variant:`secondary`,onClick:s,children:n(`popup.switchRun.stay`)}),/* @__PURE__ */ (0,U.jsx)(N,{variant:u?`danger`:`primary`,loading:i,onClick:a,"data-testid":`popup-project-switch-confirm`,children:n(u?`popup.switchRun.freeConfirm`:`popup.switchRun.planConfirm`)})]})})}var ki=V(`pgs-ab0307fe13`);function Ai({tabId:e,projectId:t,currentTestRun:n}){let{t:r}=F(),i=x(),[a,o]=(0,H.useState)(null),[s,c]=(0,H.useState)(!1),l=async t=>{let n=await R.call(`RESTORE_PROJECT`,{tabId:e,projectId:t.id,projectNumber:t.number,applicationId:null});if(!n.success)throw Error(`RESTORE_PROJECT refused: ${n.error}`);ki.info(`pgm-496ade1c1d`,{tabId:e})},u=t=>{ki.error(`pgm-61ab57a774`,{tabId:e,error:t instanceof Error?t.message:String(t)}),i.show({id:`popup-project-switch`,variant:`error`,message:r(`popup.project.switchFailed`)})};return{question:a,busy:s,choose(e){if(e.id!==t){if(n!==null){o({target:e,run:n});return}l(e).catch(u)}},confirm(){a===null||s||(c(!0),l(a.target).catch(u).finally(()=>{c(!1),o(null)}))},cancel(){s||o(null)}}}function ji({user:e,header:t,back:n,strip:r,snapshot:i,projects:a,tabProject:o}){let{t:s}=F(),l=W(`enabled`),[u,d]=(0,H.useState)(!1),{state:f,tabId:p}=i,m=Ai({tabId:p,projectId:f.projectId,currentTestRun:f.currentTestRun}),g;switch(a.state){case`loading`:g=/* @__PURE__ */ (0,U.jsx)(vn,{});break;case`error`:g=/* @__PURE__ */ (0,U.jsx)(Mi,{children:/* @__PURE__ */ (0,U.jsx)(ae,{icon:/* @__PURE__ */ (0,U.jsx)(jt,{"aria-hidden":`true`}),title:s(`popup.projects.failedTitle`),description:s(`popup.projects.failedText`),retry:{label:s(`common.retry`),onRetry:a.retry}})});break;case`ready`:{if(a.projects.length===0){g=/* @__PURE__ */ (0,U.jsx)(Mi,{children:/* @__PURE__ */ (0,U.jsx)(pe,{icon:/* @__PURE__ */ (0,U.jsx)(Rt,{"aria-hidden":`true`}),title:s(`popup.projects.emptyTitle`),description:s(`popup.projects.emptyText`),action:/* @__PURE__ */ (0,U.jsx)(N,{icon:/* @__PURE__ */ (0,U.jsx)(It,{"aria-hidden":`true`}),onClick:()=>c(),children:s(`popup.projects.openWeb`)})})});break}let t=/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(Si,{tabId:p,projects:a.projects,tabProject:o,applicationId:f.applicationId,run:f.currentTestRun,onPick:m.choose,pickerOpen:u,onPickerOpenChange:d}),/* @__PURE__ */ (0,U.jsx)(Ei,{})]});g=o===null?t:/* @__PURE__ */ (0,U.jsx)(At,{user:e,project:{id:O(o.id),number:ue(o.number)},children:t});break}}let _=a.state===`ready`&&a.projects.length>0;return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:h(`flex min-h-0 flex-1 flex-col`,n?Dt:Ct),children:[t,/* @__PURE__ */ (0,U.jsxs)(gn,{className:_&&u?`min-h-90`:void 0,children:[_&&l===!1&&/* @__PURE__ */ (0,U.jsx)(Di,{}),r,g]}),/* @__PURE__ */ (0,U.jsx)(Oi,{projectSwitch:m,currentProjectName:o===null?null:o.name})]})}function Mi({children:e}){return/* @__PURE__ */ (0,U.jsx)(`div`,{className:`grid min-h-84 content-center`,children:e})}function Ni(){let{data:e,loading:t,error:n,reload:r}=ee(),i=(0,H.useMemo)(()=>new Map(e===void 0?[]:e.map(e=>[e.id,e])),[e]);return n===null?t||e===void 0?{state:`loading`}:{state:`ready`,projects:e,byId:i}:{state:`error`,error:n,retry:()=>void r()}}var Pi=V(`pgs-aea740cf56`);function Fi({windowId:e,revision:t,back:n,onBack:r,onOpenSettings:i}){let{t:a}=F();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${n?Dt:Ct}`,"data-testid":`popup-notification-feed`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:a(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),onClick:r,autoFocus:!0,"data-testid":`popup-feed-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 mr-auto text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:a(`notifications.feed.title`)}),/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:a(`notifications.feed.settings`),placement:`bottom-end`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(bt,{"aria-hidden":`true`}),onClick:i,"data-testid":`popup-feed-settings`})})]}),/* @__PURE__ */ (0,U.jsx)(_t,{host:`popup`,api:L.notifications,locale:Se(),t:a,revision:t,logger:Pi,onOpenTarget:t=>St(t,e),onOpenSettings:i,onSeen:()=>Ot(`seen`)})]})}var Ii=V(`pgs-a3c52049ce`);function Li({windowId:e,waitingCount:t,revision:n,onOpenFeed:r}){let{t:i}=F();return/* @__PURE__ */ (0,U.jsx)(xt,{api:L.notifications,locale:Se(),t:i,waitingCount:t,revision:n,logger:Ii,onOpenTarget:t=>St(t,e),onOpenFeed:r,onSeen:()=>Ot(`seen`)})}function Ri({value:e,onChange:t,labels:n,size:r,fullWidth:i,className:a}){return/* @__PURE__ */ (0,U.jsx)(m,{value:e,onValueChange:t,"aria-label":n.group,size:r,fullWidth:i,className:a,options:[{value:`light`,label:n.light,icon:/* @__PURE__ */ (0,U.jsx)(pn,{"aria-hidden":`true`})},{value:`dark`,label:n.dark,icon:/* @__PURE__ */ (0,U.jsx)(dn,{"aria-hidden":`true`})},{value:`system`,label:n.system,icon:/* @__PURE__ */ (0,U.jsx)(Mt,{"aria-hidden":`true`})}]})}function X({title:e,hint:t,children:n,"data-testid":r}){let{t:i}=F();return/* @__PURE__ */ (0,U.jsxs)(`section`,{className:`grid gap-1.5`,"data-testid":r,children:[/* @__PURE__ */ (0,U.jsxs)(`h3`,{className:`mx-0.5 my-0 flex items-center gap-1 text-xs font-medium text-fg-muted`,children:[e,t!==void 0&&/* @__PURE__ */ (0,U.jsx)(B,{name:i(`popup.site.more`,{about:e}),text:t,placement:`bottom-start`})]}),/* @__PURE__ */ (0,U.jsx)(nn,{kind:`block`,body:`rows`,density:`compact`,children:/* @__PURE__ */ (0,U.jsx)(y,{children:n})})]})}function Z({label:e,below:t,stacked:n=!1,alignStart:r=!1,children:i,"data-testid":a}){return/* @__PURE__ */ (0,U.jsx)(_e,{title:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:e}),end:i,stacked:n,alignStart:r,"data-testid":a,children:t})}var zi={on:`bg-success shadow-(--glow-status-success)`,neutral:`bg-fg-muted`,warning:`bg-warning`,error:`bg-error`},Bi={on:`text-fg-muted`,neutral:`text-fg-muted`,warning:`text-fg-warning`,error:`text-fg-error`};function Q({tone:e,announce:t=!1,children:n,action:r,"data-testid":i}){return/* @__PURE__ */ (0,U.jsxs)(`span`,{role:e===`error`?`alert`:t?`status`:void 0,className:h(`flex items-start gap-1.75 text-xs leading-(--leading-caption)`,Bi[e]),"data-testid":i,children:[/* @__PURE__ */ (0,U.jsx)(`i`,{"aria-hidden":`true`,className:h(`mt-1.25 size-1.75 flex-none rounded-full`,zi[e])}),/* @__PURE__ */ (0,U.jsxs)(`span`,{children:[n,r]})]})}function Vi({onRetry:e}){let{t}=F();return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[` \u00B7 `,/* @__PURE__ */ (0,U.jsx)(N,{variant:`link`,size:`xs`,onClick:e,children:t(`common.retry`)})]})}var Hi=V(`pgs-6344bc6f0d`);function Ui(e,t){let n=u(),r=(0,H.useMemo)(()=>i({kind:`project`,projectId:e},`discovery-settings`),[e]),a=A({key:r,read:async()=>{let t=await R.call(`REFRESH_DISCOVERY_SETTINGS`,{projectId:e});if(!t.success)throw Error(`REFRESH_DISCOVERY_SETTINGS refused: ${t.error}`);if(t.discoverySettings===null)throw Error(`The service worker could not read the discovery settings`);return t.discoverySettings},freshness:`screen`}),[o,s]=(0,H.useState)(null),[c,l]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!1),h=(0,H.useRef)(null),g=(0,H.useRef)(!1),_=(0,H.useRef)(!1),v=(0,H.useRef)(null),y=(0,H.useCallback)(async()=>{if(!_.current){_.current=!0,l(!0),f(!1),m(!1);try{for(;h.current!==null||g.current;){let i=h.current;if(i!==null){try{await L.discovery.updateUserSettings(i)}catch(t){Hi.warn(`pgm-6e1d90d469`,{projectId:e,error:t instanceof Error?t.message:String(t)}),v.current=h.current,h.current=null,s(null),f(!0);continue}g.current=!0,h.current===i&&(h.current=null,s(null));continue}g.current=!1;let a=await Wi(e,t);a===null?m(!0):(n.write(r,a),m(!1))}}finally{_.current=!1,l(!1)}}},[n,r,e,t]),b=(0,H.useCallback)(e=>{h.current=e,s(e),y()},[y]),x=(0,H.useCallback)(()=>{let e=v.current;if(e===null)throw Error(`No failed discovery save to retry`);v.current=null,b(e)},[b]),S=(0,H.useCallback)(()=>{g.current=!0,y()},[y]);if(a.error!==null)return{status:`readFailed`,retry:()=>void a.reload()};if(p&&!c)return{status:`readFailed`,retry:S};let C=a.data;return C===void 0?{status:`loading`}:{status:`ready`,settings:C,checked:o===null?C.userEnabled:o,saving:c,saveFailed:d,toggle:b,retrySave:x}}async function Wi(e,t){let n=await R.call(`REFRESH_DISCOVERY_SETTINGS`,{tabId:t,projectId:e}).catch(t=>(Hi.warn(`pgm-8a2d41a868`,{projectId:e,error:t instanceof Error?t.message:String(t)}),null));return n===null?null:n.success?(n.discoverySettings===null&&Hi.warn(`pgm-842d0b7de2`,{projectId:e}),n.discoverySettings):(Hi.warn(`pgm-a943e9be7d`,{projectId:e,error:n.error}),null)}function Gi(e){var t;return((t=e.disabledReasons)==null?void 0:t.includes(`company_disabled`))===!0||!e.companyEnabled}function Ki(e){return e.gatingModel===`company+user+project`&&e.projectEnabled===!1}var $=`popup-discovery-status`;function qi({tabId:e,project:t}){let{t:n}=F();return t===void 0?/* @__PURE__ */ (0,U.jsx)(Zi,{status:/* @__PURE__ */ (0,U.jsx)(Yi,{}),control:/* @__PURE__ */ (0,U.jsx)(Xi,{})}):t===null?/* @__PURE__ */ (0,U.jsx)(Zi,{status:/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.noProject`)}),control:null}):/* @__PURE__ */ (0,U.jsx)(Ji,{tabId:e,project:t})}function Ji({tabId:e,project:t}){let{t:n}=F(),r=Ui(O(t.id),e),i,a=null;switch(r.status){case`loading`:i=/* @__PURE__ */ (0,U.jsx)(Yi,{}),a=/* @__PURE__ */ (0,U.jsx)(Xi,{});break;case`readFailed`:i=/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:r.retry}),children:n(`popup.settings.discoveryStatus.readFailed`)});break;case`ready`:{let{settings:e}=r;i=r.saving?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.saving`)}):r.saveFailed?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:r.retrySave}),children:n(`popup.settings.discoveryStatus.saveFailed`)}):Gi(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.companyOff`)}):Ki(e)?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`warning`,children:n(`popup.settings.discoveryStatus.projectOff`,{project:t.name})}):e.effectiveEnabled?/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`on`,children:n(`popup.settings.discoveryStatus.on`,{project:t.name})}):/* @__PURE__ */ (0,U.jsx)(Q,{"data-testid":$,tone:`neutral`,children:n(`popup.settings.discoveryStatus.off`)}),a=/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":n(`popup.settings.discovery`),checked:r.checked,onChange:r.toggle,"data-testid":`popup-discovery-toggle`});break}}return/* @__PURE__ */ (0,U.jsx)(Zi,{status:i,control:a})}function Yi(){return/* @__PURE__ */ (0,U.jsx)(P,{className:`mt-1 h-3 w-40`})}function Xi(){return/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`})}function Zi({status:e,control:t}){let{t:n}=F();return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[n(`popup.settings.discovery`),/* @__PURE__ */ (0,U.jsx)(B,{name:n(`popup.site.more`,{about:n(`popup.settings.discovery`)}),text:n(`popup.settings.discoveryHint`),placement:`bottom-start`})]}),below:e,alignStart:!0,"data-testid":`popup-discovery`,children:t})}function Qi({children:e}){return/* @__PURE__ */ (0,U.jsx)(`kbd`,{className:`inline-flex shrink-0 items-center rounded-full px-1.5 py-0.75 font-sans text-(length:--text-micro) leading-none font-medium whitespace-nowrap text-fg-muted shadow-[inset_0_0_0_1px_var(--color-border-hairline)]`,children:e})}var $i=/* @__PURE__ */ new Set([`Control`,`Alt`,`Shift`,`Meta`]);function ea(e){if($i.has(e.key))return null;let t=[];return(e.ctrlKey||e.metaKey)&&t.push(`Ctrl`),e.altKey&&t.push(`Alt`),e.shiftKey&&t.push(`Shift`),e.key===` `?t.push(`Space`):t.push(e.key.length===1?e.key.toUpperCase():e.key),t.join(`+`)}function ta(){let{t:e}=F(),t=W(`selectionHotkey`),n=G(),[r,i]=(0,H.useState)(!1);return t===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-(--control-height-sm) w-12 rounded-(--input-radius)`}):/* @__PURE__ */ (0,U.jsx)(T,{size:`sm`,active:r,"aria-label":e(`popup.settings.hotkeyName`,{hotkey:t}),onClick:()=>i(!0),onBlur:()=>i(!1),onKeyDown:e=>{if(!r)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){i(!1);return}let t=ea(e);t!==null&&(i(!1),n(`selectionHotkey`,t))},"data-testid":`popup-hotkey`,children:r?/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-(--color-primary-text) animate-pulse-dot`,children:e(`popup.settings.hotkeyCapture`)}):/* @__PURE__ */ (0,U.jsx)(`span`,{className:`flex items-center gap-1`,children:t.split(`+`).map((e,t)=>/* @__PURE__ */ (0,U.jsx)(Qi,{children:e},`${e}-${t}`))})})}function na(e,t){return t?`element`:e?`window`:`off`}function ra(e){return{isolationWindow:e===`window`,isolationElement:e===`element`}}var ia=Promise.resolve();function aa(e){let t=()=>Pe(ra(e)),n=ia.then(t,t);return ia=n,n}var oa=V(`pgs-fed3bb0e75`),sa={managed:null,company:`popup.settings.modelKeyCompany`,personal:`popup.settings.modelKeyPersonal`};function ca(){let{t:e}=F(),t=x(),n=G(),r=W(`modelPick`),a=(0,H.useMemo)(()=>zt({http:pt(),logger:oa}),[]),o=ct(),{data:s,error:c,reload:l}=A({key:i(o,`chat-model-capabilities`),read:()=>a.load(),freshness:`screen`});if((0,H.useEffect)(()=>{c!==null&&(oa.error(`pgm-9665648376`,{error:c.message}),t.show({id:`popup-models`,variant:`error`,message:e(`popup.settings.modelLoadFailed`),action:{label:e(`common.retry`),onAction:()=>void l()}}))},[c,l,e,t]),r===void 0||s===void 0&&c===null)return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),children:/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8 w-37.5 rounded-md`})});let u=s===void 0?[]:s.groups,d=s===void 0||r===null?null:kt(s,r),f=s===void 0?null:Lt(s,d,null);return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.model`),"data-testid":`popup-model`,children:/* @__PURE__ */ (0,U.jsx)(Qe,{size:`sm`,"aria-label":e(`popup.settings.model`),placeholder:e(`popup.settings.modelNone`),value:f===null?null:f.model.selectionId,onValueChange:r=>{for(let i of u){let a=i.models.find(e=>e.selectionId===r);if(a!==void 0){n(`modelPick`,{keySource:i.source,modelId:a.id}),L.aiSettings.updateUser({selectedProvider:i.source,selectedModel:a.id}).catch(n=>{oa.error(`pgm-573d3af0bc`,{error:n instanceof Error?n.message:String(n)}),t.show({id:`popup-model-save`,variant:`error`,message:e(`popup.settings.saveFailed`)})});return}}throw Error(`The AI model Select picked a row it did not render: ${r}`)},className:`w-37.5`,options:u.flatMap(t=>t.models.map(n=>{let r=sa[t.source];return{value:n.selectionId,label:r===null?n.name:`${n.name} \u00B7 ${e(r)}`,disabled:!Pt(n)}}))})})}var la=V(`pgs-cdc66fba2a`),ua={permissions:[`notifications`]};function da(e){return e instanceof Error?e.message:String(e)}function fa(){return[chrome.permissions.onAdded,chrome.permissions.onRemoved]}function pa(e){var t;return((t=e.permissions)==null?void 0:t.includes(`notifications`))===!0}function ma(){let{t:e}=F(),[t,n]=(0,H.useState)(`reading`),r=(0,H.useRef)(!0),i=(0,H.useCallback)(()=>{chrome.permissions.contains(ua).then(e=>{r.current&&n(t=>e?`on`:t===`denied`?`denied`:`off`)},e=>{la.error(`pgm-cbfb085fbb`,{error:da(e)}),r.current&&n(`readFailed`)})},[]);(0,H.useEffect)(()=>{r.current=!0;let e=e=>{pa(e)&&i()},t=fa();for(let n of t)n.addListener(e);return i(),()=>{r.current=!1;for(let n of t)n.removeListener(e)}},[i]);let a=()=>{n(`reading`),i()},o=e=>{if(e){n(`asking`),chrome.permissions.request(ua).then(e=>n(e?`on`:`denied`),e=>{la.error(`pgm-67efc28caa`,{error:da(e)}),n(`off`)});return}chrome.permissions.remove(ua).then(e=>{e||la.error(`pgm-2cbfb59188`),n(e?`off`:`on`)},e=>{la.error(`pgm-ac8845b9f5`,{error:da(e)})})},c=e(`popup.settings.osNotifications`);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[c,/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:c}),text:e(`popup.settings.osNotificationsHint`),placement:`bottom-start`})]}),below:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(`small`,{className:`text-xs leading-(--leading-caption) text-fg-muted`,children:e(`popup.settings.osNotificationsWhen`)}),t===`denied`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`neutral`,announce:!0,"data-testid":`popup-os-notifications-denied`,children:e(`popup.settings.osNotificationsDenied`)}),t===`readFailed`&&/* @__PURE__ */ (0,U.jsx)(Q,{tone:`error`,action:/* @__PURE__ */ (0,U.jsx)(Vi,{onRetry:a}),"data-testid":`popup-os-notifications-read-failed`,children:e(`popup.settings.osNotificationsReadFailed`)})]}),alignStart:!0,"data-testid":`popup-os-notifications`,children:t===`reading`?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):t===`readFailed`?null:/* @__PURE__ */ (0,U.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-fg-muted`,children:[t===`asking`&&/* @__PURE__ */ (0,U.jsx)(ye,{}),/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":c,checked:t===`on`,onChange:o,"data-testid":`popup-os-notifications-switch`})]})})}var ha=V(`pgs-7fed4be7cb`);function ga(){let{t:e}=F(),t=W(`notificationsEnabled`),n=G(),r=e(`popup.settings.notifications`);return/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[/* @__PURE__ */ (0,U.jsx)(X,{title:e(`popup.settings.groups.notifications`),hint:e(`popup.settings.groups.notificationsHint`),"data-testid":`popup-notification-groups`,children:/* @__PURE__ */ (0,U.jsx)(Tt,{api:L.notifications,locale:Se(),t:e,logger:ha,onChanged:()=>Ot(`group_changed`)})}),/* @__PURE__ */ (0,U.jsxs)(X,{title:e(`popup.settings.groups.thisBrowser`),children:[/* @__PURE__ */ (0,U.jsx)(ma,{}),/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[r,/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:r}),text:e(`popup.settings.notificationsHint`),placement:`bottom-start`})]}),children:t===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-5 w-9 rounded-full`}):/* @__PURE__ */ (0,U.jsx)(s,{"aria-label":r,checked:t,onChange:e=>n(`notificationsEnabled`,e),"data-testid":`popup-notifications`})})]})]})}var _a=/^\d+$/;function va(e){let t=e.trim();return _a.test(t)?Number(t)>$e?`tooLong`:null:`notWholeNumber`}function ya(){let{t:e,i18n:t}=F(),r=W(`autoplayStepPauseMs`),i=G(),[a,o]=(0,H.useState)(null),s=a===null?null:va(a),c=s!==null,l=()=>{if(a===null||c)return;let e=Number(a.trim());o(null),e!==r&&i(`autoplayStepPauseMs`,e)};return/* @__PURE__ */ (0,U.jsx)(Z,{label:e(`popup.settings.pause`),alignStart:!0,below:c?/* @__PURE__ */ (0,U.jsxs)(`span`,{role:`alert`,className:`mt-0.5 flex items-start gap-1.5 text-xs leading-(--leading-caption) text-fg-error`,children:[/* @__PURE__ */ (0,U.jsx)(n,{"aria-hidden":`true`,className:`mt-px size-3.5 shrink-0`}),/* @__PURE__ */ (0,U.jsx)(`span`,{children:s===`tooLong`?e(`popup.settings.pauseTooLong`,{max:new Intl.NumberFormat(t.language).format($e)}):e(`popup.settings.pauseInvalid`)})]}):void 0,"data-testid":`popup-step-pause`,children:r===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8 w-26 rounded-md`}):/* @__PURE__ */ (0,U.jsx)(Ze,{size:`sm`,inputMode:`numeric`,"aria-label":e(`popup.settings.pauseName`),value:a??String(r),onValueChange:o,onBlur:l,onKeyDown:e=>{e.key===`Enter`&&l()},invalid:c,trailing:/* @__PURE__ */ (0,U.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e(`popup.settings.ms`)}),className:`w-26 [&_input]:text-right [&_input]:tabular-nums`})})}function ba({tabId:e,project:t,onBack:n}){let{t:r}=F(),i=W(`theme`),a=G();return/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col ${Ct}`,"data-testid":`popup-settings`,children:[/* @__PURE__ */ (0,U.jsxs)(`div`,{className:`flex h-12 flex-none items-center gap-1.5 border-b border-stroke-light pr-3 pl-1.5`,children:[/* @__PURE__ */ (0,U.jsx)(I,{relationship:`label`,content:r(`popup.settings.back`),placement:`bottom-start`,children:/* @__PURE__ */ (0,U.jsx)(D,{icon:/* @__PURE__ */ (0,U.jsx)(Nt,{"aria-hidden":`true`}),onClick:n,autoFocus:!0,"data-testid":`popup-settings-back`})}),/* @__PURE__ */ (0,U.jsx)(`h2`,{className:`m-0 text-body-md font-semibold tracking-(--tracking-title) text-fg-primary`,children:r(`popup.settings.title`)})]}),/* @__PURE__ */ (0,U.jsxs)(gn,{children:[/* @__PURE__ */ (0,U.jsx)(ga,{}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.view`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.theme`),stacked:!0,children:i===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(Ri,{value:i,onChange:e=>a(`theme`,e),labels:{group:r(`popup.settings.theme`),light:r(`popup.settings.themeLight`),dark:r(`popup.settings.themeDark`),system:r(`popup.settings.themeSystem`)},fullWidth:!0})}),/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.language`),stacked:!0,children:/* @__PURE__ */ (0,U.jsx)(jn,{fullWidth:!0})})]}),/* @__PURE__ */ (0,U.jsxs)(X,{title:r(`popup.settings.groups.recording`),children:[/* @__PURE__ */ (0,U.jsx)(Z,{label:r(`popup.settings.hotkey`),children:/* @__PURE__ */ (0,U.jsx)(ta,{})}),/* @__PURE__ */ (0,U.jsx)(ya,{}),/* @__PURE__ */ (0,U.jsx)(xa,{})]}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.assistant`),children:/* @__PURE__ */ (0,U.jsx)(ca,{})}),/* @__PURE__ */ (0,U.jsx)(X,{title:r(`popup.settings.groups.pages`),children:/* @__PURE__ */ (0,U.jsx)(qi,{tabId:e,project:t},t==null?``:t.id)})]})]})}function xa(){let{t:e}=F(),t=An(),n=W(`isolationWindow`),r=W(`isolationElement`),i=n=>{t({id:`popup-isolation`,run:()=>aa(n),log:{message:`Input isolation was not stored`,context:{isolation:n}},message:e(`popup.settings.saveFailed`)})},a=n===void 0||r===void 0?void 0:na(n,r);return/* @__PURE__ */ (0,U.jsx)(Z,{label:/* @__PURE__ */ (0,U.jsxs)(U.Fragment,{children:[e(`popup.settings.isolation`),/* @__PURE__ */ (0,U.jsx)(B,{name:e(`popup.site.more`,{about:e(`popup.settings.isolation`)}),text:e(`popup.settings.isolationHint`),placement:`bottom-start`})]}),stacked:!0,"data-testid":`popup-isolation`,children:a===void 0?/* @__PURE__ */ (0,U.jsx)(P,{className:`h-8.5 w-full rounded-md`}):/* @__PURE__ */ (0,U.jsx)(m,{value:a,onValueChange:i,"aria-label":e(`popup.settings.isolation`),fullWidth:!0,options:[{value:`off`,label:e(`popup.settings.isolationOff`)},{value:`window`,label:e(`popup.settings.isolationWindow`)},{value:`element`,label:e(`popup.settings.isolationElement`)}]})})}var Sa=V(`pgs-b5906754fa`);function Ca({user:e}){let t=de(),n=Ni(),r=W(`enabled`),i=vt(e.id),a=Et(),[o,s]=(0,H.useState)({name:`main`,back:!1});if((0,H.useEffect)(()=>{Ot(`surface_opened`)},[]),a===void 0)return/* @__PURE__ */ (0,U.jsx)(_n,{});let c=n.state===`ready`?wa(t,n.byId):null,l=i.status===`ready`?i.snapshot:null,u=i.status===`ready`?i.revision:0,d=()=>s({name:`settings`,back:!1}),f=()=>s({name:`feed`,back:!1}),p=()=>s({name:`main`,back:!0}),m=/* @__PURE__ */ (0,U.jsx)(In,{user:e,onOpenSettings:d,notificationCounts:l,onOpenNotifications:f}),h=r===!0&&l!==null?/* @__PURE__ */ (0,U.jsx)(Li,{windowId:a,waitingCount:l.waitingCount,revision:u,onOpenFeed:f}):null;switch(o.name){case`settings`:{let r=/* @__PURE__ */ (0,U.jsx)(ba,{tabId:t.tabId,project:n.state===`loading`?void 0:c,onBack:p});return c===null?r:/* @__PURE__ */ (0,U.jsx)(At,{user:e,project:{id:O(c.id),number:ue(c.number)},children:r})}case`feed`:return/* @__PURE__ */ (0,U.jsx)(Fi,{windowId:a,revision:u,back:o.back,onBack:p,onOpenSettings:d});case`main`:return/* @__PURE__ */ (0,U.jsx)(ji,{user:e,header:m,back:o.back,strip:h,snapshot:t,projects:n,tabProject:c})}}function wa(e,t){let{projectId:n}=e.state;if(n===null)return null;let r=t.get(n);return r===void 0?(Sa.warn(`pgm-cb1ec83f44`,{tabId:e.tabId}),null):r}function Ta(){return/* @__PURE__ */ (0,U.jsx)(k,{loading:/* @__PURE__ */ (0,U.jsx)(_n,{}),signedOut:/* @__PURE__ */ (0,U.jsx)(Mn,{}),children:e=>/* @__PURE__ */ (0,U.jsx)(wn,{user:e,children:/* @__PURE__ */ (0,U.jsx)(H.Suspense,{fallback:/* @__PURE__ */ (0,U.jsx)(_n,{}),children:/* @__PURE__ */ (0,U.jsx)(Ca,{user:e})})})})}var Ea=V(`pgs-2e3f74b175`),Da=document.getElementById(`popup-root`);Da===null?Ea.error(`pgm-f13077b9ed`):st({surface:`popup`,root:Da,followedTab:yt(),editorNavigation:at(`popup`),render:()=>/* @__PURE__ */ (0,U.jsx)(Ta,{})}).catch(e=>{Ea.error(`pgm-f4cc990f36`,e)});
@@ -6,17 +6,17 @@
6
6
  <title data-i18n="sidepanel.title">Progon AI Assistant</title>
7
7
  <script type="module" crossorigin src="../sidepanel/sidepanel.js"></script>
8
8
  <link rel="modulepreload" crossorigin href="../chunks/shared-hePW80VL.js">
9
- <link rel="modulepreload" crossorigin href="../chunks/shared-C05lJ8nQ.js">
10
- <link rel="modulepreload" crossorigin href="../chunks/shared-C5qHe-zg.js">
11
- <link rel="modulepreload" crossorigin href="../chunks/shared-BBv6J4oP.js">
12
- <link rel="modulepreload" crossorigin href="../chunks/shared-CNYvsh0O.js">
13
- <link rel="modulepreload" crossorigin href="../chunks/shared-Dbbjj01C.js">
14
- <link rel="modulepreload" crossorigin href="../chunks/shared-BAuQl9-k.js">
15
- <link rel="modulepreload" crossorigin href="../chunks/shared-B5dGSIVr.js">
16
- <link rel="modulepreload" crossorigin href="../chunks/shared-C0apd10a.js">
17
- <link rel="modulepreload" crossorigin href="../chunks/shared-BROt3HHj.js">
18
- <link rel="stylesheet" crossorigin href="../chunks/shared-BQbdfGz-.css">
19
- <link rel="stylesheet" crossorigin href="../chunks/shared-CdFf-X4Y.css">
9
+ <link rel="modulepreload" crossorigin href="../chunks/shared-lM00HeT6.js">
10
+ <link rel="modulepreload" crossorigin href="../chunks/shared-t8TH2XkL.js">
11
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CKtbh_44.js">
12
+ <link rel="modulepreload" crossorigin href="../chunks/shared-BgEO6Nif.js">
13
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CwsTFlbT.js">
14
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CfjrOLG1.js">
15
+ <link rel="modulepreload" crossorigin href="../chunks/shared-C7IWMwZY.js">
16
+ <link rel="modulepreload" crossorigin href="../chunks/shared-CFEBqIm7.js">
17
+ <link rel="modulepreload" crossorigin href="../chunks/shared-D-c-eSoI.js">
18
+ <link rel="stylesheet" crossorigin href="../chunks/shared-BRaGK72I.css">
19
+ <link rel="stylesheet" crossorigin href="../chunks/shared-DXp1f_Ub.css">
20
20
  <link rel="stylesheet" crossorigin href="../sidepanel/sidepanel.css">
21
21
  </head>
22
22
  <body>