@botbuddy/react 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +8 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +7 -7
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @botbuddy/react — Changelog
|
|
2
2
|
|
|
3
|
+
## 0.22.0
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`findItLink(findIt, options)` (BOT-3638).** Turns a pack's "where to find
|
|
8
|
+
it" (`tour.find_it`) into a link that opens the screen. An `https://` URL
|
|
9
|
+
is returned as written with `external: true`. An app path (`/…`) is a
|
|
10
|
+
relative link when `inHostApp` is set (rendering inside your own app), or
|
|
11
|
+
`<appOrigin><path>` when you pass your one production origin. Without
|
|
12
|
+
either it returns `null`, and so does any other value
|
|
13
|
+
(`javascript:`, `//host`, a backslash or a space), so you show the text.
|
|
14
|
+
Use the pack's optional `tour.where` as the link text.
|
|
15
|
+
|
|
3
16
|
## 0.21.0
|
|
4
17
|
|
|
5
18
|
### Added
|
package/README.md
CHANGED
|
@@ -253,6 +253,14 @@ const { feed } = useReleaseNotes({ endpoint, getToken });
|
|
|
253
253
|
<ReleaseNotesAnnouncement feed={feed} viewer={user.id} onNavigate={navigate} />
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
+
|
|
257
|
+
### Pack tip links (`findItLink`, 0.22.0)
|
|
258
|
+
|
|
259
|
+
`findItLink(tour.find_it, { inHostApp: true })` turns a pack's "where to find
|
|
260
|
+
it" into `{ href, external }` or `null`: https as written, an app path relative
|
|
261
|
+
to your app, anything else `null` (show the text). Pass `appOrigin` instead of
|
|
262
|
+
`inHostApp` to link an app path onto another site's origin. Use `tour.where` as
|
|
263
|
+
the link text when present.
|
|
256
264
|
## Zero Dependencies
|
|
257
265
|
|
|
258
266
|
The widget uses inline styles and inline SVG icons, and `ReleaseNotes` injects its own plain-CSS sheet — no Tailwind, no icon library, no CSS imports needed. React is the only peer dependency.
|
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
'use strict';var react=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime');var Me=8;function ut(e,t,o,a,i,l){let _=Math.max(Me,i-o-Me),y=Math.max(Me,l-a-Me);return {x:Math.min(Math.max(e,Me),_),y:Math.min(Math.max(t,Me),y)}}function pt(e,t){let[o,a]=react.useState({x:e,y:t}),i=react.useRef(false),l=react.useRef({x:0,y:0}),_=react.useRef(false),y=react.useCallback(h=>{i.current=true,_.current=false,l.current={x:h.clientX-o.x,y:h.clientY-o.y},h.target.setPointerCapture(h.pointerId);},[o]),R=react.useCallback(h=>{i.current&&(_.current=true,a({x:h.clientX-l.current.x,y:h.clientY-l.current.y}));},[]),f=react.useCallback(()=>{i.current=false;},[]);return {pos:o,setPos:a,onPointerDown:y,onPointerMove:R,onPointerUp:f,didDrag:_}}function gt(e,t,o){let a=react.useRef(o);a.current=o,react.useEffect(()=>{if(!t)return;if(e.supabaseUrl){let l=false,_=null,y=()=>{l||_||(_=setInterval(()=>a.current(),15e3));},R=null;try{let g=new URL(e.supabaseUrl),n=["localhost","127.0.0.1","::1"].includes(g.hostname);if(g.protocol==="http:"&&!n)throw new Error("Realtime WebSocket requires HTTPS outside loopback hosts");g.protocol=g.protocol==="https:"?"wss:":"ws:",R=g.toString().replace(/\/$/,"");}catch{y();}let f=null,h=null,M=null,A=0,p=()=>{if(!(l||!R)){try{f=new WebSocket(`${R}/realtime/v1/websocket?apikey=${e.anonKey}&vsn=1.0.0`);}catch{y();return}f.onopen=()=>{if(l||!f)return;let g={topic:`realtime:public:test_run_cases:test_run_id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_run_cases",filter:`test_run_id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(g));let n={topic:`realtime:public:test_runs:id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_runs",filter:`id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(n)),h=setInterval(()=>{f?.readyState===WebSocket.OPEN&&f.send(JSON.stringify({topic:"phoenix",event:"heartbeat",payload:{},ref:String(++A)}));},3e4);},f.onmessage=g=>{try{JSON.parse(g.data).event==="postgres_changes"&&a.current();}catch{}},f.onclose=()=>{x(),l||(M=setTimeout(p,3e3));},f.onerror=()=>{f?.close();};}},x=()=>{h&&(clearInterval(h),h=null);};return p(),()=>{l=true,x(),M&&clearTimeout(M),_&&clearInterval(_),f&&(f.onclose=null,f.onerror=null,f.close());}}let i=setInterval(()=>a.current(),15e3);return ()=>clearInterval(i)},[e.supabaseUrl,e.anonKey,t]);}var Pn="botbuddy:created-test-run:";function An(e){if(!e)return "";try{return new URL(e).origin}catch{return e}}function $n(e){return `${Pn}${encodeURIComponent([e.appSlug,e.environment||"",e.ticketId||"",An(e.targetUrl),e.branchName||""].join("|"))}`}function Je(e,t){let o={apikey:e.anonKey};return t?o.Authorization=`Bearer ${t}`:e.apiKey?o.Authorization=`Bearer ${e.apiKey}`:o.Authorization=`Bearer ${e.anonKey}`,o}async function Ln(e){if(e)return e;try{let t=await fetch("/.botbuddy-token",{cache:"no-store"});if(t.ok){let o=(await t.text()).trim();if(o.startsWith("public_"))return o}}catch{}try{let t=undefined?.VITE_BOTBUDDY_TEST_RUN_TOKEN;if(t&&typeof t=="string"&&t.startsWith("public_"))return t}catch{}return null}function bt(e){let[t,o]=react.useState(null),[a,i]=react.useState("loading"),l=$n(e),[_,y]=react.useState(()=>{if(e.testRunId)return e.testRunId;try{return localStorage.getItem(l)||void 0}catch{return}}),R=e.testRunId||_,f=react.useCallback(x=>{if(o(x),!!x?.id){y(x.id);try{localStorage.setItem(l,x.id);}catch{}}},[l]),h=react.useCallback(async()=>{try{let x=await Ln(e.testRunToken);if(!x&&!R){i("no-match"),o(null);return}if(x&&!e.ticketId){i("no-match"),o(null);return}let g=new URLSearchParams;x&&g.set("token",x),e.ticketId&&g.set("ticket_id",e.ticketId),g.set("app_slug",e.appSlug),e.environment&&g.set("environment",e.environment),R&&g.set("test_run_id",R),e.targetUrl&&g.set("target_url",e.targetUrl),e.version&&g.set("version",e.version),e.commitSha&&g.set("commit_sha",e.commitSha),e.prNumber&&g.set("pr_number",String(e.prNumber)),e.branchName&&g.set("branch_name",e.branchName);let n=await fetch(`${e.config.serverUrl}/widget/test-run?${g.toString()}`,{headers:Je(e.config,e.authToken)});if(n.status===404){i("no-match"),o(null);return}if(n.status===401||n.status===403){e.authToken&&e.onAuthExpired&&e.onAuthExpired(),i("error");return}if(!n.ok){i("error");return}let d=await n.json();if(!d||d.run===null){i("no-match"),o(null);return}f(d),i(d.status==="completed"?"completed":"ready");}catch{i("error");}},[e.config.serverUrl,e.config.anonKey,e.config.apiKey,e.authToken,e.appSlug,e.environment,e.ticketId,R,e.testRunToken,e.targetUrl,e.version,e.commitSha,e.branchName,e.prNumber,e.onAuthExpired,f]);return react.useEffect(()=>{h();},[h]),gt(e.config,t?.id,h),{run:t,widgetState:a,fetchRun:h,setVerdict:async(x,g,n,d="human")=>(o(P=>{if(!P)return null;let z=P.test_cases.map(S=>S.id===x?{...S,verdict:g,fail_reason:g==="fail"&&n||null,verdict_by_display_name:d,verdict_at:new Date().toISOString()}:S),V={total:z.length,pending:0,pass:0,fail:0,skip:0};return z.forEach(S=>{S.verdict in V&&V[S.verdict]++;}),{...P,test_cases:z,summary:V}}),(await fetch(`${e.config.serverUrl}/widget/test-cases/${x}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",...Je(e.config,e.authToken)},body:JSON.stringify({verdict:g,fail_reason:n,display_name:d})})).ok),markComplete:async()=>t?(o(g=>g?{...g,status:"completed"}:null),i("completed"),(await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",...Je(e.config,e.authToken)}})).ok):false,resetRun:async()=>{if(!t)return false;let x=await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",...Je(e.config,e.authToken)}});return x.ok&&h(),x.ok},setRun:f}}var ht="botbuddy-widget-auth-token",xt="botbuddy-widget-auth-name";function Ue(e){if(!e)return null;try{let t=e.split(".")[1];if(!t)return null;let o=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"="),a=atob(o),i=JSON.parse(a);return typeof i.exp=="number"?i.exp*1e3:null}catch{return null}}var zn=2500,Un=6e4;function vt(e){let[t,o]=react.useState(()=>{try{return localStorage.getItem(ht)}catch(p){return console.warn("Unable to read BotBuddy widget auth token",p),null}}),[a,i]=react.useState(()=>{try{return localStorage.getItem(xt)}catch(p){return console.warn("Unable to read BotBuddy widget display name",p),null}}),l=react.useRef(null),_=react.useCallback((p,x)=>{o(p),x&&i(x);try{localStorage.setItem(ht,p),x&&localStorage.setItem(xt,x);}catch(g){console.warn("Unable to persist BotBuddy widget auth token",g);}},[]);react.useEffect(()=>{let p=new URL(e).origin,x=g=>{g.origin===p&&g.data?.type==="botbuddy-widget-auth"&&g.data.token&&_(g.data.token,g.data.displayName||"human");};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[e,_]);let y=react.useCallback(()=>{if(l.current)return l.current;if(typeof window>"u"||typeof document>"u")return Promise.resolve(null);let p=new URL(e).origin,x=new URL("/widget-auth",e);x.searchParams.set("silent","1"),x.searchParams.set("origin",window.location.origin);let g=new Promise(n=>{let d=document.createElement("iframe");d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.width="1px",d.style.height="1px",d.style.opacity="0",d.style.pointerEvents="none",d.style.border="0",d.style.left="-9999px",d.style.top="-9999px",d.src=x.toString();let k=false,P=()=>{window.removeEventListener("message",z),clearTimeout(V);try{d.remove();}catch{}l.current=null;},z=S=>{if(S.origin===p){if(S.data?.type==="botbuddy-widget-auth-failed"){if(k)return;k=true,n(null),P();return}S.data?.type!=="botbuddy-widget-auth"||!S.data.token||k||(k=true,n(String(S.data.token)),P());}},V=setTimeout(()=>{k||(k=true,n(null),P());},zn);window.addEventListener("message",z),document.body.appendChild(d);});return l.current=g,g},[e]);react.useEffect(()=>{if(!t)return;let p=Ue(t);if(!p)return;let x=p-Date.now()-Un,g=window.setTimeout(()=>{y();},Math.max(0,x));return ()=>window.clearTimeout(g)},[t,y]);let R=react.useCallback(()=>{let p=new URL("/widget-auth",e);p.searchParams.set("origin",window.location.origin);let x=420,g=520,n=window.screenX+(window.innerWidth-x)/2,d=window.screenY+(window.innerHeight-g)/2;window.open(p.toString(),"botbuddy-auth",`width=${x},height=${g},left=${n},top=${d},popup=yes`);},[e]),[,f]=react.useState(0);react.useEffect(()=>{let p=Ue(t);if(!p)return;let x=p-Date.now();if(x<=0)return;let g=window.setTimeout(()=>f(n=>n+1),x);return ()=>window.clearTimeout(g)},[t]);let h=react.useCallback(()=>{o(null),i(null);try{localStorage.removeItem(ht),localStorage.removeItem(xt);}catch(p){console.warn("Unable to clear BotBuddy widget auth token",p);}},[]),M=Ue(t),A=M!==null&&M<=Date.now();return {token:t,displayName:a,isAuthenticated:!!t,isExpired:A,openLogin:R,refreshNow:y,logout:h}}var Ge=null;function In(){try{if(typeof document<"u"){let e=document.querySelector("base[href]");if(e)return new URL(".botbuddy-totp.json",e.href).toString()}}catch{}return "/.botbuddy-totp.json"}function Xe(){return Ge||(Ge=(async()=>{if(typeof fetch>"u")return null;try{let e=await fetch(In(),{cache:"no-store"});if(!e.ok)return null;let t=await e.json();if(!t||typeof t!="object"||Array.isArray(t))return null;let o={};for(let[a,i]of Object.entries(t))typeof i=="string"&&i.length>0&&(o[a]=i);return o}catch{return null}})(),Ge)}async function Zt(e){return (await Xe())?.[e]??null}function Fn(e){let t=e.replace(/=+$/,"").replace(/\s+/g,"").toUpperCase(),o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",a=[],i=0,l=0;for(let _ of t){let y=o.indexOf(_);if(y<0)throw new Error("Invalid Base32 character in TOTP secret");l=l<<5|y,i+=5,i>=8&&(i-=8,a.push(l>>>i&255));}return Uint8Array.from(a)}async function Qt(e,t=Date.now()){if(typeof crypto>"u"||!crypto.subtle)throw new Error("Web Crypto unavailable");let o=Fn(e),a=new Uint8Array(o.byteLength);a.set(o);let i=Math.floor(t/1e3/30),l=new Uint8Array(8),_=Math.floor(i/4294967296),y=i>>>0;l[0]=_>>>24&255,l[1]=_>>>16&255,l[2]=_>>>8&255,l[3]=_&255,l[4]=y>>>24&255,l[5]=y>>>16&255,l[6]=y>>>8&255,l[7]=y&255;let R=await crypto.subtle.importKey("raw",a,{name:"HMAC",hash:"SHA-1"},false,["sign"]),f=await crypto.subtle.sign("HMAC",R,l),h=new Uint8Array(f),M=h[h.length-1]&15;return (((h[M]&127)<<24|(h[M+1]&255)<<16|(h[M+2]&255)<<8|h[M+3]&255)%1e6).toString().padStart(6,"0")}var en="0.11.0";function Wn(e){let t=new Date(e),a=Date.now()-t.getTime();if(a<6e4)return "just now";if(a<36e5)return `${Math.floor(a/6e4)}m ago`;if(a<864e5)return `${Math.floor(a/36e5)}h ago`;let i=t.getDate(),l=t.toLocaleString("en",{month:"short"}),_=t.toLocaleString("en",{hour:"numeric",minute:"2-digit",hour12:true});return `${l} ${i}, ${_}`}var E=({d:e,className:t,size:o=14})=>jsxRuntime.jsx("svg",{className:t,width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:e})}),w={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01",bot:"M12 8V4H8M2 14h2M20 14h2M15 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M9 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M18 10a6 6 0 0 0-12 0v4a6 6 0 0 0 12 0Z",terminal:"M4 17l6-6-6-6M12 19h8",key:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4",shield:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",copy:"M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2ZM5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",search:"M11 17.25a6.25 6.25 0 1 1 0-12.5 6.25 6.25 0 0 1 0 12.5ZM16 16l4.5 4.5"};function On(){let[e,t]=react.useState(()=>typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(typeof window>"u")return;let o=document.documentElement,a=()=>o.classList.contains("dark")?"dark":o.classList.contains("light")?"light":null,i=a();i&&t(i);let l=window.matchMedia("(prefers-color-scheme: dark)"),_=R=>{let f=a();t(f||(R.matches?"dark":"light"));};l.addEventListener("change",_);let y=new MutationObserver(()=>{let R=a();t(R||(l.matches?"dark":"light"));});return y.observe(o,{attributes:true,attributeFilter:["class"]}),()=>{l.removeEventListener("change",_),y.disconnect();}},[]),e}function Hn(e){let t=e==="dark";return {bg:t?"rgb(30,30,30)":"rgb(255,255,255)",bgSoft:t?"rgba(255,255,255,0.02)":"rgba(0,0,0,0.02)",text:t?"#e5e5e5":"#1a1a1a",textMuted:t?"rgba(255,255,255,0.4)":"rgba(0,0,0,0.45)",textFaint:t?"#555":"#999",border:t?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)",borderSubtle:t?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",shadow:t?"rgba(0,0,0,0.4)":"rgba(0,0,0,0.12)",inputBg:t?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.04)",inputBorder:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.12)",green:"#34d399",greenBg:t?"rgba(52,211,153,0.05)":"rgba(52,211,153,0.08)",greenBorder:t?"rgba(52,211,153,0.6)":"rgba(52,211,153,0.5)",greenBorderSubtle:t?"rgba(52,211,153,0.2)":"rgba(52,211,153,0.15)",red:"#f87171",amber:"#f59e0b",blue:"#60a5fa",purple:"#a78bfa",versionText:t?"rgba(255,255,255,0.5)":"rgba(0,0,0,0.35)",versionNum:t?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",gripColor:t?"#888":"#aaa",btnHover:t?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}}var Kn={pending:"#888",pass:"#34d399",fail:"#f87171",skip:"#f59e0b"},jn={pending:w.circle,pass:w.check,fail:w.x,skip:w.skip},tn={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},Vn=["app.supply-guard.io"];function Yn(e,t=[]){if(!e)return false;let o=e.toLowerCase();return [...Vn,...t].map(i=>i.toLowerCase()).includes(o)}var Jn=e=>({root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:t=>({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:e.bg,border:t?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:t?`0 4px 12px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 4px 12px ${e.shadow}`,cursor:"pointer",fontSize:"9px",color:e.text}),card:(t,o)=>({width:`${t}px`,borderRadius:"8px",background:e.bg,border:o?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:o?`0 8px 24px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 8px 24px ${e.shadow}`,overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:`1px solid ${e.borderSubtle}`},title:{fontSize:"10px",fontWeight:600,color:e.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:e.textMuted,display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:e.gripColor,display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:`1px solid ${e.borderSubtle}`},badge:t=>{let o=tn[t]||tn.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:o.bg,color:o.text,border:`1px solid ${o.border}`,lineHeight:"14px"}},progress:{height:"2px",background:e.borderSubtle,flexShrink:0},progressBar:t=>({height:"100%",width:`${t}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:t=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${t}15`,color:t,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:`1px solid ${e.borderSubtle}`,transition:"background 0.15s"},verdictBtn:(t,o)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:t?`${o}33`:"transparent",color:t?o:e.gripColor,transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:"4px",padding:"2px 6px",color:e.text,outline:"none"},humanBanner:{padding:"6px 12px",fontSize:"11px",fontWeight:600,color:e.green,borderBottom:`1px solid ${e.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",background:e.greenBg,cursor:"pointer",textDecoration:"none"}});function wt(e){return e.split("/")[0].trim()}async function qn(e){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return !1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange(0,e.length);let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return false}}function Ie({config:e,appSlug:t,environment:o,seededUsers:a,authToken:i,tk:l,compact:_=false,onExpand:y,onAuthExpired:R,refreshAuth:f,requestLogin:h,testRunId:M,testRunToken:A,ticketId:p,targetUrl:x,version:g,commitSha:n,prNumber:d,branchName:k}){let[P,z]=react.useState(false),[V,S]=react.useState(null),[W,pe]=react.useState(null),[ie,m]=react.useState(null),[we,C]=react.useState(null),[T,O]=react.useState(null),[G,X]=react.useState(null);react.useEffect(()=>{o==="local"&&Xe();},[o]);let ce=react.useCallback(u=>{S(u),m(null),C(null),X(null);let D=Ue(i);if(o!=="local"&&h&&D!==null&&D<=Date.now()){O({slug:u,token:i||null}),X(u),S(null),h();return}let U=B=>{m(B),C(u),window.setTimeout(()=>{C(I=>I===u?null:I),m(I=>I===B?null:I);},3e3);},L=new URLSearchParams({app_slug:t,seed_user_slug:u,environment:o});M&&L.set("test_run_id",M),A&&L.set("public_token",A),p&&L.set("ticket_id",p),x&&L.set("target_url",x),g&&L.set("version",g),n&&L.set("commit_sha",n),d&&L.set("pr_number",String(d)),k&&L.set("branch_name",k);let H=async B=>{let I={apikey:e.anonKey,Authorization:`Bearer ${B}`};try{let j=await fetch(`${e.serverUrl}/widget/totp-code?${L}`,{headers:I});if(!j.ok){let ke=await j.json().catch(()=>({error:`HTTP ${j.status}`}));return {ok:!1,status:j.status,error:ke.error||`HTTP ${j.status}`}}let oe=await j.json();return {ok:!0,code:String(oe.code)}}catch{return {ok:false,status:0,error:"Network error"}}},Z=(async()=>{if(o==="local"){let j=await Zt(u);if(j)try{return {ok:!0,code:await Qt(j)}}catch{}}let B=await H(i||e.anonKey);if(B.ok||B.status!==401||!f)return B;let I=await f();return I?H(I):{ok:false,status:401,error:"Sign in to BotBuddy to refresh 2FA"}})(),Y=null;try{if(typeof ClipboardItem<"u"&&navigator.clipboard?.write){let B=Z.then(I=>{if(!I.ok)throw new Error(I.error);return new Blob([I.code],{type:"text/plain"})});Y=navigator.clipboard.write([new ClipboardItem({"text/plain":B})]).then(()=>!0).catch(()=>!1);}}catch{}(async()=>{let B=await Z;if(!B.ok){B.status===401?(O({slug:u,token:i||null}),X(u)):U(B.status===404?"No 2FA seed registered":B.error),S(null);return}let I=Y?await Y:false,j=I?true:await qn(B.code),oe=I||j;pe({slug:u,code:B.code,copied:oe}),window.setTimeout(()=>pe(ke=>ke?.slug===u?null:ke),oe?2500:6e3),z(false),S(null);})();},[e.serverUrl,e.anonKey,i,t,o,M,A,p,x,g,n,d,k,f,h]),re=react.useCallback(u=>{O({slug:u,token:i||null}),h?.();},[i,h]),Re=react.useCallback(u=>{G===u?re(u):ce(u);},[G,re,ce]);react.useEffect(()=>{if(!T||!i||i===T.token)return;let u=T.slug;O(null),ce(u);},[i,ce,T]);let Ne=react.useRef(null),Le=react.useRef(null);if(react.useLayoutEffect(()=>{if(!P)return;let u=Ne.current,D=Le.current;if(!u||!D||typeof window>"u")return;let U=()=>{let L=u.getBoundingClientRect(),H=D.getBoundingClientRect(),Z=window.innerWidth,Y=window.innerHeight,B=L.left,I=L.top-H.height-6;I<8&&(I=L.bottom+6);let j=Math.max(8,Z-H.width-8),oe=Math.max(8,Y-H.height-8);B=Math.min(Math.max(B,8),j),I=Math.min(Math.max(I,8),oe),D.style.left=`${Math.round(B)}px`,D.style.top=`${Math.round(I)}px`;};return U(),window.addEventListener("scroll",U,true),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,true),window.removeEventListener("resize",U);}},[P,a.length,ie]),react.useEffect(()=>{if(!P)return;let u=D=>{let U=D.target;Le.current?.contains(U)||Ne.current?.contains(U)||z(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[P]),a.length===0)return null;if(_){let u=a.length>1,D=a[0],U=!u&&G===D,L=j=>{if(j.stopPropagation(),u&&y){y();return}Re(D);},H=!!we,Z=!!W,Y=Z&&W.copied,B=Z&&!W.copied,I=U?l.blue:H?l.red:Y?l.green:B?l.amber:l.purple;return jsxRuntime.jsxs("span",{onPointerDown:j=>j.stopPropagation(),onPointerUp:j=>j.stopPropagation(),onPointerMove:j=>j.stopPropagation(),onClick:L,style:{display:"inline-flex",alignItems:"center",gap:"3px",color:I,fontWeight:600,cursor:"pointer",letterSpacing:B?"0.08em":void 0},title:U?"Sign in to BotBuddy to refresh 2FA":H?ie||"Failed":B?`Clipboard blocked \u2014 code: ${W.code}`:u?`${a.length} 2FA personas`:`Copy 2FA code for ${a[0]}`,children:[jsxRuntime.jsx(E,{d:U?w.key:H?w.alert:Y?w.check:B?w.copy:w.shield,size:10}),U?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Sign in"}):Y?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Copied"}):B?jsxRuntime.jsx(jsxRuntime.Fragment,{children:W.code}):H?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Failed"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["2FA",u&&` \xB7${a.length}`]})]})}if(a.length===1){let u=a[0],D=V===u,U=W?.slug===u,L=U&&W.copied,H=U&&!W.copied,Z=we===u,Y=G===u,B=Y?l.blue:Z?l.red:L?l.green:H?l.amber:l.purple;return jsxRuntime.jsxs("button",{onClick:I=>{I.stopPropagation(),Re(u);},disabled:D,style:{...nn(B),cursor:D?"wait":"pointer",opacity:D?.6:1},title:Y?"Sign in to BotBuddy to refresh 2FA":Z?ie||"Failed":H?`Clipboard blocked \u2014 code: ${W.code}`:`Copy 2FA code for ${u}`,children:[jsxRuntime.jsx(E,{d:Y?w.key:Z?w.alert:L?w.check:H?w.copy:w.shield,size:12}),Y?"Sign in":L?"Copied":H?W.code:Z?"Failed":D?"\u2026":`2FA \xB7 ${u}`]})}let be=!!G&&!P,ae=!!we&&!P,Ce=!!W&&W.copied,Te=!!W&&!W.copied,ot=be?l.blue:ae?l.red:Ce?l.green:Te?l.amber:l.purple,st=P&&typeof document<"u"?reactDom.createPortal(jsxRuntime.jsxs("div",{ref:Le,onPointerDown:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),style:{position:"fixed",left:-9999,top:-9999,background:l.bg,border:`1px solid ${l.border}`,borderRadius:6,boxShadow:`0 8px 24px ${l.shadow}`,padding:4,minWidth:220,maxWidth:typeof window<"u"?Math.min(420,window.innerWidth-16):420,zIndex:1e5,fontFamily:"ui-monospace, SFMono-Regular, monospace"},children:[a.map(u=>{let D=V===u,U=G===u;return jsxRuntime.jsxs("button",{onClick:L=>{L.stopPropagation(),Re(u);},disabled:D,style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 8px",background:"transparent",border:"none",borderRadius:4,cursor:D?"wait":"pointer",fontSize:"10px",color:U?l.blue:l.text,textAlign:"left",fontFamily:"ui-monospace, SFMono-Regular, monospace"},title:U?"Sign in to BotBuddy to refresh 2FA":void 0,onMouseEnter:L=>L.currentTarget.style.background=l.btnHover,onMouseLeave:L=>L.currentTarget.style.background="transparent",children:[jsxRuntime.jsx(E,{d:U?w.key:w.shield,size:10}),jsxRuntime.jsx("span",{style:{flex:1,overflowWrap:"anywhere",lineHeight:1.3},children:u}),U?jsxRuntime.jsx("span",{style:{color:l.blue,fontSize:9},children:"Sign in"}):D?jsxRuntime.jsx("span",{style:{color:l.textMuted,fontSize:9},children:"\u2026"}):null]},u)}),ie&&jsxRuntime.jsx("div",{style:{padding:"4px 8px",fontSize:9,color:l.red},children:ie})]}),document.body):null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{ref:Ne,onClick:u=>{if(u.stopPropagation(),be&&G){re(G);return}z(D=>!D),m(null),C(null);},style:{...nn(ot),cursor:"pointer"},title:be?"Sign in to BotBuddy to refresh 2FA":ae?ie||"Failed":Te?`Clipboard blocked \u2014 code: ${W.code}`:"Choose a persona to copy a 2FA code for",children:[jsxRuntime.jsx(E,{d:be?w.key:ae?w.alert:Ce?w.check:Te?w.copy:w.shield,size:12}),be?"Sign in":Ce?"Copied":Te?W.code:ae?"Failed":`2FA \xB7 ${a.length}`,!be&&jsxRuntime.jsx(E,{d:P?w.chevronUp:w.chevronDown,size:8})]}),st]})}function nn(e){return {display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${e}15`,color:e,textDecoration:"none",border:`1px solid ${e}30`}}var rn="botbuddy-widget-state";function Gn({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:_,version:y,commitSha:R,prNumber:f,branchName:h,onNavigate:M,displayName:A="human",defaultMode:p="mini",defaultPosition:x}){let g=On(),n=react.useMemo(()=>Hn(g),[g]),d=react.useMemo(()=>Jn(n),[n]),[k,P]=react.useState(false),[z,V]=react.useState(false),[S,W]=react.useState(false),pe=react.useRef(false),ie=e.dashboardUrl||"https://app.bot-buddy.ai",m=vt(ie),C=(()=>{try{let r=typeof window<"u"?localStorage.getItem(rn):null;if(r)return JSON.parse(r)}catch{}return null})(),[T,O]=react.useState(C?.mode||p),[G,X]=react.useState(""),[ce,re]=react.useState(null),[Re,Ne]=react.useState(null),[Le,be]=react.useState(new Set),[ae,Ce]=react.useState(""),Te=react.useCallback(r=>{be(b=>{let N=new Set(b);return N.has(r)?N.delete(r):N.add(r),N});},[]),ot=C?.x??x?.x??16,st=C?.y??x?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:u,setPos:D,onPointerDown:U,onPointerMove:L,onPointerUp:H,didDrag:Z}=pt(ot,st),Y=react.useRef(null);react.useEffect(()=>{try{localStorage.setItem(rn,JSON.stringify({mode:T,x:u.x,y:u.y}));}catch{}},[T,u.x,u.y]),react.useLayoutEffect(()=>{if(typeof window>"u")return;let r=Y.current;if(!r)return;let b=r.getBoundingClientRect(),N=ut(u.x,u.y,b.width,b.height,window.innerWidth,window.innerHeight);(N.x!==u.x||N.y!==u.y)&&D(N);}),react.useEffect(()=>{if(typeof window>"u")return;let r=()=>{let b=Y.current;if(!b)return;let N=b.getBoundingClientRect(),J=ut(u.x,u.y,N.width,N.height,window.innerWidth,window.innerHeight);(J.x!==u.x||J.y!==u.y)&&D(J);};return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[u.x,u.y,D]);let B=react.useRef(m.isAuthenticated);react.useEffect(()=>{!B.current&&m.isAuthenticated&&O("max"),B.current=m.isAuthenticated;},[m.isAuthenticated]);let I="botbuddy-widget-max-size",j=()=>{try{let r=localStorage.getItem(I);if(r)return JSON.parse(r)}catch{}return {w:340,h:500}},[oe,ke]=react.useState(j),Be=react.useRef(false),ze=react.useRef({x:0,y:0,w:0,h:0}),yn=react.useCallback(r=>{r.stopPropagation(),Be.current=true,ze.current={x:r.clientX,y:r.clientY,w:oe.w,h:oe.h},r.target.setPointerCapture(r.pointerId);},[oe]),hn=react.useCallback(r=>{if(!Be.current)return;let b=Math.max(280,Math.min(600,ze.current.w+(r.clientX-ze.current.x))),N=Math.max(300,Math.min(window.innerHeight*.9,ze.current.h+(r.clientY-ze.current.y)));ke({w:b,h:N});},[]),xn=react.useCallback(()=>{Be.current&&(Be.current=false,ke(r=>(localStorage.setItem(I,JSON.stringify(r)),r)));},[]),le=_??(typeof window<"u"?window.location.href:void 0),Mt=m.displayName||A,[ge,Pt]=react.useState(null);react.useEffect(()=>{if(m.isAuthenticated)return;let r=new URLSearchParams;l&&r.set("token",l),a&&r.set("ticket_id",a),r.set("app_slug",t),o&&r.set("environment",o),i&&r.set("test_run_id",i),le&&r.set("target_url",le),y&&r.set("version",y),R&&r.set("commit_sha",R),f&&r.set("pr_number",String(f)),h&&r.set("branch_name",h),fetch(`${e.serverUrl}/widget/preview?${r}`,{headers:{apikey:e.anonKey}}).then(b=>b.json()).then(b=>Pt(b)).catch(()=>Pt(null));},[m.isAuthenticated,e.serverUrl,e.anonKey,t,o,a,i,l,le,y,R,f,h]);let At=react.useRef(false),vn=react.useCallback(()=>{At.current||m.logout();},[m.logout]),{run:v,widgetState:Se,fetchRun:wn,setVerdict:$t,markComplete:kn,resetRun:Sn,setRun:Lt}=bt({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:le,version:y,commitSha:R,prNumber:f?String(f):void 0,branchName:h,authToken:m.token,onAuthExpired:vn});At.current=!!v;let[Bt,zt]=react.useState([]),[Ut,Ke]=react.useState([]),[it,It]=react.useState(false),[Ft,Dt]=react.useState(null),[_n,je]=react.useState(false),me=Yn(typeof window<"u"?window.location.hostname:void 0,e.productionHostnames||[]);react.useEffect(()=>{if((o??"local")!=="local"||me){zt([]);return}let r=true;return Xe().then(b=>{r&&zt(Object.keys(b||{}));}),()=>{r=false;}},[o,me]);let Rn=react.useCallback(async()=>{if(!(!m.isAuthenticated||!m.token)){It(true),Dt(null);try{let r=await fetch(`${e.serverUrl}/widget/test-runs`,{method:"POST",headers:{"Content-Type":"application/json",apikey:e.anonKey,Authorization:`Bearer ${m.token}`},body:JSON.stringify({app_slug:t,environment:o||"local",target_url:le,branch_name:h,commit_sha:R,pr_number:f,ticket_id:a,title:`${a||t} local validation`})}),b=await r.json().catch(()=>({}));if(!r.ok)throw new Error(b.error||`HTTP ${r.status}`);Lt(b),O("max");}catch(r){Dt(r.message);}finally{It(false);}}},[m.isAuthenticated,m.token,e.serverUrl,e.anonKey,t,o,le,h,R,f,a,Lt]),Ve=react.useCallback(async(r,b,N)=>{Ne(r);try{await $t(r,b,N,Mt);}finally{Ne(null),re(null),X("");}},[$t,Mt]),q=v?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},Nn=q.total>0&&q.pending===0,Ee=Se==="completed",Ye=react.useMemo(()=>{let r=v?.test_cases||[];if(!ae.trim())return r;let b=ae.toLowerCase();return r.filter(N=>N.title.toLowerCase().includes(b)||N.description&&N.description.toLowerCase().includes(b)||N.url_path&&N.url_path.toLowerCase().includes(b)||N.seed_user&&N.seed_user.toLowerCase().includes(b))},[v?.test_cases,ae]),Wt=react.useMemo(()=>{let r=Ye,b=v?.test_cases||[];if(new Set(b.map(te=>te.source_pr_number)).size<=1)return null;let J=[],he=new Map;r.forEach(te=>{let ee=te.source_pr_number;he.has(ee)||he.set(ee,[]),he.get(ee).push(te);});let qt=[...he.keys()].sort((te,ee)=>te===null?1:ee===null?-1:ee-te);for(let te of qt){let ee=he.get(te),lt={total:ee.length,pass:0,fail:0,skip:0,pending:0};ee.forEach(Gt=>{Gt.verdict in lt&<[Gt.verdict]++;}),J.push({key:te!=null?`pr-${te}`:"general",label:te!=null?`PR #${te}`:"General",cases:ee,summary:lt});}return J.filter(te=>te.cases.length>0)},[Ye,v?.test_cases]),Ot=q.total>0?(q.pass+q.fail)/q.total*100:0,Q=o??v?.environment??null,ye=react.useMemo(()=>{if(!Q||Q==="production"||me)return [];let r=v?.test_cases||[],b=new Set;for(let N of r)N.seed_user&&b.add(wt(N.seed_user));if(Q==="local")for(let N of Bt)b.add(wt(N));for(let N of Ut)b.add(wt(N));return [...b]},[v?.test_cases,Q,Bt,Ut,me]);react.useEffect(()=>{if(!Q||Q==="production"||me||!m.isAuthenticated||!m.token){Ke([]);return}let r=true,b=`${e.serverUrl}/widget/totp-seeds?${new URLSearchParams({app_slug:t,environment:Q})}`,N=J=>fetch(b,{headers:{apikey:e.anonKey,Authorization:`Bearer ${J}`}});return (async()=>{try{let J=await N(m.token);if(J.status===401&&m.refreshNow){let ee=await m.refreshNow();ee&&(J=await N(ee));}if(!r)return;if(!J.ok){Ke([]);return}let he=await J.json().catch(()=>null),te=(Array.isArray(he?.seeds)?he.seeds:[]).map(ee=>ee?.seed_user_slug).filter(ee=>typeof ee=="string"&&ee.length>0);Ke(te);}catch{r&&Ke([]);}})(),()=>{r=false;}},[Q,me,m.isAuthenticated,m.token,m.refreshNow,t,e.serverUrl,e.anonKey]);let at=react.useMemo(()=>{let r=v?.auto_tooltip_seconds??ge?.auto_tooltip_seconds;return r!=null&&r>0?r*1e3:0},[v,ge]),Ht=Se==="ready"||Se==="completed"||ge?.enabled&&ge.run;react.useEffect(()=>{if(!Ht||pe.current||at<=0)return;pe.current=true,V(true);let r=window.setTimeout(()=>V(false),at);return ()=>window.clearTimeout(r)},[Ht,at]);let Kt=r=>jsxRuntime.jsxs("div",{style:d.caseRow,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsxRuntime.jsx("div",{style:{marginTop:"2px",flexShrink:0,color:Kn[r.verdict]},children:Re===r.id?jsxRuntime.jsx(E,{d:w.loader,className:""}):jsxRuntime.jsx(E,{d:jn[r.verdict],className:""})}),jsxRuntime.jsxs("div",{style:{minWidth:0,flex:1},children:[jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.text,lineHeight:1.3},children:r.title}),r.description&&jsxRuntime.jsx("div",{style:{fontSize:"9px",color:n.gripColor,marginTop:"2px"},children:r.description}),r.seed_user&&jsxRuntime.jsxs("div",{style:{fontSize:"9px",color:n.amber,marginTop:"3px",display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",background:`${n.amber}12`,border:`1px solid ${n.amber}30`},children:[jsxRuntime.jsx(E,{d:w.key,size:10}),jsxRuntime.jsx("span",{children:r.seed_user})]}),r.url_path&&jsxRuntime.jsxs("a",{href:r.url_path,target:"_blank",rel:"noopener noreferrer",onClick:b=>{b.stopPropagation(),M&&(b.preventDefault(),M(r.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsxRuntime.jsx(E,{d:w.externalLink,size:10}),r.url_path]}),r.verdict==="fail"&&r.fail_reason&&jsxRuntime.jsxs("div",{style:{fontSize:"9px",color:n.red,marginTop:"2px"},children:["\u2717 ",r.fail_reason]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(b=>jsxRuntime.jsx("button",{onClick:()=>{if(r.verdict===b){Ve(r.id,"pending"),re(null);return}if(b==="fail"){re(r.id),X("");return}re(null),Ve(r.id,b);},disabled:Re!==null,style:d.verdictBtn(r.verdict===b,b==="pass"?n.green:b==="fail"?n.red:n.amber),children:b.toUpperCase()},b)),r.created_by_agent_name&&jsxRuntime.jsxs("span",{style:{fontSize:"8px",color:n.purple,marginLeft:"4px",display:"inline-flex",alignItems:"center",gap:"2px"},children:[jsxRuntime.jsx(E,{d:w.bot,size:8}),r.created_by_agent_name]}),r.verdict_by_display_name&&jsxRuntime.jsxs("span",{style:{fontSize:"8px",color:n.textFaint,marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:"3px"},children:[r.verdict_by_display_name,r.verdict_at&&jsxRuntime.jsx("span",{style:{opacity:.7},children:Wn(r.verdict_at)})]})]}),ce===r.id&&jsxRuntime.jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsxRuntime.jsx("input",{autoFocus:true,value:G,onChange:b=>X(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Ve(r.id,"fail",G.trim()||void 0),b.key==="Escape"&&(re(null),X(""));},placeholder:"Reason (optional)...",style:d.input}),jsxRuntime.jsx("button",{onClick:()=>{Ve(r.id,"fail",G.trim()||void 0);},style:d.verdictBtn(true,n.red),children:"\u2713"})]})]},r.id);if((Se==="no-match"||Se==="loading")&&!(!m.isAuthenticated&&ge?.enabled&&ge.run)){if(!(Q==="local"&&!me))return null}if(!m.isAuthenticated&&ge?.enabled&&ge.run){let r=ge.run,b=r.summary,N=r.status==="completed";return jsxRuntime.jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>P(true),onMouseLeave:()=>{P(false),W(false),V(false);},children:[jsxRuntime.jsxs("div",{style:{...d.pill(N),gap:"8px",padding:"5px 10px",fontSize:"10px"},onPointerDown:U,onPointerMove:L,onPointerUp:()=>{H();},children:[jsxRuntime.jsx(E,{d:w.grip,size:10,className:""}),r.ticket_id&&r.ticket_url?jsxRuntime.jsx("a",{href:r.ticket_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.amber,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:r.ticket_id}):null,r.pr_url?jsxRuntime.jsxs("a",{href:r.pr_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.blue,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:["PR#",r.pr_number??r.pr_id]}):null,r.created_by_agent_name?r.codex_thread_id?jsxRuntime.jsxs("a",{href:`codex://threads/${r.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.purple,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsxRuntime.jsx(E,{d:w.terminal,size:10}),r.created_by_agent_name]}):jsxRuntime.jsxs("span",{style:{color:n.purple,fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsxRuntime.jsx(E,{d:w.bot,size:10}),r.created_by_agent_name]}):null,jsxRuntime.jsxs("span",{style:N?{color:n.green}:void 0,children:[b.pass,"/",b.total]}),b.fail>0&&jsxRuntime.jsxs("span",{style:{color:n.red},children:[b.fail,"\u2717"]}),jsxRuntime.jsx("span",{onClick:J=>{J.stopPropagation(),m.openLogin();},style:{color:n.textMuted,fontWeight:400,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:"2px"},children:"Sign in"})]}),!S&&(k||z)&&r.title&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsxRuntime.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:r.title}),(r.description||r.intro_notes)&&jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:r.description||r.intro_notes}),jsxRuntime.jsx("div",{style:{marginTop:"4px",fontSize:"9px",color:n.textFaint},children:'Click "Sign in" to start testing'})]})]})})}if(!m.isAuthenticated)return jsxRuntime.jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y,width:220,minHeight:0,cursor:"move",userSelect:"none",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`},onPointerDown:U,onPointerMove:L,onPointerUp:H,children:[jsxRuntime.jsx("div",{style:{...d.handle,borderBottom:"none"},children:jsxRuntime.jsxs("div",{style:d.sub,children:[jsxRuntime.jsx(E,{d:w.grip,size:10,className:""}),jsxRuntime.jsx(E,{d:w.clipboard,size:12,className:""}),jsxRuntime.jsx("span",{style:{fontWeight:600},children:"BotBuddy"})]})}),jsxRuntime.jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{fontSize:"9px",color:n.textMuted,marginBottom:"8px"},children:"Sign in to access test cases"}),Q==="local"&&ye.length>0&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsxRuntime.jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"10px",fontWeight:600,padding:"6px 16px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:"pointer",width:"100%"},children:"Sign in to test"})]})]});if(!v&&Q==="local"&&!me)return _n?jsxRuntime.jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxRuntime.jsxs("div",{style:d.card(240,false),children:[jsxRuntime.jsxs("div",{style:d.handle,onPointerDown:U,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||je(false);},children:[jsxRuntime.jsx(E,{d:w.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:d.title,children:"BotBuddy"}),h&&jsxRuntime.jsx("div",{style:d.sub,children:jsxRuntime.jsxs("span",{children:["\u2387 ",h]})})]}),jsxRuntime.jsx(E,{d:w.chevronUp,className:""}),jsxRuntime.jsx("button",{style:d.btn,onClick:r=>{r.stopPropagation(),je(false);},children:jsxRuntime.jsx(E,{d:w.minus,className:""})})]}),jsxRuntime.jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[ye.length>0&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsxRuntime.jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),Rn();},disabled:it,style:{fontSize:"10px",fontWeight:600,padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:it?"wait":"pointer",width:"100%"},children:it?"Creating...":"Create test run for this branch"}),Ft&&jsxRuntime.jsx("div",{style:{fontSize:"9px",color:n.red,marginTop:"8px"},children:Ft})]})]})}):jsxRuntime.jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxRuntime.jsxs("div",{style:{...d.pill(false),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:U,onPointerMove:L,onPointerUp:()=>{H(),Z.current||je(true);},children:[jsxRuntime.jsx(E,{d:w.grip,size:9,className:""}),jsxRuntime.jsx("span",{style:{fontWeight:600},children:"BotBuddy"}),ye.length>0&&jsxRuntime.jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>je(true),testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]})});let jt=()=>{Z.current||(V(false),O(r=>{let b=r==="mini"?"max":"mini";return W(b==="mini"),b}));},Vt=({icon:r,onClick:b})=>jsxRuntime.jsx("button",{style:d.btn,onClick:N=>{N.stopPropagation(),b(N);},children:jsxRuntime.jsx(E,{d:r,className:""})}),Yt=()=>jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:`1px solid ${n.borderSubtle}`,flexShrink:0},children:[v?.pr_url&&jsxRuntime.jsxs("a",{href:v.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.blue),textDecoration:"none"},children:[jsxRuntime.jsx(E,{d:w.pr,size:12}),v.pr_number?`PR#${v.pr_number}`:v.pr_id||"PR",jsxRuntime.jsx(E,{d:w.externalLink,size:8})]}),v?.ticket_url&&jsxRuntime.jsxs("a",{href:v.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.amber),textDecoration:"none"},children:[jsxRuntime.jsx(E,{d:w.ticket,size:12}),v.ticket_id||"Ticket",jsxRuntime.jsx(E,{d:w.externalLink,size:8})]}),v?.created_by_agent_name&&(v.codex_thread_id?jsxRuntime.jsxs("a",{href:`codex://threads/${v.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.purple),textDecoration:"none"},children:[jsxRuntime.jsx(E,{d:w.bot,size:12}),v.created_by_agent_name,jsxRuntime.jsx(E,{d:w.externalLink,size:8})]}):jsxRuntime.jsxs("span",{style:{...d.link(n.purple)},children:[jsxRuntime.jsx(E,{d:w.bot,size:12}),v.created_by_agent_name]})),Q&&jsxRuntime.jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout}),jsxRuntime.jsx("span",{style:{...d.badge(v?.environment||"custom"),marginLeft:"auto"},children:v?.environment})]}),Jt=()=>jsxRuntime.jsxs("div",{style:{padding:"4px 12px",display:"flex",alignItems:"center",justifyContent:"center",borderTop:`1px solid ${n.borderSubtle}`,background:n.bgSoft,flexShrink:0},children:[jsxRuntime.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(en);},style:{fontSize:"9px",fontWeight:600,color:n.versionText,letterSpacing:"0.08em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px",padding:0},title:"Copy version",children:["BotBuddy ",jsxRuntime.jsxs("span",{style:{color:n.versionNum},children:["v",en]})]}),m.isAuthenticated&&(m.isExpired?jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"8px",color:n.blue,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Widget session expired \u2014 sign in to refresh",children:"sign in"}):jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),m.logout();},style:{fontSize:"8px",color:n.textFaint,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Sign out of widget",children:"sign out"}))]});return jsxRuntime.jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:[T==="mini"&&jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>P(true),onMouseLeave:()=>{P(false),W(false),V(false);},children:[jsxRuntime.jsxs("div",{style:{...d.pill(Ee),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:U,onPointerMove:L,onPointerUp:()=>{H(),Z.current||jt();},children:[jsxRuntime.jsx(E,{d:w.grip,size:9,className:""}),v?.ticket_id&&jsxRuntime.jsx("span",{style:{color:n.amber,fontWeight:600},children:v.ticket_id}),v?.pr_number&&jsxRuntime.jsxs("span",{style:{color:n.blue,fontWeight:600},children:["PR#",v.pr_number]}),jsxRuntime.jsxs("span",{style:Ee?{color:n.green}:void 0,children:[q.pass,"/",q.total]}),q.fail>0&&jsxRuntime.jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),Q&&jsxRuntime.jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>O("expanded"),testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]}),!S&&(k||z)&&v?.title&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsxRuntime.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:v.title}),(v.description||v.intro_notes)&&jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:v.description||v.intro_notes})]})]}),T==="expanded"&&jsxRuntime.jsxs("div",{style:d.card(300,Ee),children:[jsxRuntime.jsxs("div",{style:d.handle,onPointerDown:U,onPointerMove:L,onPointerUp:H,onClick:jt,children:[jsxRuntime.jsx(E,{d:w.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:d.title,children:v?.title}),jsxRuntime.jsx("div",{style:d.sub,children:v?.branch_name&&jsxRuntime.jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsxRuntime.jsx(E,{d:w.chevronUp,className:""}),jsxRuntime.jsx(Vt,{icon:w.minus,onClick:()=>{V(false),W(true),O("mini");}})]}),jsxRuntime.jsxs("div",{style:d.stats,children:[jsxRuntime.jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.description&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:n.gripColor,borderBottom:`1px solid ${n.borderSubtle}`,flexShrink:0},children:v.description}),Yt(),Jt(),jsxRuntime.jsx("div",{style:d.progress,children:jsxRuntime.jsx("div",{style:d.progressBar(Ot)})})]}),T==="max"&&jsxRuntime.jsxs("div",{style:{...d.card(oe.w,Ee),height:oe.h,position:"relative"},children:[jsxRuntime.jsxs("div",{style:d.handle,onPointerDown:U,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||O("expanded");},children:[jsxRuntime.jsx(E,{d:w.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:d.title,children:v?.title}),jsxRuntime.jsx("div",{style:d.sub,children:v?.branch_name&&jsxRuntime.jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsxRuntime.jsx(E,{d:w.chevronDown,className:""}),jsxRuntime.jsx(Vt,{icon:w.minus,onClick:()=>{V(false),W(true),O("mini");}})]}),jsxRuntime.jsxs("div",{style:d.stats,children:[jsxRuntime.jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.intro_notes&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",borderBottom:`1px solid ${n.borderSubtle}`,fontSize:"10px",color:n.textMuted,fontStyle:"italic",flexShrink:0},children:v.intro_notes}),(v?.test_cases||[]).length>5&&jsxRuntime.jsxs("div",{style:{padding:"4px 12px",borderBottom:`1px solid ${n.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[jsxRuntime.jsx(E,{d:w.search,size:11,className:""}),jsxRuntime.jsx("input",{value:ae,onChange:r=>Ce(r.target.value),placeholder:"Filter test cases...",style:{flex:1,fontSize:"10px",background:"transparent",border:"none",outline:"none",color:n.text,fontFamily:"monospace"}}),ae&&jsxRuntime.jsx("button",{onClick:()=>Ce(""),style:{background:"none",border:"none",cursor:"pointer",color:n.textFaint,fontSize:"10px",padding:0},children:"\u2715"})]}),Se==="error"&&jsxRuntime.jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsxRuntime.jsx(E,{d:w.alert,className:""}),jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.red},children:"Failed to load"}),jsxRuntime.jsx("button",{onClick:wn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),Ee&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:"8px",borderBottom:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg},children:[jsxRuntime.jsx(E,{d:w.checkAll,className:""}),jsxRuntime.jsx("span",{style:{fontSize:"10px",color:n.green,flex:1},children:"Run completed"}),jsxRuntime.jsx("button",{onClick:Sn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer"},children:"Reset"})]}),Se!=="error"&&jsxRuntime.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(v?.test_cases||[]).length===0?jsxRuntime.jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:"No test cases"}):Ye.length===0?jsxRuntime.jsxs("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:['No matches for "',ae,'"']}):Wt?Wt.map(r=>{let b=Le.has(r.key);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{onClick:()=>Te(r.key),style:{width:"100%",display:"flex",alignItems:"center",gap:"6px",padding:"5px 12px",background:n.bgSoft,cursor:"pointer",border:"none",borderLeft:"none",borderRight:"none",borderBottomStyle:"solid",borderTopStyle:"solid",borderBottomWidth:"1px",borderTopWidth:"1px",borderBottomColor:n.borderSubtle,borderTopColor:n.borderSubtle,backgroundColor:n.bgSoft},children:[jsxRuntime.jsx(E,{d:b?w.chevronDown:w.chevronUp,size:10,className:""}),jsxRuntime.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:n.blue,flex:1,textAlign:"left"},children:r.label}),jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:n.green},children:[r.summary.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:n.red},children:[r.summary.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:n.gripColor},children:[r.summary.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{fontSize:"9px",color:n.textFaint},children:r.summary.total})]}),!b&&r.cases.map(N=>Kt(N))]},r.key)}):Ye.map(r=>Kt(r))}),Nn&&!Ee&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",borderTop:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg,display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsxRuntime.jsx("span",{style:{fontSize:"9px",color:n.green},children:"All resolved"}),jsxRuntime.jsx("button",{onClick:kn,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(52,211,153,0.15)",color:n.green,border:`1px solid ${n.greenBorderSubtle}`,cursor:"pointer"},children:"COMPLETE"})]}),Yt(),Jt(),jsxRuntime.jsx("div",{style:d.progress,children:jsxRuntime.jsx("div",{style:d.progressBar(Ot)})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:yn,onPointerMove:hn,onPointerUp:xn,onPointerEnter:r=>r.currentTarget.style.opacity="0.7",onPointerLeave:r=>{Be.current||(r.currentTarget.style.opacity="0.3");},children:jsxRuntime.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsxRuntime.jsx("path",{d:"M7 1v6H1",fill:"none",stroke:n.gripColor,strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var er=1e4,Fe=new Map;var Ze=class extends Error{};async function tr(e,t,o){let a={headers:{authorization:`Bearer ${t}`}};try{return await fetch(e,{...a,signal:o})}catch(i){if(i instanceof TypeError&&/signal/i.test(i.message)&&!o.aborted)return fetch(e,a);throw i}}function nr(e){let t=e;return !!t&&typeof t=="object"&&typeof t.tenant=="string"&&Array.isArray(t.entries)&&t.entries.every(o=>!!o&&typeof o.id=="string"&&typeof o.title=="string"&&!!o.body&&Array.isArray(o.body.ast)&&Array.isArray(o.links))}function kt({endpoint:e,getToken:t,timeoutMs:o=er}){let[a,i]=react.useState(()=>({feed:null,error:null,loading:true,stale:false})),[l,_]=react.useState(0),y=react.useRef(t);y.current=t,react.useEffect(()=>{let f=new AbortController,h=true,M=false,A=setTimeout(()=>{M=true,f.abort();},o),p=new Promise((n,d)=>{f.signal.addEventListener("abort",()=>d(new Error("timeout")),{once:true});});p.catch(()=>{}),i(n=>({...n,error:null,loading:true}));let x=null,g=(n,d)=>{if(d&&Fe.delete(e),!h)return;let k=d||x===null?void 0:Fe.get(e)?.get(x);i({feed:k??null,error:n,loading:false,stale:!!k});};return (async()=>{try{let n;try{n=await Promise.race([Promise.resolve().then(()=>y.current()),p]);}catch(z){throw M||f.signal.aborted?z:new Ze("token_unavailable")}x=n;let d=await Promise.race([tr(e,n,f.signal),p]),k=d.status===401||d.status===403;k&&Fe.delete(e);let P=null;try{P=await Promise.race([d.json(),p]);}catch(z){if(M&&!k)throw z;P=null;}if(!h)return;if(d.ok)if(!nr(P))g("invalid_feed",!1);else {let z=Fe.get(e)??new Map;z.set(n,P),Fe.set(e,z),i({feed:P,error:null,loading:!1,stale:!1});}else {let z=P?.error;g(typeof z=="string"?z:`http_${d.status}`,k);}}catch(n){n instanceof Ze?g(n.message,true):g(M?"timeout":n instanceof Error&&n.message||"unavailable",false);}finally{clearTimeout(A);}})(),()=>{h=false,clearTimeout(A),f.abort();}},[e,l,o]);let R=react.useCallback(()=>_(f=>f+1),[]);return {...a,reload:R}}var _t=["accent","fg","bg","muted","border","radius","font"],rr={accent:"hsl(var(--primary))",fg:"hsl(var(--foreground))",bg:"hsl(var(--card))",muted:"hsl(var(--muted-foreground))",border:"hsl(var(--border))",radius:"var(--radius)",font:"inherit"},se=(e,t)=>t===void 0?`var(--bbrn-${e},var(--_bbrn-${e}))`:`var(--bbrn-${e},var(--_bbrn-${e},${t}))`,Qe=se("accent","currentColor"),St=se("muted","color-mix(in srgb,currentColor 72%,transparent)"),Ae=se("border","color-mix(in srgb,currentColor 22%,transparent)"),or=`@layer bbrn{
|
|
1
|
+
'use strict';var react=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime');var Me=8;function ut(e,t,o,a,i,l){let _=Math.max(Me,i-o-Me),y=Math.max(Me,l-a-Me);return {x:Math.min(Math.max(e,Me),_),y:Math.min(Math.max(t,Me),y)}}function pt(e,t){let[o,a]=react.useState({x:e,y:t}),i=react.useRef(false),l=react.useRef({x:0,y:0}),_=react.useRef(false),y=react.useCallback(h=>{i.current=true,_.current=false,l.current={x:h.clientX-o.x,y:h.clientY-o.y},h.target.setPointerCapture(h.pointerId);},[o]),R=react.useCallback(h=>{i.current&&(_.current=true,a({x:h.clientX-l.current.x,y:h.clientY-l.current.y}));},[]),f=react.useCallback(()=>{i.current=false;},[]);return {pos:o,setPos:a,onPointerDown:y,onPointerMove:R,onPointerUp:f,didDrag:_}}function gt(e,t,o){let a=react.useRef(o);a.current=o,react.useEffect(()=>{if(!t)return;if(e.supabaseUrl){let l=false,_=null,y=()=>{l||_||(_=setInterval(()=>a.current(),15e3));},R=null;try{let g=new URL(e.supabaseUrl),n=["localhost","127.0.0.1","::1"].includes(g.hostname);if(g.protocol==="http:"&&!n)throw new Error("Realtime WebSocket requires HTTPS outside loopback hosts");g.protocol=g.protocol==="https:"?"wss:":"ws:",R=g.toString().replace(/\/$/,"");}catch{y();}let f=null,h=null,M=null,A=0,p=()=>{if(!(l||!R)){try{f=new WebSocket(`${R}/realtime/v1/websocket?apikey=${e.anonKey}&vsn=1.0.0`);}catch{y();return}f.onopen=()=>{if(l||!f)return;let g={topic:`realtime:public:test_run_cases:test_run_id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_run_cases",filter:`test_run_id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(g));let n={topic:`realtime:public:test_runs:id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_runs",filter:`id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(n)),h=setInterval(()=>{f?.readyState===WebSocket.OPEN&&f.send(JSON.stringify({topic:"phoenix",event:"heartbeat",payload:{},ref:String(++A)}));},3e4);},f.onmessage=g=>{try{JSON.parse(g.data).event==="postgres_changes"&&a.current();}catch{}},f.onclose=()=>{x(),l||(M=setTimeout(p,3e3));},f.onerror=()=>{f?.close();};}},x=()=>{h&&(clearInterval(h),h=null);};return p(),()=>{l=true,x(),M&&clearTimeout(M),_&&clearInterval(_),f&&(f.onclose=null,f.onerror=null,f.close());}}let i=setInterval(()=>a.current(),15e3);return ()=>clearInterval(i)},[e.supabaseUrl,e.anonKey,t]);}var $n="botbuddy:created-test-run:";function An(e){if(!e)return "";try{return new URL(e).origin}catch{return e}}function Pn(e){return `${$n}${encodeURIComponent([e.appSlug,e.environment||"",e.ticketId||"",An(e.targetUrl),e.branchName||""].join("|"))}`}function qe(e,t){let o={apikey:e.anonKey};return t?o.Authorization=`Bearer ${t}`:e.apiKey?o.Authorization=`Bearer ${e.apiKey}`:o.Authorization=`Bearer ${e.anonKey}`,o}async function Ln(e){if(e)return e;try{let t=await fetch("/.botbuddy-token",{cache:"no-store"});if(t.ok){let o=(await t.text()).trim();if(o.startsWith("public_"))return o}}catch{}try{let t=undefined?.VITE_BOTBUDDY_TEST_RUN_TOKEN;if(t&&typeof t=="string"&&t.startsWith("public_"))return t}catch{}return null}function bt(e){let[t,o]=react.useState(null),[a,i]=react.useState("loading"),l=Pn(e),[_,y]=react.useState(()=>{if(e.testRunId)return e.testRunId;try{return localStorage.getItem(l)||void 0}catch{return}}),R=e.testRunId||_,f=react.useCallback(x=>{if(o(x),!!x?.id){y(x.id);try{localStorage.setItem(l,x.id);}catch{}}},[l]),h=react.useCallback(async()=>{try{let x=await Ln(e.testRunToken);if(!x&&!R){i("no-match"),o(null);return}if(x&&!e.ticketId){i("no-match"),o(null);return}let g=new URLSearchParams;x&&g.set("token",x),e.ticketId&&g.set("ticket_id",e.ticketId),g.set("app_slug",e.appSlug),e.environment&&g.set("environment",e.environment),R&&g.set("test_run_id",R),e.targetUrl&&g.set("target_url",e.targetUrl),e.version&&g.set("version",e.version),e.commitSha&&g.set("commit_sha",e.commitSha),e.prNumber&&g.set("pr_number",String(e.prNumber)),e.branchName&&g.set("branch_name",e.branchName);let n=await fetch(`${e.config.serverUrl}/widget/test-run?${g.toString()}`,{headers:qe(e.config,e.authToken)});if(n.status===404){i("no-match"),o(null);return}if(n.status===401||n.status===403){e.authToken&&e.onAuthExpired&&e.onAuthExpired(),i("error");return}if(!n.ok){i("error");return}let d=await n.json();if(!d||d.run===null){i("no-match"),o(null);return}f(d),i(d.status==="completed"?"completed":"ready");}catch{i("error");}},[e.config.serverUrl,e.config.anonKey,e.config.apiKey,e.authToken,e.appSlug,e.environment,e.ticketId,R,e.testRunToken,e.targetUrl,e.version,e.commitSha,e.branchName,e.prNumber,e.onAuthExpired,f]);return react.useEffect(()=>{h();},[h]),gt(e.config,t?.id,h),{run:t,widgetState:a,fetchRun:h,setVerdict:async(x,g,n,d="human")=>(o($=>{if(!$)return null;let z=$.test_cases.map(S=>S.id===x?{...S,verdict:g,fail_reason:g==="fail"&&n||null,verdict_by_display_name:d,verdict_at:new Date().toISOString()}:S),V={total:z.length,pending:0,pass:0,fail:0,skip:0};return z.forEach(S=>{S.verdict in V&&V[S.verdict]++;}),{...$,test_cases:z,summary:V}}),(await fetch(`${e.config.serverUrl}/widget/test-cases/${x}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",...qe(e.config,e.authToken)},body:JSON.stringify({verdict:g,fail_reason:n,display_name:d})})).ok),markComplete:async()=>t?(o(g=>g?{...g,status:"completed"}:null),i("completed"),(await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",...qe(e.config,e.authToken)}})).ok):false,resetRun:async()=>{if(!t)return false;let x=await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",...qe(e.config,e.authToken)}});return x.ok&&h(),x.ok},setRun:f}}var ht="botbuddy-widget-auth-token",xt="botbuddy-widget-auth-name";function Ue(e){if(!e)return null;try{let t=e.split(".")[1];if(!t)return null;let o=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"="),a=atob(o),i=JSON.parse(a);return typeof i.exp=="number"?i.exp*1e3:null}catch{return null}}var zn=2500,In=6e4;function vt(e){let[t,o]=react.useState(()=>{try{return localStorage.getItem(ht)}catch(p){return console.warn("Unable to read BotBuddy widget auth token",p),null}}),[a,i]=react.useState(()=>{try{return localStorage.getItem(xt)}catch(p){return console.warn("Unable to read BotBuddy widget display name",p),null}}),l=react.useRef(null),_=react.useCallback((p,x)=>{o(p),x&&i(x);try{localStorage.setItem(ht,p),x&&localStorage.setItem(xt,x);}catch(g){console.warn("Unable to persist BotBuddy widget auth token",g);}},[]);react.useEffect(()=>{let p=new URL(e).origin,x=g=>{g.origin===p&&g.data?.type==="botbuddy-widget-auth"&&g.data.token&&_(g.data.token,g.data.displayName||"human");};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[e,_]);let y=react.useCallback(()=>{if(l.current)return l.current;if(typeof window>"u"||typeof document>"u")return Promise.resolve(null);let p=new URL(e).origin,x=new URL("/widget-auth",e);x.searchParams.set("silent","1"),x.searchParams.set("origin",window.location.origin);let g=new Promise(n=>{let d=document.createElement("iframe");d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.width="1px",d.style.height="1px",d.style.opacity="0",d.style.pointerEvents="none",d.style.border="0",d.style.left="-9999px",d.style.top="-9999px",d.src=x.toString();let k=false,$=()=>{window.removeEventListener("message",z),clearTimeout(V);try{d.remove();}catch{}l.current=null;},z=S=>{if(S.origin===p){if(S.data?.type==="botbuddy-widget-auth-failed"){if(k)return;k=true,n(null),$();return}S.data?.type!=="botbuddy-widget-auth"||!S.data.token||k||(k=true,n(String(S.data.token)),$());}},V=setTimeout(()=>{k||(k=true,n(null),$());},zn);window.addEventListener("message",z),document.body.appendChild(d);});return l.current=g,g},[e]);react.useEffect(()=>{if(!t)return;let p=Ue(t);if(!p)return;let x=p-Date.now()-In,g=window.setTimeout(()=>{y();},Math.max(0,x));return ()=>window.clearTimeout(g)},[t,y]);let R=react.useCallback(()=>{let p=new URL("/widget-auth",e);p.searchParams.set("origin",window.location.origin);let x=420,g=520,n=window.screenX+(window.innerWidth-x)/2,d=window.screenY+(window.innerHeight-g)/2;window.open(p.toString(),"botbuddy-auth",`width=${x},height=${g},left=${n},top=${d},popup=yes`);},[e]),[,f]=react.useState(0);react.useEffect(()=>{let p=Ue(t);if(!p)return;let x=p-Date.now();if(x<=0)return;let g=window.setTimeout(()=>f(n=>n+1),x);return ()=>window.clearTimeout(g)},[t]);let h=react.useCallback(()=>{o(null),i(null);try{localStorage.removeItem(ht),localStorage.removeItem(xt);}catch(p){console.warn("Unable to clear BotBuddy widget auth token",p);}},[]),M=Ue(t),A=M!==null&&M<=Date.now();return {token:t,displayName:a,isAuthenticated:!!t,isExpired:A,openLogin:R,refreshNow:y,logout:h}}var Xe=null;function Un(){try{if(typeof document<"u"){let e=document.querySelector("base[href]");if(e)return new URL(".botbuddy-totp.json",e.href).toString()}}catch{}return "/.botbuddy-totp.json"}function Ze(){return Xe||(Xe=(async()=>{if(typeof fetch>"u")return null;try{let e=await fetch(Un(),{cache:"no-store"});if(!e.ok)return null;let t=await e.json();if(!t||typeof t!="object"||Array.isArray(t))return null;let o={};for(let[a,i]of Object.entries(t))typeof i=="string"&&i.length>0&&(o[a]=i);return o}catch{return null}})(),Xe)}async function Zt(e){return (await Ze())?.[e]??null}function Fn(e){let t=e.replace(/=+$/,"").replace(/\s+/g,"").toUpperCase(),o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",a=[],i=0,l=0;for(let _ of t){let y=o.indexOf(_);if(y<0)throw new Error("Invalid Base32 character in TOTP secret");l=l<<5|y,i+=5,i>=8&&(i-=8,a.push(l>>>i&255));}return Uint8Array.from(a)}async function Qt(e,t=Date.now()){if(typeof crypto>"u"||!crypto.subtle)throw new Error("Web Crypto unavailable");let o=Fn(e),a=new Uint8Array(o.byteLength);a.set(o);let i=Math.floor(t/1e3/30),l=new Uint8Array(8),_=Math.floor(i/4294967296),y=i>>>0;l[0]=_>>>24&255,l[1]=_>>>16&255,l[2]=_>>>8&255,l[3]=_&255,l[4]=y>>>24&255,l[5]=y>>>16&255,l[6]=y>>>8&255,l[7]=y&255;let R=await crypto.subtle.importKey("raw",a,{name:"HMAC",hash:"SHA-1"},false,["sign"]),f=await crypto.subtle.sign("HMAC",R,l),h=new Uint8Array(f),M=h[h.length-1]&15;return (((h[M]&127)<<24|(h[M+1]&255)<<16|(h[M+2]&255)<<8|h[M+3]&255)%1e6).toString().padStart(6,"0")}var en="0.11.0";function Dn(e){let t=new Date(e),a=Date.now()-t.getTime();if(a<6e4)return "just now";if(a<36e5)return `${Math.floor(a/6e4)}m ago`;if(a<864e5)return `${Math.floor(a/36e5)}h ago`;let i=t.getDate(),l=t.toLocaleString("en",{month:"short"}),_=t.toLocaleString("en",{hour:"numeric",minute:"2-digit",hour12:true});return `${l} ${i}, ${_}`}var E=({d:e,className:t,size:o=14})=>jsxRuntime.jsx("svg",{className:t,width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:e})}),w={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01",bot:"M12 8V4H8M2 14h2M20 14h2M15 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M9 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M18 10a6 6 0 0 0-12 0v4a6 6 0 0 0 12 0Z",terminal:"M4 17l6-6-6-6M12 19h8",key:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4",shield:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",copy:"M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2ZM5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",search:"M11 17.25a6.25 6.25 0 1 1 0-12.5 6.25 6.25 0 0 1 0 12.5ZM16 16l4.5 4.5"};function Wn(){let[e,t]=react.useState(()=>typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return react.useEffect(()=>{if(typeof window>"u")return;let o=document.documentElement,a=()=>o.classList.contains("dark")?"dark":o.classList.contains("light")?"light":null,i=a();i&&t(i);let l=window.matchMedia("(prefers-color-scheme: dark)"),_=R=>{let f=a();t(f||(R.matches?"dark":"light"));};l.addEventListener("change",_);let y=new MutationObserver(()=>{let R=a();t(R||(l.matches?"dark":"light"));});return y.observe(o,{attributes:true,attributeFilter:["class"]}),()=>{l.removeEventListener("change",_),y.disconnect();}},[]),e}function Hn(e){let t=e==="dark";return {bg:t?"rgb(30,30,30)":"rgb(255,255,255)",bgSoft:t?"rgba(255,255,255,0.02)":"rgba(0,0,0,0.02)",text:t?"#e5e5e5":"#1a1a1a",textMuted:t?"rgba(255,255,255,0.4)":"rgba(0,0,0,0.45)",textFaint:t?"#555":"#999",border:t?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)",borderSubtle:t?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",shadow:t?"rgba(0,0,0,0.4)":"rgba(0,0,0,0.12)",inputBg:t?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.04)",inputBorder:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.12)",green:"#34d399",greenBg:t?"rgba(52,211,153,0.05)":"rgba(52,211,153,0.08)",greenBorder:t?"rgba(52,211,153,0.6)":"rgba(52,211,153,0.5)",greenBorderSubtle:t?"rgba(52,211,153,0.2)":"rgba(52,211,153,0.15)",red:"#f87171",amber:"#f59e0b",blue:"#60a5fa",purple:"#a78bfa",versionText:t?"rgba(255,255,255,0.5)":"rgba(0,0,0,0.35)",versionNum:t?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",gripColor:t?"#888":"#aaa",btnHover:t?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}}var Kn={pending:"#888",pass:"#34d399",fail:"#f87171",skip:"#f59e0b"},jn={pending:w.circle,pass:w.check,fail:w.x,skip:w.skip},tn={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},Vn=["app.supply-guard.io"];function Yn(e,t=[]){if(!e)return false;let o=e.toLowerCase();return [...Vn,...t].map(i=>i.toLowerCase()).includes(o)}var Jn=e=>({root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:t=>({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:e.bg,border:t?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:t?`0 4px 12px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 4px 12px ${e.shadow}`,cursor:"pointer",fontSize:"9px",color:e.text}),card:(t,o)=>({width:`${t}px`,borderRadius:"8px",background:e.bg,border:o?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:o?`0 8px 24px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 8px 24px ${e.shadow}`,overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:`1px solid ${e.borderSubtle}`},title:{fontSize:"10px",fontWeight:600,color:e.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:e.textMuted,display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:e.gripColor,display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:`1px solid ${e.borderSubtle}`},badge:t=>{let o=tn[t]||tn.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:o.bg,color:o.text,border:`1px solid ${o.border}`,lineHeight:"14px"}},progress:{height:"2px",background:e.borderSubtle,flexShrink:0},progressBar:t=>({height:"100%",width:`${t}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:t=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${t}15`,color:t,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:`1px solid ${e.borderSubtle}`,transition:"background 0.15s"},verdictBtn:(t,o)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:t?`${o}33`:"transparent",color:t?o:e.gripColor,transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:"4px",padding:"2px 6px",color:e.text,outline:"none"},humanBanner:{padding:"6px 12px",fontSize:"11px",fontWeight:600,color:e.green,borderBottom:`1px solid ${e.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",background:e.greenBg,cursor:"pointer",textDecoration:"none"}});function wt(e){return e.split("/")[0].trim()}async function qn(e){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return !1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange(0,e.length);let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return false}}function Fe({config:e,appSlug:t,environment:o,seededUsers:a,authToken:i,tk:l,compact:_=false,onExpand:y,onAuthExpired:R,refreshAuth:f,requestLogin:h,testRunId:M,testRunToken:A,ticketId:p,targetUrl:x,version:g,commitSha:n,prNumber:d,branchName:k}){let[$,z]=react.useState(false),[V,S]=react.useState(null),[D,pe]=react.useState(null),[ie,m]=react.useState(null),[we,C]=react.useState(null),[T,W]=react.useState(null),[G,X]=react.useState(null);react.useEffect(()=>{o==="local"&&Ze();},[o]);let ce=react.useCallback(u=>{S(u),m(null),C(null),X(null);let O=Ue(i);if(o!=="local"&&h&&O!==null&&O<=Date.now()){W({slug:u,token:i||null}),X(u),S(null),h();return}let I=B=>{m(B),C(u),window.setTimeout(()=>{C(U=>U===u?null:U),m(U=>U===B?null:U);},3e3);},L=new URLSearchParams({app_slug:t,seed_user_slug:u,environment:o});M&&L.set("test_run_id",M),A&&L.set("public_token",A),p&&L.set("ticket_id",p),x&&L.set("target_url",x),g&&L.set("version",g),n&&L.set("commit_sha",n),d&&L.set("pr_number",String(d)),k&&L.set("branch_name",k);let H=async B=>{let U={apikey:e.anonKey,Authorization:`Bearer ${B}`};try{let j=await fetch(`${e.serverUrl}/widget/totp-code?${L}`,{headers:U});if(!j.ok){let ke=await j.json().catch(()=>({error:`HTTP ${j.status}`}));return {ok:!1,status:j.status,error:ke.error||`HTTP ${j.status}`}}let oe=await j.json();return {ok:!0,code:String(oe.code)}}catch{return {ok:false,status:0,error:"Network error"}}},Z=(async()=>{if(o==="local"){let j=await Zt(u);if(j)try{return {ok:!0,code:await Qt(j)}}catch{}}let B=await H(i||e.anonKey);if(B.ok||B.status!==401||!f)return B;let U=await f();return U?H(U):{ok:false,status:401,error:"Sign in to BotBuddy to refresh 2FA"}})(),Y=null;try{if(typeof ClipboardItem<"u"&&navigator.clipboard?.write){let B=Z.then(U=>{if(!U.ok)throw new Error(U.error);return new Blob([U.code],{type:"text/plain"})});Y=navigator.clipboard.write([new ClipboardItem({"text/plain":B})]).then(()=>!0).catch(()=>!1);}}catch{}(async()=>{let B=await Z;if(!B.ok){B.status===401?(W({slug:u,token:i||null}),X(u)):I(B.status===404?"No 2FA seed registered":B.error),S(null);return}let U=Y?await Y:false,j=U?true:await qn(B.code),oe=U||j;pe({slug:u,code:B.code,copied:oe}),window.setTimeout(()=>pe(ke=>ke?.slug===u?null:ke),oe?2500:6e3),z(false),S(null);})();},[e.serverUrl,e.anonKey,i,t,o,M,A,p,x,g,n,d,k,f,h]),re=react.useCallback(u=>{W({slug:u,token:i||null}),h?.();},[i,h]),Re=react.useCallback(u=>{G===u?re(u):ce(u);},[G,re,ce]);react.useEffect(()=>{if(!T||!i||i===T.token)return;let u=T.slug;W(null),ce(u);},[i,ce,T]);let Ne=react.useRef(null),Be=react.useRef(null);if(react.useLayoutEffect(()=>{if(!$)return;let u=Ne.current,O=Be.current;if(!u||!O||typeof window>"u")return;let I=()=>{let L=u.getBoundingClientRect(),H=O.getBoundingClientRect(),Z=window.innerWidth,Y=window.innerHeight,B=L.left,U=L.top-H.height-6;U<8&&(U=L.bottom+6);let j=Math.max(8,Z-H.width-8),oe=Math.max(8,Y-H.height-8);B=Math.min(Math.max(B,8),j),U=Math.min(Math.max(U,8),oe),O.style.left=`${Math.round(B)}px`,O.style.top=`${Math.round(U)}px`;};return I(),window.addEventListener("scroll",I,true),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,true),window.removeEventListener("resize",I);}},[$,a.length,ie]),react.useEffect(()=>{if(!$)return;let u=O=>{let I=O.target;Be.current?.contains(I)||Ne.current?.contains(I)||z(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[$]),a.length===0)return null;if(_){let u=a.length>1,O=a[0],I=!u&&G===O,L=j=>{if(j.stopPropagation(),u&&y){y();return}Re(O);},H=!!we,Z=!!D,Y=Z&&D.copied,B=Z&&!D.copied,U=I?l.blue:H?l.red:Y?l.green:B?l.amber:l.purple;return jsxRuntime.jsxs("span",{onPointerDown:j=>j.stopPropagation(),onPointerUp:j=>j.stopPropagation(),onPointerMove:j=>j.stopPropagation(),onClick:L,style:{display:"inline-flex",alignItems:"center",gap:"3px",color:U,fontWeight:600,cursor:"pointer",letterSpacing:B?"0.08em":void 0},title:I?"Sign in to BotBuddy to refresh 2FA":H?ie||"Failed":B?`Clipboard blocked \u2014 code: ${D.code}`:u?`${a.length} 2FA personas`:`Copy 2FA code for ${a[0]}`,children:[jsxRuntime.jsx(E,{d:I?w.key:H?w.alert:Y?w.check:B?w.copy:w.shield,size:10}),I?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Sign in"}):Y?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Copied"}):B?jsxRuntime.jsx(jsxRuntime.Fragment,{children:D.code}):H?jsxRuntime.jsx(jsxRuntime.Fragment,{children:"Failed"}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:["2FA",u&&` \xB7${a.length}`]})]})}if(a.length===1){let u=a[0],O=V===u,I=D?.slug===u,L=I&&D.copied,H=I&&!D.copied,Z=we===u,Y=G===u,B=Y?l.blue:Z?l.red:L?l.green:H?l.amber:l.purple;return jsxRuntime.jsxs("button",{onClick:U=>{U.stopPropagation(),Re(u);},disabled:O,style:{...nn(B),cursor:O?"wait":"pointer",opacity:O?.6:1},title:Y?"Sign in to BotBuddy to refresh 2FA":Z?ie||"Failed":H?`Clipboard blocked \u2014 code: ${D.code}`:`Copy 2FA code for ${u}`,children:[jsxRuntime.jsx(E,{d:Y?w.key:Z?w.alert:L?w.check:H?w.copy:w.shield,size:12}),Y?"Sign in":L?"Copied":H?D.code:Z?"Failed":O?"\u2026":`2FA \xB7 ${u}`]})}let be=!!G&&!$,ae=!!we&&!$,Ce=!!D&&D.copied,Te=!!D&&!D.copied,ot=be?l.blue:ae?l.red:Ce?l.green:Te?l.amber:l.purple,st=$&&typeof document<"u"?reactDom.createPortal(jsxRuntime.jsxs("div",{ref:Be,onPointerDown:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),style:{position:"fixed",left:-9999,top:-9999,background:l.bg,border:`1px solid ${l.border}`,borderRadius:6,boxShadow:`0 8px 24px ${l.shadow}`,padding:4,minWidth:220,maxWidth:typeof window<"u"?Math.min(420,window.innerWidth-16):420,zIndex:1e5,fontFamily:"ui-monospace, SFMono-Regular, monospace"},children:[a.map(u=>{let O=V===u,I=G===u;return jsxRuntime.jsxs("button",{onClick:L=>{L.stopPropagation(),Re(u);},disabled:O,style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 8px",background:"transparent",border:"none",borderRadius:4,cursor:O?"wait":"pointer",fontSize:"10px",color:I?l.blue:l.text,textAlign:"left",fontFamily:"ui-monospace, SFMono-Regular, monospace"},title:I?"Sign in to BotBuddy to refresh 2FA":void 0,onMouseEnter:L=>L.currentTarget.style.background=l.btnHover,onMouseLeave:L=>L.currentTarget.style.background="transparent",children:[jsxRuntime.jsx(E,{d:I?w.key:w.shield,size:10}),jsxRuntime.jsx("span",{style:{flex:1,overflowWrap:"anywhere",lineHeight:1.3},children:u}),I?jsxRuntime.jsx("span",{style:{color:l.blue,fontSize:9},children:"Sign in"}):O?jsxRuntime.jsx("span",{style:{color:l.textMuted,fontSize:9},children:"\u2026"}):null]},u)}),ie&&jsxRuntime.jsx("div",{style:{padding:"4px 8px",fontSize:9,color:l.red},children:ie})]}),document.body):null;return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{ref:Ne,onClick:u=>{if(u.stopPropagation(),be&&G){re(G);return}z(O=>!O),m(null),C(null);},style:{...nn(ot),cursor:"pointer"},title:be?"Sign in to BotBuddy to refresh 2FA":ae?ie||"Failed":Te?`Clipboard blocked \u2014 code: ${D.code}`:"Choose a persona to copy a 2FA code for",children:[jsxRuntime.jsx(E,{d:be?w.key:ae?w.alert:Ce?w.check:Te?w.copy:w.shield,size:12}),be?"Sign in":Ce?"Copied":Te?D.code:ae?"Failed":`2FA \xB7 ${a.length}`,!be&&jsxRuntime.jsx(E,{d:$?w.chevronUp:w.chevronDown,size:8})]}),st]})}function nn(e){return {display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${e}15`,color:e,textDecoration:"none",border:`1px solid ${e}30`}}var rn="botbuddy-widget-state";function Gn({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:_,version:y,commitSha:R,prNumber:f,branchName:h,onNavigate:M,displayName:A="human",defaultMode:p="mini",defaultPosition:x}){let g=Wn(),n=react.useMemo(()=>Hn(g),[g]),d=react.useMemo(()=>Jn(n),[n]),[k,$]=react.useState(false),[z,V]=react.useState(false),[S,D]=react.useState(false),pe=react.useRef(false),ie=e.dashboardUrl||"https://app.bot-buddy.ai",m=vt(ie),C=(()=>{try{let r=typeof window<"u"?localStorage.getItem(rn):null;if(r)return JSON.parse(r)}catch{}return null})(),[T,W]=react.useState(C?.mode||p),[G,X]=react.useState(""),[ce,re]=react.useState(null),[Re,Ne]=react.useState(null),[Be,be]=react.useState(new Set),[ae,Ce]=react.useState(""),Te=react.useCallback(r=>{be(b=>{let N=new Set(b);return N.has(r)?N.delete(r):N.add(r),N});},[]),ot=C?.x??x?.x??16,st=C?.y??x?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:u,setPos:O,onPointerDown:I,onPointerMove:L,onPointerUp:H,didDrag:Z}=pt(ot,st),Y=react.useRef(null);react.useEffect(()=>{try{localStorage.setItem(rn,JSON.stringify({mode:T,x:u.x,y:u.y}));}catch{}},[T,u.x,u.y]),react.useLayoutEffect(()=>{if(typeof window>"u")return;let r=Y.current;if(!r)return;let b=r.getBoundingClientRect(),N=ut(u.x,u.y,b.width,b.height,window.innerWidth,window.innerHeight);(N.x!==u.x||N.y!==u.y)&&O(N);}),react.useEffect(()=>{if(typeof window>"u")return;let r=()=>{let b=Y.current;if(!b)return;let N=b.getBoundingClientRect(),J=ut(u.x,u.y,N.width,N.height,window.innerWidth,window.innerHeight);(J.x!==u.x||J.y!==u.y)&&O(J);};return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[u.x,u.y,O]);let B=react.useRef(m.isAuthenticated);react.useEffect(()=>{!B.current&&m.isAuthenticated&&W("max"),B.current=m.isAuthenticated;},[m.isAuthenticated]);let U="botbuddy-widget-max-size",j=()=>{try{let r=localStorage.getItem(U);if(r)return JSON.parse(r)}catch{}return {w:340,h:500}},[oe,ke]=react.useState(j),ze=react.useRef(false),Ie=react.useRef({x:0,y:0,w:0,h:0}),yn=react.useCallback(r=>{r.stopPropagation(),ze.current=true,Ie.current={x:r.clientX,y:r.clientY,w:oe.w,h:oe.h},r.target.setPointerCapture(r.pointerId);},[oe]),hn=react.useCallback(r=>{if(!ze.current)return;let b=Math.max(280,Math.min(600,Ie.current.w+(r.clientX-Ie.current.x))),N=Math.max(300,Math.min(window.innerHeight*.9,Ie.current.h+(r.clientY-Ie.current.y)));ke({w:b,h:N});},[]),xn=react.useCallback(()=>{ze.current&&(ze.current=false,ke(r=>(localStorage.setItem(U,JSON.stringify(r)),r)));},[]),le=_??(typeof window<"u"?window.location.href:void 0),Mt=m.displayName||A,[ge,$t]=react.useState(null);react.useEffect(()=>{if(m.isAuthenticated)return;let r=new URLSearchParams;l&&r.set("token",l),a&&r.set("ticket_id",a),r.set("app_slug",t),o&&r.set("environment",o),i&&r.set("test_run_id",i),le&&r.set("target_url",le),y&&r.set("version",y),R&&r.set("commit_sha",R),f&&r.set("pr_number",String(f)),h&&r.set("branch_name",h),fetch(`${e.serverUrl}/widget/preview?${r}`,{headers:{apikey:e.anonKey}}).then(b=>b.json()).then(b=>$t(b)).catch(()=>$t(null));},[m.isAuthenticated,e.serverUrl,e.anonKey,t,o,a,i,l,le,y,R,f,h]);let At=react.useRef(false),vn=react.useCallback(()=>{At.current||m.logout();},[m.logout]),{run:v,widgetState:Se,fetchRun:wn,setVerdict:Pt,markComplete:kn,resetRun:Sn,setRun:Lt}=bt({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:le,version:y,commitSha:R,prNumber:f?String(f):void 0,branchName:h,authToken:m.token,onAuthExpired:vn});At.current=!!v;let[Bt,zt]=react.useState([]),[It,je]=react.useState([]),[it,Ut]=react.useState(false),[Ft,Ot]=react.useState(null),[_n,Ve]=react.useState(false),me=Yn(typeof window<"u"?window.location.hostname:void 0,e.productionHostnames||[]);react.useEffect(()=>{if((o??"local")!=="local"||me){zt([]);return}let r=true;return Ze().then(b=>{r&&zt(Object.keys(b||{}));}),()=>{r=false;}},[o,me]);let Rn=react.useCallback(async()=>{if(!(!m.isAuthenticated||!m.token)){Ut(true),Ot(null);try{let r=await fetch(`${e.serverUrl}/widget/test-runs`,{method:"POST",headers:{"Content-Type":"application/json",apikey:e.anonKey,Authorization:`Bearer ${m.token}`},body:JSON.stringify({app_slug:t,environment:o||"local",target_url:le,branch_name:h,commit_sha:R,pr_number:f,ticket_id:a,title:`${a||t} local validation`})}),b=await r.json().catch(()=>({}));if(!r.ok)throw new Error(b.error||`HTTP ${r.status}`);Lt(b),W("max");}catch(r){Ot(r.message);}finally{Ut(false);}}},[m.isAuthenticated,m.token,e.serverUrl,e.anonKey,t,o,le,h,R,f,a,Lt]),Ye=react.useCallback(async(r,b,N)=>{Ne(r);try{await Pt(r,b,N,Mt);}finally{Ne(null),re(null),X("");}},[Pt,Mt]),q=v?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},Nn=q.total>0&&q.pending===0,Ee=Se==="completed",Je=react.useMemo(()=>{let r=v?.test_cases||[];if(!ae.trim())return r;let b=ae.toLowerCase();return r.filter(N=>N.title.toLowerCase().includes(b)||N.description&&N.description.toLowerCase().includes(b)||N.url_path&&N.url_path.toLowerCase().includes(b)||N.seed_user&&N.seed_user.toLowerCase().includes(b))},[v?.test_cases,ae]),Dt=react.useMemo(()=>{let r=Je,b=v?.test_cases||[];if(new Set(b.map(te=>te.source_pr_number)).size<=1)return null;let J=[],he=new Map;r.forEach(te=>{let ee=te.source_pr_number;he.has(ee)||he.set(ee,[]),he.get(ee).push(te);});let qt=[...he.keys()].sort((te,ee)=>te===null?1:ee===null?-1:ee-te);for(let te of qt){let ee=he.get(te),lt={total:ee.length,pass:0,fail:0,skip:0,pending:0};ee.forEach(Gt=>{Gt.verdict in lt&<[Gt.verdict]++;}),J.push({key:te!=null?`pr-${te}`:"general",label:te!=null?`PR #${te}`:"General",cases:ee,summary:lt});}return J.filter(te=>te.cases.length>0)},[Je,v?.test_cases]),Wt=q.total>0?(q.pass+q.fail)/q.total*100:0,Q=o??v?.environment??null,ye=react.useMemo(()=>{if(!Q||Q==="production"||me)return [];let r=v?.test_cases||[],b=new Set;for(let N of r)N.seed_user&&b.add(wt(N.seed_user));if(Q==="local")for(let N of Bt)b.add(wt(N));for(let N of It)b.add(wt(N));return [...b]},[v?.test_cases,Q,Bt,It,me]);react.useEffect(()=>{if(!Q||Q==="production"||me||!m.isAuthenticated||!m.token){je([]);return}let r=true,b=`${e.serverUrl}/widget/totp-seeds?${new URLSearchParams({app_slug:t,environment:Q})}`,N=J=>fetch(b,{headers:{apikey:e.anonKey,Authorization:`Bearer ${J}`}});return (async()=>{try{let J=await N(m.token);if(J.status===401&&m.refreshNow){let ee=await m.refreshNow();ee&&(J=await N(ee));}if(!r)return;if(!J.ok){je([]);return}let he=await J.json().catch(()=>null),te=(Array.isArray(he?.seeds)?he.seeds:[]).map(ee=>ee?.seed_user_slug).filter(ee=>typeof ee=="string"&&ee.length>0);je(te);}catch{r&&je([]);}})(),()=>{r=false;}},[Q,me,m.isAuthenticated,m.token,m.refreshNow,t,e.serverUrl,e.anonKey]);let at=react.useMemo(()=>{let r=v?.auto_tooltip_seconds??ge?.auto_tooltip_seconds;return r!=null&&r>0?r*1e3:0},[v,ge]),Ht=Se==="ready"||Se==="completed"||ge?.enabled&&ge.run;react.useEffect(()=>{if(!Ht||pe.current||at<=0)return;pe.current=true,V(true);let r=window.setTimeout(()=>V(false),at);return ()=>window.clearTimeout(r)},[Ht,at]);let Kt=r=>jsxRuntime.jsxs("div",{style:d.caseRow,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsxRuntime.jsx("div",{style:{marginTop:"2px",flexShrink:0,color:Kn[r.verdict]},children:Re===r.id?jsxRuntime.jsx(E,{d:w.loader,className:""}):jsxRuntime.jsx(E,{d:jn[r.verdict],className:""})}),jsxRuntime.jsxs("div",{style:{minWidth:0,flex:1},children:[jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.text,lineHeight:1.3},children:r.title}),r.description&&jsxRuntime.jsx("div",{style:{fontSize:"9px",color:n.gripColor,marginTop:"2px"},children:r.description}),r.seed_user&&jsxRuntime.jsxs("div",{style:{fontSize:"9px",color:n.amber,marginTop:"3px",display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",background:`${n.amber}12`,border:`1px solid ${n.amber}30`},children:[jsxRuntime.jsx(E,{d:w.key,size:10}),jsxRuntime.jsx("span",{children:r.seed_user})]}),r.url_path&&jsxRuntime.jsxs("a",{href:r.url_path,target:"_blank",rel:"noopener noreferrer",onClick:b=>{b.stopPropagation(),M&&(b.preventDefault(),M(r.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsxRuntime.jsx(E,{d:w.externalLink,size:10}),r.url_path]}),r.verdict==="fail"&&r.fail_reason&&jsxRuntime.jsxs("div",{style:{fontSize:"9px",color:n.red,marginTop:"2px"},children:["\u2717 ",r.fail_reason]})]})]}),jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(b=>jsxRuntime.jsx("button",{onClick:()=>{if(r.verdict===b){Ye(r.id,"pending"),re(null);return}if(b==="fail"){re(r.id),X("");return}re(null),Ye(r.id,b);},disabled:Re!==null,style:d.verdictBtn(r.verdict===b,b==="pass"?n.green:b==="fail"?n.red:n.amber),children:b.toUpperCase()},b)),r.created_by_agent_name&&jsxRuntime.jsxs("span",{style:{fontSize:"8px",color:n.purple,marginLeft:"4px",display:"inline-flex",alignItems:"center",gap:"2px"},children:[jsxRuntime.jsx(E,{d:w.bot,size:8}),r.created_by_agent_name]}),r.verdict_by_display_name&&jsxRuntime.jsxs("span",{style:{fontSize:"8px",color:n.textFaint,marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:"3px"},children:[r.verdict_by_display_name,r.verdict_at&&jsxRuntime.jsx("span",{style:{opacity:.7},children:Dn(r.verdict_at)})]})]}),ce===r.id&&jsxRuntime.jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsxRuntime.jsx("input",{autoFocus:true,value:G,onChange:b=>X(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Ye(r.id,"fail",G.trim()||void 0),b.key==="Escape"&&(re(null),X(""));},placeholder:"Reason (optional)...",style:d.input}),jsxRuntime.jsx("button",{onClick:()=>{Ye(r.id,"fail",G.trim()||void 0);},style:d.verdictBtn(true,n.red),children:"\u2713"})]})]},r.id);if((Se==="no-match"||Se==="loading")&&!(!m.isAuthenticated&&ge?.enabled&&ge.run)){if(!(Q==="local"&&!me))return null}if(!m.isAuthenticated&&ge?.enabled&&ge.run){let r=ge.run,b=r.summary,N=r.status==="completed";return jsxRuntime.jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>$(true),onMouseLeave:()=>{$(false),D(false),V(false);},children:[jsxRuntime.jsxs("div",{style:{...d.pill(N),gap:"8px",padding:"5px 10px",fontSize:"10px"},onPointerDown:I,onPointerMove:L,onPointerUp:()=>{H();},children:[jsxRuntime.jsx(E,{d:w.grip,size:10,className:""}),r.ticket_id&&r.ticket_url?jsxRuntime.jsx("a",{href:r.ticket_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.amber,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:r.ticket_id}):null,r.pr_url?jsxRuntime.jsxs("a",{href:r.pr_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.blue,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:["PR#",r.pr_number??r.pr_id]}):null,r.created_by_agent_name?r.codex_thread_id?jsxRuntime.jsxs("a",{href:`codex://threads/${r.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.purple,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsxRuntime.jsx(E,{d:w.terminal,size:10}),r.created_by_agent_name]}):jsxRuntime.jsxs("span",{style:{color:n.purple,fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsxRuntime.jsx(E,{d:w.bot,size:10}),r.created_by_agent_name]}):null,jsxRuntime.jsxs("span",{style:N?{color:n.green}:void 0,children:[b.pass,"/",b.total]}),b.fail>0&&jsxRuntime.jsxs("span",{style:{color:n.red},children:[b.fail,"\u2717"]}),jsxRuntime.jsx("span",{onClick:J=>{J.stopPropagation(),m.openLogin();},style:{color:n.textMuted,fontWeight:400,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:"2px"},children:"Sign in"})]}),!S&&(k||z)&&r.title&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsxRuntime.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:r.title}),(r.description||r.intro_notes)&&jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:r.description||r.intro_notes}),jsxRuntime.jsx("div",{style:{marginTop:"4px",fontSize:"9px",color:n.textFaint},children:'Click "Sign in" to start testing'})]})]})})}if(!m.isAuthenticated)return jsxRuntime.jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y,width:220,minHeight:0,cursor:"move",userSelect:"none",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`},onPointerDown:I,onPointerMove:L,onPointerUp:H,children:[jsxRuntime.jsx("div",{style:{...d.handle,borderBottom:"none"},children:jsxRuntime.jsxs("div",{style:d.sub,children:[jsxRuntime.jsx(E,{d:w.grip,size:10,className:""}),jsxRuntime.jsx(E,{d:w.clipboard,size:12,className:""}),jsxRuntime.jsx("span",{style:{fontWeight:600},children:"BotBuddy"})]})}),jsxRuntime.jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{fontSize:"9px",color:n.textMuted,marginBottom:"8px"},children:"Sign in to access test cases"}),Q==="local"&&ye.length>0&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsxRuntime.jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"10px",fontWeight:600,padding:"6px 16px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:"pointer",width:"100%"},children:"Sign in to test"})]})]});if(!v&&Q==="local"&&!me)return _n?jsxRuntime.jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxRuntime.jsxs("div",{style:d.card(240,false),children:[jsxRuntime.jsxs("div",{style:d.handle,onPointerDown:I,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||Ve(false);},children:[jsxRuntime.jsx(E,{d:w.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:d.title,children:"BotBuddy"}),h&&jsxRuntime.jsx("div",{style:d.sub,children:jsxRuntime.jsxs("span",{children:["\u2387 ",h]})})]}),jsxRuntime.jsx(E,{d:w.chevronUp,className:""}),jsxRuntime.jsx("button",{style:d.btn,onClick:r=>{r.stopPropagation(),Ve(false);},children:jsxRuntime.jsx(E,{d:w.minus,className:""})})]}),jsxRuntime.jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[ye.length>0&&jsxRuntime.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsxRuntime.jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),Rn();},disabled:it,style:{fontSize:"10px",fontWeight:600,padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:it?"wait":"pointer",width:"100%"},children:it?"Creating...":"Create test run for this branch"}),Ft&&jsxRuntime.jsx("div",{style:{fontSize:"9px",color:n.red,marginTop:"8px"},children:Ft})]})]})}):jsxRuntime.jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxRuntime.jsxs("div",{style:{...d.pill(false),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:I,onPointerMove:L,onPointerUp:()=>{H(),Z.current||Ve(true);},children:[jsxRuntime.jsx(E,{d:w.grip,size:9,className:""}),jsxRuntime.jsx("span",{style:{fontWeight:600},children:"BotBuddy"}),ye.length>0&&jsxRuntime.jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>Ve(true),testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]})});let jt=()=>{Z.current||(V(false),W(r=>{let b=r==="mini"?"max":"mini";return D(b==="mini"),b}));},Vt=({icon:r,onClick:b})=>jsxRuntime.jsx("button",{style:d.btn,onClick:N=>{N.stopPropagation(),b(N);},children:jsxRuntime.jsx(E,{d:r,className:""})}),Yt=()=>jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:`1px solid ${n.borderSubtle}`,flexShrink:0},children:[v?.pr_url&&jsxRuntime.jsxs("a",{href:v.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.blue),textDecoration:"none"},children:[jsxRuntime.jsx(E,{d:w.pr,size:12}),v.pr_number?`PR#${v.pr_number}`:v.pr_id||"PR",jsxRuntime.jsx(E,{d:w.externalLink,size:8})]}),v?.ticket_url&&jsxRuntime.jsxs("a",{href:v.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.amber),textDecoration:"none"},children:[jsxRuntime.jsx(E,{d:w.ticket,size:12}),v.ticket_id||"Ticket",jsxRuntime.jsx(E,{d:w.externalLink,size:8})]}),v?.created_by_agent_name&&(v.codex_thread_id?jsxRuntime.jsxs("a",{href:`codex://threads/${v.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.purple),textDecoration:"none"},children:[jsxRuntime.jsx(E,{d:w.bot,size:12}),v.created_by_agent_name,jsxRuntime.jsx(E,{d:w.externalLink,size:8})]}):jsxRuntime.jsxs("span",{style:{...d.link(n.purple)},children:[jsxRuntime.jsx(E,{d:w.bot,size:12}),v.created_by_agent_name]})),Q&&jsxRuntime.jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout}),jsxRuntime.jsx("span",{style:{...d.badge(v?.environment||"custom"),marginLeft:"auto"},children:v?.environment})]}),Jt=()=>jsxRuntime.jsxs("div",{style:{padding:"4px 12px",display:"flex",alignItems:"center",justifyContent:"center",borderTop:`1px solid ${n.borderSubtle}`,background:n.bgSoft,flexShrink:0},children:[jsxRuntime.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(en);},style:{fontSize:"9px",fontWeight:600,color:n.versionText,letterSpacing:"0.08em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px",padding:0},title:"Copy version",children:["BotBuddy ",jsxRuntime.jsxs("span",{style:{color:n.versionNum},children:["v",en]})]}),m.isAuthenticated&&(m.isExpired?jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"8px",color:n.blue,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Widget session expired \u2014 sign in to refresh",children:"sign in"}):jsxRuntime.jsx("button",{onClick:r=>{r.stopPropagation(),m.logout();},style:{fontSize:"8px",color:n.textFaint,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Sign out of widget",children:"sign out"}))]});return jsxRuntime.jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:[T==="mini"&&jsxRuntime.jsxs("div",{style:{position:"relative"},onMouseEnter:()=>$(true),onMouseLeave:()=>{$(false),D(false),V(false);},children:[jsxRuntime.jsxs("div",{style:{...d.pill(Ee),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:I,onPointerMove:L,onPointerUp:()=>{H(),Z.current||jt();},children:[jsxRuntime.jsx(E,{d:w.grip,size:9,className:""}),v?.ticket_id&&jsxRuntime.jsx("span",{style:{color:n.amber,fontWeight:600},children:v.ticket_id}),v?.pr_number&&jsxRuntime.jsxs("span",{style:{color:n.blue,fontWeight:600},children:["PR#",v.pr_number]}),jsxRuntime.jsxs("span",{style:Ee?{color:n.green}:void 0,children:[q.pass,"/",q.total]}),q.fail>0&&jsxRuntime.jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),Q&&jsxRuntime.jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>W("expanded"),testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]}),!S&&(k||z)&&v?.title&&jsxRuntime.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsxRuntime.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:v.title}),(v.description||v.intro_notes)&&jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:v.description||v.intro_notes})]})]}),T==="expanded"&&jsxRuntime.jsxs("div",{style:d.card(300,Ee),children:[jsxRuntime.jsxs("div",{style:d.handle,onPointerDown:I,onPointerMove:L,onPointerUp:H,onClick:jt,children:[jsxRuntime.jsx(E,{d:w.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:d.title,children:v?.title}),jsxRuntime.jsx("div",{style:d.sub,children:v?.branch_name&&jsxRuntime.jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsxRuntime.jsx(E,{d:w.chevronUp,className:""}),jsxRuntime.jsx(Vt,{icon:w.minus,onClick:()=>{V(false),D(true),W("mini");}})]}),jsxRuntime.jsxs("div",{style:d.stats,children:[jsxRuntime.jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.description&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:n.gripColor,borderBottom:`1px solid ${n.borderSubtle}`,flexShrink:0},children:v.description}),Yt(),Jt(),jsxRuntime.jsx("div",{style:d.progress,children:jsxRuntime.jsx("div",{style:d.progressBar(Wt)})})]}),T==="max"&&jsxRuntime.jsxs("div",{style:{...d.card(oe.w,Ee),height:oe.h,position:"relative"},children:[jsxRuntime.jsxs("div",{style:d.handle,onPointerDown:I,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||W("expanded");},children:[jsxRuntime.jsx(E,{d:w.grip,className:""}),jsxRuntime.jsxs("div",{style:{flex:1,minWidth:0},children:[jsxRuntime.jsx("div",{style:d.title,children:v?.title}),jsxRuntime.jsx("div",{style:d.sub,children:v?.branch_name&&jsxRuntime.jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsxRuntime.jsx(E,{d:w.chevronDown,className:""}),jsxRuntime.jsx(Vt,{icon:w.minus,onClick:()=>{V(false),D(true),W("mini");}})]}),jsxRuntime.jsxs("div",{style:d.stats,children:[jsxRuntime.jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxRuntime.jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.intro_notes&&jsxRuntime.jsx("div",{style:{padding:"6px 12px",borderBottom:`1px solid ${n.borderSubtle}`,fontSize:"10px",color:n.textMuted,fontStyle:"italic",flexShrink:0},children:v.intro_notes}),(v?.test_cases||[]).length>5&&jsxRuntime.jsxs("div",{style:{padding:"4px 12px",borderBottom:`1px solid ${n.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[jsxRuntime.jsx(E,{d:w.search,size:11,className:""}),jsxRuntime.jsx("input",{value:ae,onChange:r=>Ce(r.target.value),placeholder:"Filter test cases...",style:{flex:1,fontSize:"10px",background:"transparent",border:"none",outline:"none",color:n.text,fontFamily:"monospace"}}),ae&&jsxRuntime.jsx("button",{onClick:()=>Ce(""),style:{background:"none",border:"none",cursor:"pointer",color:n.textFaint,fontSize:"10px",padding:0},children:"\u2715"})]}),Se==="error"&&jsxRuntime.jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsxRuntime.jsx(E,{d:w.alert,className:""}),jsxRuntime.jsx("div",{style:{fontSize:"10px",color:n.red},children:"Failed to load"}),jsxRuntime.jsx("button",{onClick:wn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),Ee&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:"8px",borderBottom:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg},children:[jsxRuntime.jsx(E,{d:w.checkAll,className:""}),jsxRuntime.jsx("span",{style:{fontSize:"10px",color:n.green,flex:1},children:"Run completed"}),jsxRuntime.jsx("button",{onClick:Sn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer"},children:"Reset"})]}),Se!=="error"&&jsxRuntime.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(v?.test_cases||[]).length===0?jsxRuntime.jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:"No test cases"}):Je.length===0?jsxRuntime.jsxs("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:['No matches for "',ae,'"']}):Dt?Dt.map(r=>{let b=Be.has(r.key);return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("button",{onClick:()=>Te(r.key),style:{width:"100%",display:"flex",alignItems:"center",gap:"6px",padding:"5px 12px",background:n.bgSoft,cursor:"pointer",border:"none",borderLeft:"none",borderRight:"none",borderBottomStyle:"solid",borderTopStyle:"solid",borderBottomWidth:"1px",borderTopWidth:"1px",borderBottomColor:n.borderSubtle,borderTopColor:n.borderSubtle,backgroundColor:n.bgSoft},children:[jsxRuntime.jsx(E,{d:b?w.chevronDown:w.chevronUp,size:10,className:""}),jsxRuntime.jsx("span",{style:{fontSize:"10px",fontWeight:700,color:n.blue,flex:1,textAlign:"left"},children:r.label}),jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:n.green},children:[r.summary.pass,"\u2713"]}),jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:n.red},children:[r.summary.fail,"\u2717"]}),jsxRuntime.jsxs("span",{style:{fontSize:"9px",color:n.gripColor},children:[r.summary.pending,"\u25CC"]}),jsxRuntime.jsx("span",{style:{fontSize:"9px",color:n.textFaint},children:r.summary.total})]}),!b&&r.cases.map(N=>Kt(N))]},r.key)}):Je.map(r=>Kt(r))}),Nn&&!Ee&&jsxRuntime.jsxs("div",{style:{padding:"6px 12px",borderTop:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg,display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsxRuntime.jsx("span",{style:{fontSize:"9px",color:n.green},children:"All resolved"}),jsxRuntime.jsx("button",{onClick:kn,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(52,211,153,0.15)",color:n.green,border:`1px solid ${n.greenBorderSubtle}`,cursor:"pointer"},children:"COMPLETE"})]}),Yt(),Jt(),jsxRuntime.jsx("div",{style:d.progress,children:jsxRuntime.jsx("div",{style:d.progressBar(Wt)})}),jsxRuntime.jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:yn,onPointerMove:hn,onPointerUp:xn,onPointerEnter:r=>r.currentTarget.style.opacity="0.7",onPointerLeave:r=>{ze.current||(r.currentTarget.style.opacity="0.3");},children:jsxRuntime.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsxRuntime.jsx("path",{d:"M7 1v6H1",fill:"none",stroke:n.gripColor,strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var er=1e4,Oe=new Map;var Qe=class extends Error{};async function tr(e,t,o){let a={headers:{authorization:`Bearer ${t}`}};try{return await fetch(e,{...a,signal:o})}catch(i){if(i instanceof TypeError&&/signal/i.test(i.message)&&!o.aborted)return fetch(e,a);throw i}}function nr(e){let t=e;return !!t&&typeof t=="object"&&typeof t.tenant=="string"&&Array.isArray(t.entries)&&t.entries.every(o=>!!o&&typeof o.id=="string"&&typeof o.title=="string"&&!!o.body&&Array.isArray(o.body.ast)&&Array.isArray(o.links))}function kt({endpoint:e,getToken:t,timeoutMs:o=er}){let[a,i]=react.useState(()=>({feed:null,error:null,loading:true,stale:false})),[l,_]=react.useState(0),y=react.useRef(t);y.current=t,react.useEffect(()=>{let f=new AbortController,h=true,M=false,A=setTimeout(()=>{M=true,f.abort();},o),p=new Promise((n,d)=>{f.signal.addEventListener("abort",()=>d(new Error("timeout")),{once:true});});p.catch(()=>{}),i(n=>({...n,error:null,loading:true}));let x=null,g=(n,d)=>{if(d&&Oe.delete(e),!h)return;let k=d||x===null?void 0:Oe.get(e)?.get(x);i({feed:k??null,error:n,loading:false,stale:!!k});};return (async()=>{try{let n;try{n=await Promise.race([Promise.resolve().then(()=>y.current()),p]);}catch(z){throw M||f.signal.aborted?z:new Qe("token_unavailable")}x=n;let d=await Promise.race([tr(e,n,f.signal),p]),k=d.status===401||d.status===403;k&&Oe.delete(e);let $=null;try{$=await Promise.race([d.json(),p]);}catch(z){if(M&&!k)throw z;$=null;}if(!h)return;if(d.ok)if(!nr($))g("invalid_feed",!1);else {let z=Oe.get(e)??new Map;z.set(n,$),Oe.set(e,z),i({feed:$,error:null,loading:!1,stale:!1});}else {let z=$?.error;g(typeof z=="string"?z:`http_${d.status}`,k);}}catch(n){n instanceof Qe?g(n.message,true):g(M?"timeout":n instanceof Error&&n.message||"unavailable",false);}finally{clearTimeout(A);}})(),()=>{h=false,clearTimeout(A),f.abort();}},[e,l,o]);let R=react.useCallback(()=>_(f=>f+1),[]);return {...a,reload:R}}var _t=["accent","fg","bg","muted","border","radius","font"],rr={accent:"hsl(var(--primary))",fg:"hsl(var(--foreground))",bg:"hsl(var(--card))",muted:"hsl(var(--muted-foreground))",border:"hsl(var(--border))",radius:"var(--radius)",font:"inherit"},se=(e,t)=>t===void 0?`var(--bbrn-${e},var(--_bbrn-${e}))`:`var(--bbrn-${e},var(--_bbrn-${e},${t}))`,et=se("accent","currentColor"),St=se("muted","color-mix(in srgb,currentColor 72%,transparent)"),Ae=se("border","color-mix(in srgb,currentColor 22%,transparent)"),or=`@layer bbrn{
|
|
2
2
|
.bbrn-root{${_t.filter(e=>e!=="font").map(e=>`--_bbrn-${e}:${rr[e]};`).join("")}display:grid;gap:12px;color:${se("fg")};font-family:var(--bbrn-font)}
|
|
3
3
|
.bbrn-root .bbrn-entry{background:${se("bg","transparent")};border:1px solid ${Ae};border-radius:${se("radius",".5rem")};padding:16px}
|
|
4
4
|
.bbrn-root .bbrn-head{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}
|
|
5
5
|
.bbrn-root .bbrn-title{font-weight:600;font-size:1rem;line-height:1.4;margin:0}
|
|
6
|
-
.bbrn-root .bbrn-badge{font-size:.75rem;line-height:1.4;color:${
|
|
6
|
+
.bbrn-root .bbrn-badge{font-size:.75rem;line-height:1.4;color:${et};border:1px solid currentColor;border-radius:999px;padding:0 8px}
|
|
7
7
|
.bbrn-root .bbrn-delivery{font-size:.75rem;line-height:1.4;border-radius:999px;padding:0 8px;background:color-mix(in srgb,${Ae} 60%,transparent)}
|
|
8
8
|
.bbrn-root .bbrn-meta,.bbrn-root .bbrn-status{color:${St};font-size:.8rem;margin:0}
|
|
9
9
|
.bbrn-root .bbrn-p{margin:.5em 0}
|
|
10
10
|
.bbrn-root .bbrn-list{margin:.5em 0;padding-left:1.25em;list-style:disc}
|
|
11
11
|
.bbrn-root .bbrn-code{font-family:ui-monospace,monospace;font-size:.85em;padding:0 4px;border-radius:4px;background:color-mix(in srgb,${Ae} 60%,transparent)}
|
|
12
12
|
.bbrn-root .bbrn-links{display:flex;gap:12px;flex-wrap:wrap;margin-top:8px;font-size:.85rem}
|
|
13
|
-
.bbrn-root .bbrn-link{color:${
|
|
13
|
+
.bbrn-root .bbrn-link{color:${et};text-decoration:underline}
|
|
14
14
|
.bbrn-root .bbrn-tags{display:flex;gap:6px;flex-wrap:wrap;margin:8px 0 0;padding:0;list-style:none}
|
|
15
15
|
.bbrn-root .bbrn-tag{font-size:.75rem;line-height:1.4;border:1px solid ${Ae};border-radius:999px;padding:0 8px;color:${St}}
|
|
16
16
|
.bbrn-root .bbrn-filters{display:flex;gap:12px;flex-wrap:wrap;align-items:center;font-size:.85rem}
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
.bbrn-root .bbrn-pager .bbrn-retry{margin-left:0}
|
|
19
19
|
.bbrn-root .bbrn-filter{display:inline-flex;gap:6px;align-items:center;color:${St}}
|
|
20
20
|
.bbrn-root .bbrn-filter select{font:inherit;color:${se("fg")};background:${se("bg","transparent")};border:1px solid ${Ae};border-radius:${se("radius",".5rem")};padding:2px 6px;max-width:16rem}
|
|
21
|
-
.bbrn-root.bbrn-whatsnew{display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;height:1.25rem;padding:0 6px;border-radius:999px;font-size:.7rem;font-weight:600;line-height:1;color:${se("bg","Canvas")};background:${
|
|
21
|
+
.bbrn-root.bbrn-whatsnew{display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;height:1.25rem;padding:0 6px;border-radius:999px;font-size:.7rem;font-weight:600;line-height:1;color:${se("bg","Canvas")};background:${et}}
|
|
22
22
|
.bbrn-root.bbrn-announcement{gap:4px;max-width:22rem;background:${se("bg","Canvas")};border:1px solid ${Ae};border-radius:${se("radius",".5rem")};padding:12px 16px;box-shadow:0 4px 16px color-mix(in srgb,currentColor 18%,transparent)}
|
|
23
23
|
.bbrn-root.bbrn-announcement .bbrn-title{font-size:.9rem}
|
|
24
24
|
.bbrn-root.bbrn-announcement .bbrn-links{margin-top:4px;align-items:center}
|
|
25
25
|
.bbrn-root.bbrn-announcement .bbrn-retry{margin-left:0}
|
|
26
|
-
.bbrn-root .bbrn-retry{margin-left:8px;text-decoration:underline;background:none;border:0;padding:0;color:${
|
|
27
|
-
}`;function De(e=typeof document>"u"?void 0:document){if(!e?.head||e.head.querySelector("style[data-bbrn-styles]"))return;let t=e.createElement("style");t.setAttribute("data-bbrn-styles",""),t.textContent=or,e.head.prepend(t);}function We(e){if(!e)return;let t={};for(let o of _t){let a=e[o];typeof a=="string"&&a.trim()&&(t[`--bbrn-${o}`]=a);}return Object.keys(t).length?t:void 0}function tt(e){if(typeof e!="string"||/[\s\\]/.test(e))return null;if(e.startsWith("/"))return e.startsWith("//")?null:{kind:"internal",href:e};try{return new URL(e).protocol==="https:"?{kind:"external",href:e}:null}catch{return null}}function et(e,t=""){return e.map((o,a)=>{let i=`${t}${a}`;switch(o.t){case "text":return o.v;case "code":return jsxRuntime.jsx("code",{className:"bbrn-code",children:o.v},i);case "strong":return jsxRuntime.jsx("strong",{children:et(o.c,`${i}.`)},i);case "em":return jsxRuntime.jsx("em",{children:et(o.c,`${i}.`)},i);default:return null}})}function dn({ast:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.map((t,o)=>t.t==="list"?jsxRuntime.jsx("ul",{className:"bbrn-list",children:t.items.map((a,i)=>jsxRuntime.jsx("li",{children:et(a)},i))},o):t.t==="p"?jsxRuntime.jsx("p",{className:"bbrn-p",children:et(t.c)},o):null)})}var F=(...e)=>e.filter(Boolean).join(" ");function ln(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toISOString().slice(0,16).replace("T"," ")} UTC`}var lr=react.useInsertionEffect??react.useLayoutEffect,Nt=class extends react.Component{constructor(){super(...arguments);this.state={failed:false,keys:this.props.resetKeys};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(o,a){return o.resetKeys.length!==a.keys.length||o.resetKeys.some((l,_)=>!Object.is(l,a.keys[_]))?{failed:false,keys:o.resetKeys}:null}componentDidCatch(){}render(){return this.state.failed?this.props.fallback:this.props.children}};function dr(e,t,o=1){let a=Object.entries(t).filter(([,i])=>i).map(([i,l])=>`tag=${encodeURIComponent(`${i}:${l}`)}`);return o>1&&a.push(`page=${o}`),a.length===0?e:`${e}${e.includes("?")?"&":"?"}${a.join("&")}`}function cr({endpoint:e,getToken:t,onNavigate:o,theme:a,classNames:i,components:l,timeoutMs:_}){lr(()=>{De();},[]);let[y,R]=react.useState({}),[f,h]=react.useState(1),M=C=>{h(1),R(C);},A=react.useMemo(()=>dr(e,y,f),[e,y,f]),{feed:p,error:x,loading:g,stale:n,reload:d}=kt({endpoint:A,getToken:t,timeoutMs:_}),[k,P]=react.useState(0),z=()=>{P(C=>C+1),d();},V=react.useMemo(()=>We(a),[a]),S=i??{},W=l?.Empty,pe=l?.Link,ie=C=>T=>{!o||T.defaultPrevented||T.button!==0||T.metaKey||T.ctrlKey||T.shiftKey||T.altKey||(T.preventDefault(),o(C));},m=Object.values(y).some(Boolean),we=jsxRuntime.jsxs("p",{className:F("bbrn-status",S.status),role:"alert","data-bbrn-error":x??"render_failed",children:["Release notes could not be loaded.",jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"}),m&&jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>M({}),children:"Clear filters"})]});return jsxRuntime.jsxs("section",{className:F("bbrn-root",S.root),style:V,"aria-label":"Release notes","aria-busy":g,"data-bbrn-audience":p?.audience,children:[g&&!p&&jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),role:"status",children:"Loading release notes\u2026"}),!g&&x&&!p&&we,n&&jsxRuntime.jsxs("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-stale":"",children:["Showing the last loaded notes; they could not be refreshed.",jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"})]}),p&&jsxRuntime.jsxs(Nt,{resetKeys:[p,W,pe,k],fallback:we,children:[p.audience==="internal"&&p.notice&&jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-notice":"production-freshness",children:p.notice}),(p.filters?.length??0)>0&&jsxRuntime.jsx("div",{className:F("bbrn-filters",S.filters),role:"group","aria-label":"Filter release notes",children:p.filters.map(C=>jsxRuntime.jsxs("label",{className:F("bbrn-filter",S.filter),"data-bbrn-filter":C.group,children:[C.label,jsxRuntime.jsxs("select",{value:y[C.group]??"",onChange:T=>{let O=T.target.value;M(G=>({...G,[C.group]:O}));},children:[jsxRuntime.jsx("option",{value:"",children:"All"}),C.values.map(T=>jsxRuntime.jsx("option",{value:T,children:T},T))]})]},C.group))}),p.entries.length===0&&m&&jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),children:"No release notes match these filters."}),p.entries.length===0&&!m&&(W?jsxRuntime.jsx(W,{}):p.audience==="external"?jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),children:"Nothing new yet."}):jsxRuntime.jsxs("p",{className:F("bbrn-status",S.status),children:["No release notes yet. Submit one with ",jsxRuntime.jsx("code",{className:"bbrn-code",children:"bb release-notes submit"}),"."]})),p.entries.map(C=>{let T="source_key"in C?C:null;return jsxRuntime.jsxs("article",{className:F("bbrn-entry",S.entry),"data-entry-id":C.id,"data-source-key":T?.source_key,children:[jsxRuntime.jsxs("div",{className:F("bbrn-head",S.head),children:[jsxRuntime.jsx("h2",{className:F("bbrn-title",S.title),children:C.title}),jsxRuntime.jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-type":C.type,children:C.type}),T&&jsxRuntime.jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-state":T.state,children:T.state_copy??T.state}),T&&jsxRuntime.jsxs("span",{className:F("bbrn-meta",S.meta),children:[T.source_key," \xB7 revision ",T.revision]}),T?.delivery_copy&&jsxRuntime.jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":T.delivery_badge,children:[T.delivery_copy,T.delivery_since&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" \xB7 since ",jsxRuntime.jsx("time",{dateTime:T.delivery_since,children:ln(T.delivery_since)})]})]}),!T&&"version"in C&&C.version&&jsxRuntime.jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":"released",children:["Released in ",C.version,C.released_at&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" \xB7 ",jsxRuntime.jsx("time",{dateTime:C.released_at,children:ln(C.released_at)})]})]})]}),jsxRuntime.jsx("div",{className:F("bbrn-body",S.body),children:jsxRuntime.jsx(dn,{ast:C.body.ast})}),(C.tags?.length??0)>0&&jsxRuntime.jsx("ul",{className:F("bbrn-tags",S.tags),"aria-label":"Tags",children:C.tags.map(O=>jsxRuntime.jsx("li",{className:F("bbrn-tag",S.tag),"data-bbrn-tag-group":O.group,title:O.label,children:O.value},`${O.group}:${O.value}`))}),C.links.length>0&&jsxRuntime.jsx("div",{className:F("bbrn-links",S.links),children:C.links.map((O,G)=>{let X=tt(O.url);if(!X)return null;let ce=F("bbrn-link",S.link),re=O.kind??null;return pe?jsxRuntime.jsx(pe,{href:X.href,external:X.kind==="external",kind:re,className:ce,onClick:X.kind==="internal"&&o?ie(X.href):void 0,children:O.name},G):X.kind==="external"?jsxRuntime.jsx("a",{className:ce,href:X.href,target:"_blank",rel:"noopener noreferrer","data-link-kind":re??void 0,children:O.name},G):jsxRuntime.jsx("a",{className:ce,href:X.href,onClick:ie(X.href),"data-link-kind":re??void 0,children:O.name},G)})})]},C.id)}),p.audience==="external"&&(p.page>1||p.next_page!==null)&&jsxRuntime.jsxs("nav",{className:F("bbrn-pager",S.pager),"aria-label":"Release note pages",children:[p.page>1&&jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.page-1),children:"Newer notes"}),p.next_page!==null&&jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.next_page),children:"Older notes"})]})]})]})}var Tt="bbrn-announcements",$e=new Map,Et=new Set;function pr(e,t){return `bbrn-announcements:${e}:${t??""}`}function gr(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1||!Array.isArray(t.seen)||!Array.isArray(t.prompted))return null;let o=a=>a.filter(i=>typeof i=="string");return {v:1,seen:o(t.seen),prompted:o(t.prompted),muted:t.muted===!0}}catch{return null}}function pn(e){if(Et.has(e)&&$e.has(e))return $e.get(e);try{let t=gr(window.localStorage.getItem(e));return t&&$e.set(e,t),t??$e.get(e)??null}catch{return $e.get(e)??null}}function gn(e,t){let o={...t,seen:t.seen.slice(-500),prompted:t.prompted.slice(-500)};$e.set(e,o);try{window.localStorage.setItem(e,JSON.stringify(o)),Et.delete(e);}catch{Et.add(e);}try{window.dispatchEvent(new CustomEvent(Tt,{detail:e}));}catch{}}var He=(e,t)=>Array.from(new Set([...e,...t]));function rt({feed:e,viewer:t}){let o=e?.announcements==="badge"||e?.announcements==="badge_and_prompt"?e.announcements:"off",a=react.useMemo(()=>o==="off"?[]:(Array.isArray(e?.announced)?e.announced:e?.entries??[]).filter(k=>!!k&&typeof k.id=="string"&&!!k.announcement),[e,o]),i=e?pr(e.tenant,t):null,[l,_]=react.useState(0);react.useEffect(()=>{if(!i)return;let k=z=>{z.detail===i&&_(V=>V+1);},P=z=>{(z.key===i||z.key===null)&&_(V=>V+1);};return window.addEventListener(Tt,k),window.addEventListener("storage",P),()=>{window.removeEventListener(Tt,k),window.removeEventListener("storage",P);}},[i]);let y=react.useMemo(()=>a.map(k=>k.id),[a]),R=react.useMemo(()=>i?pn(i):null,[i,l]),f=react.useMemo(()=>{if(!i||!e)return null;if(R)return R;let k=y.slice(1);return {v:1,seen:k,prompted:k,muted:false}},[i,e,R,y]);react.useEffect(()=>{i&&f&&!R&&gn(i,f);},[i,f,R]);let h=f?y.filter(k=>!f.seen.includes(k)).length:0,M=o==="badge_and_prompt"&&f&&!f.muted?a.find(k=>!f.prompted.includes(k.id))??null:null,A=react.useCallback(k=>{if(!i)return;let P=pn(i)??f??{v:1,seen:[],prompted:[],muted:false};gn(i,k(P));},[i,f]),p=react.useCallback(()=>A(k=>({...k,seen:He(k.seen,y)})),[A,y]),x=react.useCallback(()=>A(k=>({...k,prompted:He(k.prompted,y)})),[A,y]),g=M?.id??null,n=react.useCallback(()=>A(k=>({...k,prompted:He(k.prompted,y),seen:g?He(k.seen,[g]):k.seen})),[A,y,g]),d=react.useCallback(()=>A(k=>({...k,muted:true,prompted:He(k.prompted,y)})),[A,y]);return {mode:o,announced:a,unseenCount:h,prompt:M,markAllSeen:p,dismiss:x,act:n,mute:d}}var mn=react.useInsertionEffect??react.useLayoutEffect,fe=(...e)=>e.filter(Boolean).join(" ");function mr({feed:e,viewer:t,theme:o,classNames:a}){mn(()=>{De();},[]);let{unseenCount:i}=rt({feed:e,viewer:t}),l=react.useMemo(()=>We(o),[o]);if(i===0)return null;let _=`${i} new release note${i===1?"":"s"}`;return jsxRuntime.jsx("span",{className:fe("bbrn-root bbrn-whatsnew",a?.root),style:l,"aria-label":_,title:_,"data-bbrn-whatsnew":"",children:jsxRuntime.jsx("span",{"aria-hidden":"true",children:i})})}function yr({feed:e,viewer:t,onNavigate:o,theme:a,classNames:i,heading:l="What's new"}){mn(()=>{De();},[]);let{prompt:_,dismiss:y,act:R,mute:f}=rt({feed:e,viewer:t}),h=react.useMemo(()=>We(a),[a]);if(!_)return null;let M=_.announcement?.cta??null,A=M?tt(M.url):null,p=i??{},x=n=>{n.key==="Escape"&&(n.stopPropagation(),y());},g=n=>{A?.kind==="internal"&&o&&!n.defaultPrevented&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&(n.preventDefault(),o(A.href)),R();};return jsxRuntime.jsxs("section",{className:fe("bbrn-root bbrn-announcement",p.root),style:h,role:"status","aria-live":"polite","aria-label":l,onKeyDown:x,"data-entry-id":_.id,children:[jsxRuntime.jsx("p",{className:fe("bbrn-meta",p.meta),children:l}),jsxRuntime.jsx("p",{className:fe("bbrn-title",p.title),children:_.title}),jsxRuntime.jsxs("div",{className:fe("bbrn-links",p.links),children:[M&&A&&(A.kind==="external"?jsxRuntime.jsx("a",{className:fe("bbrn-link",p.link),href:A.href,target:"_blank",rel:"noopener noreferrer",onClick:g,children:M.label}):jsxRuntime.jsx("a",{className:fe("bbrn-link",p.link),href:A.href,onClick:g,children:M.label})),jsxRuntime.jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:y,children:"Dismiss"}),jsxRuntime.jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:f,children:"Don't show again"})]})]})}
|
|
28
|
-
exports.RELEASE_NOTES_TOKENS=_t;exports.ReleaseNoteBody=dn;exports.ReleaseNotes=cr;exports.ReleaseNotesAnnouncement=
|
|
26
|
+
.bbrn-root .bbrn-retry{margin-left:8px;text-decoration:underline;background:none;border:0;padding:0;color:${et};cursor:pointer;font:inherit}
|
|
27
|
+
}`;function De(e=typeof document>"u"?void 0:document){if(!e?.head||e.head.querySelector("style[data-bbrn-styles]"))return;let t=e.createElement("style");t.setAttribute("data-bbrn-styles",""),t.textContent=or,e.head.prepend(t);}function We(e){if(!e)return;let t={};for(let o of _t){let a=e[o];typeof a=="string"&&a.trim()&&(t[`--bbrn-${o}`]=a);}return Object.keys(t).length?t:void 0}function Pe(e){if(typeof e!="string"||/[\s\\]/.test(e))return null;if(e.startsWith("/"))return e.startsWith("//")?null:{kind:"internal",href:e};try{return new URL(e).protocol==="https:"?{kind:"external",href:e}:null}catch{return null}}function tt(e,t=""){return e.map((o,a)=>{let i=`${t}${a}`;switch(o.t){case "text":return o.v;case "code":return jsxRuntime.jsx("code",{className:"bbrn-code",children:o.v},i);case "strong":return jsxRuntime.jsx("strong",{children:tt(o.c,`${i}.`)},i);case "em":return jsxRuntime.jsx("em",{children:tt(o.c,`${i}.`)},i);default:return null}})}function dn({ast:e}){return jsxRuntime.jsx(jsxRuntime.Fragment,{children:e.map((t,o)=>t.t==="list"?jsxRuntime.jsx("ul",{className:"bbrn-list",children:t.items.map((a,i)=>jsxRuntime.jsx("li",{children:tt(a)},i))},o):t.t==="p"?jsxRuntime.jsx("p",{className:"bbrn-p",children:tt(t.c)},o):null)})}var F=(...e)=>e.filter(Boolean).join(" ");function ln(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toISOString().slice(0,16).replace("T"," ")} UTC`}var lr=react.useInsertionEffect??react.useLayoutEffect,Nt=class extends react.Component{constructor(){super(...arguments);this.state={failed:false,keys:this.props.resetKeys};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(o,a){return o.resetKeys.length!==a.keys.length||o.resetKeys.some((l,_)=>!Object.is(l,a.keys[_]))?{failed:false,keys:o.resetKeys}:null}componentDidCatch(){}render(){return this.state.failed?this.props.fallback:this.props.children}};function dr(e,t,o=1){let a=Object.entries(t).filter(([,i])=>i).map(([i,l])=>`tag=${encodeURIComponent(`${i}:${l}`)}`);return o>1&&a.push(`page=${o}`),a.length===0?e:`${e}${e.includes("?")?"&":"?"}${a.join("&")}`}function cr({endpoint:e,getToken:t,onNavigate:o,theme:a,classNames:i,components:l,timeoutMs:_}){lr(()=>{De();},[]);let[y,R]=react.useState({}),[f,h]=react.useState(1),M=C=>{h(1),R(C);},A=react.useMemo(()=>dr(e,y,f),[e,y,f]),{feed:p,error:x,loading:g,stale:n,reload:d}=kt({endpoint:A,getToken:t,timeoutMs:_}),[k,$]=react.useState(0),z=()=>{$(C=>C+1),d();},V=react.useMemo(()=>We(a),[a]),S=i??{},D=l?.Empty,pe=l?.Link,ie=C=>T=>{!o||T.defaultPrevented||T.button!==0||T.metaKey||T.ctrlKey||T.shiftKey||T.altKey||(T.preventDefault(),o(C));},m=Object.values(y).some(Boolean),we=jsxRuntime.jsxs("p",{className:F("bbrn-status",S.status),role:"alert","data-bbrn-error":x??"render_failed",children:["Release notes could not be loaded.",jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"}),m&&jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>M({}),children:"Clear filters"})]});return jsxRuntime.jsxs("section",{className:F("bbrn-root",S.root),style:V,"aria-label":"Release notes","aria-busy":g,"data-bbrn-audience":p?.audience,children:[g&&!p&&jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),role:"status",children:"Loading release notes\u2026"}),!g&&x&&!p&&we,n&&jsxRuntime.jsxs("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-stale":"",children:["Showing the last loaded notes; they could not be refreshed.",jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"})]}),p&&jsxRuntime.jsxs(Nt,{resetKeys:[p,D,pe,k],fallback:we,children:[p.audience==="internal"&&p.notice&&jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-notice":"production-freshness",children:p.notice}),(p.filters?.length??0)>0&&jsxRuntime.jsx("div",{className:F("bbrn-filters",S.filters),role:"group","aria-label":"Filter release notes",children:p.filters.map(C=>jsxRuntime.jsxs("label",{className:F("bbrn-filter",S.filter),"data-bbrn-filter":C.group,children:[C.label,jsxRuntime.jsxs("select",{value:y[C.group]??"",onChange:T=>{let W=T.target.value;M(G=>({...G,[C.group]:W}));},children:[jsxRuntime.jsx("option",{value:"",children:"All"}),C.values.map(T=>jsxRuntime.jsx("option",{value:T,children:T},T))]})]},C.group))}),p.entries.length===0&&m&&jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),children:"No release notes match these filters."}),p.entries.length===0&&!m&&(D?jsxRuntime.jsx(D,{}):p.audience==="external"?jsxRuntime.jsx("p",{className:F("bbrn-status",S.status),children:"Nothing new yet."}):jsxRuntime.jsxs("p",{className:F("bbrn-status",S.status),children:["No release notes yet. Submit one with ",jsxRuntime.jsx("code",{className:"bbrn-code",children:"bb release-notes submit"}),"."]})),p.entries.map(C=>{let T="source_key"in C?C:null;return jsxRuntime.jsxs("article",{className:F("bbrn-entry",S.entry),"data-entry-id":C.id,"data-source-key":T?.source_key,children:[jsxRuntime.jsxs("div",{className:F("bbrn-head",S.head),children:[jsxRuntime.jsx("h2",{className:F("bbrn-title",S.title),children:C.title}),jsxRuntime.jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-type":C.type,children:C.type}),T&&jsxRuntime.jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-state":T.state,children:T.state_copy??T.state}),T&&jsxRuntime.jsxs("span",{className:F("bbrn-meta",S.meta),children:[T.source_key," \xB7 revision ",T.revision]}),T?.delivery_copy&&jsxRuntime.jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":T.delivery_badge,children:[T.delivery_copy,T.delivery_since&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" \xB7 since ",jsxRuntime.jsx("time",{dateTime:T.delivery_since,children:ln(T.delivery_since)})]})]}),!T&&"version"in C&&C.version&&jsxRuntime.jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":"released",children:["Released in ",C.version,C.released_at&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[" \xB7 ",jsxRuntime.jsx("time",{dateTime:C.released_at,children:ln(C.released_at)})]})]})]}),jsxRuntime.jsx("div",{className:F("bbrn-body",S.body),children:jsxRuntime.jsx(dn,{ast:C.body.ast})}),(C.tags?.length??0)>0&&jsxRuntime.jsx("ul",{className:F("bbrn-tags",S.tags),"aria-label":"Tags",children:C.tags.map(W=>jsxRuntime.jsx("li",{className:F("bbrn-tag",S.tag),"data-bbrn-tag-group":W.group,title:W.label,children:W.value},`${W.group}:${W.value}`))}),C.links.length>0&&jsxRuntime.jsx("div",{className:F("bbrn-links",S.links),children:C.links.map((W,G)=>{let X=Pe(W.url);if(!X)return null;let ce=F("bbrn-link",S.link),re=W.kind??null;return pe?jsxRuntime.jsx(pe,{href:X.href,external:X.kind==="external",kind:re,className:ce,onClick:X.kind==="internal"&&o?ie(X.href):void 0,children:W.name},G):X.kind==="external"?jsxRuntime.jsx("a",{className:ce,href:X.href,target:"_blank",rel:"noopener noreferrer","data-link-kind":re??void 0,children:W.name},G):jsxRuntime.jsx("a",{className:ce,href:X.href,onClick:ie(X.href),"data-link-kind":re??void 0,children:W.name},G)})})]},C.id)}),p.audience==="external"&&(p.page>1||p.next_page!==null)&&jsxRuntime.jsxs("nav",{className:F("bbrn-pager",S.pager),"aria-label":"Release note pages",children:[p.page>1&&jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.page-1),children:"Newer notes"}),p.next_page!==null&&jsxRuntime.jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.next_page),children:"Older notes"})]})]})]})}var ur=/^https:\/\/[^/?#\s\\*]+\/?$/;function pr(e,t){let o=Pe(e);if(!o)return null;if(o.kind==="external")return {href:o.href,external:true};if(t.inHostApp)return {href:o.href,external:false};let a=t.appOrigin;if(typeof a!="string"||!ur.test(a))return null;let i=a.replace(/\/$/,"");return t.currentOrigin&&i===t.currentOrigin?{href:o.href,external:false}:{href:`${i}${o.href}`,external:true}}var Tt="bbrn-announcements",Le=new Map,Et=new Set;function fr(e,t){return `bbrn-announcements:${e}:${t??""}`}function br(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1||!Array.isArray(t.seen)||!Array.isArray(t.prompted))return null;let o=a=>a.filter(i=>typeof i=="string");return {v:1,seen:o(t.seen),prompted:o(t.prompted),muted:t.muted===!0}}catch{return null}}function pn(e){if(Et.has(e)&&Le.has(e))return Le.get(e);try{let t=br(window.localStorage.getItem(e));return t&&Le.set(e,t),t??Le.get(e)??null}catch{return Le.get(e)??null}}function gn(e,t){let o={...t,seen:t.seen.slice(-500),prompted:t.prompted.slice(-500)};Le.set(e,o);try{window.localStorage.setItem(e,JSON.stringify(o)),Et.delete(e);}catch{Et.add(e);}try{window.dispatchEvent(new CustomEvent(Tt,{detail:e}));}catch{}}var Ke=(e,t)=>Array.from(new Set([...e,...t]));function rt({feed:e,viewer:t}){let o=e?.announcements==="badge"||e?.announcements==="badge_and_prompt"?e.announcements:"off",a=react.useMemo(()=>o==="off"?[]:(Array.isArray(e?.announced)?e.announced:e?.entries??[]).filter(k=>!!k&&typeof k.id=="string"&&!!k.announcement),[e,o]),i=e?fr(e.tenant,t):null,[l,_]=react.useState(0);react.useEffect(()=>{if(!i)return;let k=z=>{z.detail===i&&_(V=>V+1);},$=z=>{(z.key===i||z.key===null)&&_(V=>V+1);};return window.addEventListener(Tt,k),window.addEventListener("storage",$),()=>{window.removeEventListener(Tt,k),window.removeEventListener("storage",$);}},[i]);let y=react.useMemo(()=>a.map(k=>k.id),[a]),R=react.useMemo(()=>i?pn(i):null,[i,l]),f=react.useMemo(()=>{if(!i||!e)return null;if(R)return R;let k=y.slice(1);return {v:1,seen:k,prompted:k,muted:false}},[i,e,R,y]);react.useEffect(()=>{i&&f&&!R&&gn(i,f);},[i,f,R]);let h=f?y.filter(k=>!f.seen.includes(k)).length:0,M=o==="badge_and_prompt"&&f&&!f.muted?a.find(k=>!f.prompted.includes(k.id))??null:null,A=react.useCallback(k=>{if(!i)return;let $=pn(i)??f??{v:1,seen:[],prompted:[],muted:false};gn(i,k($));},[i,f]),p=react.useCallback(()=>A(k=>({...k,seen:Ke(k.seen,y)})),[A,y]),x=react.useCallback(()=>A(k=>({...k,prompted:Ke(k.prompted,y)})),[A,y]),g=M?.id??null,n=react.useCallback(()=>A(k=>({...k,prompted:Ke(k.prompted,y),seen:g?Ke(k.seen,[g]):k.seen})),[A,y,g]),d=react.useCallback(()=>A(k=>({...k,muted:true,prompted:Ke(k.prompted,y)})),[A,y]);return {mode:o,announced:a,unseenCount:h,prompt:M,markAllSeen:p,dismiss:x,act:n,mute:d}}var mn=react.useInsertionEffect??react.useLayoutEffect,fe=(...e)=>e.filter(Boolean).join(" ");function hr({feed:e,viewer:t,theme:o,classNames:a}){mn(()=>{De();},[]);let{unseenCount:i}=rt({feed:e,viewer:t}),l=react.useMemo(()=>We(o),[o]);if(i===0)return null;let _=`${i} new release note${i===1?"":"s"}`;return jsxRuntime.jsx("span",{className:fe("bbrn-root bbrn-whatsnew",a?.root),style:l,"aria-label":_,title:_,"data-bbrn-whatsnew":"",children:jsxRuntime.jsx("span",{"aria-hidden":"true",children:i})})}function xr({feed:e,viewer:t,onNavigate:o,theme:a,classNames:i,heading:l="What's new"}){mn(()=>{De();},[]);let{prompt:_,dismiss:y,act:R,mute:f}=rt({feed:e,viewer:t}),h=react.useMemo(()=>We(a),[a]);if(!_)return null;let M=_.announcement?.cta??null,A=M?Pe(M.url):null,p=i??{},x=n=>{n.key==="Escape"&&(n.stopPropagation(),y());},g=n=>{A?.kind==="internal"&&o&&!n.defaultPrevented&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&(n.preventDefault(),o(A.href)),R();};return jsxRuntime.jsxs("section",{className:fe("bbrn-root bbrn-announcement",p.root),style:h,role:"status","aria-live":"polite","aria-label":l,onKeyDown:x,"data-entry-id":_.id,children:[jsxRuntime.jsx("p",{className:fe("bbrn-meta",p.meta),children:l}),jsxRuntime.jsx("p",{className:fe("bbrn-title",p.title),children:_.title}),jsxRuntime.jsxs("div",{className:fe("bbrn-links",p.links),children:[M&&A&&(A.kind==="external"?jsxRuntime.jsx("a",{className:fe("bbrn-link",p.link),href:A.href,target:"_blank",rel:"noopener noreferrer",onClick:g,children:M.label}):jsxRuntime.jsx("a",{className:fe("bbrn-link",p.link),href:A.href,onClick:g,children:M.label})),jsxRuntime.jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:y,children:"Dismiss"}),jsxRuntime.jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:f,children:"Don't show again"})]})]})}
|
|
28
|
+
exports.RELEASE_NOTES_TOKENS=_t;exports.ReleaseNoteBody=dn;exports.ReleaseNotes=cr;exports.ReleaseNotesAnnouncement=xr;exports.ReleaseNotesBadge=hr;exports.TestRunWidget=Gn;exports.findItLink=pr;exports.safeHref=Pe;exports.useDraggable=pt;exports.useRealtimeRefresh=gt;exports.useReleaseNoteAnnouncements=rt;exports.useReleaseNotes=kt;exports.useTestRun=bt;exports.useWidgetAuth=vt;
|
package/dist/index.d.cts
CHANGED
|
@@ -305,6 +305,21 @@ declare function ReleaseNoteBody({ ast }: {
|
|
|
305
305
|
}): react_jsx_runtime.JSX.Element;
|
|
306
306
|
declare function ReleaseNotes({ endpoint, getToken, onNavigate, theme, classNames, components, timeoutMs }: ReleaseNotesProps): react_jsx_runtime.JSX.Element;
|
|
307
307
|
|
|
308
|
+
interface FindItLinkOptions {
|
|
309
|
+
/** The tenant's one production origin (https://host), or null when it has none or several. */
|
|
310
|
+
appOrigin?: string | null;
|
|
311
|
+
/** The origin of the page rendering the link; an app path on the same origin opens in place. */
|
|
312
|
+
currentOrigin?: string | null;
|
|
313
|
+
/** Rendered inside the tenant's own app (the embed): an app path is a relative link. */
|
|
314
|
+
inHostApp?: boolean;
|
|
315
|
+
}
|
|
316
|
+
interface FindItLink {
|
|
317
|
+
href: string;
|
|
318
|
+
/** true → open in a new tab (another site or another app). */
|
|
319
|
+
external: boolean;
|
|
320
|
+
}
|
|
321
|
+
declare function findItLink(findIt: string, options: FindItLinkOptions): FindItLink | null;
|
|
322
|
+
|
|
308
323
|
interface CommonProps {
|
|
309
324
|
/** The customers' feed the host already loaded (null while loading). */
|
|
310
325
|
feed: ReleaseNoteAnnouncementsFeed | null | undefined;
|
|
@@ -452,4 +467,4 @@ declare function useReleaseNoteAnnouncements({ feed, viewer }: UseReleaseNoteAnn
|
|
|
452
467
|
|
|
453
468
|
declare const RELEASE_NOTES_TOKENS: readonly ReleaseNotesToken[];
|
|
454
469
|
|
|
455
|
-
export { type BotBuddyConfig, RELEASE_NOTES_TOKENS, type ReleaseNoteAnnouncement, type ReleaseNoteAnnouncementEntry, type ReleaseNoteAnnouncementMode, type ReleaseNoteAnnouncementsFeed, type ReleaseNoteBlock, ReleaseNoteBody, type ReleaseNoteBody$1 as ReleaseNoteBodyData, type ReleaseNoteEntry, type ReleaseNoteExternalEntry, type ReleaseNoteFilter, type ReleaseNoteInline, type ReleaseNoteLink, type ReleaseNoteLinkProps, type ReleaseNoteTag, ReleaseNotes, ReleaseNotesAnnouncement, type ReleaseNotesAnnouncementProps, ReleaseNotesBadge, type ReleaseNotesBadgeProps, type ReleaseNotesClassNames, type ReleaseNotesComponents, type ReleaseNotesFeed, type ReleaseNotesProps, type ReleaseNotesSlot, type ReleaseNotesTheme, type ReleaseNotesToken, type TestCase, type TestRun, type TestRunSummary, TestRunWidget, type TestRunWidgetProps, type UseReleaseNoteAnnouncementsOptions, type UseReleaseNoteAnnouncementsState, type UseReleaseNotesOptions, type UseReleaseNotesState, type Verdict, type WidgetMode, type WidgetState, safeHref, useDraggable, useRealtimeRefresh, useReleaseNoteAnnouncements, useReleaseNotes, useTestRun, useWidgetAuth };
|
|
470
|
+
export { type BotBuddyConfig, type FindItLink, type FindItLinkOptions, RELEASE_NOTES_TOKENS, type ReleaseNoteAnnouncement, type ReleaseNoteAnnouncementEntry, type ReleaseNoteAnnouncementMode, type ReleaseNoteAnnouncementsFeed, type ReleaseNoteBlock, ReleaseNoteBody, type ReleaseNoteBody$1 as ReleaseNoteBodyData, type ReleaseNoteEntry, type ReleaseNoteExternalEntry, type ReleaseNoteFilter, type ReleaseNoteInline, type ReleaseNoteLink, type ReleaseNoteLinkProps, type ReleaseNoteTag, ReleaseNotes, ReleaseNotesAnnouncement, type ReleaseNotesAnnouncementProps, ReleaseNotesBadge, type ReleaseNotesBadgeProps, type ReleaseNotesClassNames, type ReleaseNotesComponents, type ReleaseNotesFeed, type ReleaseNotesProps, type ReleaseNotesSlot, type ReleaseNotesTheme, type ReleaseNotesToken, type TestCase, type TestRun, type TestRunSummary, TestRunWidget, type TestRunWidgetProps, type UseReleaseNoteAnnouncementsOptions, type UseReleaseNoteAnnouncementsState, type UseReleaseNotesOptions, type UseReleaseNotesState, type Verdict, type WidgetMode, type WidgetState, findItLink, safeHref, useDraggable, useRealtimeRefresh, useReleaseNoteAnnouncements, useReleaseNotes, useTestRun, useWidgetAuth };
|
package/dist/index.d.ts
CHANGED
|
@@ -305,6 +305,21 @@ declare function ReleaseNoteBody({ ast }: {
|
|
|
305
305
|
}): react_jsx_runtime.JSX.Element;
|
|
306
306
|
declare function ReleaseNotes({ endpoint, getToken, onNavigate, theme, classNames, components, timeoutMs }: ReleaseNotesProps): react_jsx_runtime.JSX.Element;
|
|
307
307
|
|
|
308
|
+
interface FindItLinkOptions {
|
|
309
|
+
/** The tenant's one production origin (https://host), or null when it has none or several. */
|
|
310
|
+
appOrigin?: string | null;
|
|
311
|
+
/** The origin of the page rendering the link; an app path on the same origin opens in place. */
|
|
312
|
+
currentOrigin?: string | null;
|
|
313
|
+
/** Rendered inside the tenant's own app (the embed): an app path is a relative link. */
|
|
314
|
+
inHostApp?: boolean;
|
|
315
|
+
}
|
|
316
|
+
interface FindItLink {
|
|
317
|
+
href: string;
|
|
318
|
+
/** true → open in a new tab (another site or another app). */
|
|
319
|
+
external: boolean;
|
|
320
|
+
}
|
|
321
|
+
declare function findItLink(findIt: string, options: FindItLinkOptions): FindItLink | null;
|
|
322
|
+
|
|
308
323
|
interface CommonProps {
|
|
309
324
|
/** The customers' feed the host already loaded (null while loading). */
|
|
310
325
|
feed: ReleaseNoteAnnouncementsFeed | null | undefined;
|
|
@@ -452,4 +467,4 @@ declare function useReleaseNoteAnnouncements({ feed, viewer }: UseReleaseNoteAnn
|
|
|
452
467
|
|
|
453
468
|
declare const RELEASE_NOTES_TOKENS: readonly ReleaseNotesToken[];
|
|
454
469
|
|
|
455
|
-
export { type BotBuddyConfig, RELEASE_NOTES_TOKENS, type ReleaseNoteAnnouncement, type ReleaseNoteAnnouncementEntry, type ReleaseNoteAnnouncementMode, type ReleaseNoteAnnouncementsFeed, type ReleaseNoteBlock, ReleaseNoteBody, type ReleaseNoteBody$1 as ReleaseNoteBodyData, type ReleaseNoteEntry, type ReleaseNoteExternalEntry, type ReleaseNoteFilter, type ReleaseNoteInline, type ReleaseNoteLink, type ReleaseNoteLinkProps, type ReleaseNoteTag, ReleaseNotes, ReleaseNotesAnnouncement, type ReleaseNotesAnnouncementProps, ReleaseNotesBadge, type ReleaseNotesBadgeProps, type ReleaseNotesClassNames, type ReleaseNotesComponents, type ReleaseNotesFeed, type ReleaseNotesProps, type ReleaseNotesSlot, type ReleaseNotesTheme, type ReleaseNotesToken, type TestCase, type TestRun, type TestRunSummary, TestRunWidget, type TestRunWidgetProps, type UseReleaseNoteAnnouncementsOptions, type UseReleaseNoteAnnouncementsState, type UseReleaseNotesOptions, type UseReleaseNotesState, type Verdict, type WidgetMode, type WidgetState, safeHref, useDraggable, useRealtimeRefresh, useReleaseNoteAnnouncements, useReleaseNotes, useTestRun, useWidgetAuth };
|
|
470
|
+
export { type BotBuddyConfig, type FindItLink, type FindItLinkOptions, RELEASE_NOTES_TOKENS, type ReleaseNoteAnnouncement, type ReleaseNoteAnnouncementEntry, type ReleaseNoteAnnouncementMode, type ReleaseNoteAnnouncementsFeed, type ReleaseNoteBlock, ReleaseNoteBody, type ReleaseNoteBody$1 as ReleaseNoteBodyData, type ReleaseNoteEntry, type ReleaseNoteExternalEntry, type ReleaseNoteFilter, type ReleaseNoteInline, type ReleaseNoteLink, type ReleaseNoteLinkProps, type ReleaseNoteTag, ReleaseNotes, ReleaseNotesAnnouncement, type ReleaseNotesAnnouncementProps, ReleaseNotesBadge, type ReleaseNotesBadgeProps, type ReleaseNotesClassNames, type ReleaseNotesComponents, type ReleaseNotesFeed, type ReleaseNotesProps, type ReleaseNotesSlot, type ReleaseNotesTheme, type ReleaseNotesToken, type TestCase, type TestRun, type TestRunSummary, TestRunWidget, type TestRunWidgetProps, type UseReleaseNoteAnnouncementsOptions, type UseReleaseNoteAnnouncementsState, type UseReleaseNotesOptions, type UseReleaseNotesState, type Verdict, type WidgetMode, type WidgetState, findItLink, safeHref, useDraggable, useRealtimeRefresh, useReleaseNoteAnnouncements, useReleaseNotes, useTestRun, useWidgetAuth };
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {useState,useRef,useCallback,useEffect,useMemo,useLayoutEffect,useInsertionEffect,Component}from'react';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Me=8;function ut(e,t,o,a,i,l){let _=Math.max(Me,i-o-Me),y=Math.max(Me,l-a-Me);return {x:Math.min(Math.max(e,Me),_),y:Math.min(Math.max(t,Me),y)}}function pt(e,t){let[o,a]=useState({x:e,y:t}),i=useRef(false),l=useRef({x:0,y:0}),_=useRef(false),y=useCallback(h=>{i.current=true,_.current=false,l.current={x:h.clientX-o.x,y:h.clientY-o.y},h.target.setPointerCapture(h.pointerId);},[o]),R=useCallback(h=>{i.current&&(_.current=true,a({x:h.clientX-l.current.x,y:h.clientY-l.current.y}));},[]),f=useCallback(()=>{i.current=false;},[]);return {pos:o,setPos:a,onPointerDown:y,onPointerMove:R,onPointerUp:f,didDrag:_}}function gt(e,t,o){let a=useRef(o);a.current=o,useEffect(()=>{if(!t)return;if(e.supabaseUrl){let l=false,_=null,y=()=>{l||_||(_=setInterval(()=>a.current(),15e3));},R=null;try{let g=new URL(e.supabaseUrl),n=["localhost","127.0.0.1","::1"].includes(g.hostname);if(g.protocol==="http:"&&!n)throw new Error("Realtime WebSocket requires HTTPS outside loopback hosts");g.protocol=g.protocol==="https:"?"wss:":"ws:",R=g.toString().replace(/\/$/,"");}catch{y();}let f=null,h=null,M=null,A=0,p=()=>{if(!(l||!R)){try{f=new WebSocket(`${R}/realtime/v1/websocket?apikey=${e.anonKey}&vsn=1.0.0`);}catch{y();return}f.onopen=()=>{if(l||!f)return;let g={topic:`realtime:public:test_run_cases:test_run_id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_run_cases",filter:`test_run_id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(g));let n={topic:`realtime:public:test_runs:id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_runs",filter:`id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(n)),h=setInterval(()=>{f?.readyState===WebSocket.OPEN&&f.send(JSON.stringify({topic:"phoenix",event:"heartbeat",payload:{},ref:String(++A)}));},3e4);},f.onmessage=g=>{try{JSON.parse(g.data).event==="postgres_changes"&&a.current();}catch{}},f.onclose=()=>{x(),l||(M=setTimeout(p,3e3));},f.onerror=()=>{f?.close();};}},x=()=>{h&&(clearInterval(h),h=null);};return p(),()=>{l=true,x(),M&&clearTimeout(M),_&&clearInterval(_),f&&(f.onclose=null,f.onerror=null,f.close());}}let i=setInterval(()=>a.current(),15e3);return ()=>clearInterval(i)},[e.supabaseUrl,e.anonKey,t]);}var Pn="botbuddy:created-test-run:";function An(e){if(!e)return "";try{return new URL(e).origin}catch{return e}}function $n(e){return `${Pn}${encodeURIComponent([e.appSlug,e.environment||"",e.ticketId||"",An(e.targetUrl),e.branchName||""].join("|"))}`}function Je(e,t){let o={apikey:e.anonKey};return t?o.Authorization=`Bearer ${t}`:e.apiKey?o.Authorization=`Bearer ${e.apiKey}`:o.Authorization=`Bearer ${e.anonKey}`,o}async function Ln(e){if(e)return e;try{let t=await fetch("/.botbuddy-token",{cache:"no-store"});if(t.ok){let o=(await t.text()).trim();if(o.startsWith("public_"))return o}}catch{}try{let t=import.meta?.env?.VITE_BOTBUDDY_TEST_RUN_TOKEN;if(t&&typeof t=="string"&&t.startsWith("public_"))return t}catch{}return null}function bt(e){let[t,o]=useState(null),[a,i]=useState("loading"),l=$n(e),[_,y]=useState(()=>{if(e.testRunId)return e.testRunId;try{return localStorage.getItem(l)||void 0}catch{return}}),R=e.testRunId||_,f=useCallback(x=>{if(o(x),!!x?.id){y(x.id);try{localStorage.setItem(l,x.id);}catch{}}},[l]),h=useCallback(async()=>{try{let x=await Ln(e.testRunToken);if(!x&&!R){i("no-match"),o(null);return}if(x&&!e.ticketId){i("no-match"),o(null);return}let g=new URLSearchParams;x&&g.set("token",x),e.ticketId&&g.set("ticket_id",e.ticketId),g.set("app_slug",e.appSlug),e.environment&&g.set("environment",e.environment),R&&g.set("test_run_id",R),e.targetUrl&&g.set("target_url",e.targetUrl),e.version&&g.set("version",e.version),e.commitSha&&g.set("commit_sha",e.commitSha),e.prNumber&&g.set("pr_number",String(e.prNumber)),e.branchName&&g.set("branch_name",e.branchName);let n=await fetch(`${e.config.serverUrl}/widget/test-run?${g.toString()}`,{headers:Je(e.config,e.authToken)});if(n.status===404){i("no-match"),o(null);return}if(n.status===401||n.status===403){e.authToken&&e.onAuthExpired&&e.onAuthExpired(),i("error");return}if(!n.ok){i("error");return}let d=await n.json();if(!d||d.run===null){i("no-match"),o(null);return}f(d),i(d.status==="completed"?"completed":"ready");}catch{i("error");}},[e.config.serverUrl,e.config.anonKey,e.config.apiKey,e.authToken,e.appSlug,e.environment,e.ticketId,R,e.testRunToken,e.targetUrl,e.version,e.commitSha,e.branchName,e.prNumber,e.onAuthExpired,f]);return useEffect(()=>{h();},[h]),gt(e.config,t?.id,h),{run:t,widgetState:a,fetchRun:h,setVerdict:async(x,g,n,d="human")=>(o(P=>{if(!P)return null;let z=P.test_cases.map(S=>S.id===x?{...S,verdict:g,fail_reason:g==="fail"&&n||null,verdict_by_display_name:d,verdict_at:new Date().toISOString()}:S),V={total:z.length,pending:0,pass:0,fail:0,skip:0};return z.forEach(S=>{S.verdict in V&&V[S.verdict]++;}),{...P,test_cases:z,summary:V}}),(await fetch(`${e.config.serverUrl}/widget/test-cases/${x}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",...Je(e.config,e.authToken)},body:JSON.stringify({verdict:g,fail_reason:n,display_name:d})})).ok),markComplete:async()=>t?(o(g=>g?{...g,status:"completed"}:null),i("completed"),(await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",...Je(e.config,e.authToken)}})).ok):false,resetRun:async()=>{if(!t)return false;let x=await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",...Je(e.config,e.authToken)}});return x.ok&&h(),x.ok},setRun:f}}var ht="botbuddy-widget-auth-token",xt="botbuddy-widget-auth-name";function Ue(e){if(!e)return null;try{let t=e.split(".")[1];if(!t)return null;let o=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"="),a=atob(o),i=JSON.parse(a);return typeof i.exp=="number"?i.exp*1e3:null}catch{return null}}var zn=2500,Un=6e4;function vt(e){let[t,o]=useState(()=>{try{return localStorage.getItem(ht)}catch(p){return console.warn("Unable to read BotBuddy widget auth token",p),null}}),[a,i]=useState(()=>{try{return localStorage.getItem(xt)}catch(p){return console.warn("Unable to read BotBuddy widget display name",p),null}}),l=useRef(null),_=useCallback((p,x)=>{o(p),x&&i(x);try{localStorage.setItem(ht,p),x&&localStorage.setItem(xt,x);}catch(g){console.warn("Unable to persist BotBuddy widget auth token",g);}},[]);useEffect(()=>{let p=new URL(e).origin,x=g=>{g.origin===p&&g.data?.type==="botbuddy-widget-auth"&&g.data.token&&_(g.data.token,g.data.displayName||"human");};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[e,_]);let y=useCallback(()=>{if(l.current)return l.current;if(typeof window>"u"||typeof document>"u")return Promise.resolve(null);let p=new URL(e).origin,x=new URL("/widget-auth",e);x.searchParams.set("silent","1"),x.searchParams.set("origin",window.location.origin);let g=new Promise(n=>{let d=document.createElement("iframe");d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.width="1px",d.style.height="1px",d.style.opacity="0",d.style.pointerEvents="none",d.style.border="0",d.style.left="-9999px",d.style.top="-9999px",d.src=x.toString();let k=false,P=()=>{window.removeEventListener("message",z),clearTimeout(V);try{d.remove();}catch{}l.current=null;},z=S=>{if(S.origin===p){if(S.data?.type==="botbuddy-widget-auth-failed"){if(k)return;k=true,n(null),P();return}S.data?.type!=="botbuddy-widget-auth"||!S.data.token||k||(k=true,n(String(S.data.token)),P());}},V=setTimeout(()=>{k||(k=true,n(null),P());},zn);window.addEventListener("message",z),document.body.appendChild(d);});return l.current=g,g},[e]);useEffect(()=>{if(!t)return;let p=Ue(t);if(!p)return;let x=p-Date.now()-Un,g=window.setTimeout(()=>{y();},Math.max(0,x));return ()=>window.clearTimeout(g)},[t,y]);let R=useCallback(()=>{let p=new URL("/widget-auth",e);p.searchParams.set("origin",window.location.origin);let x=420,g=520,n=window.screenX+(window.innerWidth-x)/2,d=window.screenY+(window.innerHeight-g)/2;window.open(p.toString(),"botbuddy-auth",`width=${x},height=${g},left=${n},top=${d},popup=yes`);},[e]),[,f]=useState(0);useEffect(()=>{let p=Ue(t);if(!p)return;let x=p-Date.now();if(x<=0)return;let g=window.setTimeout(()=>f(n=>n+1),x);return ()=>window.clearTimeout(g)},[t]);let h=useCallback(()=>{o(null),i(null);try{localStorage.removeItem(ht),localStorage.removeItem(xt);}catch(p){console.warn("Unable to clear BotBuddy widget auth token",p);}},[]),M=Ue(t),A=M!==null&&M<=Date.now();return {token:t,displayName:a,isAuthenticated:!!t,isExpired:A,openLogin:R,refreshNow:y,logout:h}}var Ge=null;function In(){try{if(typeof document<"u"){let e=document.querySelector("base[href]");if(e)return new URL(".botbuddy-totp.json",e.href).toString()}}catch{}return "/.botbuddy-totp.json"}function Xe(){return Ge||(Ge=(async()=>{if(typeof fetch>"u")return null;try{let e=await fetch(In(),{cache:"no-store"});if(!e.ok)return null;let t=await e.json();if(!t||typeof t!="object"||Array.isArray(t))return null;let o={};for(let[a,i]of Object.entries(t))typeof i=="string"&&i.length>0&&(o[a]=i);return o}catch{return null}})(),Ge)}async function Zt(e){return (await Xe())?.[e]??null}function Fn(e){let t=e.replace(/=+$/,"").replace(/\s+/g,"").toUpperCase(),o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",a=[],i=0,l=0;for(let _ of t){let y=o.indexOf(_);if(y<0)throw new Error("Invalid Base32 character in TOTP secret");l=l<<5|y,i+=5,i>=8&&(i-=8,a.push(l>>>i&255));}return Uint8Array.from(a)}async function Qt(e,t=Date.now()){if(typeof crypto>"u"||!crypto.subtle)throw new Error("Web Crypto unavailable");let o=Fn(e),a=new Uint8Array(o.byteLength);a.set(o);let i=Math.floor(t/1e3/30),l=new Uint8Array(8),_=Math.floor(i/4294967296),y=i>>>0;l[0]=_>>>24&255,l[1]=_>>>16&255,l[2]=_>>>8&255,l[3]=_&255,l[4]=y>>>24&255,l[5]=y>>>16&255,l[6]=y>>>8&255,l[7]=y&255;let R=await crypto.subtle.importKey("raw",a,{name:"HMAC",hash:"SHA-1"},false,["sign"]),f=await crypto.subtle.sign("HMAC",R,l),h=new Uint8Array(f),M=h[h.length-1]&15;return (((h[M]&127)<<24|(h[M+1]&255)<<16|(h[M+2]&255)<<8|h[M+3]&255)%1e6).toString().padStart(6,"0")}var en="0.11.0";function Wn(e){let t=new Date(e),a=Date.now()-t.getTime();if(a<6e4)return "just now";if(a<36e5)return `${Math.floor(a/6e4)}m ago`;if(a<864e5)return `${Math.floor(a/36e5)}h ago`;let i=t.getDate(),l=t.toLocaleString("en",{month:"short"}),_=t.toLocaleString("en",{hour:"numeric",minute:"2-digit",hour12:true});return `${l} ${i}, ${_}`}var E=({d:e,className:t,size:o=14})=>jsx("svg",{className:t,width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:e})}),w={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01",bot:"M12 8V4H8M2 14h2M20 14h2M15 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M9 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M18 10a6 6 0 0 0-12 0v4a6 6 0 0 0 12 0Z",terminal:"M4 17l6-6-6-6M12 19h8",key:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4",shield:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",copy:"M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2ZM5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",search:"M11 17.25a6.25 6.25 0 1 1 0-12.5 6.25 6.25 0 0 1 0 12.5ZM16 16l4.5 4.5"};function On(){let[e,t]=useState(()=>typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(typeof window>"u")return;let o=document.documentElement,a=()=>o.classList.contains("dark")?"dark":o.classList.contains("light")?"light":null,i=a();i&&t(i);let l=window.matchMedia("(prefers-color-scheme: dark)"),_=R=>{let f=a();t(f||(R.matches?"dark":"light"));};l.addEventListener("change",_);let y=new MutationObserver(()=>{let R=a();t(R||(l.matches?"dark":"light"));});return y.observe(o,{attributes:true,attributeFilter:["class"]}),()=>{l.removeEventListener("change",_),y.disconnect();}},[]),e}function Hn(e){let t=e==="dark";return {bg:t?"rgb(30,30,30)":"rgb(255,255,255)",bgSoft:t?"rgba(255,255,255,0.02)":"rgba(0,0,0,0.02)",text:t?"#e5e5e5":"#1a1a1a",textMuted:t?"rgba(255,255,255,0.4)":"rgba(0,0,0,0.45)",textFaint:t?"#555":"#999",border:t?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)",borderSubtle:t?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",shadow:t?"rgba(0,0,0,0.4)":"rgba(0,0,0,0.12)",inputBg:t?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.04)",inputBorder:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.12)",green:"#34d399",greenBg:t?"rgba(52,211,153,0.05)":"rgba(52,211,153,0.08)",greenBorder:t?"rgba(52,211,153,0.6)":"rgba(52,211,153,0.5)",greenBorderSubtle:t?"rgba(52,211,153,0.2)":"rgba(52,211,153,0.15)",red:"#f87171",amber:"#f59e0b",blue:"#60a5fa",purple:"#a78bfa",versionText:t?"rgba(255,255,255,0.5)":"rgba(0,0,0,0.35)",versionNum:t?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",gripColor:t?"#888":"#aaa",btnHover:t?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}}var Kn={pending:"#888",pass:"#34d399",fail:"#f87171",skip:"#f59e0b"},jn={pending:w.circle,pass:w.check,fail:w.x,skip:w.skip},tn={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},Vn=["app.supply-guard.io"];function Yn(e,t=[]){if(!e)return false;let o=e.toLowerCase();return [...Vn,...t].map(i=>i.toLowerCase()).includes(o)}var Jn=e=>({root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:t=>({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:e.bg,border:t?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:t?`0 4px 12px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 4px 12px ${e.shadow}`,cursor:"pointer",fontSize:"9px",color:e.text}),card:(t,o)=>({width:`${t}px`,borderRadius:"8px",background:e.bg,border:o?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:o?`0 8px 24px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 8px 24px ${e.shadow}`,overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:`1px solid ${e.borderSubtle}`},title:{fontSize:"10px",fontWeight:600,color:e.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:e.textMuted,display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:e.gripColor,display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:`1px solid ${e.borderSubtle}`},badge:t=>{let o=tn[t]||tn.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:o.bg,color:o.text,border:`1px solid ${o.border}`,lineHeight:"14px"}},progress:{height:"2px",background:e.borderSubtle,flexShrink:0},progressBar:t=>({height:"100%",width:`${t}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:t=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${t}15`,color:t,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:`1px solid ${e.borderSubtle}`,transition:"background 0.15s"},verdictBtn:(t,o)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:t?`${o}33`:"transparent",color:t?o:e.gripColor,transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:"4px",padding:"2px 6px",color:e.text,outline:"none"},humanBanner:{padding:"6px 12px",fontSize:"11px",fontWeight:600,color:e.green,borderBottom:`1px solid ${e.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",background:e.greenBg,cursor:"pointer",textDecoration:"none"}});function wt(e){return e.split("/")[0].trim()}async function qn(e){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return !1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange(0,e.length);let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return false}}function Ie({config:e,appSlug:t,environment:o,seededUsers:a,authToken:i,tk:l,compact:_=false,onExpand:y,onAuthExpired:R,refreshAuth:f,requestLogin:h,testRunId:M,testRunToken:A,ticketId:p,targetUrl:x,version:g,commitSha:n,prNumber:d,branchName:k}){let[P,z]=useState(false),[V,S]=useState(null),[W,pe]=useState(null),[ie,m]=useState(null),[we,C]=useState(null),[T,O]=useState(null),[G,X]=useState(null);useEffect(()=>{o==="local"&&Xe();},[o]);let ce=useCallback(u=>{S(u),m(null),C(null),X(null);let D=Ue(i);if(o!=="local"&&h&&D!==null&&D<=Date.now()){O({slug:u,token:i||null}),X(u),S(null),h();return}let U=B=>{m(B),C(u),window.setTimeout(()=>{C(I=>I===u?null:I),m(I=>I===B?null:I);},3e3);},L=new URLSearchParams({app_slug:t,seed_user_slug:u,environment:o});M&&L.set("test_run_id",M),A&&L.set("public_token",A),p&&L.set("ticket_id",p),x&&L.set("target_url",x),g&&L.set("version",g),n&&L.set("commit_sha",n),d&&L.set("pr_number",String(d)),k&&L.set("branch_name",k);let H=async B=>{let I={apikey:e.anonKey,Authorization:`Bearer ${B}`};try{let j=await fetch(`${e.serverUrl}/widget/totp-code?${L}`,{headers:I});if(!j.ok){let ke=await j.json().catch(()=>({error:`HTTP ${j.status}`}));return {ok:!1,status:j.status,error:ke.error||`HTTP ${j.status}`}}let oe=await j.json();return {ok:!0,code:String(oe.code)}}catch{return {ok:false,status:0,error:"Network error"}}},Z=(async()=>{if(o==="local"){let j=await Zt(u);if(j)try{return {ok:!0,code:await Qt(j)}}catch{}}let B=await H(i||e.anonKey);if(B.ok||B.status!==401||!f)return B;let I=await f();return I?H(I):{ok:false,status:401,error:"Sign in to BotBuddy to refresh 2FA"}})(),Y=null;try{if(typeof ClipboardItem<"u"&&navigator.clipboard?.write){let B=Z.then(I=>{if(!I.ok)throw new Error(I.error);return new Blob([I.code],{type:"text/plain"})});Y=navigator.clipboard.write([new ClipboardItem({"text/plain":B})]).then(()=>!0).catch(()=>!1);}}catch{}(async()=>{let B=await Z;if(!B.ok){B.status===401?(O({slug:u,token:i||null}),X(u)):U(B.status===404?"No 2FA seed registered":B.error),S(null);return}let I=Y?await Y:false,j=I?true:await qn(B.code),oe=I||j;pe({slug:u,code:B.code,copied:oe}),window.setTimeout(()=>pe(ke=>ke?.slug===u?null:ke),oe?2500:6e3),z(false),S(null);})();},[e.serverUrl,e.anonKey,i,t,o,M,A,p,x,g,n,d,k,f,h]),re=useCallback(u=>{O({slug:u,token:i||null}),h?.();},[i,h]),Re=useCallback(u=>{G===u?re(u):ce(u);},[G,re,ce]);useEffect(()=>{if(!T||!i||i===T.token)return;let u=T.slug;O(null),ce(u);},[i,ce,T]);let Ne=useRef(null),Le=useRef(null);if(useLayoutEffect(()=>{if(!P)return;let u=Ne.current,D=Le.current;if(!u||!D||typeof window>"u")return;let U=()=>{let L=u.getBoundingClientRect(),H=D.getBoundingClientRect(),Z=window.innerWidth,Y=window.innerHeight,B=L.left,I=L.top-H.height-6;I<8&&(I=L.bottom+6);let j=Math.max(8,Z-H.width-8),oe=Math.max(8,Y-H.height-8);B=Math.min(Math.max(B,8),j),I=Math.min(Math.max(I,8),oe),D.style.left=`${Math.round(B)}px`,D.style.top=`${Math.round(I)}px`;};return U(),window.addEventListener("scroll",U,true),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,true),window.removeEventListener("resize",U);}},[P,a.length,ie]),useEffect(()=>{if(!P)return;let u=D=>{let U=D.target;Le.current?.contains(U)||Ne.current?.contains(U)||z(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[P]),a.length===0)return null;if(_){let u=a.length>1,D=a[0],U=!u&&G===D,L=j=>{if(j.stopPropagation(),u&&y){y();return}Re(D);},H=!!we,Z=!!W,Y=Z&&W.copied,B=Z&&!W.copied,I=U?l.blue:H?l.red:Y?l.green:B?l.amber:l.purple;return jsxs("span",{onPointerDown:j=>j.stopPropagation(),onPointerUp:j=>j.stopPropagation(),onPointerMove:j=>j.stopPropagation(),onClick:L,style:{display:"inline-flex",alignItems:"center",gap:"3px",color:I,fontWeight:600,cursor:"pointer",letterSpacing:B?"0.08em":void 0},title:U?"Sign in to BotBuddy to refresh 2FA":H?ie||"Failed":B?`Clipboard blocked \u2014 code: ${W.code}`:u?`${a.length} 2FA personas`:`Copy 2FA code for ${a[0]}`,children:[jsx(E,{d:U?w.key:H?w.alert:Y?w.check:B?w.copy:w.shield,size:10}),U?jsx(Fragment,{children:"Sign in"}):Y?jsx(Fragment,{children:"Copied"}):B?jsx(Fragment,{children:W.code}):H?jsx(Fragment,{children:"Failed"}):jsxs(Fragment,{children:["2FA",u&&` \xB7${a.length}`]})]})}if(a.length===1){let u=a[0],D=V===u,U=W?.slug===u,L=U&&W.copied,H=U&&!W.copied,Z=we===u,Y=G===u,B=Y?l.blue:Z?l.red:L?l.green:H?l.amber:l.purple;return jsxs("button",{onClick:I=>{I.stopPropagation(),Re(u);},disabled:D,style:{...nn(B),cursor:D?"wait":"pointer",opacity:D?.6:1},title:Y?"Sign in to BotBuddy to refresh 2FA":Z?ie||"Failed":H?`Clipboard blocked \u2014 code: ${W.code}`:`Copy 2FA code for ${u}`,children:[jsx(E,{d:Y?w.key:Z?w.alert:L?w.check:H?w.copy:w.shield,size:12}),Y?"Sign in":L?"Copied":H?W.code:Z?"Failed":D?"\u2026":`2FA \xB7 ${u}`]})}let be=!!G&&!P,ae=!!we&&!P,Ce=!!W&&W.copied,Te=!!W&&!W.copied,ot=be?l.blue:ae?l.red:Ce?l.green:Te?l.amber:l.purple,st=P&&typeof document<"u"?createPortal(jsxs("div",{ref:Le,onPointerDown:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),style:{position:"fixed",left:-9999,top:-9999,background:l.bg,border:`1px solid ${l.border}`,borderRadius:6,boxShadow:`0 8px 24px ${l.shadow}`,padding:4,minWidth:220,maxWidth:typeof window<"u"?Math.min(420,window.innerWidth-16):420,zIndex:1e5,fontFamily:"ui-monospace, SFMono-Regular, monospace"},children:[a.map(u=>{let D=V===u,U=G===u;return jsxs("button",{onClick:L=>{L.stopPropagation(),Re(u);},disabled:D,style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 8px",background:"transparent",border:"none",borderRadius:4,cursor:D?"wait":"pointer",fontSize:"10px",color:U?l.blue:l.text,textAlign:"left",fontFamily:"ui-monospace, SFMono-Regular, monospace"},title:U?"Sign in to BotBuddy to refresh 2FA":void 0,onMouseEnter:L=>L.currentTarget.style.background=l.btnHover,onMouseLeave:L=>L.currentTarget.style.background="transparent",children:[jsx(E,{d:U?w.key:w.shield,size:10}),jsx("span",{style:{flex:1,overflowWrap:"anywhere",lineHeight:1.3},children:u}),U?jsx("span",{style:{color:l.blue,fontSize:9},children:"Sign in"}):D?jsx("span",{style:{color:l.textMuted,fontSize:9},children:"\u2026"}):null]},u)}),ie&&jsx("div",{style:{padding:"4px 8px",fontSize:9,color:l.red},children:ie})]}),document.body):null;return jsxs(Fragment,{children:[jsxs("button",{ref:Ne,onClick:u=>{if(u.stopPropagation(),be&&G){re(G);return}z(D=>!D),m(null),C(null);},style:{...nn(ot),cursor:"pointer"},title:be?"Sign in to BotBuddy to refresh 2FA":ae?ie||"Failed":Te?`Clipboard blocked \u2014 code: ${W.code}`:"Choose a persona to copy a 2FA code for",children:[jsx(E,{d:be?w.key:ae?w.alert:Ce?w.check:Te?w.copy:w.shield,size:12}),be?"Sign in":Ce?"Copied":Te?W.code:ae?"Failed":`2FA \xB7 ${a.length}`,!be&&jsx(E,{d:P?w.chevronUp:w.chevronDown,size:8})]}),st]})}function nn(e){return {display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${e}15`,color:e,textDecoration:"none",border:`1px solid ${e}30`}}var rn="botbuddy-widget-state";function Gn({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:_,version:y,commitSha:R,prNumber:f,branchName:h,onNavigate:M,displayName:A="human",defaultMode:p="mini",defaultPosition:x}){let g=On(),n=useMemo(()=>Hn(g),[g]),d=useMemo(()=>Jn(n),[n]),[k,P]=useState(false),[z,V]=useState(false),[S,W]=useState(false),pe=useRef(false),ie=e.dashboardUrl||"https://app.bot-buddy.ai",m=vt(ie),C=(()=>{try{let r=typeof window<"u"?localStorage.getItem(rn):null;if(r)return JSON.parse(r)}catch{}return null})(),[T,O]=useState(C?.mode||p),[G,X]=useState(""),[ce,re]=useState(null),[Re,Ne]=useState(null),[Le,be]=useState(new Set),[ae,Ce]=useState(""),Te=useCallback(r=>{be(b=>{let N=new Set(b);return N.has(r)?N.delete(r):N.add(r),N});},[]),ot=C?.x??x?.x??16,st=C?.y??x?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:u,setPos:D,onPointerDown:U,onPointerMove:L,onPointerUp:H,didDrag:Z}=pt(ot,st),Y=useRef(null);useEffect(()=>{try{localStorage.setItem(rn,JSON.stringify({mode:T,x:u.x,y:u.y}));}catch{}},[T,u.x,u.y]),useLayoutEffect(()=>{if(typeof window>"u")return;let r=Y.current;if(!r)return;let b=r.getBoundingClientRect(),N=ut(u.x,u.y,b.width,b.height,window.innerWidth,window.innerHeight);(N.x!==u.x||N.y!==u.y)&&D(N);}),useEffect(()=>{if(typeof window>"u")return;let r=()=>{let b=Y.current;if(!b)return;let N=b.getBoundingClientRect(),J=ut(u.x,u.y,N.width,N.height,window.innerWidth,window.innerHeight);(J.x!==u.x||J.y!==u.y)&&D(J);};return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[u.x,u.y,D]);let B=useRef(m.isAuthenticated);useEffect(()=>{!B.current&&m.isAuthenticated&&O("max"),B.current=m.isAuthenticated;},[m.isAuthenticated]);let I="botbuddy-widget-max-size",j=()=>{try{let r=localStorage.getItem(I);if(r)return JSON.parse(r)}catch{}return {w:340,h:500}},[oe,ke]=useState(j),Be=useRef(false),ze=useRef({x:0,y:0,w:0,h:0}),yn=useCallback(r=>{r.stopPropagation(),Be.current=true,ze.current={x:r.clientX,y:r.clientY,w:oe.w,h:oe.h},r.target.setPointerCapture(r.pointerId);},[oe]),hn=useCallback(r=>{if(!Be.current)return;let b=Math.max(280,Math.min(600,ze.current.w+(r.clientX-ze.current.x))),N=Math.max(300,Math.min(window.innerHeight*.9,ze.current.h+(r.clientY-ze.current.y)));ke({w:b,h:N});},[]),xn=useCallback(()=>{Be.current&&(Be.current=false,ke(r=>(localStorage.setItem(I,JSON.stringify(r)),r)));},[]),le=_??(typeof window<"u"?window.location.href:void 0),Mt=m.displayName||A,[ge,Pt]=useState(null);useEffect(()=>{if(m.isAuthenticated)return;let r=new URLSearchParams;l&&r.set("token",l),a&&r.set("ticket_id",a),r.set("app_slug",t),o&&r.set("environment",o),i&&r.set("test_run_id",i),le&&r.set("target_url",le),y&&r.set("version",y),R&&r.set("commit_sha",R),f&&r.set("pr_number",String(f)),h&&r.set("branch_name",h),fetch(`${e.serverUrl}/widget/preview?${r}`,{headers:{apikey:e.anonKey}}).then(b=>b.json()).then(b=>Pt(b)).catch(()=>Pt(null));},[m.isAuthenticated,e.serverUrl,e.anonKey,t,o,a,i,l,le,y,R,f,h]);let At=useRef(false),vn=useCallback(()=>{At.current||m.logout();},[m.logout]),{run:v,widgetState:Se,fetchRun:wn,setVerdict:$t,markComplete:kn,resetRun:Sn,setRun:Lt}=bt({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:le,version:y,commitSha:R,prNumber:f?String(f):void 0,branchName:h,authToken:m.token,onAuthExpired:vn});At.current=!!v;let[Bt,zt]=useState([]),[Ut,Ke]=useState([]),[it,It]=useState(false),[Ft,Dt]=useState(null),[_n,je]=useState(false),me=Yn(typeof window<"u"?window.location.hostname:void 0,e.productionHostnames||[]);useEffect(()=>{if((o??"local")!=="local"||me){zt([]);return}let r=true;return Xe().then(b=>{r&&zt(Object.keys(b||{}));}),()=>{r=false;}},[o,me]);let Rn=useCallback(async()=>{if(!(!m.isAuthenticated||!m.token)){It(true),Dt(null);try{let r=await fetch(`${e.serverUrl}/widget/test-runs`,{method:"POST",headers:{"Content-Type":"application/json",apikey:e.anonKey,Authorization:`Bearer ${m.token}`},body:JSON.stringify({app_slug:t,environment:o||"local",target_url:le,branch_name:h,commit_sha:R,pr_number:f,ticket_id:a,title:`${a||t} local validation`})}),b=await r.json().catch(()=>({}));if(!r.ok)throw new Error(b.error||`HTTP ${r.status}`);Lt(b),O("max");}catch(r){Dt(r.message);}finally{It(false);}}},[m.isAuthenticated,m.token,e.serverUrl,e.anonKey,t,o,le,h,R,f,a,Lt]),Ve=useCallback(async(r,b,N)=>{Ne(r);try{await $t(r,b,N,Mt);}finally{Ne(null),re(null),X("");}},[$t,Mt]),q=v?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},Nn=q.total>0&&q.pending===0,Ee=Se==="completed",Ye=useMemo(()=>{let r=v?.test_cases||[];if(!ae.trim())return r;let b=ae.toLowerCase();return r.filter(N=>N.title.toLowerCase().includes(b)||N.description&&N.description.toLowerCase().includes(b)||N.url_path&&N.url_path.toLowerCase().includes(b)||N.seed_user&&N.seed_user.toLowerCase().includes(b))},[v?.test_cases,ae]),Wt=useMemo(()=>{let r=Ye,b=v?.test_cases||[];if(new Set(b.map(te=>te.source_pr_number)).size<=1)return null;let J=[],he=new Map;r.forEach(te=>{let ee=te.source_pr_number;he.has(ee)||he.set(ee,[]),he.get(ee).push(te);});let qt=[...he.keys()].sort((te,ee)=>te===null?1:ee===null?-1:ee-te);for(let te of qt){let ee=he.get(te),lt={total:ee.length,pass:0,fail:0,skip:0,pending:0};ee.forEach(Gt=>{Gt.verdict in lt&<[Gt.verdict]++;}),J.push({key:te!=null?`pr-${te}`:"general",label:te!=null?`PR #${te}`:"General",cases:ee,summary:lt});}return J.filter(te=>te.cases.length>0)},[Ye,v?.test_cases]),Ot=q.total>0?(q.pass+q.fail)/q.total*100:0,Q=o??v?.environment??null,ye=useMemo(()=>{if(!Q||Q==="production"||me)return [];let r=v?.test_cases||[],b=new Set;for(let N of r)N.seed_user&&b.add(wt(N.seed_user));if(Q==="local")for(let N of Bt)b.add(wt(N));for(let N of Ut)b.add(wt(N));return [...b]},[v?.test_cases,Q,Bt,Ut,me]);useEffect(()=>{if(!Q||Q==="production"||me||!m.isAuthenticated||!m.token){Ke([]);return}let r=true,b=`${e.serverUrl}/widget/totp-seeds?${new URLSearchParams({app_slug:t,environment:Q})}`,N=J=>fetch(b,{headers:{apikey:e.anonKey,Authorization:`Bearer ${J}`}});return (async()=>{try{let J=await N(m.token);if(J.status===401&&m.refreshNow){let ee=await m.refreshNow();ee&&(J=await N(ee));}if(!r)return;if(!J.ok){Ke([]);return}let he=await J.json().catch(()=>null),te=(Array.isArray(he?.seeds)?he.seeds:[]).map(ee=>ee?.seed_user_slug).filter(ee=>typeof ee=="string"&&ee.length>0);Ke(te);}catch{r&&Ke([]);}})(),()=>{r=false;}},[Q,me,m.isAuthenticated,m.token,m.refreshNow,t,e.serverUrl,e.anonKey]);let at=useMemo(()=>{let r=v?.auto_tooltip_seconds??ge?.auto_tooltip_seconds;return r!=null&&r>0?r*1e3:0},[v,ge]),Ht=Se==="ready"||Se==="completed"||ge?.enabled&&ge.run;useEffect(()=>{if(!Ht||pe.current||at<=0)return;pe.current=true,V(true);let r=window.setTimeout(()=>V(false),at);return ()=>window.clearTimeout(r)},[Ht,at]);let Kt=r=>jsxs("div",{style:d.caseRow,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsx("div",{style:{marginTop:"2px",flexShrink:0,color:Kn[r.verdict]},children:Re===r.id?jsx(E,{d:w.loader,className:""}):jsx(E,{d:jn[r.verdict],className:""})}),jsxs("div",{style:{minWidth:0,flex:1},children:[jsx("div",{style:{fontSize:"10px",color:n.text,lineHeight:1.3},children:r.title}),r.description&&jsx("div",{style:{fontSize:"9px",color:n.gripColor,marginTop:"2px"},children:r.description}),r.seed_user&&jsxs("div",{style:{fontSize:"9px",color:n.amber,marginTop:"3px",display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",background:`${n.amber}12`,border:`1px solid ${n.amber}30`},children:[jsx(E,{d:w.key,size:10}),jsx("span",{children:r.seed_user})]}),r.url_path&&jsxs("a",{href:r.url_path,target:"_blank",rel:"noopener noreferrer",onClick:b=>{b.stopPropagation(),M&&(b.preventDefault(),M(r.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsx(E,{d:w.externalLink,size:10}),r.url_path]}),r.verdict==="fail"&&r.fail_reason&&jsxs("div",{style:{fontSize:"9px",color:n.red,marginTop:"2px"},children:["\u2717 ",r.fail_reason]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(b=>jsx("button",{onClick:()=>{if(r.verdict===b){Ve(r.id,"pending"),re(null);return}if(b==="fail"){re(r.id),X("");return}re(null),Ve(r.id,b);},disabled:Re!==null,style:d.verdictBtn(r.verdict===b,b==="pass"?n.green:b==="fail"?n.red:n.amber),children:b.toUpperCase()},b)),r.created_by_agent_name&&jsxs("span",{style:{fontSize:"8px",color:n.purple,marginLeft:"4px",display:"inline-flex",alignItems:"center",gap:"2px"},children:[jsx(E,{d:w.bot,size:8}),r.created_by_agent_name]}),r.verdict_by_display_name&&jsxs("span",{style:{fontSize:"8px",color:n.textFaint,marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:"3px"},children:[r.verdict_by_display_name,r.verdict_at&&jsx("span",{style:{opacity:.7},children:Wn(r.verdict_at)})]})]}),ce===r.id&&jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsx("input",{autoFocus:true,value:G,onChange:b=>X(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Ve(r.id,"fail",G.trim()||void 0),b.key==="Escape"&&(re(null),X(""));},placeholder:"Reason (optional)...",style:d.input}),jsx("button",{onClick:()=>{Ve(r.id,"fail",G.trim()||void 0);},style:d.verdictBtn(true,n.red),children:"\u2713"})]})]},r.id);if((Se==="no-match"||Se==="loading")&&!(!m.isAuthenticated&&ge?.enabled&&ge.run)){if(!(Q==="local"&&!me))return null}if(!m.isAuthenticated&&ge?.enabled&&ge.run){let r=ge.run,b=r.summary,N=r.status==="completed";return jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxs("div",{style:{position:"relative"},onMouseEnter:()=>P(true),onMouseLeave:()=>{P(false),W(false),V(false);},children:[jsxs("div",{style:{...d.pill(N),gap:"8px",padding:"5px 10px",fontSize:"10px"},onPointerDown:U,onPointerMove:L,onPointerUp:()=>{H();},children:[jsx(E,{d:w.grip,size:10,className:""}),r.ticket_id&&r.ticket_url?jsx("a",{href:r.ticket_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.amber,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:r.ticket_id}):null,r.pr_url?jsxs("a",{href:r.pr_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.blue,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:["PR#",r.pr_number??r.pr_id]}):null,r.created_by_agent_name?r.codex_thread_id?jsxs("a",{href:`codex://threads/${r.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.purple,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsx(E,{d:w.terminal,size:10}),r.created_by_agent_name]}):jsxs("span",{style:{color:n.purple,fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsx(E,{d:w.bot,size:10}),r.created_by_agent_name]}):null,jsxs("span",{style:N?{color:n.green}:void 0,children:[b.pass,"/",b.total]}),b.fail>0&&jsxs("span",{style:{color:n.red},children:[b.fail,"\u2717"]}),jsx("span",{onClick:J=>{J.stopPropagation(),m.openLogin();},style:{color:n.textMuted,fontWeight:400,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:"2px"},children:"Sign in"})]}),!S&&(k||z)&&r.title&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:r.title}),(r.description||r.intro_notes)&&jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:r.description||r.intro_notes}),jsx("div",{style:{marginTop:"4px",fontSize:"9px",color:n.textFaint},children:'Click "Sign in" to start testing'})]})]})})}if(!m.isAuthenticated)return jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y,width:220,minHeight:0,cursor:"move",userSelect:"none",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`},onPointerDown:U,onPointerMove:L,onPointerUp:H,children:[jsx("div",{style:{...d.handle,borderBottom:"none"},children:jsxs("div",{style:d.sub,children:[jsx(E,{d:w.grip,size:10,className:""}),jsx(E,{d:w.clipboard,size:12,className:""}),jsx("span",{style:{fontWeight:600},children:"BotBuddy"})]})}),jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[jsx("div",{style:{fontSize:"9px",color:n.textMuted,marginBottom:"8px"},children:"Sign in to access test cases"}),Q==="local"&&ye.length>0&&jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"10px",fontWeight:600,padding:"6px 16px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:"pointer",width:"100%"},children:"Sign in to test"})]})]});if(!v&&Q==="local"&&!me)return _n?jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxs("div",{style:d.card(240,false),children:[jsxs("div",{style:d.handle,onPointerDown:U,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||je(false);},children:[jsx(E,{d:w.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:d.title,children:"BotBuddy"}),h&&jsx("div",{style:d.sub,children:jsxs("span",{children:["\u2387 ",h]})})]}),jsx(E,{d:w.chevronUp,className:""}),jsx("button",{style:d.btn,onClick:r=>{r.stopPropagation(),je(false);},children:jsx(E,{d:w.minus,className:""})})]}),jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[ye.length>0&&jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsx("button",{onClick:r=>{r.stopPropagation(),Rn();},disabled:it,style:{fontSize:"10px",fontWeight:600,padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:it?"wait":"pointer",width:"100%"},children:it?"Creating...":"Create test run for this branch"}),Ft&&jsx("div",{style:{fontSize:"9px",color:n.red,marginTop:"8px"},children:Ft})]})]})}):jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxs("div",{style:{...d.pill(false),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:U,onPointerMove:L,onPointerUp:()=>{H(),Z.current||je(true);},children:[jsx(E,{d:w.grip,size:9,className:""}),jsx("span",{style:{fontWeight:600},children:"BotBuddy"}),ye.length>0&&jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>je(true),testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]})});let jt=()=>{Z.current||(V(false),O(r=>{let b=r==="mini"?"max":"mini";return W(b==="mini"),b}));},Vt=({icon:r,onClick:b})=>jsx("button",{style:d.btn,onClick:N=>{N.stopPropagation(),b(N);},children:jsx(E,{d:r,className:""})}),Yt=()=>jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:`1px solid ${n.borderSubtle}`,flexShrink:0},children:[v?.pr_url&&jsxs("a",{href:v.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.blue),textDecoration:"none"},children:[jsx(E,{d:w.pr,size:12}),v.pr_number?`PR#${v.pr_number}`:v.pr_id||"PR",jsx(E,{d:w.externalLink,size:8})]}),v?.ticket_url&&jsxs("a",{href:v.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.amber),textDecoration:"none"},children:[jsx(E,{d:w.ticket,size:12}),v.ticket_id||"Ticket",jsx(E,{d:w.externalLink,size:8})]}),v?.created_by_agent_name&&(v.codex_thread_id?jsxs("a",{href:`codex://threads/${v.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.purple),textDecoration:"none"},children:[jsx(E,{d:w.bot,size:12}),v.created_by_agent_name,jsx(E,{d:w.externalLink,size:8})]}):jsxs("span",{style:{...d.link(n.purple)},children:[jsx(E,{d:w.bot,size:12}),v.created_by_agent_name]})),Q&&jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout}),jsx("span",{style:{...d.badge(v?.environment||"custom"),marginLeft:"auto"},children:v?.environment})]}),Jt=()=>jsxs("div",{style:{padding:"4px 12px",display:"flex",alignItems:"center",justifyContent:"center",borderTop:`1px solid ${n.borderSubtle}`,background:n.bgSoft,flexShrink:0},children:[jsxs("button",{onClick:()=>{navigator.clipboard.writeText(en);},style:{fontSize:"9px",fontWeight:600,color:n.versionText,letterSpacing:"0.08em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px",padding:0},title:"Copy version",children:["BotBuddy ",jsxs("span",{style:{color:n.versionNum},children:["v",en]})]}),m.isAuthenticated&&(m.isExpired?jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"8px",color:n.blue,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Widget session expired \u2014 sign in to refresh",children:"sign in"}):jsx("button",{onClick:r=>{r.stopPropagation(),m.logout();},style:{fontSize:"8px",color:n.textFaint,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Sign out of widget",children:"sign out"}))]});return jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:[T==="mini"&&jsxs("div",{style:{position:"relative"},onMouseEnter:()=>P(true),onMouseLeave:()=>{P(false),W(false),V(false);},children:[jsxs("div",{style:{...d.pill(Ee),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:U,onPointerMove:L,onPointerUp:()=>{H(),Z.current||jt();},children:[jsx(E,{d:w.grip,size:9,className:""}),v?.ticket_id&&jsx("span",{style:{color:n.amber,fontWeight:600},children:v.ticket_id}),v?.pr_number&&jsxs("span",{style:{color:n.blue,fontWeight:600},children:["PR#",v.pr_number]}),jsxs("span",{style:Ee?{color:n.green}:void 0,children:[q.pass,"/",q.total]}),q.fail>0&&jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),Q&&jsx(Ie,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>O("expanded"),testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]}),!S&&(k||z)&&v?.title&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:v.title}),(v.description||v.intro_notes)&&jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:v.description||v.intro_notes})]})]}),T==="expanded"&&jsxs("div",{style:d.card(300,Ee),children:[jsxs("div",{style:d.handle,onPointerDown:U,onPointerMove:L,onPointerUp:H,onClick:jt,children:[jsx(E,{d:w.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:d.title,children:v?.title}),jsx("div",{style:d.sub,children:v?.branch_name&&jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsx(E,{d:w.chevronUp,className:""}),jsx(Vt,{icon:w.minus,onClick:()=>{V(false),W(true),O("mini");}})]}),jsxs("div",{style:d.stats,children:[jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.description&&jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:n.gripColor,borderBottom:`1px solid ${n.borderSubtle}`,flexShrink:0},children:v.description}),Yt(),Jt(),jsx("div",{style:d.progress,children:jsx("div",{style:d.progressBar(Ot)})})]}),T==="max"&&jsxs("div",{style:{...d.card(oe.w,Ee),height:oe.h,position:"relative"},children:[jsxs("div",{style:d.handle,onPointerDown:U,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||O("expanded");},children:[jsx(E,{d:w.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:d.title,children:v?.title}),jsx("div",{style:d.sub,children:v?.branch_name&&jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsx(E,{d:w.chevronDown,className:""}),jsx(Vt,{icon:w.minus,onClick:()=>{V(false),W(true),O("mini");}})]}),jsxs("div",{style:d.stats,children:[jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.intro_notes&&jsx("div",{style:{padding:"6px 12px",borderBottom:`1px solid ${n.borderSubtle}`,fontSize:"10px",color:n.textMuted,fontStyle:"italic",flexShrink:0},children:v.intro_notes}),(v?.test_cases||[]).length>5&&jsxs("div",{style:{padding:"4px 12px",borderBottom:`1px solid ${n.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[jsx(E,{d:w.search,size:11,className:""}),jsx("input",{value:ae,onChange:r=>Ce(r.target.value),placeholder:"Filter test cases...",style:{flex:1,fontSize:"10px",background:"transparent",border:"none",outline:"none",color:n.text,fontFamily:"monospace"}}),ae&&jsx("button",{onClick:()=>Ce(""),style:{background:"none",border:"none",cursor:"pointer",color:n.textFaint,fontSize:"10px",padding:0},children:"\u2715"})]}),Se==="error"&&jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsx(E,{d:w.alert,className:""}),jsx("div",{style:{fontSize:"10px",color:n.red},children:"Failed to load"}),jsx("button",{onClick:wn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),Ee&&jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:"8px",borderBottom:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg},children:[jsx(E,{d:w.checkAll,className:""}),jsx("span",{style:{fontSize:"10px",color:n.green,flex:1},children:"Run completed"}),jsx("button",{onClick:Sn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer"},children:"Reset"})]}),Se!=="error"&&jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(v?.test_cases||[]).length===0?jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:"No test cases"}):Ye.length===0?jsxs("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:['No matches for "',ae,'"']}):Wt?Wt.map(r=>{let b=Le.has(r.key);return jsxs("div",{children:[jsxs("button",{onClick:()=>Te(r.key),style:{width:"100%",display:"flex",alignItems:"center",gap:"6px",padding:"5px 12px",background:n.bgSoft,cursor:"pointer",border:"none",borderLeft:"none",borderRight:"none",borderBottomStyle:"solid",borderTopStyle:"solid",borderBottomWidth:"1px",borderTopWidth:"1px",borderBottomColor:n.borderSubtle,borderTopColor:n.borderSubtle,backgroundColor:n.bgSoft},children:[jsx(E,{d:b?w.chevronDown:w.chevronUp,size:10,className:""}),jsx("span",{style:{fontSize:"10px",fontWeight:700,color:n.blue,flex:1,textAlign:"left"},children:r.label}),jsxs("span",{style:{fontSize:"9px",color:n.green},children:[r.summary.pass,"\u2713"]}),jsxs("span",{style:{fontSize:"9px",color:n.red},children:[r.summary.fail,"\u2717"]}),jsxs("span",{style:{fontSize:"9px",color:n.gripColor},children:[r.summary.pending,"\u25CC"]}),jsx("span",{style:{fontSize:"9px",color:n.textFaint},children:r.summary.total})]}),!b&&r.cases.map(N=>Kt(N))]},r.key)}):Ye.map(r=>Kt(r))}),Nn&&!Ee&&jsxs("div",{style:{padding:"6px 12px",borderTop:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg,display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsx("span",{style:{fontSize:"9px",color:n.green},children:"All resolved"}),jsx("button",{onClick:kn,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(52,211,153,0.15)",color:n.green,border:`1px solid ${n.greenBorderSubtle}`,cursor:"pointer"},children:"COMPLETE"})]}),Yt(),Jt(),jsx("div",{style:d.progress,children:jsx("div",{style:d.progressBar(Ot)})}),jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:yn,onPointerMove:hn,onPointerUp:xn,onPointerEnter:r=>r.currentTarget.style.opacity="0.7",onPointerLeave:r=>{Be.current||(r.currentTarget.style.opacity="0.3");},children:jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsx("path",{d:"M7 1v6H1",fill:"none",stroke:n.gripColor,strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var er=1e4,Fe=new Map;var Ze=class extends Error{};async function tr(e,t,o){let a={headers:{authorization:`Bearer ${t}`}};try{return await fetch(e,{...a,signal:o})}catch(i){if(i instanceof TypeError&&/signal/i.test(i.message)&&!o.aborted)return fetch(e,a);throw i}}function nr(e){let t=e;return !!t&&typeof t=="object"&&typeof t.tenant=="string"&&Array.isArray(t.entries)&&t.entries.every(o=>!!o&&typeof o.id=="string"&&typeof o.title=="string"&&!!o.body&&Array.isArray(o.body.ast)&&Array.isArray(o.links))}function kt({endpoint:e,getToken:t,timeoutMs:o=er}){let[a,i]=useState(()=>({feed:null,error:null,loading:true,stale:false})),[l,_]=useState(0),y=useRef(t);y.current=t,useEffect(()=>{let f=new AbortController,h=true,M=false,A=setTimeout(()=>{M=true,f.abort();},o),p=new Promise((n,d)=>{f.signal.addEventListener("abort",()=>d(new Error("timeout")),{once:true});});p.catch(()=>{}),i(n=>({...n,error:null,loading:true}));let x=null,g=(n,d)=>{if(d&&Fe.delete(e),!h)return;let k=d||x===null?void 0:Fe.get(e)?.get(x);i({feed:k??null,error:n,loading:false,stale:!!k});};return (async()=>{try{let n;try{n=await Promise.race([Promise.resolve().then(()=>y.current()),p]);}catch(z){throw M||f.signal.aborted?z:new Ze("token_unavailable")}x=n;let d=await Promise.race([tr(e,n,f.signal),p]),k=d.status===401||d.status===403;k&&Fe.delete(e);let P=null;try{P=await Promise.race([d.json(),p]);}catch(z){if(M&&!k)throw z;P=null;}if(!h)return;if(d.ok)if(!nr(P))g("invalid_feed",!1);else {let z=Fe.get(e)??new Map;z.set(n,P),Fe.set(e,z),i({feed:P,error:null,loading:!1,stale:!1});}else {let z=P?.error;g(typeof z=="string"?z:`http_${d.status}`,k);}}catch(n){n instanceof Ze?g(n.message,true):g(M?"timeout":n instanceof Error&&n.message||"unavailable",false);}finally{clearTimeout(A);}})(),()=>{h=false,clearTimeout(A),f.abort();}},[e,l,o]);let R=useCallback(()=>_(f=>f+1),[]);return {...a,reload:R}}var _t=["accent","fg","bg","muted","border","radius","font"],rr={accent:"hsl(var(--primary))",fg:"hsl(var(--foreground))",bg:"hsl(var(--card))",muted:"hsl(var(--muted-foreground))",border:"hsl(var(--border))",radius:"var(--radius)",font:"inherit"},se=(e,t)=>t===void 0?`var(--bbrn-${e},var(--_bbrn-${e}))`:`var(--bbrn-${e},var(--_bbrn-${e},${t}))`,Qe=se("accent","currentColor"),St=se("muted","color-mix(in srgb,currentColor 72%,transparent)"),Ae=se("border","color-mix(in srgb,currentColor 22%,transparent)"),or=`@layer bbrn{
|
|
1
|
+
import {useState,useRef,useCallback,useEffect,useMemo,useLayoutEffect,useInsertionEffect,Component}from'react';import {createPortal}from'react-dom';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var Me=8;function ut(e,t,o,a,i,l){let _=Math.max(Me,i-o-Me),y=Math.max(Me,l-a-Me);return {x:Math.min(Math.max(e,Me),_),y:Math.min(Math.max(t,Me),y)}}function pt(e,t){let[o,a]=useState({x:e,y:t}),i=useRef(false),l=useRef({x:0,y:0}),_=useRef(false),y=useCallback(h=>{i.current=true,_.current=false,l.current={x:h.clientX-o.x,y:h.clientY-o.y},h.target.setPointerCapture(h.pointerId);},[o]),R=useCallback(h=>{i.current&&(_.current=true,a({x:h.clientX-l.current.x,y:h.clientY-l.current.y}));},[]),f=useCallback(()=>{i.current=false;},[]);return {pos:o,setPos:a,onPointerDown:y,onPointerMove:R,onPointerUp:f,didDrag:_}}function gt(e,t,o){let a=useRef(o);a.current=o,useEffect(()=>{if(!t)return;if(e.supabaseUrl){let l=false,_=null,y=()=>{l||_||(_=setInterval(()=>a.current(),15e3));},R=null;try{let g=new URL(e.supabaseUrl),n=["localhost","127.0.0.1","::1"].includes(g.hostname);if(g.protocol==="http:"&&!n)throw new Error("Realtime WebSocket requires HTTPS outside loopback hosts");g.protocol=g.protocol==="https:"?"wss:":"ws:",R=g.toString().replace(/\/$/,"");}catch{y();}let f=null,h=null,M=null,A=0,p=()=>{if(!(l||!R)){try{f=new WebSocket(`${R}/realtime/v1/websocket?apikey=${e.anonKey}&vsn=1.0.0`);}catch{y();return}f.onopen=()=>{if(l||!f)return;let g={topic:`realtime:public:test_run_cases:test_run_id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_run_cases",filter:`test_run_id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(g));let n={topic:`realtime:public:test_runs:id=eq.${t}`,event:"phx_join",payload:{config:{postgres_changes:[{event:"*",schema:"public",table:"test_runs",filter:`id=eq.${t}`}]}},ref:String(++A)};f.send(JSON.stringify(n)),h=setInterval(()=>{f?.readyState===WebSocket.OPEN&&f.send(JSON.stringify({topic:"phoenix",event:"heartbeat",payload:{},ref:String(++A)}));},3e4);},f.onmessage=g=>{try{JSON.parse(g.data).event==="postgres_changes"&&a.current();}catch{}},f.onclose=()=>{x(),l||(M=setTimeout(p,3e3));},f.onerror=()=>{f?.close();};}},x=()=>{h&&(clearInterval(h),h=null);};return p(),()=>{l=true,x(),M&&clearTimeout(M),_&&clearInterval(_),f&&(f.onclose=null,f.onerror=null,f.close());}}let i=setInterval(()=>a.current(),15e3);return ()=>clearInterval(i)},[e.supabaseUrl,e.anonKey,t]);}var $n="botbuddy:created-test-run:";function An(e){if(!e)return "";try{return new URL(e).origin}catch{return e}}function Pn(e){return `${$n}${encodeURIComponent([e.appSlug,e.environment||"",e.ticketId||"",An(e.targetUrl),e.branchName||""].join("|"))}`}function qe(e,t){let o={apikey:e.anonKey};return t?o.Authorization=`Bearer ${t}`:e.apiKey?o.Authorization=`Bearer ${e.apiKey}`:o.Authorization=`Bearer ${e.anonKey}`,o}async function Ln(e){if(e)return e;try{let t=await fetch("/.botbuddy-token",{cache:"no-store"});if(t.ok){let o=(await t.text()).trim();if(o.startsWith("public_"))return o}}catch{}try{let t=import.meta?.env?.VITE_BOTBUDDY_TEST_RUN_TOKEN;if(t&&typeof t=="string"&&t.startsWith("public_"))return t}catch{}return null}function bt(e){let[t,o]=useState(null),[a,i]=useState("loading"),l=Pn(e),[_,y]=useState(()=>{if(e.testRunId)return e.testRunId;try{return localStorage.getItem(l)||void 0}catch{return}}),R=e.testRunId||_,f=useCallback(x=>{if(o(x),!!x?.id){y(x.id);try{localStorage.setItem(l,x.id);}catch{}}},[l]),h=useCallback(async()=>{try{let x=await Ln(e.testRunToken);if(!x&&!R){i("no-match"),o(null);return}if(x&&!e.ticketId){i("no-match"),o(null);return}let g=new URLSearchParams;x&&g.set("token",x),e.ticketId&&g.set("ticket_id",e.ticketId),g.set("app_slug",e.appSlug),e.environment&&g.set("environment",e.environment),R&&g.set("test_run_id",R),e.targetUrl&&g.set("target_url",e.targetUrl),e.version&&g.set("version",e.version),e.commitSha&&g.set("commit_sha",e.commitSha),e.prNumber&&g.set("pr_number",String(e.prNumber)),e.branchName&&g.set("branch_name",e.branchName);let n=await fetch(`${e.config.serverUrl}/widget/test-run?${g.toString()}`,{headers:qe(e.config,e.authToken)});if(n.status===404){i("no-match"),o(null);return}if(n.status===401||n.status===403){e.authToken&&e.onAuthExpired&&e.onAuthExpired(),i("error");return}if(!n.ok){i("error");return}let d=await n.json();if(!d||d.run===null){i("no-match"),o(null);return}f(d),i(d.status==="completed"?"completed":"ready");}catch{i("error");}},[e.config.serverUrl,e.config.anonKey,e.config.apiKey,e.authToken,e.appSlug,e.environment,e.ticketId,R,e.testRunToken,e.targetUrl,e.version,e.commitSha,e.branchName,e.prNumber,e.onAuthExpired,f]);return useEffect(()=>{h();},[h]),gt(e.config,t?.id,h),{run:t,widgetState:a,fetchRun:h,setVerdict:async(x,g,n,d="human")=>(o($=>{if(!$)return null;let z=$.test_cases.map(S=>S.id===x?{...S,verdict:g,fail_reason:g==="fail"&&n||null,verdict_by_display_name:d,verdict_at:new Date().toISOString()}:S),V={total:z.length,pending:0,pass:0,fail:0,skip:0};return z.forEach(S=>{S.verdict in V&&V[S.verdict]++;}),{...$,test_cases:z,summary:V}}),(await fetch(`${e.config.serverUrl}/widget/test-cases/${x}/verdict`,{method:"POST",headers:{"Content-Type":"application/json",...qe(e.config,e.authToken)},body:JSON.stringify({verdict:g,fail_reason:n,display_name:d})})).ok),markComplete:async()=>t?(o(g=>g?{...g,status:"completed"}:null),i("completed"),(await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json",...qe(e.config,e.authToken)}})).ok):false,resetRun:async()=>{if(!t)return false;let x=await fetch(`${e.config.serverUrl}/widget/test-runs/${t.id}/reset`,{method:"POST",headers:{"Content-Type":"application/json",...qe(e.config,e.authToken)}});return x.ok&&h(),x.ok},setRun:f}}var ht="botbuddy-widget-auth-token",xt="botbuddy-widget-auth-name";function Ue(e){if(!e)return null;try{let t=e.split(".")[1];if(!t)return null;let o=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"="),a=atob(o),i=JSON.parse(a);return typeof i.exp=="number"?i.exp*1e3:null}catch{return null}}var zn=2500,In=6e4;function vt(e){let[t,o]=useState(()=>{try{return localStorage.getItem(ht)}catch(p){return console.warn("Unable to read BotBuddy widget auth token",p),null}}),[a,i]=useState(()=>{try{return localStorage.getItem(xt)}catch(p){return console.warn("Unable to read BotBuddy widget display name",p),null}}),l=useRef(null),_=useCallback((p,x)=>{o(p),x&&i(x);try{localStorage.setItem(ht,p),x&&localStorage.setItem(xt,x);}catch(g){console.warn("Unable to persist BotBuddy widget auth token",g);}},[]);useEffect(()=>{let p=new URL(e).origin,x=g=>{g.origin===p&&g.data?.type==="botbuddy-widget-auth"&&g.data.token&&_(g.data.token,g.data.displayName||"human");};return window.addEventListener("message",x),()=>window.removeEventListener("message",x)},[e,_]);let y=useCallback(()=>{if(l.current)return l.current;if(typeof window>"u"||typeof document>"u")return Promise.resolve(null);let p=new URL(e).origin,x=new URL("/widget-auth",e);x.searchParams.set("silent","1"),x.searchParams.set("origin",window.location.origin);let g=new Promise(n=>{let d=document.createElement("iframe");d.setAttribute("aria-hidden","true"),d.style.position="fixed",d.style.width="1px",d.style.height="1px",d.style.opacity="0",d.style.pointerEvents="none",d.style.border="0",d.style.left="-9999px",d.style.top="-9999px",d.src=x.toString();let k=false,$=()=>{window.removeEventListener("message",z),clearTimeout(V);try{d.remove();}catch{}l.current=null;},z=S=>{if(S.origin===p){if(S.data?.type==="botbuddy-widget-auth-failed"){if(k)return;k=true,n(null),$();return}S.data?.type!=="botbuddy-widget-auth"||!S.data.token||k||(k=true,n(String(S.data.token)),$());}},V=setTimeout(()=>{k||(k=true,n(null),$());},zn);window.addEventListener("message",z),document.body.appendChild(d);});return l.current=g,g},[e]);useEffect(()=>{if(!t)return;let p=Ue(t);if(!p)return;let x=p-Date.now()-In,g=window.setTimeout(()=>{y();},Math.max(0,x));return ()=>window.clearTimeout(g)},[t,y]);let R=useCallback(()=>{let p=new URL("/widget-auth",e);p.searchParams.set("origin",window.location.origin);let x=420,g=520,n=window.screenX+(window.innerWidth-x)/2,d=window.screenY+(window.innerHeight-g)/2;window.open(p.toString(),"botbuddy-auth",`width=${x},height=${g},left=${n},top=${d},popup=yes`);},[e]),[,f]=useState(0);useEffect(()=>{let p=Ue(t);if(!p)return;let x=p-Date.now();if(x<=0)return;let g=window.setTimeout(()=>f(n=>n+1),x);return ()=>window.clearTimeout(g)},[t]);let h=useCallback(()=>{o(null),i(null);try{localStorage.removeItem(ht),localStorage.removeItem(xt);}catch(p){console.warn("Unable to clear BotBuddy widget auth token",p);}},[]),M=Ue(t),A=M!==null&&M<=Date.now();return {token:t,displayName:a,isAuthenticated:!!t,isExpired:A,openLogin:R,refreshNow:y,logout:h}}var Xe=null;function Un(){try{if(typeof document<"u"){let e=document.querySelector("base[href]");if(e)return new URL(".botbuddy-totp.json",e.href).toString()}}catch{}return "/.botbuddy-totp.json"}function Ze(){return Xe||(Xe=(async()=>{if(typeof fetch>"u")return null;try{let e=await fetch(Un(),{cache:"no-store"});if(!e.ok)return null;let t=await e.json();if(!t||typeof t!="object"||Array.isArray(t))return null;let o={};for(let[a,i]of Object.entries(t))typeof i=="string"&&i.length>0&&(o[a]=i);return o}catch{return null}})(),Xe)}async function Zt(e){return (await Ze())?.[e]??null}function Fn(e){let t=e.replace(/=+$/,"").replace(/\s+/g,"").toUpperCase(),o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",a=[],i=0,l=0;for(let _ of t){let y=o.indexOf(_);if(y<0)throw new Error("Invalid Base32 character in TOTP secret");l=l<<5|y,i+=5,i>=8&&(i-=8,a.push(l>>>i&255));}return Uint8Array.from(a)}async function Qt(e,t=Date.now()){if(typeof crypto>"u"||!crypto.subtle)throw new Error("Web Crypto unavailable");let o=Fn(e),a=new Uint8Array(o.byteLength);a.set(o);let i=Math.floor(t/1e3/30),l=new Uint8Array(8),_=Math.floor(i/4294967296),y=i>>>0;l[0]=_>>>24&255,l[1]=_>>>16&255,l[2]=_>>>8&255,l[3]=_&255,l[4]=y>>>24&255,l[5]=y>>>16&255,l[6]=y>>>8&255,l[7]=y&255;let R=await crypto.subtle.importKey("raw",a,{name:"HMAC",hash:"SHA-1"},false,["sign"]),f=await crypto.subtle.sign("HMAC",R,l),h=new Uint8Array(f),M=h[h.length-1]&15;return (((h[M]&127)<<24|(h[M+1]&255)<<16|(h[M+2]&255)<<8|h[M+3]&255)%1e6).toString().padStart(6,"0")}var en="0.11.0";function Dn(e){let t=new Date(e),a=Date.now()-t.getTime();if(a<6e4)return "just now";if(a<36e5)return `${Math.floor(a/6e4)}m ago`;if(a<864e5)return `${Math.floor(a/36e5)}h ago`;let i=t.getDate(),l=t.toLocaleString("en",{month:"short"}),_=t.toLocaleString("en",{hour:"numeric",minute:"2-digit",hour12:true});return `${l} ${i}, ${_}`}var E=({d:e,className:t,size:o=14})=>jsx("svg",{className:t,width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:e})}),w={clipboard:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2M9 5a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2",check:"M22 11.08V12a10 10 0 1 1-5.93-9.14M22 4 12 14.01l-3-3",x:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20M15 9l-6 6M9 9l6 6",circle:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20",skip:"M5 4l10 8-10 8V4M19 5v14",grip:"M9 5h.01M15 5h.01M9 12h.01M15 12h.01M9 19h.01M15 19h.01",minus:"M5 12h14",chevronUp:"M18 15l-6-6-6 6",chevronDown:"M6 9l6 6 6-6",externalLink:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6M15 3h6v6M10 14L21 3",pr:"M6 3v18M18 9a3 3 0 1 0 0-6 3 3 0 0 0 0 6M6 21a3 3 0 1 0 0-6 3 3 0 0 0 0 6M18 9a9 9 0 0 1-9 9",ticket:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",loader:"M21 12a9 9 0 1 1-6.219-8.56",checkAll:"M18 6L7 17l-5-5M22 10l-7.5 7.5L13 16",alert:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0M12 9v4M12 17h.01",bot:"M12 8V4H8M2 14h2M20 14h2M15 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M9 13a1 1 0 1 0 0 2 1 1 0 0 0 0-2M18 10a6 6 0 0 0-12 0v4a6 6 0 0 0 12 0Z",terminal:"M4 17l6-6-6-6M12 19h8",key:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4",shield:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",copy:"M20 9h-9a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-9a2 2 0 0 0-2-2ZM5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1",search:"M11 17.25a6.25 6.25 0 1 1 0-12.5 6.25 6.25 0 0 1 0 12.5ZM16 16l4.5 4.5"};function Wn(){let[e,t]=useState(()=>typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");return useEffect(()=>{if(typeof window>"u")return;let o=document.documentElement,a=()=>o.classList.contains("dark")?"dark":o.classList.contains("light")?"light":null,i=a();i&&t(i);let l=window.matchMedia("(prefers-color-scheme: dark)"),_=R=>{let f=a();t(f||(R.matches?"dark":"light"));};l.addEventListener("change",_);let y=new MutationObserver(()=>{let R=a();t(R||(l.matches?"dark":"light"));});return y.observe(o,{attributes:true,attributeFilter:["class"]}),()=>{l.removeEventListener("change",_),y.disconnect();}},[]),e}function Hn(e){let t=e==="dark";return {bg:t?"rgb(30,30,30)":"rgb(255,255,255)",bgSoft:t?"rgba(255,255,255,0.02)":"rgba(0,0,0,0.02)",text:t?"#e5e5e5":"#1a1a1a",textMuted:t?"rgba(255,255,255,0.4)":"rgba(0,0,0,0.45)",textFaint:t?"#555":"#999",border:t?"rgba(255,255,255,0.15)":"rgba(0,0,0,0.12)",borderSubtle:t?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.06)",shadow:t?"rgba(0,0,0,0.4)":"rgba(0,0,0,0.12)",inputBg:t?"rgba(0,0,0,0.3)":"rgba(0,0,0,0.04)",inputBorder:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.12)",green:"#34d399",greenBg:t?"rgba(52,211,153,0.05)":"rgba(52,211,153,0.08)",greenBorder:t?"rgba(52,211,153,0.6)":"rgba(52,211,153,0.5)",greenBorderSubtle:t?"rgba(52,211,153,0.2)":"rgba(52,211,153,0.15)",red:"#f87171",amber:"#f59e0b",blue:"#60a5fa",purple:"#a78bfa",versionText:t?"rgba(255,255,255,0.5)":"rgba(0,0,0,0.35)",versionNum:t?"rgba(255,255,255,0.3)":"rgba(0,0,0,0.2)",gripColor:t?"#888":"#aaa",btnHover:t?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)"}}var Kn={pending:"#888",pass:"#34d399",fail:"#f87171",skip:"#f59e0b"},jn={pending:w.circle,pass:w.check,fail:w.x,skip:w.skip},tn={local:{bg:"rgba(59,130,246,0.15)",text:"#60a5fa",border:"rgba(59,130,246,0.3)"},preview:{bg:"rgba(168,85,247,0.15)",text:"#c084fc",border:"rgba(168,85,247,0.3)"},staging:{bg:"rgba(245,158,11,0.15)",text:"#fbbf24",border:"rgba(245,158,11,0.3)"},production:{bg:"rgba(239,68,68,0.15)",text:"#f87171",border:"rgba(239,68,68,0.3)"},custom:{bg:"rgba(128,128,128,0.15)",text:"#888",border:"rgba(128,128,128,0.3)"}},Vn=["app.supply-guard.io"];function Yn(e,t=[]){if(!e)return false;let o=e.toLowerCase();return [...Vn,...t].map(i=>i.toLowerCase()).includes(o)}var Jn=e=>({root:{position:"fixed",zIndex:9999,userSelect:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},pill:t=>({display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 8px",borderRadius:"9999px",background:e.bg,border:t?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:t?`0 4px 12px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 4px 12px ${e.shadow}`,cursor:"pointer",fontSize:"9px",color:e.text}),card:(t,o)=>({width:`${t}px`,borderRadius:"8px",background:e.bg,border:o?`1px solid ${e.greenBorder}`:`1px solid ${e.border}`,boxShadow:o?`0 8px 24px ${e.shadow}, 0 0 0 1px ${e.greenBorderSubtle}`:`0 8px 24px ${e.shadow}`,overflow:"hidden",display:"flex",flexDirection:"column"}),handle:{padding:"8px 12px",display:"flex",alignItems:"center",gap:"8px",cursor:"grab",borderBottom:`1px solid ${e.borderSubtle}`},title:{fontSize:"10px",fontWeight:600,color:e.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},sub:{fontSize:"9px",color:e.textMuted,display:"flex",alignItems:"center",gap:"6px"},btn:{padding:"2px",borderRadius:"4px",background:"transparent",border:"none",cursor:"pointer",color:e.gripColor,display:"flex",flexShrink:0},stats:{padding:"4px 12px",display:"flex",alignItems:"center",gap:"8px",fontSize:"9px",borderBottom:`1px solid ${e.borderSubtle}`},badge:t=>{let o=tn[t]||tn.custom;return {fontSize:"8px",padding:"0 4px",borderRadius:"4px",background:o.bg,color:o.text,border:`1px solid ${o.border}`,lineHeight:"14px"}},progress:{height:"2px",background:e.borderSubtle,flexShrink:0},progressBar:t=>({height:"100%",width:`${t}%`,background:"linear-gradient(to right, #34d399, #3b82f6)",transition:"width 0.5s"}),link:t=>({display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${t}15`,color:t,textDecoration:"none",border:"none",cursor:"pointer"}),caseRow:{padding:"6px 12px",borderBottom:`1px solid ${e.borderSubtle}`,transition:"background 0.15s"},verdictBtn:(t,o)=>({fontSize:"8px",padding:"2px 6px",borderRadius:"4px",border:"none",cursor:"pointer",background:t?`${o}33`:"transparent",color:t?o:e.gripColor,transition:"all 0.15s"}),input:{flex:1,fontSize:"9px",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:"4px",padding:"2px 6px",color:e.text,outline:"none"},humanBanner:{padding:"6px 12px",fontSize:"11px",fontWeight:600,color:e.green,borderBottom:`1px solid ${e.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",background:e.greenBg,cursor:"pointer",textDecoration:"none"}});function wt(e){return e.split("/")[0].trim()}async function qn(e){try{if(typeof navigator<"u"&&navigator.clipboard?.writeText)return await navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return !1;let t=document.createElement("textarea");t.value=e,t.setAttribute("readonly",""),t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t),t.focus(),t.select(),t.setSelectionRange(0,e.length);let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return false}}function Fe({config:e,appSlug:t,environment:o,seededUsers:a,authToken:i,tk:l,compact:_=false,onExpand:y,onAuthExpired:R,refreshAuth:f,requestLogin:h,testRunId:M,testRunToken:A,ticketId:p,targetUrl:x,version:g,commitSha:n,prNumber:d,branchName:k}){let[$,z]=useState(false),[V,S]=useState(null),[D,pe]=useState(null),[ie,m]=useState(null),[we,C]=useState(null),[T,W]=useState(null),[G,X]=useState(null);useEffect(()=>{o==="local"&&Ze();},[o]);let ce=useCallback(u=>{S(u),m(null),C(null),X(null);let O=Ue(i);if(o!=="local"&&h&&O!==null&&O<=Date.now()){W({slug:u,token:i||null}),X(u),S(null),h();return}let I=B=>{m(B),C(u),window.setTimeout(()=>{C(U=>U===u?null:U),m(U=>U===B?null:U);},3e3);},L=new URLSearchParams({app_slug:t,seed_user_slug:u,environment:o});M&&L.set("test_run_id",M),A&&L.set("public_token",A),p&&L.set("ticket_id",p),x&&L.set("target_url",x),g&&L.set("version",g),n&&L.set("commit_sha",n),d&&L.set("pr_number",String(d)),k&&L.set("branch_name",k);let H=async B=>{let U={apikey:e.anonKey,Authorization:`Bearer ${B}`};try{let j=await fetch(`${e.serverUrl}/widget/totp-code?${L}`,{headers:U});if(!j.ok){let ke=await j.json().catch(()=>({error:`HTTP ${j.status}`}));return {ok:!1,status:j.status,error:ke.error||`HTTP ${j.status}`}}let oe=await j.json();return {ok:!0,code:String(oe.code)}}catch{return {ok:false,status:0,error:"Network error"}}},Z=(async()=>{if(o==="local"){let j=await Zt(u);if(j)try{return {ok:!0,code:await Qt(j)}}catch{}}let B=await H(i||e.anonKey);if(B.ok||B.status!==401||!f)return B;let U=await f();return U?H(U):{ok:false,status:401,error:"Sign in to BotBuddy to refresh 2FA"}})(),Y=null;try{if(typeof ClipboardItem<"u"&&navigator.clipboard?.write){let B=Z.then(U=>{if(!U.ok)throw new Error(U.error);return new Blob([U.code],{type:"text/plain"})});Y=navigator.clipboard.write([new ClipboardItem({"text/plain":B})]).then(()=>!0).catch(()=>!1);}}catch{}(async()=>{let B=await Z;if(!B.ok){B.status===401?(W({slug:u,token:i||null}),X(u)):I(B.status===404?"No 2FA seed registered":B.error),S(null);return}let U=Y?await Y:false,j=U?true:await qn(B.code),oe=U||j;pe({slug:u,code:B.code,copied:oe}),window.setTimeout(()=>pe(ke=>ke?.slug===u?null:ke),oe?2500:6e3),z(false),S(null);})();},[e.serverUrl,e.anonKey,i,t,o,M,A,p,x,g,n,d,k,f,h]),re=useCallback(u=>{W({slug:u,token:i||null}),h?.();},[i,h]),Re=useCallback(u=>{G===u?re(u):ce(u);},[G,re,ce]);useEffect(()=>{if(!T||!i||i===T.token)return;let u=T.slug;W(null),ce(u);},[i,ce,T]);let Ne=useRef(null),Be=useRef(null);if(useLayoutEffect(()=>{if(!$)return;let u=Ne.current,O=Be.current;if(!u||!O||typeof window>"u")return;let I=()=>{let L=u.getBoundingClientRect(),H=O.getBoundingClientRect(),Z=window.innerWidth,Y=window.innerHeight,B=L.left,U=L.top-H.height-6;U<8&&(U=L.bottom+6);let j=Math.max(8,Z-H.width-8),oe=Math.max(8,Y-H.height-8);B=Math.min(Math.max(B,8),j),U=Math.min(Math.max(U,8),oe),O.style.left=`${Math.round(B)}px`,O.style.top=`${Math.round(U)}px`;};return I(),window.addEventListener("scroll",I,true),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,true),window.removeEventListener("resize",I);}},[$,a.length,ie]),useEffect(()=>{if(!$)return;let u=O=>{let I=O.target;Be.current?.contains(I)||Ne.current?.contains(I)||z(false);};return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[$]),a.length===0)return null;if(_){let u=a.length>1,O=a[0],I=!u&&G===O,L=j=>{if(j.stopPropagation(),u&&y){y();return}Re(O);},H=!!we,Z=!!D,Y=Z&&D.copied,B=Z&&!D.copied,U=I?l.blue:H?l.red:Y?l.green:B?l.amber:l.purple;return jsxs("span",{onPointerDown:j=>j.stopPropagation(),onPointerUp:j=>j.stopPropagation(),onPointerMove:j=>j.stopPropagation(),onClick:L,style:{display:"inline-flex",alignItems:"center",gap:"3px",color:U,fontWeight:600,cursor:"pointer",letterSpacing:B?"0.08em":void 0},title:I?"Sign in to BotBuddy to refresh 2FA":H?ie||"Failed":B?`Clipboard blocked \u2014 code: ${D.code}`:u?`${a.length} 2FA personas`:`Copy 2FA code for ${a[0]}`,children:[jsx(E,{d:I?w.key:H?w.alert:Y?w.check:B?w.copy:w.shield,size:10}),I?jsx(Fragment,{children:"Sign in"}):Y?jsx(Fragment,{children:"Copied"}):B?jsx(Fragment,{children:D.code}):H?jsx(Fragment,{children:"Failed"}):jsxs(Fragment,{children:["2FA",u&&` \xB7${a.length}`]})]})}if(a.length===1){let u=a[0],O=V===u,I=D?.slug===u,L=I&&D.copied,H=I&&!D.copied,Z=we===u,Y=G===u,B=Y?l.blue:Z?l.red:L?l.green:H?l.amber:l.purple;return jsxs("button",{onClick:U=>{U.stopPropagation(),Re(u);},disabled:O,style:{...nn(B),cursor:O?"wait":"pointer",opacity:O?.6:1},title:Y?"Sign in to BotBuddy to refresh 2FA":Z?ie||"Failed":H?`Clipboard blocked \u2014 code: ${D.code}`:`Copy 2FA code for ${u}`,children:[jsx(E,{d:Y?w.key:Z?w.alert:L?w.check:H?w.copy:w.shield,size:12}),Y?"Sign in":L?"Copied":H?D.code:Z?"Failed":O?"\u2026":`2FA \xB7 ${u}`]})}let be=!!G&&!$,ae=!!we&&!$,Ce=!!D&&D.copied,Te=!!D&&!D.copied,ot=be?l.blue:ae?l.red:Ce?l.green:Te?l.amber:l.purple,st=$&&typeof document<"u"?createPortal(jsxs("div",{ref:Be,onPointerDown:u=>u.stopPropagation(),onMouseDown:u=>u.stopPropagation(),style:{position:"fixed",left:-9999,top:-9999,background:l.bg,border:`1px solid ${l.border}`,borderRadius:6,boxShadow:`0 8px 24px ${l.shadow}`,padding:4,minWidth:220,maxWidth:typeof window<"u"?Math.min(420,window.innerWidth-16):420,zIndex:1e5,fontFamily:"ui-monospace, SFMono-Regular, monospace"},children:[a.map(u=>{let O=V===u,I=G===u;return jsxs("button",{onClick:L=>{L.stopPropagation(),Re(u);},disabled:O,style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"5px 8px",background:"transparent",border:"none",borderRadius:4,cursor:O?"wait":"pointer",fontSize:"10px",color:I?l.blue:l.text,textAlign:"left",fontFamily:"ui-monospace, SFMono-Regular, monospace"},title:I?"Sign in to BotBuddy to refresh 2FA":void 0,onMouseEnter:L=>L.currentTarget.style.background=l.btnHover,onMouseLeave:L=>L.currentTarget.style.background="transparent",children:[jsx(E,{d:I?w.key:w.shield,size:10}),jsx("span",{style:{flex:1,overflowWrap:"anywhere",lineHeight:1.3},children:u}),I?jsx("span",{style:{color:l.blue,fontSize:9},children:"Sign in"}):O?jsx("span",{style:{color:l.textMuted,fontSize:9},children:"\u2026"}):null]},u)}),ie&&jsx("div",{style:{padding:"4px 8px",fontSize:9,color:l.red},children:ie})]}),document.body):null;return jsxs(Fragment,{children:[jsxs("button",{ref:Ne,onClick:u=>{if(u.stopPropagation(),be&&G){re(G);return}z(O=>!O),m(null),C(null);},style:{...nn(ot),cursor:"pointer"},title:be?"Sign in to BotBuddy to refresh 2FA":ae?ie||"Failed":Te?`Clipboard blocked \u2014 code: ${D.code}`:"Choose a persona to copy a 2FA code for",children:[jsx(E,{d:be?w.key:ae?w.alert:Ce?w.check:Te?w.copy:w.shield,size:12}),be?"Sign in":Ce?"Copied":Te?D.code:ae?"Failed":`2FA \xB7 ${a.length}`,!be&&jsx(E,{d:$?w.chevronUp:w.chevronDown,size:8})]}),st]})}function nn(e){return {display:"inline-flex",alignItems:"center",gap:"4px",fontSize:"9px",padding:"2px 6px",borderRadius:"4px",background:`${e}15`,color:e,textDecoration:"none",border:`1px solid ${e}30`}}var rn="botbuddy-widget-state";function Gn({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:_,version:y,commitSha:R,prNumber:f,branchName:h,onNavigate:M,displayName:A="human",defaultMode:p="mini",defaultPosition:x}){let g=Wn(),n=useMemo(()=>Hn(g),[g]),d=useMemo(()=>Jn(n),[n]),[k,$]=useState(false),[z,V]=useState(false),[S,D]=useState(false),pe=useRef(false),ie=e.dashboardUrl||"https://app.bot-buddy.ai",m=vt(ie),C=(()=>{try{let r=typeof window<"u"?localStorage.getItem(rn):null;if(r)return JSON.parse(r)}catch{}return null})(),[T,W]=useState(C?.mode||p),[G,X]=useState(""),[ce,re]=useState(null),[Re,Ne]=useState(null),[Be,be]=useState(new Set),[ae,Ce]=useState(""),Te=useCallback(r=>{be(b=>{let N=new Set(b);return N.has(r)?N.delete(r):N.add(r),N});},[]),ot=C?.x??x?.x??16,st=C?.y??x?.y??(typeof window<"u"?window.innerHeight-56:600),{pos:u,setPos:O,onPointerDown:I,onPointerMove:L,onPointerUp:H,didDrag:Z}=pt(ot,st),Y=useRef(null);useEffect(()=>{try{localStorage.setItem(rn,JSON.stringify({mode:T,x:u.x,y:u.y}));}catch{}},[T,u.x,u.y]),useLayoutEffect(()=>{if(typeof window>"u")return;let r=Y.current;if(!r)return;let b=r.getBoundingClientRect(),N=ut(u.x,u.y,b.width,b.height,window.innerWidth,window.innerHeight);(N.x!==u.x||N.y!==u.y)&&O(N);}),useEffect(()=>{if(typeof window>"u")return;let r=()=>{let b=Y.current;if(!b)return;let N=b.getBoundingClientRect(),J=ut(u.x,u.y,N.width,N.height,window.innerWidth,window.innerHeight);(J.x!==u.x||J.y!==u.y)&&O(J);};return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[u.x,u.y,O]);let B=useRef(m.isAuthenticated);useEffect(()=>{!B.current&&m.isAuthenticated&&W("max"),B.current=m.isAuthenticated;},[m.isAuthenticated]);let U="botbuddy-widget-max-size",j=()=>{try{let r=localStorage.getItem(U);if(r)return JSON.parse(r)}catch{}return {w:340,h:500}},[oe,ke]=useState(j),ze=useRef(false),Ie=useRef({x:0,y:0,w:0,h:0}),yn=useCallback(r=>{r.stopPropagation(),ze.current=true,Ie.current={x:r.clientX,y:r.clientY,w:oe.w,h:oe.h},r.target.setPointerCapture(r.pointerId);},[oe]),hn=useCallback(r=>{if(!ze.current)return;let b=Math.max(280,Math.min(600,Ie.current.w+(r.clientX-Ie.current.x))),N=Math.max(300,Math.min(window.innerHeight*.9,Ie.current.h+(r.clientY-Ie.current.y)));ke({w:b,h:N});},[]),xn=useCallback(()=>{ze.current&&(ze.current=false,ke(r=>(localStorage.setItem(U,JSON.stringify(r)),r)));},[]),le=_??(typeof window<"u"?window.location.href:void 0),Mt=m.displayName||A,[ge,$t]=useState(null);useEffect(()=>{if(m.isAuthenticated)return;let r=new URLSearchParams;l&&r.set("token",l),a&&r.set("ticket_id",a),r.set("app_slug",t),o&&r.set("environment",o),i&&r.set("test_run_id",i),le&&r.set("target_url",le),y&&r.set("version",y),R&&r.set("commit_sha",R),f&&r.set("pr_number",String(f)),h&&r.set("branch_name",h),fetch(`${e.serverUrl}/widget/preview?${r}`,{headers:{apikey:e.anonKey}}).then(b=>b.json()).then(b=>$t(b)).catch(()=>$t(null));},[m.isAuthenticated,e.serverUrl,e.anonKey,t,o,a,i,l,le,y,R,f,h]);let At=useRef(false),vn=useCallback(()=>{At.current||m.logout();},[m.logout]),{run:v,widgetState:Se,fetchRun:wn,setVerdict:Pt,markComplete:kn,resetRun:Sn,setRun:Lt}=bt({config:e,appSlug:t,environment:o,ticketId:a,testRunId:i,testRunToken:l,targetUrl:le,version:y,commitSha:R,prNumber:f?String(f):void 0,branchName:h,authToken:m.token,onAuthExpired:vn});At.current=!!v;let[Bt,zt]=useState([]),[It,je]=useState([]),[it,Ut]=useState(false),[Ft,Ot]=useState(null),[_n,Ve]=useState(false),me=Yn(typeof window<"u"?window.location.hostname:void 0,e.productionHostnames||[]);useEffect(()=>{if((o??"local")!=="local"||me){zt([]);return}let r=true;return Ze().then(b=>{r&&zt(Object.keys(b||{}));}),()=>{r=false;}},[o,me]);let Rn=useCallback(async()=>{if(!(!m.isAuthenticated||!m.token)){Ut(true),Ot(null);try{let r=await fetch(`${e.serverUrl}/widget/test-runs`,{method:"POST",headers:{"Content-Type":"application/json",apikey:e.anonKey,Authorization:`Bearer ${m.token}`},body:JSON.stringify({app_slug:t,environment:o||"local",target_url:le,branch_name:h,commit_sha:R,pr_number:f,ticket_id:a,title:`${a||t} local validation`})}),b=await r.json().catch(()=>({}));if(!r.ok)throw new Error(b.error||`HTTP ${r.status}`);Lt(b),W("max");}catch(r){Ot(r.message);}finally{Ut(false);}}},[m.isAuthenticated,m.token,e.serverUrl,e.anonKey,t,o,le,h,R,f,a,Lt]),Ye=useCallback(async(r,b,N)=>{Ne(r);try{await Pt(r,b,N,Mt);}finally{Ne(null),re(null),X("");}},[Pt,Mt]),q=v?.summary||{total:0,pending:0,pass:0,fail:0,skip:0},Nn=q.total>0&&q.pending===0,Ee=Se==="completed",Je=useMemo(()=>{let r=v?.test_cases||[];if(!ae.trim())return r;let b=ae.toLowerCase();return r.filter(N=>N.title.toLowerCase().includes(b)||N.description&&N.description.toLowerCase().includes(b)||N.url_path&&N.url_path.toLowerCase().includes(b)||N.seed_user&&N.seed_user.toLowerCase().includes(b))},[v?.test_cases,ae]),Dt=useMemo(()=>{let r=Je,b=v?.test_cases||[];if(new Set(b.map(te=>te.source_pr_number)).size<=1)return null;let J=[],he=new Map;r.forEach(te=>{let ee=te.source_pr_number;he.has(ee)||he.set(ee,[]),he.get(ee).push(te);});let qt=[...he.keys()].sort((te,ee)=>te===null?1:ee===null?-1:ee-te);for(let te of qt){let ee=he.get(te),lt={total:ee.length,pass:0,fail:0,skip:0,pending:0};ee.forEach(Gt=>{Gt.verdict in lt&<[Gt.verdict]++;}),J.push({key:te!=null?`pr-${te}`:"general",label:te!=null?`PR #${te}`:"General",cases:ee,summary:lt});}return J.filter(te=>te.cases.length>0)},[Je,v?.test_cases]),Wt=q.total>0?(q.pass+q.fail)/q.total*100:0,Q=o??v?.environment??null,ye=useMemo(()=>{if(!Q||Q==="production"||me)return [];let r=v?.test_cases||[],b=new Set;for(let N of r)N.seed_user&&b.add(wt(N.seed_user));if(Q==="local")for(let N of Bt)b.add(wt(N));for(let N of It)b.add(wt(N));return [...b]},[v?.test_cases,Q,Bt,It,me]);useEffect(()=>{if(!Q||Q==="production"||me||!m.isAuthenticated||!m.token){je([]);return}let r=true,b=`${e.serverUrl}/widget/totp-seeds?${new URLSearchParams({app_slug:t,environment:Q})}`,N=J=>fetch(b,{headers:{apikey:e.anonKey,Authorization:`Bearer ${J}`}});return (async()=>{try{let J=await N(m.token);if(J.status===401&&m.refreshNow){let ee=await m.refreshNow();ee&&(J=await N(ee));}if(!r)return;if(!J.ok){je([]);return}let he=await J.json().catch(()=>null),te=(Array.isArray(he?.seeds)?he.seeds:[]).map(ee=>ee?.seed_user_slug).filter(ee=>typeof ee=="string"&&ee.length>0);je(te);}catch{r&&je([]);}})(),()=>{r=false;}},[Q,me,m.isAuthenticated,m.token,m.refreshNow,t,e.serverUrl,e.anonKey]);let at=useMemo(()=>{let r=v?.auto_tooltip_seconds??ge?.auto_tooltip_seconds;return r!=null&&r>0?r*1e3:0},[v,ge]),Ht=Se==="ready"||Se==="completed"||ge?.enabled&&ge.run;useEffect(()=>{if(!Ht||pe.current||at<=0)return;pe.current=true,V(true);let r=window.setTimeout(()=>V(false),at);return ()=>window.clearTimeout(r)},[Ht,at]);let Kt=r=>jsxs("div",{style:d.caseRow,children:[jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[jsx("div",{style:{marginTop:"2px",flexShrink:0,color:Kn[r.verdict]},children:Re===r.id?jsx(E,{d:w.loader,className:""}):jsx(E,{d:jn[r.verdict],className:""})}),jsxs("div",{style:{minWidth:0,flex:1},children:[jsx("div",{style:{fontSize:"10px",color:n.text,lineHeight:1.3},children:r.title}),r.description&&jsx("div",{style:{fontSize:"9px",color:n.gripColor,marginTop:"2px"},children:r.description}),r.seed_user&&jsxs("div",{style:{fontSize:"9px",color:n.amber,marginTop:"3px",display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 6px",borderRadius:"4px",background:`${n.amber}12`,border:`1px solid ${n.amber}30`},children:[jsx(E,{d:w.key,size:10}),jsx("span",{children:r.seed_user})]}),r.url_path&&jsxs("a",{href:r.url_path,target:"_blank",rel:"noopener noreferrer",onClick:b=>{b.stopPropagation(),M&&(b.preventDefault(),M(r.url_path));},style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",padding:"2px 0",marginTop:"2px",display:"inline-flex",alignItems:"center",gap:"2px",textDecoration:"none",position:"relative",zIndex:1,pointerEvents:"auto"},children:[jsx(E,{d:w.externalLink,size:10}),r.url_path]}),r.verdict==="fail"&&r.fail_reason&&jsxs("div",{style:{fontSize:"9px",color:n.red,marginTop:"2px"},children:["\u2717 ",r.fail_reason]})]})]}),jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginTop:"4px",marginLeft:"22px"},children:[["pass","fail","skip"].map(b=>jsx("button",{onClick:()=>{if(r.verdict===b){Ye(r.id,"pending"),re(null);return}if(b==="fail"){re(r.id),X("");return}re(null),Ye(r.id,b);},disabled:Re!==null,style:d.verdictBtn(r.verdict===b,b==="pass"?n.green:b==="fail"?n.red:n.amber),children:b.toUpperCase()},b)),r.created_by_agent_name&&jsxs("span",{style:{fontSize:"8px",color:n.purple,marginLeft:"4px",display:"inline-flex",alignItems:"center",gap:"2px"},children:[jsx(E,{d:w.bot,size:8}),r.created_by_agent_name]}),r.verdict_by_display_name&&jsxs("span",{style:{fontSize:"8px",color:n.textFaint,marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:"3px"},children:[r.verdict_by_display_name,r.verdict_at&&jsx("span",{style:{opacity:.7},children:Dn(r.verdict_at)})]})]}),ce===r.id&&jsxs("div",{style:{marginLeft:"22px",marginTop:"4px",display:"flex",gap:"4px"},children:[jsx("input",{autoFocus:true,value:G,onChange:b=>X(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Ye(r.id,"fail",G.trim()||void 0),b.key==="Escape"&&(re(null),X(""));},placeholder:"Reason (optional)...",style:d.input}),jsx("button",{onClick:()=>{Ye(r.id,"fail",G.trim()||void 0);},style:d.verdictBtn(true,n.red),children:"\u2713"})]})]},r.id);if((Se==="no-match"||Se==="loading")&&!(!m.isAuthenticated&&ge?.enabled&&ge.run)){if(!(Q==="local"&&!me))return null}if(!m.isAuthenticated&&ge?.enabled&&ge.run){let r=ge.run,b=r.summary,N=r.status==="completed";return jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxs("div",{style:{position:"relative"},onMouseEnter:()=>$(true),onMouseLeave:()=>{$(false),D(false),V(false);},children:[jsxs("div",{style:{...d.pill(N),gap:"8px",padding:"5px 10px",fontSize:"10px"},onPointerDown:I,onPointerMove:L,onPointerUp:()=>{H();},children:[jsx(E,{d:w.grip,size:10,className:""}),r.ticket_id&&r.ticket_url?jsx("a",{href:r.ticket_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.amber,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:r.ticket_id}):null,r.pr_url?jsxs("a",{href:r.pr_url,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.blue,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:["PR#",r.pr_number??r.pr_id]}):null,r.created_by_agent_name?r.codex_thread_id?jsxs("a",{href:`codex://threads/${r.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",onClick:J=>J.stopPropagation(),style:{color:n.purple,textDecoration:"none",fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsx(E,{d:w.terminal,size:10}),r.created_by_agent_name]}):jsxs("span",{style:{color:n.purple,fontWeight:600,display:"inline-flex",alignItems:"center",gap:"3px"},children:[jsx(E,{d:w.bot,size:10}),r.created_by_agent_name]}):null,jsxs("span",{style:N?{color:n.green}:void 0,children:[b.pass,"/",b.total]}),b.fail>0&&jsxs("span",{style:{color:n.red},children:[b.fail,"\u2717"]}),jsx("span",{onClick:J=>{J.stopPropagation(),m.openLogin();},style:{color:n.textMuted,fontWeight:400,cursor:"pointer",textDecoration:"underline",textUnderlineOffset:"2px"},children:"Sign in"})]}),!S&&(k||z)&&r.title&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:r.title}),(r.description||r.intro_notes)&&jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:r.description||r.intro_notes}),jsx("div",{style:{marginTop:"4px",fontSize:"9px",color:n.textFaint},children:'Click "Sign in" to start testing'})]})]})})}if(!m.isAuthenticated)return jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y,width:220,minHeight:0,cursor:"move",userSelect:"none",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`},onPointerDown:I,onPointerMove:L,onPointerUp:H,children:[jsx("div",{style:{...d.handle,borderBottom:"none"},children:jsxs("div",{style:d.sub,children:[jsx(E,{d:w.grip,size:10,className:""}),jsx(E,{d:w.clipboard,size:12,className:""}),jsx("span",{style:{fontWeight:600},children:"BotBuddy"})]})}),jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[jsx("div",{style:{fontSize:"9px",color:n.textMuted,marginBottom:"8px"},children:"Sign in to access test cases"}),Q==="local"&&ye.length>0&&jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"10px",fontWeight:600,padding:"6px 16px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:"pointer",width:"100%"},children:"Sign in to test"})]})]});if(!v&&Q==="local"&&!me)return _n?jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxs("div",{style:d.card(240,false),children:[jsxs("div",{style:d.handle,onPointerDown:I,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||Ve(false);},children:[jsx(E,{d:w.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:d.title,children:"BotBuddy"}),h&&jsx("div",{style:d.sub,children:jsxs("span",{children:["\u2387 ",h]})})]}),jsx(E,{d:w.chevronUp,className:""}),jsx("button",{style:d.btn,onClick:r=>{r.stopPropagation(),Ve(false);},children:jsx(E,{d:w.minus,className:""})})]}),jsxs("div",{style:{padding:"12px 14px",textAlign:"center"},children:[ye.length>0&&jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"8px"},children:jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})}),jsx("button",{onClick:r=>{r.stopPropagation(),Rn();},disabled:it,style:{fontSize:"10px",fontWeight:600,padding:"6px 12px",borderRadius:"6px",border:`1px solid ${n.green}`,background:`${n.green}22`,color:n.green,cursor:it?"wait":"pointer",width:"100%"},children:it?"Creating...":"Create test run for this branch"}),Ft&&jsx("div",{style:{fontSize:"9px",color:n.red,marginTop:"8px"},children:Ft})]})]})}):jsx("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:jsxs("div",{style:{...d.pill(false),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:I,onPointerMove:L,onPointerUp:()=>{H(),Z.current||Ve(true);},children:[jsx(E,{d:w.grip,size:9,className:""}),jsx("span",{style:{fontWeight:600},children:"BotBuddy"}),ye.length>0&&jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>Ve(true),testRunId:i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]})});let jt=()=>{Z.current||(V(false),W(r=>{let b=r==="mini"?"max":"mini";return D(b==="mini"),b}));},Vt=({icon:r,onClick:b})=>jsx("button",{style:d.btn,onClick:N=>{N.stopPropagation(),b(N);},children:jsx(E,{d:r,className:""})}),Yt=()=>jsxs("div",{style:{padding:"6px 12px",display:"flex",gap:"8px",flexWrap:"wrap",alignItems:"center",borderTop:`1px solid ${n.borderSubtle}`,flexShrink:0},children:[v?.pr_url&&jsxs("a",{href:v.pr_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.blue),textDecoration:"none"},children:[jsx(E,{d:w.pr,size:12}),v.pr_number?`PR#${v.pr_number}`:v.pr_id||"PR",jsx(E,{d:w.externalLink,size:8})]}),v?.ticket_url&&jsxs("a",{href:v.ticket_url,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.amber),textDecoration:"none"},children:[jsx(E,{d:w.ticket,size:12}),v.ticket_id||"Ticket",jsx(E,{d:w.externalLink,size:8})]}),v?.created_by_agent_name&&(v.codex_thread_id?jsxs("a",{href:`codex://threads/${v.codex_thread_id}`,target:"_blank",rel:"noopener noreferrer",style:{...d.link(n.purple),textDecoration:"none"},children:[jsx(E,{d:w.bot,size:12}),v.created_by_agent_name,jsx(E,{d:w.externalLink,size:8})]}):jsxs("span",{style:{...d.link(n.purple)},children:[jsx(E,{d:w.bot,size:12}),v.created_by_agent_name]})),Q&&jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout}),jsx("span",{style:{...d.badge(v?.environment||"custom"),marginLeft:"auto"},children:v?.environment})]}),Jt=()=>jsxs("div",{style:{padding:"4px 12px",display:"flex",alignItems:"center",justifyContent:"center",borderTop:`1px solid ${n.borderSubtle}`,background:n.bgSoft,flexShrink:0},children:[jsxs("button",{onClick:()=>{navigator.clipboard.writeText(en);},style:{fontSize:"9px",fontWeight:600,color:n.versionText,letterSpacing:"0.08em",background:"none",border:"none",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"4px",padding:0},title:"Copy version",children:["BotBuddy ",jsxs("span",{style:{color:n.versionNum},children:["v",en]})]}),m.isAuthenticated&&(m.isExpired?jsx("button",{onClick:r=>{r.stopPropagation(),m.openLogin();},style:{fontSize:"8px",color:n.blue,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Widget session expired \u2014 sign in to refresh",children:"sign in"}):jsx("button",{onClick:r=>{r.stopPropagation(),m.logout();},style:{fontSize:"8px",color:n.textFaint,background:"none",border:"none",cursor:"pointer",marginLeft:"8px",padding:"0 4px",textDecoration:"underline"},title:"Sign out of widget",children:"sign out"}))]});return jsxs("div",{ref:Y,style:{...d.root,left:u.x,top:u.y},children:[T==="mini"&&jsxs("div",{style:{position:"relative"},onMouseEnter:()=>$(true),onMouseLeave:()=>{$(false),D(false),V(false);},children:[jsxs("div",{style:{...d.pill(Ee),gap:"6px",padding:"3px 8px",fontSize:"9px"},onPointerDown:I,onPointerMove:L,onPointerUp:()=>{H(),Z.current||jt();},children:[jsx(E,{d:w.grip,size:9,className:""}),v?.ticket_id&&jsx("span",{style:{color:n.amber,fontWeight:600},children:v.ticket_id}),v?.pr_number&&jsxs("span",{style:{color:n.blue,fontWeight:600},children:["PR#",v.pr_number]}),jsxs("span",{style:Ee?{color:n.green}:void 0,children:[q.pass,"/",q.total]}),q.fail>0&&jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),Q&&jsx(Fe,{config:e,appSlug:t,environment:Q,seededUsers:ye,authToken:m.token,refreshAuth:m.refreshNow,requestLogin:m.openLogin,tk:n,compact:true,onExpand:()=>W("expanded"),testRunId:v?.id||i,testRunToken:l,ticketId:a,targetUrl:le,version:y,commitSha:R,prNumber:f,branchName:h,onAuthExpired:m.logout})]}),!S&&(k||z)&&v?.title&&jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",left:0,minWidth:"180px",maxWidth:"260px",padding:"8px 12px",borderRadius:"8px",background:n.bg,border:`1px solid ${n.border}`,boxShadow:`0 8px 24px ${n.shadow}`,pointerEvents:"none",fontFamily:"ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace"},children:[jsx("div",{style:{fontSize:"11px",fontWeight:700,color:n.text,lineHeight:1.3,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:v.title}),(v.description||v.intro_notes)&&jsx("div",{style:{fontSize:"10px",color:n.textMuted,marginTop:"4px",lineHeight:1.35,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical"},children:v.description||v.intro_notes})]})]}),T==="expanded"&&jsxs("div",{style:d.card(300,Ee),children:[jsxs("div",{style:d.handle,onPointerDown:I,onPointerMove:L,onPointerUp:H,onClick:jt,children:[jsx(E,{d:w.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:d.title,children:v?.title}),jsx("div",{style:d.sub,children:v?.branch_name&&jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsx(E,{d:w.chevronUp,className:""}),jsx(Vt,{icon:w.minus,onClick:()=>{V(false),D(true),W("mini");}})]}),jsxs("div",{style:d.stats,children:[jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.description&&jsx("div",{style:{padding:"6px 12px",fontSize:"10px",color:n.gripColor,borderBottom:`1px solid ${n.borderSubtle}`,flexShrink:0},children:v.description}),Yt(),Jt(),jsx("div",{style:d.progress,children:jsx("div",{style:d.progressBar(Wt)})})]}),T==="max"&&jsxs("div",{style:{...d.card(oe.w,Ee),height:oe.h,position:"relative"},children:[jsxs("div",{style:d.handle,onPointerDown:I,onPointerMove:L,onPointerUp:H,onClick:()=>{Z.current||W("expanded");},children:[jsx(E,{d:w.grip,className:""}),jsxs("div",{style:{flex:1,minWidth:0},children:[jsx("div",{style:d.title,children:v?.title}),jsx("div",{style:d.sub,children:v?.branch_name&&jsxs("span",{children:["\u2387 ",v.branch_name]})})]}),jsx(E,{d:w.chevronDown,className:""}),jsx(Vt,{icon:w.minus,onClick:()=>{V(false),D(true),W("mini");}})]}),jsxs("div",{style:d.stats,children:[jsxs("span",{style:{color:n.green},children:[q.pass,"\u2713"]}),jsxs("span",{style:{color:n.red},children:[q.fail,"\u2717"]}),jsxs("span",{style:{color:n.amber},children:[q.skip,"\u23ED"]}),jsxs("span",{style:{color:n.gripColor},children:[q.pending,"\u25CC"]}),jsx("span",{style:{color:n.textFaint,marginLeft:"auto"},children:q.total})]}),v?.intro_notes&&jsx("div",{style:{padding:"6px 12px",borderBottom:`1px solid ${n.borderSubtle}`,fontSize:"10px",color:n.textMuted,fontStyle:"italic",flexShrink:0},children:v.intro_notes}),(v?.test_cases||[]).length>5&&jsxs("div",{style:{padding:"4px 12px",borderBottom:`1px solid ${n.borderSubtle}`,display:"flex",alignItems:"center",gap:"6px",flexShrink:0},children:[jsx(E,{d:w.search,size:11,className:""}),jsx("input",{value:ae,onChange:r=>Ce(r.target.value),placeholder:"Filter test cases...",style:{flex:1,fontSize:"10px",background:"transparent",border:"none",outline:"none",color:n.text,fontFamily:"monospace"}}),ae&&jsx("button",{onClick:()=>Ce(""),style:{background:"none",border:"none",cursor:"pointer",color:n.textFaint,fontSize:"10px",padding:0},children:"\u2715"})]}),Se==="error"&&jsxs("div",{style:{padding:"12px",textAlign:"center"},children:[jsx(E,{d:w.alert,className:""}),jsx("div",{style:{fontSize:"10px",color:n.red},children:"Failed to load"}),jsx("button",{onClick:wn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer",marginTop:"4px"},children:"Retry"})]}),Ee&&jsxs("div",{style:{padding:"6px 12px",display:"flex",alignItems:"center",gap:"8px",borderBottom:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg},children:[jsx(E,{d:w.checkAll,className:""}),jsx("span",{style:{fontSize:"10px",color:n.green,flex:1},children:"Run completed"}),jsx("button",{onClick:Sn,style:{fontSize:"9px",color:"#3b82f6",background:"none",border:"none",cursor:"pointer"},children:"Reset"})]}),Se!=="error"&&jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:(v?.test_cases||[]).length===0?jsx("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:"No test cases"}):Je.length===0?jsxs("div",{style:{padding:"16px 12px",textAlign:"center",fontSize:"10px",color:n.gripColor},children:['No matches for "',ae,'"']}):Dt?Dt.map(r=>{let b=Be.has(r.key);return jsxs("div",{children:[jsxs("button",{onClick:()=>Te(r.key),style:{width:"100%",display:"flex",alignItems:"center",gap:"6px",padding:"5px 12px",background:n.bgSoft,cursor:"pointer",border:"none",borderLeft:"none",borderRight:"none",borderBottomStyle:"solid",borderTopStyle:"solid",borderBottomWidth:"1px",borderTopWidth:"1px",borderBottomColor:n.borderSubtle,borderTopColor:n.borderSubtle,backgroundColor:n.bgSoft},children:[jsx(E,{d:b?w.chevronDown:w.chevronUp,size:10,className:""}),jsx("span",{style:{fontSize:"10px",fontWeight:700,color:n.blue,flex:1,textAlign:"left"},children:r.label}),jsxs("span",{style:{fontSize:"9px",color:n.green},children:[r.summary.pass,"\u2713"]}),jsxs("span",{style:{fontSize:"9px",color:n.red},children:[r.summary.fail,"\u2717"]}),jsxs("span",{style:{fontSize:"9px",color:n.gripColor},children:[r.summary.pending,"\u25CC"]}),jsx("span",{style:{fontSize:"9px",color:n.textFaint},children:r.summary.total})]}),!b&&r.cases.map(N=>Kt(N))]},r.key)}):Je.map(r=>Kt(r))}),Nn&&!Ee&&jsxs("div",{style:{padding:"6px 12px",borderTop:`1px solid ${n.greenBorderSubtle}`,background:n.greenBg,display:"flex",alignItems:"center",justifyContent:"space-between",flexShrink:0},children:[jsx("span",{style:{fontSize:"9px",color:n.green},children:"All resolved"}),jsx("button",{onClick:kn,style:{fontSize:"8px",padding:"2px 8px",borderRadius:"4px",background:"rgba(52,211,153,0.15)",color:n.green,border:`1px solid ${n.greenBorderSubtle}`,cursor:"pointer"},children:"COMPLETE"})]}),Yt(),Jt(),jsx("div",{style:d.progress,children:jsx("div",{style:d.progressBar(Wt)})}),jsx("div",{style:{position:"absolute",bottom:0,right:0,width:16,height:16,cursor:"se-resize",zIndex:10,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:"2px",opacity:.3},onPointerDown:yn,onPointerMove:hn,onPointerUp:xn,onPointerEnter:r=>r.currentTarget.style.opacity="0.7",onPointerLeave:r=>{ze.current||(r.currentTarget.style.opacity="0.3");},children:jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",children:jsx("path",{d:"M7 1v6H1",fill:"none",stroke:n.gripColor,strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})}var er=1e4,Oe=new Map;var Qe=class extends Error{};async function tr(e,t,o){let a={headers:{authorization:`Bearer ${t}`}};try{return await fetch(e,{...a,signal:o})}catch(i){if(i instanceof TypeError&&/signal/i.test(i.message)&&!o.aborted)return fetch(e,a);throw i}}function nr(e){let t=e;return !!t&&typeof t=="object"&&typeof t.tenant=="string"&&Array.isArray(t.entries)&&t.entries.every(o=>!!o&&typeof o.id=="string"&&typeof o.title=="string"&&!!o.body&&Array.isArray(o.body.ast)&&Array.isArray(o.links))}function kt({endpoint:e,getToken:t,timeoutMs:o=er}){let[a,i]=useState(()=>({feed:null,error:null,loading:true,stale:false})),[l,_]=useState(0),y=useRef(t);y.current=t,useEffect(()=>{let f=new AbortController,h=true,M=false,A=setTimeout(()=>{M=true,f.abort();},o),p=new Promise((n,d)=>{f.signal.addEventListener("abort",()=>d(new Error("timeout")),{once:true});});p.catch(()=>{}),i(n=>({...n,error:null,loading:true}));let x=null,g=(n,d)=>{if(d&&Oe.delete(e),!h)return;let k=d||x===null?void 0:Oe.get(e)?.get(x);i({feed:k??null,error:n,loading:false,stale:!!k});};return (async()=>{try{let n;try{n=await Promise.race([Promise.resolve().then(()=>y.current()),p]);}catch(z){throw M||f.signal.aborted?z:new Qe("token_unavailable")}x=n;let d=await Promise.race([tr(e,n,f.signal),p]),k=d.status===401||d.status===403;k&&Oe.delete(e);let $=null;try{$=await Promise.race([d.json(),p]);}catch(z){if(M&&!k)throw z;$=null;}if(!h)return;if(d.ok)if(!nr($))g("invalid_feed",!1);else {let z=Oe.get(e)??new Map;z.set(n,$),Oe.set(e,z),i({feed:$,error:null,loading:!1,stale:!1});}else {let z=$?.error;g(typeof z=="string"?z:`http_${d.status}`,k);}}catch(n){n instanceof Qe?g(n.message,true):g(M?"timeout":n instanceof Error&&n.message||"unavailable",false);}finally{clearTimeout(A);}})(),()=>{h=false,clearTimeout(A),f.abort();}},[e,l,o]);let R=useCallback(()=>_(f=>f+1),[]);return {...a,reload:R}}var _t=["accent","fg","bg","muted","border","radius","font"],rr={accent:"hsl(var(--primary))",fg:"hsl(var(--foreground))",bg:"hsl(var(--card))",muted:"hsl(var(--muted-foreground))",border:"hsl(var(--border))",radius:"var(--radius)",font:"inherit"},se=(e,t)=>t===void 0?`var(--bbrn-${e},var(--_bbrn-${e}))`:`var(--bbrn-${e},var(--_bbrn-${e},${t}))`,et=se("accent","currentColor"),St=se("muted","color-mix(in srgb,currentColor 72%,transparent)"),Ae=se("border","color-mix(in srgb,currentColor 22%,transparent)"),or=`@layer bbrn{
|
|
2
2
|
.bbrn-root{${_t.filter(e=>e!=="font").map(e=>`--_bbrn-${e}:${rr[e]};`).join("")}display:grid;gap:12px;color:${se("fg")};font-family:var(--bbrn-font)}
|
|
3
3
|
.bbrn-root .bbrn-entry{background:${se("bg","transparent")};border:1px solid ${Ae};border-radius:${se("radius",".5rem")};padding:16px}
|
|
4
4
|
.bbrn-root .bbrn-head{display:flex;gap:8px;align-items:baseline;flex-wrap:wrap}
|
|
5
5
|
.bbrn-root .bbrn-title{font-weight:600;font-size:1rem;line-height:1.4;margin:0}
|
|
6
|
-
.bbrn-root .bbrn-badge{font-size:.75rem;line-height:1.4;color:${
|
|
6
|
+
.bbrn-root .bbrn-badge{font-size:.75rem;line-height:1.4;color:${et};border:1px solid currentColor;border-radius:999px;padding:0 8px}
|
|
7
7
|
.bbrn-root .bbrn-delivery{font-size:.75rem;line-height:1.4;border-radius:999px;padding:0 8px;background:color-mix(in srgb,${Ae} 60%,transparent)}
|
|
8
8
|
.bbrn-root .bbrn-meta,.bbrn-root .bbrn-status{color:${St};font-size:.8rem;margin:0}
|
|
9
9
|
.bbrn-root .bbrn-p{margin:.5em 0}
|
|
10
10
|
.bbrn-root .bbrn-list{margin:.5em 0;padding-left:1.25em;list-style:disc}
|
|
11
11
|
.bbrn-root .bbrn-code{font-family:ui-monospace,monospace;font-size:.85em;padding:0 4px;border-radius:4px;background:color-mix(in srgb,${Ae} 60%,transparent)}
|
|
12
12
|
.bbrn-root .bbrn-links{display:flex;gap:12px;flex-wrap:wrap;margin-top:8px;font-size:.85rem}
|
|
13
|
-
.bbrn-root .bbrn-link{color:${
|
|
13
|
+
.bbrn-root .bbrn-link{color:${et};text-decoration:underline}
|
|
14
14
|
.bbrn-root .bbrn-tags{display:flex;gap:6px;flex-wrap:wrap;margin:8px 0 0;padding:0;list-style:none}
|
|
15
15
|
.bbrn-root .bbrn-tag{font-size:.75rem;line-height:1.4;border:1px solid ${Ae};border-radius:999px;padding:0 8px;color:${St}}
|
|
16
16
|
.bbrn-root .bbrn-filters{display:flex;gap:12px;flex-wrap:wrap;align-items:center;font-size:.85rem}
|
|
@@ -18,11 +18,11 @@ import {useState,useRef,useCallback,useEffect,useMemo,useLayoutEffect,useInserti
|
|
|
18
18
|
.bbrn-root .bbrn-pager .bbrn-retry{margin-left:0}
|
|
19
19
|
.bbrn-root .bbrn-filter{display:inline-flex;gap:6px;align-items:center;color:${St}}
|
|
20
20
|
.bbrn-root .bbrn-filter select{font:inherit;color:${se("fg")};background:${se("bg","transparent")};border:1px solid ${Ae};border-radius:${se("radius",".5rem")};padding:2px 6px;max-width:16rem}
|
|
21
|
-
.bbrn-root.bbrn-whatsnew{display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;height:1.25rem;padding:0 6px;border-radius:999px;font-size:.7rem;font-weight:600;line-height:1;color:${se("bg","Canvas")};background:${
|
|
21
|
+
.bbrn-root.bbrn-whatsnew{display:inline-flex;align-items:center;justify-content:center;min-width:1.25rem;height:1.25rem;padding:0 6px;border-radius:999px;font-size:.7rem;font-weight:600;line-height:1;color:${se("bg","Canvas")};background:${et}}
|
|
22
22
|
.bbrn-root.bbrn-announcement{gap:4px;max-width:22rem;background:${se("bg","Canvas")};border:1px solid ${Ae};border-radius:${se("radius",".5rem")};padding:12px 16px;box-shadow:0 4px 16px color-mix(in srgb,currentColor 18%,transparent)}
|
|
23
23
|
.bbrn-root.bbrn-announcement .bbrn-title{font-size:.9rem}
|
|
24
24
|
.bbrn-root.bbrn-announcement .bbrn-links{margin-top:4px;align-items:center}
|
|
25
25
|
.bbrn-root.bbrn-announcement .bbrn-retry{margin-left:0}
|
|
26
|
-
.bbrn-root .bbrn-retry{margin-left:8px;text-decoration:underline;background:none;border:0;padding:0;color:${
|
|
27
|
-
}`;function De(e=typeof document>"u"?void 0:document){if(!e?.head||e.head.querySelector("style[data-bbrn-styles]"))return;let t=e.createElement("style");t.setAttribute("data-bbrn-styles",""),t.textContent=or,e.head.prepend(t);}function We(e){if(!e)return;let t={};for(let o of _t){let a=e[o];typeof a=="string"&&a.trim()&&(t[`--bbrn-${o}`]=a);}return Object.keys(t).length?t:void 0}function tt(e){if(typeof e!="string"||/[\s\\]/.test(e))return null;if(e.startsWith("/"))return e.startsWith("//")?null:{kind:"internal",href:e};try{return new URL(e).protocol==="https:"?{kind:"external",href:e}:null}catch{return null}}function et(e,t=""){return e.map((o,a)=>{let i=`${t}${a}`;switch(o.t){case "text":return o.v;case "code":return jsx("code",{className:"bbrn-code",children:o.v},i);case "strong":return jsx("strong",{children:et(o.c,`${i}.`)},i);case "em":return jsx("em",{children:et(o.c,`${i}.`)},i);default:return null}})}function dn({ast:e}){return jsx(Fragment,{children:e.map((t,o)=>t.t==="list"?jsx("ul",{className:"bbrn-list",children:t.items.map((a,i)=>jsx("li",{children:et(a)},i))},o):t.t==="p"?jsx("p",{className:"bbrn-p",children:et(t.c)},o):null)})}var F=(...e)=>e.filter(Boolean).join(" ");function ln(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toISOString().slice(0,16).replace("T"," ")} UTC`}var lr=useInsertionEffect??useLayoutEffect,Nt=class extends Component{constructor(){super(...arguments);this.state={failed:false,keys:this.props.resetKeys};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(o,a){return o.resetKeys.length!==a.keys.length||o.resetKeys.some((l,_)=>!Object.is(l,a.keys[_]))?{failed:false,keys:o.resetKeys}:null}componentDidCatch(){}render(){return this.state.failed?this.props.fallback:this.props.children}};function dr(e,t,o=1){let a=Object.entries(t).filter(([,i])=>i).map(([i,l])=>`tag=${encodeURIComponent(`${i}:${l}`)}`);return o>1&&a.push(`page=${o}`),a.length===0?e:`${e}${e.includes("?")?"&":"?"}${a.join("&")}`}function cr({endpoint:e,getToken:t,onNavigate:o,theme:a,classNames:i,components:l,timeoutMs:_}){lr(()=>{De();},[]);let[y,R]=useState({}),[f,h]=useState(1),M=C=>{h(1),R(C);},A=useMemo(()=>dr(e,y,f),[e,y,f]),{feed:p,error:x,loading:g,stale:n,reload:d}=kt({endpoint:A,getToken:t,timeoutMs:_}),[k,P]=useState(0),z=()=>{P(C=>C+1),d();},V=useMemo(()=>We(a),[a]),S=i??{},W=l?.Empty,pe=l?.Link,ie=C=>T=>{!o||T.defaultPrevented||T.button!==0||T.metaKey||T.ctrlKey||T.shiftKey||T.altKey||(T.preventDefault(),o(C));},m=Object.values(y).some(Boolean),we=jsxs("p",{className:F("bbrn-status",S.status),role:"alert","data-bbrn-error":x??"render_failed",children:["Release notes could not be loaded.",jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"}),m&&jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>M({}),children:"Clear filters"})]});return jsxs("section",{className:F("bbrn-root",S.root),style:V,"aria-label":"Release notes","aria-busy":g,"data-bbrn-audience":p?.audience,children:[g&&!p&&jsx("p",{className:F("bbrn-status",S.status),role:"status",children:"Loading release notes\u2026"}),!g&&x&&!p&&we,n&&jsxs("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-stale":"",children:["Showing the last loaded notes; they could not be refreshed.",jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"})]}),p&&jsxs(Nt,{resetKeys:[p,W,pe,k],fallback:we,children:[p.audience==="internal"&&p.notice&&jsx("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-notice":"production-freshness",children:p.notice}),(p.filters?.length??0)>0&&jsx("div",{className:F("bbrn-filters",S.filters),role:"group","aria-label":"Filter release notes",children:p.filters.map(C=>jsxs("label",{className:F("bbrn-filter",S.filter),"data-bbrn-filter":C.group,children:[C.label,jsxs("select",{value:y[C.group]??"",onChange:T=>{let O=T.target.value;M(G=>({...G,[C.group]:O}));},children:[jsx("option",{value:"",children:"All"}),C.values.map(T=>jsx("option",{value:T,children:T},T))]})]},C.group))}),p.entries.length===0&&m&&jsx("p",{className:F("bbrn-status",S.status),children:"No release notes match these filters."}),p.entries.length===0&&!m&&(W?jsx(W,{}):p.audience==="external"?jsx("p",{className:F("bbrn-status",S.status),children:"Nothing new yet."}):jsxs("p",{className:F("bbrn-status",S.status),children:["No release notes yet. Submit one with ",jsx("code",{className:"bbrn-code",children:"bb release-notes submit"}),"."]})),p.entries.map(C=>{let T="source_key"in C?C:null;return jsxs("article",{className:F("bbrn-entry",S.entry),"data-entry-id":C.id,"data-source-key":T?.source_key,children:[jsxs("div",{className:F("bbrn-head",S.head),children:[jsx("h2",{className:F("bbrn-title",S.title),children:C.title}),jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-type":C.type,children:C.type}),T&&jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-state":T.state,children:T.state_copy??T.state}),T&&jsxs("span",{className:F("bbrn-meta",S.meta),children:[T.source_key," \xB7 revision ",T.revision]}),T?.delivery_copy&&jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":T.delivery_badge,children:[T.delivery_copy,T.delivery_since&&jsxs(Fragment,{children:[" \xB7 since ",jsx("time",{dateTime:T.delivery_since,children:ln(T.delivery_since)})]})]}),!T&&"version"in C&&C.version&&jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":"released",children:["Released in ",C.version,C.released_at&&jsxs(Fragment,{children:[" \xB7 ",jsx("time",{dateTime:C.released_at,children:ln(C.released_at)})]})]})]}),jsx("div",{className:F("bbrn-body",S.body),children:jsx(dn,{ast:C.body.ast})}),(C.tags?.length??0)>0&&jsx("ul",{className:F("bbrn-tags",S.tags),"aria-label":"Tags",children:C.tags.map(O=>jsx("li",{className:F("bbrn-tag",S.tag),"data-bbrn-tag-group":O.group,title:O.label,children:O.value},`${O.group}:${O.value}`))}),C.links.length>0&&jsx("div",{className:F("bbrn-links",S.links),children:C.links.map((O,G)=>{let X=tt(O.url);if(!X)return null;let ce=F("bbrn-link",S.link),re=O.kind??null;return pe?jsx(pe,{href:X.href,external:X.kind==="external",kind:re,className:ce,onClick:X.kind==="internal"&&o?ie(X.href):void 0,children:O.name},G):X.kind==="external"?jsx("a",{className:ce,href:X.href,target:"_blank",rel:"noopener noreferrer","data-link-kind":re??void 0,children:O.name},G):jsx("a",{className:ce,href:X.href,onClick:ie(X.href),"data-link-kind":re??void 0,children:O.name},G)})})]},C.id)}),p.audience==="external"&&(p.page>1||p.next_page!==null)&&jsxs("nav",{className:F("bbrn-pager",S.pager),"aria-label":"Release note pages",children:[p.page>1&&jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.page-1),children:"Newer notes"}),p.next_page!==null&&jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.next_page),children:"Older notes"})]})]})]})}var Tt="bbrn-announcements",$e=new Map,Et=new Set;function pr(e,t){return `bbrn-announcements:${e}:${t??""}`}function gr(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1||!Array.isArray(t.seen)||!Array.isArray(t.prompted))return null;let o=a=>a.filter(i=>typeof i=="string");return {v:1,seen:o(t.seen),prompted:o(t.prompted),muted:t.muted===!0}}catch{return null}}function pn(e){if(Et.has(e)&&$e.has(e))return $e.get(e);try{let t=gr(window.localStorage.getItem(e));return t&&$e.set(e,t),t??$e.get(e)??null}catch{return $e.get(e)??null}}function gn(e,t){let o={...t,seen:t.seen.slice(-500),prompted:t.prompted.slice(-500)};$e.set(e,o);try{window.localStorage.setItem(e,JSON.stringify(o)),Et.delete(e);}catch{Et.add(e);}try{window.dispatchEvent(new CustomEvent(Tt,{detail:e}));}catch{}}var He=(e,t)=>Array.from(new Set([...e,...t]));function rt({feed:e,viewer:t}){let o=e?.announcements==="badge"||e?.announcements==="badge_and_prompt"?e.announcements:"off",a=useMemo(()=>o==="off"?[]:(Array.isArray(e?.announced)?e.announced:e?.entries??[]).filter(k=>!!k&&typeof k.id=="string"&&!!k.announcement),[e,o]),i=e?pr(e.tenant,t):null,[l,_]=useState(0);useEffect(()=>{if(!i)return;let k=z=>{z.detail===i&&_(V=>V+1);},P=z=>{(z.key===i||z.key===null)&&_(V=>V+1);};return window.addEventListener(Tt,k),window.addEventListener("storage",P),()=>{window.removeEventListener(Tt,k),window.removeEventListener("storage",P);}},[i]);let y=useMemo(()=>a.map(k=>k.id),[a]),R=useMemo(()=>i?pn(i):null,[i,l]),f=useMemo(()=>{if(!i||!e)return null;if(R)return R;let k=y.slice(1);return {v:1,seen:k,prompted:k,muted:false}},[i,e,R,y]);useEffect(()=>{i&&f&&!R&&gn(i,f);},[i,f,R]);let h=f?y.filter(k=>!f.seen.includes(k)).length:0,M=o==="badge_and_prompt"&&f&&!f.muted?a.find(k=>!f.prompted.includes(k.id))??null:null,A=useCallback(k=>{if(!i)return;let P=pn(i)??f??{v:1,seen:[],prompted:[],muted:false};gn(i,k(P));},[i,f]),p=useCallback(()=>A(k=>({...k,seen:He(k.seen,y)})),[A,y]),x=useCallback(()=>A(k=>({...k,prompted:He(k.prompted,y)})),[A,y]),g=M?.id??null,n=useCallback(()=>A(k=>({...k,prompted:He(k.prompted,y),seen:g?He(k.seen,[g]):k.seen})),[A,y,g]),d=useCallback(()=>A(k=>({...k,muted:true,prompted:He(k.prompted,y)})),[A,y]);return {mode:o,announced:a,unseenCount:h,prompt:M,markAllSeen:p,dismiss:x,act:n,mute:d}}var mn=useInsertionEffect??useLayoutEffect,fe=(...e)=>e.filter(Boolean).join(" ");function mr({feed:e,viewer:t,theme:o,classNames:a}){mn(()=>{De();},[]);let{unseenCount:i}=rt({feed:e,viewer:t}),l=useMemo(()=>We(o),[o]);if(i===0)return null;let _=`${i} new release note${i===1?"":"s"}`;return jsx("span",{className:fe("bbrn-root bbrn-whatsnew",a?.root),style:l,"aria-label":_,title:_,"data-bbrn-whatsnew":"",children:jsx("span",{"aria-hidden":"true",children:i})})}function yr({feed:e,viewer:t,onNavigate:o,theme:a,classNames:i,heading:l="What's new"}){mn(()=>{De();},[]);let{prompt:_,dismiss:y,act:R,mute:f}=rt({feed:e,viewer:t}),h=useMemo(()=>We(a),[a]);if(!_)return null;let M=_.announcement?.cta??null,A=M?tt(M.url):null,p=i??{},x=n=>{n.key==="Escape"&&(n.stopPropagation(),y());},g=n=>{A?.kind==="internal"&&o&&!n.defaultPrevented&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&(n.preventDefault(),o(A.href)),R();};return jsxs("section",{className:fe("bbrn-root bbrn-announcement",p.root),style:h,role:"status","aria-live":"polite","aria-label":l,onKeyDown:x,"data-entry-id":_.id,children:[jsx("p",{className:fe("bbrn-meta",p.meta),children:l}),jsx("p",{className:fe("bbrn-title",p.title),children:_.title}),jsxs("div",{className:fe("bbrn-links",p.links),children:[M&&A&&(A.kind==="external"?jsx("a",{className:fe("bbrn-link",p.link),href:A.href,target:"_blank",rel:"noopener noreferrer",onClick:g,children:M.label}):jsx("a",{className:fe("bbrn-link",p.link),href:A.href,onClick:g,children:M.label})),jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:y,children:"Dismiss"}),jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:f,children:"Don't show again"})]})]})}
|
|
28
|
-
export{_t as RELEASE_NOTES_TOKENS,dn as ReleaseNoteBody,cr as ReleaseNotes,
|
|
26
|
+
.bbrn-root .bbrn-retry{margin-left:8px;text-decoration:underline;background:none;border:0;padding:0;color:${et};cursor:pointer;font:inherit}
|
|
27
|
+
}`;function De(e=typeof document>"u"?void 0:document){if(!e?.head||e.head.querySelector("style[data-bbrn-styles]"))return;let t=e.createElement("style");t.setAttribute("data-bbrn-styles",""),t.textContent=or,e.head.prepend(t);}function We(e){if(!e)return;let t={};for(let o of _t){let a=e[o];typeof a=="string"&&a.trim()&&(t[`--bbrn-${o}`]=a);}return Object.keys(t).length?t:void 0}function Pe(e){if(typeof e!="string"||/[\s\\]/.test(e))return null;if(e.startsWith("/"))return e.startsWith("//")?null:{kind:"internal",href:e};try{return new URL(e).protocol==="https:"?{kind:"external",href:e}:null}catch{return null}}function tt(e,t=""){return e.map((o,a)=>{let i=`${t}${a}`;switch(o.t){case "text":return o.v;case "code":return jsx("code",{className:"bbrn-code",children:o.v},i);case "strong":return jsx("strong",{children:tt(o.c,`${i}.`)},i);case "em":return jsx("em",{children:tt(o.c,`${i}.`)},i);default:return null}})}function dn({ast:e}){return jsx(Fragment,{children:e.map((t,o)=>t.t==="list"?jsx("ul",{className:"bbrn-list",children:t.items.map((a,i)=>jsx("li",{children:tt(a)},i))},o):t.t==="p"?jsx("p",{className:"bbrn-p",children:tt(t.c)},o):null)})}var F=(...e)=>e.filter(Boolean).join(" ");function ln(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.toISOString().slice(0,16).replace("T"," ")} UTC`}var lr=useInsertionEffect??useLayoutEffect,Nt=class extends Component{constructor(){super(...arguments);this.state={failed:false,keys:this.props.resetKeys};}static getDerivedStateFromError(){return {failed:true}}static getDerivedStateFromProps(o,a){return o.resetKeys.length!==a.keys.length||o.resetKeys.some((l,_)=>!Object.is(l,a.keys[_]))?{failed:false,keys:o.resetKeys}:null}componentDidCatch(){}render(){return this.state.failed?this.props.fallback:this.props.children}};function dr(e,t,o=1){let a=Object.entries(t).filter(([,i])=>i).map(([i,l])=>`tag=${encodeURIComponent(`${i}:${l}`)}`);return o>1&&a.push(`page=${o}`),a.length===0?e:`${e}${e.includes("?")?"&":"?"}${a.join("&")}`}function cr({endpoint:e,getToken:t,onNavigate:o,theme:a,classNames:i,components:l,timeoutMs:_}){lr(()=>{De();},[]);let[y,R]=useState({}),[f,h]=useState(1),M=C=>{h(1),R(C);},A=useMemo(()=>dr(e,y,f),[e,y,f]),{feed:p,error:x,loading:g,stale:n,reload:d}=kt({endpoint:A,getToken:t,timeoutMs:_}),[k,$]=useState(0),z=()=>{$(C=>C+1),d();},V=useMemo(()=>We(a),[a]),S=i??{},D=l?.Empty,pe=l?.Link,ie=C=>T=>{!o||T.defaultPrevented||T.button!==0||T.metaKey||T.ctrlKey||T.shiftKey||T.altKey||(T.preventDefault(),o(C));},m=Object.values(y).some(Boolean),we=jsxs("p",{className:F("bbrn-status",S.status),role:"alert","data-bbrn-error":x??"render_failed",children:["Release notes could not be loaded.",jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"}),m&&jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>M({}),children:"Clear filters"})]});return jsxs("section",{className:F("bbrn-root",S.root),style:V,"aria-label":"Release notes","aria-busy":g,"data-bbrn-audience":p?.audience,children:[g&&!p&&jsx("p",{className:F("bbrn-status",S.status),role:"status",children:"Loading release notes\u2026"}),!g&&x&&!p&&we,n&&jsxs("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-stale":"",children:["Showing the last loaded notes; they could not be refreshed.",jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:z,children:"Retry"})]}),p&&jsxs(Nt,{resetKeys:[p,D,pe,k],fallback:we,children:[p.audience==="internal"&&p.notice&&jsx("p",{className:F("bbrn-status",S.status),role:"status","data-bbrn-notice":"production-freshness",children:p.notice}),(p.filters?.length??0)>0&&jsx("div",{className:F("bbrn-filters",S.filters),role:"group","aria-label":"Filter release notes",children:p.filters.map(C=>jsxs("label",{className:F("bbrn-filter",S.filter),"data-bbrn-filter":C.group,children:[C.label,jsxs("select",{value:y[C.group]??"",onChange:T=>{let W=T.target.value;M(G=>({...G,[C.group]:W}));},children:[jsx("option",{value:"",children:"All"}),C.values.map(T=>jsx("option",{value:T,children:T},T))]})]},C.group))}),p.entries.length===0&&m&&jsx("p",{className:F("bbrn-status",S.status),children:"No release notes match these filters."}),p.entries.length===0&&!m&&(D?jsx(D,{}):p.audience==="external"?jsx("p",{className:F("bbrn-status",S.status),children:"Nothing new yet."}):jsxs("p",{className:F("bbrn-status",S.status),children:["No release notes yet. Submit one with ",jsx("code",{className:"bbrn-code",children:"bb release-notes submit"}),"."]})),p.entries.map(C=>{let T="source_key"in C?C:null;return jsxs("article",{className:F("bbrn-entry",S.entry),"data-entry-id":C.id,"data-source-key":T?.source_key,children:[jsxs("div",{className:F("bbrn-head",S.head),children:[jsx("h2",{className:F("bbrn-title",S.title),children:C.title}),jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-type":C.type,children:C.type}),T&&jsx("span",{className:F("bbrn-badge",S.badge),"data-bbrn-state":T.state,children:T.state_copy??T.state}),T&&jsxs("span",{className:F("bbrn-meta",S.meta),children:[T.source_key," \xB7 revision ",T.revision]}),T?.delivery_copy&&jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":T.delivery_badge,children:[T.delivery_copy,T.delivery_since&&jsxs(Fragment,{children:[" \xB7 since ",jsx("time",{dateTime:T.delivery_since,children:ln(T.delivery_since)})]})]}),!T&&"version"in C&&C.version&&jsxs("span",{className:F("bbrn-delivery",S.delivery),"data-bbrn-delivery":"released",children:["Released in ",C.version,C.released_at&&jsxs(Fragment,{children:[" \xB7 ",jsx("time",{dateTime:C.released_at,children:ln(C.released_at)})]})]})]}),jsx("div",{className:F("bbrn-body",S.body),children:jsx(dn,{ast:C.body.ast})}),(C.tags?.length??0)>0&&jsx("ul",{className:F("bbrn-tags",S.tags),"aria-label":"Tags",children:C.tags.map(W=>jsx("li",{className:F("bbrn-tag",S.tag),"data-bbrn-tag-group":W.group,title:W.label,children:W.value},`${W.group}:${W.value}`))}),C.links.length>0&&jsx("div",{className:F("bbrn-links",S.links),children:C.links.map((W,G)=>{let X=Pe(W.url);if(!X)return null;let ce=F("bbrn-link",S.link),re=W.kind??null;return pe?jsx(pe,{href:X.href,external:X.kind==="external",kind:re,className:ce,onClick:X.kind==="internal"&&o?ie(X.href):void 0,children:W.name},G):X.kind==="external"?jsx("a",{className:ce,href:X.href,target:"_blank",rel:"noopener noreferrer","data-link-kind":re??void 0,children:W.name},G):jsx("a",{className:ce,href:X.href,onClick:ie(X.href),"data-link-kind":re??void 0,children:W.name},G)})})]},C.id)}),p.audience==="external"&&(p.page>1||p.next_page!==null)&&jsxs("nav",{className:F("bbrn-pager",S.pager),"aria-label":"Release note pages",children:[p.page>1&&jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.page-1),children:"Newer notes"}),p.next_page!==null&&jsx("button",{type:"button",className:F("bbrn-retry",S.retry),onClick:()=>h(p.next_page),children:"Older notes"})]})]})]})}var ur=/^https:\/\/[^/?#\s\\*]+\/?$/;function pr(e,t){let o=Pe(e);if(!o)return null;if(o.kind==="external")return {href:o.href,external:true};if(t.inHostApp)return {href:o.href,external:false};let a=t.appOrigin;if(typeof a!="string"||!ur.test(a))return null;let i=a.replace(/\/$/,"");return t.currentOrigin&&i===t.currentOrigin?{href:o.href,external:false}:{href:`${i}${o.href}`,external:true}}var Tt="bbrn-announcements",Le=new Map,Et=new Set;function fr(e,t){return `bbrn-announcements:${e}:${t??""}`}function br(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||t.v!==1||!Array.isArray(t.seen)||!Array.isArray(t.prompted))return null;let o=a=>a.filter(i=>typeof i=="string");return {v:1,seen:o(t.seen),prompted:o(t.prompted),muted:t.muted===!0}}catch{return null}}function pn(e){if(Et.has(e)&&Le.has(e))return Le.get(e);try{let t=br(window.localStorage.getItem(e));return t&&Le.set(e,t),t??Le.get(e)??null}catch{return Le.get(e)??null}}function gn(e,t){let o={...t,seen:t.seen.slice(-500),prompted:t.prompted.slice(-500)};Le.set(e,o);try{window.localStorage.setItem(e,JSON.stringify(o)),Et.delete(e);}catch{Et.add(e);}try{window.dispatchEvent(new CustomEvent(Tt,{detail:e}));}catch{}}var Ke=(e,t)=>Array.from(new Set([...e,...t]));function rt({feed:e,viewer:t}){let o=e?.announcements==="badge"||e?.announcements==="badge_and_prompt"?e.announcements:"off",a=useMemo(()=>o==="off"?[]:(Array.isArray(e?.announced)?e.announced:e?.entries??[]).filter(k=>!!k&&typeof k.id=="string"&&!!k.announcement),[e,o]),i=e?fr(e.tenant,t):null,[l,_]=useState(0);useEffect(()=>{if(!i)return;let k=z=>{z.detail===i&&_(V=>V+1);},$=z=>{(z.key===i||z.key===null)&&_(V=>V+1);};return window.addEventListener(Tt,k),window.addEventListener("storage",$),()=>{window.removeEventListener(Tt,k),window.removeEventListener("storage",$);}},[i]);let y=useMemo(()=>a.map(k=>k.id),[a]),R=useMemo(()=>i?pn(i):null,[i,l]),f=useMemo(()=>{if(!i||!e)return null;if(R)return R;let k=y.slice(1);return {v:1,seen:k,prompted:k,muted:false}},[i,e,R,y]);useEffect(()=>{i&&f&&!R&&gn(i,f);},[i,f,R]);let h=f?y.filter(k=>!f.seen.includes(k)).length:0,M=o==="badge_and_prompt"&&f&&!f.muted?a.find(k=>!f.prompted.includes(k.id))??null:null,A=useCallback(k=>{if(!i)return;let $=pn(i)??f??{v:1,seen:[],prompted:[],muted:false};gn(i,k($));},[i,f]),p=useCallback(()=>A(k=>({...k,seen:Ke(k.seen,y)})),[A,y]),x=useCallback(()=>A(k=>({...k,prompted:Ke(k.prompted,y)})),[A,y]),g=M?.id??null,n=useCallback(()=>A(k=>({...k,prompted:Ke(k.prompted,y),seen:g?Ke(k.seen,[g]):k.seen})),[A,y,g]),d=useCallback(()=>A(k=>({...k,muted:true,prompted:Ke(k.prompted,y)})),[A,y]);return {mode:o,announced:a,unseenCount:h,prompt:M,markAllSeen:p,dismiss:x,act:n,mute:d}}var mn=useInsertionEffect??useLayoutEffect,fe=(...e)=>e.filter(Boolean).join(" ");function hr({feed:e,viewer:t,theme:o,classNames:a}){mn(()=>{De();},[]);let{unseenCount:i}=rt({feed:e,viewer:t}),l=useMemo(()=>We(o),[o]);if(i===0)return null;let _=`${i} new release note${i===1?"":"s"}`;return jsx("span",{className:fe("bbrn-root bbrn-whatsnew",a?.root),style:l,"aria-label":_,title:_,"data-bbrn-whatsnew":"",children:jsx("span",{"aria-hidden":"true",children:i})})}function xr({feed:e,viewer:t,onNavigate:o,theme:a,classNames:i,heading:l="What's new"}){mn(()=>{De();},[]);let{prompt:_,dismiss:y,act:R,mute:f}=rt({feed:e,viewer:t}),h=useMemo(()=>We(a),[a]);if(!_)return null;let M=_.announcement?.cta??null,A=M?Pe(M.url):null,p=i??{},x=n=>{n.key==="Escape"&&(n.stopPropagation(),y());},g=n=>{A?.kind==="internal"&&o&&!n.defaultPrevented&&n.button===0&&!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&!n.altKey&&(n.preventDefault(),o(A.href)),R();};return jsxs("section",{className:fe("bbrn-root bbrn-announcement",p.root),style:h,role:"status","aria-live":"polite","aria-label":l,onKeyDown:x,"data-entry-id":_.id,children:[jsx("p",{className:fe("bbrn-meta",p.meta),children:l}),jsx("p",{className:fe("bbrn-title",p.title),children:_.title}),jsxs("div",{className:fe("bbrn-links",p.links),children:[M&&A&&(A.kind==="external"?jsx("a",{className:fe("bbrn-link",p.link),href:A.href,target:"_blank",rel:"noopener noreferrer",onClick:g,children:M.label}):jsx("a",{className:fe("bbrn-link",p.link),href:A.href,onClick:g,children:M.label})),jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:y,children:"Dismiss"}),jsx("button",{type:"button",className:fe("bbrn-retry",p.retry),onClick:f,children:"Don't show again"})]})]})}
|
|
28
|
+
export{_t as RELEASE_NOTES_TOKENS,dn as ReleaseNoteBody,cr as ReleaseNotes,xr as ReleaseNotesAnnouncement,hr as ReleaseNotesBadge,Gn as TestRunWidget,pr as findItLink,Pe as safeHref,pt as useDraggable,gt as useRealtimeRefresh,rt as useReleaseNoteAnnouncements,kt as useReleaseNotes,bt as useTestRun,vt as useWidgetAuth};
|
package/package.json
CHANGED