browsentic 0.4.0 → 0.4.8

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.
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{G as t,J as n,K as r,Q as i,V as a,_ as o,at as s,ct as c,et as l,h as u,m as d,ot as f,p,q as m,r as h,st as g,t as _,tt as v,v as y,y as b}from"./globals-DAVXgO1U.js";var x=s(`panel-right-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m10 15-3-3 3-3`,key:`1pgupc`}]]),S=e(g(),1),C=e(c(),1),w=m(),T={unpaired:`Pair this browser to start`,offline:`The daemon isn’t answering — start browsentic`,agent:`That agent cannot run — pick another below`};function E(){let e=b(),s=h(),[c,m]=(0,C.useState)(!1),g=e?.paired??!1;async function S(){let e=await f.windows.getCurrent();e.id!=null&&(await p(e.id),window.close())}let E=_({active:c&&(e?.connected??!1),onSubmit:e=>{m(!1),s.send(e),S()}}),D=r(e,{running:s.running,listening:c&&E.listening}),O=D.ready;function k(){O&&E.submitNow()}function A(){if(E.supported){if(c&&E.error){E.retry();return}m(e=>!e)}}let j=D.blocker?T[D.blocker]:E.error?E.error:c&&E.listening?E.interim||`Listening… speak, then pause`:s.running?`Working — open the side panel to watch`:E.supported?`Tap to talk, or type below`:`Type your instruction below`;return(0,w.jsxs)(`div`,{className:`flex w-[22rem] flex-col`,children:[(0,w.jsxs)(`header`,{className:`flex items-center gap-2 px-4 py-3`,children:[(0,w.jsx)(o,{className:`flex-1`}),(0,w.jsx)(t,{tone:D.tone,children:D.label})]}),g&&(0,w.jsxs)(`main`,{className:`dot-grid flex flex-col items-center gap-4 border-y border-line px-4 py-6`,children:[(0,w.jsxs)(`button`,{type:`button`,"aria-label":c?`Stop listening`:`Start listening`,onClick:A,disabled:!O||!E.supported,className:n(`relative flex size-20 items-center justify-center rounded-full border transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2 focus-visible:ring-offset-ground`,(!O||!E.supported)&&`opacity-40`,c?`border-magenta/60 bg-magenta/15 text-magenta`:`glow-brand border-brand/50 bg-brand/10 text-brand enabled:hover:scale-105 enabled:hover:bg-brand/20`),children:[c&&E.listening&&(0,w.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-magenta/25`}),c?(0,w.jsx)(v,{className:`size-8`}):(0,w.jsx)(l,{className:`size-8`})]}),(0,w.jsx)(`p`,{className:n(`min-h-8 text-center text-xs leading-relaxed`,E.error||!D.ready?`text-amber`:`text-ink-dim`),children:j}),(0,w.jsxs)(`form`,{className:`flex w-full gap-1.5`,onSubmit:e=>{e.preventDefault(),k()},children:[(0,w.jsx)(u,{value:E.input,onChange:e=>E.setInput(e.target.value),placeholder:`What should I do?`,"aria-label":`Instruction for Browsentic`,className:`h-8 text-xs`,disabled:!O}),(0,w.jsx)(a,{type:`submit`,size:`sm`,"aria-label":`Send`,disabled:!O||!E.input.trim(),children:(0,w.jsx)(i,{})})]}),(0,w.jsxs)(a,{variant:`outline`,size:`sm`,className:`w-full`,onClick:S,children:[(0,w.jsx)(x,{}),` Open the side panel`]})]}),(0,w.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,w.jsx)(d,{}),(0,w.jsx)(y,{})]})]})}S.createRoot(document.getElementById(`root`)).render((0,w.jsx)(C.StrictMode,{children:(0,w.jsx)(E,{})}));
@@ -0,0 +1,11 @@
1
+ import{n as e}from"./rolldown-runtime-Bh1tDfsg.js";import{$ as t,A as n,B as r,C as i,D as a,E as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,P as _,Q as v,R as y,S as b,T as x,U as S,V as C,W as w,X as T,Y as E,Z as D,_ as ee,a as O,at as k,b as A,c as j,ct as te,d as ne,et as re,f as ie,g as M,h as N,i as ae,it as P,j as F,k as oe,l as se,m as ce,n as le,nt as I,o as ue,ot as L,q as de,r as fe,rt as pe,s as me,st as he,t as ge,tt as _e,u as ve,v as ye,w as be,x as xe,y as Se,z as R}from"./globals-DAVXgO1U.js";var Ce=k(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),we=k(`book-open`,[[`path`,{d:`M12 5v16`,key:`1f6ucr`}],[`path`,{d:`M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z`,key:`1fyvmf`}]]),Te=k(`camera`,[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),Ee=k(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),z=k(`clapperboard`,[[`path`,{d:`m12.296 3.464 3.02 3.956`,key:`qash78`}],[`path`,{d:`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,key:`1h7j8b`}],[`path`,{d:`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`4lm6w1`}],[`path`,{d:`m6.18 5.276 3.1 3.899`,key:`zjj9t3`}]]),De=k(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),Oe=k(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),ke=k(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),Ae=k(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),je=k(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Me=k(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Ne=k(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),Pe=k(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),B=k(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Fe=k(`highlighter`,[[`path`,{d:`m9 11-6 6v3h9l3-3`,key:`1a3l36`}],[`path`,{d:`m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4`,key:`14a9rk`}]]),Ie=k(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),Le=k(`images`,[[`path`,{d:`m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16`,key:`9kzy35`}],[`path`,{d:`M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2`,key:`1t0f0t`}],[`circle`,{cx:`13`,cy:`7`,r:`1`,fill:`currentColor`,key:`1obus6`}],[`rect`,{x:`8`,y:`2`,width:`14`,height:`14`,rx:`2`,key:`1gvhby`}]]),Re=k(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),ze=k(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Be=k(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Ve=k(`layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),He=k(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),Ue=k(`lock`,[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]),We=k(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),Ge=k(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),Ke=k(`move-vertical`,[[`path`,{d:`M12 2v20`,key:`t6zp3m`}],[`path`,{d:`m8 18 4 4 4-4`,key:`bh5tu3`}],[`path`,{d:`m8 6 4-4 4 4`,key:`ybng9g`}]]),qe=k(`panel-right-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}],[`path`,{d:`m8 9 3 3-3 3`,key:`12hl5m`}]]),Je=k(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),Ye=k(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),Xe=k(`play`,[[`path`,{d:`M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z`,key:`10ikf1`}]]),V=k(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]),Ze=k(`rotate-ccw-clock`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),H=k(`scan-eye`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`path`,{d:`M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0`,key:`11ak4c`}]]),Qe=k(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),$e=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),et=k(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),tt=k(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),nt=k(`square-slash`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),rt=k(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),it=k(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),at=k(`text-cursor-input`,[[`path`,{d:`M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6`,key:`1528k5`}],[`path`,{d:`M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7`,key:`13ksps`}],[`path`,{d:`M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1`,key:`1n9rhb`}],[`path`,{d:`M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1`,key:`1mj8rg`}],[`path`,{d:`M9 6v12`,key:`velyjx`}]]),ot=k(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),st=k(`type`,[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]),ct=k(`upload`,[[`path`,{d:`M12 3v12`,key:`1x0j5s`}],[`path`,{d:`m17 8-5-5-5 5`,key:`7q97r8`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}]]),lt=k(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),U=k(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),ut=k(`zap`,[[`path`,{d:`M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z`,key:`1v7up4`}]]),W=e(te(),1),dt=e(he(),1),ft=[`general`,`site-exploration`],pt=/^[a-z0-9][a-z0-9-]{0,47}$/,mt=32*1024,ht=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/,gt=300,_t=3,vt=60;function yt(e){let t=/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*\r?\n?/.exec(e);if(!t)return{fields:{},body:e};let n={};for(let e of t[1].split(/\r?\n/)){let t=e.indexOf(`:`);t>0&&(n[e.slice(0,t).trim()]=e.slice(t+1).trim())}return{fields:n,body:e.slice(t[0].length)}}function bt(e){return e?e.replace(/^\[|\]$/g,``).split(`,`).map(e=>e.trim().replace(/^['"]|['"]$/g,``)).filter(Boolean):[]}function xt(e){return e?.trim()===`site-exploration`?`site-exploration`:`general`}function St(e){return e.replace(/[\r\n]+/g,` `).replace(/\s+/g,` `).trim()}function Ct(e){try{return new URL(e).hostname.toLowerCase()}catch{return``}}function wt(e){let t=e.trim().toLowerCase();return t?(t.includes(`://`)?Ct(t):t).replace(/^\/+|\/+$/g,``).split(`/`)[0].split(`:`)[0].replace(/^\.+|\.+$/g,``):``}function Tt(e){return e===`localhost`||e.length<=253&&ht.test(e)}function Et(e,t){return Dt(e,t).length>0}function Dt(e,t){let n=e.toLowerCase();return n?t.filter(e=>n===e||n.endsWith(`.${e}`)).sort((e,t)=>t.length-e.length):[]}function Ot(e,t={}){let n=e.name.trim().toLowerCase();if(!n)return G(`Give the skill a name.`);if(!pt.test(n))return G(`Names use lowercase letters, digits and hyphens only, starting with a letter or digit (max 48).`);if(t.reservedNames?.some(e=>e.toLowerCase()===n))return G(`"${n}" is the name of a built-in skill. Pick another.`);let r=St(e.description).slice(0,gt),i=e.category;if(!ft.includes(i))return G(`Unknown category "${String(i)}".`);let a=jt(e.domains.map(wt).filter(Boolean));if(i===`site-exploration`){if(!a.length)return G(`A site-exploration skill needs at least one domain, like acme.com.`);if(a.length>20)return G(`At most 20 domains.`);for(let e of a){if(e.includes(`*`))return G(`"${e}" — wildcards are not supported; subdomains match automatically.`);if(!Tt(e))return G(`"${e}" is not a domain. Use something like acme.com.`)}}let o=i===`site-exploration`?[]:jt(e.triggers.map(e=>St(e).toLowerCase()).filter(Boolean));if(o.length>30)return G(`At most 30 triggers.`);for(let e of o)if(e.length<_t||e.length>vt)return G(`Trigger "${e}" must be ${_t}–${vt} characters.`);let s=yt(e.body.replace(/\r\n/g,`
2
+ `)).body.trim();return s?kt(s)>32768?G(`The skill is larger than ${Math.round(mt/1024)} KB. Trim it down.`):{ok:!0,draft:{name:n,description:r,category:i,domains:a,triggers:o,body:s}}:G(`The skill has no instructions — add some markdown below the front matter.`)}function kt(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);r<128?t+=1:r<2048?t+=2:r>=55296&&r<=56319?(t+=4,n++):t+=3}return t}function At(e,t){let{fields:n,body:r}=yt(e.replace(/\r\n/g,`
3
+ `)),i=wt(t.replace(/\.(md|markdown)$/i,``)).replace(/[^a-z0-9-]+/g,`-`).replace(/^-+|-+$/g,``);return{name:(n.name||i).toLowerCase(),description:n.description??``,category:xt(n.category),domains:bt(n.domains).map(wt).filter(Boolean),triggers:bt(n.triggers).map(e=>e.toLowerCase()),body:r.trim()}}function jt(e){return[...new Set(e)]}function G(e){return{ok:!1,message:e}}var Mt=`/context`,Nt=`See what this conversation carries — messages, files, recordings, tabs.`,K=de(),Pt={command:0,site:1,general:2,agent:3,"other-site":4};function Ft(e,t,n){let r=Ct(t),i=[{key:`command:context`,group:`command`,name:`context`,description:Nt,command:Mt}];for(let t of e?.skills??[]){let e=t.category===`site-exploration`?r&&Et(r,t.domains)?`site`:`other-site`:`general`;i.push({key:`${e}:${t.name}`,group:e,name:t.name,description:t.description})}for(let t of e?.agentSkills??[])i.push({key:`agent:${t.id}`,group:`agent`,name:t.name,description:t.description,agentSkillId:t.id});let a=n.trim().toLowerCase();return(a?i.filter(e=>e.name.toLowerCase().includes(a)||e.description.toLowerCase().includes(a)):i).sort((e,t)=>Pt[e.group]-Pt[t.group]||e.name.localeCompare(t.name))}function It({items:e,agent:t,highlight:n,onHover:r,onSelect:i}){let a={command:`Commands`,site:`On this site`,general:`Browsentic skills`,agent:`${t?E[t].label:`Agent`} skills`,"other-site":`Other sites`};return(0,K.jsx)(`div`,{role:`listbox`,"aria-label":`Skills and commands`,className:`enters absolute inset-x-0 bottom-full z-20 mb-2 max-h-64 overflow-y-auto rounded-xl border border-line bg-surface shadow-lg`,children:e.length===0?(0,K.jsx)(`p`,{className:`px-3 py-2.5 text-[11px] text-ink-faint`,children:`Nothing matches — keep typing, or press Escape.`}):e.map((t,o)=>(0,K.jsxs)(`div`,{children:[(o===0||e[o-1].group!==t.group)&&(0,K.jsx)(`p`,{className:`px-3 pt-2 pb-1 font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:a[t.group]}),(0,K.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":o===n,onMouseEnter:()=>r(o),onMouseDown:e=>{e.preventDefault(),i(t)},className:d(`flex w-full items-start gap-2 px-3 py-1.5 text-left transition-colors`,o===n?`bg-brand/12`:`hover:bg-ground/40`),children:[t.group===`command`?(0,K.jsx)(nt,{className:`mt-0.5 size-3 shrink-0 text-amber`}):t.group===`agent`?(0,K.jsx)(et,{className:`mt-0.5 size-3 shrink-0 text-brand`}):t.group===`general`?(0,K.jsx)(we,{className:`mt-0.5 size-3 shrink-0 text-ink-faint`}):(0,K.jsx)(B,{className:`mt-0.5 size-3 shrink-0 text-ink-faint`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-xs font-medium text-ink`,children:t.name}),t.description&&(0,K.jsx)(`span`,{className:`block truncate text-[11px] text-ink-dim`,children:t.description})]})]})]},t.key))})}function Lt({className:e,...t}){return(0,K.jsx)(`textarea`,{"data-slot":`textarea`,className:d(`field-sizing-content flex min-h-16 w-full rounded-lg border border-line-strong bg-ground/60 px-3 py-2 text-sm text-ink outline-none transition-colors`,`placeholder:text-ink-faint selection:bg-brand/30 selection:text-ink`,`focus-visible:border-brand/55`,`disabled:cursor-not-allowed disabled:opacity-45`,e),...t})}async function Rt(){let[e]=await L.tabs.query({active:!0,currentWindow:!0});if(e?.id==null)return{error:`No active tab to point at`};let t=await A({id:e.id,windowId:e.windowId});if(!t.ok)return t.error.code===`PICK_CANCELLED`?{cancelled:!0}:{error:t.error.message};let{element:n,content:r,truncated:i,url:a,title:o,shot:s}=t.data;return{focus:{tag:n.tag,role:n.role,selector:n.selector,label:n.text,content:r,truncated:i,url:a,title:o,shot:s?.dataUrl}}}var zt=e=>e.label?.trim()||e.role||e.tag;function Bt({voice:e,voiceEnabled:t,connected:n,running:r,files:i,attachError:a,catalog:o,tabUrl:s,attachedSkill:c,focus:l,picking:u,onAttachSkill:f,onCommand:p,onSend:m,onStop:h,onToggleVoice:g,onPick:_,onClearFocus:y,onAttachPage:b,onAttachFile:x,onRemoveFile:S}){let w=(0,W.useRef)(null),T=(0,W.useRef)(null),E=e.input.startsWith(`/`)?e.input.slice(1):null,D=E!==null&&n,[ee,O]=(0,W.useState)(0),k=(0,W.useMemo)(()=>D?Ft(o,s,E??``):[],[D,o,s,E]);(0,W.useEffect)(()=>O(0),[E]);let{cancelPending:A}=e;(0,W.useEffect)(()=>{D&&A()},[D,A]);function j(t){t.command?(e.setInput(``),p(t.command)):t.agentSkillId?(f({id:t.agentSkillId,name:t.name}),e.setInput(``)):e.setInput(`@${t.name} `),T.current?.focus()}function te(e){e.target.closest(`button, textarea`)||T.current?.focus()}return(0,K.jsxs)(K.Fragment,{children:[a&&(0,K.jsx)(`p`,{className:`mb-2 rounded-lg border border-amber/40 bg-amber/10 px-2.5 py-1.5 text-[11px] text-amber`,children:a}),(0,K.jsx)(Vt,{focus:l,picking:u,onClear:y}),c&&(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-xl border border-brand/35 bg-brand/8 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(et,{className:`size-3.5 shrink-0 text-brand`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:[`Skill attached: `,(0,K.jsx)(`span`,{className:`font-medium`,children:c.name})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>f(null),"aria-label":`Detach ${c.name}`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]}),(0,K.jsx)(Ut,{files:i,onRemove:S}),(0,K.jsx)(Ht,{voice:e,voiceEnabled:t}),(0,K.jsxs)(`div`,{onClick:te,className:d(`panel-card relative flex flex-col rounded-2xl transition-colors has-[textarea:focus]:border-brand/50`,n&&`cursor-text`),children:[D&&(0,K.jsx)(It,{items:k,agent:o?.agent,highlight:ee,onHover:O,onSelect:j}),(0,K.jsx)(Lt,{ref:T,value:e.input,onChange:t=>e.setInput(t.target.value),onKeyDown:t=>{if(D){if(t.key===`Escape`){t.preventDefault(),e.setInput(``);return}if(k.length>0){if(t.key===`ArrowDown`){t.preventDefault(),O(e=>(e+1)%k.length);return}if(t.key===`ArrowUp`){t.preventDefault(),O(e=>(e-1+k.length)%k.length);return}if(t.key===`Enter`||t.key===`Tab`){t.preventDefault(),j(k[Math.min(ee,k.length-1)]);return}}}t.key===`Enter`&&!t.shiftKey&&(t.preventDefault(),m())},placeholder:n?`Tell me what to do on this page…`:`Pair the browser to get started`,disabled:!n,rows:2,className:`max-h-48 min-h-14 resize-none rounded-none border-0 bg-transparent px-3 pt-2.5 pb-0 focus-visible:border-0`}),(0,K.jsxs)(`div`,{className:`flex items-center gap-0.5 px-1.5 pb-1.5`,children:[(0,K.jsx)(C,{variant:l||u?`subtle`:`ghost`,size:`icon-sm`,title:`A-Eye — point at an element on the page and send it with your next message`,"aria-label":`Point at an element with A-Eye`,onClick:_,disabled:!n||u,className:d(l||u?`text-ember`:void 0),children:(0,K.jsx)(H,{className:d(`size-3.5`,u&&`animate-pulse`)})}),(0,K.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:`Add this page’s title, URL and selection to the message`,"aria-label":`Attach page context`,onClick:b,disabled:!n,children:(0,K.jsx)(Je,{className:`size-3.5`})}),(0,K.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:`Attach a file for the agent to read`,"aria-label":`Attach a file`,onClick:()=>w.current?.click(),disabled:!n,children:(0,K.jsx)(Ne,{className:`size-3.5`})}),(0,K.jsxs)(C,{variant:t&&!e.error?`subtle`:`ghost`,size:`icon-sm`,"aria-label":t?`Turn voice off`:`Turn voice on`,title:e.supported?`Speak instead of typing`:`Voice input is not available in this browser`,onClick:g,disabled:!e.supported,className:`relative`,children:[t&&e.listening&&(0,K.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-magenta/30`}),t&&!e.error?(0,K.jsx)(re,{className:`size-3.5`}):(0,K.jsx)(_e,{className:`size-3.5`})]}),r?(0,K.jsx)(C,{size:`icon-sm`,variant:`destructive`,className:`ml-auto`,"aria-label":`Stop the agent`,onClick:h,children:(0,K.jsx)(rt,{className:`size-3 fill-current`})}):(0,K.jsx)(C,{size:`icon-sm`,className:`ml-auto`,"aria-label":`Send message`,onClick:m,disabled:!e.input.trim()||!n,children:(0,K.jsx)(v,{className:`size-3.5`})})]})]}),(0,K.jsx)(`input`,{ref:w,type:`file`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&x(t)}}),(0,K.jsx)(`p`,{className:`mt-2 text-center font-mono text-[10px] text-ink-faint`,children:t&&e.supported?`Speak and pause to send · Enter sends now`:`Enter to send · Shift + Enter for a new line · / for skills and commands`})]})}function Vt({focus:e,picking:t,onClear:n}){return!t&&!e?null:(0,K.jsxs)(`div`,{className:`enters mb-2 flex items-center gap-2 rounded-xl border border-ember/40 bg-ember/8 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(H,{className:d(`size-3.5 shrink-0 text-ember`,t&&`animate-pulse`)}),t||!e?(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-ink-dim`,children:[`Point at anything on the page — `,(0,K.jsx)(`span`,{className:`text-ink-faint`,children:`Esc cancels`})]}):(0,K.jsxs)(K.Fragment,{children:[e.shot&&(0,K.jsx)(`img`,{src:e.shot,alt:`The element you picked`,className:`max-h-7 max-w-14 shrink-0 rounded border border-ember/40 object-cover`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-ink`,children:[`A-Eye: `,(0,K.jsx)(`span`,{className:`font-medium`,children:zt(e)})]}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:e.tag}),(0,K.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Drop the A-Eye selection`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]})]})}function Ht({voice:e,voiceEnabled:t}){return t&&e.error?(0,K.jsx)(`p`,{className:`mb-2 rounded-lg border border-amber/40 bg-amber/10 px-2.5 py-1.5 text-[11px] text-amber`,children:e.error}):e.pendingSend?(0,K.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg bg-brand/10 px-2.5 py-1.5 text-[11px] text-brand`,children:[(0,K.jsx)(`span`,{className:`relative flex-1 overflow-hidden rounded-full bg-brand/20`,children:(0,K.jsx)(`span`,{className:`block h-1 rounded-full bg-brand`,style:{animation:`browsentic-countdown ${e.autoSendMs}ms linear forwards`}})}),(0,K.jsx)(`span`,{className:`shrink-0`,children:`Sending…`}),(0,K.jsxs)(`button`,{type:`button`,onClick:e.cancelPending,className:`flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-0.5 transition-colors hover:bg-brand/15`,"aria-label":`Cancel sending`,children:[(0,K.jsx)(U,{className:`size-3`}),` Edit`]})]}):t&&e.listening?(0,K.jsxs)(`p`,{className:`mb-2 flex items-center gap-1.5 px-1 text-[11px] text-ink-dim`,children:[(0,K.jsx)(`span`,{className:`glow-dot inline-flex size-1.5 shrink-0 animate-pulse rounded-full bg-magenta text-magenta`}),e.interim?(0,K.jsx)(`span`,{className:`truncate italic`,children:e.interim}):(0,K.jsx)(`span`,{children:`Listening…`})]}):t&&!e.supported?(0,K.jsx)(`p`,{className:`mb-2 px-1 text-[11px] text-ink-faint`,children:`Voice input isn’t available in this browser.`}):null}function Ut({files:e,onRemove:t}){return e.length===0?null:(0,K.jsx)(`div`,{className:`mb-2 flex max-h-40 flex-col gap-1.5 overflow-y-auto`,children:e.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-1.5 text-xs`,children:[(0,K.jsx)(Me,{className:`mt-0.5 size-3.5 shrink-0 text-ink-faint`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-ink`,children:e.name}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] text-ink-faint`,children:Wt(e.size)})]}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:[(0,K.jsx)(I,{className:`size-3 animate-spin`}),` Analyzing…`]}),e.status===`ready`&&e.summary&&(0,K.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-ink-dim`,children:e.summary}),e.status===`error`&&(0,K.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-destructive`,children:e.error??`Analysis failed`})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`Remove ${e.name}`,className:`mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]},e.id))})}function Wt(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Gt({onClose:e}){return(0,K.jsxs)(`div`,{className:`enters max-h-[60%] shrink-0 overflow-y-auto border-b border-line bg-ground-2/80 px-3 py-3 backdrop-blur`,children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-ink`,children:`Connection`}),(0,K.jsx)(C,{variant:`ghost`,size:`icon-sm`,"aria-label":`Close connection settings`,onClick:e,children:(0,K.jsx)(U,{className:`size-3.5`})})]}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(ce,{}),(0,K.jsx)(ye,{})]})]})}var Kt=[`Summarise what this page says`,`Fill this form in with my details`,`Find the unpaid invoices and open the newest`],qt={unpaired:`This browser isn’t paired yet, so nothing can drive it. Pairing takes one command and one code.`,offline:`Paired, but the daemon isn’t answering. Start browsentic and this reconnects on its own.`,agent:`The chosen agent can’t run on this machine. Pick another one, or let Browsentic fix it.`};function Jt({blocker:e,voiceOn:t,onGo:n,onFix:r,onUse:i}){return(0,K.jsxs)(`div`,{className:`dot-grid fade-bottom flex flex-col gap-4 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,K.jsx)(M,{className:`mt-0.5 size-7 shrink-0 text-brand`}),(0,K.jsx)(`div`,{className:`panel-card min-w-0 rounded-2xl rounded-tl-md px-3 py-2.5 text-sm leading-relaxed text-ink`,children:e?qt[e]:(0,K.jsxs)(K.Fragment,{children:[t?`Just talk`:`Tell me`,` what to do on this page — read it, fill something in, click through a flow — and every action shows up here as I take it.`]})})]}),e?(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:(0,K.jsx)(Yt,{icon:Qe,label:e===`agent`?`Choose an agent`:`Set up the link`,onClick:r})}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:Kt.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(e),className:`rounded-xl border border-line bg-ground/40 px-3 py-2 text-left text-xs text-ink-dim transition-colors hover:border-brand/40 hover:bg-surface/60 hover:text-ink`,children:e},e))}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,K.jsx)(Yt,{icon:we,label:`Teach it this site`,onClick:()=>n(`skills`)}),(0,K.jsx)(Yt,{icon:z,label:`Record a flow`,onClick:()=>n(`recordings`)}),(0,K.jsx)(Yt,{icon:Ze,label:`Past chats`,onClick:()=>n(`history`)})]})]})]})}function Yt({icon:e,label:t,onClick:n}){return(0,K.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1.5 rounded-full border border-line bg-ground-2/70 px-2.5 py-1 text-[11px] text-ink-dim transition-colors hover:border-brand/40 hover:text-ink`,children:[(0,K.jsx)(e,{className:`size-3`}),t]})}function Xt({state:e,onStop:t}){let n=Qt(e.startedAt),r=Math.max(0,e.timeoutMs-n),i=e.percent==null?null:Math.round(e.percent);return(0,K.jsxs)(`div`,{className:`enters mb-2 rounded-xl border border-magenta/35 bg-magenta/8 p-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(V,{className:`size-3.5 shrink-0 animate-pulse text-magenta`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-ink`,children:[`Watching `,e.label??e.host]}),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] tabular-nums text-ink-faint`,children:[$t(n),i!=null&&` · ${i}%`]}),(0,K.jsxs)(C,{size:`sm`,variant:`ghost`,className:`shrink-0 text-magenta hover:text-magenta`,onClick:t,children:[(0,K.jsx)(rt,{className:`size-3 fill-current`}),` Stop`]})]}),i!=null&&(0,K.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-full bg-magenta/15`,children:(0,K.jsx)(`div`,{className:`glow-dot h-full rounded-full bg-magenta text-magenta transition-[width] duration-500`,style:{width:`${i}%`}})}),(0,K.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-faint`,children:Zt(e,r)})]})}function Zt(e,t){return e.stalledForMs==null?e.percent!=null&&e.etaMs!=null?`${Math.round(e.percent)}% · ${F(e.etaMs)} left`:e.logs.at(-1)?.text??`Stops automatically in ${$t(t)}.`:`No change for ${$t(e.stalledForMs)}.`}function Qt(e){let[t,n]=(0,W.useState)(()=>Date.now());return(0,W.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),Math.max(0,t-e)}function $t(e){let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var en=[{id:`chat`,label:`Chat`,icon:We},{id:`history`,label:`History`,icon:Ze},{id:`skills`,label:`Skills`,icon:we},{id:`recordings`,label:`Recordings`,icon:z},{id:`settings`,label:`Settings`,icon:$e}];function tn({tab:e,counts:t,onSelect:n}){let r=(0,W.useRef)(null),[i,a]=(0,W.useState)(`full`),o=(0,W.useRef)({full:0,active:0});return(0,W.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=!0,n=()=>{if(!t)return;let n=e.clientWidth;i!==`icons`&&(o.current[i]=nn(e));let{full:r,active:s}=o.current;a(r>0&&n>=r?`full`:i===`full`||n>=s?`active`:`icons`)};n();let s=new ResizeObserver(n);return s.observe(e),document.fonts.ready.then(n),()=>{t=!1,s.disconnect()}},[i,e,en.map(({id:e})=>t[e]??0).join(`·`)]),(0,K.jsx)(`nav`,{ref:r,"aria-label":`Panel sections`,className:`flex shrink-0 items-center gap-0.5 overflow-x-auto border-b border-line px-2 pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:en.map(({id:r,label:a,icon:o})=>{let s=e===r,c=t[r]??0,l=i===`full`||i===`active`&&s;return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(r),title:l?void 0:a,"aria-label":a,"aria-current":s?`page`:void 0,className:d(`relative inline-flex shrink-0 items-center gap-1.5 rounded-full px-2.5 py-1.5 text-[11px] font-medium transition-colors`,s?`bg-brand/12 text-brand`:`text-ink-faint hover:bg-surface/60 hover:text-ink-dim`),children:[(0,K.jsx)(o,{className:`size-3.5`}),l&&a,c>0&&(l?(0,K.jsx)(`span`,{className:d(`rounded-full px-1 font-mono text-[9px] tabular-nums`,s?`bg-brand/20`:`bg-surface text-ink-faint`),children:c}):(0,K.jsx)(`span`,{className:d(`absolute top-1 right-1 size-1.5 rounded-full`,s?`bg-brand/70`:`bg-ink-faint/60`)}))]},r)})})}function nn(e){let t=getComputedStyle(e),n=parseFloat(t.columnGap)||0,r=parseFloat(t.paddingLeft)+parseFloat(t.paddingRight),i=Array.from(e.children);return i.reduce((e,t)=>e+t.getBoundingClientRect().width,0)+n*Math.max(0,i.length-1)+r}function rn({state:e,onStop:t}){let n=an(e.startedAt),r=Math.max(0,g-n);return(0,K.jsxs)(`div`,{className:`enters mb-2 rounded-xl border border-destructive/40 bg-destructive/8 p-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`glow-dot size-2 shrink-0 animate-pulse rounded-full bg-destructive text-destructive`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-ink`,children:[`Recording `,e.host]}),(0,K.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] tabular-nums text-ink-faint`,children:[on(n),` · `,e.events,` `,e.events===1?`step`:`steps`]}),(0,K.jsxs)(C,{size:`sm`,variant:`ghost`,className:`shrink-0 text-destructive hover:text-destructive`,onClick:t,children:[(0,K.jsx)(rt,{className:`size-3 fill-current`}),` Stop`]})]}),(0,K.jsxs)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-ink-faint`,children:[e.warning??`Stops automatically in ${on(r)}.`,!e.captureValues&&` Typed values are not being saved.`]})]})}function an(e){let[t,n]=(0,W.useState)(()=>Date.now());return(0,W.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),Math.max(0,t-e)}function on(e){let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var sn=l(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border px-2 py-0.5 font-mono text-[10px] tracking-[0.08em] whitespace-nowrap uppercase [&>svg]:pointer-events-none [&>svg]:size-2.5`,{variants:{variant:{default:`border-brand/35 bg-brand/12 text-brand`,secondary:`border-line-strong bg-surface/70 text-ink-dim`,destructive:`border-destructive/40 bg-destructive/12 text-destructive`,warning:`border-amber/40 bg-amber/12 text-amber`,outline:`border-line text-ink-faint`}},defaultVariants:{variant:`default`}});function q({className:e,variant:t,asChild:n=!1,...r}){return(0,K.jsx)(n?S:`span`,{"data-slot":`badge`,className:d(sn({variant:t}),e),...r})}function cn({recordings:e,busy:t,onReplay:n,onRemove:r}){return e.length===0?(0,K.jsxs)(`div`,{className:`dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center`,children:[(0,K.jsx)(z,{className:`mx-auto size-5 text-ink-faint`}),(0,K.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-ink-faint`,children:`No recordings yet. Press Record above and walk through the flow you want repeated.`})]}):(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[t&&(0,K.jsx)(`p`,{className:`px-1 pb-1 text-[11px] text-ink-faint`,children:`Waiting on the current run — stop it to replay a recording.`}),e.map(e=>(0,K.jsx)(ln,{recording:e,busy:t===!0,onReplay:n,onRemove:r},e.id))]})}function ln({recording:e,busy:t,onReplay:n,onRemove:r}){let[i,a]=(0,W.useState)(null),o=e.status===`ready`;return(0,K.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-2 text-xs`,children:[(0,K.jsx)(z,{className:`mt-0.5 size-3.5 shrink-0 text-ink-faint`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[i===null?(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-ink`,children:e.name}),e.capturedValues&&(0,K.jsxs)(q,{variant:`warning`,children:[(0,K.jsx)(ze,{}),` values`]})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(N,{value:i,autoFocus:!0,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Escape`&&a(null),t.key===`Enter`&&(be(e.id,i),a(null))},"aria-label":`Recording name`,className:`h-7 text-xs`}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>{be(e.id,i),a(null)},"aria-label":`Save name`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(P,{className:`size-3`})})]}),(0,K.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 font-mono text-[10px] text-ink-faint`,children:[(0,K.jsx)(B,{className:`size-2.5 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.host})]}),e.goal&&e.goal!==e.name&&(0,K.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-ink-dim`,children:e.goal}),(0,K.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:e.status===`analyzing`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I,{className:`size-3 animate-spin`}),` Splitting into steps…`]}):e.status===`error`?(0,K.jsx)(`span`,{className:`text-destructive`,children:e.error??`Could not read this recording`}):(0,K.jsxs)(K.Fragment,{children:[e.steps??0,` `,e.steps===1?`step`:`steps`,` · `,pn(e.durationMs),` ·`,` `,mn(e.updatedAt)]})}),o&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(e),disabled:t,className:`mt-1.5 inline-flex items-center gap-1 rounded-full bg-brand/12 px-2 py-0.5 text-[11px] text-brand transition-colors hover:bg-brand/20 disabled:opacity-50`,children:[(0,K.jsx)(Xe,{className:`size-3`}),` Do this again`]})]}),(0,K.jsxs)(`div`,{className:`mt-0.5 flex shrink-0 gap-0.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(e.name),"aria-label":`Rename ${e.name}`,className:`rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(Ye,{className:`size-3`})}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),"aria-label":`Delete ${e.name}`,className:`rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]})]})}var un=6e4,dn=60*un,fn=24*dn;function pn(e){let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${String(t%60).padStart(2,`0`)}s`}function mn(e){let t=Date.now()-e;return t<un?`just now`:t<dn?`${Math.floor(t/un)}m ago`:t<fn?`${Math.floor(t/dn)}h ago`:t<7*fn?`${Math.floor(t/fn)}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function hn({tabUrl:e,recordings:t,recording:n,busy:r,onStart:i,onStop:a,onReplay:o,onRemove:s}){let[c,l]=(0,W.useState)(!1),u=Ct(e),d=!r&&!n&&/^https?:/.test(e);return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 p-3`,children:[(0,K.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:`Capture what you do on a site — the clicks, the fields you fill, the pages you move through — and the agent can repeat it later. A recording runs for at most 15 minutes.`}),n?(0,K.jsxs)(C,{variant:`destructive`,onClick:a,children:[(0,K.jsx)(rt,{className:`fill-current`}),` Stop recording`]}):(0,K.jsxs)(C,{variant:`destructive`,onClick:()=>i(c),disabled:!d,title:d?`Record what you do on ${u}`:`Open an http(s) page, with nothing else running`,children:[(0,K.jsx)(Ee,{className:`fill-current`}),(0,K.jsxs)(`span`,{className:`truncate`,children:[`Record `,u||`this page`]})]}),!n&&(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-xl border border-line bg-ground/40 px-2.5 py-2 text-[11px] leading-relaxed text-ink-dim`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:c,onChange:e=>l(e.target.checked),className:`mt-0.5 size-3 shrink-0 accent-destructive`}),(0,K.jsxs)(`span`,{children:[(0,K.jsx)(`span`,{className:`font-medium text-ink`,children:`Save what I type.`}),` Off by default — every field becomes a placeholder the agent asks you to fill. Passwords and card numbers are never saved either way.`]})]}),(0,K.jsx)(cn,{recordings:t,busy:r,onReplay:o,onRemove:s})]})}var gn=[{key:`user`,label:`you`,color:`bg-brand`},{key:`assistant`,label:`replies`,color:`bg-magenta`},{key:`tools`,label:`tools`,color:`bg-amber`},{key:`notices`,label:`notices`,color:`bg-ink-faint`}];function _n({breakdown:e}){let{messages:t,files:n,recordings:r,filesOmitted:i,recordingsOmitted:a}=e,o=gn.reduce((e,n)=>e+t[n.key],0),s=o===0&&n.length===0&&r.length===0;return(0,K.jsxs)(`div`,{className:`enters panel-card min-w-0 rounded-2xl px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ve,{className:`size-3.5 shrink-0 text-brand`}),(0,K.jsx)(`span`,{className:`flex-1 truncate font-mono text-[10px] tracking-[0.14em] text-ink uppercase`,children:`Session context`}),(0,K.jsx)(`span`,{className:`shrink-0 rounded-full bg-ground/60 px-2 py-0.5 font-mono text-[9px] tracking-[0.1em] text-ink-faint uppercase`,children:yn(e)})]}),s?(0,K.jsx)(`p`,{className:`mt-2 text-[11px] text-ink-dim`,children:`This conversation is empty — nothing rides along yet.`}):(0,K.jsxs)(K.Fragment,{children:[o>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`div`,{className:`mt-2.5 flex h-1.5 gap-px overflow-hidden rounded-full`,children:gn.filter(e=>t[e.key]>0).map(e=>(0,K.jsx)(`span`,{className:e.color,style:{flexGrow:t[e.key]}},e.key))}),(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-x-3 gap-y-0.5`,children:gn.map(e=>(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] text-ink-dim`,children:[(0,K.jsx)(`span`,{className:d(`size-1.5 shrink-0 rounded-full`,e.color)}),(0,K.jsx)(`span`,{className:`font-mono`,children:t[e.key]}),` `,e.label]},e.key))})]}),(0,K.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-1 border-t border-line pt-2`,children:[(0,K.jsxs)(vn,{icon:B,children:[e.tabCount===1?`1 tab`:`${e.tabCount} tabs`,e.host&&(0,K.jsxs)(K.Fragment,{children:[` · `,e.host]}),` · turn`,` `,(0,K.jsx)(`span`,{className:`font-mono text-[10px]`,children:e.turns}),` ·`,` `,(0,K.jsx)(`span`,{className:`font-mono text-[10px]`,children:bn(t.chars)}),` characters`]}),(0,K.jsx)(vn,{icon:ke,children:e.usage?(0,K.jsxs)(K.Fragment,{children:[`Agent window ≈ `,(0,K.jsx)(`span`,{className:`font-mono text-[10px]`,children:bn(e.usage.contextTokens)}),` `,`tokens · `,(0,K.jsx)(`span`,{className:`font-mono text-[10px]`,children:bn(e.usage.outputTokens)}),` `,`generated last run`]}):e.agent===`antigravity`?`Antigravity does not report token counts.`:`Token counts appear after the agent’s first reply.`}),n.map((e,t)=>(0,K.jsxs)(vn,{icon:Me,children:[(0,K.jsx)(`span`,{className:`text-ink`,children:e.name}),(0,K.jsxs)(`span`,{className:`font-mono text-[10px] text-ink-faint`,children:[` · `,xn(e.size)]}),e.status===`pending`&&(0,K.jsx)(`span`,{className:`text-ink-faint`,children:` · analyzing`}),e.status===`error`&&(0,K.jsx)(`span`,{className:`text-destructive`,children:` · analysis failed`})]},t)),i>0&&(0,K.jsxs)(`p`,{className:`pl-[18px] text-[10px] text-ink-faint`,children:[i,` more `,i===1?`file stays`:`files stay`,` behind — only the first`,` `,n.length,` ride along.`]}),r.map((e,t)=>(0,K.jsxs)(vn,{icon:z,children:[(0,K.jsx)(`span`,{className:`text-ink`,children:e.name}),e.steps!==void 0&&(0,K.jsxs)(`span`,{className:`font-mono text-[10px] text-ink-faint`,children:[` · `,e.steps,` steps`]})]},t)),a>0&&(0,K.jsxs)(`p`,{className:`pl-[18px] text-[10px] text-ink-faint`,children:[a,` more `,a===1?`recording stays`:`recordings stay`,` behind — only the first `,r.length,` ride along.`]})]})]}),(0,K.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-ink-faint`,children:`Held in this browser — files and ready recordings ride along with your next message.`})]})}function vn({icon:e,children:t}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1.5 text-[11px] text-ink-dim`,children:[(0,K.jsx)(e,{className:`mt-0.5 size-3 shrink-0 text-ink-faint`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 break-words`,children:t})]})}function yn(e){return e.agent?`${E[e.agent].label}${e.resumes?` · resumes`:``}`:`no agent yet`}function bn(e){return e<1e3?String(e):`${(e/1e3).toFixed(+(e<1e4))} k`}function xn(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Sn({text:e,streaming:t,className:n}){let r=(0,W.useRef)(!1);t&&(r.current=!0);let i=(0,W.useMemo)(()=>Nn(e).map(e=>({block:e,sig:JSON.stringify(e)})),[e]);return(0,K.jsx)(`div`,{"data-stream":t?`live`:r.current?`done`:void 0,className:d(`flex min-w-0 flex-col gap-2`,n),children:i.map(({block:e,sig:t},n)=>(0,K.jsx)(Cn,{block:e,sig:t},n))})}var Cn=(0,W.memo)(({block:e})=>Hn(e,`0`),(e,t)=>e.sig===t.sig),wn=/^ {0,3}(`{3,}|~{3,})[^\n]*$/,Tn=/^ {0,3}(?:`{3,}|~{3,})[ \t]*([^\s`~]*)/,En=/^ {0,3}(`{3,}|~{3,})[ \t]*$/,Dn=/^ {0,3}(#{1,6})[ \t]+(.*?)[ \t]*#*[ \t]*$/,On=/^ {0,3}([-*_])[ \t]*(?:\1[ \t]*){2,}$/,kn=/^ {0,3}>[ \t]?/,An=/^([ \t]*)(?:([-*+])|(\d{1,9})[.)])[ \t]+(.*)$/,jn=/^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)+\|?[ \t]*$/,Mn=12;function Nn(e,t=0){let n=e.replace(/\r\n?/g,`
4
+ `).split(`
5
+ `);if(t>=Mn){let e=n.filter(e=>e.trim()).join(`
6
+ `);return e?[{kind:`paragraph`,text:e}]:[]}let r=[];for(let e=0;e<n.length;){let i=n[e];if(!i.trim()){e++;continue}if(wn.test(i)){let t=/^ {0,3}(`{3,}|~{3,})/.exec(i)[1],a=[];for(e++;e<n.length;){let r=En.exec(n[e]);if(r&&r[1][0]===t[0]&&r[1].length>=t.length){e++;break}a.push(n[e]),e++}r.push({kind:`code`,lang:Tn.exec(i)?.[1]||void 0,text:a.join(`
7
+ `)});continue}let a=Dn.exec(i);if(a){r.push({kind:`heading`,level:a[1].length,text:a[2]}),e++;continue}if(On.test(i)){r.push({kind:`rule`}),e++;continue}if(kn.test(i)){let i=[];for(;e<n.length&&(kn.test(n[e])||i.length>0&&n[e].trim());)i.push(n[e].replace(kn,``)),e++;r.push({kind:`quote`,blocks:Nn(i.join(`
8
+ `),t+1)});continue}let o=An.exec(i);if(o){let[i,a]=Fn(n,e,o,t);r.push(i),e=a;continue}if(In(n,e)){let[t,i]=Ln(n,e);r.push(t),e=i;continue}let s=[];for(;e<n.length&&n[e].trim()&&!Pn(n,e);)s.push(n[e].trim()),e++;r.push({kind:`paragraph`,text:s.join(`
9
+ `)})}return r}function Pn(e,t){let n=e[t];return wn.test(n)||Dn.test(n)||On.test(n)||kn.test(n)||An.test(n)||In(e,t)}function Fn(e,t,n,r){let i=zn(n[1]),a=n[3]!==void 0,o=[],s=t;for(;s<e.length;){let t=An.exec(e[s]);if(!t||t[3]!==void 0!==a)break;let n=zn(t[1]);if(n<i||n>i+1)break;let r=[t[4]];for(s++;s<e.length;){let t=e[s];if(!t.trim()){let t=e[s+1]??``;if(!t.trim()||zn(t)<=i)break;r.push(``),s++;continue}if(zn(t)<=i)break;r.push(Bn(t,i+2)),s++}o.push(r)}return[{kind:`list`,ordered:a,start:a?Number.parseInt(n[3],10):1,items:o.map(e=>Nn(e.join(`
10
+ `),r+1))},s]}function In(e,t){return e[t].includes(`|`)&&t+1<e.length&&jn.test(e[t+1])}function Ln(e,t){let n=Rn(e[t]),r=Rn(e[t+1]).map(e=>e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`),i=[],a=t+2;for(;a<e.length&&e[a].trim()&&e[a].includes(`|`)&&!Pn(e,a);)i.push(Rn(e[a])),a++;return[{kind:`table`,head:n,align:r,rows:i},a]}function Rn(e){let t=[],n=``;for(let r=0;r<e.length;r++){if(e[r]===`\\`&&e[r+1]===`|`){n+=`|`,r++;continue}if(e[r]===`|`){t.push(n),n=``;continue}n+=e[r]}return t.push(n),t[0].trim()||t.shift(),t.length&&!t[t.length-1]?.trim()&&t.pop(),t.map(e=>e.trim())}function zn(e){let t=/^[ \t]*/.exec(e)[0];return t.length+(t.match(/\t/g)?.length??0)}var Bn=(e,t)=>e.replace(/^[ \t]+/,e=>e.replace(/\t/g,` `).slice(t)),Vn=`rounded bg-surface px-1 py-px font-mono text-[0.85em] text-ink`;function Hn(e,t){switch(e.kind){case`heading`:return(0,K.jsx)(`h${Math.min(e.level+1,6)}`,{className:d(`wrap-anywhere font-semibold`,e.level<=2&&`text-[0.95rem]`),children:J(e.text)},t);case`paragraph`:return(0,K.jsx)(`p`,{className:`wrap-anywhere`,children:J(e.text)},t);case`code`:return(0,K.jsx)(`pre`,{className:`max-w-full overflow-x-auto rounded-lg border border-line bg-ground/70 p-2 text-xs whitespace-pre`,children:(0,K.jsx)(`code`,{className:`font-mono`,children:e.text})},t);case`list`:{let n=e.items.map((e,t)=>(0,K.jsx)(`li`,{className:`wrap-anywhere`,children:Wn(e)},t));return e.ordered?(0,K.jsx)(`ol`,{start:e.start,className:`list-decimal space-y-1 pl-5`,children:n},t):(0,K.jsx)(`ul`,{className:`list-disc space-y-1 pl-5`,children:n},t)}case`quote`:return(0,K.jsx)(`blockquote`,{className:`flex flex-col gap-2 border-l-2 border-brand/40 pl-2.5 text-ink-dim`,children:e.blocks.map((e,t)=>Hn(e,String(t)))},t);case`table`:return(0,K.jsx)(`div`,{className:`max-w-full overflow-x-auto`,children:(0,K.jsxs)(`table`,{className:`w-full border-collapse text-left text-xs`,children:[(0,K.jsx)(`thead`,{children:(0,K.jsx)(`tr`,{children:e.head.map((t,n)=>(0,K.jsx)(`th`,{className:d(`border-b border-line-strong px-1.5 py-1 font-semibold`,Un[e.align[n]??`left`]),children:J(t)},n))})}),(0,K.jsx)(`tbody`,{children:e.rows.map((t,n)=>(0,K.jsx)(`tr`,{children:t.map((t,n)=>(0,K.jsx)(`td`,{className:d(`border-b border-line px-1.5 py-1 align-top`,Un[e.align[n]??`left`]),children:J(t)},n))},n))})]})},t);case`rule`:return(0,K.jsx)(`hr`,{className:`border-line`},t)}}var Un={left:`text-left`,center:`text-center`,right:`text-right`};function Wn(e){return e.length===1&&e[0].kind===`paragraph`?J(e[0].text):(0,K.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>Hn(e,String(t)))})}var Gn=4,Kn="`*_~[!<h",qn=/[\\`*_~[\]()#+\-.!>|]/,Jn=512,Yn=2048,Xn=3080,Zn=[{re:/(`+)([^`]+?)\1(?!`)/y,node:(e,t)=>(0,K.jsx)(`code`,{className:Vn,children:e[2]},t)},{re:/\*\*(?!\s)([^\n]+?)\*\*/y,node:(e,t,n,r)=>(0,K.jsx)(`strong`,{children:J(e[1],n+1,r)},t)},{re:/__(?!\s)([^\n]+?)__/y,node:(e,t,n,r)=>(0,K.jsx)(`strong`,{children:J(e[1],n+1,r)},t)},{re:/~~(?!\s)([^\n]+?)~~/y,node:(e,t,n,r)=>(0,K.jsx)(`del`,{children:J(e[1],n+1,r)},t)},{re:/\*(?!\s)([^*\n]+?)\*/y,node:(e,t,n,r)=>(0,K.jsx)(`em`,{children:J(e[1],n+1,r)},t)},{re:/(?<![\w\\])_(?!\s)([^_\n]+?)_(?!\w)/y,node:(e,t,n,r)=>(0,K.jsx)(`em`,{children:J(e[1],n+1,r)},t)},{re:RegExp(`!\\[([^\\]\\n]{0,${Jn}})\\]\\([ \\t]*([^)\\s]{0,${Yn}})[^)\\n]{0,${Jn}}\\)`,`y`),linking:!0,node:(e,t,n)=>$n(e[2],e[1]||e[2],t,n)},{re:RegExp(`\\[([^\\]\\n]{0,${Jn}})\\]\\([ \\t]*([^)\\s]{0,${Yn}})[^)\\n]{0,${Jn}}\\)`,`y`),linking:!0,node:(e,t,n)=>$n(e[2],e[1],t,n)},{re:/<(https?:\/\/[^>\s]+)>/y,linking:!0,node:(e,t,n)=>$n(e[1],e[1],t,n)},{re:/https?:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]}]/y,linking:!0,node:(e,t,n)=>$n(e[0],e[0],t,n)}],Qn=/(?<=\s)(?=\S)/;function J(e,t=0,n=!1){let r=[],i=``,a=0,o=0,s=()=>{i&&i.split(Qn).forEach((e,t)=>{r.push((0,K.jsx)(`span`,{className:`tok`,children:e},`t${a}.${t}`))}),i=``,a=o+1},c=e.indexOf(`)`);for(;o<e.length;){let a=e[o];if(a===`\\`&&o+1<e.length&&qn.test(e[o+1])){i+=e[o+1],o+=2;continue}if(a===`
11
+ `){s(),r.push((0,K.jsx)(`br`,{},`br${o}`)),o++;continue}if((a===`[`||a===`!`)&&(c!==-1&&c<o&&(c=e.indexOf(`)`,o)),c===-1||c-o>Xn)){i+=a,o++;continue}let l=!1;if(t<Gn&&Kn.includes(a))for(let i of Zn){if(n&&i.linking)continue;i.re.lastIndex=o;let a=i.re.exec(e),c=i.re.lastIndex;if(!(!a||c<=o)){s(),r.push(i.node(a,`n${o}`,t,n)),o=c,l=!0;break}}l||(i+=a,o++)}return s(),r}function $n(e,t,n,r){let i=er(e),a=J(t,r+1,!0);return i?(0,K.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer noopener`,className:`underline decoration-1 underline-offset-2 hover:opacity-80`,children:a},n):(0,K.jsx)(`span`,{children:a},n)}function er(e){let t=e.trim();return/^(https?:\/\/|mailto:)/i.test(t)?t:null}function tr({items:e,running:t,onDecide:n}){let r=e.at(-1),i=t&&r?.kind===`assistant`,a=t&&!i;return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2.5 p-3`,children:[e.map((t,r)=>t.kind===`tool`?(0,K.jsx)(ar,{item:t,onDecide:n},t.id):t.kind===`notice`?(0,K.jsx)(sr,{item:t},t.id):t.kind===`context`?(0,K.jsx)(_n,{breakdown:t.breakdown},t.id):t.kind===`user`?(0,K.jsx)(nr,{text:t.text,focus:t.focus},t.id):(0,K.jsx)(rr,{text:t.text,streaming:i&&r===e.length-1},t.id)),a&&(0,K.jsx)(ir,{})]})}function nr({text:e,focus:t}){return(0,K.jsxs)(`div`,{className:`enters flex min-w-0 flex-col items-end gap-1`,children:[(0,K.jsx)(`div`,{className:`min-w-0 max-w-[88%] rounded-2xl rounded-br-md border border-brand/30 bg-brand/10 px-3 py-2 text-sm whitespace-pre-wrap wrap-anywhere text-ink`,children:e}),t&&(0,K.jsxs)(`span`,{className:`flex min-w-0 max-w-[88%] items-center gap-1 rounded-full bg-ember/12 px-2 py-0.5 text-[10px] text-ember`,children:[(0,K.jsx)(H,{className:`size-2.5 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:t})]})]})}function rr({text:e,streaming:t}){return(0,K.jsx)(`div`,{className:`enters min-w-0`,children:(0,K.jsx)(Sn,{text:e,streaming:t,className:`panel-card rounded-2xl rounded-tl-md px-3 py-2.5 text-sm leading-relaxed text-ink`})})}function ir(){return(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-1`,children:[(0,K.jsx)(`span`,{className:`flex items-center gap-1`,children:[0,1,2].map(e=>(0,K.jsx)(`span`,{className:`think-dot size-1.5 rounded-full bg-brand`},e))}),(0,K.jsx)(`span`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Working`})]})}function ar({item:e,onDecide:t}){let n=e.action.replace(/^page\./,``),r=cr[n]??lt,i=e.ok===void 0&&!e.awaiting;return(0,K.jsxs)(`div`,{className:`enters flex min-w-0 flex-col gap-1.5`,children:[(0,K.jsxs)(`div`,{className:d(`relative flex min-w-0 items-start gap-2 overflow-hidden rounded-lg border px-2 py-1.5 transition-colors`,e.awaiting?`border-ember/45 bg-ember/10`:e.ok===!1?`border-destructive/40 bg-destructive/8`:`border-line bg-ground/40`,i&&`sweep`),children:[(0,K.jsx)(r,{className:d(`mt-0.5 size-3 shrink-0`,e.awaiting?`text-ember`:e.ok===!1?`text-destructive`:e.source===`local`?`text-amber`:e.source===`external`?`text-magenta`:`text-brand`)}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-mono text-[10px] text-ink`,children:n}),e.source===`local`&&(0,K.jsx)(or,{tone:`amber`,icon:ut,label:`local`}),e.source===`external`&&(0,K.jsx)(or,{tone:`magenta`,icon:it,label:`mcp`})]}),e.summary&&(0,K.jsx)(`p`,{className:d(`mt-0.5 truncate text-[10px]`,e.ok===!1?`text-destructive`:`text-ink-faint`),children:e.summary})]}),e.ok===!0&&(0,K.jsx)(P,{className:`mt-0.5 size-3 shrink-0 text-lime/80`}),e.ok===!1&&(0,K.jsx)(U,{className:`mt-0.5 size-3 shrink-0 text-destructive`})]}),e.preview&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>void xe(e.preview),title:`Open the ${e.preview.full?`full-size`:`captured`} screenshot in a new tab`,className:`group max-w-[88%] overflow-hidden rounded-xl border border-line bg-ground/60 transition-colors hover:border-brand/50`,children:(0,K.jsx)(`img`,{src:e.preview.thumbnail,alt:`Screenshot, ${e.preview.width}×${e.preview.height}`,width:e.preview.width,height:e.preview.height,className:`block h-auto w-full transition-opacity group-hover:opacity-85`})}),e.awaiting&&(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 rounded-lg border border-ember/45 bg-ember/10 px-2.5 py-2`,children:[(0,K.jsx)(`p`,{className:`flex-1 text-xs text-ink`,children:`Allow this action?`}),(0,K.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>t(e.id,!1),children:`Deny`}),e.site&&(0,K.jsxs)(C,{size:`sm`,variant:`ghost`,onClick:()=>t(e.id,!0,!0),title:`Stop asking for ${n} on ${e.site}. Undo with “browsentic approvals clear”.`,children:[`Always on `,e.site]}),(0,K.jsx)(C,{size:`sm`,onClick:()=>t(e.id,!0),children:`Allow`})]})]})}function or({tone:e,icon:t,label:n}){return(0,K.jsxs)(`span`,{className:d(`inline-flex shrink-0 items-center gap-0.5 rounded-full px-1.5 py-px font-mono text-[8px] tracking-[0.1em] uppercase`,e===`amber`?`bg-amber/15 text-amber`:`bg-magenta/15 text-magenta`),children:[(0,K.jsx)(t,{className:`size-2`}),n]})}function sr({item:e}){let t=e.tone===`error`;return(0,K.jsxs)(`div`,{className:d(`enters flex items-start gap-2 rounded-lg px-2.5 py-1.5 text-[11px] leading-relaxed`,t?`border border-destructive/35 bg-destructive/8 text-destructive`:`text-ink-faint`),children:[t?(0,K.jsx)(T,{className:`mt-px size-3 shrink-0`}):(0,K.jsx)(Re,{className:`mt-px size-3 shrink-0`}),(0,K.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]})}var cr={getPageInfo:je,extractText:je,pickElement:H,"browsentic.focusShot":H,findProgress:je,clickElement:Ge,trustedClick:Ge,hoverElement:Ge,fillInput:st,typeText:st,focusInput:at,selectText:at,pressKey:Be,submitForm:Oe,selectOption:He,navigate:De,openTab:Ae,switchTab:Ae,closeTab:U,screenshot:Te,scrollTo:Ke,highlightElement:Fe,waitForElement:Ie,attachFile:Je,listFiles:Je,startMonitor:V,stopMonitor:V,monitorStatus:V,awaitMonitor:V,listRecordings:z,readRecording:z};function lr({sessions:e,currentId:t,busy:n,onOpen:r,onRemove:i}){return e.length===0?(0,K.jsx)(`div`,{className:`p-3`,children:(0,K.jsxs)(`div`,{className:`dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center`,children:[(0,K.jsx)(We,{className:`mx-auto size-5 text-ink-faint`}),(0,K.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-ink-faint`,children:`Every conversation lands here on its own. Start one in Chat, and “New chat” in the header closes it out.`})]})}):(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5 p-3`,children:[n&&(0,K.jsx)(`p`,{className:`px-1 pb-1 text-[11px] text-ink-faint`,children:`Waiting on the current run — stop it to reopen another conversation.`}),e.map(e=>(0,K.jsx)(ur,{session:e,current:e.id===t,busy:n===!0,onOpen:r,onRemove:i},e.id))]})}function ur({session:e,current:t,busy:n,onOpen:r,onRemove:i}){let a=e.title??(e.host?`Conversation on ${e.host}`:`Untitled conversation`);return(0,K.jsxs)(`div`,{className:d(`flex items-start gap-2 rounded-xl border px-2.5 py-2 text-xs transition-colors`,t?`border-brand/35 bg-brand/8`:`border-line bg-ground/40 hover:border-line-strong`),children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),disabled:n,className:`flex min-w-0 flex-1 items-start gap-2 text-left disabled:opacity-50`,title:e.url,children:[(0,K.jsx)(We,{className:d(`mt-0.5 size-3.5 shrink-0`,t?`text-brand`:`text-ink-faint`)}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-ink`,children:a}),t&&(0,K.jsx)(q,{children:`open`})]}),e.host&&(0,K.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 font-mono text-[10px] text-ink-faint`,children:[(0,K.jsx)(B,{className:`size-2.5 shrink-0`}),(0,K.jsx)(`span`,{className:`truncate`,children:e.host})]}),(0,K.jsx)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:ve(e)&&!e.title?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(I,{className:`size-3 animate-spin`}),` Naming…`]}):(0,K.jsxs)(K.Fragment,{children:[e.turns,` `,e.turns===1?`message`:`messages`,` · `,mr(e.updatedAt)]})})]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>i(e.id),"aria-label":`Delete ${a}`,className:`mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]})}var dr=6e4,fr=60*dr,pr=24*fr;function mr(e){let t=Date.now()-e;return t<dr?`just now`:t<fr?`${Math.floor(t/dr)}m ago`:t<pr?`${Math.floor(t/fr)}h ago`:t<7*pr?`${Math.floor(t/pr)}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function hr({sessions:e,activeSessionId:t,onFocus:n,onEnd:r}){let[i,a]=(0,W.useState)(!0);if(!e.length)return null;let o=e.filter(e=>e.runId).length;return(0,K.jsxs)(`div`,{className:`enters shrink-0 border-b border-line px-3 py-2`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),"aria-expanded":i,className:`flex w-full items-center gap-1.5 font-mono text-[10px] tracking-[0.12em] text-ink-faint uppercase transition-colors hover:text-ink`,children:[(0,K.jsx)(Ve,{className:`size-3 shrink-0`}),(0,K.jsxs)(`span`,{className:`flex-1 text-left`,children:[`Sessions · `,e.length,o>0&&(0,K.jsxs)(`span`,{className:`text-brand`,children:[` · `,o,` running`]})]}),(0,K.jsx)(pe,{className:d(`size-3 shrink-0 transition-transform`,i&&`rotate-180`)})]}),i&&(0,K.jsx)(`div`,{className:`mt-1.5 flex flex-col gap-1`,children:e.map(e=>(0,K.jsx)(gr,{session:e,current:e.sessionId===t,onFocus:n,onEnd:r},e.sessionId))})]})}function gr({session:e,current:t,onFocus:n,onEnd:r}){let i=e.tabIds.length-1;return(0,K.jsxs)(`div`,{className:d(`flex items-center gap-2 rounded-lg border px-2 py-1.5 text-xs transition-colors`,t?`border-brand/35 bg-brand/8`:`border-line bg-ground/40 hover:border-line-strong`),children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(e.sessionId),className:`flex min-w-0 flex-1 items-center gap-2 text-left`,title:e.url,children:[(0,K.jsx)(`span`,{className:d(`size-1.5 shrink-0 rounded-full`,e.runId?`glow-dot animate-pulse bg-brand text-brand`:`bg-ink-faint`)}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block truncate text-ink`,children:e.title}),(0,K.jsxs)(`span`,{className:`block font-mono text-[10px] text-ink-faint`,children:[e.turns,` `,e.turns===1?`message`:`messages`,i>0&&` · +${i} tab${i===1?``:`s`}`,e.host&&` · ${e.host}`]})]})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>r(e.sessionId),"aria-label":`End the session on ${e.title}`,title:`End this session`,className:`shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]})}function _r({checked:e,disabled:t,label:n,onChange:r,className:i}){return(0,K.jsx)(`button`,{type:`button`,role:`switch`,"data-slot":`switch`,"aria-checked":e,"aria-label":n,disabled:t,onClick:()=>r(!e),className:d(`relative inline-flex h-4 w-7 shrink-0 items-center rounded-full border transition-colors`,`focus-visible:ring-2 focus-visible:ring-brand/50 focus-visible:outline-none`,e?`border-brand/50 bg-brand/70`:`border-line-strong bg-surface`,t&&`cursor-not-allowed opacity-40`,i),children:(0,K.jsx)(`span`,{"data-slot":`switch-thumb`,className:d(`pointer-events-none size-2.5 rounded-full bg-ink shadow-sm transition-transform`,e?`translate-x-3.5`:`translate-x-0.5`)})})}var vr=`fence`,yr=`unattended`,br={allow:`Allow`,confirm:`Ask`,deny:`Block`},xr=[`allow`,`confirm`,`deny`];function Sr(){let e=Se(),n=e?.connected??!1,[r,i]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),[s,c]=(0,W.useState)(null),l=(0,W.useCallback)(async(e,t)=>{o(t),c(null);let n=await L.runtime.sendMessage({channel:m,...e}).catch(()=>null);o(null),n?.ok?i(n.data):c(n?.error.message??`The daemon did not answer.`)},[]);(0,W.useEffect)(()=>{n&&l({op:`guardrails`},`load`)},[n,l]);let u=(e,t)=>void l({op:`setGuardrail`,setting:e,value:t},e);return e?.paired?n?r?(0,K.jsxs)(`div`,{className:`space-y-5 px-3 pb-6`,children:[(0,K.jsxs)(`header`,{className:`space-y-1.5`,children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,K.jsx)(`h2`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Guardrails`}),(0,K.jsxs)(`button`,{type:`button`,onClick:()=>void l({op:`guardrails`},`load`),disabled:a!==null,className:`flex items-center gap-1 font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase transition-colors hover:text-brand disabled:opacity-40`,children:[(0,K.jsx)(t,{className:d(`size-3`,a===`load`&&`animate-spin`)}),` Reload`]})]}),(0,K.jsxs)(`p`,{className:`text-[11px] leading-relaxed text-ink-faint`,children:[`A row left off uses the default Browsentic ships. Turning one on writes an override to`,` `,(0,K.jsx)(`span`,{className:`font-mono text-[10px] text-ink-dim`,children:r.configPath}),` and nothing else. A run takes its policy when it starts, so a change here applies to the next one.`]})]}),s&&(0,K.jsx)(`p`,{className:`text-[11px] text-destructive`,children:s}),(0,K.jsx)(`section`,{className:`space-y-1.5`,children:r.rules.map(e=>(0,K.jsx)(Cr,{rule:e,busy:a===e.id,onWrite:u},e.id))}),(0,K.jsxs)(`section`,{className:`space-y-1.5`,children:[(0,K.jsx)(`h3`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`Everything else`}),(0,K.jsx)(wr,{title:`Fence page text`,note:`Wraps every page result in a marker telling the model it is reading data, never instructions.`,state:r.fence.overridden?r.fence.enabled?`On`:`Off`:`On (default)`,on:r.fence.overridden,busy:a===vr,onToggle:e=>u(vr,e?r.fence.enabled:null),children:r.fence.overridden&&(0,K.jsx)(Tr,{options:[{value:!0,label:`Fence`},{value:!1,label:`Do not fence`}],value:r.fence.enabled,onSelect:e=>u(`fence`,e)})}),(0,K.jsx)(wr,{title:`Callers with nobody to ask`,note:`An MCP client outside the side panel cannot answer a prompt. This is what its “Ask” decisions become.`,state:r.unattended.overridden?br[r.unattended.effect]:`Block (default)`,on:r.unattended.overridden,busy:a===yr,onToggle:e=>u(yr,e?r.unattended.effect:null),children:r.unattended.overridden&&(0,K.jsx)(Tr,{options:[{value:`deny`,label:`Block`},{value:`allow`,label:`Allow`}],value:r.unattended.effect,onSelect:e=>u(`unattended`,e)})}),(0,K.jsxs)(`div`,{className:`rounded-md border border-line bg-surface/30 px-2.5 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(D,{className:`size-3 text-brand`}),(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-ink`,children:`Credential sealing`}),(0,K.jsx)(`span`,{className:`ml-auto font-mono text-[9px] tracking-[0.1em] text-brand uppercase`,children:`Always on`})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:`Passwords, keys, tokens and cookies are replaced by a placeholder before a result leaves the browser. There is no switch: it is what keeps a plaintext credential off the socket in the first place.`})]}),r.hosts.length>0&&(0,K.jsxs)(`div`,{className:`rounded-md border border-line bg-surface/30 px-2.5 py-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-ink`,children:`Standing host allowlist`}),(0,K.jsx)(`p`,{className:`mt-1 font-mono text-[10px] leading-relaxed break-all text-ink-dim`,children:r.hosts.join(` · `)}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] text-ink-faint`,children:`Added to every run’s scope. Edited in config.json.`})]})]})]}):(0,K.jsx)(Er,{children:s??`Reading the policy…`}):(0,K.jsx)(Er,{children:`The daemon is offline. Settings live in its config file, so they load when it reconnects.`}):(0,K.jsx)(Er,{children:`Pair a browser to see what this agent is allowed to do.`})}function Cr({rule:e,busy:t,onWrite:n}){if(e.locked)return(0,K.jsxs)(`div`,{className:`rounded-md border border-line bg-surface/20 px-2.5 py-2`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-ink-dim`,children:e.title}),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[9px] tracking-[0.1em] text-ink-faint uppercase`,children:[(0,K.jsx)(Ue,{className:`size-2.5`}),br[e.fallback]]})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:e.reason})]});let r=e.override??e.fallback;return(0,K.jsx)(wr,{title:e.title,note:e.reason,state:e.override?br[e.override]:`${br[e.fallback]} (default)`,on:e.override!==void 0,busy:t,onToggle:t=>n(e.id,t?r:null),children:e.override!==void 0&&(0,K.jsx)(Tr,{options:xr.map(e=>({value:e,label:br[e]})),value:e.override,onSelect:t=>n(e.id,t)})})}function wr({title:e,note:t,state:n,on:r,busy:i,onToggle:a,children:o}){return(0,K.jsxs)(`div`,{className:d(`rounded-md border px-2.5 py-2 transition-colors`,r?`border-brand/30 bg-brand/5`:`border-line bg-surface/20`),children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`text-[11px] font-medium text-ink`,children:e}),(0,K.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`font-mono text-[9px] tracking-[0.1em] text-ink-faint uppercase`,children:n}),i?(0,K.jsx)(I,{className:`size-3 animate-spin text-ink-faint`}):(0,K.jsx)(_r,{checked:r,label:`Override ${e}`,onChange:a})]})]}),(0,K.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-ink-faint`,children:t}),o]})}function Tr({options:e,value:t,onSelect:n}){return(0,K.jsx)(`div`,{className:`mt-2 flex gap-1`,children:e.map(e=>(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(e.value),"aria-pressed":e.value===t,className:d(`flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors`,e.value===t?`bg-brand/20 text-brand`:`bg-surface text-ink-faint hover:text-ink-dim`),children:e.label},String(e.value)))})}function Er({children:e}){return(0,K.jsx)(`p`,{className:`px-4 py-8 text-center text-[11px] leading-relaxed text-ink-faint`,children:e})}function Dr({draft:e,onActivate:t,onDiscard:n}){let[r,i]=(0,W.useState)(!1),a=r?e.host:e.domain;return(0,K.jsxs)(`div`,{className:`enters mb-2 overflow-hidden rounded-xl border border-amber/40 bg-amber/8`,children:[(0,K.jsxs)(`div`,{className:`flex items-start gap-2 border-b border-amber/25 px-2.5 py-2`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`truncate text-xs font-medium text-ink`,children:[`Mapped `,e.host]}),(0,K.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-ink-faint`,children:[(0,K.jsxs)(`span`,{children:[e.pages,` pages`]}),(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,K.jsx)(Le,{className:`size-2.5`}),` `,e.screenshots]}),(0,K.jsx)(`span`,{children:new Date(e.generatedAt).toLocaleString()})]})]}),(0,K.jsx)(q,{variant:`warning`,children:`not active yet`})]}),(0,K.jsxs)(`div`,{className:`px-2.5 py-2`,children:[(0,K.jsxs)(`p`,{className:`mb-2 text-[11px] leading-relaxed text-ink-dim`,children:[`This was written from pages the agent read. Once you activate it, it joins the instructions for every future request on `,(0,K.jsx)(`span`,{className:`font-mono text-ink`,children:a}),`. Read it first.`]}),e.warnings.length>0&&(0,K.jsx)(`div`,{className:`mb-2 space-y-1 rounded-lg bg-amber/12 px-2 py-1.5`,children:e.warnings.map(e=>(0,K.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-snug text-amber`,children:[(0,K.jsx)(T,{className:`mt-0.5 size-3 shrink-0`}),(0,K.jsx)(`span`,{children:e})]},e))}),(0,K.jsx)(`div`,{className:`max-h-56 overflow-x-hidden overflow-y-auto rounded-lg border border-line bg-ground/70`,children:(0,K.jsx)(`pre`,{className:`px-2 py-1.5 font-mono text-[10px] leading-relaxed break-words whitespace-pre-wrap text-ink-dim`,children:e.markdown})}),(0,K.jsxs)(`p`,{className:`mt-1.5 flex items-start gap-1 font-mono text-[10px] break-all text-ink-faint`,children:[(0,K.jsx)(Pe,{className:`mt-0.5 size-2.5 shrink-0`}),e.directory]}),e.screenshots>0&&(0,K.jsx)(`p`,{className:`mt-0.5 text-[10px] text-ink-faint`,children:`Screenshots may show pages you were signed in to. They stay on this machine.`}),(0,K.jsxs)(`label`,{className:`mt-2 flex items-center gap-1.5 text-[11px] text-ink-dim`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`size-3 accent-brand`}),`Only on `,(0,K.jsx)(`span`,{className:`font-mono text-ink`,children:e.host}),`, not its subdomains`]}),(0,K.jsxs)(`div`,{className:`mt-2.5 flex gap-1.5`,children:[(0,K.jsxs)(C,{variant:`ghost`,size:`sm`,className:`flex-1`,onClick:n,children:[(0,K.jsx)(ot,{className:`size-3`}),` Discard`]}),(0,K.jsxs)(C,{size:`sm`,className:`flex-1`,onClick:()=>t(r),children:[(0,K.jsx)(P,{className:`size-3`}),` Activate`]})]})]})]})}function Or(){let[e,t]=(0,W.useState)([]);return(0,W.useEffect)(()=>{let e=!0;L.storage.local.get(me).then(n=>{let r=n[me];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:skills`in e){let n=e[me].newValue;t(Array.isArray(n)?n:[])}};return L.storage.local.onChanged.addListener(n),()=>{e=!1,L.storage.local.onChanged.removeListener(n)}},[]),e}function kr({tabUrl:e,connected:t,onMapSite:n,mapping:r}){let i=Or(),a=(0,W.useRef)(null),[o,s]=(0,W.useState)(null),[c,l]=(0,W.useState)(``),[u,d]=(0,W.useState)(null),f=Ct(e),p=t&&!r&&/^https?:/.test(e),h=i.some(e=>e.origin===`generated`&&Et(f,e.domains));async function g(){let e=a.current,t=e?.files?.[0];if(e&&(e.value=``),!t)return;let n=At(await t.text(),t.name);s(n),l(n.domains.join(`, `)),d(null)}async function _(){if(!o)return;let e=c.split(`,`).map(wt).filter(Boolean),t=Ot({...o,domains:e});if(!t.ok){d(t.message);return}let n=t.draft,r=crypto.randomUUID();await j({id:r,name:n.name,description:n.description,category:n.category,domains:n.domains,status:`pending`,addedAt:Date.now()},{id:r,body:n.body,triggers:n.triggers}),await L.runtime.sendMessage({channel:m,op:`saveSkill`,skillId:r}),s(null),d(null)}return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-3 p-3`,children:[(0,K.jsx)(`p`,{className:`text-[11px] leading-relaxed text-ink-dim`,children:`Notes about a site — where things are, how its lists load — that join the agent’s instructions only while you are on that site. Let the agent write them for you, or upload your own markdown.`}),!o&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:[(0,K.jsxs)(C,{size:`sm`,onClick:n,disabled:!p,title:p?`Map ${f}`:`Open an http(s) page, with no run in progress`,children:[r?(0,K.jsx)(I,{className:`animate-spin`}):(0,K.jsx)(De,{}),(0,K.jsxs)(`span`,{className:`truncate`,children:[h?`Re-map`:`Map`,` this site`]})]}),(0,K.jsxs)(C,{variant:`outline`,size:`sm`,onClick:()=>a.current?.click(),children:[(0,K.jsx)(ct,{}),` Upload notes`]})]}),o?(0,K.jsx)(Ar,{draft:o,domainText:c,error:u,connected:t,onChange:e=>{s({...o,...e}),d(null)},onDomainText:e=>{l(e),d(null)},onCancel:()=>{s(null),d(null)},onSave:()=>void _()}):(0,K.jsx)(jr,{skills:i,host:f}),(0,K.jsx)(`input`,{ref:a,type:`file`,accept:`.md,.markdown,text/markdown`,className:`hidden`,onChange:()=>void g()})]})}function Ar({draft:e,domainText:t,error:n,connected:r,onChange:i,onDomainText:a,onCancel:o,onSave:s}){let c=e.category===`site-exploration`;return(0,K.jsxs)(`div`,{className:`panel-card flex flex-col gap-2 rounded-xl p-2.5`,children:[(0,K.jsx)(`p`,{className:`font-mono text-[10px] tracking-[0.14em] text-ink-faint uppercase`,children:`New skill`}),(0,K.jsx)(N,{value:e.name,onChange:e=>i({name:e.target.value.toLowerCase()}),placeholder:`skill-name`,"aria-label":`Skill name`,className:`h-8 font-mono text-xs`}),(0,K.jsx)(N,{value:e.description,onChange:e=>i({description:e.target.value}),placeholder:`What is this for?`,"aria-label":`Skill description`,className:`h-8 text-xs`}),(0,K.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,K.jsx)(C,{variant:c?`outline`:`default`,size:`sm`,className:`flex-1`,onClick:()=>i({category:`general`}),children:`General`}),(0,K.jsxs)(C,{variant:c?`default`:`outline`,size:`sm`,className:`flex-1`,onClick:()=>i({category:`site-exploration`}),children:[(0,K.jsx)(B,{}),` Site notes`]})]}),c&&(0,K.jsx)(N,{value:t,onChange:e=>a(e.target.value),placeholder:`acme.com, admin.acme.com`,"aria-label":`Domains this skill applies to`,className:`h-8 font-mono text-xs`}),(0,K.jsx)(`p`,{className:`line-clamp-3 rounded-lg border border-line bg-ground/70 px-2 py-1.5 text-[11px] leading-relaxed text-ink-faint`,children:e.body||`This file has no instructions in it.`}),n&&(0,K.jsx)(`p`,{className:`rounded-lg border border-amber/40 bg-amber/10 px-2 py-1.5 text-[11px] text-amber`,children:n}),(0,K.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,K.jsx)(C,{variant:`ghost`,size:`sm`,className:`flex-1`,onClick:o,children:`Cancel`}),(0,K.jsxs)(C,{size:`sm`,className:`flex-1`,onClick:s,disabled:!r,children:[(0,K.jsx)(P,{}),` Save skill`]})]}),!r&&(0,K.jsx)(`p`,{className:`text-center text-[10px] text-ink-faint`,children:`Pair the browser to save skills.`})]})}function jr({skills:e,host:t}){return e.length===0?(0,K.jsxs)(`div`,{className:`dot-grid fade-bottom rounded-xl border border-line px-3 py-6 text-center`,children:[(0,K.jsx)(we,{className:`mx-auto size-5 text-ink-faint`}),(0,K.jsx)(`p`,{className:`mt-2 text-[11px] leading-relaxed text-ink-faint`,children:`No skills yet. Mapping a site writes one for you; uploading a markdown file adds your own.`})]}):(0,K.jsx)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:e.map(e=>(0,K.jsx)(Mr,{skill:e,host:t},e.id))})}function Mr({skill:e,host:t}){let n=e.category===`site-exploration`&&Et(t,e.domains),r=e.origin===`generated`,i=r?De:we;return(0,K.jsxs)(`div`,{className:d(`flex items-start gap-2 rounded-xl border px-2.5 py-2 text-xs`,n?`border-brand/35 bg-brand/8`:`border-line bg-ground/40`),children:[(0,K.jsx)(i,{className:d(`mt-0.5 size-3.5 shrink-0`,n?`text-brand`:`text-ink-faint`)}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`span`,{className:`truncate font-medium text-ink`,children:e.name}),r&&(0,K.jsx)(q,{variant:`outline`,children:`mapped`}),n&&(0,K.jsx)(q,{children:`on this site`})]}),e.domains.length>0&&(0,K.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-ink-faint`,children:e.domains.join(`, `)}),e.description&&(0,K.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] text-ink-dim`,children:e.description}),e.status===`pending`&&(0,K.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-ink-faint`,children:[(0,K.jsx)(I,{className:`size-3 animate-spin`}),` Saving…`]}),e.status===`error`&&(0,K.jsx)(`span`,{className:`mt-0.5 block text-[11px] text-destructive`,children:e.error??`Could not save`})]}),(0,K.jsx)(`button`,{type:`button`,onClick:()=>void L.runtime.sendMessage({channel:m,op:`removeSkill`,skillId:e.id}),"aria-label":`Remove ${e.name}`,className:`mt-0.5 shrink-0 rounded-full p-1 text-ink-faint transition-colors hover:bg-surface hover:text-ink`,children:(0,K.jsx)(U,{className:`size-3`})})]})}var Nr=Object.defineProperty,Y=(e,t)=>Nr(e,`name`,{value:t,configurable:!0});function Pr(e,t){return W.useReducer((e,n)=>t[e][n]??e,e)}Y(Pr,`useStateMachine`);var Fr=`ScrollArea`,[Ir,Lr]=y(Fr),[Rr,X]=Ir(Fr),zr=W.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=W.useState(null),[l,d]=W.useState(null),[f,m]=W.useState(null),[h,g]=W.useState(null),[_,v]=W.useState(null),[y,b]=W.useState(0),[x,S]=W.useState(0),[C,T]=W.useState(!1),[E,D]=W.useState(!1),ee=w(t,c),O=p(i);return(0,K.jsx)(Rr,{scope:n,type:r,dir:O,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:d,content:f,onContentChange:m,scrollbarX:h,onScrollbarXChange:g,scrollbarXEnabled:C,onScrollbarXEnabledChange:T,scrollbarY:_,onScrollbarYChange:v,scrollbarYEnabled:E,onScrollbarYEnabledChange:D,onCornerWidthChange:b,onCornerHeightChange:S,children:(0,K.jsx)(u.div,{dir:O,...o,ref:ee,style:{position:`relative`,"--radix-scroll-area-corner-width":y+`px`,"--radix-scroll-area-corner-height":x+`px`,...e.style}})})},`ScrollArea`)),Br=`ScrollAreaViewport`,Vr=W.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=X(Br,n),s=w(t,W.useRef(null),o.onViewportChange);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Hr,{nonce:i}),(0,K.jsx)(u.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,K.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),Hr=W.memo(Y(function({nonce:e}){return(0,K.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),Z=`ScrollAreaScrollbar`,Ur=W.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=X(Z,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return W.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,K.jsx)(Wr,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,K.jsx)(Gr,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,K.jsx)(Kr,{...r,ref:t,forceMount:n}):i.type===`always`?(0,K.jsx)(qr,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),Wr=W.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=X(Z,e.__scopeScrollArea),[a,o]=W.useState(!1);return W.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=Y(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=Y(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,K.jsx)(h,{present:n||a,children:(0,K.jsx)(Kr,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),Gr=W.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=X(Z,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=fi(()=>c(`SCROLL_END`),100),[s,c]=Pr(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return W.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),W.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=Y(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,K.jsx)(h,{present:n||s!==`hidden`,children:(0,K.jsx)(qr,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:R(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:R(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),Kr=W.forwardRef(Y(function(e,t){let n=X(Z,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=W.useState(!1),s=e.orientation===`horizontal`,c=fi(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return $(n.viewport,c),$(n.content,c),(0,K.jsx)(h,{present:r||a,children:(0,K.jsx)(qr,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),qr=W.forwardRef(Y(function(e,t){let{orientation:n=`vertical`,...r}=e,i=X(Z,e.__scopeScrollArea),a=W.useRef(null),o=W.useRef(0),[s,c]=W.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=oi(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:Y(e=>a.current=e,`onThumbChange`),onThumbPointerUp:Y(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:Y(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return si(e,o.current,s,t)}return Y(d,`getScrollPosition`),n===`horizontal`?(0,K.jsx)(Jr,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=ci(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,K.jsx)(Yr,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=ci(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),Jr=W.forwardRef(Y(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=X(Z,e.__scopeScrollArea),[o,s]=W.useState(),c=W.useRef(null),l=w(t,c,a.onScrollbarXChange);return W.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,K.jsx)(Qr,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":Q(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),ui(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:ai(o.paddingLeft),paddingEnd:ai(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),Yr=W.forwardRef(Y(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=X(Z,e.__scopeScrollArea),[o,s]=W.useState(),c=W.useRef(null),l=w(t,c,a.onScrollbarYChange);return W.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,K.jsx)(Qr,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":Q(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),ui(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:ai(o.paddingTop),paddingEnd:ai(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[Xr,Zr]=Ir(Z),Qr=W.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:c,onThumbPositionChange:l,onDragScroll:d,onWheelScroll:f,onResize:p,...m}=e,h=X(Z,n),[g,_]=W.useState(null),v=w(t,_),y=W.useRef(null),b=W.useRef(``),x=h.viewport,S=r.content-r.viewport,C=s(f),T=s(l),E=fi(p,10);function D(e){if(y.current){let t=e.clientX-y.current.left,n=e.clientY-y.current.top;d({x:t,y:n})}}return Y(D,`handleDragScroll`),W.useEffect(()=>{let e=Y(e=>{let t=e.target;g?.contains(t)&&C(e,S)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[x,g,S,C]),W.useEffect(T,[r,T]),$(g,E),$(h.content,E),(0,K.jsx)(Xr,{scope:n,scrollbar:g,hasThumb:i,onThumbChange:s(a),onThumbPointerUp:s(o),onThumbPositionChange:T,onThumbPointerDown:s(c),children:(0,K.jsx)(u.div,{...m,ref:v,style:{position:`absolute`,...m.style},onPointerDown:R(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),y.current=g.getBoundingClientRect(),b.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,h.viewport&&(h.viewport.style.scrollBehavior=`auto`),D(e))}),onPointerMove:R(e.onPointerMove,D),onPointerUp:R(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=b.current,h.viewport&&(h.viewport.style.scrollBehavior=``),y.current=null})})})},`ScrollAreaScrollbarImpl`)),$r=`ScrollAreaThumb`,ei=W.forwardRef(Y(function(e,t){let{forceMount:n,...r}=e,i=Zr($r,e.__scopeScrollArea);return(0,K.jsx)(h,{present:n||i.hasThumb,children:(0,K.jsx)(ti,{ref:t,...r})})},`ScrollAreaThumb`)),ti=W.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=X($r,n),o=Zr($r,n),{onThumbPositionChange:s}=o,c=w(t,o.onThumbChange),l=W.useRef(void 0),d=fi(()=>{l.current&&=(l.current(),void 0)},100);return W.useEffect(()=>{let e=a.viewport;if(e){let t=Y(()=>{if(d(),!l.current){let t=di(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,d,s]),(0,K.jsx)(u.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:R(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:R(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),ni=`ScrollAreaCorner`,ri=W.forwardRef(Y(function(e,t){let n=X(ni,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,K.jsx)(ii,{...e,ref:t}):null},`ScrollAreaCorner`)),ii=W.forwardRef(Y(function(e,t){let{__scopeScrollArea:n,...r}=e,i=X(ni,n),[a,o]=W.useState(0),[s,c]=W.useState(0),l=!!(a&&s),{onCornerWidthChange:d,onCornerHeightChange:f}=i;return $(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),$(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),W.useEffect(()=>()=>{d(0),f(0)},[d,f]),l?(0,K.jsx)(u.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function ai(e){return e?parseInt(e,10):0}Y(ai,`toInt`);function oi(e,t){let n=e/t;return isNaN(n)?0:n}Y(oi,`getThumbRatio`);function Q(e){let t=oi(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}Y(Q,`getThumbSize`);function si(e,t,n,r=`ltr`){let i=Q(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return li([c,l],d)(e)}Y(si,`getScrollPositionFromPointer`);function ci(e,t,n=`ltr`){let i=Q(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=t.scrollbar.size-a,s=t.content-t.viewport,c=o-i,l=r(e,n===`ltr`?[0,s]:[s*-1,0]);return li([0,s],[0,c])(l)}Y(ci,`getThumbOffsetFromScroll`);function li(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}Y(li,`linearScale`);function ui(e,t){return e>0&&e<t}Y(ui,`isScrollingWithinScrollbarBounds`);var di=Y((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return Y((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function fi(e,t){let n=s(e),r=W.useRef(0);return W.useEffect(()=>()=>window.clearTimeout(r.current),[]),W.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}Y(fi,`useDebounceCallback`);function $(e,t){let n=s(t);_(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}Y($,`useResizeObserver`);var pi=zr,mi=Vr,hi=ri;function gi({className:e,children:t,viewportRef:n,...r}){return(0,K.jsxs)(pi,{"data-slot":`scroll-area`,className:d(`relative`,e),...r,children:[(0,K.jsx)(mi,{ref:n,"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] outline-none [&>div]:block!`,children:t}),(0,K.jsx)(_i,{}),(0,K.jsx)(hi,{})]})}function _i({className:e,orientation:t=`vertical`,...n}){return(0,K.jsx)(Ur,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:d(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,K.jsx)(ei,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-surface-2 transition-colors hover:bg-brand/40`})})}function vi(){return ae().url}function yi(){return xi(O,!1,e=>typeof e==`boolean`)}function bi(){return xi(ue,`chat`,e=>typeof e==`string`)}function xi(e,t,n){let[r,i]=(0,W.useState)(t);return(0,W.useEffect)(()=>{let t=!0;L.storage.local.get(e).then(r=>{t&&n(r[e])&&i(r[e])});let r=t=>{let r=t[e];r&&n(r.newValue)&&i(r.newValue)};return L.storage.local.onChanged.addListener(r),()=>{t=!1,L.storage.local.onChanged.removeListener(r)}},[e]),[r,(0,W.useCallback)(t=>{i(t),L.storage.local.set({[e]:t})},[e])]}function Si(){let[e,t]=(0,W.useState)([]);return(0,W.useEffect)(()=>{let e=!0;L.storage.local.get(x).then(n=>{let r=n[x];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:files`in e){let n=e[x].newValue;t(Array.isArray(n)?n:[])}};return L.storage.local.onChanged.addListener(n),()=>{e=!1,L.storage.local.onChanged.removeListener(n)}},[]),e}function Ci(){let[e,t]=(0,W.useState)([]);return(0,W.useEffect)(()=>{let e=!0;L.storage.local.get(b).then(n=>{let r=n[b];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:recordings`in e){let n=e[b].newValue;t(Array.isArray(n)?n:[])}};return L.storage.local.onChanged.addListener(n),()=>{e=!1,L.storage.local.onChanged.removeListener(n)}},[]),e}function wi(){let[e,t]=(0,W.useState)([]);return(0,W.useEffect)(()=>{let e=!0;L.storage.local.get(se).then(n=>{let r=n[se];e&&Array.isArray(r)&&t(r)});let n=e=>{if(`browsentic:sessions`in e){let n=e[se].newValue;t(Array.isArray(n)?n:[])}};return L.storage.local.onChanged.addListener(n),()=>{e=!1,L.storage.local.onChanged.removeListener(n)}},[]),e}var Ti=10*1024*1024,Ei=56;function Di(){let e=Se(),t=fe(),[r,s]=le(),l=Si(),u=wi(),d=Ci(),p=Or(),h=vi(),[g,_]=(0,W.useState)(null),[v,y]=(0,W.useState)(null),[b,x]=(0,W.useState)(null),[S,w]=(0,W.useState)(!1),[T,E]=bi(),[D,O]=(0,W.useState)(!1),[,k]=yi(),A=(0,W.useRef)(null),j=(0,W.useRef)(null),[te,re]=(0,W.useState)(!0),M=e?.connected??!1,N=ge({active:r&&M&&!t.running,onSubmit:e=>{t.send(e,{agentSkillId:v?.id,focus:b??void 0}),y(null),x(null)}}),ae=f(e,{running:t.running,listening:N.listening});(0,W.useEffect)(()=>{!M||e?.skillCatalog||L.runtime.sendMessage({channel:m,op:`listSkills`})},[M,e?.skillCatalog]),(0,W.useEffect)(()=>{L.runtime.sendMessage({channel:m,op:`panelOpened`}),L.windows.getCurrent().then(e=>{j.current=e.id??null})},[]),(0,W.useEffect)(()=>{let e=A.current;if(!e)return;let t=()=>{let t=e.scrollHeight-e.scrollTop-e.clientHeight;re(t<Ei)};return e.addEventListener(`scroll`,t,{passive:!0}),()=>e.removeEventListener(`scroll`,t)},[]),(0,W.useEffect)(()=>{if(!te||T!==`chat`)return;let e=A.current;e&&(e.scrollTop=e.scrollHeight)},[t.items,t.running,te,T]);function P(){let e=A.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`}),re(!0)}function F(e){O(!1),e!==T&&(E(e),re(e===`chat`),A.current&&(A.current.scrollTop=0))}function se(){O(!1),k(!0),ie(j.current)}function ce(){t.running||!M||(F(`chat`),N.submitNow())}function I(e){F(`chat`),t.restore(e)}function ue(e){F(`chat`),t.send(`Replay my recording “${e.name}” (id ${e.id}).`)}function de(){F(`chat`),t.mapSite()}async function pe(){if(S)return;_(null),w(!0);let e=await Rt();w(!1),`focus`in e?x(e.focus):`error`in e&&_(`A-Eye couldn’t read that element: ${e.error}`)}async function me(){let e=await oe(n,{});if(!e.ok){N.setInput(`${N.input}\n[couldn’t read this page: ${e.error.message}]\n`);return}let{document:t,selection:r}=e.data,i=r?`\nSelection: “${r}”`:``;N.setInput(`${N.input?`${N.input}\n\n`:``}[Page: ${t.title} — ${t.url}${i}]\n`)}async function he(e){if(e.size>Ti){_(`“${e.name}” is larger than ${Ti/1024/1024} MB.`);return}_(null);let t=crypto.randomUUID(),n=await Oi(e);await o({id:t,name:e.name,mime:e.type||`application/octet-stream`,size:e.size,status:`pending`,addedAt:Date.now()},n),await L.runtime.sendMessage({channel:m,op:`analyzeFile`,fileId:t})}function _e(){if(!r){s(!0);return}if(N.error){N.retry();return}s(!1)}let ve=t.sessions.filter(e=>e.runId).length,ye=ve>0&&T!==`chat`,be=ye||!!t.recording||t.monitors.length>0||!!t.draft,xe={history:u.length,skills:p.length,recordings:d.length};return(0,K.jsxs)(`div`,{className:`flex h-screen flex-col`,children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center gap-2 px-3 py-2.5`,children:[(0,K.jsx)(ee,{className:`flex-1`}),(0,K.jsx)(c,{tone:ae.tone,expanded:D,onClick:()=>O(e=>!e),children:ae.label}),(0,K.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:`New chat`,"aria-label":`Start a new conversation`,onClick:()=>{F(`chat`),t.clear()},children:(0,K.jsx)(tt,{className:`size-3.5`})}),(0,K.jsx)(C,{variant:`ghost`,size:`icon-sm`,title:`Minimize to a rail on the page`,"aria-label":`Minimize to a rail on the page`,onClick:se,children:(0,K.jsx)(qe,{className:`size-3.5`})})]}),D&&(0,K.jsx)(Gt,{onClose:()=>O(!1)}),(0,K.jsx)(tn,{tab:T,counts:xe,onSelect:F}),(0,K.jsx)(hr,{sessions:t.sessions,activeSessionId:t.sessionId,onFocus:e=>{F(`chat`),t.focusSession(e)},onEnd:t.endSession}),be&&(0,K.jsxs)(`div`,{className:`max-h-[45%] shrink-0 overflow-y-auto px-3 pt-2`,children:[ye&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>F(`chat`),className:`enters mb-2 flex w-full items-center gap-2 rounded-xl border border-brand/35 bg-brand/8 px-2.5 py-2 text-left transition-colors hover:bg-brand/12`,children:[(0,K.jsx)(`span`,{className:`glow-dot size-1.5 shrink-0 animate-pulse rounded-full bg-brand text-brand`}),(0,K.jsx)(`span`,{className:`flex-1 text-xs text-ink`,children:ve===1?`A run is in progress`:`${ve} runs are in progress`}),(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-[10px] tracking-[0.12em] text-brand uppercase`,children:`Watch`})]}),t.recording&&(0,K.jsx)(rn,{state:t.recording,onStop:t.stopRecording}),t.monitors.map(e=>(0,K.jsx)(Xt,{state:e,onStop:()=>t.stopMonitor(e.monitorId)},e.monitorId)),t.draft&&(0,K.jsx)(Dr,{draft:t.draft,onActivate:t.activateMap,onDiscard:t.discardMap})]}),(0,K.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,K.jsxs)(gi,{viewportRef:A,className:`h-full`,children:[T===`chat`?t.items.length===0?(0,K.jsx)(Jt,{blocker:ae.blocker,voiceOn:r&&N.supported,onGo:F,onFix:()=>O(!0),onUse:N.setInput}):(0,K.jsx)(tr,{items:t.items,running:t.running,onDecide:t.decide}):T===`history`?(0,K.jsx)(lr,{sessions:u,currentId:t.sessionId??void 0,busy:t.running,onOpen:I,onRemove:e=>void ne(e)}):T===`skills`?(0,K.jsx)(kr,{tabUrl:h,connected:M,onMapSite:de,mapping:t.running}):T===`settings`?(0,K.jsx)(Sr,{}):(0,K.jsx)(hn,{tabUrl:h,recordings:d,recording:t.recording,busy:t.running,onStart:t.startRecording,onStop:t.stopRecording,onReplay:ue,onRemove:e=>void i(e)}),(0,K.jsx)(`div`,{className:`h-3`})]}),T===`chat`&&!te&&t.items.length>0&&(0,K.jsxs)(C,{size:`sm`,variant:`outline`,className:`enters absolute bottom-3 left-1/2 -translate-x-1/2 backdrop-blur`,onClick:P,children:[(0,K.jsx)(Ce,{className:`size-3`}),` Latest`]})]}),T===`chat`&&(0,K.jsx)(`footer`,{className:`shrink-0 border-t border-line p-3`,children:(0,K.jsx)(Bt,{voice:N,voiceEnabled:r,connected:M,running:t.running,files:l,attachError:g,catalog:e?.skillCatalog,tabUrl:h,attachedSkill:v,focus:b,picking:S,onAttachSkill:y,onCommand:e=>{F(`chat`),t.send(e)},onSend:ce,onStop:t.cancel,onToggleVoice:_e,onPick:()=>void pe(),onClearFocus:()=>x(null),onAttachPage:()=>void me(),onAttachFile:e=>void he(e),onRemoveFile:e=>void a(e)})})]})}function Oi(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=r.result;t(typeof e==`string`?e.slice(e.indexOf(`,`)+1):``)},r.onerror=()=>n(r.error??Error(`Could not read the file`)),r.readAsDataURL(e)})}dt.createRoot(document.getElementById(`root`)).render((0,K.jsx)(W.StrictMode,{children:(0,K.jsx)(Di,{})}));