@kabmo-labs/kabmo 0.39.0 → 0.39.1
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/client/index.html +1 -1
- package/dist/client/index.js +270 -270
- package/dist/client/static/js/{CsvGrid-kfcp4sd6.js → CsvGrid-7synegzg.js} +1 -1
- package/dist/client/static/js/{DocxView-atff5w38.js → DocxView-v5d9n5yw.js} +1 -1
- package/dist/client/static/js/{DrawioView-yfnq4c99.js → DrawioView-ww7y98tt.js} +1 -1
- package/dist/client/static/js/{ImageView-nreh25s0.js → ImageView-t3rkypzs.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-0x1q1q5z.js → LayoutWrapper-th2pd4yt.js} +1 -1
- package/dist/client/static/js/{Modal-2xqd3sss.js → Modal-qj39shgb.js} +1 -1
- package/dist/client/static/js/{PdfView-mk8paxt1.js → PdfView-t9v4datp.js} +1 -1
- package/dist/client/static/js/{SessionsView-ner25qxn.js → SessionsView-yqy0a1xg.js} +1 -1
- package/dist/client/static/js/{SheetView-s6n3fawm.js → SheetView-6zkxbjd4.js} +1 -1
- package/dist/client/static/js/{SvgPreview-8bxvz3ez.js → SvgPreview-7rt2p1y1.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-tvvz9fha.js → abnfDiagram-O67JEVCF-888zn5zg.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-bybv3wg4.js → architectureDiagram-NJMV4G6O-b04e26rb.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-h3fs79x6.js → blockDiagram-BEXU5L5S-32ph2m52.js} +1 -1
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-h8p3h54v.js → c4Diagram-YGBWAQC7-hwnaa333.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-q645r4q6.js → classDiagram-v2-NBCMYWYE-2kg7dqeb.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-p4mm1zcv.js → cose-bilkent-JH36ORCC-tj2sbtyv.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-v2hbc3aq.js → cynefinDiagram-VND7K2PF-wx2y8dhm.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-4edpda33.js → dagre-6A5THRUB-5v3rzdxd.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-b6gp813w.js → diagram-22UHCM2B-7er2jwy1.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-s1f3b0ng.js → diagram-3UASUU5V-2b7nmdha.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-ga06kjp5.js → diagram-ATOU4E4O-yf61ftn0.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-wdbmv4td.js → diagram-CDSNMT55-cn3rs9xn.js} +1 -1
- package/dist/client/static/js/{diagram-MLGK6HIB-fkntefcq.js → diagram-MLGK6HIB-7kvtsj6c.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-k2zh7edp.js → diagram-MPIPVDR6-g3zg3r5e.js} +1 -1
- package/dist/client/static/js/{dockerfile-srcym0bs.js → dockerfile-f9j396wm.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vc4vz9c.js → ebnfDiagram-ZINNZB2B-ft02nzne.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-g2ppf1by.js → elk-276RUBZZ-87fvkn2k.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-rmnwkb5q.js → erDiagram-OPXOYQCR-gh9mp6j8.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ptfvae64.js → ganttDiagram-FUAMR5RP-227xs61z.js} +1 -1
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ne9n3cyf.js → gitGraphDiagram-X574FWY7-4671gdym.js} +1 -1
- package/dist/client/static/js/{index-a7qccdq2.js → index-28a5kf88.js} +1 -1
- package/dist/client/static/js/{index-ymp2wqtc.js → index-35mh9kbs.js} +1 -1
- package/dist/client/static/js/{index-3fw3sd10.js → index-4c2zcvem.js} +7 -7
- package/dist/client/static/js/{index-jkph8wqq.js → index-4ry8kz8h.js} +1 -1
- package/dist/client/static/js/{index-v8vjh5jj.js → index-668chrpq.js} +1 -1
- package/dist/client/static/js/{index-8qgwj6m8.js → index-6rs8e8ng.js} +1 -1
- package/dist/client/static/js/{index-56w8m083.js → index-7qc2avfy.js} +1 -1
- package/dist/client/static/js/{index-5kvvb0zm.js → index-87qandgr.js} +1 -1
- package/dist/client/static/js/{index-ntx3bbmb.js → index-8xasfxf3.js} +1 -1
- package/dist/client/static/js/{index-gvkc9e32.js → index-d3prrt2q.js} +1 -1
- package/dist/client/static/js/{index-4pehdq5h.js → index-f1nqk6z6.js} +1 -1
- package/dist/client/static/js/{index-pzqsp5jw.js → index-f73v86a3.js} +1 -1
- package/dist/client/static/js/{index-270y5r9k.js → index-fjqp03xe.js} +1 -1
- package/dist/client/static/js/{index-mmsszqvn.js → index-fs3pbqwn.js} +1 -1
- package/dist/client/static/js/{index-xdqsqhnn.js → index-h8rr48px.js} +1 -1
- package/dist/client/static/js/{index-dmd26a1y.js → index-hdd8nqz8.js} +1 -1
- package/dist/client/static/js/{index-me7m3516.js → index-j2g39xq7.js} +1 -1
- package/dist/client/static/js/{index-dt22v9ns.js → index-jze0zg3z.js} +1 -1
- package/dist/client/static/js/{index-m3r0j562.js → index-kkfbd1db.js} +1 -1
- package/dist/client/static/js/{index-7h5n5rz4.js → index-m847wafq.js} +1 -1
- package/dist/client/static/js/{index-y2prm0xm.js → index-mtadrbxt.js} +1 -1
- package/dist/client/static/js/{index-7z63xr1s.js → index-phm1zb8m.js} +1 -1
- package/dist/client/static/js/{index-p89z1qmj.js → index-qbnd827h.js} +1 -1
- package/dist/client/static/js/{index-8w2tx2k9.js → index-s80x8d58.js} +1 -1
- package/dist/client/static/js/{index-ywpdhntc.js → index-tmnnafht.js} +1 -1
- package/dist/client/static/js/{index-hh05xd1d.js → index-vb3srfyc.js} +1 -1
- package/dist/client/static/js/{index-k61tdd4a.js → index-w0rbyw47.js} +1 -1
- package/dist/client/static/js/{index-5a4w58r2.js → index-w0xvdda9.js} +1 -1
- package/dist/client/static/js/{index-878d61js.js → index-wfcgqjzr.js} +1 -1
- package/dist/client/static/js/{index-pr7gk5eq.js → index-wgvysmnr.js} +1 -1
- package/dist/client/static/js/{index-mdxnhndy.js → index-xfr6r539.js} +1 -1
- package/dist/client/static/js/{index-k3c3n69j.js → index-xnk1500f.js} +2 -2
- package/dist/client/static/js/{index-61qjr1k0.js → index-y5ymgp20.js} +2 -2
- package/dist/client/static/js/{index-k5a6r25s.js → index-y91j4t1q.js} +1 -1
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ctfwcm3n.js → infoDiagram-VRGFBTTK-k1jnhhbp.js} +1 -1
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-b0b0pn4y.js → ishikawaDiagram-OU5B5YK6-ar94x2gr.js} +1 -1
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kdq12drs.js → journeyDiagram-ZHPQQLJL-ntfp0w54.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-65x6xn2q.js → kanban-definition-PNTS6WVX-q5rsr6j3.js} +1 -1
- package/dist/client/static/js/{mermaid.core-0fq63jpa.js → mermaid.core-0gafsqrm.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-p86myex3.js → mindmap-definition-NLK3R4M7-jgz6nyhk.js} +1 -1
- package/dist/client/static/js/one-dark-pro-n0as47q7.js +1 -0
- package/dist/client/static/js/one-light-05nw3mzj.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-p2hkk9xb.js → pegDiagram-GJSIUBJH-b3e9ma2c.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-bza19wkx.js → pieDiagram-5QR66LMP-66mn2qnt.js} +1 -1
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-bxqec9w1.js → quadrantDiagram-O4NWA36T-n7warg0e.js} +1 -1
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g3hx3sm.js → railroadDiagram-XR7U4H2S-k8j43rxj.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qbjjm48v.js → requirementDiagram-PLB6GJNP-ef2v7nyq.js} +1 -1
- package/dist/client/static/js/{rust-jatm47v6.js → rust-jvkbr060.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t2ythbh7.js → sankeyDiagram-IPEJSGJF-3njbd1yd.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mqsfek2j.js → sequenceDiagram-PO4LG4MO-k2wqc0qt.js} +1 -1
- package/dist/client/static/js/{sizeCapture-INFHLROL-xj67pgds.js → sizeCapture-INFHLROL-cpnd12ee.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gj4fezak.js → stateDiagram-v2-GCMORJYK-1ydpxaeg.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-pgtdd1pk.js → swimlanes-2SLR337P-4md43da2.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-zk37paj9.js → swimlanesDiagram-TC7HE7FX-d48g5gjf.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-q013vdd1.js → timeline-definition-EJHVYXUP-sp32bf3e.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-7swsbqnq.js → usecaseDiagram-POWQR4AR-p2ssettn.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-9dygxdxf.js → vennDiagram-UO4OBE2U-ejqq8b82.js} +1 -1
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-aaaa9kj3.js → wardleyDiagram-VNRHLVJA-tkk79rsn.js} +1 -1
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tamf39gx.js → xychartDiagram-PMCCYNJV-zhgrsqpb.js} +1 -1
- package/package.json +1 -1
- package/src/server/lib/terminal/attach-replay.test.ts +80 -17
- package/src/server/plugins/static.test.ts +23 -1
- package/src/server/plugins/static.ts +24 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +0 -1
- package/dist/client/static/js/one-dark-pro-c4q810z4.js +0 -1
- package/dist/client/static/js/one-light-czk9dzya.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,o,i,mo,a,Rs,e,w,Ze,ze,S,lr,cr,s,m,jr,f,wa,_e,mt,qf,jt,Jg,rn,Er,Gp,Yl}from"./index-3fw3sd10.js";import{Ns,hr,Ru}from"./index-270y5r9k.js";function oe(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID();return`t-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ie(t){return JSON.stringify(t)}function ue(t){let r=je(t);if(!w(r))return null;if(r.t==="ready"){if(typeof r.id!=="string"||typeof r.cwd!=="string")return null;let l=typeof r.replayBytes==="number"?r.replayBytes:0;return{...r,t:"ready",replayBytes:l}}if(r.t==="exit")return{t:"exit",exitCode:typeof r.exitCode==="number"?r.exitCode:null,signal:typeof r.signal==="string"?r.signal:null};if(r.t==="error"&&typeof r.message==="string")return{t:"error",code:Je(r.code),message:r.message};return null}function me(t){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/terminal/${encodeURIComponent(t)}/ws`}function Je(t){return t==="capacity"||t==="cwd"||t==="shell"||t==="spawn"?t:"unknown"}function je(t){try{return JSON.parse(t)}catch{return null}}function de(t){if(t.buffer instanceof ArrayBuffer)return t;return new Uint8Array(t)}var et=500,tt=8000,nt=4;function pe(t,r){let l=null,c=null,p=0,u=!1,b=!1,y=!1,x=null,A=[],M=0,L=null,U=()=>{let h=new WebSocket(me(t));h.binaryType="arraybuffer",l=h,h.onopen=()=>{if(b)return;if(p=0,u=!0,r.onConnectionChange(!0),x)h.send(ie(x))},h.onmessage=(g)=>{if(b)return;if(g.data instanceof ArrayBuffer){v(new Uint8Array(g.data));return}if(typeof g.data!=="string")return;let B=ue(g.data);if(B)D(B)},h.onclose=()=>{if(l=null,b)return;if(r.onConnectionChange(!1),y=!1,A=[],M=0,L=null,!u)return;if(p+=1,p>nt)return;let g=Math.min(et*2**(p-1),tt);c=setTimeout(()=>{if(c=null,!b)U()},g)},h.onerror=()=>{}},D=(h)=>{if(h.t==="ready"){if(y=!0,L=h,M=h.replayBytes,A=[],r.onReady(h),M===0)E();return}if(h.t==="exit"){r.onExit(h.exitCode,h.signal);return}r.onError(h.code,h.message)},v=(h)=>{if(M<=0){r.onOutput(h);return}if(A.push(h),M-=h.length,M>0)return;E()},E=()=>{let h=L,g=A;if(L=null,A=[],M=0,!h)return;r.onReplay(g.length===1?g[0]:rt(g),h)};U();let P=(h)=>{let g=l;if(!g||g.readyState!==WebSocket.OPEN)return;g.send(ie(h))};return{attach(h,g,B,F,q){if(y)return;let R={t:"attach",cols:h,rows:g};if(B)R.root=B;if(F)R.repo=F;if(q)R.theme=q;x=R,P(R)},resize(h,g){P({t:"resize",cols:h,rows:g})},input(h){let g=l;if(!g||g.readyState!==WebSocket.OPEN)return;g.send(de(h))},close(){P({t:"close"})},release(){if(b=!0,c!==null)clearTimeout(c),c=null;let h=l;if(l=null,!h)return;h.onopen=null,h.onmessage=null,h.onclose=null,h.onerror=null,h.close()}}}function rt(t){let r=0;for(let p of t)r+=p.length;let l=new Uint8Array(r),c=0;for(let p of t)l.set(p,c),c+=p.length;return l}function fe(t){return{connect:t.visible||t.opened,persist:t.ready&&t.visible&&!t.opened}}function be(t={}){let{sessionId:r,ready:l}=Ze(),[c,p]=S("terminal.id",""),[u,b]=S("terminal.opened",!1),y=fe({visible:t.visible===!0,ready:l,opened:u}),[x,A]=n("connecting"),[M,L]=n(""),[U,D]=n(null),[v,E]=n(null),[P,h]=n(0),g=i(null),B=i(null),F=i(t.onOutput);F.current=t.onOutput;let q=i(t.onReplay);q.current=t.onReplay;let R=i(t.onRestart);R.current=t.onRestart;let T=i(t.root);T.current=t.root;let k=i(t.repo);k.current=t.repo;let I=i(t.theme);I.current=t.theme;let N=i(p);N.current=p;let z=i(null);o(()=>{if(!y.persist)return;b(!0)},[y.persist]),o(()=>{if(!y.connect||!l)return;if(ze(r,"terminal.id"))return;N.current(oe())},[y.connect,l,r]),o(()=>{if(!y.connect||!l||!c)return;A("connecting"),E(null),D(null);let _=pe(c,{onReady(H){A("running"),L(H.shell),D(null)},onReplay(H,X){q.current?.(H,X)},onOutput(H){F.current?.(H)},onExit(H){A("exited"),D(H)},onError(H,X){A("error"),E(`${H}: ${X}`)},onConnectionChange(H){if(!H)A("connecting")}});g.current=_;let K=B.current;if(K)_.attach(K.cols,K.rows,T.current,k.current,I.current);return()=>{_.release(),g.current=null}},[y.connect,l,c,P]);let Y=a(()=>{g.current?.close(),R.current?.(),N.current(oe())},[]);o(()=>{if(!l)return;let _=t.root;if(!_)return;let K=`${_}\x00${t.repo??"."}`;if(z.current===null){z.current=K;return}if(z.current===K)return;z.current=K,Y()},[l,t.root,t.repo,Y]);let Z=a((_,K)=>{B.current={cols:_,rows:K},g.current?.attach(_,K,T.current,k.current,I.current)},[]),J=a((_,K)=>{B.current={cols:_,rows:K},g.current?.resize(_,K)},[]),te=a((_)=>{g.current?.input(_)},[]),ne=a(()=>{h((_)=>_+1)},[]);return{status:x,shell:M,exitCode:U,error:v,attach:Z,resize:J,input:te,restart:Y,reattach:ne}}var ot={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]},he=s(ot);var it={name:"zap",size:24,node:[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]},ye=s(it);var at={connecting:"CONNECTING",running:"LIVE",exited:"EXITED",error:"ERROR"},st={connecting:"bg-warning/10 text-warning border-warning/20",running:"bg-success/10 text-success border-success/20",exited:"bg-ink/5 text-ink/60 border-ink/15",error:"bg-error/10 text-error border-error/20"};function ge({status:t,exitCode:r,rootPath:l,activeRepo:c,onSelectRepo:p,repos:u,reposScanning:b,onRefreshRepos:y,shell:x,onRestart:A}){let M=x?x.split("/").pop():"";return e(mt,{left:e(d,{children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:14,className:"text-ink/80 flex-shrink-0"}),e("span",{className:"text-xs font-semibold tracking-wider text-ink uppercase",children:"Terminal"})]}),e("span",{className:`inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono border ${st[t]}`,title:t==="exited"&&r!==null?`Shell exited with code ${r}`:void 0,children:[t==="connecting"&&e(m,{size:10,className:"animate-spin"}),e("span",{children:t==="exited"&&r!==null?`EXIT ${r}`:at[t]})]}),e(hr,{rootPath:l,activeRepo:c,onSelectRepo:p,repos:u,scanning:b,onRefreshRepos:y}),e(qf,{label:"Kill this shell and start a new one",onClick:A,children:e(wa,{size:14})})]}),right:M?e("span",{className:"hidden sm:block text-[10px] font-mono text-ink/40 flex-shrink-0",children:M}):void 0})}var lt=[{label:"bun build",cmd:"bun run build"},{label:"bun test",cmd:"bun test"},{label:"git status",cmd:"git status -s"},{label:"git diff",cmd:"git diff"},{label:"ls -la",cmd:"ls -la"},{label:"pwd",cmd:"pwd"},{label:"bun -v",cmd:"bun --version"}];function Te({onSelectCommand:t,disabled:r}){return e("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-1.5 bg-paper border-b border-ink/10 flex-shrink-0",children:[e("div",{className:"flex items-center space-x-1 text-[10px] font-mono text-ink/50 uppercase tracking-wider flex-shrink-0 select-none",children:[e(ye,{size:11,className:"text-warning"}),e("span",{children:"Quick:"})]}),lt.map((l)=>e("button",{type:"button",disabled:r,onClick:()=>t(l.cmd),className:"px-2 py-0.5 rounded text-[10px] font-mono bg-canvas hover:bg-ink/5 active:bg-ink/10 text-ink/80 hover:text-ink border border-ink/15 transition-all whitespace-nowrap disabled:opacity-40 cursor-pointer shadow-2xs",children:l.label},l.cmd))]})}var W=Object.freeze({ctrl:!1,alt:!1}),ae=[{id:"escape",label:"Esc",name:"Escape",sequence:"\x1B"},{id:"tab",label:"Tab",name:"Tab",sequence:"\t"},{id:"interrupt",label:"^C",name:"Ctrl+C — interrupt",sequence:"\x03"},{id:"left",label:"←",name:"Left arrow",csi:{prefix:"1",final:"D",application:"OD"}},{id:"up",label:"↑",name:"Up arrow",csi:{prefix:"1",final:"A",application:"OA"}},{id:"down",label:"↓",name:"Down arrow",csi:{prefix:"1",final:"B",application:"OB"}},{id:"right",label:"→",name:"Right arrow",csi:{prefix:"1",final:"C",application:"OC"}},{id:"home",label:"Home",name:"Home",csi:{prefix:"1",final:"H",application:"OH",terminfo:"\x1BOH"}},{id:"end",label:"End",name:"End",csi:{prefix:"1",final:"F",application:"OF",terminfo:"\x1BOF"}},{id:"pageUp",label:"PgUp",name:"Page up",csi:{prefix:"5",final:"~"}},{id:"pageDown",label:"PgDn",name:"Page down",csi:{prefix:"6",final:"~"}},{id:"delete",label:"Del",name:"Delete",csi:{prefix:"3",final:"~"}},{id:"shiftTab",label:"⇧Tab",name:"Shift+Tab",sequence:"\x1B[Z"},{id:"eof",label:"^D",name:"Ctrl+D — end of input",sequence:"\x04"},{id:"clear",label:"^L",name:"Ctrl+L — clear screen",sequence:"\f"}],se=[{id:"pipe",label:"|",name:"Pipe",sequence:"|"},{id:"tilde",label:"~",name:"Tilde",sequence:"~"},{id:"dollar",label:"$",name:"Dollar",sequence:"$"},{id:"asterisk",label:"*",name:"Asterisk",sequence:"*"},{id:"question",label:"?",name:"Question mark",sequence:"?"},{id:"underscore",label:"_",name:"Underscore",sequence:"_"},{id:"backslash",label:"\\",name:"Backslash",sequence:"\\"},{id:"slash",label:"/",name:"Slash",sequence:"/"},{id:"minus",label:"-",name:"Minus",sequence:"-"},{id:"equals",label:"=",name:"Equals",sequence:"="},{id:"plus",label:"+",name:"Plus",sequence:"+"},{id:"ampersand",label:"&",name:"Ampersand",sequence:"&"},{id:"semicolon",label:";",name:"Semicolon",sequence:";"},{id:"colon",label:":",name:"Colon",sequence:":"},{id:"comma",label:",",name:"Comma",sequence:","},{id:"dot",label:".",name:"Period",sequence:"."},{id:"at",label:"@",name:"At sign",sequence:"@"},{id:"percent",label:"%",name:"Percent",sequence:"%"},{id:"caret",label:"^",name:"Caret",sequence:"^"},{id:"hash",label:"#",name:"Hash",sequence:"#"},{id:"bang",label:"!",name:"Exclamation mark",sequence:"!"},{id:"parenOpen",label:"(",name:"Open parenthesis",sequence:"("},{id:"parenClose",label:")",name:"Close parenthesis",sequence:")"},{id:"bracketOpen",label:"[",name:"Open bracket",sequence:"["},{id:"bracketClose",label:"]",name:"Close bracket",sequence:"]"},{id:"braceOpen",label:"{",name:"Open brace",sequence:"{"},{id:"braceClose",label:"}",name:"Close brace",sequence:"}"},{id:"lessThan",label:"<",name:"Less than",sequence:"<"},{id:"greaterThan",label:">",name:"Greater than",sequence:">"},{id:"quote",label:"'",name:"Single quote",sequence:"'"},{id:"doubleQuote",label:'"',name:"Double quote",sequence:'"'},{id:"backtick",label:"`",name:"Backtick",sequence:"`"}],xe={};for(let t of[...ae,...se])xe[t.id]=t;function we(t,r={}){let l=xe[t];if(!l)return"";let c=r.modifiers??W;if(l.csi)return ct(l.csi,c,r.applicationCursorKeys??!1);let p=l.sequence??"";return c.alt?`\x1B${p}`:p}function ct(t,r,l){let c=ut(r);if(c!==null)return`\x1B[${t.prefix};${c}${t.final}`;if(t.terminfo)return t.terminfo;if(l&&t.application)return`\x1B${t.application}`;return`\x1B[${t.prefix==="1"?"":t.prefix}${t.final}`}function ut(t){let r=(t.alt?2:0)|(t.ctrl?4:0);return r===0?null:r+1}function ve(t,r){if(t.length!==1)return t;let l=t;if(r.ctrl)l=pt(l)??l;if(r.alt)l=`\x1B${l}`;return l}var dt={"@":"\x00"," ":"\x00","":"\b","[":"\x1B","\\":"\x1C","]":"\x1D","^":"\x1E",_:"\x1F","?":""};function pt(t){if(t.length!==1)return null;let r=t.charCodeAt(0);if(r>=97&&r<=122)return String.fromCharCode(r-96);if(r>=65&&r<=90)return String.fromCharCode(r-64);return dt[t]??null}var ft=[{modifier:"ctrl",label:"Ctrl",name:"Ctrl — applies to the next key"},{modifier:"alt",label:"Alt",name:"Alt / meta — applies to the next key"}],V="flex items-center justify-center h-8 min-w-8 px-1.5 rounded border font-mono transition-colors cursor-pointer select-none disabled:opacity-40 disabled:cursor-default text-[11px] @[420px]:h-9 @[420px]:min-w-10 @[420px]:text-xs",Q="bg-canvas text-ink/80 border-ink/15 hover:text-ink hover:bg-ink/5 active:bg-ink/10",Re="bg-ink text-canvas border-ink";function Se({modifiers:t,onToggleModifier:r,onKey:l,onCopy:c,onPaste:p,disabled:u}){let[b,y]=n(!1),[x,A]=n(null),M=t.ctrl||t.alt,L=(v)=>{A(v),setTimeout(()=>A((E)=>E===v?null:E),1500)},U=async()=>{L(await c()?"copied":"empty")},D=async()=>{if(!await p())L("pasteFailed")};return e("div",{className:"@container flex flex-col gap-1 px-2 py-1.5 border-t border-ink/10 bg-paper flex-shrink-0",onPointerDown:(v)=>v.preventDefault(),children:[e("div",{className:"flex flex-wrap items-center gap-1",children:[ft.map(({modifier:v,label:E,name:P})=>e("button",{type:"button",onClick:()=>r(v),"aria-pressed":t[v],title:P,"aria-label":P,className:`${V} ${t[v]?Re:Q}`,children:E},v)),M&&e("span",{className:"text-[10px] font-mono text-ink/50 px-0.5 whitespace-nowrap","aria-hidden":!0,children:"next"}),e("span",{className:"w-px h-5 bg-ink/15 flex-shrink-0","aria-hidden":!0}),e("button",{type:"button",onClick:U,disabled:u,title:x==="empty"?"Nothing selected":"Copy selection","aria-label":"Copy selection",className:`${V} ${x==="empty"?"bg-warning/10 text-warning border-warning/30":Q}`,children:[x==="copied"?e(f,{size:13}):e(he,{size:13}),e("span",{className:"pl-1",children:"Copy"})]}),e("button",{type:"button",onClick:D,disabled:u,title:x==="pasteFailed"?"Clipboard unavailable":"Paste into the shell","aria-label":"Paste into the shell",className:`${V} ${x==="pasteFailed"?"bg-error/10 text-error border-error/30":Q}`,children:[e(Ns,{size:13}),e("span",{className:"pl-1",children:"Paste"})]}),e("button",{type:"button",onClick:()=>y((v)=>!v),"aria-pressed":b,title:b?"Show control keys":"Show symbols","aria-label":b?"Show control keys":"Show symbols",className:`${V} ml-auto ${b?Re:Q}`,children:b?"ABC":"123"})]}),e("div",{className:"flex flex-wrap items-center gap-1",children:(b?se:ae).map((v)=>e("button",{type:"button",disabled:u,onClick:()=>l(v.id),title:v.name,"aria-label":v.name,className:`${V} ${Q}`,children:v.label},v.id))})]})}function Ce(t){if(!t.startsWith("\x1B[M")||t.length<6)return{text:t};let r=new Uint8Array(t.length);for(let l=0;l<t.length;l+=1)r[l]=t.charCodeAt(l)&255;return{bytes:r}}function ke(t){let r=rn(t),{canvas:l,ink:c,paper:p}=r,u=(y)=>Er(y,c,0.2),b=(y)=>Er(l,c,y);return{background:"transparent",foreground:c,cursor:r.meta,cursorAccent:p,selectionBackground:b(0.28),selectionForeground:c,black:b(0.2),red:r.error,green:r.success,yellow:r.warning,blue:r.info,magenta:r.meta,cyan:Er(r.info,r.success,0.5),white:b(0.75),brightBlack:b(0.5),brightRed:u(r.error),brightGreen:u(r.success),brightYellow:u(r.warning),brightBlue:u(r.info),brightMagenta:u(r.meta),brightCyan:u(Er(r.info,r.success,0.5)),brightWhite:b(0.92)}}var j="Fira Code",bt="'FiraCode Nerd Font Mono', 'FiraCode Nerd Font', 'JetBrainsMono Nerd Font', 'JetBrainsMono NF', 'JetBrains Mono Nerd Font', 'Hack Nerd Font', 'MesloLGS NF', 'MesloLGM Nerd Font', 'CaskaydiaCove Nerd Font', 'SauceCodePro Nerd Font', 'Symbols Nerd Font Mono', 'Symbols Nerd Font', 'PowerlineSymbols'",Ae="Kabmo Nerd Symbols",Me=[j,Ae],ee=`'${j}', ${bt}, '${Ae}', Menlo, Monaco, 'Courier New', monospace`,G=12,ht=16,yt=1e4;function gt(t,r){return Math.max(1,t)*Math.max(1,r)*ht}var Ee=gt(yt,100);var Tt=2000;async function Le(){if(typeof document>"u"||!document.fonts?.load)return;let t=Promise.withResolvers(),r=setTimeout(t.resolve,Tt);try{await Promise.race([document.fonts.load(`${G}px "${j}"`).then(()=>{return},()=>{return}),t.promise])}finally{clearTimeout(r)}}function Ie(t){if(typeof document>"u"||!document.fonts)return()=>{};let r=new Set(Me),l=(c)=>{if([...c.fontfaces].some((u)=>r.has(u.family.replace(/['"]/g,"").trim())))t()};return document.fonts.addEventListener("loadingdone",l),()=>document.fonts.removeEventListener("loadingdone",l)}var Fe=2.5,xt=1;function wt(t,r){let l=t*0.8,c=t*0.2,p=Math.ceil(t*0.6),u=l,b=c,y=typeof document>"u"?null:document.createElement("canvas").getContext("2d");if(y){y.font=`${t}px ${r}`,p=Math.ceil(y.measureText("M").width)||p;let x=y.measureText("Mg");u=x.actualBoundingBoxAscent||l,b=x.actualBoundingBoxDescent||c}return{width:p,height:Math.ceil(u+b+Fe+xt),baseline:Math.round(u+Fe)}}function Ne(t){let r=t.renderer;if(!r)return;r.measureFont=()=>wt(t.options.fontSize??G,t.options.fontFamily??ee),r.remeasureFont()}function Oe(t){let r=t.renderer;if(!r||!t.wasmTerm)return;r.setFontSize(t.options.fontSize??G),r.resize(t.cols,t.rows),r.render(t.wasmTerm,!0,t.viewportY,t)}function vt(t,r,l){if(!l.width||!l.height)return null;return{cols:Math.max(2,Math.floor(t/l.width)),rows:Math.max(1,Math.floor(r/l.height))}}function Pe(t,r){let l=t;l.proposeDimensions=()=>{let c=r.element,p=r.renderer?.getMetrics();if(!c||!p)return;let u=getComputedStyle(c),b=(parseFloat(u.paddingLeft)||0)+(parseFloat(u.paddingRight)||0),y=(parseFloat(u.paddingTop)||0)+(parseFloat(u.paddingBottom)||0);return vt(c.clientWidth-b,c.clientHeight-y,p)??void 0}}function Rt(t){let{cols:r,rows:l,attached:c,committed:p}=t;if(r<10||l<5)return{kind:"ignore"};if(!c)return{kind:"attach",cols:r,rows:l};if(r===p.cols&&l===p.rows)return{kind:"ignore"};return{kind:"change",cols:r,rows:l}}function Be(t){let r={cols:0,rows:0},l=!1,c,p=()=>{if(!t.fit())return;let u=t.current();if(!u)return;let b=Rt({cols:u.cols,rows:u.rows,attached:l,committed:r});if(b.kind==="ignore")return;if(r={cols:b.cols,rows:b.rows},b.kind==="attach"){l=!0,t.onReady(b.cols,b.rows);return}t.onGridChange(b.cols,b.rows)};return{schedule(){clearTimeout(c),c=setTimeout(p,120)},restate(){r={cols:0,rows:0}},isAttached:()=>l,dispose(){clearTimeout(c),c=void 0}}}function Ue(t,r){if(r.type!=="keydown"||!r.shiftKey)return!1;if(r.key==="PageUp")return t.scrollPages(-1),!0;if(r.key==="PageDown")return t.scrollPages(1),!0;if(r.key==="Home")return t.scrollToTop(),!0;if(r.key==="End")return t.scrollToBottom(),!0;if(r.key==="ArrowUp")return t.scrollLines(-1),!0;if(r.key==="ArrowDown")return t.scrollLines(1),!0;return!1}function De(t,r){let l=0,c=(u)=>{if(u.touches.length===1)l=u.touches[0].clientY},p=(u)=>{if(u.touches.length!==1)return;let b=l-u.touches[0].clientY;if(Math.abs(b)<16)return;r()?.scrollLines(Math.trunc(b/16)),l=u.touches[0].clientY};return t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",p,{passive:!0}),()=>{t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",p)}}function St(t){if(t.viewportY<=0&&!t.hasSelection&&!t.pointerHeld)return null;return t.scrollback-t.viewportY}function Ct(t){let r=t.scrollback-t.top;return r>0?r:null}function qe(t){let r={pointerHeld:!1},l=()=>{r.pointerHeld=!0},c=()=>{r.pointerHeld=!1};return t.addEventListener("pointerdown",l,!0),globalThis.addEventListener("pointerup",c),globalThis.addEventListener("pointercancel",c),{get pointerHeld(){return r.pointerHeld},stop(){t.removeEventListener("pointerdown",l,!0),globalThis.removeEventListener("pointerup",c),globalThis.removeEventListener("pointercancel",c)}}}function Ke(t,r,l){let c=St({scrollback:t.getScrollbackLength(),viewportY:t.getViewportY(),hasSelection:t.hasSelection(),pointerHeld:r.pointerHeld});if(l(),c===null)return;let p=Ct({scrollback:t.getScrollbackLength(),top:c});if(p===null)return;let u=p-t.getViewportY();if(u===0)return;try{t.scrollLines(-u)}catch{}}async function He(t,r,l,c){let p=await import("./ghostty-web-2gt2tp72.js"),[u]=await Promise.all([p.Ghostty.load(),Le()]);if(c())return null;let b=r,y=null,x=!1,A,M=null,L=!1,U=(T)=>{let{term:k}=T;k.attachCustomKeyEventHandler((I)=>Ue(k,I)),T.disposables.push(k.onScroll((I)=>l.onScrolledUpChange(I>0)),k.onData((I)=>{let N=Ce(I);if(N.bytes)l.onBinaryInput(N.bytes);else l.onInput(N.text)}),k.onResize(()=>{if(x)return;g.schedule()}))},D=(T)=>{let k=new p.Terminal({cursorBlink:!0,cursorStyle:"block",fontSize:G,fontFamily:ee,theme:ke(T),scrollback:Ee,smoothScrollDuration:0,ghostty:u});k.open(t),Ne(k),k.clear();let I=new p.FitAddon;k.loadAddon(I),Pe(I,k);let N={term:k,fitAddon:I,disposables:[]};return U(N),N},v=(T)=>{if(!T)return;for(let k of T.disposables)try{k.dispose()}catch{}try{T.fitAddon.dispose()}catch{}try{T.term.dispose()}catch{}},E=()=>{if(L)return!1;if(t.clientWidth<=0||t.clientHeight<=0)return!1;let T=y?.term.renderer?.getMetrics();if(!T?.width||!T.height)return!1;try{return y?.fitAddon.fit(),!0}catch{return!1}},P=()=>{if(L)return;x=!1,E(),g.restate(),g.schedule()},h=(T,k,I)=>{let N=y?.term;if(!N)return;if(x=!0,N.cols!==k||N.rows!==I)N.resize(k,I);if(T.length===0){requestAnimationFrame(P);return}N.write(T,P)},g=Be({current:()=>y?.term,fit:E,onReady:l.onReady,onGridChange:l.onGridChange}),B=qe(t);y=D(b),E(),g.schedule();let F=new ResizeObserver(()=>{clearTimeout(A),A=setTimeout(()=>{E(),g.schedule()},35)});F.observe(t);let q=Ie(()=>{let T=y?.term;if(!T)return;Oe(T),E(),g.schedule()}),R=De(t,()=>y?.term??null);return M=requestAnimationFrame(()=>{E(),g.schedule()}),{write(T){let k=y?.term;if(!k)return;Ke(k,B,()=>k.write(T))},writeReplay:h,reset(){let T=y?.term;if(!T)return;T.reset(),T.clear(),E()},focus(){y?.term.focus()},applicationCursorKeys(){return y?.term.wasmTerm?.getMode(1,!1)??!1},getSelection(){return y?.term.getSelection()??""},paste(T){y?.term.paste(T)},scrollToBottom(){y?.term.scrollToBottom()},setTheme(T){if(L||T===b)return;b=T,v(y),y=D(T),E()},dispose(){if(L=!0,M!==null)cancelAnimationFrame(M);clearTimeout(A),g.dispose(),q(),R(),B.stop(),F.disconnect(),v(y),y=null}}}function $e(){let t=null,r=!1;return{request(){if(t)t();else r=!0},attach(l){if(t=l,!r)return;r=!1,l()},detach(){t=null,r=!1}}}var le=Rs(({onInput:t,onBinaryInput:r,onGridChange:l,onReady:c,onReattach:p},u)=>{let{theme:b}=Gp(),y=i(null),x=i(null),[A,M]=n(!1),L=i(null);if(!L.current)L.current=$e();let U=L.current,D=i(t);D.current=t;let v=i(r);v.current=r;let E=i(l);E.current=l;let P=i(c);P.current=c;let h=i(p);h.current=p;let g=i(b);g.current=b,o(()=>{let F=x.current;if(!F)return;F.setTheme(b),h.current?.()},[b]),mo(u,()=>({write(F){x.current?.write(F)},writeReplay(F,q,R){x.current?.writeReplay(F,q,R)},reset(){x.current?.reset()},focus(){U.request()},applicationCursorKeys(){return x.current?.applicationCursorKeys()??!1},getSelection(){return x.current?.getSelection()??""},paste(F){x.current?.paste(F)}}),[]);let B=a(()=>{x.current?.scrollToBottom(),M(!1)},[]);return o(()=>{let F=y.current;if(!F)return;let q=!1;return He(F,g.current,{onInput:(R)=>D.current(R),onBinaryInput:(R)=>v.current(R),onGridChange:(R,T)=>E.current(R,T),onReady:(R,T)=>P.current(R,T),onScrolledUpChange:M},()=>q).then((R)=>{if(!R)return;if(q){R.dispose();return}x.current=R,F.querySelector("textarea")?.setAttribute("data-terminal-input",""),U.attach(()=>x.current?.focus())}),()=>{q=!0,U.detach(),x.current?.dispose(),x.current=null}},[]),e("div",{className:"relative flex-1 w-full h-full overflow-hidden p-2",children:[e("div",{ref:y,"data-terminal-root":"",className:"kabmo-terminal w-full h-full cursor-text",style:{height:"100%",width:"100%"}}),A&&e("button",{type:"button",onClick:B,className:"absolute bottom-3 right-4 z-20 flex items-center space-x-1.5 px-2.5 py-1 bg-paper hover:bg-canvas text-ink border border-ink/20 rounded-full shadow-lg text-[11px] font-mono transition-all animate-fade-in cursor-pointer active:scale-95",title:"Scroll to latest output (Shift+End)",children:[e(jr,{size:12,className:"text-warning"}),e("span",{children:"Latest"})]})]})});le.displayName="RealtimeTerminalView";var ce=new TextEncoder;function Wn({className:t="",enabled:r=!0,rootPath:l,showHeader:c=!0,active:p=!0}){let u=i(null),{isDark:b}=Gp(),y=Ru(),x=i(null),A=Yl(x),[M,L]=n(W),{activeRepo:U,setActiveRepo:D}=lr(l),{repos:v,scanning:E,rescan:P}=cr(l,r),h=i(null),g=i(M);g.current=M;let B=a((C)=>{u.current?.write(C)},[]);o(()=>{if(!p||!r)return;u.current?.focus()},[p,r]);let F=a((C,O)=>{u.current?.writeReplay(C,O.replayCols,O.replayRows)},[]),q=a(()=>{u.current?.reset()},[]),{status:R,shell:T,exitCode:k,error:I,attach:N,resize:z,input:Y,restart:Z,reattach:J}=be({visible:p&&r,root:r?l:void 0,repo:U,theme:b?"dark":"light",onOutput:B,onReplay:F,onRestart:q}),te=a((C,O)=>{h.current={cols:C,rows:O},N(C,O)},[N]),ne=a((C,O)=>{let re=h.current;if(h.current={cols:C,rows:O},!re)return;z(C,O)},[z]),_=a((C)=>{let O=g.current,re=O.ctrl||O.alt,Qe=ve(C,O);if(re&&C.length===1)L(W);Y(ce.encode(Qe))},[Y]),K=a((C)=>{L((O)=>({...O,[C]:!O[C]})),u.current?.focus()},[]),H=a((C)=>{let O=we(C,{applicationCursorKeys:u.current?.applicationCursorKeys()??!1,modifiers:g.current});if(!O)return;Y(ce.encode(O)),L(W),u.current?.focus()},[Y]),X=a(async()=>{let C=u.current?.getSelection()??"";if(!C)return!1;return jt(C)},[]),Ye=a(async()=>{let C=await Jg();if(C===null||C.length===0)return!1;return u.current?.paste(C),u.current?.focus(),!0},[]),Ge=a((C)=>{Y(C)},[Y]),Xe=a((C)=>{Y(ce.encode(`${C}\r`)),u.current?.focus()},[Y]),We=a(()=>{Z()},[Z]),Ve=a(()=>{J()},[J]);if(!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{ref:x,className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,"aria-hidden":!p,style:A>0?{paddingBottom:A}:void 0,children:[c&&e(ge,{status:R,exitCode:k,rootPath:l,activeRepo:U,onSelectRepo:D,repos:v,reposScanning:E,onRefreshRepos:P,shell:T,onRestart:We}),e(Te,{onSelectCommand:Xe,disabled:R!=="running"}),I&&e("div",{className:"px-3 py-1.5 border-b border-error/20 bg-error/5 text-[11px] font-mono text-error flex-shrink-0",children:I}),e("div",{className:"flex-1 w-full min-h-0 bg-canvas overflow-hidden",children:e(le,{ref:u,onInput:_,onBinaryInput:Ge,onReady:te,onGridChange:ne,onReattach:Ve})}),y&&e(Se,{modifiers:M,onToggleModifier:K,onKey:H,onCopy:X,onPaste:Ye,disabled:R!=="running"})]})}export{Wn as TerminalPanel};
|
|
1
|
+
import{d,n,o,i,mo,a,Rs,e,w,Ze,ze,S,lr,cr,s,m,jr,f,wa,_e,mt,qf,jt,Jg,rn,Er,Gp,Yl}from"./index-4c2zcvem.js";import{Ns,hr,Ru}from"./index-fjqp03xe.js";function oe(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID();return`t-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function ie(t){return JSON.stringify(t)}function ue(t){let r=je(t);if(!w(r))return null;if(r.t==="ready"){if(typeof r.id!=="string"||typeof r.cwd!=="string")return null;let l=typeof r.replayBytes==="number"?r.replayBytes:0;return{...r,t:"ready",replayBytes:l}}if(r.t==="exit")return{t:"exit",exitCode:typeof r.exitCode==="number"?r.exitCode:null,signal:typeof r.signal==="string"?r.signal:null};if(r.t==="error"&&typeof r.message==="string")return{t:"error",code:Je(r.code),message:r.message};return null}function me(t){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/terminal/${encodeURIComponent(t)}/ws`}function Je(t){return t==="capacity"||t==="cwd"||t==="shell"||t==="spawn"?t:"unknown"}function je(t){try{return JSON.parse(t)}catch{return null}}function de(t){if(t.buffer instanceof ArrayBuffer)return t;return new Uint8Array(t)}var et=500,tt=8000,nt=4;function pe(t,r){let l=null,c=null,p=0,u=!1,b=!1,y=!1,x=null,A=[],M=0,L=null,U=()=>{let h=new WebSocket(me(t));h.binaryType="arraybuffer",l=h,h.onopen=()=>{if(b)return;if(p=0,u=!0,r.onConnectionChange(!0),x)h.send(ie(x))},h.onmessage=(g)=>{if(b)return;if(g.data instanceof ArrayBuffer){v(new Uint8Array(g.data));return}if(typeof g.data!=="string")return;let B=ue(g.data);if(B)D(B)},h.onclose=()=>{if(l=null,b)return;if(r.onConnectionChange(!1),y=!1,A=[],M=0,L=null,!u)return;if(p+=1,p>nt)return;let g=Math.min(et*2**(p-1),tt);c=setTimeout(()=>{if(c=null,!b)U()},g)},h.onerror=()=>{}},D=(h)=>{if(h.t==="ready"){if(y=!0,L=h,M=h.replayBytes,A=[],r.onReady(h),M===0)E();return}if(h.t==="exit"){r.onExit(h.exitCode,h.signal);return}r.onError(h.code,h.message)},v=(h)=>{if(M<=0){r.onOutput(h);return}if(A.push(h),M-=h.length,M>0)return;E()},E=()=>{let h=L,g=A;if(L=null,A=[],M=0,!h)return;r.onReplay(g.length===1?g[0]:rt(g),h)};U();let P=(h)=>{let g=l;if(!g||g.readyState!==WebSocket.OPEN)return;g.send(ie(h))};return{attach(h,g,B,F,q){if(y)return;let R={t:"attach",cols:h,rows:g};if(B)R.root=B;if(F)R.repo=F;if(q)R.theme=q;x=R,P(R)},resize(h,g){P({t:"resize",cols:h,rows:g})},input(h){let g=l;if(!g||g.readyState!==WebSocket.OPEN)return;g.send(de(h))},close(){P({t:"close"})},release(){if(b=!0,c!==null)clearTimeout(c),c=null;let h=l;if(l=null,!h)return;h.onopen=null,h.onmessage=null,h.onclose=null,h.onerror=null,h.close()}}}function rt(t){let r=0;for(let p of t)r+=p.length;let l=new Uint8Array(r),c=0;for(let p of t)l.set(p,c),c+=p.length;return l}function fe(t){return{connect:t.visible||t.opened,persist:t.ready&&t.visible&&!t.opened}}function be(t={}){let{sessionId:r,ready:l}=Ze(),[c,p]=S("terminal.id",""),[u,b]=S("terminal.opened",!1),y=fe({visible:t.visible===!0,ready:l,opened:u}),[x,A]=n("connecting"),[M,L]=n(""),[U,D]=n(null),[v,E]=n(null),[P,h]=n(0),g=i(null),B=i(null),F=i(t.onOutput);F.current=t.onOutput;let q=i(t.onReplay);q.current=t.onReplay;let R=i(t.onRestart);R.current=t.onRestart;let T=i(t.root);T.current=t.root;let k=i(t.repo);k.current=t.repo;let I=i(t.theme);I.current=t.theme;let N=i(p);N.current=p;let z=i(null);o(()=>{if(!y.persist)return;b(!0)},[y.persist]),o(()=>{if(!y.connect||!l)return;if(ze(r,"terminal.id"))return;N.current(oe())},[y.connect,l,r]),o(()=>{if(!y.connect||!l||!c)return;A("connecting"),E(null),D(null);let _=pe(c,{onReady(H){A("running"),L(H.shell),D(null)},onReplay(H,X){q.current?.(H,X)},onOutput(H){F.current?.(H)},onExit(H){A("exited"),D(H)},onError(H,X){A("error"),E(`${H}: ${X}`)},onConnectionChange(H){if(!H)A("connecting")}});g.current=_;let K=B.current;if(K)_.attach(K.cols,K.rows,T.current,k.current,I.current);return()=>{_.release(),g.current=null}},[y.connect,l,c,P]);let Y=a(()=>{g.current?.close(),R.current?.(),N.current(oe())},[]);o(()=>{if(!l)return;let _=t.root;if(!_)return;let K=`${_}\x00${t.repo??"."}`;if(z.current===null){z.current=K;return}if(z.current===K)return;z.current=K,Y()},[l,t.root,t.repo,Y]);let Z=a((_,K)=>{B.current={cols:_,rows:K},g.current?.attach(_,K,T.current,k.current,I.current)},[]),J=a((_,K)=>{B.current={cols:_,rows:K},g.current?.resize(_,K)},[]),te=a((_)=>{g.current?.input(_)},[]),ne=a(()=>{h((_)=>_+1)},[]);return{status:x,shell:M,exitCode:U,error:v,attach:Z,resize:J,input:te,restart:Y,reattach:ne}}var ot={name:"clipboard-copy",size:24,node:[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]},he=s(ot);var it={name:"zap",size:24,node:[["path",{d:"M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z",key:"1v7up4"}]]},ye=s(it);var at={connecting:"CONNECTING",running:"LIVE",exited:"EXITED",error:"ERROR"},st={connecting:"bg-warning/10 text-warning border-warning/20",running:"bg-success/10 text-success border-success/20",exited:"bg-ink/5 text-ink/60 border-ink/15",error:"bg-error/10 text-error border-error/20"};function ge({status:t,exitCode:r,rootPath:l,activeRepo:c,onSelectRepo:p,repos:u,reposScanning:b,onRefreshRepos:y,shell:x,onRestart:A}){let M=x?x.split("/").pop():"";return e(mt,{left:e(d,{children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:14,className:"text-ink/80 flex-shrink-0"}),e("span",{className:"text-xs font-semibold tracking-wider text-ink uppercase",children:"Terminal"})]}),e("span",{className:`inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono border ${st[t]}`,title:t==="exited"&&r!==null?`Shell exited with code ${r}`:void 0,children:[t==="connecting"&&e(m,{size:10,className:"animate-spin"}),e("span",{children:t==="exited"&&r!==null?`EXIT ${r}`:at[t]})]}),e(hr,{rootPath:l,activeRepo:c,onSelectRepo:p,repos:u,scanning:b,onRefreshRepos:y}),e(qf,{label:"Kill this shell and start a new one",onClick:A,children:e(wa,{size:14})})]}),right:M?e("span",{className:"hidden sm:block text-[10px] font-mono text-ink/40 flex-shrink-0",children:M}):void 0})}var lt=[{label:"bun build",cmd:"bun run build"},{label:"bun test",cmd:"bun test"},{label:"git status",cmd:"git status -s"},{label:"git diff",cmd:"git diff"},{label:"ls -la",cmd:"ls -la"},{label:"pwd",cmd:"pwd"},{label:"bun -v",cmd:"bun --version"}];function Te({onSelectCommand:t,disabled:r}){return e("div",{className:"flex flex-wrap items-center gap-1.5 px-3 py-1.5 bg-paper border-b border-ink/10 flex-shrink-0",children:[e("div",{className:"flex items-center space-x-1 text-[10px] font-mono text-ink/50 uppercase tracking-wider flex-shrink-0 select-none",children:[e(ye,{size:11,className:"text-warning"}),e("span",{children:"Quick:"})]}),lt.map((l)=>e("button",{type:"button",disabled:r,onClick:()=>t(l.cmd),className:"px-2 py-0.5 rounded text-[10px] font-mono bg-canvas hover:bg-ink/5 active:bg-ink/10 text-ink/80 hover:text-ink border border-ink/15 transition-all whitespace-nowrap disabled:opacity-40 cursor-pointer shadow-2xs",children:l.label},l.cmd))]})}var W=Object.freeze({ctrl:!1,alt:!1}),ae=[{id:"escape",label:"Esc",name:"Escape",sequence:"\x1B"},{id:"tab",label:"Tab",name:"Tab",sequence:"\t"},{id:"interrupt",label:"^C",name:"Ctrl+C — interrupt",sequence:"\x03"},{id:"left",label:"←",name:"Left arrow",csi:{prefix:"1",final:"D",application:"OD"}},{id:"up",label:"↑",name:"Up arrow",csi:{prefix:"1",final:"A",application:"OA"}},{id:"down",label:"↓",name:"Down arrow",csi:{prefix:"1",final:"B",application:"OB"}},{id:"right",label:"→",name:"Right arrow",csi:{prefix:"1",final:"C",application:"OC"}},{id:"home",label:"Home",name:"Home",csi:{prefix:"1",final:"H",application:"OH",terminfo:"\x1BOH"}},{id:"end",label:"End",name:"End",csi:{prefix:"1",final:"F",application:"OF",terminfo:"\x1BOF"}},{id:"pageUp",label:"PgUp",name:"Page up",csi:{prefix:"5",final:"~"}},{id:"pageDown",label:"PgDn",name:"Page down",csi:{prefix:"6",final:"~"}},{id:"delete",label:"Del",name:"Delete",csi:{prefix:"3",final:"~"}},{id:"shiftTab",label:"⇧Tab",name:"Shift+Tab",sequence:"\x1B[Z"},{id:"eof",label:"^D",name:"Ctrl+D — end of input",sequence:"\x04"},{id:"clear",label:"^L",name:"Ctrl+L — clear screen",sequence:"\f"}],se=[{id:"pipe",label:"|",name:"Pipe",sequence:"|"},{id:"tilde",label:"~",name:"Tilde",sequence:"~"},{id:"dollar",label:"$",name:"Dollar",sequence:"$"},{id:"asterisk",label:"*",name:"Asterisk",sequence:"*"},{id:"question",label:"?",name:"Question mark",sequence:"?"},{id:"underscore",label:"_",name:"Underscore",sequence:"_"},{id:"backslash",label:"\\",name:"Backslash",sequence:"\\"},{id:"slash",label:"/",name:"Slash",sequence:"/"},{id:"minus",label:"-",name:"Minus",sequence:"-"},{id:"equals",label:"=",name:"Equals",sequence:"="},{id:"plus",label:"+",name:"Plus",sequence:"+"},{id:"ampersand",label:"&",name:"Ampersand",sequence:"&"},{id:"semicolon",label:";",name:"Semicolon",sequence:";"},{id:"colon",label:":",name:"Colon",sequence:":"},{id:"comma",label:",",name:"Comma",sequence:","},{id:"dot",label:".",name:"Period",sequence:"."},{id:"at",label:"@",name:"At sign",sequence:"@"},{id:"percent",label:"%",name:"Percent",sequence:"%"},{id:"caret",label:"^",name:"Caret",sequence:"^"},{id:"hash",label:"#",name:"Hash",sequence:"#"},{id:"bang",label:"!",name:"Exclamation mark",sequence:"!"},{id:"parenOpen",label:"(",name:"Open parenthesis",sequence:"("},{id:"parenClose",label:")",name:"Close parenthesis",sequence:")"},{id:"bracketOpen",label:"[",name:"Open bracket",sequence:"["},{id:"bracketClose",label:"]",name:"Close bracket",sequence:"]"},{id:"braceOpen",label:"{",name:"Open brace",sequence:"{"},{id:"braceClose",label:"}",name:"Close brace",sequence:"}"},{id:"lessThan",label:"<",name:"Less than",sequence:"<"},{id:"greaterThan",label:">",name:"Greater than",sequence:">"},{id:"quote",label:"'",name:"Single quote",sequence:"'"},{id:"doubleQuote",label:'"',name:"Double quote",sequence:'"'},{id:"backtick",label:"`",name:"Backtick",sequence:"`"}],xe={};for(let t of[...ae,...se])xe[t.id]=t;function we(t,r={}){let l=xe[t];if(!l)return"";let c=r.modifiers??W;if(l.csi)return ct(l.csi,c,r.applicationCursorKeys??!1);let p=l.sequence??"";return c.alt?`\x1B${p}`:p}function ct(t,r,l){let c=ut(r);if(c!==null)return`\x1B[${t.prefix};${c}${t.final}`;if(t.terminfo)return t.terminfo;if(l&&t.application)return`\x1B${t.application}`;return`\x1B[${t.prefix==="1"?"":t.prefix}${t.final}`}function ut(t){let r=(t.alt?2:0)|(t.ctrl?4:0);return r===0?null:r+1}function ve(t,r){if(t.length!==1)return t;let l=t;if(r.ctrl)l=pt(l)??l;if(r.alt)l=`\x1B${l}`;return l}var dt={"@":"\x00"," ":"\x00","":"\b","[":"\x1B","\\":"\x1C","]":"\x1D","^":"\x1E",_:"\x1F","?":""};function pt(t){if(t.length!==1)return null;let r=t.charCodeAt(0);if(r>=97&&r<=122)return String.fromCharCode(r-96);if(r>=65&&r<=90)return String.fromCharCode(r-64);return dt[t]??null}var ft=[{modifier:"ctrl",label:"Ctrl",name:"Ctrl — applies to the next key"},{modifier:"alt",label:"Alt",name:"Alt / meta — applies to the next key"}],V="flex items-center justify-center h-8 min-w-8 px-1.5 rounded border font-mono transition-colors cursor-pointer select-none disabled:opacity-40 disabled:cursor-default text-[11px] @[420px]:h-9 @[420px]:min-w-10 @[420px]:text-xs",Q="bg-canvas text-ink/80 border-ink/15 hover:text-ink hover:bg-ink/5 active:bg-ink/10",Re="bg-ink text-canvas border-ink";function Se({modifiers:t,onToggleModifier:r,onKey:l,onCopy:c,onPaste:p,disabled:u}){let[b,y]=n(!1),[x,A]=n(null),M=t.ctrl||t.alt,L=(v)=>{A(v),setTimeout(()=>A((E)=>E===v?null:E),1500)},U=async()=>{L(await c()?"copied":"empty")},D=async()=>{if(!await p())L("pasteFailed")};return e("div",{className:"@container flex flex-col gap-1 px-2 py-1.5 border-t border-ink/10 bg-paper flex-shrink-0",onPointerDown:(v)=>v.preventDefault(),children:[e("div",{className:"flex flex-wrap items-center gap-1",children:[ft.map(({modifier:v,label:E,name:P})=>e("button",{type:"button",onClick:()=>r(v),"aria-pressed":t[v],title:P,"aria-label":P,className:`${V} ${t[v]?Re:Q}`,children:E},v)),M&&e("span",{className:"text-[10px] font-mono text-ink/50 px-0.5 whitespace-nowrap","aria-hidden":!0,children:"next"}),e("span",{className:"w-px h-5 bg-ink/15 flex-shrink-0","aria-hidden":!0}),e("button",{type:"button",onClick:U,disabled:u,title:x==="empty"?"Nothing selected":"Copy selection","aria-label":"Copy selection",className:`${V} ${x==="empty"?"bg-warning/10 text-warning border-warning/30":Q}`,children:[x==="copied"?e(f,{size:13}):e(he,{size:13}),e("span",{className:"pl-1",children:"Copy"})]}),e("button",{type:"button",onClick:D,disabled:u,title:x==="pasteFailed"?"Clipboard unavailable":"Paste into the shell","aria-label":"Paste into the shell",className:`${V} ${x==="pasteFailed"?"bg-error/10 text-error border-error/30":Q}`,children:[e(Ns,{size:13}),e("span",{className:"pl-1",children:"Paste"})]}),e("button",{type:"button",onClick:()=>y((v)=>!v),"aria-pressed":b,title:b?"Show control keys":"Show symbols","aria-label":b?"Show control keys":"Show symbols",className:`${V} ml-auto ${b?Re:Q}`,children:b?"ABC":"123"})]}),e("div",{className:"flex flex-wrap items-center gap-1",children:(b?se:ae).map((v)=>e("button",{type:"button",disabled:u,onClick:()=>l(v.id),title:v.name,"aria-label":v.name,className:`${V} ${Q}`,children:v.label},v.id))})]})}function Ce(t){if(!t.startsWith("\x1B[M")||t.length<6)return{text:t};let r=new Uint8Array(t.length);for(let l=0;l<t.length;l+=1)r[l]=t.charCodeAt(l)&255;return{bytes:r}}function ke(t){let r=rn(t),{canvas:l,ink:c,paper:p}=r,u=(y)=>Er(y,c,0.2),b=(y)=>Er(l,c,y);return{background:"transparent",foreground:c,cursor:r.meta,cursorAccent:p,selectionBackground:b(0.28),selectionForeground:c,black:b(0.2),red:r.error,green:r.success,yellow:r.warning,blue:r.info,magenta:r.meta,cyan:Er(r.info,r.success,0.5),white:b(0.75),brightBlack:b(0.5),brightRed:u(r.error),brightGreen:u(r.success),brightYellow:u(r.warning),brightBlue:u(r.info),brightMagenta:u(r.meta),brightCyan:u(Er(r.info,r.success,0.5)),brightWhite:b(0.92)}}var j="Fira Code",bt="'FiraCode Nerd Font Mono', 'FiraCode Nerd Font', 'JetBrainsMono Nerd Font', 'JetBrainsMono NF', 'JetBrains Mono Nerd Font', 'Hack Nerd Font', 'MesloLGS NF', 'MesloLGM Nerd Font', 'CaskaydiaCove Nerd Font', 'SauceCodePro Nerd Font', 'Symbols Nerd Font Mono', 'Symbols Nerd Font', 'PowerlineSymbols'",Ae="Kabmo Nerd Symbols",Me=[j,Ae],ee=`'${j}', ${bt}, '${Ae}', Menlo, Monaco, 'Courier New', monospace`,G=12,ht=16,yt=1e4;function gt(t,r){return Math.max(1,t)*Math.max(1,r)*ht}var Ee=gt(yt,100);var Tt=2000;async function Le(){if(typeof document>"u"||!document.fonts?.load)return;let t=Promise.withResolvers(),r=setTimeout(t.resolve,Tt);try{await Promise.race([document.fonts.load(`${G}px "${j}"`).then(()=>{return},()=>{return}),t.promise])}finally{clearTimeout(r)}}function Ie(t){if(typeof document>"u"||!document.fonts)return()=>{};let r=new Set(Me),l=(c)=>{if([...c.fontfaces].some((u)=>r.has(u.family.replace(/['"]/g,"").trim())))t()};return document.fonts.addEventListener("loadingdone",l),()=>document.fonts.removeEventListener("loadingdone",l)}var Fe=2.5,xt=1;function wt(t,r){let l=t*0.8,c=t*0.2,p=Math.ceil(t*0.6),u=l,b=c,y=typeof document>"u"?null:document.createElement("canvas").getContext("2d");if(y){y.font=`${t}px ${r}`,p=Math.ceil(y.measureText("M").width)||p;let x=y.measureText("Mg");u=x.actualBoundingBoxAscent||l,b=x.actualBoundingBoxDescent||c}return{width:p,height:Math.ceil(u+b+Fe+xt),baseline:Math.round(u+Fe)}}function Ne(t){let r=t.renderer;if(!r)return;r.measureFont=()=>wt(t.options.fontSize??G,t.options.fontFamily??ee),r.remeasureFont()}function Oe(t){let r=t.renderer;if(!r||!t.wasmTerm)return;r.setFontSize(t.options.fontSize??G),r.resize(t.cols,t.rows),r.render(t.wasmTerm,!0,t.viewportY,t)}function vt(t,r,l){if(!l.width||!l.height)return null;return{cols:Math.max(2,Math.floor(t/l.width)),rows:Math.max(1,Math.floor(r/l.height))}}function Pe(t,r){let l=t;l.proposeDimensions=()=>{let c=r.element,p=r.renderer?.getMetrics();if(!c||!p)return;let u=getComputedStyle(c),b=(parseFloat(u.paddingLeft)||0)+(parseFloat(u.paddingRight)||0),y=(parseFloat(u.paddingTop)||0)+(parseFloat(u.paddingBottom)||0);return vt(c.clientWidth-b,c.clientHeight-y,p)??void 0}}function Rt(t){let{cols:r,rows:l,attached:c,committed:p}=t;if(r<10||l<5)return{kind:"ignore"};if(!c)return{kind:"attach",cols:r,rows:l};if(r===p.cols&&l===p.rows)return{kind:"ignore"};return{kind:"change",cols:r,rows:l}}function Be(t){let r={cols:0,rows:0},l=!1,c,p=()=>{if(!t.fit())return;let u=t.current();if(!u)return;let b=Rt({cols:u.cols,rows:u.rows,attached:l,committed:r});if(b.kind==="ignore")return;if(r={cols:b.cols,rows:b.rows},b.kind==="attach"){l=!0,t.onReady(b.cols,b.rows);return}t.onGridChange(b.cols,b.rows)};return{schedule(){clearTimeout(c),c=setTimeout(p,120)},restate(){r={cols:0,rows:0}},isAttached:()=>l,dispose(){clearTimeout(c),c=void 0}}}function Ue(t,r){if(r.type!=="keydown"||!r.shiftKey)return!1;if(r.key==="PageUp")return t.scrollPages(-1),!0;if(r.key==="PageDown")return t.scrollPages(1),!0;if(r.key==="Home")return t.scrollToTop(),!0;if(r.key==="End")return t.scrollToBottom(),!0;if(r.key==="ArrowUp")return t.scrollLines(-1),!0;if(r.key==="ArrowDown")return t.scrollLines(1),!0;return!1}function De(t,r){let l=0,c=(u)=>{if(u.touches.length===1)l=u.touches[0].clientY},p=(u)=>{if(u.touches.length!==1)return;let b=l-u.touches[0].clientY;if(Math.abs(b)<16)return;r()?.scrollLines(Math.trunc(b/16)),l=u.touches[0].clientY};return t.addEventListener("touchstart",c,{passive:!0}),t.addEventListener("touchmove",p,{passive:!0}),()=>{t.removeEventListener("touchstart",c),t.removeEventListener("touchmove",p)}}function St(t){if(t.viewportY<=0&&!t.hasSelection&&!t.pointerHeld)return null;return t.scrollback-t.viewportY}function Ct(t){let r=t.scrollback-t.top;return r>0?r:null}function qe(t){let r={pointerHeld:!1},l=()=>{r.pointerHeld=!0},c=()=>{r.pointerHeld=!1};return t.addEventListener("pointerdown",l,!0),globalThis.addEventListener("pointerup",c),globalThis.addEventListener("pointercancel",c),{get pointerHeld(){return r.pointerHeld},stop(){t.removeEventListener("pointerdown",l,!0),globalThis.removeEventListener("pointerup",c),globalThis.removeEventListener("pointercancel",c)}}}function Ke(t,r,l){let c=St({scrollback:t.getScrollbackLength(),viewportY:t.getViewportY(),hasSelection:t.hasSelection(),pointerHeld:r.pointerHeld});if(l(),c===null)return;let p=Ct({scrollback:t.getScrollbackLength(),top:c});if(p===null)return;let u=p-t.getViewportY();if(u===0)return;try{t.scrollLines(-u)}catch{}}async function He(t,r,l,c){let p=await import("./ghostty-web-2gt2tp72.js"),[u]=await Promise.all([p.Ghostty.load(),Le()]);if(c())return null;let b=r,y=null,x=!1,A,M=null,L=!1,U=(T)=>{let{term:k}=T;k.attachCustomKeyEventHandler((I)=>Ue(k,I)),T.disposables.push(k.onScroll((I)=>l.onScrolledUpChange(I>0)),k.onData((I)=>{let N=Ce(I);if(N.bytes)l.onBinaryInput(N.bytes);else l.onInput(N.text)}),k.onResize(()=>{if(x)return;g.schedule()}))},D=(T)=>{let k=new p.Terminal({cursorBlink:!0,cursorStyle:"block",fontSize:G,fontFamily:ee,theme:ke(T),scrollback:Ee,smoothScrollDuration:0,ghostty:u});k.open(t),Ne(k),k.clear();let I=new p.FitAddon;k.loadAddon(I),Pe(I,k);let N={term:k,fitAddon:I,disposables:[]};return U(N),N},v=(T)=>{if(!T)return;for(let k of T.disposables)try{k.dispose()}catch{}try{T.fitAddon.dispose()}catch{}try{T.term.dispose()}catch{}},E=()=>{if(L)return!1;if(t.clientWidth<=0||t.clientHeight<=0)return!1;let T=y?.term.renderer?.getMetrics();if(!T?.width||!T.height)return!1;try{return y?.fitAddon.fit(),!0}catch{return!1}},P=()=>{if(L)return;x=!1,E(),g.restate(),g.schedule()},h=(T,k,I)=>{let N=y?.term;if(!N)return;if(x=!0,N.cols!==k||N.rows!==I)N.resize(k,I);if(T.length===0){requestAnimationFrame(P);return}N.write(T,P)},g=Be({current:()=>y?.term,fit:E,onReady:l.onReady,onGridChange:l.onGridChange}),B=qe(t);y=D(b),E(),g.schedule();let F=new ResizeObserver(()=>{clearTimeout(A),A=setTimeout(()=>{E(),g.schedule()},35)});F.observe(t);let q=Ie(()=>{let T=y?.term;if(!T)return;Oe(T),E(),g.schedule()}),R=De(t,()=>y?.term??null);return M=requestAnimationFrame(()=>{E(),g.schedule()}),{write(T){let k=y?.term;if(!k)return;Ke(k,B,()=>k.write(T))},writeReplay:h,reset(){let T=y?.term;if(!T)return;T.reset(),T.clear(),E()},focus(){y?.term.focus()},applicationCursorKeys(){return y?.term.wasmTerm?.getMode(1,!1)??!1},getSelection(){return y?.term.getSelection()??""},paste(T){y?.term.paste(T)},scrollToBottom(){y?.term.scrollToBottom()},setTheme(T){if(L||T===b)return;b=T,v(y),y=D(T),E()},dispose(){if(L=!0,M!==null)cancelAnimationFrame(M);clearTimeout(A),g.dispose(),q(),R(),B.stop(),F.disconnect(),v(y),y=null}}}function $e(){let t=null,r=!1;return{request(){if(t)t();else r=!0},attach(l){if(t=l,!r)return;r=!1,l()},detach(){t=null,r=!1}}}var le=Rs(({onInput:t,onBinaryInput:r,onGridChange:l,onReady:c,onReattach:p},u)=>{let{theme:b}=Gp(),y=i(null),x=i(null),[A,M]=n(!1),L=i(null);if(!L.current)L.current=$e();let U=L.current,D=i(t);D.current=t;let v=i(r);v.current=r;let E=i(l);E.current=l;let P=i(c);P.current=c;let h=i(p);h.current=p;let g=i(b);g.current=b,o(()=>{let F=x.current;if(!F)return;F.setTheme(b),h.current?.()},[b]),mo(u,()=>({write(F){x.current?.write(F)},writeReplay(F,q,R){x.current?.writeReplay(F,q,R)},reset(){x.current?.reset()},focus(){U.request()},applicationCursorKeys(){return x.current?.applicationCursorKeys()??!1},getSelection(){return x.current?.getSelection()??""},paste(F){x.current?.paste(F)}}),[]);let B=a(()=>{x.current?.scrollToBottom(),M(!1)},[]);return o(()=>{let F=y.current;if(!F)return;let q=!1;return He(F,g.current,{onInput:(R)=>D.current(R),onBinaryInput:(R)=>v.current(R),onGridChange:(R,T)=>E.current(R,T),onReady:(R,T)=>P.current(R,T),onScrolledUpChange:M},()=>q).then((R)=>{if(!R)return;if(q){R.dispose();return}x.current=R,F.querySelector("textarea")?.setAttribute("data-terminal-input",""),U.attach(()=>x.current?.focus())}),()=>{q=!0,U.detach(),x.current?.dispose(),x.current=null}},[]),e("div",{className:"relative flex-1 w-full h-full overflow-hidden p-2",children:[e("div",{ref:y,"data-terminal-root":"",className:"kabmo-terminal w-full h-full cursor-text",style:{height:"100%",width:"100%"}}),A&&e("button",{type:"button",onClick:B,className:"absolute bottom-3 right-4 z-20 flex items-center space-x-1.5 px-2.5 py-1 bg-paper hover:bg-canvas text-ink border border-ink/20 rounded-full shadow-lg text-[11px] font-mono transition-all animate-fade-in cursor-pointer active:scale-95",title:"Scroll to latest output (Shift+End)",children:[e(jr,{size:12,className:"text-warning"}),e("span",{children:"Latest"})]})]})});le.displayName="RealtimeTerminalView";var ce=new TextEncoder;function Wn({className:t="",enabled:r=!0,rootPath:l,showHeader:c=!0,active:p=!0}){let u=i(null),{isDark:b}=Gp(),y=Ru(),x=i(null),A=Yl(x),[M,L]=n(W),{activeRepo:U,setActiveRepo:D}=lr(l),{repos:v,scanning:E,rescan:P}=cr(l,r),h=i(null),g=i(M);g.current=M;let B=a((C)=>{u.current?.write(C)},[]);o(()=>{if(!p||!r)return;u.current?.focus()},[p,r]);let F=a((C,O)=>{u.current?.writeReplay(C,O.replayCols,O.replayRows)},[]),q=a(()=>{u.current?.reset()},[]),{status:R,shell:T,exitCode:k,error:I,attach:N,resize:z,input:Y,restart:Z,reattach:J}=be({visible:p&&r,root:r?l:void 0,repo:U,theme:b?"dark":"light",onOutput:B,onReplay:F,onRestart:q}),te=a((C,O)=>{h.current={cols:C,rows:O},N(C,O)},[N]),ne=a((C,O)=>{let re=h.current;if(h.current={cols:C,rows:O},!re)return;z(C,O)},[z]),_=a((C)=>{let O=g.current,re=O.ctrl||O.alt,Qe=ve(C,O);if(re&&C.length===1)L(W);Y(ce.encode(Qe))},[Y]),K=a((C)=>{L((O)=>({...O,[C]:!O[C]})),u.current?.focus()},[]),H=a((C)=>{let O=we(C,{applicationCursorKeys:u.current?.applicationCursorKeys()??!1,modifiers:g.current});if(!O)return;Y(ce.encode(O)),L(W),u.current?.focus()},[Y]),X=a(async()=>{let C=u.current?.getSelection()??"";if(!C)return!1;return jt(C)},[]),Ye=a(async()=>{let C=await Jg();if(C===null||C.length===0)return!1;return u.current?.paste(C),u.current?.focus(),!0},[]),Ge=a((C)=>{Y(C)},[Y]),Xe=a((C)=>{Y(ce.encode(`${C}\r`)),u.current?.focus()},[Y]),We=a(()=>{Z()},[Z]),Ve=a(()=>{J()},[J]);if(!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{ref:x,className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,"aria-hidden":!p,style:A>0?{paddingBottom:A}:void 0,children:[c&&e(ge,{status:R,exitCode:k,rootPath:l,activeRepo:U,onSelectRepo:D,repos:v,reposScanning:E,onRefreshRepos:P,shell:T,onRestart:We}),e(Te,{onSelectCommand:Xe,disabled:R!=="running"}),I&&e("div",{className:"px-3 py-1.5 border-b border-error/20 bg-error/5 text-[11px] font-mono text-error flex-shrink-0",children:I}),e("div",{className:"flex-1 w-full min-h-0 bg-canvas overflow-hidden",children:e(le,{ref:u,onInput:_,onBinaryInput:Ge,onReady:te,onGridChange:ne,onReattach:Ve})}),y&&e(Se,{modifiers:M,onToggleModifier:K,onKey:H,onCopy:X,onPaste:Ye,disabled:R!=="running"})]})}export{Wn as TerminalPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t,l,$t,C,X,te,R,p,ue}from"./index-
|
|
1
|
+
import{t,l,$t,C,X,te,R,p,ue}from"./index-y5ymgp20.js";var M="",O="",D="",E=[],N=new Map,S=t((e)=>X(e,p()),"sanitizeText"),z=t((e)=>{switch(e.type){case"terminal":return{...e,value:S(e.value)};case"nonterminal":return{...e,name:S(e.name)};case"sequence":return{...e,elements:e.elements.map(z)};case"choice":return{...e,alternatives:e.alternatives.map(z)};case"optional":return{...e,element:z(e.element)};case"repetition":return{...e,element:z(e.element),separator:e.separator?z(e.separator):void 0};case"special":return{...e,text:S(e.text)}}},"sanitizeAstNode"),q=t(()=>{M="",O="",D="",E.length=0,N.clear(),R(),l.debug("[Railroad] Database cleared")},"clear"),Y=t((e)=>{M=S(e),l.debug("[Railroad] Title set:",e)},"setTitle"),P=t(()=>M,"getTitle"),G=t((e)=>{let n={...e,name:S(e.name),definition:z(e.definition),comment:e.comment?S(e.comment):void 0};if(l.debug("[Railroad] Adding rule:",n.name),N.has(n.name))l.warn(`[Railroad] Rule '${n.name}' is already defined. Overwriting.`);E.push(n),N.set(n.name,n)},"addRule"),U=t(()=>E,"getRules"),j=t((e)=>N.get(e),"getRule"),K=t((e)=>{O=S(e).replace(/^\s+/g,""),l.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),J=t(()=>O,"getAccTitle"),Q=t((e)=>{D=S(e).replace(/\n\s+/g,`
|
|
2
2
|
`),l.debug("[Railroad] Accessibility description set:",e)},"setAccDescription"),Z=t(()=>D,"getAccDescription"),V=Y,ee=P,Re={clear:q,setTitle:Y,getTitle:P,addRule:G,getRules:U,getRule:j,setAccTitle:K,getAccTitle:J,setAccDescription:Q,getAccDescription:Z,setDiagramTitle:V,getDiagramTitle:ee},T={compactMode:!1,padding:10,verticalSeparation:8,horizontalSeparation:10,arcRadius:10,fontSize:14,fontFamily:"monospace",terminalFill:"#FFFFC0",terminalStroke:"#000000",terminalTextColor:"#000000",nonTerminalFill:"#FFFFFF",nonTerminalStroke:"#000000",nonTerminalTextColor:"#000000",lineColor:"#000000",strokeWidth:2,markerFill:"#000000",commentFill:"#E8E8E8",commentStroke:"#888888",commentTextColor:"#666666",specialFill:"#F0E0FF",specialStroke:"#8800CC",ruleNameColor:"#000066",showMarkers:!0,markerRadius:5},re=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\([\d\s%+,./-]+\)$|^[a-z]+$/i,ie=/^[\w "',.-]+$/,ne=new Set(["compactMode","padding","verticalSeparation","horizontalSeparation","arcRadius","fontSize","fontFamily","terminalFill","terminalStroke","terminalTextColor","nonTerminalFill","nonTerminalStroke","nonTerminalTextColor","lineColor","strokeWidth","markerFill","commentFill","commentStroke","commentTextColor","specialFill","specialStroke","ruleNameColor","showMarkers","markerRadius"]),L=t((e)=>{if(!e)return!1;return Object.keys(e).every((n)=>n==="railroad"||ne.has(n))},"isRailroadStyleOptions"),ae=t((e)=>{if(!e)return{};if("railroad"in e&&e.railroad)return e.railroad;return L(e)?e:{}},"extractRailroadOverrides"),oe=t((e)=>{if(!e||L(e))return{};let{railroad:n,svgId:o,theme:i,look:r,...a}=e;return a},"extractThemeOverrides"),u=t((e,n)=>{if(typeof e!=="string")return n;let o=e.trim();return re.test(o)?o:n},"sanitizeColorValue"),I=t((e,n)=>{if(typeof e!=="string")return n;let o=e.trim();return ie.test(o)?o:n},"sanitizeFontFamilyValue"),y=t((e,n)=>{let o=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(o)&&o>=0?o:n},"sanitizeNumberValue"),le=t((e)=>{let n=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)&&n>0?n:void 0},"parseThemeFontSize"),se=t((e)=>{let n=I(e.fontFamily,T.fontFamily),o=le(e.fontSize)??T.fontSize;return{...T,fontFamily:n,fontSize:o,terminalFill:u(e.secondBkg??e.secondaryColor,T.terminalFill),terminalStroke:u(e.secondaryBorderColor??e.lineColor,T.terminalStroke),terminalTextColor:u(e.secondaryTextColor??e.textColor,T.terminalTextColor),nonTerminalFill:u(e.mainBkg??e.background,T.nonTerminalFill),nonTerminalStroke:u(e.primaryBorderColor??e.lineColor,T.nonTerminalStroke),nonTerminalTextColor:u(e.primaryTextColor??e.textColor,T.nonTerminalTextColor),lineColor:u(e.lineColor,T.lineColor),markerFill:u(e.lineColor,T.markerFill),commentFill:u(e.labelBackground??e.tertiaryColor,T.commentFill),commentStroke:u(e.tertiaryBorderColor??e.lineColor,T.commentStroke),commentTextColor:u(e.tertiaryTextColor??e.textColor,T.commentTextColor),specialFill:u(e.tertiaryColor??e.secondaryColor,T.specialFill),specialStroke:u(e.tertiaryBorderColor??e.secondaryBorderColor,T.specialStroke),ruleNameColor:u(e.titleColor??e.textColor,T.ruleNameColor)}},"buildThemeDefaults"),W=t((e)=>{let n=C(),o={...$t(),...n.themeVariables??{},...oe(e)},i=se(o),r={...n.railroad??{},...ae(e)};return{compactMode:r.compactMode??i.compactMode,padding:y(r.padding,i.padding),verticalSeparation:y(r.verticalSeparation,i.verticalSeparation),horizontalSeparation:y(r.horizontalSeparation,i.horizontalSeparation),arcRadius:y(r.arcRadius,i.arcRadius),fontSize:y(r.fontSize,i.fontSize),fontFamily:I(r.fontFamily,i.fontFamily),terminalFill:u(r.terminalFill,i.terminalFill),terminalStroke:u(r.terminalStroke,i.terminalStroke),terminalTextColor:u(r.terminalTextColor,i.terminalTextColor),nonTerminalFill:u(r.nonTerminalFill,i.nonTerminalFill),nonTerminalStroke:u(r.nonTerminalStroke,i.nonTerminalStroke),nonTerminalTextColor:u(r.nonTerminalTextColor,i.nonTerminalTextColor),lineColor:u(r.lineColor,i.lineColor),strokeWidth:y(r.strokeWidth,i.strokeWidth),markerFill:u(r.markerFill,i.markerFill),commentFill:u(r.commentFill,i.commentFill),commentStroke:u(r.commentStroke,i.commentStroke),commentTextColor:u(r.commentTextColor,i.commentTextColor),specialFill:u(r.specialFill,i.specialFill),specialStroke:u(r.specialStroke,i.specialStroke),ruleNameColor:u(r.ruleNameColor,i.ruleNameColor),showMarkers:r.showMarkers??i.showMarkers,markerRadius:y(r.markerRadius,i.markerRadius)}},"buildRailroadStyleOptions"),Na=t((e)=>{let{fontFamily:n,fontSize:o,terminalFill:i,terminalStroke:r,terminalTextColor:a,nonTerminalFill:g,nonTerminalStroke:c,nonTerminalTextColor:s,lineColor:f,strokeWidth:h,markerFill:m,commentFill:k,commentStroke:d,commentTextColor:x,specialFill:b,specialStroke:F,ruleNameColor:v}=W(e);return`
|
|
3
3
|
.railroad-diagram {
|
|
4
4
|
font-family: ${n};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t}from"./index-
|
|
1
|
+
import{t}from"./index-y5ymgp20.js";function be(c,e){if(c.accDescr)e.setAccDescription?.(c.accDescr);if(c.accTitle)e.setAccTitle?.(c.accTitle);if(c.title)e.setDiagramTitle?.(c.title)}t(be,"populateCommonDb");
|
|
2
2
|
export{be};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d,n,o,W,i,u,a,br,e,yr,fo,Wn,Ep,we,S,Ip,Gf,lr,cr,s,$a,Be,za,m,Dn,L,_,Xe,f,B,ie,et,re,fe,ge,Rn,nn,Fn,Y,D,wa,O,ko,ln,b,mt,at,pe,Mu,ii,J,it,st,ft,je,he}from"./index-3fw3sd10.js";import{kp,hr}from"./index-270y5r9k.js";var Dt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},_e=s(Dt);var Bt={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},Ue=s(Bt);function We({message:t,hasStagedChanges:c,isBusy:l=!1,amend:r=!1,seeded:p=!1,onToggleAmend:h,onChangeMessage:g,onCommit:v}){let y=t.trim().length>0&&!l&&(r||c),P=r?"Rewrite the previous commit with this message":c?"Commit staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[e("textarea",{value:t,onChange:(C)=>g(C.currentTarget.value),onKeyDown:(C)=>{if(C.key==="Enter"&&(C.metaKey||C.ctrlKey)&&y)C.preventDefault(),v()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("div",{className:"flex items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(C)=>h?.(C.currentTarget.checked),className:`${he} accent-ink cursor-pointer`}),"Amend"]}),r&&p&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:v,disabled:!y,title:P,className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function qe({operation:t,conflicts:c,isBusy:l,onAbort:r,onContinue:p}){let h=fo[t],g=c.length,v=g===0,y=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(_,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"font-medium",children:[h.charAt(0).toUpperCase()+h.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success":"text-warning"}`,children:v?"all conflicts resolved":`${g} conflict${g===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning/90 space-y-0.5",children:c.map((P)=>e("div",{className:"truncate",title:P,children:P},P))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:l,title:`Abort the ${h} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(ln,{size:12}),"Abort ",h]}),y&&e("button",{type:"button",onClick:p,disabled:l||!v,title:v?`Conclude the ${h}`:`Resolve all ${g} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Rn,{size:12}),"Continue ",h]})]})]})}function Ke({branchRef:t,showBranchMenu:c,setShowBranchMenu:l,branch:r,branches:p,remoteBranches:h,onCheckout:g,onMerge:v,onOpenBranchPrompt:y,onManageBranches:P,optionsRef:C,showOptions:R,setShowOptions:N,onHistory:G,onGraph:M,viewMode:k,setViewMode:x,isBusy:w=!1,syncCount:A={ahead:0,behind:0},syncing:T=!1,onSync:E,onFetch:q,detached:U=!1}){return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>l(!c),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:U?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(ge,{size:12,className:U?"text-warning":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${U?"font-mono text-warning":""}`,children:r}),e(B,{size:12,className:"text-ink/40"})]}),c&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-56 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[p.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),p.map((H)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(H),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:H}),r===H&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==H&&e("button",{type:"button",onClick:()=>{v(H),l(!1)},title:`Merge ${H} into ${r}`,"aria-label":`Merge ${H} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Rn,{size:12})})]},H))]}),h.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),h.map((H)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(H),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:H}),r===H&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==H&&e("button",{type:"button",onClick:()=>{v(H),l(!1)},title:`Merge ${H} into ${r}`,"aria-label":`Merge ${H} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Rn,{size:12})})]},H))]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{y(),l(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(Y,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:P,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e(ko,{size:12}),e("span",{children:"Manage branches..."})]})]})})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:C,children:[e("button",{type:"button",onClick:q,disabled:w,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e($a,{size:13})}),e("button",{type:"button",onClick:E,disabled:w,title:T?"Syncing with upstream…":A.ahead>0&&A.behind>0?`Pull ${A.behind} then push ${A.ahead} commit(s)`:A.ahead>0?`Push ${A.ahead} commit(s)`:A.behind>0?`Pull ${A.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":T,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${T?"":"disabled:opacity-40"}`,children:[e(D,{size:13,className:T?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",A.ahead," ↓",A.behind]})]}),e("button",{type:"button",onClick:G,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Dn,{size:13})}),e("button",{type:"button",onClick:M,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Rn,{size:13})}),e("button",{type:"button",onClick:()=>N(!R),title:"View Options","aria-label":"View Options","aria-expanded":R,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Be,{size:13})}),R&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{x("flat"),N(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ue,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{x("tree"),N(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Ve({activeRepo:t,repos:c,isRefreshing:l,rootPath:r,reposScanning:p,onSelectRepo:h,onRefresh:g,onRefreshRepos:v}){return e(mt,{left:e(d,{children:[e(kp,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(hr,{rootPath:r,activeRepo:t,onSelectRepo:h,repos:c,scanning:p,onRefreshRepos:v})]}),right:e(at,{label:"Refresh",onClick:g,busy:l})})}function De({change:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let h=Wn(t.status,c),{charStatus:g,colorClass:v}=h,y=t.file.split("/"),P=y.pop()||t.file,C=y.length>0?y.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:c,status:g,repo:l||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${h.label}`,children:g}),e(it,{name:P,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:P}),C&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:C})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!c&&e(d,{children:[e("button",{type:"button",onClick:(N)=>{N.stopPropagation(),p("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:11})}),e("button",{type:"button",onClick:(N)=>{N.stopPropagation(),p("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}),c&&e("button",{type:"button",onClick:(N)=>{N.stopPropagation(),p("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:11})})]})})]})}function Ye({change:t,repo:c,rootPath:l,onResolve:r}){let[p,h]=n(!1),[g,v]=n(null),y=t.file.split("/"),P=y.pop()||t.file,C=y.length>0?y.join("/"):"",R=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:c,root:l}}))},N=async()=>{let k=!p;if(h(k),k&&g===null){let x=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:c||"."});if(l)x.set("root",l);try{let A=await(await fetch(`/api/fs/git?${x.toString()}`)).json();v(A.markers??{})}catch{v({})}}},G=g?.ours||"ours",M=g?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:R,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(za,{size:11,className:"text-warning flex-shrink-0"}),e(it,{name:P,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning",title:t.file,children:P}),C&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:C}),yr(t.status)&&e("span",{className:"text-[10px] text-warning/70 font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),N()},title:p?"Hide resolve actions":"Show resolve actions","aria-label":p?"Hide resolve actions":"Show resolve actions","aria-expanded":p,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:p?e(et,{size:11}):e(B,{size:11})})]}),p&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${G} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",G]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${M} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",M]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Ft(t){let c={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let p=r.file.replace(/^[./]+/,""),h=p.endsWith("/"),g=p.replace(/\/$/,"").split("/").filter(Boolean),v=c,y="";for(let P=0;P<g.length;P++){let C=g[P];y=y?`${y}/${C}`:C;let R=P===g.length-1;if(R&&!h)v.children.push({id:y,name:C,path:y,type:"file",change:r,children:[],changeCount:1});else{let G=v.children.find((M)=>M.type==="folder"&&M.name===C);if(!G)G={id:y,name:C,path:y,type:"folder",children:[],changeCount:0,change:R&&h?r:void 0},v.children.push(G);v=G}}}function l(r){if(r.type==="file")return 1;let p=r.change?1:0;for(let h of r.children)p+=l(h);return r.changeCount=p,r.children.sort((h,g)=>{if(h.type==="folder"&&g.type==="file")return-1;if(h.type==="file"&&g.type==="folder")return 1;return h.name.localeCompare(g.name)}),p}return l(c),c.children}function Ze(t){let{sessionId:c,ready:l,read:r}=Ip(),p=u(()=>Ft(t),[t]),h=u(()=>{let N=new Set;function G(M){for(let k of M)if(k.type==="folder"){if(N.add(k.id),k.children&&k.children.length>0)G(k.children)}}return G(p),N},[p]),[g,v]=S("git.expandedFolders",[]),y=u(()=>new Set(g),[g]),P=i(null);o(()=>{if(!l||P.current===c)return;if(h.size===0)return;if(P.current=c,r("git.expandedFolders",[]).length>0)return;v(Array.from(h))},[l,c,h,r,v]);let C=a((N)=>{v((G)=>{let M=new Set(G);if(M.has(N))M.delete(N);else M.add(N);return Array.from(M)})},[v]),R=a((N)=>y.has(N),[y]);return{tree:p,expandedFolders:y,toggleFolder:C,isFolderOpen:R,expandAll:()=>v(Array.from(h)),collapseAll:()=>v([])}}function Fe({node:t,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g}){let v=t.type==="folder",y=v?l(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:y?e(B,{size:12}):e(ie,{size:12})}),e(it,{name:t.name,isFolder:!0,isOpen:y,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:11})})})})]}),y&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(Fe,{node:k,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g},k.id))})]});let P=t.change,C=Wn(P?.status||"M",c),{charStatus:R,colorClass:N}=C,G=P?P.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:G,staged:c,status:R,repo:h||".",root:g}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${N}`,title:`Status: ${C.label}`,children:R})}),e(it,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${N}`,title:G,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",G)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",G)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",G)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:11})})})})]})}function Ee({changes:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let{tree:h,isFolderOpen:g,toggleFolder:v}=Ze(t);if(h.length===0)return null;return e("div",{className:"py-0.5",children:h.map((y)=>e(Fe,{node:y,isStaged:c,isFolderOpen:g,toggleFolder:v,onAction:p,repo:l,rootPath:r},y.id))})}function Qe({changes:t,isLoading:c,viewMode:l,repo:r,rootPath:p,onAction:h,onResolve:g}){let[v,y]=S("git.stagedExpanded",!0),[P,C]=S("git.unstagedExpanded",!0),[R,N]=S("git.conflictsExpanded",!0),G=t.filter((x)=>yr(x.status)),M=t.filter((x)=>{if(yr(x.status))return!1;let w=x.status;return w&&w[0]!==" "&&w[0]!=="?"}),k=t.filter((x)=>{if(yr(x.status))return!1;let w=x.status;return w&&w[1]!==" "&&w[1]!=="?"||w==="??"});if(c&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[G.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>N(!R),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning text-xs",children:[e("span",{className:"w-3 text-center",children:R?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning/70 font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:G.length})]})}),R&&G.map((x)=>e(Ye,{change:x,repo:r,rootPath:p,onResolve:g??(()=>{})},`conflict-${x.file}`))]}),M.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>y(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:M.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:12})})})]}),v&&(l==="tree"?e(Ee,{changes:M,isStaged:!0,repo:r,rootPath:p,onAction:h}):M.map((x)=>e(De,{change:x,isStaged:!0,repo:r,rootPath:p,onAction:h},x.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>C(!P),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:P?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:12})}),e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:12})})]})]}),P&&(l==="tree"?e(Ee,{changes:k,isStaged:!1,repo:r,rootPath:p,onAction:h}):k.map((x)=>e(De,{change:x,isStaged:!1,repo:r,rootPath:p,onAction:h},x.file+"unstaged")))]})]})})}function Je({matches:t,loaded:c,total:l,hasMore:r,isFiltering:p}){if(p)return`${t} of ${c} loaded`;if(typeof l==="number"&&l>0)return r||c<l?`${c} of ${l}`:`${l} commits`;return r?`${c}+ commits`:`${c} commits`}function tt({isGraphMode:t,onToggleMode:c,searchQuery:l,onSearchChange:r,onRefresh:p,onClose:h,isRefreshing:g,totalCommits:v,loadedCount:y,totalCount:P,hasMore:C}){let R=Je({matches:v,loaded:y,total:P,hasMore:C,isFiltering:l.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
|
|
1
|
+
import{d,n,o,W,i,u,a,br,e,yr,fo,Wn,Ep,we,S,Ip,Gf,lr,cr,s,$a,Be,za,m,Dn,L,_,Xe,f,B,ie,et,re,fe,ge,Rn,nn,Fn,Y,D,wa,O,ko,ln,b,mt,at,pe,Mu,ii,J,it,st,ft,je,he}from"./index-4c2zcvem.js";import{kp,hr}from"./index-fjqp03xe.js";var Dt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},_e=s(Dt);var Bt={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},Ue=s(Bt);function We({message:t,hasStagedChanges:c,isBusy:l=!1,amend:r=!1,seeded:p=!1,onToggleAmend:h,onChangeMessage:g,onCommit:v}){let y=t.trim().length>0&&!l&&(r||c),P=r?"Rewrite the previous commit with this message":c?"Commit staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[e("textarea",{value:t,onChange:(C)=>g(C.currentTarget.value),onKeyDown:(C)=>{if(C.key==="Enter"&&(C.metaKey||C.ctrlKey)&&y)C.preventDefault(),v()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("div",{className:"flex items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(C)=>h?.(C.currentTarget.checked),className:`${he} accent-ink cursor-pointer`}),"Amend"]}),r&&p&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:v,disabled:!y,title:P,className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function qe({operation:t,conflicts:c,isBusy:l,onAbort:r,onContinue:p}){let h=fo[t],g=c.length,v=g===0,y=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(_,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"font-medium",children:[h.charAt(0).toUpperCase()+h.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success":"text-warning"}`,children:v?"all conflicts resolved":`${g} conflict${g===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning/90 space-y-0.5",children:c.map((P)=>e("div",{className:"truncate",title:P,children:P},P))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:l,title:`Abort the ${h} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(ln,{size:12}),"Abort ",h]}),y&&e("button",{type:"button",onClick:p,disabled:l||!v,title:v?`Conclude the ${h}`:`Resolve all ${g} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Rn,{size:12}),"Continue ",h]})]})]})}function Ke({branchRef:t,showBranchMenu:c,setShowBranchMenu:l,branch:r,branches:p,remoteBranches:h,onCheckout:g,onMerge:v,onOpenBranchPrompt:y,onManageBranches:P,optionsRef:C,showOptions:R,setShowOptions:N,onHistory:G,onGraph:M,viewMode:k,setViewMode:x,isBusy:w=!1,syncCount:A={ahead:0,behind:0},syncing:T=!1,onSync:E,onFetch:q,detached:U=!1}){return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>l(!c),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:U?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(ge,{size:12,className:U?"text-warning":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${U?"font-mono text-warning":""}`,children:r}),e(B,{size:12,className:"text-ink/40"})]}),c&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-56 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[p.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),p.map((H)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(H),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:H}),r===H&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==H&&e("button",{type:"button",onClick:()=>{v(H),l(!1)},title:`Merge ${H} into ${r}`,"aria-label":`Merge ${H} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Rn,{size:12})})]},H))]}),h.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),h.map((H)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(H),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:H}),r===H&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==H&&e("button",{type:"button",onClick:()=>{v(H),l(!1)},title:`Merge ${H} into ${r}`,"aria-label":`Merge ${H} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Rn,{size:12})})]},H))]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{y(),l(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(Y,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:P,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e(ko,{size:12}),e("span",{children:"Manage branches..."})]})]})})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:C,children:[e("button",{type:"button",onClick:q,disabled:w,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e($a,{size:13})}),e("button",{type:"button",onClick:E,disabled:w,title:T?"Syncing with upstream…":A.ahead>0&&A.behind>0?`Pull ${A.behind} then push ${A.ahead} commit(s)`:A.ahead>0?`Push ${A.ahead} commit(s)`:A.behind>0?`Pull ${A.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":T,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${T?"":"disabled:opacity-40"}`,children:[e(D,{size:13,className:T?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",A.ahead," ↓",A.behind]})]}),e("button",{type:"button",onClick:G,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Dn,{size:13})}),e("button",{type:"button",onClick:M,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Rn,{size:13})}),e("button",{type:"button",onClick:()=>N(!R),title:"View Options","aria-label":"View Options","aria-expanded":R,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Be,{size:13})}),R&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{x("flat"),N(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(Ue,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{x("tree"),N(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Ve({activeRepo:t,repos:c,isRefreshing:l,rootPath:r,reposScanning:p,onSelectRepo:h,onRefresh:g,onRefreshRepos:v}){return e(mt,{left:e(d,{children:[e(kp,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(hr,{rootPath:r,activeRepo:t,onSelectRepo:h,repos:c,scanning:p,onRefreshRepos:v})]}),right:e(at,{label:"Refresh",onClick:g,busy:l})})}function De({change:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let h=Wn(t.status,c),{charStatus:g,colorClass:v}=h,y=t.file.split("/"),P=y.pop()||t.file,C=y.length>0?y.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:c,status:g,repo:l||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${h.label}`,children:g}),e(it,{name:P,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:P}),C&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:C})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!c&&e(d,{children:[e("button",{type:"button",onClick:(N)=>{N.stopPropagation(),p("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:11})}),e("button",{type:"button",onClick:(N)=>{N.stopPropagation(),p("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}),c&&e("button",{type:"button",onClick:(N)=>{N.stopPropagation(),p("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:11})})]})})]})}function Ye({change:t,repo:c,rootPath:l,onResolve:r}){let[p,h]=n(!1),[g,v]=n(null),y=t.file.split("/"),P=y.pop()||t.file,C=y.length>0?y.join("/"):"",R=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:c,root:l}}))},N=async()=>{let k=!p;if(h(k),k&&g===null){let x=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:c||"."});if(l)x.set("root",l);try{let A=await(await fetch(`/api/fs/git?${x.toString()}`)).json();v(A.markers??{})}catch{v({})}}},G=g?.ours||"ours",M=g?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:R,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(za,{size:11,className:"text-warning flex-shrink-0"}),e(it,{name:P,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning",title:t.file,children:P}),C&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:C}),yr(t.status)&&e("span",{className:"text-[10px] text-warning/70 font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),N()},title:p?"Hide resolve actions":"Show resolve actions","aria-label":p?"Hide resolve actions":"Show resolve actions","aria-expanded":p,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:p?e(et,{size:11}):e(B,{size:11})})]}),p&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${G} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",G]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${M} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",M]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Ft(t){let c={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let p=r.file.replace(/^[./]+/,""),h=p.endsWith("/"),g=p.replace(/\/$/,"").split("/").filter(Boolean),v=c,y="";for(let P=0;P<g.length;P++){let C=g[P];y=y?`${y}/${C}`:C;let R=P===g.length-1;if(R&&!h)v.children.push({id:y,name:C,path:y,type:"file",change:r,children:[],changeCount:1});else{let G=v.children.find((M)=>M.type==="folder"&&M.name===C);if(!G)G={id:y,name:C,path:y,type:"folder",children:[],changeCount:0,change:R&&h?r:void 0},v.children.push(G);v=G}}}function l(r){if(r.type==="file")return 1;let p=r.change?1:0;for(let h of r.children)p+=l(h);return r.changeCount=p,r.children.sort((h,g)=>{if(h.type==="folder"&&g.type==="file")return-1;if(h.type==="file"&&g.type==="folder")return 1;return h.name.localeCompare(g.name)}),p}return l(c),c.children}function Ze(t){let{sessionId:c,ready:l,read:r}=Ip(),p=u(()=>Ft(t),[t]),h=u(()=>{let N=new Set;function G(M){for(let k of M)if(k.type==="folder"){if(N.add(k.id),k.children&&k.children.length>0)G(k.children)}}return G(p),N},[p]),[g,v]=S("git.expandedFolders",[]),y=u(()=>new Set(g),[g]),P=i(null);o(()=>{if(!l||P.current===c)return;if(h.size===0)return;if(P.current=c,r("git.expandedFolders",[]).length>0)return;v(Array.from(h))},[l,c,h,r,v]);let C=a((N)=>{v((G)=>{let M=new Set(G);if(M.has(N))M.delete(N);else M.add(N);return Array.from(M)})},[v]),R=a((N)=>y.has(N),[y]);return{tree:p,expandedFolders:y,toggleFolder:C,isFolderOpen:R,expandAll:()=>v(Array.from(h)),collapseAll:()=>v([])}}function Fe({node:t,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g}){let v=t.type==="folder",y=v?l(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:y?e(B,{size:12}):e(ie,{size:12})}),e(it,{name:t.name,isFolder:!0,isOpen:y,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:11})})})})]}),y&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(Fe,{node:k,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g},k.id))})]});let P=t.change,C=Wn(P?.status||"M",c),{charStatus:R,colorClass:N}=C,G=P?P.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:G,staged:c,status:R,repo:h||".",root:g}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${N}`,title:`Status: ${C.label}`,children:R})}),e(it,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${N}`,title:G,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",G)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",G)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",G)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:11})})})})]})}function Ee({changes:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let{tree:h,isFolderOpen:g,toggleFolder:v}=Ze(t);if(h.length===0)return null;return e("div",{className:"py-0.5",children:h.map((y)=>e(Fe,{node:y,isStaged:c,isFolderOpen:g,toggleFolder:v,onAction:p,repo:l,rootPath:r},y.id))})}function Qe({changes:t,isLoading:c,viewMode:l,repo:r,rootPath:p,onAction:h,onResolve:g}){let[v,y]=S("git.stagedExpanded",!0),[P,C]=S("git.unstagedExpanded",!0),[R,N]=S("git.conflictsExpanded",!0),G=t.filter((x)=>yr(x.status)),M=t.filter((x)=>{if(yr(x.status))return!1;let w=x.status;return w&&w[0]!==" "&&w[0]!=="?"}),k=t.filter((x)=>{if(yr(x.status))return!1;let w=x.status;return w&&w[1]!==" "&&w[1]!=="?"||w==="??"});if(c&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[G.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>N(!R),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning text-xs",children:[e("span",{className:"w-3 text-center",children:R?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning/70 font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:G.length})]})}),R&&G.map((x)=>e(Ye,{change:x,repo:r,rootPath:p,onResolve:g??(()=>{})},`conflict-${x.file}`))]}),M.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>y(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:M.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(nn,{size:12})})})]}),v&&(l==="tree"?e(Ee,{changes:M,isStaged:!0,repo:r,rootPath:p,onAction:h}):M.map((x)=>e(De,{change:x,isStaged:!0,repo:r,rootPath:p,onAction:h},x.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>C(!P),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:P?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(ln,{size:12})}),e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:12})})]})]}),P&&(l==="tree"?e(Ee,{changes:k,isStaged:!1,repo:r,rootPath:p,onAction:h}):k.map((x)=>e(De,{change:x,isStaged:!1,repo:r,rootPath:p,onAction:h},x.file+"unstaged")))]})]})})}function Je({matches:t,loaded:c,total:l,hasMore:r,isFiltering:p}){if(p)return`${t} of ${c} loaded`;if(typeof l==="number"&&l>0)return r||c<l?`${c} of ${l}`:`${l} commits`;return r?`${c}+ commits`:`${c} commits`}function tt({isGraphMode:t,onToggleMode:c,searchQuery:l,onSearchChange:r,onRefresh:p,onClose:h,isRefreshing:g,totalCommits:v,loadedCount:y,totalCount:P,hasMore:C}){let R=Je({matches:v,loaded:y,total:P,hasMore:C,isFiltering:l.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
|
|
2
2
|
pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:[e("div",{className:"flex items-center justify-between gap-2 lg:gap-4",children:[e("div",{className:"flex flex-col min-w-0",children:[e("div",{className:"flex items-center gap-2.5 min-w-0",children:[e("h2",{className:"text-base font-semibold text-ink tracking-tight",children:t?"Graph":"History"}),e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-ink/5 text-ink/80 border border-ink/10 whitespace-nowrap",children:R})]}),e("p",{className:"text-xs text-muted mt-0.5 hidden lg:block",children:t?"Follow branch topology and inspect commits.":"Browse recent commits and inspect changed files."})]}),e("div",{className:"flex items-center gap-1.5 lg:gap-2 flex-shrink-0",children:[e("div",{className:"flex items-center bg-ink/5 p-0.5 rounded-lg border border-ink/10 text-xs",children:[e("button",{type:"button",onClick:()=>c(!1),title:"History view","aria-label":"History view","aria-pressed":!t,className:`tap-target flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${!t?"bg-paper text-ink shadow-xs":"text-ink/80 hover:text-ink hover:bg-ink/5"}`,children:[e(Dn,{size:13,"aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"History"})]}),e("button",{type:"button",onClick:()=>c(!0),title:"Graph view","aria-label":"Graph view","aria-pressed":t,className:`tap-target flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${t?"bg-paper text-ink shadow-xs":"text-ink/80 hover:text-ink hover:bg-ink/5"}`,children:[e(Rn,{size:13,"aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"Graph"})]})]}),e("button",{type:"button",onClick:p,disabled:g,className:"tap-target flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border border-ink/15 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40",title:"Refresh commit history","aria-label":"Refresh commit history",children:[e(wa,{size:13,className:g?"animate-spin text-ink":"","aria-hidden":"true"}),e("span",{className:"hidden lg:inline",children:"Refresh"})]}),e("button",{type:"button",onClick:h,className:"tap-target p-2 -mr-1 rounded-md hover:bg-ink/5 text-muted hover:text-ink transition-colors cursor-pointer",title:"Close modal","aria-label":"Close commit history",children:e(b,{size:16,"aria-hidden":"true"})})]})]}),e("div",{className:"relative mt-1",children:[e(O,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/55","aria-hidden":"true"}),e("input",{type:"text",value:l,onChange:(N)=>r(N.currentTarget.value),placeholder:"Filter commits by message, author, or hash...","aria-label":"Filter commits",className:"w-full bg-ink/[0.03] border border-ink/15 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 focus-visible:ring-2 focus-visible:ring-ink/20 transition-colors font-mono"}),l&&e("button",{type:"button",onClick:()=>r(""),"aria-label":"Clear filter",className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-ink/55 hover:text-ink cursor-pointer",children:e(b,{size:12,"aria-hidden":"true"})})]})]})}var le=["#38bdf8","#f97316","#a855f7","#10b981","#ec4899","#eab308","#06b6d4","#6366f1"];function He(t,c){if(!t||!c)return!1;if(t===c)return!0;let l=Math.min(t.length,c.length);if(l>=4)return t.substring(0,l)===c.substring(0,l);return!1}function Re(t){let c=new Map,l=[];for(let r of t){if(typeof r.lane==="number"){c.set(r.hash,r.lane);continue}let p=l.findIndex((g)=>He(g,r.hash)||He(g,r.shortHash));if(p===-1)if(p=l.indexOf(null),p===-1)p=l.length,l.push(r.hash);else l[p]=r.hash;c.set(r.hash,p);let h=r.parents&&r.parents[0];if(h)l[p]=h;else l[p]=null;if(r.parents&&r.parents.length>1)for(let g=1;g<r.parents.length;g++){let v=r.parents[g];if(!l.some((P)=>He(P,v))){let P=l.indexOf(null);if(P===-1)l.push(v);else l[P]=v}}}return c}function nt(t,c,l,r){let p=[],h=new Map;t.forEach((g,v)=>{if(h.set(g.hash,v),g.shortHash)h.set(g.shortHash,v);if(g.hash.length>=7)h.set(g.hash.substring(0,7),v)});for(let g of t){let v=c.get(g.hash)??0,y=l[g.hash]??0,P=le[v%le.length];if(!g.parents||g.parents.length===0)continue;for(let C of g.parents){let R=h.get(C);if(typeof R!=="number"&&C.length>=7)R=h.get(C.substring(0,7));if(typeof R==="number"){let N=t[R],G=c.get(N.hash)??v,M=l[N.hash]??y+60;p.push({fromHash:g.hash,toHash:N.hash,fromLane:v,toLane:G,fromY:y,toY:M,color:le[v%le.length]})}else p.push({fromHash:g.hash,toHash:"tail-"+g.hash,fromLane:v,toLane:v,fromY:y,toY:Math.max(y+80,r),color:P})}}return p}function ot(t,c,l,r){if(Math.abs(t-l)<1)return`M ${t} ${c} L ${l} ${r}`;let p=r-c,h=c+p*0.45,g=r-p*0.45;return`M ${t} ${c} C ${t} ${h}, ${l} ${g}, ${l} ${r}`}function rt({commits:t,nodePositions:c,selectedHash:l,hoveredHash:r,isGraphMode:p,laneWidth:h=18,paddingLeft:g=16,totalHeight:v}){let y=u(()=>{if(!p){let N=new Map;return t.forEach((G)=>N.set(G.hash,0)),N}return Re(t)},[t,p]),P=u(()=>{let N=0;return y.forEach((G)=>{if(G>N)N=G}),N},[y]),C=p?(P+1)*h+g*2:36,R=u(()=>{if(!p){let N=[];for(let G=0;G<t.length-1;G++){let M=c[t[G].hash]??G*60+20,k=c[t[G+1].hash]??(G+1)*60+20;N.push({fromHash:t[G].hash,toHash:t[G+1].hash,fromLane:0,toLane:0,fromY:M,toY:k,color:"var(--theme-ink)"})}return N}return nt(t,y,c,v)},[t,y,c,v,p]);return e("div",{className:"absolute top-0 left-0 pointer-events-none z-10",style:{width:C,height:v},"aria-hidden":"true",children:e("svg",{className:"w-full h-full overflow-visible",style:{width:C,height:v},children:[R.map((N)=>{let G=p?g+N.fromLane*h:16,M=p?g+N.toLane*h:16,k=p?N.color:"currentColor",x=p?0.95:0.25,w=ot(G,N.fromY,M,N.toY);return e("path",{d:w,fill:"none",stroke:k,strokeWidth:p?2.25:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:x},`${N.fromHash}->${N.toHash}`)}),t.map((N)=>{let G=y.get(N.hash)??0,M=p?g+G*h:16,k=c[N.hash]??20,x=l===N.hash||l===N.shortHash,w=r===N.hash||r===N.shortHash,A=p?le[G%le.length]:"var(--theme-success)";return e("g",{"data-commit-node":N.hash,children:[(x||w)&&e("circle",{cx:M,cy:k,r:8,fill:A,fillOpacity:x?0.35:0.2,stroke:A,strokeWidth:1}),e("circle",{"data-commit-dot":"",cx:M,cy:k,r:p?4:4.5,fill:p?"var(--theme-paper)":A,stroke:A,strokeWidth:p?2.5:1.5}),p&&e("circle",{cx:M,cy:k,r:1.8,fill:A})]},`node-${N.hash}`)})]})})}var Et=[{action:"checkout",label:"checkout"},{action:"create_branch_here",label:"create branch here"},{action:"cherry_pick",label:"cherry-pick"},{action:"revert",label:"revert"},{action:"reset",label:"reset..."},{action:"merge",label:"merge into current"},{action:"rebase",label:"rebase onto this"}];function lt({commit:t,onAction:c}){return e("div",{className:"flex flex-wrap items-center gap-1.5 pt-1.5 pb-2",children:Et.map(({action:l,label:r})=>e("button",{type:"button",onClick:(p)=>{p.stopPropagation(),c(l,t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer",children:r},l))})}var Ge=3;function Ht(t){let c=[];for(let l=0;l<t.length;l+=1){if(t[l].type!=="context"){c.push({row:t[l],index:l});continue}let r=l;while(r<t.length&&t[r].type==="context")r+=1;let p=r-l;if(p>Ge*2+1){for(let h=l;h<l+Ge;h+=1)c.push({row:t[h],index:h});c.push({row:{type:"elided",count:p-Ge*2},index:-1});for(let h=r-Ge;h<r;h+=1)c.push({row:t[h],index:h})}else for(let h=l;h<r;h+=1)c.push({row:t[h],index:h});l=r-1}return c}function ct({diffText:t,isLoading:c,filePath:l,fullContext:r=!1,onToggleContext:p}){let h=ii(),g=u(()=>{if(!t)return[];let C=[],R=1,N=1,G=t.split(/\r?\n/),k=G.some((x)=>x.startsWith("@@"))?G:[`@@ -0,0 +1,${G.length} @@`,...G.map((x)=>x.startsWith("+")||x.startsWith("-")?x:`+${x}`)];for(let x of k){if(x.startsWith("diff --git")||x.startsWith("index ")||x.startsWith("---")||x.startsWith("+++")||x.startsWith("new file mode")||x.startsWith("deleted file mode")||x.startsWith("similarity index")||x.startsWith("old mode")||x.startsWith("new mode")||x.startsWith("\\ No newline"))continue;if(x.startsWith("@@")){let w=x.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(w)R=parseInt(w[1],10),N=parseInt(w[2],10);C.push({type:"meta",text:x})}else if(x.startsWith("+"))C.push({type:"add",text:x.slice(1),newNum:N++});else if(x.startsWith("-"))C.push({type:"del",text:x.slice(1),oldNum:R++});else{let w=x.startsWith(" ")?x.slice(1):x;C.push({type:"context",text:w,oldNum:R++,newNum:N++})}}return C},[t]),v=ft(l),y=u(()=>{let C=Array(g.length).fill(""),R=-1,N=(G)=>{if(R<0)return;let M=Mu(g.slice(R,G).map((k)=>k.text).join(`
|
|
3
3
|
`),v);for(let k=R;k<G;k++)C[k]=M[k-R]??"";R=-1};return g.forEach((G,M)=>{if(G.type==="meta")N(M);else if(R<0)R=M}),N(g.length),C},[g,v,h]),P=u(()=>r?g.map((C,R)=>({row:C,index:R})):Ht(g),[g,r]);if(c)return e("div",{className:"my-2 p-4 rounded bg-canvas border border-ink/10 text-muted font-mono text-xs flex items-center justify-center",children:"Loading commit diff..."});if(!t||g.length===0)return e("div",{className:"my-2 p-3 rounded bg-canvas border border-ink/10 text-muted font-mono text-xs text-center",children:"No diff content available for this file."});return e("div",{className:"my-2 rounded border border-ink/15 bg-paper overflow-hidden text-[11px] font-mono leading-relaxed text-ink",children:[e("div",{className:"flex items-center justify-between px-3 py-1.5 bg-canvas border-b border-ink/10 text-ink/70 text-[10.5px]",children:[e("span",{className:"font-semibold text-muted",children:"Diff preview"}),e("button",{type:"button",onClick:p,disabled:!p,className:"hover:text-ink flex items-center gap-1 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-default",title:r?"Show only the changed hunks":"Read the whole file around the change","aria-pressed":r,children:r?e(d,{children:[e(et,{size:12,"aria-hidden":"true"})," Collapse context"]}):e(d,{children:[e(B,{size:12,"aria-hidden":"true"})," Expand all context"]})})]}),e("div",{className:"overflow-x-auto max-h-72 select-text",children:e("div",{className:"w-max min-w-full divide-y divide-ink/[0.04]",children:P.map(({row:C,index:R},N)=>{if(C.type==="elided")return e("div",{className:"px-3 py-1 bg-canvas text-muted text-[10px] text-center select-none",title:`${C.count} unchanged line(s) hidden`,children:["⋯ ",C.count," unchanged line",C.count===1?"":"s"," hidden ⋯"]},`elided-${N}`);let G=C,M=R;if(G.type==="meta")return e("div",{className:"flex items-center gap-2 px-3 py-1 bg-canvas border-y border-ink/10 text-muted text-[10px] font-semibold",children:[e("span",{children:"↕"}),e("span",{children:G.text})]},M);let k=G.type==="add",x=G.type==="del";return e("div",{className:`flex items-start font-mono ${k?"bg-success/10 hover:bg-success/15":x?"bg-error/10 hover:bg-error/15":"text-ink hover:bg-ink/[0.02]"}`,children:[e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${x?"bg-error/15 text-ink/80 font-semibold":k?"bg-success/15 text-ink/80":"bg-canvas/50 text-muted"}`,children:G.oldNum??(k?"+":"")}),e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${k?"bg-success/15 text-ink/80 font-semibold":x?"bg-error/15 text-ink/80":"bg-canvas/50 text-muted"}`,children:G.newNum??(x?"-":"")}),e("div",{className:`w-4 flex-shrink-0 text-center py-0.5 select-none font-bold ${k||x?"text-ink/80":"opacity-0"}`,children:k?"+":x?"-":" "}),e("div",{className:"flex-1 py-0.5 pr-3 whitespace-pre text-ink",children:G.text?e("span",{className:"shiki",dangerouslySetInnerHTML:{__html:y[M]}}):" "})]},M)})})})]})}function dt({commit:t,isSelected:c,onSelect:l,onAction:r,onToggleFile:p,isExpandedFile:h,isLoadingFile:g,isFullContextFile:v,onToggleContext:y,fileDiffs:P,headerRef:C}){let[R,N]=n(!1),[G,M]=n(!1),k=t.body?.trim()??"",x=k.length>0,w=t.files??[],A=w.length,T=A>0,E=x||T,q=(F)=>{F.stopPropagation(),navigator.clipboard.writeText(t.hash),N(!0),setTimeout(()=>N(!1),2000)},U=(F,Z)=>{F.stopPropagation(),p(t.hash,Z)},H=()=>{if(l(t),!E)return;let F=globalThis.getSelection?.();if(F&&!F.isCollapsed)return;M((Z)=>!Z)};return e("div",{onClick:H,"data-testid":"commit-row","data-commit-hash":t.hash,className:`border-b border-ink/5 transition-colors cursor-pointer ${c?"bg-ink/[0.03]":"hover:bg-ink/[0.015]"}`,children:e("div",{className:"py-2.5 flex flex-col",children:[e("div",{className:"flex flex-col gap-1",children:[t.refs&&t.refs.length>0&&e("div",{className:"flex flex-wrap items-center gap-1.5 pb-0.5",children:t.refs.map((F,Z)=>{let z=F.includes("stash"),K=F.includes("HEAD")||F.includes("main")||F.includes("master");return e("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono border ${z?"bg-warning/10 text-ink/80 border-warning/25 font-semibold":K?"bg-ink/10 text-ink font-semibold border-ink/20":"bg-canvas text-muted border-ink/10 font-medium"}`,children:F},Z)})}),e("div",{ref:C,className:"flex items-start gap-1.5",children:e("button",{type:"button",onClick:(F)=>{F.stopPropagation(),H()},"aria-expanded":E?G:void 0,className:"flex flex-1 min-w-0 items-start gap-1.5 text-left cursor-pointer rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20",children:[e("span",{"data-commit-title":"",className:"text-[13px] font-semibold text-ink leading-snug break-words flex-1 min-w-0",children:t.message}),E&&e("span",{className:"text-ink/55 flex-shrink-0 mt-0.5","aria-hidden":"true",children:G?e(B,{size:13}):e(ie,{size:13})})]})}),x&&G&&e("div",{className:"text-[12px] text-ink/70 leading-relaxed whitespace-pre-wrap break-words border-l-2 border-ink/15 pl-2.5 py-0.5 font-mono",children:k}),e("div",{className:"flex items-center gap-x-2 gap-y-0.5 text-[11px] text-muted font-mono flex-wrap",children:[e("span",{children:t.author}),e("span",{children:t.date}),e("button",{type:"button",onClick:q,title:"Copy commit hash","aria-label":`Copy commit hash ${t.shortHash}`,className:"inline-flex items-center gap-1 hover:text-ink transition-colors cursor-pointer text-ink/70",children:[e("span",{children:t.shortHash}),R?e(f,{size:11,className:"text-success-text","aria-hidden":"true"}):e(re,{size:11,"aria-hidden":"true"})]}),T&&e("span",{children:[A," ",A===1?"file":"files"]})]})]}),c&&e("div",{className:"mt-2",children:e(lt,{commit:t,onAction:r})}),T&&G&&e("div",{className:"mt-2 flex flex-col gap-1",children:w.map((F,Z)=>{let z=h(t.hash,F.file),K=`${t.hash}:${F.file}`,V=P[K]!==void 0?P[K]:F.diff,ne=g(t.hash,F.file),oe=F.status==="A"?"text-success-text font-bold":F.status==="D"?"text-error-text font-bold":F.status==="R"?"text-meta-text font-bold":"text-info-text font-bold";return e("div",{className:"flex flex-col",children:[e("button",{type:"button",onClick:(ce)=>U(ce,F),"aria-expanded":z,className:"flex w-full items-center gap-2 py-1 px-2 rounded text-[11.5px] font-mono text-ink/80 transition-colors group cursor-pointer border border-transparent hover:border-ink/10 text-left",children:[e("span",{className:`w-3.5 text-center flex-shrink-0 text-[11px] ${oe}`,children:F.status||"M"}),e("span",{className:"truncate flex-1 min-w-0 text-ink/90 group-hover:text-ink font-medium",children:F.file}),e("span",{className:"flex items-center gap-1 text-[10.5px] tabular-nums flex-shrink-0 font-medium",children:[e("span",{className:"text-success-text",children:["+",F.additions]}),e("span",{className:"text-ink/30",children:"/"}),e("span",{className:"text-error-text",children:["-",F.deletions]})]}),e("span",{className:"text-ink/55 group-hover:text-ink flex-shrink-0",children:z?e(B,{size:13,"aria-hidden":"true"}):e(ie,{size:13,"aria-hidden":"true"})})]}),z&&e("div",{className:"pl-4 pr-1",children:e(ct,{diffText:V,isLoading:ne,filePath:F.file,fullContext:v(t.hash,F.file),onToggleContext:()=>y(t.hash,F)})})]},Z)})})]})})}var be=50;function zt(t){if(!Array.isArray(t))return[];let c=[];for(let l of t){if(!l||typeof l!=="object")continue;let r=l;if(typeof r.file!=="string"||!r.file)continue;c.push({file:r.file,status:typeof r.status==="string"?r.status:"M",additions:typeof r.additions==="number"&&Number.isFinite(r.additions)?r.additions:0,deletions:typeof r.deletions==="number"&&Number.isFinite(r.deletions)?r.deletions:0,diff:typeof r.diff==="string"?r.diff:void 0})}return c}function ze(t){if(!Array.isArray(t))return[];let c=[];for(let l of t){if(!l||typeof l!=="object")continue;let r=l,p=typeof r.hash==="string"&&r.hash?r.hash:"";if(!p)continue;c.push({hash:p,shortHash:typeof r.shortHash==="string"&&r.shortHash?r.shortHash:p.slice(0,8),author:typeof r.author==="string"?r.author:"Unknown",date:typeof r.date==="string"?r.date:typeof r.time==="string"?r.time:"",message:typeof r.message==="string"?r.message:"",body:typeof r.body==="string"?r.body:void 0,parents:Array.isArray(r.parents)?r.parents.filter((h)=>typeof h==="string"):[],refs:Array.isArray(r.refs)?r.refs.filter((h)=>typeof h==="string"):[],files:zt(r.files),lane:typeof r.lane==="number"?r.lane:void 0})}return c}function pt({output:t,isGraphMode:c,rootPath:l,activeRepo:r}){let[p,h]=n(!1),[g,v]=n(t?.hasMore??t?.data?.length===be),[y,P]=n(t?.total),C=u(()=>ze(t?.data),[t?.data]),R=Array.isArray(t?.data)?t.data.length:0,[N,G]=n(C),[M,k]=n(R);o(()=>{if(G(C),k(R),v(t?.hasMore??R===be),typeof t?.total==="number")P(t.total)},[C,R,t?.hasMore,t?.total]);let x=a(async()=>{if(p||!g)return;h(!0);try{let w=new FormData;if(w.set("actionType",c?"graph":"history"),w.set("limit",String(be)),w.set("skip",String(M)),l)w.set("root",l);if(r)w.set("repo",r);let T=await(await fetch("/api/fs/git",{method:"POST",body:w})).json();if(T.success&&Array.isArray(T.data)){let E=ze(T.data),q=T.data.length;if(G((U)=>{let H=new Set(U.map((Z)=>Z.hash)),F=E.filter((Z)=>!H.has(Z.hash));return[...U,...F]}),k((U)=>U+q),v(Boolean(T.hasMore??q===be)),typeof T.total==="number")P(T.total)}else v(!1)}catch(w){console.error("Failed to load more commits:",w)}finally{h(!1)}},[p,g,c,M,l,r]);return{commits:N,hasMore:g,totalCount:y,isLoadingMore:p,handleLoadMore:x}}function ut({onExecuteAction:t,rootPath:c,activeRepo:l}){let[r,p]=n({}),[h,g]=n(new Set),[v,y]=n(new Set),[P,C]=n(new Set),R=a(async(k,x,w)=>{let A=`${k}:${x.file}`;y((T)=>new Set(T).add(A));try{let T=new FormData;if(T.set("actionType","commit_diff"),T.set("hash",k),T.set("file",x.file),w)T.set("full","1");if(c)T.set("root",c);if(l&&l!==".")T.set("repo",l);let q=await(await fetch("/api/fs/git",{method:"POST",body:T})).json();if(q&&typeof q.diff==="string")p((U)=>({...U,[A]:q.diff}));else if(q&&q.error)p((U)=>({...U,[A]:`// Error: ${q.error}`}))}catch(T){console.error("Failed to load file diff:",T);let E=T instanceof Error?T.message:"Network error";p((q)=>({...q,[A]:`// Error loading diff: ${E}`}))}finally{y((T)=>{let E=new Set(T);return E.delete(A),E})}},[c,l]),N=a(async(k,x)=>{let w=`${k}:${x.file}`,A=!h.has(w);if(g((T)=>{let E=new Set(T);if(E.has(w))E.delete(w);else E.add(w);return E}),A&&r[w]===void 0&&!x.diff)await R(k,x,!1)},[h,r,R]),G=a(async(k,x)=>{let w=`${k}:${x.file}`,A=!P.has(w);C((T)=>{let E=new Set(T);if(E.has(w))E.delete(w);else E.add(w);return E}),await R(k,x,A)},[P,R]),M=a((k,x)=>{if(!t)return;if(k==="checkout")t("checkout",void 0,{branch:x.hash});else if(k==="create_branch_here"){let w=window.prompt(`Create new branch at commit ${x.shortHash}:`,`branch-${x.shortHash}`);if(w?.trim())t("create_branch_at",void 0,{branch:w.trim(),hash:x.hash})}else if(k==="cherry_pick"){if(window.confirm(`Cherry-pick commit ${x.shortHash} onto current branch?`))t("cherry_pick",void 0,{hash:x.hash})}else if(k==="revert"){if(window.confirm(`Revert commit ${x.shortHash}?`))t("revert_commit",void 0,{hash:x.hash})}else if(k==="reset"){let w=window.prompt(`Reset current branch to ${x.shortHash} (soft, mixed, hard):`,"soft");if(w&&["soft","mixed","hard"].includes(w.toLowerCase()))t("reset_commit",void 0,{hash:x.hash,mode:w.toLowerCase()})}else if(k==="merge"){if(window.confirm(`Merge commit ${x.shortHash} into current branch?`))t("merge_commit",void 0,{hash:x.hash})}else if(k==="rebase"){if(window.confirm(`Rebase current branch onto commit ${x.shortHash}?`))t("rebase_commit",void 0,{hash:x.hash})}},[t]);return{fileDiffs:r,expandedFiles:h,loadingFiles:v,fullContextFiles:P,handleToggleFile:N,handleToggleContext:G,handleCommitAction:M}}function Oe({output:t,onClose:c,onRefresh:l,onExecuteAction:r,rootPath:p,activeRepo:h}){if(o(()=>{if(!t)return;let j=(I)=>{if(I.key==="Escape")c()};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[t,c]),!t)return null;let[g,v]=n(()=>({title:t.title,graph:t.title.toLowerCase().includes("graph")}));if(g.title!==t.title)v({title:t.title,graph:t.title.toLowerCase().includes("graph")});let y=g.graph,P=(j)=>v((I)=>({...I,graph:j})),[C,R]=n(""),[N,G]=n(""),[M,k]=n(!1),{commits:x,hasMore:w,totalCount:A,isLoadingMore:T,handleLoadMore:E}=pt({output:t,isGraphMode:y,rootPath:p,activeRepo:h}),{fileDiffs:q,expandedFiles:U,loadingFiles:H,fullContextFiles:F,handleToggleFile:Z,handleToggleContext:z,handleCommitAction:K}=ut({onExecuteAction:r,rootPath:p,activeRepo:h});o(()=>{if(x.length>0&&!N)G(x[0].hash)},[x,N]);let V=u(()=>{if(!C.trim())return x;let j=C.toLowerCase().trim();return x.filter((I)=>I.message.toLowerCase().includes(j)||I.author.toLowerCase().includes(j)||I.shortHash.toLowerCase().includes(j)||I.hash.toLowerCase().includes(j)||I.refs?.some((te)=>te.toLowerCase().includes(j)))},[x,C]),ne=i(null),oe=i(null),ce=i(null),de=i({}),[me,ve]=n({}),[Se,Pe]=n(800);o(()=>{let j=ce.current;if(!j||!w||T||C.trim())return;let I=new IntersectionObserver((te)=>{if(te[0].isIntersecting)E()},{root:ne.current,threshold:0.1});return I.observe(j),()=>I.disconnect()},[w,T,C,E]);let ae=a(()=>{if(!ne.current||!oe.current)return;let j=ne.current.getBoundingClientRect(),I=ne.current.scrollTop,te={};V.forEach((ue,Le)=>{let xe=de.current[ue.hash];if(xe){let se=xe.getBoundingClientRect();te[ue.hash]=se.top+se.height/2-j.top+I}else te[ue.hash]=Le*60+20}),ve(te);let Ce=oe.current.offsetHeight;Pe(Math.max(Ce,ne.current.clientHeight,600))},[V]);W(()=>{ae();let j=requestAnimationFrame(()=>{ae()});return()=>cancelAnimationFrame(j)},[ae,V,q,U,y,N]),o(()=>{let j=oe.current;if(!j)return;let I=new ResizeObserver(()=>{ae()});I.observe(j);for(let te of Array.from(j.children))I.observe(te);return()=>I.disconnect()},[ae,V]);let Q=u(()=>Re(V),[V]),$e=u(()=>{let j=0;return Q.forEach((I)=>{if(I>j)j=I}),j},[Q]),ye=18,ke=16,Me=y?($e+1)*ye+ke*2:36,Ae=()=>{k(!0),l?.(),setTimeout(()=>k(!1),600)};return e("div",{className:"fixed inset-0 z-50 modal-scrim backdrop-blur-xs flex items-center justify-center p-0 lg:p-5",onClick:c,role:"dialog","aria-modal":"true","aria-label":t.title,children:e("div",{className:`glass-overlay bg-paper border-ink/20 shadow-2xl flex flex-col overflow-hidden
|
|
4
4
|
w-full h-full rounded-none border-0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,o,s,G,Zr,tc,Kf,Vf,QA,tm}from"./index-
|
|
1
|
+
import{n,o,s,G,Zr,tc,Kf,Vf,QA,tm}from"./index-4c2zcvem.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},vt=s(p);var md="omp:editor-theme-changed";function a(){if(typeof window>"u")return tc;return G("editorTheme")??tc}var m={theme:null,vars:{},themes:Vf(null)};function mi(){let[e,t]=n(a);if(o(()=>{let i=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(md,i),()=>window.removeEventListener(md,i)},[]),o(()=>{tm(e)},[e]),e===Zr)return m;let r=Kf(e);return{theme:r,vars:QA(r),themes:Vf(e)}}var fd="omp:editor-indent-changed",gd=[2,4,8],Kc={width:2,insertSpaces:!0};function Ad(){if(typeof window>"u")return Kc;let e=G("editorIndentWidth"),t=G("editorInsertSpaces");return{width:typeof e==="number"&&gd.includes(e)?e:Kc.width,insertSpaces:typeof t==="boolean"?t:Kc.insertSpaces}}function Vc(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function Yc(){let[e,t]=n(Ad);return o(()=>{let r=(i)=>{let d=i.detail;t(d??Ad())};return window.addEventListener(fd,r),()=>window.removeEventListener(fd,r)},[]),e}var hd="omp:editor-typing-changed",ul={autoCloseBrackets:!0,autocomplete:!0};function Jc(){if(typeof window>"u")return ul;let e=G("editorAutoCloseBrackets"),t=G("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:ul.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:ul.autocomplete}}function Zc(){let[e,t]=n(Jc);return o(()=>{let r=(i)=>{let d=i.detail;t(d??Jc())};return window.addEventListener(hd,r),()=>window.removeEventListener(hd,r)},[]),e}var cs="omp:editor-blame-changed",dl={enabled:!0,inline:!1};function fi(){if(typeof window>"u")return dl;let e=G("editorBlame"),t=G("editorBlameInline");return{enabled:typeof e==="boolean"?e:dl.enabled,inline:typeof t==="boolean"?t:dl.inline}}function bd(){let[e,t]=n(fi);return o(()=>{let r=(i)=>{let d=i.detail;t(d??fi())};return window.addEventListener(cs,r),()=>window.removeEventListener(cs,r)},[]),e}
|
|
2
2
|
export{vt,md,mi,fd,gd,Kc,Ad,Vc,Yc,hd,ul,Jc,Zc,cs,dl,fi,bd};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n,o,i,u,a,Jt,e,f,re,jt}from"./index-
|
|
1
|
+
import{n,o,i,u,a,Jt,e,f,re,jt}from"./index-4c2zcvem.js";function j(t,s){return{top:Math.min(t.row,s.row),left:Math.min(t.col,s.col),bottom:Math.max(t.row,s.row),right:Math.max(t.col,s.col)}}function q(t){return t.bottom-t.top+1}function z(t){return t.right-t.left+1}function H(t){let s=t+1,r="";while(s>0){let d=(s-1)%26;r=String.fromCharCode(65+d)+r,s=Math.floor((s-1)/26)}return r}function X(t){return`${H(t.col)}${t.row+1}`}function F(t){let s=X({row:t.top,col:t.left}),r=X({row:t.bottom,col:t.right});return s===r?s:`${s}:${r}`}function I(t,s,r){return{row:Math.min(Math.max(t.row,0),Math.max(s-1,0)),col:Math.min(Math.max(t.col,0),Math.max(r-1,0))}}function U(t,s,r,d,p){return I({row:t.row+s,col:t.col+r},d,p)}function W(t,s){if(t<=0||s<=0)return null;return{top:0,left:0,bottom:t-1,right:s-1}}function K(t,s){let r=[];for(let d=s.top;d<=s.bottom;d+=1){let p=[];for(let c=s.left;c<=s.right;c+=1){let g=t[d]?.[c]??"";p.push(/[\t\r\n"]/.test(g)?`"${g.replace(/"/g,'""')}"`:g)}r.push(p.join("\t"))}return r.join(`\r
|
|
2
2
|
`)}function B(t,s){let[r,d]=n(null),[p,c]=n(null),[g,C]=n(!1),b=i(!1),m=a((v)=>I(v,t,s),[t,s]),y=a((v,E)=>{let G=m(v);if(E&&r)c(G);else d(G),c(G);b.current=!0,C(!0)},[r,m]),k=a((v)=>{if(!b.current)return;c(m(v))},[m]),N=a(()=>{b.current=!1,C(!1)},[]),T=a((v,E,G)=>{let S=U(p??{row:0,col:0},v,E,t,s);if(G&&r)c(S);else d(S),c(S)},[r,p,t,s]),A=a(()=>{let v=W(t,s);if(!v)return;d({row:v.top,col:v.left}),c({row:v.bottom,col:v.right})},[t,s]),L=a((v,E)=>{let G=m({row:t-1,col:v});if(E&&r)c(G);else d(m({row:0,col:v})),c(G)},[r,m,t]),P=a((v,E)=>{let G=m({row:v,col:s-1});if(E&&r)c(G);else d(m({row:v,col:0})),c(G)},[r,m,s]),l=a(()=>{d(null),c(null)},[]),x=u(()=>{if(!r||!p)return null;return j(m(r),m(p))},[r,p,m]),R=u(()=>p?m(p):null,[p,m]);return{range:x,active:R,dragging:g,begin:y,extendTo:k,endDrag:N,move:T,selectAll:A,selectColumn:L,selectRow:P,clear:l}}function Y(t){let[s,r]=n(null),d=a((C,b,m,y)=>{r({section:C,row:b,col:m,value:y,initial:y})},[]),p=a((C)=>{r((b)=>b?{...b,value:C}:b)},[]),c=a(()=>{if(s&&s.value!==s.initial)t(s);r(null)},[s,t]),g=a(()=>r(null),[]);return{edit:s,begin:d,change:p,commit:c,cancel:g}}function V(t){let s=t.target?.closest?.("[data-row][data-col]");if(!s)return null;return{row:Number(s.dataset.row),col:Number(s.dataset.col)}}function J({cells:t,width:s,selection:r,editor:d,scrollerRef:p,startEdit:c,onEditCell:g,setCopyState:C}){let b=d.edit,m=r.active;return{onPointerDown:(l)=>{if(l.button!==0)return;let x=l.target;if(x?.closest?.("[data-edit-input]"))return;if(b)d.commit();let R=V(l);if(R){p.current?.focus(),r.begin(R,l.shiftKey),l.preventDefault();return}let v=x?.closest?.("[data-col-header]");if(v){p.current?.focus(),r.selectColumn(Number(v.dataset.colHeader),l.shiftKey),l.preventDefault();return}let E=x?.closest?.("[data-row-header]");if(E){p.current?.focus(),r.selectRow(Number(E.dataset.rowHeader),l.shiftKey),l.preventDefault();return}if(x?.closest?.("[data-corner]"))p.current?.focus(),r.selectAll(),l.preventDefault()},onPointerOver:(l)=>{let x=V(l);if(x)r.extendTo(x)},onDoubleClick:(l)=>{let x=V(l);if(x){c("data",x.row,x.col);return}let R=l.target?.closest?.("[data-col-header]");if(R)c("header",0,Number(R.dataset.colHeader))},onInput:(l)=>{let x=l.target;if(x.matches?.("[data-edit-input]"))d.change(x.value)},onKeyDown:(l)=>{if(b){if(l.key==="Enter"){l.preventDefault(),d.commit(),r.move(l.shiftKey?-1:1,0,!1);return}if(l.key==="Tab"){l.preventDefault(),d.commit(),r.move(0,l.shiftKey?-1:1,!1);return}if(l.key==="Escape"){l.preventDefault(),d.cancel();return}return}let x=l.metaKey||l.ctrlKey;if(x&&l.key.toLowerCase()==="a"){l.preventDefault(),r.selectAll();return}if(l.key==="Escape"){r.clear();return}if(l.key==="Enter"||l.key==="F2"){if(!g||!m)return;l.preventDefault(),c("data",m.row,m.col);return}if(l.key==="Delete"||l.key==="Backspace"){if(!g||!m)return;l.preventDefault(),g(m.row,m.col,"");return}if(l.key.length===1&&!x&&!l.altKey){if(!g||!m)return;l.preventDefault(),c("data",m.row,m.col,l.key);return}let v={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[l.key];if(v){l.preventDefault(),r.move(v[0],v[1],l.shiftKey);return}if(l.key==="Home"||l.key==="End"){l.preventDefault();let E=l.key==="Home"?0:s-1,G=x?l.key==="Home"?0:t.length-1:m?.row??0;r.move(G-(m?.row??0),E-(m?.col??0),l.shiftKey)}},onCopy:(l)=>{if(b)return;if(!r.range)return;l.clipboardData?.setData("text/plain",K(t,r.range)),l.preventDefault(),C("copied")},onPaste:(l)=>{if(b)return;l.preventDefault(),C("refused")}}}var Q=Jt(function({cells:s,rowIndex:r,selectedLeft:d,selectedRight:p,activeCol:c,editingCol:g,editingValue:C}){let b=d>=0;return e("tr",{className:"odd:bg-ink/[0.02]",children:[e("th",{"data-row-header":r,className:`cursor-pointer border-b border-r border-ink/10 px-2 py-0.5 text-right font-normal tabular-nums ${b?"bg-info/10 text-ink/60":"text-ink/30"}`,title:`Select row ${r+1}`,children:r+1}),s.map((m,y)=>{let k=b&&y>=d&&y<=p;return e("td",{"data-row":r,"data-col":y,title:m,className:`cursor-cell border-b border-ink/10 px-2 py-0.5 text-ink ${k?"bg-info/10":""} ${y===c?"ring-1 ring-inset ring-info":""}`,children:y===g?e("input",{"data-edit-input":"true",value:C,spellcheck:!1,className:"w-full min-w-0 bg-transparent font-mono text-[11px] text-ink outline-none"}):e("span",{className:"block truncate",children:m})},y)})]})});function Z({status:t,tone:s="muted",actions:r,canCopy:d,copyState:p,onCopy:c}){return e("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-ink/10 bg-canvas px-2 py-1 font-sans text-[11px]",children:[e("span",{className:`truncate ${s==="warning"?"text-warning":"text-ink/50"}`,children:t}),e("div",{className:"flex shrink-0 items-center gap-2",children:[r,e("button",{type:"button",onClick:c,disabled:!d,title:"Copy the selected cells as tab-separated text",className:`flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors ${d?"text-ink/60 hover:bg-ink/5 hover:text-ink":"cursor-default text-ink/25"} ${p==="failed"?"text-error":""}`,children:[p==="copied"?e(f,{size:12}):e(re,{size:12}),e("span",{children:p==="copied"?"Copied":p==="failed"?"Copy failed":"Copy"})]})]})]})}var ne=44,oe=1600;function _c({header:t,rows:s,truncated:r,label:d,readOnlyNote:p,onEditCell:c,onEditHeader:g,actions:C}){let b=u(()=>s.reduce((h,w)=>Math.max(h,w.length),t.length),[t,s]),m=u(()=>Array.from({length:b},(h,w)=>t[w]??H(w)),[t,b]),y=u(()=>s.map((h)=>h.length===b?h:Array.from({length:b},(w,M)=>h[M]??"")),[s,b]),k=B(y.length,b),N=i(null),[T,A]=n("idle"),L=a((h)=>{if(h.section==="header")g?.(h.col,h.value);else c?.(h.row,h.col,h.value)},[c,g]),P=Y(L),l=P.edit,x=a((h,w,M,_)=>{if(h==="header"?!g:!c)return;let te=h==="header"?m[M]??"":y[w]?.[M]??"";P.begin(h,w,M,_??te)},[y,P,m,c,g]),R=a(async()=>{if(!k.range)return;let h=await jt(K(y,k.range));A(h?"copied":"failed")},[y,k.range]);o(()=>{if(T==="idle")return;let h=setTimeout(()=>A("idle"),oe);return()=>clearTimeout(h)},[T]);let{dragging:v,endDrag:E}=k;o(()=>{if(!v)return;let h=()=>E();return window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),()=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)}},[v,E]);let G=k.active;o(()=>{if(!G)return;N.current?.querySelector(`[data-row="${G.row}"][data-col="${G.col}"]`)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[G]);let O=l?`${l.section}:${l.row}:${l.col}`:"";o(()=>{if(!O)return;let h=N.current?.querySelector("[data-edit-input]");h?.focus(),h?.select()},[O]);let S=J({cells:y,width:b,selection:k,editor:P,scrollerRef:N,startEdit:x,onEditCell:c,setCopyState:A});if(b===0&&y.length===0)return e("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-xs text-ink/50",children:"This file has no rows."});let D=k.range,ee=T==="refused"?p??"This grid is read-only.":D?`${F(D)} · ${q(D)}×${z(D)}`:"Click a cell, drag to select a block";return e("div",{className:"flex min-h-0 flex-1 flex-col",children:[r&&e("div",{className:"shrink-0 border-b border-warning/30 bg-warning/10 px-3 py-1 font-sans text-[11px] text-warning",children:["Showing the first ",y.length.toLocaleString()," rows."]}),e(Z,{status:ee,tone:T==="refused"?"warning":"muted",actions:C,canCopy:D!==null,copyState:T,onCopy:()=>void R()}),e("div",{ref:N,tabIndex:0,role:"grid","aria-label":d??"Spreadsheet",className:"flex-1 overflow-auto outline-none",onPointerDown:S.onPointerDown,onPointerOver:S.onPointerOver,onDblClick:S.onDoubleClick,onInput:S.onInput,onKeyDown:S.onKeyDown,onCopy:S.onCopy,onPaste:S.onPaste,children:e("table",{className:"w-full table-fixed select-none border-collapse font-mono text-[11px]",children:[e("colgroup",{children:[e("col",{style:{width:`${ne}px`}}),m.map((h,w)=>e("col",{},w))]}),e("thead",{className:"sticky top-0 z-10 bg-canvas",children:e("tr",{children:[e("th",{"data-corner":!0,title:"Select all",className:"cursor-pointer border-b border-r border-ink/10 px-2 py-1 text-right font-normal text-ink/30",children:"#"}),m.map((h,w)=>{let M=D!==null&&w>=D.left&&w<=D.right,_=l?.section==="header"&&l.col===w;return e("th",{"data-col-header":w,title:h,className:`cursor-pointer border-b border-ink/10 px-2 py-1 text-left font-semibold ${M?"bg-info/10 text-ink":"text-ink/80"}`,children:_?e("input",{"data-edit-input":"true",value:l.value,spellcheck:!1,className:"w-full min-w-0 bg-transparent font-mono text-[11px] font-semibold text-ink outline-none"}):e("span",{className:"block truncate",children:h})},w)})]})}),e("tbody",{children:y.map((h,w)=>{let M=D!==null&&w>=D.top&&w<=D.bottom;return e(Q,{cells:h,rowIndex:w,selectedLeft:M?D.left:-1,selectedRight:M?D.right:-1,activeCol:G?.row===w?G.col:-1,editingCol:l?.section==="data"&&l.row===w?l.col:-1,editingValue:l?.section==="data"&&l.row===w?l.value:""},w)})})]})})]})}var af=2000,of=100;function ie(t,s){if(/\.tsv$/i.test(s??""))return"\t";let r=t.slice(0,t.indexOf(`
|
|
3
3
|
`)===-1?t.length:t.indexOf(`
|
|
4
4
|
`)),d=0,p=0,c=!1;for(let g=0;g<r.length;g+=1){let C=r[g];if(C==='"')c=!c;else if(!c&&C==="\t")d+=1;else if(!c&&C===",")p+=1}return d>p?"\t":","}function le(t,s,r){let d=[],p=[],c="",g=!1,C=0,b=()=>{if(C<r)p.push(c);c="",C+=1},m=()=>{b(),d.push(p),p=[],C=0};for(let y=0;y<t.length;y+=1){let k=t[y];if(g){if(k==='"')if(t[y+1]==='"')c+='"',y+=1;else g=!1;else c+=k;continue}if(k==='"'&&c.length===0){g=!0;continue}if(k===s){b();continue}if(k==="\r"){if(t[y+1]===`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{n,o,i,a,e,s,ur,m,ie,Nt,nt,D,b,G,Ie}from"./index-
|
|
1
|
+
import{n,o,i,a,e,s,ur,m,ie,Nt,nt,D,b,G,Ie}from"./index-4c2zcvem.js";var Y={name:"pin-off",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]]},ml=s(Y);var H={name:"pin",size:24,node:[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]]},Ta=s(H);async function xd(r){let u=r?`?path=${encodeURIComponent(r)}`:"",p=await fetch(`/api/fs/browse${u}`),l=await p.json();if(!p.ok||l.error)throw Error(l.error||`HTTP ${p.status}`);return l}function ws({initialPath:r,onSelect:u,onClose:p}){let[l,C]=n(r??""),[f,y]=n(""),[h,P]=n([]),[x,T]=n(null),[R,k]=n(!0),[v,S]=n(null),[z,g]=n(null),L=i(null),d=a(async(t)=>{k(!0),S(null);try{let c=await xd(t);C(c.path??t??""),T(c.parentPath??null),y(c.path??t??""),P(c.directories??[])}catch(c){S(c instanceof Error?c.message:String(c))}finally{k(!1)}},[]);o(()=>{d(r)},[r,d]);let A=()=>{if(x)d(x)},I=(t)=>{t.preventDefault();let c=f.trim();if(c)d(c)},w=(t)=>{d(t.path)},_=(t)=>{g(t.path),u(t.path)},B=()=>{if(l)g(l),u(l)};return e("div",{className:"fixed inset-0 modal-scrim z-[60] flex items-center justify-center p-4",onClick:p,children:e("div",{className:"glass-overlay bg-paper border border-ink/15 rounded-lg shadow-2xl w-full max-w-lg flex flex-col overflow-hidden",onClick:(t)=>t.stopPropagation(),children:[e("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[e("h3",{className:"font-semibold text-sm flex items-center space-x-2",children:[e(Nt,{size:15,className:"text-ink/70"}),e("span",{children:"Choose Project Folder"})]}),e("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors","aria-label":"Close picker",children:e(b,{size:15})})]}),e("div",{className:"px-4 py-2 border-b border-ink/10 bg-canvas/50",children:[e("form",{onSubmit:I,className:"flex items-center space-x-2",children:[e(ur,{size:14,className:"text-ink/40 flex-shrink-0"}),e("input",{ref:L,type:"text",value:f,onChange:(t)=>y(t.currentTarget.value),placeholder:"~ or /absolute/path",className:"flex-1 bg-transparent outline-none text-xs font-mono text-ink placeholder-ink/35 py-1",spellcheck:!1}),e("button",{type:"submit",className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Go"})]}),e("div",{className:"flex items-center space-x-1 mt-1 text-[11px] text-ink/40 truncate",children:[e("button",{type:"button",onClick:()=>void d(),className:"hover:text-ink transition-colors flex items-center",children:[e(ur,{size:11,className:"mr-0.5"})," home"]}),l.split("/").filter(Boolean).map((t,c,F)=>{let N="/"+l.split("/").filter(Boolean).slice(0,c+1).join("/"),j=c===F.length-1;return e("span",{className:"flex items-center space-x-1 min-w-0",children:[e(ie,{size:10,className:"text-ink/20 flex-shrink-0"}),j?e("span",{className:"text-ink/70 truncate",children:t}):e("button",{type:"button",onClick:()=>void d(N),className:"hover:text-ink transition-colors truncate max-w-[120px]",children:t})]},N)})]})]}),e("div",{className:"flex-1 min-h-[240px] max-h-[360px] scrollbar-overlay-container p-2",children:R?e("div",{className:"flex items-center justify-center h-40 text-ink/40",children:e(m,{size:18,className:"animate-spin"})}):v?e("div",{className:"flex flex-col items-center justify-center h-40 text-xs text-error space-y-2 px-4",children:[e("span",{children:v}),e("button",{type:"button",onClick:()=>void d(l||void 0),className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[e(D,{size:11})," Retry"]})]}):h.length===0?e("div",{className:"text-center py-16 text-xs text-ink/40",children:"No subfolders"}):h.map((t)=>e("div",{className:`group flex items-center justify-between px-2.5 py-2 rounded cursor-pointer transition-colors ${z===t.path?"bg-ink/10":"hover:bg-ink/5"}`,onDblClick:()=>w(t),children:[e("button",{type:"button",onClick:()=>w(t),className:"flex items-center space-x-2 min-w-0 flex-1 text-left",children:[e(nt,{size:15,className:"text-ink/50 flex-shrink-0"}),e("span",{className:"text-xs truncate text-ink/85",children:t.name})]}),e("button",{type:"button",onClick:()=>_(t),className:"touch-shown-flex hidden group-hover:flex px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-semibold hover:bg-ink/80 transition-colors flex-shrink-0",children:"Choose"})]},t.path))}),e("div",{className:"flex items-center justify-between px-4 py-3 border-t border-ink/10",children:[e("div",{className:"flex items-center space-x-2 min-w-0",children:[e("button",{type:"button",onClick:A,disabled:!x,className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1",children:[e("span",{children:"↑"}),e("span",{children:"Up"})]}),e("button",{type:"button",onClick:()=>void d(),className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Home"})]}),e("div",{className:"flex items-center space-x-2",children:[e("button",{type:"button",onClick:p,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),e("button",{type:"button",onClick:B,disabled:!l,className:"px-3.5 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 disabled:opacity-50 transition-colors",children:"Use This Folder"})]})]})]})})}var Ag="modern",hg=["classic","modern"];function M(r){return r==="classic"||r==="modern"}function fl(r){return M(r)?r:"modern"}var bg={classic:{label:"Classic",description:"A toolbar of boxed icons and compact rows — the layout Kabmo has always shipped.",caption:"Toolbar · 24px rows"},modern:{label:"Modern",description:"Permanent search, filter chips, sticky workspace headers and taller rows with one trailing column.",caption:"Search · chips · 30px rows"}};var U="sidebarStyle",E="omp:sidebar-style-changed";function V(r){return fl(G(U,r))}function yg(r){if(typeof window>"u")return;window.dispatchEvent(new CustomEvent(E,{detail:fl(r)}))}function du(){let[r,u]=n(()=>V());return Ie(E,(p)=>{u(fl(p.detail))}),r}
|
|
2
2
|
export{ml,Ta,Ag,hg,fl,bg,yg,du,xd,ws};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t}from"./index-
|
|
1
|
+
import{t}from"./index-y5ymgp20.js";var hi=class{constructor(i){this.init=i,this.records=this.init()}static{t(this,"ImperativeState")}reset(){this.records=this.init()}};
|
|
2
2
|
export{hi};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d,n,o,i,a,e,S,m,L,en,Aa,Qe,D,Ln,b,bA,jp,zu,yA,Jl}from"./index-3fw3sd10.js";import{gu}from"./index-k61tdd4a.js";import"./index-hh05xd1d.js";var de={idle:"Kosong",loading:"Memuat",ready:"Siap"},V="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function K({url:t,input:s,loading:r,error:l,canGoBack:p,canGoForward:f,viewportMode:h,zoomLevel:c,onInputChange:x,onSubmit:A,onBack:P,onForward:T,onReload:v,onOpenExternal:E,onIncludeInChat:I,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k}){let w=i(void 0);o(()=>{if(w.current===t)return;if(w.current=t,t)x(t)},[t,x]);let M=!t?"idle":r?"loading":"ready",O=M==="ready"?"bg-success animate-pulse":M==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",H=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:P,disabled:!p,"aria-label":"Back",title:"Back",className:V,children:e(en,{size:12})}),e("button",{type:"button",onClick:T,disabled:!f,"aria-label":"Maju",title:"Maju",className:V,children:e(Aa,{size:12})}),e("button",{type:"button",onClick:v,disabled:!t,"aria-label":"Reload",title:"Reload",className:V,children:e(D,{size:12,className:r?"animate-spin":void 0})})]});return e(gu,{url:t,statusDotClass:O,statusLabel:de[M],viewportMode:h,zoomLevel:c,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k,onIncludeInChat:I,onOpenExternal:E,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[H,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-0.5 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(y)=>{y.preventDefault(),A(s)},children:[e(Qe,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:s,onChange:(y)=>x(y.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var Z={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};var ce="clipboard-read; clipboard-write; fullscreen";function X({url:t,frameKey:s,loading:r,viewportMode:l,zoomLevel:p,onLoad:f,active:h=!0,overlay:c,onFrame:x}){if(!h)return null;if(!t)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(Qe,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:[r?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${Z[l]} transition-all duration-200`,style:{zoom:p!==100?`${p}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(A)=>x?.(A),src:t,title:"Browser pengguna",onLoad:f,referrerPolicy:"no-referrer",allow:ce,className:"w-full h-full bg-white border-0",style:c?{pointerEvents:"none"}:void 0},s),c]})]})}var W="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function ue(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function Y({shape:t,index:s,readability:r,onLabel:l,onNote:p}){let f=ue(r),h=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[zu[t.tool]," #",s]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),yA.map((c)=>{let x=t.label===c;return e("button",{type:"button",onClick:()=>l(x?"":c),"aria-pressed":x,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${x?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:c},c)}),e("input",{value:t.label,onInput:(c)=>l(c.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${W} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(c)=>p(c.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${W} resize-y`}),h?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:h.path,children:["elemen: ",h.path,h.state?` · ${h.state}`:""]}):null,f?e("p",{className:"text-[10px] text-ink/40",children:f}):null]})]})}var me=["box","pin","arrow"],pe="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",U="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function j({tool:t,shapes:s,selectedId:r,readability:l,onTool:p,onLabel:f,onNote:h,onRemove:c,onReset:x,onCancel:A,onSend:P}){let T=s.find((E)=>E.id===r)??null,v=s.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),me.map((E)=>e("button",{type:"button",onClick:()=>p(E),"aria-pressed":t===E,className:`${pe} ${t===E?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:zu[E]},E)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:s.length>0?`${s.length} mark${s.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:x,disabled:!v,className:U,title:"Clear all marks",children:[e(L,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:P,disabled:!v,className:U,title:"Kirim anotasi ke draft chat",children:[e(Ln,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:A,className:U,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),T?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(Y,{shape:T,index:s.indexOf(T)+1,readability:l,onLabel:(E)=>f(T.id,E),onNote:(E)=>h(T.id,E)})}),e("button",{type:"button",onClick:()=>c(T.id),className:U,title:"Remove this mark",children:e(L,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var q=0;function J(){return q+=1,`annot-${Date.now().toString(36)}-${q}`}function Q(t){let[s,r]=n(!1),[l,p]=n("box"),[f,h]=n([]),[c,x]=n(null);o(()=>{h([]),x(null)},[t]);let A=a(()=>{r((N)=>!N),x(null)},[]),P=a(()=>{x(null),r(!1)},[]),T=a((N)=>{h((B)=>[...B,N]),x(N.id)},[]),v=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,note:B}:g))},[]),E=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,label:B}:g))},[]),I=a((N)=>{h((B)=>B.filter((u)=>u.id!==N)),x((B)=>B===N?null:B)},[]),C=a(()=>{h([]),x(null)},[]);return{active:s,tool:l,shapes:f,selectedId:c,setTool:p,toggle:A,close:P,add:T,setNote:v,setLabel:E,select:x,remove:I,reset:C}}var fe=4,_="var(--theme-error)";function ee({shapes:t,tool:s,selectedId:r,onMeasure:l,onAdd:p,onSelect:f}){let h=i(null),c=i(null),[x,A]=n(null),[P,T]=n({width:0,height:0});o(()=>{let u=h.current;if(!u)return;let g=()=>{let w=u.getBoundingClientRect();if(w.width<=0||w.height<=0)return;T((M)=>M.width===w.width&&M.height===w.height?M:{width:w.width,height:w.height}),l({width:w.width,height:w.height})};if(g(),typeof ResizeObserver!=="function")return;let k=new ResizeObserver(g);return k.observe(u),()=>k.disconnect()},[l]);let v=(u)=>{let g=h.current;if(!g)return null;let k=g.getBoundingClientRect(),w={x:u.clientX-k.left,y:u.clientY-k.top};return{normalized:bA(k,w),px:w.x,py:w.y}},E=(u)=>{if(u.button!==0)return;let g=v(u);if(!g)return;u.preventDefault(),f(null),u.currentTarget.setPointerCapture?.(u.pointerId);let k={id:J(),tool:s,start:g.normalized,end:g.normalized,label:"",note:""};c.current=k,A(k)},I=(u)=>{let g=c.current;if(!g)return;let k=v(u);if(!k)return;let w={...g,end:k.normalized};c.current=w,A(w)},C=(u)=>{let g=c.current;if(!g)return;let k=v(u),w=k?{...g,end:k.normalized}:g;if(c.current=null,A(null),u.currentTarget.releasePointerCapture?.(u.pointerId),w.tool!=="pin"){let M=h.current?.getBoundingClientRect();if((M?Math.hypot((w.end.x-w.start.x)*M.width,(w.end.y-w.start.y)*M.height):0)<fe)return}p(w)},N=()=>{c.current=null,A(null)},B=x?[...t,x]:t;return e("div",{ref:h,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:E,onPointerMove:I,onPointerUp:C,onPointerCancel:N,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,P.width)} ${Math.max(1,P.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:B.map((u,g)=>e(he,{shape:u,index:g+1,box:P,selected:u.id===r,onSelect:()=>f(u.id)},u.id))})})}function he({shape:t,index:s,box:r,selected:l,onSelect:p}){let f={x:t.start.x*r.width,y:t.start.y*r.height},h={x:t.end.x*r.width,y:t.end.y*r.height},c=jp(t),x=l?3:2,A=String(s);return e("g",{onPointerDown:(T)=>{T.stopPropagation(),T.preventDefault(),p()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:c.x*r.width,y:c.y*r.height,width:Math.max(1,c.width*r.width),height:Math.max(1,c.height*r.height),fill:_,fillOpacity:l?0.16:0.1,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:h.x,cy:h.y,r:4,fill:_})]}),t.tool==="pin"&&e("circle",{cx:f.x,cy:f.y,r:7,fill:_,fillOpacity:l?0.5:0.3,stroke:_,strokeWidth:x}),e("circle",{cx:f.x,cy:f.y,r:9,fill:_}),e("text",{x:f.x,y:f.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:A})]})}function te(t){let s=t.trim();if(!s)return s;let r=/^[a-z][a-z0-9+.-]*:/i.test(s)?s:`https://${s}`,l=new URL(r);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var ge="userBrowser.history",be="userBrowser.historyIndex",xe="userBrowser.inputUrl";function ne(){let[t,s]=S(ge,[]),[r,l]=S(be,-1),[p,f]=S(xe,""),[h,c]=n(0),[x,A]=n(!1),[P,T]=n(void 0),v=r>=0&&r<t.length?t[r]??"":"",E=a((u)=>{let g=u.trim();if(!g)return;let k;try{k=te(g)}catch(O){T(O instanceof Error?O.message:"Alamat tidak valid");return}T(void 0),A(!0);let M=[...t.slice(0,r+1),k];s(M),l(M.length-1),f(k),c((O)=>O+1)},[t,r,s,l,f]),I=a(()=>{if(r<=0)return;A(!0),l(r-1)},[r,l]),C=a(()=>{if(r>=t.length-1)return;A(!0),l(r+1)},[t.length,r,l]),N=a(()=>{if(!v)return;A(!0),c((u)=>u+1)},[v]),B=a(()=>{A(!1)},[]);return{url:v,input:p,setInput:f,frameKey:h,loading:x,error:P,canGoBack:r>0,canGoForward:r>=0&&r<t.length-1,submit:E,goBack:I,goForward:C,reload:N,markLoaded:B}}function we(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function F(t){let s=t.replace(/\s+/g," ").trim();return s.length>60?`${s.slice(0,59)}…`:s}function ve(t){let s=t.tagName.toLowerCase();if(t.id)return`${s}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let p=t.getAttribute(l);if(p)return`${s}[${l}="${F(p)}"]`}let r=t.getAttribute("role");if(r)return`${s}[role="${r}"]`;return s}function ye(t){let s=[],r=t;while(r&&s.length<4){if(r.tagName.toLowerCase()==="html")break;s.unshift(ve(r)),r=r.parentElement}return s.join(" > ")}function ke(t){let s=[];if(t.disabled)s.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let r=t,p=r.selectedOptions?.[0]?.textContent?.trim()||r.value;if(p)s.push(`nilai "${F(p)}"`);let f=r.options?.length??0;if(f>0)s.push(`${f} opsi`)}else if(t.tagName.toLowerCase()==="input"){let r=t;if(r.type)s.push(`tipe ${r.type}`);if(r.type!=="password"&&r.placeholder)s.push(`placeholder "${F(r.placeholder)}"`)}return s.length>0?s.join(", "):void 0}function Ae(t){let s={path:ye(t),tag:t.tagName.toLowerCase()},r=t.getAttribute("role");if(r)s.role=r;let l=F(t.innerText??t.textContent??"");if(l)s.text=l;let p=ke(t);if(p)s.state=p;return s}function oe(t,s){let r=we(t);if(r!=="readable")return{ok:!1,reason:r};let{contentWindow:l,contentDocument:p}=t;if(!l||!p)return{ok:!1,reason:"cross-origin"};try{let f=Math.min(Math.max(s.x,0),1)*l.innerWidth,h=Math.min(Math.max(s.y,0),1)*l.innerHeight,c=p.elementFromPoint(f,h);if(!c||c===p.documentElement||c===p.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:Ae(c)}}catch{return{ok:!1,reason:"cross-origin"}}}function mt({className:t="",active:s=!0}){let[r,l]=S("userBrowser.viewportMode","responsive"),[p,f]=S("userBrowser.zoomLevel",100),[h,c]=n(null),[x,A]=n(null),[P,T]=n(null),{url:v,input:E,setInput:I,frameKey:C,loading:N,error:B,canGoBack:u,canGoForward:g,submit:k,goBack:w,goForward:M,reload:O,markLoaded:H}=ne(),y=Q(C),re=a(()=>{if(!v)return;window.open(v,"_blank","noopener,noreferrer")},[v]),ae=a(()=>{if(!v)return;Jl({url:v})},[v]),ie=a((R)=>{c((z)=>z&&z.width===R.width&&z.height===R.height?z:R)},[]),se=a((R)=>{let z=oe(x,R.start);T(z),y.add(z.ok?{...R,element:z.element}:R)},[y,x]),le=a(()=>{if(!v||y.shapes.length===0)return;let R=p/100;Jl({url:v,annotations:y.shapes,panel:{width:(h?.width??0)/R,height:(h?.height??0)/R,viewportMode:r,zoom:p}}),y.close()},[v,y,h,r,p]),G=y.active&&Boolean(v);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(K,{url:v,input:E,loading:N,error:B,canGoBack:u,canGoForward:g,viewportMode:r,zoomLevel:p,onInputChange:I,onSubmit:k,onBack:w,onForward:M,onReload:O,onOpenExternal:re,onIncludeInChat:ae,onChangeViewport:l,onZoomIn:()=>f((R)=>Math.min(200,R+10)),onZoomOut:()=>f((R)=>Math.max(50,R-10)),onResetZoom:()=>f(100),onSetZoom:f,annotate:{active:G,count:y.shapes.length,onToggle:y.toggle}}),G&&e(j,{tool:y.tool,shapes:y.shapes,selectedId:y.selectedId,readability:P,onTool:y.setTool,onLabel:y.setLabel,onNote:y.setNote,onRemove:y.remove,onReset:y.reset,onCancel:y.close,onSend:le}),e(X,{url:v,frameKey:C,loading:N,viewportMode:r,zoomLevel:p,onLoad:H,onFrame:A,active:s,overlay:G?e(ee,{shapes:y.shapes,tool:y.tool,selectedId:y.selectedId,onMeasure:ie,onAdd:se,onSelect:y.select}):null})]})}export{mt as UserBrowserPanel};
|
|
1
|
+
import{d,n,o,i,a,e,S,m,L,en,Aa,Qe,D,Ln,b,bA,jp,zu,yA,Jl}from"./index-4c2zcvem.js";import{gu}from"./index-w0rbyw47.js";import"./index-vb3srfyc.js";var de={idle:"Kosong",loading:"Memuat",ready:"Siap"},V="p-1 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink cursor-pointer disabled:cursor-not-allowed transition-colors";function K({url:t,input:s,loading:r,error:l,canGoBack:p,canGoForward:f,viewportMode:h,zoomLevel:c,onInputChange:x,onSubmit:A,onBack:P,onForward:T,onReload:v,onOpenExternal:E,onIncludeInChat:I,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k}){let w=i(void 0);o(()=>{if(w.current===t)return;if(w.current=t,t)x(t)},[t,x]);let M=!t?"idle":r?"loading":"ready",O=M==="ready"?"bg-success animate-pulse":M==="loading"?"bg-ink/40 animate-pulse":"bg-ink/25",H=e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 space-x-0.5 flex-shrink-0",children:[e("button",{type:"button",onClick:P,disabled:!p,"aria-label":"Back",title:"Back",className:V,children:e(en,{size:12})}),e("button",{type:"button",onClick:T,disabled:!f,"aria-label":"Maju",title:"Maju",className:V,children:e(Aa,{size:12})}),e("button",{type:"button",onClick:v,disabled:!t,"aria-label":"Reload",title:"Reload",className:V,children:e(D,{size:12,className:r?"animate-spin":void 0})})]});return e(gu,{url:t,statusDotClass:O,statusLabel:de[M],viewportMode:h,zoomLevel:c,onChangeViewport:C,onZoomIn:N,onZoomOut:B,onResetZoom:u,onSetZoom:g,annotate:k,onIncludeInChat:I,onOpenExternal:E,openExternalLabel:"Buka di tab baru",openExternalTitle:"Buka di tab baru (untuk situs yang menolak iframe)",children:e("div",{className:"flex items-center flex-1 min-w-0 space-x-1.5",children:[H,e("form",{className:`flex-1 min-w-0 flex items-center bg-canvas border rounded-md px-2 py-0.5 space-x-1 focus-within:border-ink/40 ${l?"border-error":"border-ink/15"}`,onSubmit:(y)=>{y.preventDefault(),A(s)},children:[e(Qe,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:s,onChange:(y)=>x(y.currentTarget.value),placeholder:"Type an address (e.g. localhost:5173) and press Enter…","aria-label":"Browser address","aria-invalid":l!==void 0&&l!==null,title:l??void 0,spellcheck:!1,autoComplete:"off",className:`w-full min-w-0 bg-transparent outline-none font-mono text-[11px] placeholder:text-ink/35 ${l?"text-error":"text-ink/90"}`})]})]})})}var Z={"desktop-16-9":"w-full max-w-[1280px] aspect-video max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",laptop:"w-[1024px] max-w-full h-[768px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",tablet:"w-[768px] max-w-full h-[1024px] max-h-full border border-ink/20 rounded-lg shadow-md overflow-hidden my-auto",mobile:"w-[375px] max-w-full h-[667px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto","mobile-lg":"w-[414px] max-w-full h-[896px] max-h-full border border-ink/20 rounded-xl shadow-md overflow-hidden my-auto",responsive:"w-full h-full border-0"};var ce="clipboard-read; clipboard-write; fullscreen";function X({url:t,frameKey:s,loading:r,viewportMode:l,zoomLevel:p,onLoad:f,active:h=!0,overlay:c,onFrame:x}){if(!h)return null;if(!t)return e("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center select-none",children:[e("div",{className:"w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3",children:e(Qe,{size:22})}),e("h3",{className:"text-sm font-semibold text-ink mb-1",children:"Browser Anda"}),e("p",{className:"text-xs text-ink/60 max-w-sm",children:"Type an address above and press Enter. The page loads inside this panel."}),e("p",{className:"text-[11px] text-ink/45 max-w-sm mt-2",children:"Sebagian situs (Google, GitHub) menolak ditampilkan dalam iframe — pakai tombol buka di tab baru."})]});return e("div",{className:"flex-1 min-h-0 relative flex items-center justify-center p-2 overflow-auto bg-canvas/60",children:[r?e("div",{className:"absolute inset-0 z-10 flex items-center justify-center pointer-events-none",children:e("div",{className:"flex items-center space-x-2 px-3 py-1.5 rounded-md bg-paper border border-ink/15",children:[e(m,{size:13,className:"animate-spin text-ink/50"}),e("span",{className:"text-[11px] font-mono text-ink/60",children:"Memuat…"})]})}):null,e("div",{className:`relative flex flex-col bg-white ${Z[l]} transition-all duration-200`,style:{zoom:p!==100?`${p}%`:void 0,transformOrigin:"top center"},children:[e("iframe",{ref:(A)=>x?.(A),src:t,title:"Browser pengguna",onLoad:f,referrerPolicy:"no-referrer",allow:ce,className:"w-full h-full bg-white border-0",style:c?{pointerEvents:"none"}:void 0},s),c]})]})}var W="w-full min-w-0 bg-canvas border border-ink/15 rounded px-2 py-1 text-[11px] font-mono text-ink placeholder:text-ink/35 focus:outline-none focus:border-ink/40";function ue(t){if(!t||t.ok)return null;if(t.reason==="cross-origin")return"This page is cross-origin, so its elements cannot be read. Name the part and add a note instead.";if(t.reason==="no-frame")return"The page has not loaded, so its elements cannot be read yet.";return"There is no element at this point (empty space). Name the part instead."}function Y({shape:t,index:s,readability:r,onLabel:l,onNote:p}){let f=ue(r),h=t.element;return e("div",{className:"flex items-start gap-1.5 min-w-0",children:[e("span",{className:"text-[11px] font-mono text-ink/45 pt-1 flex-shrink-0",children:[zu[t.tool]," #",s]}),e("div",{className:"flex-1 min-w-0 space-y-1",children:[e("div",{className:"flex items-center gap-1 flex-wrap",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/40",children:"bagian"}),yA.map((c)=>{let x=t.label===c;return e("button",{type:"button",onClick:()=>l(x?"":c),"aria-pressed":x,className:`px-1.5 py-0.5 rounded-full border text-[10px] font-mono transition-colors cursor-pointer ${x?"bg-ink text-canvas border-ink":"bg-canvas text-ink/65 border-ink/15 hover:border-ink/40"}`,children:c},c)}),e("input",{value:t.label,onInput:(c)=>l(c.currentTarget.value),placeholder:"or type your own…","aria-label":"Name of the marked part",spellcheck:!1,className:`${W} flex-1 min-w-[110px]`})]}),e("textarea",{value:t.note,onInput:(c)=>p(c.currentTarget.value),placeholder:"What is wrong with this part? (e.g. the Pay button looks disabled)",rows:2,"aria-label":"Annotation note",className:`${W} resize-y`}),h?e("p",{className:"text-[10px] font-mono text-ink/45 truncate",title:h.path,children:["elemen: ",h.path,h.state?` · ${h.state}`:""]}):null,f?e("p",{className:"text-[10px] text-ink/40",children:f}):null]})]})}var me=["box","pin","arrow"],pe="px-2 py-1 rounded text-[11px] font-mono border transition-colors cursor-pointer",U="flex items-center gap-1 px-2 py-1 rounded text-[11px] border border-ink/15 hover:border-ink/40 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed";function j({tool:t,shapes:s,selectedId:r,readability:l,onTool:p,onLabel:f,onNote:h,onRemove:c,onReset:x,onCancel:A,onSend:P}){let T=s.find((E)=>E.id===r)??null,v=s.length>0;return e("div",{className:"flex-shrink-0 border-b border-ink/10 bg-paper px-2.5 py-1.5 space-y-1.5 select-none",children:[e("div",{className:"flex items-center gap-1.5",children:[e("span",{className:"text-[10px] uppercase font-mono text-ink/50 mr-1",children:"Anotasi"}),me.map((E)=>e("button",{type:"button",onClick:()=>p(E),"aria-pressed":t===E,className:`${pe} ${t===E?"bg-ink text-canvas border-ink":"bg-canvas text-ink/70 border-ink/15 hover:border-ink/40"}`,children:zu[E]},E)),e("span",{className:"text-[11px] font-mono text-ink/45 ml-1",children:s.length>0?`${s.length} mark${s.length===1?"":"s"}`:"drag on the page to mark a part"}),e("div",{className:"flex-1"}),e("button",{type:"button",onClick:x,disabled:!v,className:U,title:"Clear all marks",children:[e(L,{size:12})," Bersihkan"]}),e("button",{type:"button",onClick:P,disabled:!v,className:U,title:"Kirim anotasi ke draft chat",children:[e(Ln,{size:12})," Kirim ke chat"]}),e("button",{type:"button",onClick:A,className:U,title:"Tutup mode anotasi",children:e(b,{size:12})})]}),T?e("div",{className:"flex items-start gap-1.5",children:[e("div",{className:"flex-1 min-w-0",children:e(Y,{shape:T,index:s.indexOf(T)+1,readability:l,onLabel:(E)=>f(T.id,E),onNote:(E)=>h(T.id,E)})}),e("button",{type:"button",onClick:()=>c(T.id),className:U,title:"Remove this mark",children:e(L,{size:12})})]}):e("p",{className:"text-[11px] text-ink/45",children:"This page cannot be screenshotted, so what gets sent is the area, the part name and your note."})]})}var q=0;function J(){return q+=1,`annot-${Date.now().toString(36)}-${q}`}function Q(t){let[s,r]=n(!1),[l,p]=n("box"),[f,h]=n([]),[c,x]=n(null);o(()=>{h([]),x(null)},[t]);let A=a(()=>{r((N)=>!N),x(null)},[]),P=a(()=>{x(null),r(!1)},[]),T=a((N)=>{h((B)=>[...B,N]),x(N.id)},[]),v=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,note:B}:g))},[]),E=a((N,B)=>{h((u)=>u.map((g)=>g.id===N?{...g,label:B}:g))},[]),I=a((N)=>{h((B)=>B.filter((u)=>u.id!==N)),x((B)=>B===N?null:B)},[]),C=a(()=>{h([]),x(null)},[]);return{active:s,tool:l,shapes:f,selectedId:c,setTool:p,toggle:A,close:P,add:T,setNote:v,setLabel:E,select:x,remove:I,reset:C}}var fe=4,_="var(--theme-error)";function ee({shapes:t,tool:s,selectedId:r,onMeasure:l,onAdd:p,onSelect:f}){let h=i(null),c=i(null),[x,A]=n(null),[P,T]=n({width:0,height:0});o(()=>{let u=h.current;if(!u)return;let g=()=>{let w=u.getBoundingClientRect();if(w.width<=0||w.height<=0)return;T((M)=>M.width===w.width&&M.height===w.height?M:{width:w.width,height:w.height}),l({width:w.width,height:w.height})};if(g(),typeof ResizeObserver!=="function")return;let k=new ResizeObserver(g);return k.observe(u),()=>k.disconnect()},[l]);let v=(u)=>{let g=h.current;if(!g)return null;let k=g.getBoundingClientRect(),w={x:u.clientX-k.left,y:u.clientY-k.top};return{normalized:bA(k,w),px:w.x,py:w.y}},E=(u)=>{if(u.button!==0)return;let g=v(u);if(!g)return;u.preventDefault(),f(null),u.currentTarget.setPointerCapture?.(u.pointerId);let k={id:J(),tool:s,start:g.normalized,end:g.normalized,label:"",note:""};c.current=k,A(k)},I=(u)=>{let g=c.current;if(!g)return;let k=v(u);if(!k)return;let w={...g,end:k.normalized};c.current=w,A(w)},C=(u)=>{let g=c.current;if(!g)return;let k=v(u),w=k?{...g,end:k.normalized}:g;if(c.current=null,A(null),u.currentTarget.releasePointerCapture?.(u.pointerId),w.tool!=="pin"){let M=h.current?.getBoundingClientRect();if((M?Math.hypot((w.end.x-w.start.x)*M.width,(w.end.y-w.start.y)*M.height):0)<fe)return}p(w)},N=()=>{c.current=null,A(null)},B=x?[...t,x]:t;return e("div",{ref:h,className:"absolute inset-0 cursor-crosshair touch-none",onPointerDown:E,onPointerMove:I,onPointerUp:C,onPointerCancel:N,children:e("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${Math.max(1,P.width)} ${Math.max(1,P.height)}`,preserveAspectRatio:"none","aria-label":"Page annotation area",children:B.map((u,g)=>e(he,{shape:u,index:g+1,box:P,selected:u.id===r,onSelect:()=>f(u.id)},u.id))})})}function he({shape:t,index:s,box:r,selected:l,onSelect:p}){let f={x:t.start.x*r.width,y:t.start.y*r.height},h={x:t.end.x*r.width,y:t.end.y*r.height},c=jp(t),x=l?3:2,A=String(s);return e("g",{onPointerDown:(T)=>{T.stopPropagation(),T.preventDefault(),p()},className:"cursor-pointer",children:[t.tool==="box"&&e("rect",{x:c.x*r.width,y:c.y*r.height,width:Math.max(1,c.width*r.width),height:Math.max(1,c.height*r.height),fill:_,fillOpacity:l?0.16:0.1,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke",rx:3}),t.tool==="arrow"&&e(d,{children:[e("line",{x1:f.x,y1:f.y,x2:h.x,y2:h.y,stroke:_,strokeWidth:x,vectorEffect:"non-scaling-stroke"}),e("circle",{cx:h.x,cy:h.y,r:4,fill:_})]}),t.tool==="pin"&&e("circle",{cx:f.x,cy:f.y,r:7,fill:_,fillOpacity:l?0.5:0.3,stroke:_,strokeWidth:x}),e("circle",{cx:f.x,cy:f.y,r:9,fill:_}),e("text",{x:f.x,y:f.y,textAnchor:"middle",dominantBaseline:"central",fontSize:11,fontWeight:700,fill:"var(--theme-paper)",children:A})]})}function te(t){let s=t.trim();if(!s)return s;let r=/^[a-z][a-z0-9+.-]*:/i.test(s)?s:`https://${s}`,l=new URL(r);if(l.protocol!=="http:"&&l.protocol!=="https:")throw Error("Only http and https URLs are allowed");return l.toString()}var ge="userBrowser.history",be="userBrowser.historyIndex",xe="userBrowser.inputUrl";function ne(){let[t,s]=S(ge,[]),[r,l]=S(be,-1),[p,f]=S(xe,""),[h,c]=n(0),[x,A]=n(!1),[P,T]=n(void 0),v=r>=0&&r<t.length?t[r]??"":"",E=a((u)=>{let g=u.trim();if(!g)return;let k;try{k=te(g)}catch(O){T(O instanceof Error?O.message:"Alamat tidak valid");return}T(void 0),A(!0);let M=[...t.slice(0,r+1),k];s(M),l(M.length-1),f(k),c((O)=>O+1)},[t,r,s,l,f]),I=a(()=>{if(r<=0)return;A(!0),l(r-1)},[r,l]),C=a(()=>{if(r>=t.length-1)return;A(!0),l(r+1)},[t.length,r,l]),N=a(()=>{if(!v)return;A(!0),c((u)=>u+1)},[v]),B=a(()=>{A(!1)},[]);return{url:v,input:p,setInput:f,frameKey:h,loading:x,error:P,canGoBack:r>0,canGoForward:r>=0&&r<t.length-1,submit:E,goBack:I,goForward:C,reload:N,markLoaded:B}}function we(t){if(!t)return"no-frame";try{return t.contentDocument?"readable":"cross-origin"}catch{return"cross-origin"}}function F(t){let s=t.replace(/\s+/g," ").trim();return s.length>60?`${s.slice(0,59)}…`:s}function ve(t){let s=t.tagName.toLowerCase();if(t.id)return`${s}#${t.id}`;for(let l of["data-testid","data-test","aria-label"]){let p=t.getAttribute(l);if(p)return`${s}[${l}="${F(p)}"]`}let r=t.getAttribute("role");if(r)return`${s}[role="${r}"]`;return s}function ye(t){let s=[],r=t;while(r&&s.length<4){if(r.tagName.toLowerCase()==="html")break;s.unshift(ve(r)),r=r.parentElement}return s.join(" > ")}function ke(t){let s=[];if(t.disabled)s.push("nonaktif");if(t instanceof HTMLSelectElement||t.tagName.toLowerCase()==="select"){let r=t,p=r.selectedOptions?.[0]?.textContent?.trim()||r.value;if(p)s.push(`nilai "${F(p)}"`);let f=r.options?.length??0;if(f>0)s.push(`${f} opsi`)}else if(t.tagName.toLowerCase()==="input"){let r=t;if(r.type)s.push(`tipe ${r.type}`);if(r.type!=="password"&&r.placeholder)s.push(`placeholder "${F(r.placeholder)}"`)}return s.length>0?s.join(", "):void 0}function Ae(t){let s={path:ye(t),tag:t.tagName.toLowerCase()},r=t.getAttribute("role");if(r)s.role=r;let l=F(t.innerText??t.textContent??"");if(l)s.text=l;let p=ke(t);if(p)s.state=p;return s}function oe(t,s){let r=we(t);if(r!=="readable")return{ok:!1,reason:r};let{contentWindow:l,contentDocument:p}=t;if(!l||!p)return{ok:!1,reason:"cross-origin"};try{let f=Math.min(Math.max(s.x,0),1)*l.innerWidth,h=Math.min(Math.max(s.y,0),1)*l.innerHeight,c=p.elementFromPoint(f,h);if(!c||c===p.documentElement||c===p.body)return{ok:!1,reason:"no-element"};return{ok:!0,element:Ae(c)}}catch{return{ok:!1,reason:"cross-origin"}}}function mt({className:t="",active:s=!0}){let[r,l]=S("userBrowser.viewportMode","responsive"),[p,f]=S("userBrowser.zoomLevel",100),[h,c]=n(null),[x,A]=n(null),[P,T]=n(null),{url:v,input:E,setInput:I,frameKey:C,loading:N,error:B,canGoBack:u,canGoForward:g,submit:k,goBack:w,goForward:M,reload:O,markLoaded:H}=ne(),y=Q(C),re=a(()=>{if(!v)return;window.open(v,"_blank","noopener,noreferrer")},[v]),ae=a(()=>{if(!v)return;Jl({url:v})},[v]),ie=a((R)=>{c((z)=>z&&z.width===R.width&&z.height===R.height?z:R)},[]),se=a((R)=>{let z=oe(x,R.start);T(z),y.add(z.ok?{...R,element:z.element}:R)},[y,x]),le=a(()=>{if(!v||y.shapes.length===0)return;let R=p/100;Jl({url:v,annotations:y.shapes,panel:{width:(h?.width??0)/R,height:(h?.height??0)/R,viewportMode:r,zoom:p}}),y.close()},[v,y,h,r,p]),G=y.active&&Boolean(v);return e("div",{className:`flex flex-col h-full w-full bg-paper text-ink overflow-hidden ${t}`,children:[e(K,{url:v,input:E,loading:N,error:B,canGoBack:u,canGoForward:g,viewportMode:r,zoomLevel:p,onInputChange:I,onSubmit:k,onBack:w,onForward:M,onReload:O,onOpenExternal:re,onIncludeInChat:ae,onChangeViewport:l,onZoomIn:()=>f((R)=>Math.min(200,R+10)),onZoomOut:()=>f((R)=>Math.max(50,R-10)),onResetZoom:()=>f(100),onSetZoom:f,annotate:{active:G,count:y.shapes.length,onToggle:y.toggle}}),G&&e(j,{tool:y.tool,shapes:y.shapes,selectedId:y.selectedId,readability:P,onTool:y.setTool,onLabel:y.setLabel,onNote:y.setNote,onRemove:y.remove,onReset:y.reset,onCancel:y.close,onSend:le}),e(X,{url:v,frameKey:C,loading:N,viewportMode:r,zoomLevel:p,onLoad:H,onFrame:A,active:s,overlay:G?e(ee,{shapes:y.shapes,tool:y.tool,selectedId:y.selectedId,onMeasure:ie,onAdd:se,onSelect:y.select}):null})]})}export{mt as UserBrowserPanel};
|