@p4code/cli 0.3.7 → 0.3.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.
- package/dist/bin.mjs +13 -1
- package/dist/client/assets/DiffPanel-Dal1Yg3h.js +98 -0
- package/dist/client/assets/{FilePreviewPanel-B6nnYOqU.js → FilePreviewPanel-DO5Cfkhz.js} +2 -2
- package/dist/client/assets/PreviewPanel-CbyU7gX5.js +2 -0
- package/dist/client/assets/{PullRequestCodeTab-V2sIBtyA.js → PullRequestCodeTab-DafrLIyD.js} +2 -2
- package/dist/client/assets/{fileCommentAnnotations-C2CmwvYq.js → fileCommentAnnotations-T5GciR3Y.js} +2 -2
- package/dist/client/assets/{index-B3dXJT1N.js → index-BF-ujeAN.js} +240 -233
- package/dist/client/assets/index-CCG5yNnZ.css +1 -0
- package/dist/client/assets/{previewAssetResource-CH23pI2Y.js → previewAssetResource-C23LvxId.js} +3 -3
- package/dist/client/assets/{renderFileChildren-DZ_Jj00r.js → renderFileChildren-DmrRjyA3.js} +2 -2
- package/dist/client/assets/{toggle-group-DugRuwNC.js → toggle-group-BSctKB7_.js} +2 -2
- package/dist/client/index.html +3 -3
- package/package.json +1 -1
- package/dist/client/assets/DiffPanel-CfBRfslC.js +0 -98
- package/dist/client/assets/PreviewPanel-uOARpCuE.js +0 -2
- package/dist/client/assets/arrow-right-Ckvu2OXE.js +0 -2
- package/dist/client/assets/index-C472PBAT.css +0 -1
|
@@ -1,98 +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{$c as i,Dl as a,Dr as o,Ea as s,Et as c,Fa as l,Ll as ee,Ma as te,Ml as ne,Na as u,Nr as re,Pa as d,Qc as ie,Sr as f,Ta as p,Xc as m,Zc as h,_n as g,gl as _,gt as v,h as y,ht as b,ja as x,ot as S,ou as C,va as w,vt as T,x as ae,xa as E,xl as D,xn as O}from"./previewAssetResource-CH23pI2Y.js";import{t as oe}from"./arrow-right-Ckvu2OXE.js";import{a as k,i as A,n as j,o as M,r as N,s as se,t as ce}from"./toggle-group-DugRuwNC.js";import{F as le,Fr as ue,I as de,J as fe,L as pe,Lr as me,Mr as he,Nr as ge,R as P,Sr as _e,Y as ve,_ as ye,at as be,cr as xe,ct as Se,dr as Ce,fr as we,gr as Te,h as Ee,it as De,jr as Oe,lr as ke,lt as Ae,mr as je,oi as Me,or as Ne,ot as Pe,pr as Fe,rt as Ie,si as Le,sr as Re,st as ze,ur as Be,zr as Ve}from"./index-B3dXJT1N.js";import{a as He,n as Ue}from"./fileCommentAnnotations-C2CmwvYq.js";var We=i(`pilcrow`,[[`path`,{d:`M13 4v16`,key:`8vvj80`}],[`path`,{d:`M17 4v16`,key:`7dpous`}],[`path`,{d:`M19 4H9.5a4.5 4.5 0 0 0 0 9H13`,key:`sh4n9v`}]]),F=e(n(),1);function Ge({threadRef:e,filePath:t,activeCwd:n,openInEditor:r,openFileSurface:i}){if(e){if(i){i(t);return}S.getState().openFile(e,t);return}r(n?y(t,n):t)}var I=r();function Ke(e,t){let n=(0,I.c)(4),r=Te(e,t),i;return n[0]!==r.data||n[1]!==r.error||n[2]!==r.isPending?(i={data:r.data,error:r.error,isPending:r.isPending},n[0]=r.data,n[1]=r.error,n[2]=r.isPending,n[3]=i):i=n[3],i}var L=t(),qe=[];function Je(e){return(e.endSide??e.side)===`deletions`?`deletions`:`additions`}function R(e,t,n){let r=Je(t),i=e.findIndex(e=>e.side===r&&e.lineNumber===t.end);return i<0?[...e,{side:r,lineNumber:t.end,metadata:{entries:[n]}}]:e.map((e,t)=>t===i?{...e,metadata:{entries:[...e.metadata.entries,n]}}:e)}function Ye(e){let t=(0,I.c)(50),{files:n,sectionId:r,sectionTitle:i,composerDraftTarget:a,options:s,viewerRef:c,className:l,renderHeaderPrefix:ee}=e,te=f(Qe),ne=f(B),u;t[0]===a?u=t[1]:(u=e=>e.getComposerDraft(a)?.reviewComments??qe,t[0]=a,t[1]=u);let d=f(u),[ie,p]=(0,F.useState)(null),[m,h]=(0,F.useState)(null),g;t[2]===n?g=t[3]:(g=new Map(n.map(Ze)),t[2]=n,t[3]=g);let _=g,v;if(t[4]!==m||t[5]!==n||t[6]!==d||t[7]!==r){let e;t[9]!==m||t[10]!==d||t[11]!==r?(e=e=>{let{fileDiff:t,filePath:n,fileKey:i,collapsed:a}=e,o=d.filter(e=>e.sectionId===r&&e.filePath===n&&(e.fenceLanguage??`diff`)===`diff`).reduce((e,n)=>{let r=re(t,n);return r?R(e,r,{id:n.id,kind:`comment`,range:r,rangeLabel:n.rangeLabel,text:n.text}):e},[]),s=m?.fileKey===i?[...o,m.annotation]:o;return{id:i,type:`diff`,fileDiff:t,annotations:s,collapsed:a,version:De(`${a?`1`:`0`}:${s.flatMap(z).join(`:`)}`)}},t[9]=m,t[10]=d,t[11]=r,t[12]=e):e=t[12],v=n.map(e),t[4]=m,t[5]=n,t[6]=d,t[7]=r,t[8]=v}else v=t[8];let y=v,b;t[13]!==a||t[14]!==m?.annotation||t[15]!==ne?(b=e=>{p(null),m?.annotation.metadata.entries.some(t=>t.id===e)?h(null):ne(a,e)},t[13]=a,t[14]=m?.annotation,t[15]=ne,t[16]=b):b=t[16];let x=b,S;t[17]!==te||t[18]!==a||t[19]!==m||t[20]!==_||t[21]!==r||t[22]!==i?(S=(e,t)=>{let n=m?.annotation.metadata.entries.find(t=>t.id===e),s=m?_.get(m.fileKey):void 0;if(!n||!s)return;let c=o({id:n.id,sectionId:r,sectionTitle:i,filePath:s.filePath,fileDiff:s.fileDiff,range:n.range,text:t});c&&te(a,c),p(null),h(null)},t[17]=te,t[18]=a,t[19]=m,t[20]=_,t[21]=r,t[22]=i,t[23]=S):S=t[23];let C=S,w;t[24]!==_||t[25]!==r||t[26]!==i?(w=(e,t)=>{if(!e)return;let n=t.item;if(n.type!==`diff`)return;let a=_.get(n.id);if(!a)return;let s=Ue(),c=o({id:s,sectionId:r,sectionTitle:i,filePath:a.filePath,fileDiff:a.fileDiff,range:e,text:``});c&&h({fileKey:n.id,annotation:{side:Je(e),lineNumber:e.end,metadata:{entries:[{id:s,kind:`draft`,range:e,rangeLabel:c.rangeLabel,text:``}]}}})},t[24]=_,t[25]=r,t[26]=i,t[27]=w):w=t[27];let T=w,ae=m!==null,E;t[28]===c?E=t[29]:(E=c?{ref:c}:{},t[28]=c,t[29]=E);let D;t[30]===l?D=t[31]:(D=l?{className:l}:{},t[30]=l,t[31]=D);let O=!ae,oe=!ae,A;t[32]!==T||t[33]!==s||t[34]!==oe||t[35]!==O?(A={...s,enableGutterUtility:O,enableLineSelection:oe,onLineSelectionEnd:T},t[32]=T,t[33]=s,t[34]=oe,t[35]=O,t[36]=A):A=t[36];let j;t[37]===ee?j=t[38]:(j=e=>e.type===`diff`?ee(e.fileDiff,e.id,e.collapsed===!0):null,t[37]=ee,t[38]=j);let M;t[39]!==x||t[40]!==C?(M=e=>(0,L.jsx)(`div`,{className:`py-1`,children:e.metadata.entries.map(e=>(0,L.jsx)(He,{kind:e.kind,rangeLabel:e.rangeLabel,text:e.text,onCancel:()=>x(e.id),onComment:t=>C(e.id,t),onDelete:()=>x(e.id)},e.id))}),t[39]=x,t[40]=C,t[41]=M):M=t[41];let N;return t[42]!==y||t[43]!==ie||t[44]!==A||t[45]!==j||t[46]!==M||t[47]!==E||t[48]!==D?(N=(0,L.jsx)(k,{...E,...D,items:y,selectedLines:ie,onSelectedLinesChange:p,options:A,renderHeaderPrefix:j,renderAnnotation:M}),t[42]=y,t[43]=ie,t[44]=A,t[45]=j,t[46]=M,t[47]=E,t[48]=D,t[49]=N):N=t[49],N}function z(e){return e.metadata.entries.map(Xe)}function Xe(e){return`${e.id}:${e.rangeLabel}:${e.text}`}function Ze(e){return[e.fileKey,e]}function B(e){return e.removeReviewComment}function Qe(e){return e.addReviewComment}function $e(e){return{diffPreview:D(e,{label:`environment-data:review:diff-preview`,tag:C.reviewGetDiffPreview,staleTimeMs:5e3})}}var et=$e(O);function V(e){return e.remoteName&&e.name.startsWith(`${e.remoteName}/`)?e.name.slice(e.remoteName.length+1):e.name}function tt(e,t){let n=new Set(t),r=e.map(e=>{let r=t.filter(t=>n.has(t)&&V(t)===e.name),i=r.find(e=>e.remoteName===`origin`)??r[0]??null;return i&&n.delete(i),{id:`local:${e.name}`,label:e.name,local:e,remote:i}}),i=t.filter(e=>n.has(e)).map(e=>({id:`remote:${e.name}`,label:e.name,local:null,remote:e}));return[...r,...i]}function nt(e,t){let n=t.trim().toLocaleLowerCase();return n.length===0?e:e.filter(e=>e.label.toLocaleLowerCase().includes(n)||e.local?.name.toLocaleLowerCase().includes(n)===!0||e.remote?.name.toLocaleLowerCase().includes(n)===!0)}var H=`__automatic_base_ref__`,rt=new Set,it=`
|
|
2
|
-
[data-diffs-header],
|
|
3
|
-
[data-diff],
|
|
4
|
-
[data-file],
|
|
5
|
-
[data-error-wrapper],
|
|
6
|
-
[data-virtualizer-buffer] {
|
|
7
|
-
--diffs-header-font-family: var(--font-sans) !important;
|
|
8
|
-
--diffs-font-family: var(--font-mono) !important;
|
|
9
|
-
--diffs-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
|
|
10
|
-
--diffs-light-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
|
|
11
|
-
--diffs-dark-bg: color-mix(in srgb, var(--card) 90%, var(--background)) !important;
|
|
12
|
-
--diffs-token-light-bg: transparent;
|
|
13
|
-
--diffs-token-dark-bg: transparent;
|
|
14
|
-
|
|
15
|
-
--diffs-bg-context-override: color-mix(in srgb, var(--background) 97%, var(--foreground));
|
|
16
|
-
--diffs-bg-hover-override: color-mix(in srgb, var(--background) 94%, var(--foreground));
|
|
17
|
-
--diffs-bg-separator-override: color-mix(in srgb, var(--background) 95%, var(--foreground));
|
|
18
|
-
--diffs-bg-buffer-override: color-mix(in srgb, var(--background) 90%, var(--foreground));
|
|
19
|
-
|
|
20
|
-
--diffs-bg-addition-override: color-mix(in srgb, var(--background) 92%, var(--success));
|
|
21
|
-
--diffs-bg-addition-number-override: color-mix(in srgb, var(--background) 88%, var(--success));
|
|
22
|
-
--diffs-bg-addition-hover-override: color-mix(in srgb, var(--background) 85%, var(--success));
|
|
23
|
-
--diffs-bg-addition-emphasis-override: color-mix(in srgb, var(--background) 80%, var(--success));
|
|
24
|
-
|
|
25
|
-
--diffs-bg-deletion-override: color-mix(in srgb, var(--background) 92%, var(--destructive));
|
|
26
|
-
--diffs-bg-deletion-number-override: color-mix(in srgb, var(--background) 88%, var(--destructive));
|
|
27
|
-
--diffs-bg-deletion-hover-override: color-mix(in srgb, var(--background) 85%, var(--destructive));
|
|
28
|
-
--diffs-bg-deletion-emphasis-override: color-mix(
|
|
29
|
-
in srgb,
|
|
30
|
-
var(--background) 80%,
|
|
31
|
-
var(--destructive)
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
background-color: var(--diffs-bg) !important;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
[data-file-info] {
|
|
38
|
-
background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
|
|
39
|
-
border-block-color: var(--border) !important;
|
|
40
|
-
color: var(--foreground) !important;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
[data-diffs-header] {
|
|
44
|
-
position: sticky !important;
|
|
45
|
-
top: 0;
|
|
46
|
-
z-index: 4;
|
|
47
|
-
background-color: color-mix(in srgb, var(--card) 94%, var(--foreground)) !important;
|
|
48
|
-
border-bottom: 1px solid var(--border) !important;
|
|
49
|
-
align-items: center !important;
|
|
50
|
-
font-family: var(--font-sans) !important;
|
|
51
|
-
font-size: 12px !important;
|
|
52
|
-
line-height: 1 !important;
|
|
53
|
-
min-height: 32px !important;
|
|
54
|
-
padding-block: 6px !important;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
[data-diffs-header] [data-header-content] {
|
|
58
|
-
align-items: center !important;
|
|
59
|
-
line-height: 1 !important;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
[data-diffs-header] [data-metadata] {
|
|
63
|
-
align-items: center !important;
|
|
64
|
-
line-height: 1 !important;
|
|
65
|
-
font-variant-numeric: tabular-nums;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
[data-diffs-header] [data-additions-count],
|
|
69
|
-
[data-diffs-header] [data-deletions-count] {
|
|
70
|
-
font-family: var(--font-mono) !important;
|
|
71
|
-
font-size: 11px !important;
|
|
72
|
-
font-variant-numeric: tabular-nums;
|
|
73
|
-
line-height: 1 !important;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
[data-diffs-header] [data-change-icon],
|
|
77
|
-
[data-diffs-header] [data-rename-icon] {
|
|
78
|
-
display: block;
|
|
79
|
-
flex-shrink: 0;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[data-title] {
|
|
83
|
-
cursor: pointer;
|
|
84
|
-
transition:
|
|
85
|
-
color 120ms ease,
|
|
86
|
-
text-decoration-color 120ms ease;
|
|
87
|
-
text-decoration: underline;
|
|
88
|
-
text-decoration-color: transparent;
|
|
89
|
-
text-underline-offset: 2px;
|
|
90
|
-
font-family: var(--font-sans) !important;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
[data-title]:hover {
|
|
94
|
-
color: color-mix(in srgb, var(--foreground) 84%, var(--primary)) !important;
|
|
95
|
-
text-decoration-color: currentColor;
|
|
96
|
-
}
|
|
97
|
-
`;function U({mode:e=`inline`,composerDraftTarget:t,initialGitScope:n,threadRef:r}){let{resolvedTheme:i}=ae(),o=ue(),[re]=(0,F.useState)(n),[f,y]=(0,F.useState)(`stacked`),[S,C]=(0,F.useState)(o.wordWrap),[D,O]=(0,F.useState)(o.diffIgnoreWhitespace),[k,ye]=(0,F.useState)(``),[Te,De]=(0,F.useState)(()=>({scopeKey:null,fileKeys:rt})),He=(0,F.useRef)(null),Ue=r.threadId,I=ge(r),qe=I?.projectId??null,Je=he(I&&qe?{environmentId:I.environmentId,projectId:qe}:null),R=I?.worktreePath??Je?.workspaceRoot,z=_(g.configValueAtom(I?.environmentId??null)),Xe=je(I?.environmentId??null,z?.availableEditors??[]),Ze=c(I!=null&&R!=null?Oe.status({environmentId:I.environmentId,input:{cwd:R}}):null),B=P(e=>pe(e.byThreadKey,r,re===`unstaged`)),Qe=Ze.data?.isRepo??!0,{turnDiffSummaries:$e,inferredCheckpointTurnCountByTurnId:V}=de(I),U=(0,F.useMemo)(()=>[...$e].toSorted((e,t)=>{let n=e.checkpointTurnCount??V[e.turnId]??0,r=t.checkpointTurnCount??V[t.turnId]??0;return n===r?t.completedAt.localeCompare(e.completedAt):r-n}),[V,$e]);(0,F.useEffect)(()=>{B.kind===`turn`&&P.getState().reconcileTurnSelection(r,U.map(e=>e.turnId))},[B,U,r]);let W=B.kind===`turn`?B.turnId:null,G=B.kind===`unstaged`?`unstaged`:`branch`,K=B.kind===`branch`?B.baseRef:null,at=B.kind===`turn`?B.filePath:null,ot=B.kind===`turn`?B.revealRequestId:0,q=W===null?void 0:U.find(e=>e.turnId===W)??U[0],J=q&&(q.checkpointTurnCount??V[q.turnId]),st=U[0],ct=W===null?G===`unstaged`?`Working tree`:`Branch changes`:q?.turnId===st?.turnId?`Latest turn`:`Turn ${J??`?`}`,lt=q?`turn:${q.turnId}`:G,Y=`${r.environmentId}:${r.threadId}:${lt}`,ut=Te.scopeKey===Y?Te.fileKeys:rt,dt=q?`Turn ${J??`?`}`:G===`unstaged`?`Working tree`:`Branch changes`,ft=(0,F.useMemo)(()=>typeof J==`number`?{fromTurnCount:Math.max(0,J-1),toTurnCount:J}:null,[J]),pt=Ke({environmentId:I?.environmentId??null,threadId:Ue,fromTurnCount:ft?.fromTurnCount??null,toTurnCount:ft?.toTurnCount??null,ignoreWhitespace:D,cacheScope:q?`turn:${q.turnId}`:null},{enabled:Qe&&q!==void 0}),mt=c(W===null&&I&&R?et.diffPreview({environmentId:I.environmentId,input:{cwd:R,...K?{baseRef:K}:{},ignoreWhitespace:D}}):null),ht=W===null&&mt.error?.includes(`configured workspace root`)===!0&&z?.cwd!==void 0&&z.cwd!==R,gt=c(ht&&I&&z?et.diffPreview({environmentId:I.environmentId,input:{cwd:z.cwd,...K?{baseRef:K}:{},ignoreWhitespace:D}}):null),X=ht?gt:mt,Z=X.data?.sources.find(e=>e.kind===(G===`unstaged`?`working-tree`:`branch-range`)),_t=c(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`local`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),vt=c(W===null&&G===`branch`&&I&&X.data?.cwd?Oe.listRefs({environmentId:I.environmentId,input:{cwd:X.data.cwd,includeMatchingRemoteRefs:!0,refKind:`remote`,...k.trim().length>0?{query:k.trim()}:{},limit:100}}):null),yt=tt(_t.data?.refs.filter(e=>e.name!==Z?.headRef)??[],vt.data?.refs??[]),bt=nt(yt,k),xt=e=>K&&K===e.remote?.name?K:e.local?.name??e.remote?.name??e.id,St=[H,...yt.map(xt)],Ct=[...k.trim().length===0?[H]:[],...bt.map(xt)],wt=Z?.diff,Tt=q?pt.data?.diff:wt,Et=!q&&Z?.truncated===!0,Dt=q?pt.isPending:X.isPending,Ot=q?pt.error:X.error,kt=typeof Tt==`string`&&Tt.trim().length===0,Q=(0,F.useMemo)(()=>ze(Tt,`diff-panel:${i}`,{compactPartialHunkOffsets:W===null}),[i,Tt,W]),At=(0,F.useMemo)(()=>!Q||Q.kind!==`files`?[]:Q.files.toSorted((e,t)=>Ae(e).localeCompare(Ae(t),void 0,{numeric:!0,sensitivity:`base`})),[Q]),$=(0,F.useMemo)(()=>At.map(e=>{let t=Ie(e);return{fileDiff:e,filePath:Ae(e),fileKey:t,collapsed:ut.has(t)}}),[ut,At]),jt=(0,F.useMemo)(()=>$.map(e=>e.fileKey),[$]),Mt=N(jt,ut),Nt=(0,F.useMemo)(()=>Pe(At),[At]);(0,F.useEffect)(()=>{if(!at)return;let e=$.find(e=>e.filePath===at);e&&He.current?.scrollTo({type:`item`,id:e.fileKey,align:`start`})},[$,at,ot]);let Pt=le({threadRef:r,workspaceRoot:R??null}),Ft=(0,F.useCallback)(e=>{Ge({threadRef:r,filePath:e,activeCwd:R,openFileSurface:Pt,openInEditor:e=>{(async()=>{let t=await Xe(e);t._tag===`Failure`&&!a(t)&&console.warn(`Failed to open diff file in editor.`,{operation:`open-diff-file`,environmentId:r.environmentId,threadId:r.threadId,...ee(ne(t))})})()}})},[R,Pt,Xe,r]),It=(0,F.useCallback)(e=>{De(t=>{let n=new Set(t.scopeKey===Y?t.fileKeys:[]);return n.has(e)?n.delete(e):n.add(e),{scopeKey:Y,fileKeys:n}})},[Y]),Lt=(0,F.useCallback)(()=>{De(e=>{let t=e.scopeKey===Y?e.fileKeys:rt;return{scopeKey:Y,fileKeys:A(jt,t)}})},[Y,jt]),Rt=e=>{P.getState().selectTurn(r,e)},zt=e=>{P.getState().selectGitScope(r,e)},Bt=e=>{P.getState().selectBranchBaseRef(r,e)};return(0,L.jsx)(ve,{mode:e,header:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3 [-webkit-app-region:no-drag]`,children:[(0,L.jsxs)(E,{children:[(0,L.jsxs)(d,{className:`inline-flex h-6 max-w-full items-center gap-1 rounded-md bg-muted/70 px-2 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Diff scope: ${ct}`,children:[(0,L.jsx)(`span`,{className:`truncate`,children:ct}),(0,L.jsx)(h,{className:`size-3.5 shrink-0 text-muted-foreground`})]}),(0,L.jsxs)(s,{align:`start`,className:`w-60`,children:[(0,L.jsx)(p,{className:W===null&&G===`unstaged`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`unstaged`),children:(0,L.jsx)(`span`,{children:`Working tree`})}),(0,L.jsx)(p,{className:W===null&&G===`branch`?`bg-foreground/[0.08]`:void 0,onClick:()=>zt(`branch`),children:(0,L.jsx)(`span`,{children:`Branch changes`})}),(0,L.jsx)(p,{className:W!==null&&q?.turnId===st?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>{st&&Rt(st.turnId)},children:(0,L.jsx)(`span`,{children:`Latest turn`})}),(0,L.jsxs)(x,{children:[(0,L.jsx)(u,{children:`Turn`}),(0,L.jsx)(te,{className:`w-64`,children:U.map(e=>{let t=e.checkpointTurnCount??V[e.turnId]??`?`;return(0,L.jsxs)(p,{className:e.turnId===q?.turnId?`bg-foreground/[0.08]`:void 0,onClick:()=>Rt(e.turnId),children:[(0,L.jsxs)(`span`,{children:[`Turn `,t]}),(0,L.jsx)(`span`,{className:`ml-auto text-xs tabular-nums text-muted-foreground`,children:_e(e.completedAt,o.timestampFormat)})]},e.turnId)})})]})]})]}),W===null&&G===`branch`&&Z?.baseRef&&(0,L.jsxs)(`div`,{className:`flex min-w-0 max-w-full items-center gap-2 overflow-hidden text-xs text-muted-foreground`,title:`${Z.headRef??`HEAD`} → ${Z.baseRef}`,"aria-label":`Comparing ${Z.headRef??`HEAD`} against ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 max-w-48 truncate`,children:Z.headRef??`HEAD`}),(0,L.jsx)(oe,{className:`size-3.5 shrink-0 opacity-70`}),(0,L.jsxs)(Re,{items:St,filteredItems:Ct,value:K??H,onOpenChange:e=>{e||ye(``)},onValueChange:e=>{e&&Bt(e===H?null:e)},children:[(0,L.jsxs)(Fe,{className:`inline-flex min-w-0 max-w-48 items-center gap-1 overflow-hidden rounded-md px-1.5 py-1 outline-none transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,"aria-label":`Change comparison target. Currently ${Z.baseRef}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:Z.baseRef}),(0,L.jsx)(h,{className:`size-3.5 shrink-0 opacity-70`})]}),(0,L.jsxs)(we,{align:`start`,className:`w-72 min-w-0 max-w-[calc(100vw-1rem)] overflow-hidden [&>[data-slot=combobox-popup]]:min-w-0 [&>[data-slot=combobox-popup]]:overflow-hidden`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink-0 px-3 pt-2.5`,children:(0,L.jsxs)(`div`,{className:`relative -translate-y-px border-b border-border/70 pb-1.5 transition-colors focus-within:border-ring`,children:[(0,L.jsx)(Ve,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1.5 left-0 size-4 shrink-0 text-muted-foreground/55`}),(0,L.jsx)(ke,{className:`[&_input]:h-6.5 [&_input]:ps-5 [&_input]:font-sans [&_input]:leading-6.5`,inputClassName:`rounded-none bg-transparent text-sm`,placeholder:`Search refs...`,showTrigger:!1,size:`sm`,unstyled:!0,value:k,onChange:e=>ye(e.target.value)})]})}),(0,L.jsxs)(`div`,{className:`grid shrink-0 grid-cols-[1rem_minmax(0,1fr)] items-center gap-2 border-b border-border/70 ps-3 pe-6.5 pt-2 pb-1.5 font-medium text-[10px] text-muted-foreground uppercase tracking-wide`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`}),(0,L.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center`,children:[(0,L.jsx)(`span`,{children:`Branch`}),(0,L.jsx)(`span`,{className:`text-right`,children:`Remote`})]})]}),(0,L.jsx)(xe,{children:`No matching refs.`}),(0,L.jsxs)(Ce,{className:`max-h-64 min-w-0 overflow-x-hidden`,children:[(0,L.jsx)(Be,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:H,children:(0,L.jsx)(`span`,{className:`block min-w-0 truncate`,children:`Automatic`})}),yt.map(e=>{let t=xt(e),n=e.local!==null&&e.remote!==null,r=e.remote?.name===t;return(0,L.jsx)(Be,{className:`h-8 w-full min-w-0 grid-cols-[1rem_minmax(0,1fr)] py-0`,contentClassName:`w-full min-w-0 overflow-hidden`,value:t,children:(0,L.jsxs)(`div`,{className:`grid w-full min-w-0 grid-cols-[minmax(0,1fr)_2rem] items-center overflow-hidden`,children:[(0,L.jsx)(`span`,{className:`block min-w-0 truncate pe-2`,children:e.label}),n?(0,L.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:(0,L.jsx)(Ne,{"aria-label":`Use remote version of ${e.label}`,checked:r,className:`[--thumb-size:--spacing(3)]`,onCheckedChange:t=>{let n=t?e.remote?.name:e.local?.name;n&&Bt(n)}})}):e.remote?(0,L.jsx)(`span`,{className:`flex justify-end text-muted-foreground`,title:`Remote only`,children:(0,L.jsx)(ie,{"aria-hidden":`true`,className:`size-3`})}):null]})},e.id)})]})]})]})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]`,children:[$.length>0&&(0,L.jsx)(Ee,{additions:Nt.additions,deletions:Nt.deletions,className:`mr-1 text-[11px]`,layout:`inline`}),$.length>0&&(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(w,{type:`button`,size:`icon-xs`,variant:`outline`,"aria-label":Mt?`Expand all files`:`Collapse all files`,onClick:Lt}),children:Mt?(0,L.jsx)(Me,{className:`size-3`}):(0,L.jsx)(Le,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:Mt?`Expand all files`:`Collapse all files`})]}),(0,L.jsxs)(j,{className:`shrink-0`,variant:`outline`,size:`xs`,value:[f],onValueChange:e=>{let t=e[0];(t===`stacked`||t===`split`)&&y(t)},children:[(0,L.jsx)(ce,{"aria-label":`Stacked diff view`,value:`stacked`,children:(0,L.jsx)(M,{className:`size-3`})}),(0,L.jsx)(ce,{"aria-label":`Split diff view`,value:`split`,children:(0,L.jsx)(se,{className:`size-3`})})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(ce,{"aria-label":S?`Disable diff line wrapping`:`Enable diff line wrapping`,variant:`outline`,size:`xs`,pressed:S,onPressedChange:e=>{C(!!e)}}),children:(0,L.jsx)(me,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:S?`Disable line wrapping`:`Enable line wrapping`})]}),(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(ce,{"aria-label":D?`Show whitespace changes`:`Hide whitespace changes`,variant:`outline`,size:`xs`,pressed:D,onPressedChange:e=>{O(!!e)}}),children:(0,L.jsx)(We,{className:`size-3`})}),(0,L.jsx)(v,{side:`top`,children:D?`Show whitespace changes`:`Hide whitespace changes`})]})]})]}),children:I?Qe?W!==null&&U.length===0?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`No completed turns yet.`}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`diff-panel-viewport flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[Et&&(0,L.jsx)(`p`,{className:`shrink-0 border-b border-border/70 bg-muted/40 px-3 py-1.5 text-[11px] text-muted-foreground`,children:`This diff was truncated because it exceeded the preview limit. The changes shown are incomplete.`}),Ot&&!Q&&(0,L.jsx)(`div`,{className:`px-3`,children:(0,L.jsx)(`p`,{className:`mb-2 text-[11px] text-red-500/80`,children:Ot})}),Q?Q.kind===`files`?(0,L.jsx)(`div`,{className:`min-h-0 flex-1`,onClickCapture:e=>{let t=(e.nativeEvent.composedPath?.()??[]).find(e=>e instanceof HTMLElement&&e.hasAttribute(`data-title`))?.textContent?.trim();t&&Ft(t)},children:(0,L.jsx)(Ye,{viewerRef:He,className:`diff-render-surface h-full min-h-0 overflow-auto`,files:$,sectionId:lt,sectionTitle:dt,composerDraftTarget:t,renderHeaderPrefix:(e,t,n)=>{let r=Ae(e);return(0,L.jsxs)(b,{children:[(0,L.jsx)(T,{render:(0,L.jsx)(`button`,{type:`button`,className:l(`inline-flex size-5 shrink-0 cursor-pointer items-center justify-center rounded-sm border-0 bg-transparent p-0 transition-colors hover:bg-foreground/10 focus-visible:outline-hidden`,be(e)),"aria-label":n?`Expand ${r}`:`Collapse ${r}`,"aria-expanded":!n,onClick:e=>{e.stopPropagation(),It(t)}}),children:n?(0,L.jsx)(m,{className:`size-4`}):(0,L.jsx)(h,{className:`size-4`})}),(0,L.jsx)(v,{side:`top`,children:n?`Expand diff`:`Collapse diff`})]})},options:{diffStyle:f===`split`?`split`:`unified`,lineDiffType:`none`,overflow:S?`wrap`:`scroll`,theme:Se(i),themeType:i,unsafeCSS:it,stickyHeaders:!0,itemMetrics:{diffHeaderHeight:33},layout:{paddingTop:0,paddingBottom:8,gap:8}}},Y??lt)}):(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-2`,children:(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] text-muted-foreground/75`,children:Q.reason}),(0,L.jsx)(`pre`,{className:l(`max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90`,S?`overflow-auto whitespace-pre-wrap wrap-break-word`:`overflow-auto`),children:Q.text})]})}):Dt?(0,L.jsx)(fe,{label:q?`Loading checkpoint diff...`:G===`unstaged`?`Loading working tree diff...`:`Loading branch diff...`}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-3 py-2 text-xs text-muted-foreground/70`,children:(0,L.jsx)(`p`,{children:kt?`No net changes in this selection.`:`No patch available for this selection.`})})]})}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Turn diffs are unavailable because this project is not a git repository.`}):(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center px-5 text-center text-xs text-muted-foreground/70`,children:`Select a thread to inspect turn diffs.`})})}export{ye as DiffWorkerPoolProvider,U as default};
|
|
98
|
-
//# sourceMappingURL=DiffPanel-CfBRfslC.js.map
|
|
@@ -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,$c as a,Af as o,Da as s,Ea as c,Fa as l,G as u,J as d,K as f,Kl as p,Ma as m,Mf as h,Ml as g,Na as _,Oa as v,Pa as y,Q as b,Ql as x,Sr as S,Ta as C,Ul as w,V as T,Vl as E,Wl as D,Wu as O,X as k,au as A,bt as j,dt as M,ft as N,gl as P,gt as F,ht as I,ja as ee,ka as L,kt as te,ot as ne,q as R,r as re,st as z,tu as B,va as V,vt as H,x as U,xa as ie,xt as ae,yt as W}from"./previewAssetResource-CH23pI2Y.js";import{t as oe}from"./arrow-right-Ckvu2OXE.js";import{$n as G,$r as K,A as q,Br as J,Dr as Y,Er as se,Jn as ce,Kr as le,M as ue,N as de,O as fe,Or as pe,P as me,Qn as he,Tr as ge,Ur as _e,Vr as ve,Wr as ye,Xn as be,Yn as xe,Zn as Se,a as Ce,c as we,ci as Te,er as Ee,g as De,i as Oe,j as ke,k as X,n as Ae,ni as je,o as Me,qr as Ne,r as Pe,s as Fe,t as Ie,tr as Le,wr as Re,z as ze}from"./index-B3dXJT1N.js";var Be=a(`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`}]]),Ve=a(`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`}]]),He=a(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),Ue=a(`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(),We=()=>{};function Ge(e){let t=(0,Z.c)(98),{url:n,displayUrl:r,loading:i,loadProgress:a,canGoBack:o,canGoForward:s,refreshDisabled:c,inputDisabled:u,focusUrlNonce:d,onBack:f,onForward:p,onRefresh:m,onSubmit:h,onOpenInBrowser:g,onCapture:_,captureDisabled:v,recording:y,onPictureInPicture:b,pictureInPicture:x,pictureInPictureDisabled:S,onPickElement:C,pickActive:w,pickDisabled:T,pickDisabledReason:E,trailingActions:D}=e,O=(0,Q.useRef)(null),[k,A]=(0,Q.useState)(n),[j,M]=(0,Q.useState)(!1),N,P;t[0]===d?(N=t[1],P=t[2]):(N=()=>{if(d==null)return;let e=O.current;e&&e.focus()},P=[d],t[0]=d,t[1]=N,t[2]=P),(0,Q.useEffect)(N,P);let ee;t[3]!==k||t[4]!==h?(ee=e=>{e?.preventDefault();let t=k.trim();t.length!==0&&(h(t),O.current?.blur())},t[3]=k,t[4]=h,t[5]=ee):ee=t[5];let L=ee,te=o?f:We,ne=!o,R;t[6]!==te||t[7]!==ne?(R=(0,$.jsx)(V,{variant:`ghost`,size:`icon-xs`,onClick:te,disabled:ne,"aria-label":`Back`,type:`button`}),t[6]=te,t[7]=ne,t[8]=R):R=t[8];let re;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Te,{}),t[9]=re):re=t[9];let z;t[10]===R?z=t[11]:(z=(0,$.jsx)(H,{render:R,children:re}),t[10]=R,t[11]=z);let B;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(F,{children:`Back`}),t[12]=B):B=t[12];let U;t[13]===z?U=t[14]:(U=(0,$.jsxs)(I,{children:[z,B]}),t[13]=z,t[14]=U);let ie=s?p:We,ae=!s,W;t[15]!==ie||t[16]!==ae?(W=(0,$.jsx)(V,{variant:`ghost`,size:`icon-xs`,onClick:ie,disabled:ae,"aria-label":`Forward`,type:`button`}),t[15]=ie,t[16]=ae,t[17]=W):W=t[17];let G;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(oe,{}),t[18]=G):G=t[18];let K;t[19]===W?K=t[20]:(K=(0,$.jsx)(H,{render:W,children:G}),t[19]=W,t[20]=K);let q;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(F,{children:`Forward`}),t[21]=q):q=t[21];let Y;t[22]===K?Y=t[23]:(Y=(0,$.jsxs)(I,{children:[K,q]}),t[22]=K,t[23]=Y);let se=c?We:m,ue=i?`Stop`:`Refresh`,de;t[24]!==c||t[25]!==se||t[26]!==ue?(de=(0,$.jsx)(V,{variant:`ghost`,size:`icon-xs`,onClick:se,disabled:c,"aria-label":ue,type:`button`}),t[24]=c,t[25]=se,t[26]=ue,t[27]=de):de=t[27];let fe=i&&`animate-spin`,pe;t[28]===fe?pe=t[29]:(pe=l(fe),t[28]=fe,t[29]=pe);let me;t[30]===pe?me=t[31]:(me=(0,$.jsx)(J,{className:pe}),t[30]=pe,t[31]=me);let he;t[32]!==de||t[33]!==me?(he=(0,$.jsx)(H,{render:de,children:me}),t[32]=de,t[33]=me,t[34]=he):he=t[34];let ge=i?`Loading…`:`Refresh`,_e;t[35]===ge?_e=t[36]:(_e=(0,$.jsx)(F,{children:ge}),t[35]=ge,t[36]=_e);let ve;t[37]!==he||t[38]!==_e?(ve=(0,$.jsxs)(I,{children:[he,_e]}),t[37]=he,t[38]=_e,t[39]=ve):ve=t[39];let Se;t[40]!==U||t[41]!==Y||t[42]!==ve?(Se=(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5`,role:`group`,"aria-label":`Navigation`,children:[U,Y,ve]}),t[40]=U,t[41]=Y,t[42]=ve,t[43]=Se):Se=t[43];let Ce=j?k:r??n,we=g&&!j&&`group-hover/address:pe-7 transition-[padding]`,Ee;t[44]===we?Ee=t[45]:(Ee=l(we),t[44]=we,t[45]=Ee);let De;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(De=e=>A(e.target.value),t[46]=De):De=t[46];let Oe;t[47]===n?Oe=t[48]:(Oe=()=>{A(n),M(!0),queueMicrotask(()=>O.current?.select())},t[47]=n,t[48]=Oe);let ke;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(ke=()=>{M(!1)},t[49]=ke):ke=t[49];let X;t[50]!==L||t[51]!==n?(X=e=>{e.key===`Enter`&&L(e),e.key===`Escape`&&(e.preventDefault(),A(n),O.current?.blur())},t[50]=L,t[51]=n,t[52]=X):X=t[52];let Ae;t[53]!==u||t[54]!==Ce||t[55]!==Ee||t[56]!==Oe||t[57]!==X?(Ae=(0,$.jsx)(H,{render:(0,$.jsx)(be,{ref:O,value:Ce,className:Ee,onChange:De,onFocus:Oe,onBlur:ke,onKeyDown:X,placeholder:`Search or enter URL`,spellCheck:!1,disabled:u,"data-preview-url-input":!0,size:`sm`})}),t[53]=u,t[54]=Ce,t[55]=Ee,t[56]=Oe,t[57]=X,t[58]=Ae):Ae=t[58];let Me;t[59]!==r||t[60]!==j||t[61]!==n?(Me=!j&&r?(0,$.jsx)(F,{children:n}):null,t[59]=r,t[60]=j,t[61]=n,t[62]=Me):Me=t[62];let Ne;t[63]!==Ae||t[64]!==Me?(Ne=(0,$.jsxs)(I,{children:[Ae,Me]}),t[63]=Ae,t[64]=Me,t[65]=Ne):Ne=t[65];let Pe;t[66]!==j||t[67]!==g?(Pe=g&&!j?(0,$.jsx)(xe,{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)(I,{children:[(0,$.jsx)(H,{render:(0,$.jsx)(V,{variant:`ghost`,size:`icon-xs`,onClick:g,"aria-label":`Open in system browser`,type:`button`}),children:(0,$.jsx)(je,{})}),(0,$.jsx)(F,{children:`Open in system browser`})]})}):null,t[66]=j,t[67]=g,t[68]=Pe):Pe=t[68];let Fe;t[69]!==Ne||t[70]!==Pe?(Fe=(0,$.jsxs)(ce,{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:[Ne,Pe]}),t[69]=Ne,t[70]=Pe,t[71]=Fe):Fe=t[71];let Ie;t[72]!==C||t[73]!==w||t[74]!==T||t[75]!==E?(Ie=C?(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{render:(0,$.jsx)(V,{variant:w?`secondary`:`ghost`,size:`icon-xs`,onClick:C,disabled:T,"aria-label":w?`Cancel annotation`:`Annotate preview`,"aria-pressed":w?`true`:`false`,type:`button`}),children:(0,$.jsx)(le,{className:l(w&&`text-primary`)})}),(0,$.jsx)(F,{children:T&&E?E:w?`Cancel annotation (Esc)`:`Annotate elements, regions, and drawings`})]}):null,t[72]=C,t[73]=w,t[74]=T,t[75]=E,t[76]=Ie):Ie=t[76];let Le;t[77]!==v||t[78]!==_||t[79]!==y?(Le=_?(0,$.jsxs)(I,{children:[(0,$.jsxs)(H,{render:(0,$.jsx)(V,{variant:y?`secondary`:`ghost`,size:`icon-xs`,onClick:e=>_(e.shiftKey),"aria-label":y?`Stop recording`:`Capture screenshot`,type:`button`,className:`relative`,disabled:v}),children:[(0,$.jsx)(Be,{className:l(y&&`text-destructive`)}),y?(0,$.jsx)(`span`,{className:`absolute right-0.5 top-0.5 size-1.5 animate-status-pulse rounded-full bg-destructive`}):null]}),(0,$.jsx)(F,{children:y?`Stop recording`:`Screenshot · Shift-click to record`})]}):null,t[77]=v,t[78]=_,t[79]=y,t[80]=Le):Le=t[80];let Re;t[81]!==b||t[82]!==x||t[83]!==S?(Re=b?(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{render:(0,$.jsx)(V,{variant:x?`secondary`:`ghost`,size:`icon-xs`,onClick:b,"aria-label":x?`Close floating preview`:`Float preview over chat`,"aria-pressed":x?`true`:`false`,type:`button`,disabled:S}),children:(0,$.jsx)(ye,{className:l(x&&`text-primary`)})}),(0,$.jsx)(F,{children:x?`Close floating preview`:`Float preview over chat`})]}):null,t[81]=b,t[82]=x,t[83]=S,t[84]=Re):Re=t[84];let ze;t[85]!==L||t[86]!==Se||t[87]!==Fe||t[88]!==Ie||t[89]!==Le||t[90]!==Re||t[91]!==D?(ze=(0,$.jsxs)(`form`,{onSubmit:L,className:`surface-subheader gap-1 px-2`,"data-surface-subheader":!0,children:[Se,Fe,Ie,Le,Re,D]}),t[85]=L,t[86]=Se,t[87]=Fe,t[88]=Ie,t[89]=Le,t[90]=Re,t[91]=D,t[92]=ze):ze=t[92];let Ve;t[93]===a?Ve=t[94]:(Ve=a>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:`${a}%`,boxShadow:`0 0 6px 1px var(--color-ring)`}}):null,t[93]=a,t[94]=Ve);let He;return t[95]!==ze||t[96]!==Ve?(He=(0,$.jsxs)(`div`,{className:`relative`,children:[ze,Ve]}),t[95]=ze,t[96]=Ve,t[97]=He):He=t[97],He}function Ke(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 qe(e){let t=(0,Z.c)(6),{className:n}=e,r;t[0]===n?r=t[1]:(r=l(`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 a;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(a=(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]=a):a=t[3];let o;return t[4]===r?o=t[5]:(o=(0,$.jsxs)(`div`,{"aria-hidden":!0,className:r,children:[i,a]}),t[4]=r,t[5]=o),o}function Je(e){let t=(0,Z.c)(17),{server:n,onOpen:r}=e,i;t[0]===n?i=t[1]:(i=Ye(n),t[0]=n,t[1]=i);let a=i,o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,$.jsx)(qe,{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)(Xe,{}):(0,$.jsx)(Ze,{}),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 Ye(e){return e.processName?e.processName:e.listening?`Listening`:e.source===`configured`?`Configured`:`Recently seen`}function Xe(){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 Ze(){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 Qe(e){let t=(0,Z.c)(7),n=pe(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:ge(e.environmentId,t.url)}),t[5]=e.environmentId,t[6]=i),r=$e({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 $e(e){let t=new Map;for(let n of e.configuredUrls){let e=tt(n);if(!e)continue;let r=et(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=et(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=tt(n);if(!e)continue;let r=et(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 et(e,t){return`${e.toLowerCase()}:${t}`}function tt(e){try{let t=new URL(e);if(t.protocol!==`http:`&&t.protocol!==`https:`||!se(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 nt(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=Qe(o);if(s.length===0){let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsxs)(Se,{children:[(0,$.jsx)(G,{variant:`icon`,children:(0,$.jsx)(K,{className:`size-4.5 text-muted-foreground`})}),(0,$.jsx)(Ee,{children:`No preview yet`}),(0,$.jsx)(he,{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)(Ue,{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)(Je,{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 rt=[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}];function it(e){let t=(0,Z.c)(74),{tabId:n,hasWebContents:r,zoomFactor:i,colorScheme:a,deviceToolbarVisible:o,onToggleDeviceToolbar:l,nativePictureInPicture:u,onNativePictureInPicture:d}=e;if(!X)return null;let f=!n||!r,p;t[0]===n?p=t[1]:(p=e=>()=>{n&&e(n).catch(ft)},t[0]=n,t[1]=p);let h=p,g;t[2]===i?g=t[3]:(g=Math.round(i*100),t[2]=i,t[3]=g);let v=`${g}%`,b;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsxs)(I,{children:[(0,$.jsx)(H,{render:(0,$.jsx)(y,{render:(0,$.jsx)(V,{variant:`ghost`,size:`icon-xs`,type:`button`,"aria-label":`Preview menu`})}),children:(0,$.jsx)(Ve,{})}),(0,$.jsx)(F,{children:`More`})]}),t[4]=b):b=t[4];let x;t[5]===h?x=t[6]:(x=h(X.hardReload),t[5]=h,t[6]=x);let S;t[7]!==x||t[8]!==f?(S=(0,$.jsx)(C,{onClick:x,disabled:f,children:`Hard reload`}),t[7]=x,t[8]=f,t[9]=S):S=t[9];let w;t[10]===h?w=t[11]:(w=h(X.openDevTools),t[10]=h,t[11]=w);let T;t[12]!==w||t[13]!==f?(T=(0,$.jsx)(C,{onClick:w,disabled:f,children:`Open DevTools`}),t[12]=w,t[13]=f,t[14]=T):T=t[14];let E=u?`Close separate preview window`:`Open separate preview window`,D;t[15]!==d||t[16]!==E||t[17]!==f?(D=(0,$.jsx)(C,{onClick:d,disabled:f,children:E}),t[15]=d,t[16]=E,t[17]=f,t[18]=D):D=t[18];let O=o?`Hide device toolbar`:`Show device toolbar`,k;t[19]!==l||t[20]!==O||t[21]!==f?(k=(0,$.jsx)(C,{onClick:l,disabled:f,children:O}),t[19]=l,t[20]=O,t[21]=f,t[22]=k):k=t[22];let A;t[23]===f?A=t[24]:(A=(0,$.jsx)(_,{disabled:f,children:`Appearance`}),t[23]=f,t[24]=A);let j;t[25]===n?j=t[26]:(j=e=>{n&&X.setColorScheme(n,e).catch(dt)},t[25]=n,t[26]=j);let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=rt.map(ut),t[27]=M):M=t[27];let N;t[28]!==a||t[29]!==j?(N=(0,$.jsx)(m,{className:`min-w-32`,children:(0,$.jsx)(s,{value:a,onValueChange:j,children:M})}),t[28]=a,t[29]=j,t[30]=N):N=t[30];let P;t[31]!==A||t[32]!==N?(P=(0,$.jsxs)(ee,{children:[A,N]}),t[31]=A,t[32]=N,t[33]=P):P=t[33];let te;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(L,{}),t[34]=te):te=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 R;t[36]===h?R=t[37]:(R=h(X.zoomOut),t[36]=h,t[37]=R);let re;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(Ne,{}),t[38]=re):re=t[38];let z;t[39]!==R||t[40]!==f?(z=(0,$.jsx)(V,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:R,"aria-label":`Zoom out`,disabled:f,children:re}),t[39]=R,t[40]=f,t[41]=z):z=t[41];let B;t[42]===v?B=t[43]:(B=(0,$.jsx)(`span`,{className:`min-w-12 text-center text-xs tabular-nums text-muted-foreground`,children:v}),t[42]=v,t[43]=B);let U;t[44]===h?U=t[45]:(U=h(X.zoomIn),t[44]=h,t[45]=U);let ae;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(_e,{}),t[46]=ae):ae=t[46];let W;t[47]!==U||t[48]!==f?(W=(0,$.jsx)(V,{variant:`outline`,size:`icon-xs`,type:`button`,onClick:U,"aria-label":`Zoom in`,disabled:f,children:ae}),t[47]=U,t[48]=f,t[49]=W):W=t[49];let oe;t[50]===h?oe=t[51]:(oe=h(X.resetZoom),t[50]=h,t[51]=oe);let G;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(ve,{}),t[52]=G):G=t[52];let K;t[53]!==oe||t[54]!==f?(K=(0,$.jsx)(V,{variant:`ghost`,size:`icon-xs`,type:`button`,onClick:oe,"aria-label":`Reset zoom`,disabled:f,children:G}),t[53]=oe,t[54]=f,t[55]=K):K=t[55];let q;t[56]!==z||t[57]!==B||t[58]!==W||t[59]!==K?(q=(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[z,B,W,K]}),t[56]=z,t[57]=B,t[58]=W,t[59]=K,t[60]=q):q=t[60];let J;t[61]!==q||t[62]!==f?(J=(0,$.jsxs)(C,{closeOnClick:!1,onClick:lt,className:`justify-between`,disabled:f,children:[ne,q]}),t[61]=q,t[62]=f,t[63]=J):J=t[63];let Y,se,ce;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Y=(0,$.jsx)(L,{}),se=(0,$.jsx)(C,{onClick:st,children:`Clear cookies`}),ce=(0,$.jsx)(C,{onClick:at,children:`Clear cache`}),t[64]=Y,t[65]=se,t[66]=ce):(Y=t[64],se=t[65],ce=t[66]);let le;return t[67]!==k||t[68]!==P||t[69]!==J||t[70]!==S||t[71]!==T||t[72]!==D?(le=(0,$.jsxs)(ie,{children:[b,(0,$.jsxs)(c,{align:`end`,sideOffset:6,className:`min-w-56`,children:[S,T,D,k,P,te,J,Y,se,ce]})]}),t[67]=k,t[68]=P,t[69]=J,t[70]=S,t[71]=T,t[72]=D,t[73]=le):le=t[73],le}function at(){X.clearCache().catch(ot)}function ot(){}function st(){X.clearCookies().catch(ct)}function ct(){}function lt(e){return e.preventDefault()}function ut(e){return(0,$.jsx)(v,{value:e.value,children:e.label},e.value)}function dt(){}function ft(){}function pt(e){return i[e]||(e.length>0?e:`Network error`)}function mt(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=_t(n)??n,t[0]=n,t[1]=c);let l=c,u;t[2]===i?u=t[3]:(u=pt(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 p=f,m,h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(gt,{className:`mb-6 size-12 text-muted-foreground/70`}),h=(0,$.jsx)(`h1`,{className:`mb-3 text-2xl font-semibold leading-tight text-foreground`,children:`This site can’t be reached`}),t[7]=m,t[8]=h):(m=t[7],h=t[8]);let g;t[9]===l?g=t[10]:(g=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:l}),t[9]=l,t[10]=g);let _;t[11]!==d||t[12]!==g?(_=(0,$.jsxs)(`p`,{className:`text-sm leading-relaxed text-muted-foreground`,children:[g,`: `,d,`.`]}),t[11]=d,t[12]=g,t[13]=_):_=t[13];let v;t[14]===o?v=t[15]:(v=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]=v);let y;t[16]===p?y=t[17]:(y=(0,$.jsx)(`div`,{className:`mt-8 text-xs uppercase tracking-wide text-muted-foreground/70`,children:p}),t[16]=p,t[17]=y);let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=()=>s(ht),t[18]=b):b=t[18];let x=o?`Hide details`:`Details`,S;t[19]===x?S=t[20]:(S=(0,$.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:b,children:x}),t[19]=x,t[20]=S);let C;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`div`,{className:`flex-1`}),t[21]=C):C=t[21];let w;t[22]===a?w=t[23]:(w=(0,$.jsx)(V,{type:`button`,size:`sm`,onClick:a,children:`Reload`}),t[22]=a,t[23]=w);let T;t[24]!==S||t[25]!==w?(T=(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-8`,children:[S,C,w]}),t[24]=S,t[25]=w,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==_||t[29]!==v||t[30]!==y?(E=(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:[m,h,_,v,y,T]})}),t[27]=T,t[28]=_,t[29]=v,t[30]=y,t[31]=E):E=t[31],E}function ht(e){return!e}function gt(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 _t(e){try{return new URL(e).host}catch{return null}}function vt(e){let t=e.toLowerCase();return t.includes(`mac`)?`Reveal in Finder`:t.includes(`win`)?`Reveal in File Explorer`:`Reveal in Files`}var yt=120,bt=220,xt=4,St=90,Ct=.08,wt=.5;function Tt(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),bt);return()=>window.clearTimeout(e)}n(e=>e>0&&e<95?e:xt);let t=window.setInterval(()=>{let e=r.current;if(e>=St)return;let t=St-e,i=Math.max(wt,t*Ct);n(Math.min(St,e+i))},yt);return()=>window.clearInterval(t)},[e]),t}var Et=class extends h()(`PreviewSessionThreadKeyParseError`,{threadKey:o}){get message(){return`Invalid scoped preview thread key: ${this.threadKey}`}},Dt=E(e=>{let t=B(e);if(t===null)throw new Et({threadKey:e});let n=z.list({environmentId:t.environmentId,input:{threadId:t.threadId}}),r=z.events({environmentId:t.environmentId,input:{}});return w(e=>{let i=!1,a=0,o=e=>{x(e)&&R(t,e.value)},s=r=>{if(!x(r)||r.value.threadId!==t.threadId)return;let i=f(t).serverEpoch;if(i!==null&&i!==r.value.serverEpoch){e.refresh(n);return}T(t,r.value)};e.addFinalizer(()=>{i=!0});let c=e.once(r);e.subscribe(n,e=>{o(e)}),e.subscribe(r,e=>{a+=1,s(e)}),queueMicrotask(()=>{i||(e.refresh(n),a===0&&s(c))})}).pipe(D(1e3),p(`preview:session-sync:${e}`))});function Ot(e){let t=(0,Z.c)(2),n;t[0]===e?n=t[1]:(n=Dt(A(e)),t[0]=e,t[1]=n),P(n)}var kt=1500,At=.001;function jt(e){let t=(0,Z.c)(11),{zoomFactor:n}=e,[r,i]=(0,Q.useState)(!1),a=(0,Q.useRef)(n),o=(0,Q.useRef)(null),s,c;t[0]===n?(s=t[1],c=t[2]):(s=()=>{if(!(Math.abs(a.current-n)<At))return a.current=n,i(!0),o.current!==null&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i(!1),o.current=null},kt),()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)}},c=[n],t[0]=n,t[1]=s,t[2]=c),(0,Q.useEffect)(s,c);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=l(`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 Mt(e,t){return e?1:t===`human`?.18:.35}var Nt=700;function Pt(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=we(a),s;t[2]===n?s=t[3]:(s=e=>e.byTabId[n]?.content??null,t[2]=n,t[3]=s);let c=me(s);if(!o)return null;let l;return t[4]!==c||t[5]!==i||t[6]!==o||t[7]!==r?(l=(0,$.jsx)(Ft,{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 Ft(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),Nt);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=Mt(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)(He,{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 It=typeof window>`u`?null:te();function Lt({threadRef:e,tabId:t,configuredUrls:n,visible:r}){let[i,a]=(0,Q.useState)(void 0),[o,s]=(0,Q.useState)(!1),c=Me(),l=(0,Q.useRef)(!1),u=(0,Q.useRef)(!0),f=b(e),p=ke(t=>q(t.byThreadKey,e)),m=S(e=>e.addPreviewAnnotation),h=S(e=>e.addImage),_=j(e.environmentId),v=ae(e.environmentId),y=W(z.open),x=W(z.resize,`preview viewport resize`),{resolvedTheme:C}=U();Ot(e),(0,Q.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let w=t??f.activeTabId,T=w?ue(e,f.serverEpoch,w):null,E=w&&T?c.has(T)?T:Pe(e,w):null,D=w?f.sessions[w]??null:null,P=w?f.desktopByTabId[w]??null:null;(0,Q.useEffect)(()=>{let e=X;if(!(!e||!T||!P?.pictureInPicture))return e.pictureInPicture.setVisible(T,r),()=>{e.pictureInPicture.setVisible(T,!1)}},[P?.pictureInPicture,T,r]);let F=D?.navStatus??{_tag:`Idle`},I=F._tag===`Idle`?``:F.url,ee=P?.loading??F._tag===`Loading`,L=P?.canGoBack??D?.canGoBack??!1,te=P?.canGoForward??D?.canGoForward??!1,R=F._tag===`Idle`,B=F._tag===`LoadFailed`,V=fe(D),H=P?.controller??`none`,ie=Tt(ee),oe=I&&_&&v?Ke({url:I,environmentLabel:_.label,environmentHttpBaseUrl:v})??void 0:void 0,G=D?.viewport??O,K=me(e=>T?e.byTabId[T]?.rect??null:null),J=(0,Q.useCallback)(async t=>{T&&X?(await X.navigate(T,t),d(e,t)):await Re({openPreview:y,threadRef:e,url:t})},[y,T,e]),se=(0,Q.useCallback)(async e=>{try{await J(Y(e))}catch{}},[J]),ce=(0,Q.useCallback)(async t=>{try{await J(ge(e.environmentId,t))}catch{}},[J,e.environmentId]),le=(0,Q.useCallback)(()=>{X&&T&&X.refresh(T)},[T]),pe=(0,Q.useCallback)(()=>{X&&T&&X.zoomIn(T)},[T]),he=(0,Q.useCallback)(()=>{X&&T&&X.zoomOut(T)},[T]),_e=(0,Q.useCallback)(()=>{X&&T&&X.resetZoom(T)},[T]),ve=(0,Q.useCallback)(async t=>{if(!w)return;let n=await x({environmentId:e.environmentId,input:{threadId:e.threadId,tabId:w,viewport:t}});if(n._tag===`Failure`){let e=g(n);throw M.add({type:`error`,title:`Unable to resize browser viewport`,description:e instanceof Error?e.message:`An error occurred.`}),e}k(e,n.value)},[x,w,e]),ye=()=>{if(!T)return;if(G._tag!==`fill`){Ie(T,O).catch(()=>void 0);return}let e=K?Fe(K,P?.zoomFactor):{width:1024,height:768};Ie(T,{_tag:`freeform`,...e}).catch(()=>void 0)};(0,Q.useEffect)(()=>{if(T)return Ae(T,ve)},[ve,T]);let be=(0,Q.useCallback)(()=>{X&&T&&X.goBack(T)},[T]),xe=(0,Q.useCallback)(()=>{X&&T&&X.goForward(T)},[T]),Se=(0,Q.useCallback)(()=>{!It||!I||It.shell.openExternal(I).catch(()=>void 0)},[I]),we=(0,Q.useCallback)(()=>{if(w){if(p?.tabId===w){ke.getState().close(e);return}ke.getState().open(e,w),ne.getState().close(e)}},[p?.tabId,w,e]),Te=(0,Q.useCallback)(()=>{!X||!T||(P?.pictureInPicture?X.pictureInPicture.close:X.pictureInPicture.open)(T).catch(e=>{M.add({type:`error`,title:`Unable to update popped-out preview`,description:e instanceof Error?e.message:`An error occurred.`})})},[P?.pictureInPicture,T]),Ee=(0,Q.useCallback)(t=>{if(!X||!T||!w)return;let n=X;if(E){Ce(E).then(e=>{if(!e)return;let t=!1,r,i=()=>{if(!navigator.clipboard?.writeText){M.update(r,N({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=>{M.update(r,N({type:`error`,title:`Unable to copy recording path`,description:e instanceof Error?e.message:`An error occurred.`,actionProps:a}))})},a={children:vt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},o=()=>{M.update(r,N({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:t?`Copied!`:`Copy path`,disabled:t,onClick:i},secondaryActionVariant:`outline`}}))};r=M.add(N({type:`success`,title:`Recording saved`,actionProps:a,data:{secondaryActionProps:{children:`Copy path`,onClick:i},secondaryActionVariant:`outline`}}))},e=>{M.add({type:`error`,title:`Unable to stop recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}if(t){Oe(T,e,w).catch(e=>{M.add({type:`error`,title:`Unable to start recording`,description:e instanceof Error?e.message:`An error occurred.`})});return}n.captureScreenshot(T).then(e=>{let t={children:vt(navigator.platform),onClick:()=>void n.revealArtifact(e.path)},r=!1,i=!1,a,o=(e=`success`,n=`Screenshot saved`,o)=>{M.update(a,N({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=M.add(N({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=>{M.add({type:`error`,title:`Unable to capture screenshot`,description:e instanceof Error?e.message:`An error occurred.`})})},[E,T,w,e]),je=(0,Q.useCallback)(()=>{if(!X||!T)return;if(l.current){X.cancelPickElement(T).catch(()=>void 0);return}let t=typeof document<`u`?document.activeElement:null;l.current=!0,s(!0),(async()=>{try{let t=await X.pickElement(T);if(!t)return;m(e,t);let n=await De(t);n&&t.screenshot&&h(e,{type:`image`,id:t.id,name:n.name,mimeType:n.type,sizeBytes:n.size,previewUrl:t.screenshot.dataUrl,file:n})}catch{}finally{if(l.current=!1,u.current&&s(!1),t&&t.isConnected&&typeof t.focus==`function`)try{t.focus({preventScroll:!0})}catch{}}})()},[h,m,T,e]);return(0,Q.useEffect)(()=>{let e=re(I,C);e&&J(e).catch(()=>void 0)},[J,C,I]),(0,Q.useEffect)(()=>()=>{l.current&&(l.current=!1,X&&T&&X.cancelPickElement(T).catch(()=>void 0),u.current&&s(!1))},[T]),(0,Q.useEffect)(()=>{if(r)return Le(e=>{switch(e){case`refresh`:le();return;case`focus-url`:a(e=>(e??0)+1);return;case`zoom-in`:pe();return;case`zoom-out`:he();return;case`reset-zoom`:_e();return;case`toggle-panel`:return}})},[le,_e,pe,he,r]),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col bg-background`,"data-thread-key":A(e),children:[(0,$.jsx)(Ge,{url:I,displayUrl:oe,loading:ee,loadProgress:ie,canGoBack:L,canGoForward:te,refreshDisabled:R,focusUrlNonce:i,onBack:be,onForward:xe,onRefresh:le,onSubmit:e=>void se(e),onOpenInBrowser:w?Se:void 0,onCapture:X&&w?Ee:void 0,captureDisabled:!P||B,recording:E!==null,onPictureInPicture:X&&w?we:void 0,pictureInPicture:p?.tabId===w,pictureInPictureDisabled:!P?.hasWebContents||B,onPickElement:X&&w?je:void 0,pickActive:o,pickDisabled:!w||B,pickDisabledReason:B?`Page didn't load — pick unavailable until the page renders`:void 0,trailingActions:X?(0,$.jsx)(it,{tabId:T,hasWebContents:P?.hasWebContents??!1,zoomFactor:P?.zoomFactor??1,colorScheme:P?.colorScheme??`system`,deviceToolbarVisible:G._tag!==`fill`,onToggleDeviceToolbar:ye,nativePictureInPicture:P?.pictureInPicture??!1,onNativePictureInPicture:Te}):null}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden`,children:[T&&D&&!V?(0,$.jsx)(de,{tabId:T,visible:r&&!B,className:`absolute inset-0 h-full w-full`},T):null,V?(0,$.jsx)(nt,{environmentId:e.environmentId,configuredUrls:n,recentlySeenUrls:f.recentlySeenUrls,onOpenUrl:e=>void ce(e)}):null,D&&P?(0,$.jsx)(jt,{zoomFactor:P.zoomFactor}):null,T&&P&&!V&&!B?(0,$.jsx)(Pt,{tabId:T,zoomFactor:P.zoomFactor,controller:H}):null,H===`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:H===`agent`?`Agent controlling browser`:`Human control`}),F._tag===`LoadFailed`?(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 bg-background`,children:(0,$.jsx)(mt,{url:F.url,code:F.code,description:F.description,onReload:le})}):null]})]})}function Rt(e){let t=(0,Z.c)(13),{mode:n,threadRef:r,tabId:i,configuredUrls:a,visible:o}=e;if(!u()){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 P4Code desktop app.`})}),t[0]=e):e=t[0];let r;return t[1]===n?r=t[2]:(r=(0,$.jsx)(ze,{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)(Lt,{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)(ze,{mode:n,children:c}),t[10]=n,t[11]=c,t[12]=l):l=t[12],l}export{Rt as PreviewPanel};
|
|
2
|
-
//# sourceMappingURL=PreviewPanel-uOARpCuE.js.map
|