@p4code/cli 0.6.48 → 0.6.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.mjs +549 -190
- package/dist/client/assets/{DiffPanel-CBLL8DDt.js → DiffPanel-QET7ky-v.js} +2 -2
- package/dist/client/assets/{FilePreviewPanel-DJeGSXHG.js → FilePreviewPanel-XIjCoVxw.js} +3 -3
- package/dist/client/assets/PreviewPanel-BH0iIJ9a.js +2 -0
- package/dist/client/assets/{PullRequestCodeTab-VeaXNDHp.js → PullRequestCodeTab-DAI4cIYu.js} +2 -2
- package/dist/client/assets/{fileCommentAnnotations-DxX6PWkZ.js → fileCommentAnnotations-ByKdy50L.js} +2 -2
- package/dist/client/assets/index-BSuuYg8z.js +3209 -0
- package/dist/client/assets/{index-Bvl_aGgf.css → index-B_0XzNmV.css} +1 -1
- package/dist/client/assets/previewAssetResource-BMf_t-Oa.js +48 -0
- package/dist/client/assets/{renderFileChildren-Di43LmWA.js → renderFileChildren-DsohA9os.js} +2 -2
- package/dist/client/assets/{toggle-group-CWqFUkb4.js → toggle-group-D7q15ngh.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/PreviewPanel-DThvl6zI.js +0 -2
- package/dist/client/assets/index-BuDjBLW6.js +0 -3203
- package/dist/client/assets/previewAssetResource-Cp_rWZ2h.js +0 -48
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{n as t,r as n,t as r}from"./compiler-runtime-CLAvuQ-D.js";import{$ as i,$a as a,Au as o,B as s,Ct as c,Du as l,G as u,Ga as d,Gu as f,Ia as p,K as m,Ka as h,Mt as g,Mu as _,Q as v,Qa as y,Ru as b,St as x,Ua as S,Ur as C,Vu as w,W as T,Wa as E,Xa as D,Y as ee,Ya as O,Yp as k,Z as te,Za as A,Zp as j,_d as M,_l as N,ht as P,ku as F,mt as I,pu as L,q as ne,qa as R,r as re,ut as ie,vt as ae,wt as oe,x as z,xt as B,yt as V,za as se,zl as ce}from"./previewAssetResource-Cp_rWZ2h.js";import{$n as le,$r as ue,Ar as H,B as de,Cr as fe,Dr as U,Er as pe,Gr as W,H as G,I as K,Jr as me,Kr as he,L as ge,Mr as _e,Nr as ve,Or as q,Pr as J,Qn as Y,Qr as X,R as ye,Tr as be,V as xe,Xn as Se,Yn as Ce,Yr as we,Zn as Te,Zr as Ee,a as De,ai as Oe,c as ke,ci as Ae,d as je,et as Me,i as Ne,j as Pe,jr as Fe,kr as Ie,l as Le,mi as Re,n as ze,nt as Be,o as Ve,pi as He,r as Ue,s as We,t as Ge,tt as Ke,u as qe,wr as Je,y as Ye,z as Xe}from"./index-BuDjBLW6.js";var Ze=N(`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`}]]),Qe=N(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),$e=N(`radio-tower`,[[`path`,{d:`M4.9 16.1C1 12.2 1 5.8 4.9 1.9`,key:`s0qx1y`}],[`path`,{d:`M7.8 4.7a6.14 6.14 0 0 0-.8 7.5`,key:`1idnkw`}],[`circle`,{cx:`12`,cy:`9`,r:`2`,key:`1092wv`}],[`path`,{d:`M16.2 4.8c2 2 2.26 5.11.8 7.47`,key:`ojru2q`}],[`path`,{d:`M19.1 1.9a9.96 9.96 0 0 1 0 14.1`,key:`rhi7fg`}],[`path`,{d:`M9.5 18h5`,key:`mfy3pd`}],[`path`,{d:`m8 22 4-11 4 11`,key:`25yftu`}]]),Z=r(),Q=e(n(),1),$=t(),et=()=>{};function tt(e){let t=(0,Z.c)(116),{url:n,displayUrl:r,loading:i,loadProgress:o,canGoBack:s,canGoForward:c,refreshDisabled:l,inputDisabled:u,focusUrlNonce:d,onBack:f,onForward:m,onRefresh:h,onSubmit:g,onOpenInBrowser:_,onCapture:v,captureDisabled:y,recording:b,onPictureInPicture:x,pictureInPicture:S,pictureInPictureDisabled:C,onPickElement:w,pickActive:T,pickDisabled:E,pickDisabledReason:D,trailingActions:ee}=e,O=(0,Q.useRef)(null),[k,te]=(0,Q.useState)(n),[A,j]=(0,Q.useState)(!1),M;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(M=[],t[0]=M):M=t[0];let[N,P]=(0,Q.useState)(M),[F,I]=(0,Q.useState)(-1),L=(0,Q.useId)(),ne;t[1]!==k||t[2]!==N||t[3]!==A||t[4]!==n?(ne=A&&k!==n?qe(N,k):[],t[1]=k,t[2]=N,t[3]=A,t[4]=n,t[5]=ne):ne=t[5];let R=ne,re,ie;t[6]===d?(re=t[7],ie=t[8]):(re=()=>{if(d==null)return;let e=O.current;e&&e.focus()},ie=[d],t[6]=d,t[7]=re,t[8]=ie),(0,Q.useEffect)(re,ie);let oe;t[9]!==F||t[10]!==k||t[11]!==g||t[12]!==R?(oe=e=>{e?.preventDefault();let t=R[F]?.url??k.trim();t.length!==0&&(g(t),O.current?.blur())},t[9]=F,t[10]=k,t[11]=g,t[12]=R,t[13]=oe):oe=t[13];let z=oe,se=s?f:et,ce=!s,le;t[14]!==se||t[15]!==ce?(le=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:ce,"aria-label":`Back`,type:`button`}),t[14]=se,t[15]=ce,t[16]=le):le=t[16];let ue;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(Re,{}),t[17]=ue):ue=t[17];let H;t[18]===le?H=t[19]:(H=(0,$.jsx)(B,{render:le,children:ue}),t[18]=le,t[19]=H);let de;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(de=(0,$.jsx)(V,{children:`Back`}),t[20]=de):de=t[20];let fe;t[21]===H?fe=t[22]:(fe=(0,$.jsxs)(ae,{children:[H,de]}),t[21]=H,t[22]=fe);let U=c?m:et,pe=!c,G;t[23]!==U||t[24]!==pe?(G=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:U,disabled:pe,"aria-label":`Forward`,type:`button`}),t[23]=U,t[24]=pe,t[25]=G):G=t[25];let K;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(He,{}),t[26]=K):K=t[26];let me;t[27]===G?me=t[28]:(me=(0,$.jsx)(B,{render:G,children:K}),t[27]=G,t[28]=me);let he;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(he=(0,$.jsx)(V,{children:`Forward`}),t[29]=he):he=t[29];let ge;t[30]===me?ge=t[31]:(ge=(0,$.jsxs)(ae,{children:[me,he]}),t[30]=me,t[31]=ge);let _e=l?et:h,ve=i?`Stop`:`Refresh`,q;t[32]!==l||t[33]!==_e||t[34]!==ve?(q=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:_e,disabled:l,"aria-label":ve,type:`button`}),t[32]=l,t[33]=_e,t[34]=ve,t[35]=q):q=t[35];let J=i&&`animate-spin`,Y;t[36]===J?Y=t[37]:(Y=a(J),t[36]=J,t[37]=Y);let X;t[38]===Y?X=t[39]:(X=(0,$.jsx)(W,{className:Y}),t[38]=Y,t[39]=X);let ye;t[40]!==q||t[41]!==X?(ye=(0,$.jsx)(B,{render:q,children:X}),t[40]=q,t[41]=X,t[42]=ye):ye=t[42];let be=i?`Loading…`:`Refresh`,xe;t[43]===be?xe=t[44]:(xe=(0,$.jsx)(V,{children:be}),t[43]=be,t[44]=xe);let Se;t[45]!==ye||t[46]!==xe?(Se=(0,$.jsxs)(ae,{children:[ye,xe]}),t[45]=ye,t[46]=xe,t[47]=Se):Se=t[47];let Ce;t[48]!==fe||t[49]!==ge||t[50]!==Se?(Ce=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[fe,ge,Se]}),t[48]=fe,t[49]=ge,t[50]=Se,t[51]=Ce):Ce=t[51];let Te=A?k:r??n,De=_&&!A&&`group-hover/address:pe-7 transition-[padding]`,Oe;t[52]===De?Oe=t[53]:(Oe=a(De),t[52]=De,t[53]=Oe);let ke;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>{te(e.target.value),I(-1)},t[54]=ke):ke=t[54];let je;t[55]===n?je=t[56]:(je=()=>{te(n),P(Le()),I(-1),j(!0),queueMicrotask(()=>O.current?.select())},t[55]=n,t[56]=je);let Ne;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=()=>{j(!1)},t[57]=Ne):Ne=t[57];let Pe;t[58]!==z||t[59]!==R.length||t[60]!==n?(Pe=e=>{if(e.key===`Enter`&&z(e),(e.key===`ArrowDown`||e.key===`ArrowUp`)&&R.length>0){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;I(e=>{let n=e+t;return n>=R.length?-1:n<-1?R.length-1:n})}e.key===`Escape`&&(e.preventDefault(),te(n),O.current?.blur())},t[58]=z,t[59]=R.length,t[60]=n,t[61]=Pe):Pe=t[61];let Fe=R.length>0,Ie=F>=0?`${L}-${F}`:void 0,ze;t[62]!==u||t[63]!==L||t[64]!==Te||t[65]!==Oe||t[66]!==je||t[67]!==Pe||t[68]!==Fe||t[69]!==Ie?(ze=(0,$.jsx)(B,{render:(0,$.jsx)(Be,{ref:O,value:Te,className:Oe,onChange:ke,onFocus:je,onBlur:Ne,onKeyDown:Pe,role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":Fe,"aria-controls":L,"aria-activedescendant":Ie,placeholder:`Search or enter URL`,spellCheck:!1,disabled:u,"data-preview-url-input":!0,size:`sm`})}),t[62]=u,t[63]=L,t[64]=Te,t[65]=Oe,t[66]=je,t[67]=Pe,t[68]=Fe,t[69]=Ie,t[70]=ze):ze=t[70];let Ve;t[71]!==r||t[72]!==A||t[73]!==n?(Ve=!A&&r?(0,$.jsx)(V,{children:n}):null,t[71]=r,t[72]=A,t[73]=n,t[74]=Ve):Ve=t[74];let Ue;t[75]!==ze||t[76]!==Ve?(Ue=(0,$.jsxs)(ae,{children:[ze,Ve]}),t[75]=ze,t[76]=Ve,t[77]=Ue):Ue=t[77];let We;t[78]!==A||t[79]!==_?(We=_&&!A?(0,$.jsx)(Ke,{align:`inline-end`,className:`pointer-events-none absolute inset-y-0 right-0 opacity-0 transition-opacity group-hover/address:pointer-events-auto group-hover/address:opacity-100`,children:(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,onClick:_,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(Ae,{})}),(0,$.jsx)(V,{children:`Open in system browser`})]})}):null,t[78]=A,t[79]=_,t[80]=We):We=t[80];let Ge;t[81]!==Ue||t[82]!==We?(Ge=(0,$.jsxs)(Me,{className:`group/address h-7 flex-1 rounded-md border-transparent bg-transparent shadow-none before:shadow-none hover:bg-muted/40 focus-within:bg-background`,children:[Ue,We]}),t[81]=Ue,t[82]=We,t[83]=Ge):Ge=t[83];let Je;t[84]!==w||t[85]!==T||t[86]!==E||t[87]!==D?(Je=w?(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(p,{variant:T?`secondary`:`ghost`,size:`icon-xs`,onClick:w,disabled:E,"aria-label":T?`Cancel annotation`:`Annotate preview`,"aria-pressed":T?`true`:`false`,type:`button`}),children:(0,$.jsx)(Ee,{className:a(T&&`text-primary`)})}),(0,$.jsx)(V,{children:E&&D?D:T?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[84]=w,t[85]=T,t[86]=E,t[87]=D,t[88]=Je):Je=t[88];let Ye;t[89]!==y||t[90]!==v||t[91]!==b?(Ye=v?(0,$.jsxs)(ae,{children:[(0,$.jsxs)(B,{render:(0,$.jsx)(p,{variant:b?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>v(e.shiftKey),"aria-label":b?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:y}),children:[(0,$.jsx)(Ze,{className:a(b&&`text-destructive`)}),b?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(V,{children:b?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[89]=y,t[90]=v,t[91]=b,t[92]=Ye):Ye=t[92];let Xe;t[93]!==x||t[94]!==S||t[95]!==C?(Xe=x?(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(p,{variant:S?`secondary`:`ghost`,size:`icon-xs`,onClick:x,"aria-label":S?`Close floating preview`:`Float preview over chat`,"aria-pressed":S?`true`:`false`,type:`button`,disabled:C}),children:(0,$.jsx)(we,{className:a(S&&`text-primary`)})}),(0,$.jsx)(V,{children:S?`Close floating preview`:`Float preview over chat`})]}):null,t[93]=x,t[94]=S,t[95]=C,t[96]=Xe):Xe=t[96];let Qe;t[97]!==z||t[98]!==Ce||t[99]!==Ge||t[100]!==Je||t[101]!==Ye||t[102]!==Xe||t[103]!==ee?(Qe=(0,$.jsxs)(`form`,{onSubmit:z,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[Ce,Ge,Je,Ye,Xe,ee]}),t[97]=z,t[98]=Ce,t[99]=Ge,t[100]=Je,t[101]=Ye,t[102]=Xe,t[103]=ee,t[104]=Qe):Qe=t[104];let $e;t[105]!==F||t[106]!==g||t[107]!==R||t[108]!==L?($e=R.length>0?(0,$.jsx)(`ul`,{id:L,role:`listbox`,"aria-label":`History suggestions`,className:`absolute inset-x-2 top-full z-50 mt-1 overflow-hidden rounded-lg border border-border bg-popover p-1 text-popover-foreground shadow-lg`,children:R.map((e,t)=>(0,$.jsxs)(`li`,{id:`${L}-${t}`,role:`option`,"aria-selected":t===F,onMouseDown:nt,onClick:()=>{g(e.url),O.current?.blur()},onMouseEnter:()=>I(t),className:`flex cursor-default flex-col rounded-md px-2 py-1 text-sm aria-selected:bg-accent aria-selected:text-accent-foreground`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.title||e.url}),e.title?(0,$.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.url}):null]},e.url))}):null,t[105]=F,t[106]=g,t[107]=R,t[108]=L,t[109]=$e):$e=t[109];let tt;t[110]===o?tt=t[111]:(tt=o>0?(0,$.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute bottom-0 left-0 z-10 h-0.5 rounded-r-full bg-primary transition-all duration-150 ease-out`,style:{width:`${o}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[110]=o,t[111]=tt);let rt;return t[112]!==Qe||t[113]!==$e||t[114]!==tt?(rt=(0,$.jsxs)(`div`,{className:`relative`,children:[Qe,$e,tt]}),t[112]=Qe,t[113]=$e,t[114]=tt,t[115]=rt):rt=t[115],rt}function nt(e){return e.preventDefault()}function rt(e){try{let t=new URL(e.url),n=new URL(e.environmentHttpBaseUrl);if(t.origin===n.origin&&t.pathname.startsWith(`/api/assets/`)){let n=t.pathname.split(`/`).at(-1);if(!n)return null;let r=decodeURIComponent(n);return!r||r===`.`||r===`..`?null:`${e.environmentLabel} · ${r}`}return t.protocol===`http:`||t.protocol===`https:`?t.host:null}catch{return null}}function it(e){let t=(0,Z.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=a(`relative flex flex-col gap-0.5 overflow-hidden rounded-[5px] border border-border/60 bg-card p-1 shadow-xs/5`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-destructive/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-warning/80`}),(0,$.jsx)(`span`,{className:`size-[3px] rounded-full bg-success/80`})]}),t[2]=i):i=t[2];let o;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsxs)(`div`,{className:`mt-[1px] flex flex-1 flex-col gap-[2px]`,children:[(0,$.jsx)(`span`,{className:`h-[2px] w-full rounded-full bg-muted-foreground/30`}),(0,$.jsx)(`span`,{className:`h-[2px] w-3/5 rounded-full bg-muted-foreground/20`})]}),t[3]=o):o=t[3];let s;return t[4]===r?s=t[5]:(s=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,o]}),t[4]=r,t[5]=s),s}function at(e){let t=(0,Z.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=ot(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(it,{className:`size-7 shrink-0`}),t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=(0,$.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:a}),t[3]=a,t[4]=s);let c;t[5]!==n.host||t[6]!==n.port?(c=(0,$.jsxs)(`span`,{className:`truncate text-xs text-muted-foreground`,children:[n.host,`:`,n.port]}),t[5]=n.host,t[6]=n.port,t[7]=c):c=t[7];let l;t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[s,c]}),t[8]=s,t[9]=c,t[10]=l):l=t[10];let u;t[11]===n.listening?u=t[12]:(u=n.listening?(0,$.jsx)(st,{}):(0,$.jsx)(ct,{}),t[11]=n.listening,t[12]=u);let d;return t[13]!==r||t[14]!==l||t[15]!==u?(d=(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex w-full items-center gap-3 px-3 py-3 text-left hover:bg-accent/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[o,l,u]}),t[13]=r,t[14]=l,t[15]=u,t[16]=d):d=t[16],d}function ot(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function st(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsxs)(`span`,{"aria-label":`Listening`,className:`relative inline-flex size-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 animate-status-ping rounded-full bg-success opacity-60`}),(0,$.jsx)(`span`,{className:`relative inline-flex size-2 rounded-full bg-success`})]}),e[0]=t):t=e[0],t}function ct(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`span`,{"aria-label":`Not currently listening`,className:`size-2 shrink-0 rounded-full bg-muted-foreground/40`}),e[0]=t):t=e[0],t}function lt(e){let t=(0,Z.c)(7),n=U(e.environmentId),r;if(t[0]!==e.configuredUrls||t[1]!==e.environmentId||t[2]!==e.recentlySeenUrls||t[3]!==n){let i;t[5]===e.environmentId?i=t[6]:(i=t=>({...t,url:Je(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=ut({scanner:n.map(i),configuredUrls:e.configuredUrls??[],recentlySeenUrls:e.recentlySeenUrls??[]}),t[0]=e.configuredUrls,t[1]=e.environmentId,t[2]=e.recentlySeenUrls,t[3]=n,t[4]=r}else r=t[4];return r}function ut(e){let t=new Map;for(let n of e.configuredUrls){let e=ft(n);if(!e)continue;let r=dt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`configured`,listening:!1})}for(let n of e.scanner){let e=dt(n.host,n.port),r=t.get(e);if(r){t.set(e,{...r,processName:n.processName??r.processName,pid:n.pid??r.pid,terminal:n.terminal??r.terminal,listening:!0});continue}t.set(e,{...n,source:`scanner`,listening:!0})}for(let n of e.recentlySeenUrls){let e=ft(n);if(!e)continue;let r=dt(e.host,e.port);t.has(r)||t.set(r,{host:e.host,port:e.port,url:e.url,processName:null,pid:null,terminal:null,source:`recent`,listening:!1})}return Array.from(t.values()).toSorted((e,t)=>{let n={configured:0,scanner:1,recent:2};return n[e.source]===n[t.source]?e.port-t.port:n[e.source]-n[t.source]})}function dt(e,t){return`${e.toLowerCase()}:${t}`}function ft(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!be(t.hostname))return null;let n=t.port?Number.parseInt(t.port,10):t.protocol===`http:`?80:443;return!Number.isFinite(n)||n<=0?null:{host:t.hostname,port:n,url:t.href}}catch{return null}}function pt(e){let t=(0,Z.c)(16),{environmentId:n,configuredUrls:r,recentlySeenUrls:i,onOpenUrl:a}=e,o;t[0]!==r||t[1]!==n||t[2]!==i?(o={environmentId:n,configuredUrls:r,recentlySeenUrls:i},t[0]=r,t[1]=n,t[2]=i,t[3]=o):o=t[3];let s=lt(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(Ce,{children:[(0,$.jsx)(Te,{variant:`icon`,children:(0,$.jsx)(Oe,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(Y,{children:`No preview yet`}),(0,$.jsx)(Se,{children:`Type a URL above, or run a dev script. Listening localhost ports will show up here automatically.`})]}),t[4]=e):e=t[4],e}let c;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)($e,{className:`size-4 shrink-0`}),(0,$.jsx)(`h2`,{className:`font-medium`,children:`Local servers`})]}),t[5]=c):c=t[5];let l;if(t[6]!==a||t[7]!==s){let e;t[9]===a?e=t[10]:(e=e=>(0,$.jsx)(at,{server:e,onOpen:()=>a(e.url)},`${e.host}:${e.port}`),t[9]=a,t[10]=e),l=s.map(e),t[6]=a,t[7]=s,t[8]=l}else l=t[8];let u;t[11]===l?u=t[12]:(u=(0,$.jsx)(`div`,{className:`flex flex-col divide-y divide-border/60 overflow-hidden rounded-xl border border-border/70 bg-background`,children:l}),t[11]=l,t[12]=u);let d;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`p`,{className:`px-1 text-xs text-muted-foreground`,children:`Select a listening port to open it in this browser tab.`}),t[13]=d):d=t[13];let f;return t[14]===u?f=t[15]:(f=(0,$.jsx)(`div`,{className:`flex h-full min-h-0 overflow-y-auto px-5 py-8`,children:(0,$.jsxs)(`div`,{className:`m-auto flex w-full max-w-xl flex-col gap-3`,children:[c,u,d]})}),t[14]=u,t[15]=f),f}var mt=e=>(e instanceof Error?e.message:``).replace(/^Error invoking remote method '[^']+':\s*/u,``).replace(/^[A-Za-z]+Error:\s*/u,``).trim()||`Chrome import failed.`;function ht(e){let[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{if(!e.open||!K)return;let t=!1;return n(null),c(null),K.listChromeProfiles().then(e=>{t||(n(e),i(e[0]?.id??null))},e=>{t||(n([]),i(null),c(mt(e)))}),()=>{t=!0}},[e.open]);let l=async()=>{if(!(!K||!r)){o(!0);try{let t=await K.importFromChrome({profileId:r});ke(t.history),I.add({type:`success`,title:`Imported from Chrome`,description:`${t.importedCookies} cookies and ${t.history.length} history entries.${t.failedCookies>0?` ${t.failedCookies} cookies could not be imported.`:``}`}),e.onOpenChange(!1)}catch(e){I.add({type:`error`,title:`Could not import from Chrome`,description:mt(e)})}finally{o(!1)}}};return(0,$.jsx)(q,{open:e.open,onOpenChange:e.onOpenChange,children:(0,$.jsxs)(ve,{className:`max-w-md`,children:[(0,$.jsxs)(Fe,{children:[(0,$.jsx)(J,{children:`Import from Chrome`}),(0,$.jsx)(Ie,{children:`Copies all cookies and recent history from a Chrome profile into the built-in browser. Agents that use this browser can act with these signed-in sessions. macOS asks for Keychain access to decrypt the cookies.`})]}),(0,$.jsx)(_e,{children:s?(0,$.jsx)(`p`,{className:`text-sm text-destructive-foreground`,children:s}):t===null?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Looking for Chrome profiles…`}):t.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Chrome profiles found. Importing is available on macOS with Google Chrome installed.`}):(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":`Chrome profile`,className:`space-y-1`,children:t.map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 rounded-md px-2 py-1.5 text-sm hover:bg-accent`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`chrome-profile`,value:e.id,checked:r===e.id,onChange:()=>i(e.id)}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),e.name===e.id?null:(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.id})]},e.id))})}),(0,$.jsxs)(H,{children:[(0,$.jsx)(p,{variant:`outline`,onClick:()=>e.onOpenChange(!1),children:`Cancel`}),(0,$.jsx)(p,{disabled:!r||a,onClick:()=>void l(),children:a?`Importing…`:`Import`})]})]})})}var gt=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function _t(e){let t=(0,Z.c)(81),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:a,deviceToolbarVisible:o,onToggleDeviceToolbar:s,nativePictureInPicture:c,onNativePictureInPicture:l}=e,[u,f]=(0,Q.useState)(!1);if(!K)return null;let m=!n||!r,h;t[0]===n?h=t[1]:(h=e=>()=>{n&&e(n).catch(Tt)},t[0]=n,t[1]=h);let g=h,_;t[2]===i?_=t[3]:(_=Math.round(i*100),t[2]=i,t[3]=_);let v=`${_}%`,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(ae,{children:[(0,$.jsx)(B,{render:(0,$.jsx)(y,{render:(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Qe,{})}),(0,$.jsx)(V,{children:`More`})]}),t[4]=b):b=t[4];let x;t[5]===g?x=t[6]:(x=g(K.hardReload),t[5]=g,t[6]=x);let C;t[7]!==x||t[8]!==m?(C=(0,$.jsx)(S,{onClick:x,disabled:m,children:`Hard reload`}),t[7]=x,t[8]=m,t[9]=C):C=t[9];let w;t[10]===g?w=t[11]:(w=g(K.openDevTools),t[10]=g,t[11]=w);let T;t[12]!==w||t[13]!==m?(T=(0,$.jsx)(S,{onClick:w,disabled:m,children:`Open DevTools`}),t[12]=w,t[13]=m,t[14]=T):T=t[14];let ee=c?`Close separate preview window`:`Open separate preview window`,k;t[15]!==l||t[16]!==ee||t[17]!==m?(k=(0,$.jsx)(S,{onClick:l,disabled:m,children:ee}),t[15]=l,t[16]=ee,t[17]=m,t[18]=k):k=t[18];let te=o?`Hide device toolbar`:`Show device toolbar`,j;t[19]!==s||t[20]!==te||t[21]!==m?(j=(0,$.jsx)(S,{onClick:s,disabled:m,children:te}),t[19]=s,t[20]=te,t[21]=m,t[22]=j):j=t[22];let M;t[23]===m?M=t[24]:(M=(0,$.jsx)(A,{disabled:m,children:`Appearance`}),t[23]=m,t[24]=M);let N;t[25]===n?N=t[26]:(N=e=>{n&&K.setColorScheme(n,e).catch(wt)},t[25]=n,t[26]=N);let P;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(P=gt.map(Ct),t[27]=P):P=t[27];let F;t[28]!==a||t[29]!==N?(F=(0,$.jsx)(D,{className:`min-w-32`,children:(0,$.jsx)(d,{value:a,onValueChange:N,children:P})}),t[28]=a,t[29]=N,t[30]=F):F=t[30];let I;t[31]!==M||t[32]!==F?(I=(0,$.jsxs)(O,{children:[M,F]}),t[31]=M,t[32]=F,t[33]=I):I=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(R,{}),t[34]=L):L=t[34];let ne;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(`span`,{children:`Zoom`}),t[35]=ne):ne=t[35];let re;t[36]===g?re=t[37]:(re=g(K.zoomOut),t[36]=g,t[37]=re);let ie;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,$.jsx)(ue,{}),t[38]=ie):ie=t[38];let oe;t[39]!==re||t[40]!==m?(oe=(0,$.jsx)(p,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:re,"aria-label":`Zoom out`,disabled:m,children:ie}),t[39]=re,t[40]=m,t[41]=oe):oe=t[41];let z;t[42]===v?z=t[43]:(z=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:v}),t[42]=v,t[43]=z);let ce;t[44]===g?ce=t[45]:(ce=g(K.zoomIn),t[44]=g,t[45]=ce);let le;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(me,{}),t[46]=le):le=t[46];let H;t[47]!==ce||t[48]!==m?(H=(0,$.jsx)(p,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:ce,"aria-label":`Zoom in`,disabled:m,children:le}),t[47]=ce,t[48]=m,t[49]=H):H=t[49];let de;t[50]===g?de=t[51]:(de=g(K.resetZoom),t[50]=g,t[51]=de);let fe;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,$.jsx)(he,{}),t[52]=fe):fe=t[52];let U;t[53]!==de||t[54]!==m?(U=(0,$.jsx)(p,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:de,"aria-label":`Reset zoom`,disabled:m,children:fe}),t[53]=de,t[54]=m,t[55]=U):U=t[55];let pe;t[56]!==oe||t[57]!==z||t[58]!==H||t[59]!==U?(pe=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[oe,z,H,U]}),t[56]=oe,t[57]=z,t[58]=H,t[59]=U,t[60]=pe):pe=t[60];let W;t[61]!==pe||t[62]!==m?(W=(0,$.jsxs)(S,{closeOnClick:!1,onClick:St,className:`justify-between`,disabled:m,children:[ne,pe]}),t[61]=pe,t[62]=m,t[63]=W):W=t[63];let G,ge,_e,ve;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(R,{}),ge=(0,$.jsx)(S,{onClick:bt,children:`Clear cookies`}),_e=(0,$.jsx)(S,{onClick:vt,children:`Clear cache`}),ve=(0,$.jsx)(R,{}),t[64]=G,t[65]=ge,t[66]=_e,t[67]=ve):(G=t[64],ge=t[65],_e=t[66],ve=t[67]);let q;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(S,{onClick:()=>f(!0),children:`Import from Chrome…`}),t[68]=q):q=t[68];let J;t[69]!==j||t[70]!==I||t[71]!==W||t[72]!==C||t[73]!==T||t[74]!==k?(J=(0,$.jsxs)(se,{children:[b,(0,$.jsxs)(E,{align:`end`,sideOffset:6,className:`min-w-56`,children:[C,T,k,j,I,L,W,G,ge,_e,ve,q]})]}),t[69]=j,t[70]=I,t[71]=W,t[72]=C,t[73]=T,t[74]=k,t[75]=J):J=t[75];let Y;t[76]===u?Y=t[77]:(Y=(0,$.jsx)(ht,{open:u,onOpenChange:f}),t[76]=u,t[77]=Y);let X;return t[78]!==J||t[79]!==Y?(X=(0,$.jsxs)($.Fragment,{children:[J,Y]}),t[78]=J,t[79]=Y,t[80]=X):X=t[80],X}function vt(){K.clearCache().catch(yt)}function yt(){}function bt(){K.clearCookies().catch(xt)}function xt(){}function St(e){return e.preventDefault()}function Ct(e){return(0,$.jsx)(h,{value:e.value,children:e.label},e.value)}function wt(){}function Tt(){}function Et(e){return v[e]||(e.length>0?e:`Network error`)}function Dt(e){let t=(0,Z.c)(32),{url:n,code:r,description:i,onReload:a}=e,[o,s]=(0,Q.useState)(!1),c;t[0]===n?c=t[1]:(c=At(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=Et(i),t[2]=i,t[3]=u);let d=u,f;t[4]!==r||t[5]!==i?(f=i.length>0?i:`ERR_${Math.abs(r)||`FAILED`}`,t[4]=r,t[5]=i,t[6]=f):f=t[6];let m=f,h,g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(kt,{className:`mb-6 size-12 text-muted-foreground/70`}),g=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=h,t[8]=g):(h=t[7],g=t[8]);let _;t[9]===l?_=t[10]:(_=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=_);let v;t[11]!==d||t[12]!==_?(v=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[_,`: `,d,`.`]}),t[11]=d,t[12]=_,t[13]=v):v=t[13];let y;t[14]===o?y=t[15]:(y=o?(0,$.jsxs)(`div`,{className:`mt-6 rounded-lg border border-border bg-muted/40 p-4 text-sm`,children:[(0,$.jsx)(`p`,{className:`mb-2 font-medium text-foreground`,children:`Try:`}),(0,$.jsxs)(`ul`,{className:`list-disc space-y-1 pl-5 text-muted-foreground`,children:[(0,$.jsx)(`li`,{children:`Checking your connection`}),(0,$.jsx)(`li`,{children:`Confirming the dev server is running`}),(0,$.jsx)(`li`,{children:`Checking the proxy and the firewall`})]})]}):null,t[14]=o,t[15]=y);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>s(Ot),t[18]=x):x=t[18];let S=o?`Hide details`:`Details`,C;t[19]===S?C=t[20]:(C=(0,$.jsx)(p,{type:`button`,variant:`outline`,size:`sm`,onClick:x,children:S}),t[19]=S,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=w):w=t[21];let T;t[22]===a?T=t[23]:(T=(0,$.jsx)(p,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=T);let E;t[24]!==C||t[25]!==T?(E=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[C,w,T]}),t[24]=C,t[25]=T,t[26]=E):E=t[26];let D;return t[27]!==E||t[28]!==v||t[29]!==y||t[30]!==b?(D=(0,$.jsx)(`div`,{className:`relative flex h-full min-h-0 w-full overflow-y-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-1 flex-col px-8 py-12 sm:py-16`,children:[h,g,v,y,b,E]})}),t[27]=E,t[28]=v,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function Ot(e){return!e}function kt(e){let t=(0,Z.c)(5),{className:n}=e,r,i,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(`path`,{d:`M16 12 L48 12 L48 52 L16 52 Z`}),i=(0,$.jsx)(`path`,{d:`M22 22 L42 22 M22 30 L36 30 M22 38 L40 38`,strokeLinecap:`round`}),a=(0,$.jsx)(`path`,{d:`M52 8 L12 56`,strokeLinecap:`round`}),t[0]=r,t[1]=i,t[2]=a):(r=t[0],i=t[1],a=t[2]);let o;return t[3]===n?o=t[4]:(o=(0,$.jsxs)(`svg`,{viewBox:`0 0 64 64`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,className:n,children:[r,i,a]}),t[3]=n,t[4]=o),o}function At(e){try{return new URL(e).host}catch{return null}}function jt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var Mt=120,Nt=220,Pt=4,Ft=90,It=.08,Lt=.5;function Rt(e){let[t,n]=(0,Q.useState)(0),r=(0,Q.useRef)(0);return r.current=t,(0,Q.useEffect)(()=>{if(!e){if(r.current===0)return;n(100);let e=window.setTimeout(()=>n(0),Nt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:Pt);let t=window.setInterval(()=>{let e=r.current;if(e>=Ft)return;let t=Ft-e,i=Math.max(Lt,t*It);n(Math.min(Ft,e+i))},Mt);return()=>window.clearInterval(t)},[e]),t}var zt=class extends j()(`PreviewSessionThreadKeyParseError`,{threadKey:k}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Bt=l(e=>{let t=w(e);if(t===null)throw new zt({threadKey:e});let n=i.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=i.events({environmentId:t.environmentId,input:{}});return F(e=>{let i=!1,a=0,o=e=>{b(e)&&m(t,e.value)},c=r=>{if(!b(r)||r.value.threadId!==t.threadId)return;let i=u(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}s(t,r.value)};e.addFinalizer(()=>{i=!0});let l=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,c(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&c(l))})}).pipe(o(1e3),_(`preview:session-sync:${e}`))});function Vt(e){let t=(0,Z.c)(2),n;t[0]===e?n=t[1]:(n=Bt(f(e)),t[0]=e,t[1]=n),ce(n)}var Ht=1500,Ut=.001;function Wt(e){let t=(0,Z.c)(11),{zoomFactor:n}=e,[r,i]=(0,Q.useState)(!1),o=(0,Q.useRef)(n),s=(0,Q.useRef)(null),c,l;t[0]===n?(c=t[1],l=t[2]):(c=()=>{if(!(Math.abs(o.current-n)<Ut))return o.current=n,i(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{i(!1),s.current=null},Ht),()=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null)}},l=[n],t[0]=n,t[1]=c,t[2]=l),(0,Q.useEffect)(c,l);let u;t[3]===n?u=t[4]:(u=Math.round(n*100),t[3]=n,t[4]=u);let d=`${u}%`,f=!r,p=r?`opacity-100 translate-y-0`:`opacity-0 -translate-y-1`,m;t[5]===p?m=t[6]:(m=a(`pointer-events-none absolute top-3 right-3 z-20 select-none rounded-full border border-border/70 bg-popover/95 px-2.5 py-1 text-xs font-medium text-foreground shadow-md/10 backdrop-blur transition-all duration-200 ease-out`,p),t[5]=p,t[6]=m);let h;return t[7]!==d||t[8]!==f||t[9]!==m?(h=(0,$.jsx)(`div`,{"aria-hidden":f,className:m,children:d}),t[7]=d,t[8]=f,t[9]=m,t[10]=h):h=t[10],h}function Gt(e,t){return e?1:t===`human`?.18:.35}var Kt=700;function qt(e){let t=(0,Z.c)(9),{tabId:n,zoomFactor:r,controller:i}=e,a;t[0]===n?a=t[1]:(a=e=>e.byTabId[n]??null,t[0]=n,t[1]=a);let o=je(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=xe(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Jt,{event:o,content:c,zoomFactor:r,controller:i},o.sequence),t[4]=c,t[5]=i,t[6]=o,t[7]=r,t[8]=l):l=t[8],l}function Jt(e){let t=(0,Z.c)(15),{event:n,content:r,zoomFactor:i,controller:a}=e,[o,s]=(0,Q.useState)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{let e=window.setTimeout(()=>s(!1),Kt);return()=>window.clearTimeout(e)},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Q.useEffect)(c,l);let u;t[2]!==o||t[3]!==a?(u=Gt(o,a),t[2]=o,t[3]=a,t[4]=u):u=t[4];let d=`translate3d(${n.x*i*(r?.scale??1)+(r?.x??0)-(r?.scrollLeft??0)}px, ${n.y*i*(r?.scale??1)+(r?.y??0)-(r?.scrollTop??0)}px, 0)`,f;t[5]!==u||t[6]!==d?(f={opacity:u,transform:d},t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;t[8]!==n.phase||t[9]!==n.sequence?(p=n.phase===`click`?(0,$.jsx)(`span`,{className:`absolute left-0.5 top-0.5 size-4 animate-status-ping rounded-full bg-primary/25 motion-reduce:animate-none`},n.sequence):null,t[8]=n.phase,t[9]=n.sequence,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(X,{className:`relative size-5 -translate-x-0.5 -translate-y-0.5 fill-background text-primary drop-shadow-sm`,strokeWidth:2}),t[11]=m):m=t[11];let h;return t[12]!==f||t[13]!==p?(h=(0,$.jsxs)(`div`,{className:`pointer-events-none absolute left-0 top-0 z-40 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none`,style:f,"aria-hidden":`true`,"data-agent-browser-cursor":!0,children:[p,m]}),t[12]=f,t[13]=p,t[14]=h):h=t[14],h}var Yt=typeof window>`u`?null:g();function Xt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[a,o]=(0,Q.useState)(void 0),[s,l]=(0,Q.useState)(!1),u=Ve(),d=(0,Q.useRef)(!1),p=(0,Q.useRef)(!0),m=te(e),h=ye(t=>ge(t.byThreadKey,e)),g=C(e=>e.addPreviewAnnotation),_=C(e=>e.addImage),v=c(e.environmentId),y=oe(e.environmentId),b=x(i.open),S=x(i.resize,`preview viewport resize`),{resolvedTheme:w}=z();Vt(e),(0,Q.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let T=t??m.activeTabId,E=T?Xe(e,m.serverEpoch,T):null,D=T&&E?u.has(E)?E:Ue(e,T):null,O=T?m.sessions[T]??null:null,k=T?m.desktopByTabId[T]??null:null;(0,Q.useEffect)(()=>{let e=K;if(!(!e||!E||!k?.pictureInPicture))return e.pictureInPicture.setVisible(E,r),()=>{e.pictureInPicture.setVisible(E,!1)}},[k?.pictureInPicture,E,r]);let A=O?.navStatus??{_tag:`Idle`},j=A._tag===`Idle`?``:A.url,N=k?.loading??A._tag===`Loading`,F=k?.canGoBack??O?.canGoBack??!1,R=k?.canGoForward??O?.canGoForward??!1,ae=A._tag===`Idle`,B=A._tag===`LoadFailed`,V=Pe(O),se=k?.controller??`none`,ce=Rt(N),ue=j&&v&&y?rt({url:j,environmentLabel:v.label,environmentHttpBaseUrl:y})??void 0:void 0,H=O?.viewport??M,U=xe(e=>E?e.byTabId[E]?.rect??null:null),W=(0,Q.useCallback)(async t=>{E&&K?(await K.navigate(E,t),ne(e,t)):await fe({openPreview:b,threadRef:e,url:t})},[b,E,e]),G=(0,Q.useCallback)(async e=>{try{await W(pe(e))}catch{}},[W]),me=(0,Q.useCallback)(async t=>{try{await W(Je(e.environmentId,t))}catch{}},[W,e.environmentId]),he=(0,Q.useCallback)(()=>{K&&E&&K.refresh(E)},[E]),_e=(0,Q.useCallback)(()=>{K&&E&&K.zoomIn(E)},[E]),ve=(0,Q.useCallback)(()=>{K&&E&&K.zoomOut(E)},[E]),q=(0,Q.useCallback)(()=>{K&&E&&K.resetZoom(E)},[E]),J=(0,Q.useCallback)(async t=>{if(!T)return;let n=await S({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:T,viewport:t}});if(n._tag===`Failure`){let e=L(n);throw I.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}ee(e,n.value)},[S,T,e]),Y=()=>{if(!E)return;if(H._tag!==`fill`){Ge(E,M).catch(()=>void 0);return}let e=U?We(U,k?.zoomFactor):{width:1024,height:768};Ge(E,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(E)return ze(E,J)},[J,E]);let X=(0,Q.useCallback)(()=>{K&&E&&K.goBack(E)},[E]),be=(0,Q.useCallback)(()=>{K&&E&&K.goForward(E)},[E]),Se=(0,Q.useCallback)(()=>{!Yt||!j||Yt.shell.openExternal(j).catch(()=>void 0)},[j]),Ce=(0,Q.useCallback)(()=>{if(T){if(h?.tabId===T){ye.getState().close(e);return}ye.getState().open(e,T),ie.getState().close(e)}},[h?.tabId,T,e]),we=(0,Q.useCallback)(()=>{!K||!E||(k?.pictureInPicture?K.pictureInPicture.close:K.pictureInPicture.open)(E).catch(e=>{I.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[k?.pictureInPicture,E]),Te=(0,Q.useCallback)(t=>{if(!K||!E||!T)return;let n=K;if(D){De(D).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){I.update(r,P({type:`error`,title:`Unable to copy recording path`,description:`Clipboard API unavailable.`,actionProps:a}));return}navigator.clipboard.writeText(e.path).then(()=>{t=!0,o(),window.setTimeout(()=>{t=!1,o()},2e3)},e=>{I.update(r,P({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:jt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{I.update(r,P({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=I.add(P({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{I.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){Ne(E,e,T).catch(e=>{I.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(E).then(e=>{let t={children:jt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{I.update(a,P({type:e,title:n,description:o,actionProps:{children:i?`Copied!`:`Copy image`,disabled:i,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:r?`Copied!`:`Copy path`,disabled:r,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},s=()=>{if(!navigator.clipboard?.writeText){o(`error`,`Unable to copy screenshot path`,`Clipboard API unavailable.`);return}navigator.clipboard.writeText(e.path).then(()=>{r=!0,o(),window.setTimeout(()=>{r=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot path`,e instanceof Error?e.message:`An error occurred.`)})},c=()=>{n.copyArtifactToClipboard(e.path).then(()=>{i=!0,o(),window.setTimeout(()=>{i=!1,o()},2e3)},e=>{o(`error`,`Unable to copy screenshot`,e instanceof Error?e.message:`An error occurred.`)})};a=I.add(P({type:`success`,title:`Screenshot saved`,actionProps:{children:`Copy image`,onClick:c},data:{additionalActions:[{id:`copy-path`,props:{children:`Copy path`,onClick:s}}],secondaryActionProps:{...t},secondaryActionVariant:`outline`}}))},e=>{I.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[D,E,T,e]),Ee=(0,Q.useCallback)(()=>{if(!K||!E)return;if(d.current){K.cancelPickElement(E).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;d.current=!0,l(!0),(async()=>{try{let t=await K.pickElement(E);if(!t)return;g(e,t);let n=await Ye(t);n&&t.screenshot&&_(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(d.current=!1,p.current&&l(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[_,g,E,e]);return(0,Q.useEffect)(()=>{let e=re(j,w);e&&W(e).catch(()=>void 0)},[W,w,j]),(0,Q.useEffect)(()=>()=>{d.current&&(d.current=!1,K&&E&&K.cancelPickElement(E).catch(()=>void 0),p.current&&l(!1))},[E]),(0,Q.useEffect)(()=>{if(r)return le(e=>{switch(e){case`refresh`:he();return;case`focus-url`:o(e=>(e??0)+1);return;case`zoom-in`:_e();return;case`zoom-out`:ve();return;case`reset-zoom`:q();return;case`toggle-panel`:return}})},[he,q,_e,ve,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":f(e),children:[(0,$.jsx)(tt,{url:j,displayUrl:ue,loading:N,loadProgress:ce,canGoBack:F,canGoForward:R,refreshDisabled:ae,focusUrlNonce:a,onBack:X,onForward:be,onRefresh:he,onSubmit:e=>void G(e),onOpenInBrowser:T?Se:void 0,onCapture:K&&T?Te:void 0,captureDisabled:!k||B,recording:D!==null,onPictureInPicture:K&&T?Ce:void 0,pictureInPicture:h?.tabId===T,pictureInPictureDisabled:!k?.hasWebContents||B,onPickElement:K&&T?Ee:void 0,pickActive:s,pickDisabled:!T||B,pickDisabledReason:B?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:K?(0,$.jsx)(_t,{tabId:E,hasWebContents:k?.hasWebContents??!1,zoomFactor:k?.zoomFactor??1,colorScheme:k?.colorScheme??`system`,deviceToolbarVisible:H._tag!==`fill`,onToggleDeviceToolbar:Y,nativePictureInPicture:k?.pictureInPicture??!1,onNativePictureInPicture:we}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[E&&O&&!V?(0,$.jsx)(de,{tabId:E,visible:r&&!B,className:`absolute inset-0 h-full w-full`},E):null,V?(0,$.jsx)(pt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:m.recentlySeenUrls,onOpenUrl:e=>void me(e)}):null,O&&k?(0,$.jsx)(Wt,{zoomFactor:k.zoomFactor}):null,E&&k&&!V&&!B?(0,$.jsx)(qt,{tabId:E,zoomFactor:k.zoomFactor,controller:se}):null,se===`none`?null:(0,$.jsx)(`div`,{className:`pointer-events-none absolute left-3 top-3 z-40 rounded-full border border-border/70 bg-background/90 px-2.5 py-1 text-[11px] font-medium shadow-sm backdrop-blur`,children:se===`agent`?`Agent controlling browser`:`Human control`}),A._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(Dt,{url:A.url,code:A.code,description:A.description,onReload:he})}):null]})]})}function Zt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!T()){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col items-center justify-center gap-3 p-8 text-center`,children:(0,$.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Preview is only available in the P4 Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(G,{mode:n,children:e}),t[1]=n,t[2]=r),r}let s;t[3]===i?s=t[4]:(s=i===void 0?{}:{tabId:i},t[3]=i,t[4]=s);let c;t[5]!==a||t[6]!==s||t[7]!==r||t[8]!==o?(c=(0,$.jsx)(Xt,{threadRef:r,...s,configuredUrls:a,visible:o}),t[5]=a,t[6]=s,t[7]=r,t[8]=o,t[9]=c):c=t[9];let l;return t[10]!==n||t[11]!==c?(l=(0,$.jsx)(G,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Zt as PreviewPanel};
|
|
2
|
-
//# sourceMappingURL=PreviewPanel-DThvl6zI.js.map
|