cogpit 3.5.3 → 3.5.4
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/cli-runtime.js +2 -2
- package/dist/instance-worker.js +1 -1
- package/dist/web/assets/{AutomationsPanel-D7XmgTgZ.js → AutomationsPanel-DTiDsq54.js} +1 -1
- package/dist/web/assets/{CogpitBlock-CiS2M1Q_.js → CogpitBlock-Hk57z10V.js} +17 -17
- package/dist/web/assets/{CommandPaletteHost-Dj06VjlP.js → CommandPaletteHost-BYfieK7H.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-DqQo1F4o.js → ConfigBrowser-C77Ydij0.js} +1 -1
- package/dist/web/assets/CrewPanel-BzEJLKMd.js +1 -0
- package/dist/web/assets/{HighlightedEditor-DPrSCx1c.js → HighlightedEditor-D1S-wotA.js} +2 -2
- package/dist/web/assets/{KeyboardShortcutsDialog-BdXPWBJw.js → KeyboardShortcutsDialog-B_DSi5JO.js} +1 -1
- package/dist/web/assets/MissionHome-B3uYgylE.js +2 -0
- package/dist/web/assets/{MobileFileChanges-Ngv9AlhR.js → MobileFileChanges-DovO__Ap.js} +1 -1
- package/dist/web/assets/{PluginsDialog-CWRSNNll.js → PluginsDialog-o6ySRFLf.js} +1 -1
- package/dist/web/assets/{PreviewPanel-CQcJIdef.js → PreviewPanel-kD79kXYD.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-D5EKIBD7.js → ProjectFilesPanel-CwEqOA2q.js} +3 -3
- package/dist/web/assets/{ProjectSwitcherModal-BoSCOiv9.js → ProjectSwitcherModal-BnWbJWEX.js} +1 -1
- package/dist/web/assets/{TerminalOutput-DYZJD2WR.js → TerminalOutput-DsK-7nR8.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-8sO11Ob-.js → ThemeSelectorModal-D5SBWDm5.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-qv6TkN7g.js → WorkflowsPanel-NU49178V.js} +1 -1
- package/dist/web/assets/{WorktreePanel-Dr82TWOP.js → WorktreePanel-DPk5b1Os.js} +1 -1
- package/dist/web/assets/{edition-ui-DQHX5fm4.js → edition-ui-7WkqSCbs.js} +1 -1
- package/dist/web/assets/index-Bg4A-xl7.js +510 -0
- package/dist/web/assets/{index-DU4gWgPu.js → index-BgZ8qUzM.js} +2 -2
- package/dist/web/assets/{index-BGSPI7dK.js → index-C2tUYo8z.js} +1 -1
- package/dist/web/assets/{index-zhwBlO_8.js → index-CevokSRq.js} +2 -2
- package/dist/web/assets/{index-CHtH7TlZ.js → index-DIuobrPN.js} +2 -2
- package/dist/web/assets/index-DMO9bL9w.css +1 -0
- package/dist/web/assets/{switch-gTnbAJaZ.js → switch-DI9dp0Ya.js} +1 -1
- package/dist/web/assets/{vendor-ui-CKjyvB3_.js → vendor-ui-Dc_kJXxz.js} +202 -197
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/CrewPanel-DzLPmS6o.js +0 -1
- package/dist/web/assets/MissionHome-CTcx5vR7.js +0 -2
- package/dist/web/assets/index-BVmNox_3.js +0 -504
- package/dist/web/assets/index-DKDki7Rz.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ue,r as y,j as t}from"./vendor-react-gGw_S5I_.js";import{ae as Z,bA as $e,ac as Q,b_ as Xe,av as Re,b$ as et,au as re,B as P,aC as Ie,c0 as tt,c1 as st,b2 as Be,b3 as Me,b1 as He,b4 as Ge,b5 as Ke,b6 as Je,G as se,I as ne,c2 as nt,k as De,c3 as We,c4 as it,c5 as Ye,a3 as lt,a4 as at,a8 as ot,a5 as rt,a6 as ct,a7 as dt,a9 as ut,aa as ht,H as Ee,c6 as pt,c7 as mt,o as ft,n as xt,l as gt,D as jt,j as bt,c8 as vt,c9 as yt,ca as wt,cb as Oe,cc as Fe,E as Ct,f as St,U as Nt,h as kt,i as $t}from"./index-BVmNox_3.js";import{V as Rt,cL as Dt}from"./vendor-ui-CKjyvB3_.js";import"./vendor-markdown-BEJ8yVzA.js";function Ze(i){const e=i.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Et(i,e){if(i.length===0&&e.length===0)return 0;if(i.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(i.length,e.length);s+=1){const l=i[s],o=e[s];if(l===void 0)return-1;if(o===void 0)return 1;const a=/^\d+$/.test(l),n=/^\d+$/.test(o);if(a&&n){if(Number(l)!==Number(o))return Number(l)<Number(o)?-1:1;continue}if(a!==n)return a?-1:1;if(l!==o)return l<o?-1:1}return 0}function It(i,e){const s=Ze(i),l=Ze(e);if(!s||!l)return null;for(let o=0;o<3;o+=1)if(s.parts[o]!==l.parts[o])return s.parts[o]<l.parts[o]?-1:1;return Et(s.prerelease,l.prerelease)}function Ue(i){const e=ue.c(33),{value:s,onChange:l,projects:o,disabled:a}=i,n=a===void 0?!1:a,u=y.useId();let r;e[0]!==s.projectIds||e[1]!==s.type?(r=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=r):r=e[2];let v;e[3]!==r?(v=new Set(r),e[3]=r,e[4]=v):v=e[4];const m=v;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Xe,{children:"Available in"}),e[5]=g):g=e[5];const k=`${u}-all`,j=s.type==="all";let c;e[6]!==l?(c=p=>l(p?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=l,e[7]=c):c=e[7];let h;e[8]!==n||e[9]!==k||e[10]!==j||e[11]!==c?(h=t.jsx($e,{id:k,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=k,e[10]=j,e[11]=c,e[12]=h):h=e[12];const f=`${u}-all`;let b;e[13]!==f?(b=t.jsx(Q,{htmlFor:f,children:"All projects on this host, including new projects"}),e[13]=f,e[14]=b):b=e[14];let w;e[15]!==b||e[16]!==h?(w=t.jsxs(Z,{orientation:"horizontal",children:[h,b]}),e[15]=b,e[16]=h,e[17]=w):w=e[17];let S;e[18]!==n||e[19]!==u||e[20]!==l||e[21]!==o||e[22]!==m||e[23]!==s.projectIds||e[24]!==s.type?(S=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:o.map(p=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-${p.id}`,checked:m.has(p.id),disabled:n,onCheckedChange:N=>l({type:"projects",projectIds:N?[...s.projectIds,p.id]:s.projectIds.filter(I=>I!==p.id)})}),t.jsx(Q,{htmlFor:`${u}-${p.id}`,children:p.name})]},p.id))}),e[18]=n,e[19]=u,e[20]=l,e[21]=o,e[22]=m,e[23]=s.projectIds,e[24]=s.type,e[25]=S):S=e[25];const R=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let d;e[26]!==R?(d=t.jsx(Re,{children:R}),e[26]=R,e[27]=d):d=e[27];let C;return e[28]!==n||e[29]!==w||e[30]!==S||e[31]!==d?(C=t.jsxs(et,{disabled:n,children:[g,w,S,d]}),e[28]=n,e[29]=w,e[30]=S,e[31]=d,e[32]=C):C=e[32],C}function Pt(i){const e=ue.c(69),{client:s,run:l,busy:o}=i,a=y.useId(),[n,u]=y.useState(""),[r,v]=y.useState(""),[m,g]=y.useState(null),[k,j]=y.useState(""),[c,h]=y.useState(!1);let f;e[0]!==s||e[1]!==k||e[2]!==r||e[3]!==n||e[4]!==m||e[5]!==l?(f=Y=>{Y.preventDefault(),l(async()=>{var de;if(!m||m.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((de=globalThis.crypto)!=null&&de.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const M=await m.arrayBuffer(),ce=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",M)),Tt).join("");if(ce!==k.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:r,root:new TextDecoder("utf-8",{fatal:!0}).decode(M),fingerprint:ce}),h(!1),u(""),v(""),j("")})},e[0]=s,e[1]=k,e[2]=r,e[3]=n,e[4]=m,e[5]=l,e[6]=f):f=e[6];const b=`${a}-name`;let w;e[7]!==b?(w=t.jsx(Q,{htmlFor:b,children:"Development publisher"}),e[7]=b,e[8]=w):w=e[8];const S=`${a}-name`;let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=Y=>u(Y.target.value),e[9]=R):R=e[9];let d;e[10]!==o||e[11]!==n||e[12]!==S?(d=t.jsx(re,{id:S,value:n,onChange:R,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:o}),e[10]=o,e[11]=n,e[12]=S,e[13]=d):d=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=C):C=e[14];let p;e[15]!==w||e[16]!==d?(p=t.jsxs(Z,{children:[w,d,C]}),e[15]=w,e[16]=d,e[17]=p):p=e[17];const N=`${a}-label`;let I;e[18]!==N?(I=t.jsx(Q,{htmlFor:N,children:"Display name"}),e[18]=N,e[19]=I):I=e[19];const $=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Y=>v(Y.target.value),e[20]=O):O=e[20];let D;e[21]!==o||e[22]!==r||e[23]!==$?(D=t.jsx(re,{id:$,value:r,onChange:O,maxLength:100,required:!0,disabled:o}),e[21]=o,e[22]=r,e[23]=$,e[24]=D):D=e[24];let q;e[25]!==I||e[26]!==D?(q=t.jsxs(Z,{children:[I,D]}),e[25]=I,e[26]=D,e[27]=q):q=e[27];const H=`${a}-root`;let L;e[28]!==H?(L=t.jsx(Q,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=L):L=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var M;g(((M=Y.target.files)==null?void 0:M[0])??null),h(!1)},e[30]=G):G=e[30];let T;e[31]!==o||e[32]!==ee?(T=t.jsx(re,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:o}),e[31]=o,e[32]=ee,e[33]=T):T=e[33];let K;e[34]!==L||e[35]!==T?(K=t.jsxs(Z,{children:[L,T]}),e[34]=L,e[35]=T,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(Q,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let z;e[39]===Symbol.for("react.memo_cache_sentinel")?(z=Y=>{j(Y.target.value),h(!1)},e[39]=z):z=e[39];let U;e[40]!==o||e[41]!==k||e[42]!==J?(U=t.jsx(re,{id:J,value:k,onChange:z,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:o}),e[40]=o,e[41]=k,e[42]=J,e[43]=U):U=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=F):F=e[44];let V;e[45]!==_||e[46]!==U?(V=t.jsxs(Z,{children:[_,U,F]}),e[45]=_,e[46]=U,e[47]=V):V=e[47];const x=`${a}-trust`;let E;e[48]!==o||e[49]!==x||e[50]!==c?(E=t.jsx($e,{id:x,checked:c,onCheckedChange:h,disabled:o}),e[48]=o,e[49]=x,e[50]=c,e[51]=E):E=e[51];const W=`${a}-trust`;let B;e[52]!==W?(B=t.jsx(Q,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=B):B=e[53];let X;e[54]!==E||e[55]!==B?(X=t.jsxs(Z,{orientation:"horizontal",children:[E,B]}),e[54]=E,e[55]=B,e[56]=X):X=e[56];const ae=o||!c||!m;let ie;e[57]!==ae?(ie=t.jsx(P,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==q||e[60]!==K||e[61]!==V||e[62]!==X||e[63]!==ie||e[64]!==p?(le=t.jsxs(Ie,{children:[p,q,K,V,X,ie]}),e[59]=q,e[60]=K,e[61]=V,e[62]=X,e[63]=ie,e[64]=p,e[65]=le):le=e[65];let oe;return e[66]!==f||e[67]!==le?(oe=t.jsx("form",{onSubmit:f,children:le}),e[66]=f,e[67]=le,e[68]=oe):oe=e[68],oe}function Tt(i){return i.toString(16).padStart(2,"0")}const At={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Ot({client:i,preview:e,activation:s,key:l,onFrame:o,onComplete:a,onError:n}){const u=new AbortController;let r="loading",v,m=0;const g=()=>new Error("The installation check expired. Review the package again to retry.");function k(f){r==="canceled"||r==="finished"||(r="canceled",clearTimeout(v),u.abort(),o(null),n(f))}function j(){r==="canceled"||r==="finished"||(r="finished",clearTimeout(v),a())}async function c(f){if(r==="committing"){r="recovering",clearTimeout(v);try{const b=await i.transactionOutcome(e);if(r!=="recovering")return;b.status==="committed"?(await i.refresh(),r==="recovering"&&j()):k(f)}catch{r==="recovering"&&k(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function h(){if(r==="trial"){if(Date.now()>m){k(g());return}r="committing";try{await i.commit(e,u.signal),r==="committing"&&j()}catch(f){await c(f instanceof Error?f:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const f=await i.payload(e.transactionId,u.signal);if(u.signal.aborted||(e.manifest.entry||await st(f,e.digest),m=await i.beginTrial(e,u.signal),u.signal.aborted))return;const b=m-Date.now();if(b<=0){k(g());return}if(r="trial",v=setTimeout(()=>{r==="committing"?(u.abort(),c(g())):r==="trial"&&k(g())},b),!e.manifest.entry){await h();return}o({key:l,client:i,props:{payload:f,digest:e.digest,activationKey:l,context:At,active:!1,title:"Plugin installation check",execute:async(w,S)=>{if(u.signal.throwIfAborted(),S.throwIfAborted(),w.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{h()},onError:k}})}catch(f){k(f instanceof Error?f:new Error("Plugin trial failed"))}})(),()=>{r="canceled",clearTimeout(v),u.abort()}}function Ft(i){const e=ue.c(22),{client:s,preview:l,activation:o,onComplete:a,onError:n}=i,u=`${o}:trial:${l.transactionId}:${l.digest}:${l.registryRevision}`,[r,v]=y.useState(null);let m;e[0]!==a||e[1]!==n?(m={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=m):m=e[2];const g=y.useRef(m);let k;e[3]!==a||e[4]!==n?(k=()=>{g.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=k):k=e[5],y.useLayoutEffect(k);let j,c;e[6]!==o||e[7]!==s||e[8]!==u||e[9]!==l?(j=()=>Ot({client:s,preview:l,activation:o,key:u,onFrame:v,onComplete:()=>g.current.onComplete(),onError:w=>g.current.onError(w)}),c=[s,l,o,u],e[6]=o,e[7]=s,e[8]=u,e[9]=l,e[10]=j,e[11]=c):(j=e[10],c=e[11]),y.useLayoutEffect(j,c);let h;e[12]!==l.manifest.name?(h=t.jsxs("p",{children:["Checking that ",l.manifest.name," starts correctly…"]}),e[12]=l.manifest.name,e[13]=h):h=e[13];let f;e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==u?(f=o&&(r==null?void 0:r.key)===u&&r.client===s&&t.jsx(tt,{...r.props}),e[14]=o,e[15]=s,e[16]=r,e[17]=u,e[18]=f):f=e[18];let b;return e[19]!==h||e[20]!==f?(b=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[h,f]}),e[19]=h,e[20]=f,e[21]=b):b=e[21],b}function _t({connection:i,resourceId:e,target:s,client:l,disabled:o,save:a}){const n=y.useId(),u=i.definition.resources[e],r=nt(i.definition,e),v=!!u.options&&r.length===0,m=i.selected[e],[g,k]=y.useState(""),[j,c]=y.useState(null),[h,f]=y.useState(!1),[b,w]=y.useState(null),S=y.useRef(null);y.useEffect(()=>()=>{var $;return($=S.current)==null?void 0:$.abort()},[]);const R=r.find($=>!i.selected[$]),d=o||!!R||u.scope==="project"&&!s.projectId,C=y.useCallback(async()=>{var O;(O=S.current)==null||O.abort();const $=new AbortController;S.current=$,f(!0),w(null);try{const D=await l.connectionOptions(s,i.id,e,$.signal);if($.signal.aborted)return;c(D)}catch(D){$.signal.aborted||w(D instanceof Error?D.message:"Unable to load choices")}finally{$.signal.aborted||f(!1)}},[l,s,i.id,e]),p=j===null&&!h&&!b;y.useEffect(()=>{v&&p&&!d&&C()},[v,p,d,C]);const N=m&&!(j!=null&&j.some($=>$.id===m.id))?[m,...j??[]]:j??[],I=t.jsxs(Je,{items:N.map($=>({value:$.id,label:$.label})),value:(m==null?void 0:m.id)??null,disabled:d||h||!j,onValueChange:$=>{$&&$!==(m==null?void 0:m.id)&&a(i.id,"select",{resourceId:e,value:$})},children:[t.jsx(Ke,{id:`${n}-resource`,"aria-invalid":!!b,children:t.jsx(Ge,{placeholder:h?"Loading choices…":`Choose ${u.label}`})}),t.jsx(Be,{children:t.jsx(Me,{children:N.map($=>t.jsx(He,{value:$.id,children:$.label},$.id))})})]});return t.jsxs(Z,{"data-disabled":d,"data-invalid":!!b,children:[t.jsx(Q,{htmlFor:`${n}-resource`,children:u.label}),t.jsx(Re,{children:u.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),m&&!v&&t.jsxs("p",{className:"text-sm",children:["Selected: ",m.label]}),R&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",i.definition.resources[R].label," first."]}),u.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),u.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[v?I:t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{C()},children:h?"Loading choices…":j?"Refresh choices":"Browse choices"}),!v&&j&&I,v&&b&&t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{C()},children:"Try again"}),(j==null?void 0:j.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),u.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:$=>{$.preventDefault(),a(i.id,"select",{resourceId:e,value:g.trim()})},children:[t.jsx(re,{id:u.options?`${n}-input`:`${n}-resource`,"aria-label":`${u.label} ${u.input.urls?"URL or ID":"ID"}`,value:g,onChange:$=>k($.target.value),maxLength:2048,disabled:d,autoComplete:"off",spellCheck:!1,placeholder:u.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(P,{type:"submit",size:"sm",variant:"outline",disabled:d||!g.trim(),children:"Validate and select"})]}),m&&t.jsxs(P,{type:"button",size:"sm",variant:"ghost",disabled:d,onClick:()=>{a(i.id,"select",{resourceId:e,value:null})},children:["Clear ",u.label]}),b&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:b})]})}function Lt(i){const e=ue.c(45),{connection:s,target:l,client:o,disabled:a,save:n}=i,u=y.useId(),[r,v]=y.useState(""),[m,g]=y.useState(!1),k=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let h;e[2]!==c?(h=t.jsx(De,{variant:"outline",children:c}),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==j||e[5]!==h?(f=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,h]}),e[4]=j,e[5]=h,e[6]=f):f=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=b):b=e[7];let w;e[8]!==s.definition.operations?(w=new Set(Object.values(s.definition.operations).map(zt)),e[8]=s.definition.operations,e[9]=w):w=e[9];let S;e[10]!==w?(S=[...w],e[10]=w,e[11]=S):S=e[11];const R=S.join(", ");let d;e[12]!==R?(d=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",R]}),e[12]=R,e[13]=d):d=e[13];let C;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==u||e[20]!==m||e[21]!==n?(C=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-replace`,checked:m,onCheckedChange:g,disabled:a}),t.jsx(Q,{htmlFor:`${u}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:m})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=u,e[20]=m,e[21]=n,e[22]=C):C=e[22];let p;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==u||e[29]!==n||e[30]!==r?(p=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:$=>{$.preventDefault();const O=r.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Ie,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(Q,{htmlFor:`${u}-secret`,children:s.definition.secret.label}),t.jsx(re,{id:`${u}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:r,onChange:$=>v($.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(P,{type:"submit",size:"sm",disabled:a||!r.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=u,e[29]=n,e[30]=r,e[31]=p):p=e[31];let N;e[32]!==o||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==l?(N=s.status!=="disconnected"&&t.jsx(Ie,{children:Object.keys(s.definition.resources).map($=>t.jsx(_t,{connection:s,resourceId:$,target:l,client:o,disabled:a,save:n},$))}),e[32]=o,e[33]=s,e[34]=a,e[35]=n,e[36]=l,e[37]=N):N=e[37];let I;return e[38]!==s.label||e[39]!==d||e[40]!==C||e[41]!==p||e[42]!==N||e[43]!==f?(I=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":k,children:[f,b,d,C,p,N]}),e[38]=s.label,e[39]=d,e[40]=C,e[41]=p,e[42]=N,e[43]=f,e[44]=I):I=e[44],I}function zt(i){return i.origin}function Vt({client:i,target:e}){const[s,l]=y.useState(null),[o,a]=y.useState(null),[n,u]=y.useState(!1),r=y.useRef(null),v=y.useRef(!1),m=e.pluginId,g=e.projectId;y.useEffect(()=>{const j=new AbortController;return r.current=j,i.connections({pluginId:m,projectId:g},j.signal).then(c=>{j.signal.aborted||l(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),r.current=null}},[i,m,g]);async function k(j,c,h){if(!s||v.current||!r.current||r.current.signal.aborted)return;v.current=!0;const f=r.current.signal;u(!0),a(null);try{const b=await i.changeConnection(e,j,c,h,s.revision,f);f.aborted||l(b)}catch(b){f.aborted||a(b instanceof Error?b.message:"Connection change failed")}finally{v.current=!1,f.aborted||u(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[o&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:o})}),!s&&!o&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Lt,{connection:j,target:e,client:i,disabled:n,save:k},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function qt(i){const e=ue.c(32),{client:s,status:l,pluginId:o,initialProjectId:a}=i,[n,u]=y.useState(a),r=y.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let m;e[1]!==l.projects?(m=[v,...l.projects.map(Bt)],e[1]=l.projects,e[2]=m):m=e[2];const g=m;let k;e[3]!==r?(k=t.jsx(Q,{htmlFor:r,children:"Project settings"}),e[3]=r,e[4]=k):k=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=I=>u(I||null),e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ge,{}),e[6]=h):h=e[6];let f;e[7]!==r?(f=t.jsx(Ke,{id:r,children:h}),e[7]=r,e[8]=f):f=e[8];let b;e[9]!==g?(b=t.jsx(Be,{children:t.jsx(Me,{children:g.map(Ut)})}),e[9]=g,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==j||e[13]!==f||e[14]!==b?(w=t.jsxs(Je,{items:g,value:j,onValueChange:c,children:[f,b]}),e[11]=g,e[12]=j,e[13]=f,e[14]=b,e[15]=w):w=e[15];let S;e[16]!==l.host.name?(S=t.jsxs(Re,{children:["Connection credentials belong to ",l.host.name,". Project resources stay within the project you choose."]}),e[16]=l.host.name,e[17]=S):S=e[17];let R;e[18]!==S||e[19]!==k||e[20]!==w?(R=t.jsxs(Z,{children:[k,w,S]}),e[18]=S,e[19]=k,e[20]=w,e[21]=R):R=e[21];const d=`${o}:${n??"host"}:${l.connectionRevision??0}`;let C;e[22]!==o||e[23]!==n?(C={pluginId:o,projectId:n},e[22]=o,e[23]=n,e[24]=C):C=e[24];let p;e[25]!==s||e[26]!==d||e[27]!==C?(p=t.jsx(Vt,{client:s,target:C},d),e[25]=s,e[26]=d,e[27]=C,e[28]=p):p=e[28];let N;return e[29]!==R||e[30]!==p?(N=t.jsxs("div",{className:"flex flex-col gap-4",children:[R,p]}),e[29]=R,e[30]=p,e[31]=N):N=e[31],N}function Ut(i){return t.jsx(He,{value:i.value,children:i.label},i.value)}function Bt(i){return{value:i.id,label:i.name}}function Mt({client:i,pluginId:e,projectId:s,definition:l}){var R;const o=y.useId(),[a,n]=y.useState(null),[u,r]=y.useState({}),[v,m]=y.useState(null),[g,k]=y.useState(!1),[j,c]=y.useState(""),[h,f]=y.useState(0),b=y.useRef(null),w=l.scope==="project"&&!s;y.useEffect(()=>{var C;if((C=b.current)==null||C.abort(),b.current=null,k(!1),n(null),m(null),c(""),w)return;const d=new AbortController;return i.settings({pluginId:e,projectId:s},d.signal).then(p=>{d.signal.aborted||(n(p),r(We(l,p.values)))}).catch(p=>{d.signal.aborted||m(p instanceof Error?p.message:"Unable to load plugin settings")}),()=>{var p;d.abort(),(p=b.current)==null||p.abort()}},[i,e,s,l,w,h]);async function S(d){if(d.preventDefault(),!a||g)return;let C;try{C=We(l,u)}catch{m("Check the setting values and their limits.");return}k(!0),m(null),c("");const p=new AbortController;b.current=p;try{const N=await i.saveSettings({pluginId:e,projectId:s},C,a.revision,p.signal);p.signal.aborted||(n(N),r(N.values),c("Settings saved."))}catch(N){p.signal.aborted||m(N instanceof Error?N.message:"Unable to save plugin settings")}finally{b.current===p&&(b.current=null,p.signal.aborted||k(!1))}}return w?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a project to edit this plugin's settings."}):t.jsx("form",{onSubmit:d=>{S(d)},children:t.jsxs(Ie,{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:l.scope==="project"?"Settings for this project.":"Settings for your account on this host."}),a&&l.fields.map(d=>{const C=`${o}-${d.id}`,p=N=>{r(I=>({...I,[d.id]:N})),c("")};return t.jsxs(Z,{"data-disabled":g,children:[t.jsx(Q,{htmlFor:C,children:d.label}),d.description&&t.jsx(Re,{children:d.description}),d.type==="boolean"?t.jsx($e,{id:C,checked:u[d.id]===!0,disabled:g,onCheckedChange:N=>p(N===!0)}):d.type==="select"?t.jsxs(Je,{value:String(u[d.id]),items:d.options,disabled:g,onValueChange:N=>{N!==null&&p(String(N))},children:[t.jsx(Ke,{id:C,children:t.jsx(Ge,{})}),t.jsx(Be,{children:t.jsx(Me,{children:d.options.map(N=>t.jsx(He,{value:N.value,children:N.label},N.value))})})]}):t.jsx(re,{id:C,disabled:g,type:d.type==="number"?"number":"text",value:String(u[d.id]??""),...d.type==="number"?{min:d.min,max:d.max,step:d.step??"any"}:{maxLength:d.maxLength},onChange:N=>p(d.type==="number"?N.target.value===""?"":Number(N.target.value):N.target.value)})]},d.id)}),!!((R=a==null?void 0:a.adjustedFields)!=null&&R.length)&&t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Some saved values no longer match this version. Defaults are shown for ",a.adjustedFields.join(", "),"; save to apply them."]}),!a&&!v&&t.jsx("p",{role:"status",children:"Loading settings…"}),v&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v}),j&&t.jsx("p",{role:"status",className:"text-sm",children:j}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(P,{type:"submit",disabled:!a||g,children:g?"Saving…":"Save settings"}),t.jsx(P,{type:"button",variant:"outline",disabled:g,onClick:()=>f(d=>d+1),children:"Reload settings"})]})]})})}function Ht(i){var ie;const e=ue.c(175),{plugin:s,status:l,client:o,busy:a,run:n,onPreview:u,onConnections:r,onUpdate:v}=i,m=y.useId(),[g,k]=y.useState(s.scope),[j,c]=y.useState(!1),[h,f]=y.useState(!1);let b,w,S,R,d,C,p,N,I,$,O,D;if(e[0]!==a||e[1]!==o||e[2]!==r||e[3]!==u||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==g||e[8]!==l.host.name||e[9]!==l.projects||e[10]!==l.runtime||e[11]!==l.store){const le=it(),oe=Ye(s.manifest,le,l.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==o||e[25]!==s.id||e[26]!==n||e[27]!==l.store?(Y=(A,Ae)=>n(()=>o.changeInstalled(s.id,A,Ae,l.store.revision)),e[24]=o,e[25]=s.id,e[26]=n,e[27]=l.store,e[28]=Y):Y=e[28];const M=Y,ce=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let de;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==l.store?(de=s.lastError&&((ie=l.store.availableSeeds)==null?void 0:ie.find(A=>A.manifest.id===s.id&&A.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=l.store,e[33]=de):de=e[33];const _e=de;$="flex flex-col gap-3 rounded-lg border p-4";let he;e[34]!==s.manifest.name?(he=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=he):he=e[35];let pe;e[36]!==s.id||e[37]!==s.manifest.version?(pe=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=pe):pe=e[38];let me;e[39]!==he||e[40]!==pe?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[he,pe]}),e[39]=he,e[40]=pe,e[41]=me):me=e[41];const Le=ce==="Enabled"?"secondary":"outline";let fe;e[42]!==ce||e[43]!==Le?(fe=t.jsx(De,{variant:Le,children:ce}),e[42]=ce,e[43]=Le,e[44]=fe):fe=e[44],e[45]!==me||e[46]!==fe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,fe]}),e[45]=me,e[46]=fe,e[47]=O):O=e[47],e[48]!==s.lastError?(D=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=D):D=e[49],w=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(A=>t.jsxs("p",{children:[A.side==="client"?"This client":A.side==="host"?l.host.name:"This package",": ",A.name," requires ",A.required,"; available ",A.actual??"none","."]},`${A.side}:${A.code}:${A.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==M||e[51]!==s.enabled?(xe=()=>M("enabled",{enabled:!s.enabled}),e[50]=M,e[51]=s.enabled,e[52]=xe):xe=e[52];const ze=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==ze?(ge=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:ze}),e[53]=a,e[54]=xe,e[55]=ze,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==r||e[59]!==s.id||e[60]!==s.manifest.contributes||e[61]!==s.manifest.permissions.connections.length?(je=(s.manifest.permissions.connections.length>0||s.manifest.contributes.settings)&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>r(s.id),children:s.manifest.contributes.settings?"Settings":"Connections"}),e[57]=a,e[58]=r,e[59]=s.id,e[60]=s.manifest.contributes,e[61]=s.manifest.permissions.connections.length,e[62]=je):je=e[62];const Ve=a||s.pinned;let be;e[63]!==v||e[64]!==s?(be=()=>v(s),e[63]=v,e[64]=s,e[65]=be):be=e[65];let ve;e[66]!==Ve||e[67]!==be?(ve=t.jsx(P,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[66]=Ve,e[67]=be,e[68]=ve):ve=e[68];let ye;e[69]!==a||e[70]!==o||e[71]!==u||e[72]!==s.id||e[73]!==s.scope||e[74]!==_e||e[75]!==n?(ye=_e&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>u(await o.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[69]=a,e[70]=o,e[71]=u,e[72]=s.id,e[73]=s.scope,e[74]=_e,e[75]=n,e[76]=ye):ye=e[76];let we;e[77]!==M||e[78]!==s.pinned?(we=()=>M("pin",{pinned:!s.pinned}),e[77]=M,e[78]=s.pinned,e[79]=we):we=e[79];const qe=s.pinned?"Unpin version":"Pin version";let Ce;e[80]!==a||e[81]!==we||e[82]!==qe?(Ce=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:we,children:qe}),e[80]=a,e[81]=we,e[82]=qe,e[83]=Ce):Ce=e[83];let Pe;e[84]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>{f(!1),c(!0)},e[84]=Pe):Pe=e[84];let Se;e[85]!==a?(Se=t.jsx(P,{size:"sm",variant:"ghost",disabled:a,onClick:Pe,children:"Uninstall"}),e[85]=a,e[86]=Se):Se=e[86],e[87]!==ge||e[88]!==je||e[89]!==ve||e[90]!==ye||e[91]!==Ce||e[92]!==Se?(S=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,Ce,Se]}),e[87]=ge,e[88]=je,e[89]=ve,e[90]=ye,e[91]=Ce,e[92]=Se,e[93]=S):S=e[93],e[94]!==s.pinned?(R=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[94]=s.pinned,e[95]=R):R=e[95],N="text-sm",e[96]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[96]=I):I=e[96],b="flex flex-col gap-4 pt-4",e[97]!==a||e[98]!==g||e[99]!==l.projects?(d=t.jsx(Ue,{value:g,onChange:k,projects:l.projects,disabled:a}),e[97]=a,e[98]=g,e[99]=l.projects,e[100]=d):d=e[100];let Ne;e[101]!==a||e[102]!==s.scope||e[103]!==g?(Ne=a||JSON.stringify(g)===JSON.stringify(s.scope),e[101]=a,e[102]=s.scope,e[103]=g,e[104]=Ne):Ne=e[104];let ke;e[105]!==M||e[106]!==g?(ke=()=>M("scope",{scope:g}),e[105]=M,e[106]=g,e[107]=ke):ke=e[107],e[108]!==l.host.name||e[109]!==Ne||e[110]!==ke?(C=t.jsxs(P,{size:"sm",variant:"outline",disabled:Ne,onClick:ke,children:["Save projects on ",l.host.name]}),e[108]=l.host.name,e[109]=Ne,e[110]=ke,e[111]=C):C=e[111];let Te;e[112]!==s.selectedDigest?(Te=A=>A.digest!==s.selectedDigest,e[112]=s.selectedDigest,e[113]=Te):Te=e[113],p=s.versions.filter(Te).map(A=>{const Ae=!A.unavailableReason&&Ye(A.manifest,le,l.runtime,{allowPrerelease:A.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(P,{size:"sm",variant:"outline",disabled:a||s.pinned||!Ae,onClick:()=>n(async()=>u({...await o.rollback(s.id,A.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",A.manifest.version]}),!Ae&&t.jsx("p",{className:"text-xs text-muted-foreground",children:A.unavailableReason??"This version is incompatible with the connected host or client."})]},A.digest)}),e[0]=a,e[1]=o,e[2]=r,e[3]=u,e[4]=v,e[5]=s,e[6]=n,e[7]=g,e[8]=l.host.name,e[9]=l.projects,e[10]=l.runtime,e[11]=l.store,e[12]=b,e[13]=w,e[14]=S,e[15]=R,e[16]=d,e[17]=C,e[18]=p,e[19]=N,e[20]=I,e[21]=$,e[22]=O,e[23]=D}else b=e[12],w=e[13],S=e[14],R=e[15],d=e[16],C=e[17],p=e[18],N=e[19],I=e[20],$=e[21],O=e[22],D=e[23];let q;e[114]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[114]=q):q=e[114];let H;e[115]!==b||e[116]!==d||e[117]!==C||e[118]!==p?(H=t.jsxs("div",{className:b,children:[d,C,p,q]}),e[115]=b,e[116]=d,e[117]=C,e[118]=p,e[119]=H):H=e[119];let L;e[120]!==H||e[121]!==N||e[122]!==I?(L=t.jsxs("details",{className:N,children:[I,H]}),e[120]=H,e[121]=N,e[122]=I,e[123]=L):L=e[123];let ee;e[124]!==s.manifest.name?(ee=t.jsxs(lt,{children:["Uninstall ",s.manifest.name,"?"]}),e[124]=s.manifest.name,e[125]=ee):ee=e[125];let G;e[126]!==l.host.name?(G=t.jsxs(at,{children:["This removes the plugin from ",l.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[126]=l.host.name,e[127]=G):G=e[127];let T;e[128]!==ee||e[129]!==G?(T=t.jsxs(rt,{children:[ee,G]}),e[128]=ee,e[129]=G,e[130]=T):T=e[130];const K=`${m}-delete`,te=a||l.connectionRevision===void 0;let _;e[131]!==h||e[132]!==K||e[133]!==te?(_=t.jsx($e,{id:K,checked:h,onCheckedChange:f,disabled:te}),e[131]=h,e[132]=K,e[133]=te,e[134]=_):_=e[134];const J=`${m}-delete`;let z;e[135]!==J?(z=t.jsx(Q,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[135]=J,e[136]=z):z=e[136];let U;e[137]!==_||e[138]!==z?(U=t.jsxs(Z,{orientation:"horizontal",children:[_,z]}),e[137]=_,e[138]=z,e[139]=U):U=e[139];let F;e[140]!==h?(F=h&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[140]=h,e[141]=F):F=e[141];let V;e[142]!==a?(V=t.jsx(ct,{disabled:a,children:"Cancel"}),e[142]=a,e[143]=V):V=e[143];let x;e[144]!==o||e[145]!==h||e[146]!==s.id||e[147]!==n||e[148]!==l.connectionRevision||e[149]!==l.store?(x=()=>{c(!1),n(()=>o.changeInstalled(s.id,"uninstall",h?{deleteData:!0,expectedConnectionRevision:l.connectionRevision}:{deleteData:!1},l.store.revision))},e[144]=o,e[145]=h,e[146]=s.id,e[147]=n,e[148]=l.connectionRevision,e[149]=l.store,e[150]=x):x=e[150];let E;e[151]!==a||e[152]!==l.host.name||e[153]!==x?(E=t.jsxs(ot,{variant:"destructive",disabled:a,onClick:x,children:["Uninstall from ",l.host.name]}),e[151]=a,e[152]=l.host.name,e[153]=x,e[154]=E):E=e[154];let W;e[155]!==V||e[156]!==E?(W=t.jsxs(dt,{children:[V,E]}),e[155]=V,e[156]=E,e[157]=W):W=e[157];let B;e[158]!==T||e[159]!==U||e[160]!==F||e[161]!==W?(B=t.jsxs(ut,{children:[T,U,F,W]}),e[158]=T,e[159]=U,e[160]=F,e[161]=W,e[162]=B):B=e[162];let X;e[163]!==j||e[164]!==B?(X=t.jsx(ht,{open:j,onOpenChange:c,children:B}),e[163]=j,e[164]=B,e[165]=X):X=e[165];let ae;return e[166]!==w||e[167]!==S||e[168]!==R||e[169]!==L||e[170]!==X||e[171]!==$||e[172]!==O||e[173]!==D?(ae=t.jsxs("article",{className:$,children:[O,D,w,S,R,L,X]}),e[166]=w,e[167]=S,e[168]=R,e[169]=L,e[170]=X,e[171]=$,e[172]=O,e[173]=D,e[174]=ae):ae=e[174],ae}const Gt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Kt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",pullReview:"pull request changes and patches",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"},Jt={append:"Append text to your draft message",context:"Add file references with notes to your draft message",drafts:"Read, save and restore your composer drafts, including images and sent-message history kept in this browser"},Wt={snapshot:"Read this project's worktree setup command and recent setup output",scripts:"Read the script names in this project's root package.json",propose:"Propose a setup command that runs in new worktrees; Cogpit shows the exact command and saves it only when you trust it",act:"Retry or cancel a worktree setup that is waiting before the first prompt"};function Yt(i,e){return i==="worktreeSetup"?Wt[e]:e==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":e==="mergePull"?"Merge pull requests in the selected GitHub repository when you confirm, using this host's signed-in CLI":e==="submitReview"?"Post review comments to pull requests in the selected GitHub repository when you submit them, using this host's signed-in CLI":e==="reviewGuide"||e==="cancelReviewGuide"?"Read and cancel the review guides this host generates for pull requests":`Read ${Gt[i]} ${Kt[e]} using this host's signed-in CLI`}function Qe(i){const e=i.permissions;return[...new Set([...e.context.map(s=>s==="session.identity"?"Recognise the open session among related sessions, by handle only":"Read the selected project's name and plugin identifier"),...e.composer.map(s=>Jt[s]),...e.review.map(()=>"Ask to start a pull request session in a new worktree, which you confirm and choose the provider for"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...i.contributes.settings?[`Add ${i.contributes.settings.fields.length} ${i.contributes.settings.scope} settings fields`]:[],...(i.contributes.skills??[]).map(s=>`Provide agent instructions: ${s.title}`),...(i.contributes.chatBlocks??[]).map(s=>`Render ${s.title} cards and read the text inside their declared chat blocks`),...(i.contributes.sessionActions??[]).map(s=>`Add a ${s.title} button that sends an agent request when clicked`),...i.contributes.dictation?[`Add a ${i.contributes.dictation.title} button that records your microphone only while you dictate, and sends the recording to connection ${i.contributes.dictation.connection} to transcribe`]:[],...e.connections.flatMap(s=>s.operations.map(l=>`Use connection ${s.id}: ${l}`)),...e.integrations.flatMap(s=>s.operations.map(l=>Yt(s.id,l)))])]}function Zt(i){var j;const e=ue.c(32),{preview:s}=i;let l,o,a,n,u,r;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=Qe(s.manifest),h=s.previousManifest?Qe(s.previousManifest):null,f=h?c.filter(S=>!h.includes(S)):[],b=h?h.filter(S=>!c.includes(S)):[],w=s.previousConnectionDefinitions?s.connectionDefinitions.filter(S=>{var d;const R=(d=s.previousConnectionDefinitions)==null?void 0:d.find(C=>C.id===S.id);return!R||JSON.stringify(R)!==JSON.stringify(S)}):[];l="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(o=s.oldVersion&&t.jsxs(se,{children:[t.jsx(Ee,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=o):o=e[14],a=h&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),f.length===0&&b.length===0&&w.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),f.map(as),b.map(ls),w.map(is)]}),n=s.oldVersion&&!h&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=u):u=e[15],r=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(ns)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=l,e[7]=o,e[8]=a,e[9]=n,e[10]=u,e[11]=r}else l=e[6],o=e[7],a=e[8],n=e[9],u=e[10],r=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Qt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let m;e[18]!==s.incompatibleClients?(m=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=m):m=e[19];let g;e[20]!==s.digest?(g=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=g):g=e[21];let k;return e[22]!==l||e[23]!==o||e[24]!==a||e[25]!==n||e[26]!==u||e[27]!==r||e[28]!==v||e[29]!==m||e[30]!==g?(k=t.jsxs("div",{className:l,children:[o,a,n,u,r,v,m,g]}),e[22]=l,e[23]=o,e[24]=a,e[25]=n,e[26]=u,e[27]=r,e[28]=v,e[29]=m,e[30]=g,e[31]=k):k=e[31],k}function Qt(i){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:i.label}),t.jsxs("p",{children:["Access to ",Object.values(i.resources).map(ss).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(i.operations).map(ts))].join(", ")]}),Object.entries(i.operations).filter(es).map(Xt)]},i.id)}function Xt(i){const[e,s]=i;return t.jsxs("p",{className:"text-muted-foreground",children:[s.method," ",e,s.method==="POST"?" — sends supplied data to this service":"",s.upload?" · sends a microphone recording":"",s.response?" · receives audio":""]},e)}function es(i){const[,e]=i;return e.audience==="panel"}function ts(i){return i.origin}function ss(i){return i.label}function ns(i){return t.jsx("li",{children:i},i)}function is(i){return t.jsxs("p",{children:["Changed connection: ",i.label,". Review its destinations and access below."]},i.id)}function ls(i){return t.jsxs("p",{children:["Removed: ",i]},`remove:${i}`)}function as(i){return t.jsxs("p",{children:["Added: ",i]},`add:${i}`)}function us({client:i,state:e,currentPath:s,onClose:l,initialPluginId:o}){var V;const a=y.useId(),n=e.status,u=pt(),r=(n==null?void 0:n.safeMode)||u,{project:v,resolving:m}=mt({client:i,status:n,activation:e.activation,projectPath:s}),[g,k]=y.useState(null),j=g??{type:"projects",projectIds:v?[v.id]:[]},[c,h]=y.useState(null),[f,b]=y.useState({activation:"",hostName:""}),[w,S]=y.useState(!1),[R,d]=y.useState(!1),[C,p]=y.useState(null),[N,I]=y.useState(null),[$,O]=y.useState("installed"),[D,q]=y.useState(null),[H,L]=y.useState(null),[ee,G]=y.useState(o),T=n==null?void 0:n.store.plugins.find(x=>x.id===ee),K=y.useRef(!1),te=!!(n!=null&&n.store.available)&&f.activation===e.activation;function _(x){b({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),h(x)}y.useEffect(()=>{!c||te&&!(r&&w)||(S(!1),h(null),p("The host connection or plugin execution state changed. Review the package again before installing."),i.cancel(c).catch(()=>{}))},[i,c,te,r,w]),y.useEffect(()=>()=>{c&&i.cancel(c).catch(()=>{})},[i,c]);async function J(x){if(!K.current){K.current=!0,d(!0),p(null),I(null);try{await x()}catch(E){p(E instanceof Error?E.message:"Plugin action failed")}finally{K.current=!1,d(!1)}}}function z(){const x=c;S(!1),h(null),x&&i.cancel(x).catch(()=>{})}async function U(){if(!H||!D&&!g&&m)return;const x=await i.stage(H,(D==null?void 0:D.scope)??j);if(D&&x.manifest.id!==D.id)throw await i.cancel(x),new Error(`Choose a package for ${D.manifest.name} (${D.id}).`);_(x)}const F=R||w||!(n!=null&&n.store.available);return t.jsx(ft,{open:!0,onOpenChange:x=>{!x&&!R&&!w&&(z(),l())},children:t.jsxs(xt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!R&&!w,children:[t.jsxs(gt,{children:[t.jsx(jt,{children:"Plugins"}),t.jsx(bt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||C||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:n!=null&&n.store.available&&!C&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:C??e.error??(n==null?void 0:n.store.error)})]}),N&&t.jsx(se,{children:t.jsx(ne,{children:N})}),r&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(P,{size:"sm",variant:"outline",disabled:R||w||(n==null?void 0:n.safeMode),onClick:()=>vt(!u),children:u?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(P,{variant:"outline",disabled:R,onClick:()=>{J(()=>i.refresh())},children:[t.jsx(Rt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&T&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h2",{className:"font-medium",children:T.manifest.name}),t.jsx(P,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),T.manifest.permissions.connections.length>0&&T.manifest.contributes.settings&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect the service first. Its settings below take effect once it is connected."}),T.manifest.permissions.connections.length>0&&t.jsx(qt,{client:i,status:n,pluginId:T.id,initialProjectId:(v==null?void 0:v.id)??null},`${T.id}:${n.store.revision}`),T.manifest.contributes.settings&&t.jsx(Mt,{client:i,pluginId:T.id,projectId:(v==null?void 0:v.id)??null,definition:T.manifest.contributes.settings},`settings:${T.id}:${n.store.revision}`)]}),n&&!T&&!c&&t.jsxs(yt,{value:$,onValueChange:x=>{O(String(x)),q(null),L(null)},children:[t.jsxs(wt,{className:"h-auto flex-wrap",children:[t.jsx(Oe,{value:"installed",children:"Installed"}),t.jsx(Oe,{value:"browse",children:"Browse"}),t.jsx(Oe,{value:"install",children:"Install from file"}),t.jsx(Oe,{value:"publishers",children:"Publishers"})]}),t.jsx(Fe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(x=>t.jsx(Ht,{plugin:x,status:n,client:i,busy:F,run:E=>{J(E)},onPreview:_,onConnections:G,onUpdate:E=>{q(E),L(null),O("install")}},`${x.id}:${n.store.revision}`)):t.jsx(Ct,{children:t.jsxs(St,{children:[t.jsx(Nt,{variant:"icon",children:t.jsx(Dt,{})}),t.jsx(kt,{children:"No installed plugins"}),t.jsx($t,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Fe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(Ue,{value:j,onChange:k,projects:n.projects,disabled:F}),(n.store.availableSeeds??[]).map(x=>{const E=n.store.plugins.find(B=>B.id===x.manifest.id),W=E&&It(x.manifest.version,E.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:x.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.manifest.version," · ",x.manifest.publisher]})]}),W?t.jsx(P,{size:"sm",disabled:F||E.pinned,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,E.scope)))},children:E.pinned?"Pinned to installed version":"Review update"}):E?t.jsx(De,{variant:"outline",children:"Installed"}):t.jsx(P,{size:"sm",disabled:F||!g&&m,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,j)))},children:"Review installation"})]},x.manifest.id)}),!((V=n.store.availableSeeds)!=null&&V.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Fe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:x=>{x.preventDefault(),J(U)},children:t.jsxs(Ie,{children:[D&&t.jsxs("p",{className:"text-sm",children:["Update ",D.manifest.name," from ",D.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(Q,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(re,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:F,required:!0,onChange:x=>{var E;return L(((E=x.target.files)==null?void 0:E[0])??null)}})]}),!D&&t.jsx(Ue,{value:j,onChange:k,projects:n.projects,disabled:F}),t.jsxs(P,{type:"submit",disabled:F||!H||!D&&!g&&m,children:["Review ",D?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Fe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(x=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[x.label," ",t.jsx(De,{variant:"outline",children:x.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[x.id," · ",x.fingerprint]})]},x.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Pt,{client:i,busy:F,run:x=>{J(x)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",f.hostName]}),t.jsx(De,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Zt,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(x=>{var E;return((E=n==null?void 0:n.projects.find(W=>W.id===x))==null?void 0:E.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(x=>t.jsxs("li",{children:[x.side,": ",x.name," requires ",x.required,"; available ",x.actual??"none","."]},`${x.side}:${x.code}:${x.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(x=>x.name).join(", "),"."]})}),w&&te&&!r?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{client:i,preview:c,activation:e.activation,onComplete:()=>{S(!1),h(null),I(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${f.hostName}.`),O("installed"),q(null)},onError:x=>{p(x.message),z()}}),t.jsxs(P,{variant:"outline",onClick:z,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(P,{variant:"outline",disabled:R,onClick:z,children:"Cancel"}),t.jsxs(P,{disabled:F||!te||!c.compatibility.compatible||r,onClick:()=>{p(null),S(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",f.hostName]})]})]})]})]})})}export{us as PluginsDialog};
|
|
1
|
+
import{c as ue,r as y,j as t}from"./vendor-react-gGw_S5I_.js";import{ae as Z,bA as $e,ac as Q,b_ as Xe,av as Re,b$ as et,au as re,B as P,aC as Ie,c0 as tt,c1 as st,b2 as Be,b3 as Me,b1 as He,b4 as Ge,b5 as Ke,b6 as Je,G as se,I as ne,c2 as nt,k as De,c3 as We,c4 as it,c5 as Ye,a3 as lt,a4 as at,a8 as ot,a5 as rt,a6 as ct,a7 as dt,a9 as ut,aa as ht,H as Ee,c6 as pt,c7 as mt,o as ft,n as xt,l as gt,D as jt,j as bt,c8 as vt,c9 as yt,ca as wt,cb as Oe,cc as Fe,E as Ct,f as St,U as Nt,h as kt,i as $t}from"./index-Bg4A-xl7.js";import{V as Rt,cM as Dt}from"./vendor-ui-Dc_kJXxz.js";import"./vendor-markdown-BEJ8yVzA.js";function Ze(i){const e=i.trim().replace(/^v/i,"").match(/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/);return e?{parts:[Number(e[1]),Number(e[2]),Number(e[3])],prerelease:e[4]?e[4].split("."):[]}:null}function Et(i,e){if(i.length===0&&e.length===0)return 0;if(i.length===0)return 1;if(e.length===0)return-1;for(let s=0;s<Math.max(i.length,e.length);s+=1){const l=i[s],o=e[s];if(l===void 0)return-1;if(o===void 0)return 1;const a=/^\d+$/.test(l),n=/^\d+$/.test(o);if(a&&n){if(Number(l)!==Number(o))return Number(l)<Number(o)?-1:1;continue}if(a!==n)return a?-1:1;if(l!==o)return l<o?-1:1}return 0}function It(i,e){const s=Ze(i),l=Ze(e);if(!s||!l)return null;for(let o=0;o<3;o+=1)if(s.parts[o]!==l.parts[o])return s.parts[o]<l.parts[o]?-1:1;return Et(s.prerelease,l.prerelease)}function Ue(i){const e=ue.c(33),{value:s,onChange:l,projects:o,disabled:a}=i,n=a===void 0?!1:a,u=y.useId();let r;e[0]!==s.projectIds||e[1]!==s.type?(r=s.type==="projects"?s.projectIds:[],e[0]=s.projectIds,e[1]=s.type,e[2]=r):r=e[2];let v;e[3]!==r?(v=new Set(r),e[3]=r,e[4]=v):v=e[4];const m=v;let g;e[5]===Symbol.for("react.memo_cache_sentinel")?(g=t.jsx(Xe,{children:"Available in"}),e[5]=g):g=e[5];const k=`${u}-all`,j=s.type==="all";let c;e[6]!==l?(c=p=>l(p?{type:"all"}:{type:"projects",projectIds:[]}),e[6]=l,e[7]=c):c=e[7];let h;e[8]!==n||e[9]!==k||e[10]!==j||e[11]!==c?(h=t.jsx($e,{id:k,checked:j,disabled:n,onCheckedChange:c}),e[8]=n,e[9]=k,e[10]=j,e[11]=c,e[12]=h):h=e[12];const f=`${u}-all`;let b;e[13]!==f?(b=t.jsx(Q,{htmlFor:f,children:"All projects on this host, including new projects"}),e[13]=f,e[14]=b):b=e[14];let w;e[15]!==b||e[16]!==h?(w=t.jsxs(Z,{orientation:"horizontal",children:[h,b]}),e[15]=b,e[16]=h,e[17]=w):w=e[17];let S;e[18]!==n||e[19]!==u||e[20]!==l||e[21]!==o||e[22]!==m||e[23]!==s.projectIds||e[24]!==s.type?(S=s.type==="projects"&&t.jsx("div",{className:"flex max-h-40 flex-col gap-3 overflow-y-auto",children:o.map(p=>t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-${p.id}`,checked:m.has(p.id),disabled:n,onCheckedChange:N=>l({type:"projects",projectIds:N?[...s.projectIds,p.id]:s.projectIds.filter(I=>I!==p.id)})}),t.jsx(Q,{htmlFor:`${u}-${p.id}`,children:p.name})]},p.id))}),e[18]=n,e[19]=u,e[20]=l,e[21]=o,e[22]=m,e[23]=s.projectIds,e[24]=s.type,e[25]=S):S=e[25];const R=s.type==="projects"&&s.projectIds.length===0?"Installed but hidden until you choose a project.":"This setting is shared by every client connected to this host.";let d;e[26]!==R?(d=t.jsx(Re,{children:R}),e[26]=R,e[27]=d):d=e[27];let C;return e[28]!==n||e[29]!==w||e[30]!==S||e[31]!==d?(C=t.jsxs(et,{disabled:n,children:[g,w,S,d]}),e[28]=n,e[29]=w,e[30]=S,e[31]=d,e[32]=C):C=e[32],C}function Pt(i){const e=ue.c(69),{client:s,run:l,busy:o}=i,a=y.useId(),[n,u]=y.useState(""),[r,v]=y.useState(""),[m,g]=y.useState(null),[k,j]=y.useState(""),[c,h]=y.useState(!1);let f;e[0]!==s||e[1]!==k||e[2]!==r||e[3]!==n||e[4]!==m||e[5]!==l?(f=Y=>{Y.preventDefault(),l(async()=>{var de;if(!m||m.size>262144)throw new Error("Choose a root metadata file smaller than 256 KiB");if(!((de=globalThis.crypto)!=null&&de.subtle))throw new Error("Publisher enrollment requires HTTPS or localhost");const M=await m.arrayBuffer(),ce=Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",M)),Tt).join("");if(ce!==k.trim().toLowerCase())throw new Error("The root file does not match the fingerprint you entered");await s.enrollDeveloper({publisher:n,label:r,root:new TextDecoder("utf-8",{fatal:!0}).decode(M),fingerprint:ce}),h(!1),u(""),v(""),j("")})},e[0]=s,e[1]=k,e[2]=r,e[3]=n,e[4]=m,e[5]=l,e[6]=f):f=e[6];const b=`${a}-name`;let w;e[7]!==b?(w=t.jsx(Q,{htmlFor:b,children:"Development publisher"}),e[7]=b,e[8]=w):w=e[8];const S=`${a}-name`;let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=Y=>u(Y.target.value),e[9]=R):R=e[9];let d;e[10]!==o||e[11]!==n||e[12]!==S?(d=t.jsx(re,{id:S,value:n,onChange:R,placeholder:"dev-your-name",pattern:"dev-[a-z0-9-]+",maxLength:64,required:!0,disabled:o}),e[10]=o,e[11]=n,e[12]=S,e[13]=d):d=e[13];let C;e[14]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(Re,{children:"Development publishers have a separate namespace from official plugins."}),e[14]=C):C=e[14];let p;e[15]!==w||e[16]!==d?(p=t.jsxs(Z,{children:[w,d,C]}),e[15]=w,e[16]=d,e[17]=p):p=e[17];const N=`${a}-label`;let I;e[18]!==N?(I=t.jsx(Q,{htmlFor:N,children:"Display name"}),e[18]=N,e[19]=I):I=e[19];const $=`${a}-label`;let O;e[20]===Symbol.for("react.memo_cache_sentinel")?(O=Y=>v(Y.target.value),e[20]=O):O=e[20];let D;e[21]!==o||e[22]!==r||e[23]!==$?(D=t.jsx(re,{id:$,value:r,onChange:O,maxLength:100,required:!0,disabled:o}),e[21]=o,e[22]=r,e[23]=$,e[24]=D):D=e[24];let q;e[25]!==I||e[26]!==D?(q=t.jsxs(Z,{children:[I,D]}),e[25]=I,e[26]=D,e[27]=q):q=e[27];const H=`${a}-root`;let L;e[28]!==H?(L=t.jsx(Q,{htmlFor:H,children:"Publisher root file"}),e[28]=H,e[29]=L):L=e[29];const ee=`${a}-root`;let G;e[30]===Symbol.for("react.memo_cache_sentinel")?(G=Y=>{var M;g(((M=Y.target.files)==null?void 0:M[0])??null),h(!1)},e[30]=G):G=e[30];let T;e[31]!==o||e[32]!==ee?(T=t.jsx(re,{id:ee,type:"file",accept:".json,application/json",onChange:G,required:!0,disabled:o}),e[31]=o,e[32]=ee,e[33]=T):T=e[33];let K;e[34]!==L||e[35]!==T?(K=t.jsxs(Z,{children:[L,T]}),e[34]=L,e[35]=T,e[36]=K):K=e[36];const te=`${a}-fingerprint`;let _;e[37]!==te?(_=t.jsx(Q,{htmlFor:te,children:"Verified SHA-256 fingerprint"}),e[37]=te,e[38]=_):_=e[38];const J=`${a}-fingerprint`;let z;e[39]===Symbol.for("react.memo_cache_sentinel")?(z=Y=>{j(Y.target.value),h(!1)},e[39]=z):z=e[39];let U;e[40]!==o||e[41]!==k||e[42]!==J?(U=t.jsx(re,{id:J,value:k,onChange:z,placeholder:"64 hexadecimal characters",pattern:"[a-fA-F0-9]{64}",required:!0,disabled:o}),e[40]=o,e[41]=k,e[42]=J,e[43]=U):U=e[43];let F;e[44]===Symbol.for("react.memo_cache_sentinel")?(F=t.jsx(Re,{children:"Get this fingerprint from the publisher through a source you trust."}),e[44]=F):F=e[44];let V;e[45]!==_||e[46]!==U?(V=t.jsxs(Z,{children:[_,U,F]}),e[45]=_,e[46]=U,e[47]=V):V=e[47];const x=`${a}-trust`;let E;e[48]!==o||e[49]!==x||e[50]!==c?(E=t.jsx($e,{id:x,checked:c,onCheckedChange:h,disabled:o}),e[48]=o,e[49]=x,e[50]=c,e[51]=E):E=e[51];const W=`${a}-trust`;let B;e[52]!==W?(B=t.jsx(Q,{htmlFor:W,children:"I verified the publisher and trust packages signed by this root."}),e[52]=W,e[53]=B):B=e[53];let X;e[54]!==E||e[55]!==B?(X=t.jsxs(Z,{orientation:"horizontal",children:[E,B]}),e[54]=E,e[55]=B,e[56]=X):X=e[56];const ae=o||!c||!m;let ie;e[57]!==ae?(ie=t.jsx(P,{type:"submit",disabled:ae,children:"Trust development publisher"}),e[57]=ae,e[58]=ie):ie=e[58];let le;e[59]!==q||e[60]!==K||e[61]!==V||e[62]!==X||e[63]!==ie||e[64]!==p?(le=t.jsxs(Ie,{children:[p,q,K,V,X,ie]}),e[59]=q,e[60]=K,e[61]=V,e[62]=X,e[63]=ie,e[64]=p,e[65]=le):le=e[65];let oe;return e[66]!==f||e[67]!==le?(oe=t.jsx("form",{onSubmit:f,children:le}),e[66]=f,e[67]=le,e[68]=oe):oe=e[68],oe}function Tt(i){return i.toString(16).padStart(2,"0")}const At={project:null,theme:{mode:"light",tokens:{}},locale:"en",reducedMotion:!0,visible:!1};function Ot({client:i,preview:e,activation:s,key:l,onFrame:o,onComplete:a,onError:n}){const u=new AbortController;let r="loading",v,m=0;const g=()=>new Error("The installation check expired. Review the package again to retry.");function k(f){r==="canceled"||r==="finished"||(r="canceled",clearTimeout(v),u.abort(),o(null),n(f))}function j(){r==="canceled"||r==="finished"||(r="finished",clearTimeout(v),a())}async function c(f){if(r==="committing"){r="recovering",clearTimeout(v);try{const b=await i.transactionOutcome(e);if(r!=="recovering")return;b.status==="committed"?(await i.refresh(),r==="recovering"&&j()):k(f)}catch{r==="recovering"&&k(new Error("The host did not confirm the installation result. Check Installed after reconnecting before trying again."))}}}async function h(){if(r==="trial"){if(Date.now()>m){k(g());return}r="committing";try{await i.commit(e,u.signal),r==="committing"&&j()}catch(f){await c(f instanceof Error?f:new Error("Plugin installation failed"))}}}return s&&(async()=>{try{const f=await i.payload(e.transactionId,u.signal);if(u.signal.aborted||(e.manifest.entry||await st(f,e.digest),m=await i.beginTrial(e,u.signal),u.signal.aborted))return;const b=m-Date.now();if(b<=0){k(g());return}if(r="trial",v=setTimeout(()=>{r==="committing"?(u.abort(),c(g())):r==="trial"&&k(g())},b),!e.manifest.entry){await h();return}o({key:l,client:i,props:{payload:f,digest:e.digest,activationKey:l,context:At,active:!1,title:"Plugin installation check",execute:async(w,S)=>{if(u.signal.throwIfAborted(),S.throwIfAborted(),w.method!=="lifecycle.ready")throw new Error("This action is unavailable during installation");return null},onReady:()=>{h()},onError:k}})}catch(f){k(f instanceof Error?f:new Error("Plugin trial failed"))}})(),()=>{r="canceled",clearTimeout(v),u.abort()}}function Ft(i){const e=ue.c(22),{client:s,preview:l,activation:o,onComplete:a,onError:n}=i,u=`${o}:trial:${l.transactionId}:${l.digest}:${l.registryRevision}`,[r,v]=y.useState(null);let m;e[0]!==a||e[1]!==n?(m={onComplete:a,onError:n},e[0]=a,e[1]=n,e[2]=m):m=e[2];const g=y.useRef(m);let k;e[3]!==a||e[4]!==n?(k=()=>{g.current={onComplete:a,onError:n}},e[3]=a,e[4]=n,e[5]=k):k=e[5],y.useLayoutEffect(k);let j,c;e[6]!==o||e[7]!==s||e[8]!==u||e[9]!==l?(j=()=>Ot({client:s,preview:l,activation:o,key:u,onFrame:v,onComplete:()=>g.current.onComplete(),onError:w=>g.current.onError(w)}),c=[s,l,o,u],e[6]=o,e[7]=s,e[8]=u,e[9]=l,e[10]=j,e[11]=c):(j=e[10],c=e[11]),y.useLayoutEffect(j,c);let h;e[12]!==l.manifest.name?(h=t.jsxs("p",{children:["Checking that ",l.manifest.name," starts correctly…"]}),e[12]=l.manifest.name,e[13]=h):h=e[13];let f;e[14]!==o||e[15]!==s||e[16]!==r||e[17]!==u?(f=o&&(r==null?void 0:r.key)===u&&r.client===s&&t.jsx(tt,{...r.props}),e[14]=o,e[15]=s,e[16]=r,e[17]=u,e[18]=f):f=e[18];let b;return e[19]!==h||e[20]!==f?(b=t.jsxs("div",{role:"status",className:"flex flex-col gap-2",children:[h,f]}),e[19]=h,e[20]=f,e[21]=b):b=e[21],b}function _t({connection:i,resourceId:e,target:s,client:l,disabled:o,save:a}){const n=y.useId(),u=i.definition.resources[e],r=nt(i.definition,e),v=!!u.options&&r.length===0,m=i.selected[e],[g,k]=y.useState(""),[j,c]=y.useState(null),[h,f]=y.useState(!1),[b,w]=y.useState(null),S=y.useRef(null);y.useEffect(()=>()=>{var $;return($=S.current)==null?void 0:$.abort()},[]);const R=r.find($=>!i.selected[$]),d=o||!!R||u.scope==="project"&&!s.projectId,C=y.useCallback(async()=>{var O;(O=S.current)==null||O.abort();const $=new AbortController;S.current=$,f(!0),w(null);try{const D=await l.connectionOptions(s,i.id,e,$.signal);if($.signal.aborted)return;c(D)}catch(D){$.signal.aborted||w(D instanceof Error?D.message:"Unable to load choices")}finally{$.signal.aborted||f(!1)}},[l,s,i.id,e]),p=j===null&&!h&&!b;y.useEffect(()=>{v&&p&&!d&&C()},[v,p,d,C]);const N=m&&!(j!=null&&j.some($=>$.id===m.id))?[m,...j??[]]:j??[],I=t.jsxs(Je,{items:N.map($=>({value:$.id,label:$.label})),value:(m==null?void 0:m.id)??null,disabled:d||h||!j,onValueChange:$=>{$&&$!==(m==null?void 0:m.id)&&a(i.id,"select",{resourceId:e,value:$})},children:[t.jsx(Ke,{id:`${n}-resource`,"aria-invalid":!!b,children:t.jsx(Ge,{placeholder:h?"Loading choices…":`Choose ${u.label}`})}),t.jsx(Be,{children:t.jsx(Me,{children:N.map($=>t.jsx(He,{value:$.id,children:$.label},$.id))})})]});return t.jsxs(Z,{"data-disabled":d,"data-invalid":!!b,children:[t.jsx(Q,{htmlFor:`${n}-resource`,children:u.label}),t.jsx(Re,{children:u.scope==="project"?"Applies to the selected project.":"Applies to all projects using this connection."}),m&&!v&&t.jsxs("p",{className:"text-sm",children:["Selected: ",m.label]}),R&&t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Choose ",i.definition.resources[R].label," first."]}),u.scope==="project"&&!s.projectId&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a Cogpit project above."}),u.options&&t.jsxs("div",{className:"flex flex-wrap gap-2",children:[v?I:t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{C()},children:h?"Loading choices…":j?"Refresh choices":"Browse choices"}),!v&&j&&I,v&&b&&t.jsx(P,{type:"button",variant:"outline",size:"sm",disabled:d||h,onClick:()=>{C()},children:"Try again"}),(j==null?void 0:j.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"No choices were returned."})]}),u.input&&t.jsxs("form",{className:"flex flex-wrap gap-2",onSubmit:$=>{$.preventDefault(),a(i.id,"select",{resourceId:e,value:g.trim()})},children:[t.jsx(re,{id:u.options?`${n}-input`:`${n}-resource`,"aria-label":`${u.label} ${u.input.urls?"URL or ID":"ID"}`,value:g,onChange:$=>k($.target.value),maxLength:2048,disabled:d,autoComplete:"off",spellCheck:!1,placeholder:u.input.urls?"Paste a URL or ID":"Enter an ID"}),t.jsx(P,{type:"submit",size:"sm",variant:"outline",disabled:d||!g.trim(),children:"Validate and select"})]}),m&&t.jsxs(P,{type:"button",size:"sm",variant:"ghost",disabled:d,onClick:()=>{a(i.id,"select",{resourceId:e,value:null})},children:["Clear ",u.label]}),b&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:b})]})}function Lt(i){const e=ue.c(45),{connection:s,target:l,client:o,disabled:a,save:n}=i,u=y.useId(),[r,v]=y.useState(""),[m,g]=y.useState(!1),k=s.label;let j;e[0]!==s.label?(j=t.jsx("h3",{className:"font-medium",children:s.label}),e[0]=s.label,e[1]=j):j=e[1];const c=s.status==="disconnected"?"Needs connection":s.readOnly?"Configured by host":"Connected";let h;e[2]!==c?(h=t.jsx(De,{variant:"outline",children:c}),e[2]=c,e[3]=h):h=e[3];let f;e[4]!==j||e[5]!==h?(f=t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[j,h]}),e[4]=j,e[5]=h,e[6]=f):f=e[6];let b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=t.jsx("p",{className:"text-sm text-muted-foreground",children:"Cogpit keeps this credential on the selected host. Plugin code cannot read it."}),e[7]=b):b=e[7];let w;e[8]!==s.definition.operations?(w=new Set(Object.values(s.definition.operations).map(zt)),e[8]=s.definition.operations,e[9]=w):w=e[9];let S;e[10]!==w?(S=[...w],e[10]=w,e[11]=S):S=e[11];const R=S.join(", ");let d;e[12]!==R?(d=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["Credential destinations: ",R]}),e[12]=R,e[13]=d):d=e[13];let C;e[14]!==s.id||e[15]!==s.legacyImportAvailable||e[16]!==s.readOnly||e[17]!==s.status||e[18]!==a||e[19]!==u||e[20]!==m||e[21]!==n?(C=s.legacyImportAvailable&&t.jsxs("div",{className:"flex flex-col gap-3 rounded-md bg-muted p-3",children:[t.jsx("p",{className:"text-sm",children:"An existing host connection has saved settings available to import."}),s.status==="connected"&&!s.readOnly&&t.jsxs(Z,{orientation:"horizontal",children:[t.jsx($e,{id:`${u}-replace`,checked:m,onCheckedChange:g,disabled:a}),t.jsx(Q,{htmlFor:`${u}-replace`,children:"Allow replacing my current connection with these saved settings"})]}),t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"import-legacy",{replaceExisting:m})},children:"Import saved host settings"})]}),e[14]=s.id,e[15]=s.legacyImportAvailable,e[16]=s.readOnly,e[17]=s.status,e[18]=a,e[19]=u,e[20]=m,e[21]=n,e[22]=C):C=e[22];let p;e[23]!==s.definition.secret||e[24]!==s.id||e[25]!==s.readOnly||e[26]!==s.status||e[27]!==a||e[28]!==u||e[29]!==n||e[30]!==r?(p=s.readOnly?t.jsx("p",{className:"text-sm",children:"The host environment supplies this credential. Change it on the host."}):t.jsx("form",{onSubmit:$=>{$.preventDefault();const O=r.trim();v(""),n(s.id,"credential",{secret:O})},children:t.jsxs(Ie,{children:[t.jsxs(Z,{"data-disabled":a,children:[t.jsx(Q,{htmlFor:`${u}-secret`,children:s.definition.secret.label}),t.jsx(re,{id:`${u}-secret`,type:"password",autoComplete:"off",spellCheck:!1,maxLength:4096,disabled:a,value:r,onChange:$=>v($.target.value)})]}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(P,{type:"submit",size:"sm",disabled:a||!r.trim(),children:s.status==="disconnected"?"Validate and connect":"Replace credential"}),s.status!=="disconnected"&&t.jsx(P,{type:"button",size:"sm",variant:"outline",disabled:a,onClick:()=>{n(s.id,"disconnect",{})},children:"Disconnect"})]})]})}),e[23]=s.definition.secret,e[24]=s.id,e[25]=s.readOnly,e[26]=s.status,e[27]=a,e[28]=u,e[29]=n,e[30]=r,e[31]=p):p=e[31];let N;e[32]!==o||e[33]!==s||e[34]!==a||e[35]!==n||e[36]!==l?(N=s.status!=="disconnected"&&t.jsx(Ie,{children:Object.keys(s.definition.resources).map($=>t.jsx(_t,{connection:s,resourceId:$,target:l,client:o,disabled:a,save:n},$))}),e[32]=o,e[33]=s,e[34]=a,e[35]=n,e[36]=l,e[37]=N):N=e[37];let I;return e[38]!==s.label||e[39]!==d||e[40]!==C||e[41]!==p||e[42]!==N||e[43]!==f?(I=t.jsxs("section",{className:"flex flex-col gap-4 rounded-lg border p-4","aria-label":k,children:[f,b,d,C,p,N]}),e[38]=s.label,e[39]=d,e[40]=C,e[41]=p,e[42]=N,e[43]=f,e[44]=I):I=e[44],I}function zt(i){return i.origin}function Vt({client:i,target:e}){const[s,l]=y.useState(null),[o,a]=y.useState(null),[n,u]=y.useState(!1),r=y.useRef(null),v=y.useRef(!1),m=e.pluginId,g=e.projectId;y.useEffect(()=>{const j=new AbortController;return r.current=j,i.connections({pluginId:m,projectId:g},j.signal).then(c=>{j.signal.aborted||l(c)}).catch(c=>{j.signal.aborted||a(c instanceof Error?c.message:"Unable to load connections")}),()=>{j.abort(),r.current=null}},[i,m,g]);async function k(j,c,h){if(!s||v.current||!r.current||r.current.signal.aborted)return;v.current=!0;const f=r.current.signal;u(!0),a(null);try{const b=await i.changeConnection(e,j,c,h,s.revision,f);f.aborted||l(b)}catch(b){f.aborted||a(b instanceof Error?b.message:"Connection change failed")}finally{v.current=!1,f.aborted||u(!1)}}return t.jsxs("div",{className:"flex flex-col gap-4",children:[o&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:o})}),!s&&!o&&t.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"Loading connections…"}),s==null?void 0:s.connections.map(j=>t.jsx(Lt,{connection:j,target:e,client:i,disabled:n,save:k},`${j.id}:${s.revision}`)),(s==null?void 0:s.connections.length)===0&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This plugin does not use provider connections."})]})}function qt(i){const e=ue.c(32),{client:s,status:l,pluginId:o,initialProjectId:a}=i,[n,u]=y.useState(a),r=y.useId();let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={value:"",label:"Host connections only"},e[0]=v):v=e[0];let m;e[1]!==l.projects?(m=[v,...l.projects.map(Bt)],e[1]=l.projects,e[2]=m):m=e[2];const g=m;let k;e[3]!==r?(k=t.jsx(Q,{htmlFor:r,children:"Project settings"}),e[3]=r,e[4]=k):k=e[4];const j=n??"";let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c=I=>u(I||null),e[5]=c):c=e[5];let h;e[6]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(Ge,{}),e[6]=h):h=e[6];let f;e[7]!==r?(f=t.jsx(Ke,{id:r,children:h}),e[7]=r,e[8]=f):f=e[8];let b;e[9]!==g?(b=t.jsx(Be,{children:t.jsx(Me,{children:g.map(Ut)})}),e[9]=g,e[10]=b):b=e[10];let w;e[11]!==g||e[12]!==j||e[13]!==f||e[14]!==b?(w=t.jsxs(Je,{items:g,value:j,onValueChange:c,children:[f,b]}),e[11]=g,e[12]=j,e[13]=f,e[14]=b,e[15]=w):w=e[15];let S;e[16]!==l.host.name?(S=t.jsxs(Re,{children:["Connection credentials belong to ",l.host.name,". Project resources stay within the project you choose."]}),e[16]=l.host.name,e[17]=S):S=e[17];let R;e[18]!==S||e[19]!==k||e[20]!==w?(R=t.jsxs(Z,{children:[k,w,S]}),e[18]=S,e[19]=k,e[20]=w,e[21]=R):R=e[21];const d=`${o}:${n??"host"}:${l.connectionRevision??0}`;let C;e[22]!==o||e[23]!==n?(C={pluginId:o,projectId:n},e[22]=o,e[23]=n,e[24]=C):C=e[24];let p;e[25]!==s||e[26]!==d||e[27]!==C?(p=t.jsx(Vt,{client:s,target:C},d),e[25]=s,e[26]=d,e[27]=C,e[28]=p):p=e[28];let N;return e[29]!==R||e[30]!==p?(N=t.jsxs("div",{className:"flex flex-col gap-4",children:[R,p]}),e[29]=R,e[30]=p,e[31]=N):N=e[31],N}function Ut(i){return t.jsx(He,{value:i.value,children:i.label},i.value)}function Bt(i){return{value:i.id,label:i.name}}function Mt({client:i,pluginId:e,projectId:s,definition:l}){var R;const o=y.useId(),[a,n]=y.useState(null),[u,r]=y.useState({}),[v,m]=y.useState(null),[g,k]=y.useState(!1),[j,c]=y.useState(""),[h,f]=y.useState(0),b=y.useRef(null),w=l.scope==="project"&&!s;y.useEffect(()=>{var C;if((C=b.current)==null||C.abort(),b.current=null,k(!1),n(null),m(null),c(""),w)return;const d=new AbortController;return i.settings({pluginId:e,projectId:s},d.signal).then(p=>{d.signal.aborted||(n(p),r(We(l,p.values)))}).catch(p=>{d.signal.aborted||m(p instanceof Error?p.message:"Unable to load plugin settings")}),()=>{var p;d.abort(),(p=b.current)==null||p.abort()}},[i,e,s,l,w,h]);async function S(d){if(d.preventDefault(),!a||g)return;let C;try{C=We(l,u)}catch{m("Check the setting values and their limits.");return}k(!0),m(null),c("");const p=new AbortController;b.current=p;try{const N=await i.saveSettings({pluginId:e,projectId:s},C,a.revision,p.signal);p.signal.aborted||(n(N),r(N.values),c("Settings saved."))}catch(N){p.signal.aborted||m(N instanceof Error?N.message:"Unable to save plugin settings")}finally{b.current===p&&(b.current=null,p.signal.aborted||k(!1))}}return w?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose a project to edit this plugin's settings."}):t.jsx("form",{onSubmit:d=>{S(d)},children:t.jsxs(Ie,{children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:l.scope==="project"?"Settings for this project.":"Settings for your account on this host."}),a&&l.fields.map(d=>{const C=`${o}-${d.id}`,p=N=>{r(I=>({...I,[d.id]:N})),c("")};return t.jsxs(Z,{"data-disabled":g,children:[t.jsx(Q,{htmlFor:C,children:d.label}),d.description&&t.jsx(Re,{children:d.description}),d.type==="boolean"?t.jsx($e,{id:C,checked:u[d.id]===!0,disabled:g,onCheckedChange:N=>p(N===!0)}):d.type==="select"?t.jsxs(Je,{value:String(u[d.id]),items:d.options,disabled:g,onValueChange:N=>{N!==null&&p(String(N))},children:[t.jsx(Ke,{id:C,children:t.jsx(Ge,{})}),t.jsx(Be,{children:t.jsx(Me,{children:d.options.map(N=>t.jsx(He,{value:N.value,children:N.label},N.value))})})]}):t.jsx(re,{id:C,disabled:g,type:d.type==="number"?"number":"text",value:String(u[d.id]??""),...d.type==="number"?{min:d.min,max:d.max,step:d.step??"any"}:{maxLength:d.maxLength},onChange:N=>p(d.type==="number"?N.target.value===""?"":Number(N.target.value):N.target.value)})]},d.id)}),!!((R=a==null?void 0:a.adjustedFields)!=null&&R.length)&&t.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["Some saved values no longer match this version. Defaults are shown for ",a.adjustedFields.join(", "),"; save to apply them."]}),!a&&!v&&t.jsx("p",{role:"status",children:"Loading settings…"}),v&&t.jsx("p",{role:"alert",className:"text-sm text-destructive",children:v}),j&&t.jsx("p",{role:"status",className:"text-sm",children:j}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(P,{type:"submit",disabled:!a||g,children:g?"Saving…":"Save settings"}),t.jsx(P,{type:"button",variant:"outline",disabled:g,onClick:()=>f(d=>d+1),children:"Reload settings"})]})]})})}function Ht(i){var ie;const e=ue.c(175),{plugin:s,status:l,client:o,busy:a,run:n,onPreview:u,onConnections:r,onUpdate:v}=i,m=y.useId(),[g,k]=y.useState(s.scope),[j,c]=y.useState(!1),[h,f]=y.useState(!1);let b,w,S,R,d,C,p,N,I,$,O,D;if(e[0]!==a||e[1]!==o||e[2]!==r||e[3]!==u||e[4]!==v||e[5]!==s||e[6]!==n||e[7]!==g||e[8]!==l.host.name||e[9]!==l.projects||e[10]!==l.runtime||e[11]!==l.store){const le=it(),oe=Ye(s.manifest,le,l.runtime,{allowPrerelease:s.manifest.publisher.startsWith("dev-")});let Y;e[24]!==o||e[25]!==s.id||e[26]!==n||e[27]!==l.store?(Y=(A,Ae)=>n(()=>o.changeInstalled(s.id,A,Ae,l.store.revision)),e[24]=o,e[25]=s.id,e[26]=n,e[27]=l.store,e[28]=Y):Y=e[28];const M=Y,ce=s.lastError?"Needs recovery":oe.compatible?s.enabled?"Enabled":"Disabled":"Incompatible";let de;e[29]!==s.id||e[30]!==s.lastError||e[31]!==s.selectedDigest||e[32]!==l.store?(de=s.lastError&&((ie=l.store.availableSeeds)==null?void 0:ie.find(A=>A.manifest.id===s.id&&A.digest===s.selectedDigest)),e[29]=s.id,e[30]=s.lastError,e[31]=s.selectedDigest,e[32]=l.store,e[33]=de):de=e[33];const _e=de;$="flex flex-col gap-3 rounded-lg border p-4";let he;e[34]!==s.manifest.name?(he=t.jsx("h3",{className:"font-medium",children:s.manifest.name}),e[34]=s.manifest.name,e[35]=he):he=e[35];let pe;e[36]!==s.id||e[37]!==s.manifest.version?(pe=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[s.id," · ",s.manifest.version]}),e[36]=s.id,e[37]=s.manifest.version,e[38]=pe):pe=e[38];let me;e[39]!==he||e[40]!==pe?(me=t.jsxs("div",{className:"flex min-w-0 flex-col gap-1",children:[he,pe]}),e[39]=he,e[40]=pe,e[41]=me):me=e[41];const Le=ce==="Enabled"?"secondary":"outline";let fe;e[42]!==ce||e[43]!==Le?(fe=t.jsx(De,{variant:Le,children:ce}),e[42]=ce,e[43]=Le,e[44]=fe):fe=e[44],e[45]!==me||e[46]!==fe?(O=t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[me,fe]}),e[45]=me,e[46]=fe,e[47]=O):O=e[47],e[48]!==s.lastError?(D=s.lastError&&t.jsx(se,{variant:"destructive",children:t.jsx(ne,{children:s.lastError})}),e[48]=s.lastError,e[49]=D):D=e[49],w=!oe.compatible&&t.jsx(se,{variant:"destructive",children:t.jsxs(ne,{children:[oe.issues.map(A=>t.jsxs("p",{children:[A.side==="client"?"This client":A.side==="host"?l.host.name:"This package",": ",A.name," requires ",A.required,"; available ",A.actual??"none","."]},`${A.side}:${A.code}:${A.name}`)),t.jsx("p",{children:"Keep the saved data and update the affected app, or choose a compatible retained version below."})]})});let xe;e[50]!==M||e[51]!==s.enabled?(xe=()=>M("enabled",{enabled:!s.enabled}),e[50]=M,e[51]=s.enabled,e[52]=xe):xe=e[52];const ze=s.enabled?"Disable":"Enable";let ge;e[53]!==a||e[54]!==xe||e[55]!==ze?(ge=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:xe,children:ze}),e[53]=a,e[54]=xe,e[55]=ze,e[56]=ge):ge=e[56];let je;e[57]!==a||e[58]!==r||e[59]!==s.id||e[60]!==s.manifest.contributes||e[61]!==s.manifest.permissions.connections.length?(je=(s.manifest.permissions.connections.length>0||s.manifest.contributes.settings)&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>r(s.id),children:s.manifest.contributes.settings?"Settings":"Connections"}),e[57]=a,e[58]=r,e[59]=s.id,e[60]=s.manifest.contributes,e[61]=s.manifest.permissions.connections.length,e[62]=je):je=e[62];const Ve=a||s.pinned;let be;e[63]!==v||e[64]!==s?(be=()=>v(s),e[63]=v,e[64]=s,e[65]=be):be=e[65];let ve;e[66]!==Ve||e[67]!==be?(ve=t.jsx(P,{size:"sm",variant:"outline",disabled:Ve,onClick:be,children:"Update from file"}),e[66]=Ve,e[67]=be,e[68]=ve):ve=e[68];let ye;e[69]!==a||e[70]!==o||e[71]!==u||e[72]!==s.id||e[73]!==s.scope||e[74]!==_e||e[75]!==n?(ye=_e&&t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:()=>n(async()=>u(await o.stageSeed(s.id,s.scope))),children:"Review bundled repair"}),e[69]=a,e[70]=o,e[71]=u,e[72]=s.id,e[73]=s.scope,e[74]=_e,e[75]=n,e[76]=ye):ye=e[76];let we;e[77]!==M||e[78]!==s.pinned?(we=()=>M("pin",{pinned:!s.pinned}),e[77]=M,e[78]=s.pinned,e[79]=we):we=e[79];const qe=s.pinned?"Unpin version":"Pin version";let Ce;e[80]!==a||e[81]!==we||e[82]!==qe?(Ce=t.jsx(P,{size:"sm",variant:"outline",disabled:a,onClick:we,children:qe}),e[80]=a,e[81]=we,e[82]=qe,e[83]=Ce):Ce=e[83];let Pe;e[84]===Symbol.for("react.memo_cache_sentinel")?(Pe=()=>{f(!1),c(!0)},e[84]=Pe):Pe=e[84];let Se;e[85]!==a?(Se=t.jsx(P,{size:"sm",variant:"ghost",disabled:a,onClick:Pe,children:"Uninstall"}),e[85]=a,e[86]=Se):Se=e[86],e[87]!==ge||e[88]!==je||e[89]!==ve||e[90]!==ye||e[91]!==Ce||e[92]!==Se?(S=t.jsxs("div",{className:"flex flex-wrap gap-2",children:[ge,je,ve,ye,Ce,Se]}),e[87]=ge,e[88]=je,e[89]=ve,e[90]=ye,e[91]=Ce,e[92]=Se,e[93]=S):S=e[93],e[94]!==s.pinned?(R=s.pinned&&t.jsx("p",{className:"text-xs text-muted-foreground",children:"Unpin this version before updating or rolling back. Revoked packages remain blocked."}),e[94]=s.pinned,e[95]=R):R=e[95],N="text-sm",e[96]===Symbol.for("react.memo_cache_sentinel")?(I=t.jsx("summary",{className:"cursor-pointer",children:"Projects and previous versions"}),e[96]=I):I=e[96],b="flex flex-col gap-4 pt-4",e[97]!==a||e[98]!==g||e[99]!==l.projects?(d=t.jsx(Ue,{value:g,onChange:k,projects:l.projects,disabled:a}),e[97]=a,e[98]=g,e[99]=l.projects,e[100]=d):d=e[100];let Ne;e[101]!==a||e[102]!==s.scope||e[103]!==g?(Ne=a||JSON.stringify(g)===JSON.stringify(s.scope),e[101]=a,e[102]=s.scope,e[103]=g,e[104]=Ne):Ne=e[104];let ke;e[105]!==M||e[106]!==g?(ke=()=>M("scope",{scope:g}),e[105]=M,e[106]=g,e[107]=ke):ke=e[107],e[108]!==l.host.name||e[109]!==Ne||e[110]!==ke?(C=t.jsxs(P,{size:"sm",variant:"outline",disabled:Ne,onClick:ke,children:["Save projects on ",l.host.name]}),e[108]=l.host.name,e[109]=Ne,e[110]=ke,e[111]=C):C=e[111];let Te;e[112]!==s.selectedDigest?(Te=A=>A.digest!==s.selectedDigest,e[112]=s.selectedDigest,e[113]=Te):Te=e[113],p=s.versions.filter(Te).map(A=>{const Ae=!A.unavailableReason&&Ye(A.manifest,le,l.runtime,{allowPrerelease:A.manifest.publisher.startsWith("dev-")}).compatible;return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(P,{size:"sm",variant:"outline",disabled:a||s.pinned||!Ae,onClick:()=>n(async()=>u({...await o.rollback(s.id,A.digest,s.scope),operation:"rollback"})),children:["Review rollback to ",A.manifest.version]}),!Ae&&t.jsx("p",{className:"text-xs text-muted-foreground",children:A.unavailableReason??"This version is incompatible with the connected host or client."})]},A.digest)}),e[0]=a,e[1]=o,e[2]=r,e[3]=u,e[4]=v,e[5]=s,e[6]=n,e[7]=g,e[8]=l.host.name,e[9]=l.projects,e[10]=l.runtime,e[11]=l.store,e[12]=b,e[13]=w,e[14]=S,e[15]=R,e[16]=d,e[17]=C,e[18]=p,e[19]=N,e[20]=I,e[21]=$,e[22]=O,e[23]=D}else b=e[12],w=e[13],S=e[14],R=e[15],d=e[16],C=e[17],p=e[18],N=e[19],I=e[20],$=e[21],O=e[22],D=e[23];let q;e[114]===Symbol.for("react.memo_cache_sentinel")?(q=t.jsx("p",{className:"text-xs text-muted-foreground",children:"Rollback keeps current settings. Disabling keeps the installation and its saved data."}),e[114]=q):q=e[114];let H;e[115]!==b||e[116]!==d||e[117]!==C||e[118]!==p?(H=t.jsxs("div",{className:b,children:[d,C,p,q]}),e[115]=b,e[116]=d,e[117]=C,e[118]=p,e[119]=H):H=e[119];let L;e[120]!==H||e[121]!==N||e[122]!==I?(L=t.jsxs("details",{className:N,children:[I,H]}),e[120]=H,e[121]=N,e[122]=I,e[123]=L):L=e[123];let ee;e[124]!==s.manifest.name?(ee=t.jsxs(lt,{children:["Uninstall ",s.manifest.name,"?"]}),e[124]=s.manifest.name,e[125]=ee):ee=e[125];let G;e[126]!==l.host.name?(G=t.jsxs(at,{children:["This removes the plugin from ",l.host.name," for every connected client and project. Saved data is retained unless you choose deletion."]}),e[126]=l.host.name,e[127]=G):G=e[127];let T;e[128]!==ee||e[129]!==G?(T=t.jsxs(rt,{children:[ee,G]}),e[128]=ee,e[129]=G,e[130]=T):T=e[130];const K=`${m}-delete`,te=a||l.connectionRevision===void 0;let _;e[131]!==h||e[132]!==K||e[133]!==te?(_=t.jsx($e,{id:K,checked:h,onCheckedChange:f,disabled:te}),e[131]=h,e[132]=K,e[133]=te,e[134]=_):_=e[134];const J=`${m}-delete`;let z;e[135]!==J?(z=t.jsx(Q,{htmlFor:J,children:"Delete my saved settings and connections on this host"}),e[135]=J,e[136]=z):z=e[136];let U;e[137]!==_||e[138]!==z?(U=t.jsxs(Z,{orientation:"horizontal",children:[_,z]}),e[137]=_,e[138]=z,e[139]=U):U=e[139];let F;e[140]!==h?(F=h&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This cannot be undone. Other administrators' saved data is retained. Provider tokens and legacy backup files are not removed."}),e[140]=h,e[141]=F):F=e[141];let V;e[142]!==a?(V=t.jsx(ct,{disabled:a,children:"Cancel"}),e[142]=a,e[143]=V):V=e[143];let x;e[144]!==o||e[145]!==h||e[146]!==s.id||e[147]!==n||e[148]!==l.connectionRevision||e[149]!==l.store?(x=()=>{c(!1),n(()=>o.changeInstalled(s.id,"uninstall",h?{deleteData:!0,expectedConnectionRevision:l.connectionRevision}:{deleteData:!1},l.store.revision))},e[144]=o,e[145]=h,e[146]=s.id,e[147]=n,e[148]=l.connectionRevision,e[149]=l.store,e[150]=x):x=e[150];let E;e[151]!==a||e[152]!==l.host.name||e[153]!==x?(E=t.jsxs(ot,{variant:"destructive",disabled:a,onClick:x,children:["Uninstall from ",l.host.name]}),e[151]=a,e[152]=l.host.name,e[153]=x,e[154]=E):E=e[154];let W;e[155]!==V||e[156]!==E?(W=t.jsxs(dt,{children:[V,E]}),e[155]=V,e[156]=E,e[157]=W):W=e[157];let B;e[158]!==T||e[159]!==U||e[160]!==F||e[161]!==W?(B=t.jsxs(ut,{children:[T,U,F,W]}),e[158]=T,e[159]=U,e[160]=F,e[161]=W,e[162]=B):B=e[162];let X;e[163]!==j||e[164]!==B?(X=t.jsx(ht,{open:j,onOpenChange:c,children:B}),e[163]=j,e[164]=B,e[165]=X):X=e[165];let ae;return e[166]!==w||e[167]!==S||e[168]!==R||e[169]!==L||e[170]!==X||e[171]!==$||e[172]!==O||e[173]!==D?(ae=t.jsxs("article",{className:$,children:[O,D,w,S,R,L,X]}),e[166]=w,e[167]=S,e[168]=R,e[169]=L,e[170]=X,e[171]=$,e[172]=O,e[173]=D,e[174]=ae):ae=e[174],ae}const Gt={github:"GitHub",vercel:"Vercel",cloudflare:"Cloudflare"},Kt={actions:"workflow runs",actionJobs:"workflow jobs and steps",pulls:"pull requests",pullFiles:"pull request files",issues:"issues",pullReview:"pull request changes and patches",deployments:"deployments",buildLogs:"build logs",workspace:"Worker configuration and account",version:"version details"},Jt={append:"Append text to your draft message",context:"Add file references with notes to your draft message",drafts:"Read, save and restore your composer drafts, including images and sent-message history kept in this browser"},Wt={snapshot:"Read this project's worktree setup command and recent setup output",scripts:"Read the script names in this project's root package.json",propose:"Propose a setup command that runs in new worktrees; Cogpit shows the exact command and saves it only when you trust it",act:"Retry or cancel a worktree setup that is waiting before the first prompt"};function Yt(i,e){return i==="worktreeSetup"?Wt[e]:e==="pullSessions"?"Read related Cogpit sessions for the selected GitHub repository":e==="mergePull"?"Merge pull requests in the selected GitHub repository when you confirm, using this host's signed-in CLI":e==="submitReview"?"Post review comments to pull requests in the selected GitHub repository when you submit them, using this host's signed-in CLI":e==="reviewGuide"||e==="cancelReviewGuide"?"Read and cancel the review guides this host generates for pull requests":`Read ${Gt[i]} ${Kt[e]} using this host's signed-in CLI`}function Qe(i){const e=i.permissions;return[...new Set([...e.context.map(s=>s==="session.identity"?"Recognise the open session among related sessions, by handle only":"Read the selected project's name and plugin identifier"),...e.composer.map(s=>Jt[s]),...e.review.map(()=>"Ask to start a pull request session in a new worktree, which you confirm and choose the provider for"),...e.navigation.map(s=>s==="external"?"Ask Cogpit to open HTTPS links":"Open permitted sessions"),...e.storage?[`Store up to ${e.storage.quotaKiB} KiB of ${e.storage.scope} settings`]:[],...i.contributes.settings?[`Add ${i.contributes.settings.fields.length} ${i.contributes.settings.scope} settings fields`]:[],...(i.contributes.skills??[]).map(s=>`Provide agent instructions: ${s.title}`),...(i.contributes.chatBlocks??[]).map(s=>`Render ${s.title} cards and read the text inside their declared chat blocks`),...(i.contributes.sessionActions??[]).map(s=>`Add a ${s.title} button that sends an agent request when clicked`),...i.contributes.dictation?[`Add a ${i.contributes.dictation.title} button that records your microphone only while you dictate, and sends the recording to connection ${i.contributes.dictation.connection} to transcribe`]:[],...e.connections.flatMap(s=>s.operations.map(l=>`Use connection ${s.id}: ${l}`)),...e.integrations.flatMap(s=>s.operations.map(l=>Yt(s.id,l)))])]}function Zt(i){var j;const e=ue.c(32),{preview:s}=i;let l,o,a,n,u,r;if(e[0]!==s.connectionDefinitions||e[1]!==s.manifest||e[2]!==s.oldVersion||e[3]!==s.operation||e[4]!==s.previousConnectionDefinitions||e[5]!==s.previousManifest){const c=Qe(s.manifest),h=s.previousManifest?Qe(s.previousManifest):null,f=h?c.filter(S=>!h.includes(S)):[],b=h?h.filter(S=>!c.includes(S)):[],w=s.previousConnectionDefinitions?s.connectionDefinitions.filter(S=>{var d;const R=(d=s.previousConnectionDefinitions)==null?void 0:d.find(C=>C.id===S.id);return!R||JSON.stringify(R)!==JSON.stringify(S)}):[];l="flex flex-col gap-3 text-sm",e[12]!==s.oldVersion||e[13]!==s.operation?(o=s.oldVersion&&t.jsxs(se,{children:[t.jsx(Ee,{children:s.operation==="rollback"?"Rollback keeps current settings":"Update on this host"}),t.jsxs(ne,{children:["Saved settings and connections are retained. This version replaces ",s.oldVersion," in every enabled project and connected client. A failed trial leaves the current version selected."]})]}),e[12]=s.oldVersion,e[13]=s.operation,e[14]=o):o=e[14],a=h&&t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("h3",{className:"font-medium",children:"Access changes"}),f.length===0&&b.length===0&&w.length===0&&t.jsx("p",{children:"No changes to requested access or connection definitions."}),f.map(as),b.map(ls),w.map(is)]}),n=s.oldVersion&&!h&&t.jsx(se,{children:t.jsx(ne,{children:"This host does not report previous permissions. Review all requested access before continuing."})}),e[15]===Symbol.for("react.memo_cache_sentinel")?(u=t.jsx("h3",{className:"font-medium",children:"Requested access"}),e[15]=u):u=e[15],r=c.length?t.jsx("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:c.map(ns)}):t.jsx("p",{className:"text-muted-foreground",children:"No project, connection, storage, or composer access requested."}),e[0]=s.connectionDefinitions,e[1]=s.manifest,e[2]=s.oldVersion,e[3]=s.operation,e[4]=s.previousConnectionDefinitions,e[5]=s.previousManifest,e[6]=l,e[7]=o,e[8]=a,e[9]=n,e[10]=u,e[11]=r}else l=e[6],o=e[7],a=e[8],n=e[9],u=e[10],r=e[11];let v;e[16]!==s.connectionDefinitions?(v=s.connectionDefinitions.map(Qt),e[16]=s.connectionDefinitions,e[17]=v):v=e[17];let m;e[18]!==s.incompatibleClients?(m=!!((j=s.incompatibleClients)!=null&&j.length)&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Some connected clients cannot run this version"}),t.jsxs(ne,{children:[s.incompatibleClients.join(", "),". Their plugin panels will be unavailable until those clients are updated. Offline clients are checked when they reconnect."]})]}),e[18]=s.incompatibleClients,e[19]=m):m=e[19];let g;e[20]!==s.digest?(g=t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["SHA-256: ",s.digest]}),e[20]=s.digest,e[21]=g):g=e[21];let k;return e[22]!==l||e[23]!==o||e[24]!==a||e[25]!==n||e[26]!==u||e[27]!==r||e[28]!==v||e[29]!==m||e[30]!==g?(k=t.jsxs("div",{className:l,children:[o,a,n,u,r,v,m,g]}),e[22]=l,e[23]=o,e[24]=a,e[25]=n,e[26]=u,e[27]=r,e[28]=v,e[29]=m,e[30]=g,e[31]=k):k=e[31],k}function Qt(i){return t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("p",{className:"font-medium",children:i.label}),t.jsxs("p",{children:["Access to ",Object.values(i.resources).map(ss).join(", ")||"the connected account","."]}),t.jsxs("p",{className:"break-all text-muted-foreground",children:["Credential destinations: ",[...new Set(Object.values(i.operations).map(ts))].join(", ")]}),Object.entries(i.operations).filter(es).map(Xt)]},i.id)}function Xt(i){const[e,s]=i;return t.jsxs("p",{className:"text-muted-foreground",children:[s.method," ",e,s.method==="POST"?" — sends supplied data to this service":"",s.upload?" · sends a microphone recording":"",s.response?" · receives audio":""]},e)}function es(i){const[,e]=i;return e.audience==="panel"}function ts(i){return i.origin}function ss(i){return i.label}function ns(i){return t.jsx("li",{children:i},i)}function is(i){return t.jsxs("p",{children:["Changed connection: ",i.label,". Review its destinations and access below."]},i.id)}function ls(i){return t.jsxs("p",{children:["Removed: ",i]},`remove:${i}`)}function as(i){return t.jsxs("p",{children:["Added: ",i]},`add:${i}`)}function us({client:i,state:e,currentPath:s,onClose:l,initialPluginId:o}){var V;const a=y.useId(),n=e.status,u=pt(),r=(n==null?void 0:n.safeMode)||u,{project:v,resolving:m}=mt({client:i,status:n,activation:e.activation,projectPath:s}),[g,k]=y.useState(null),j=g??{type:"projects",projectIds:v?[v.id]:[]},[c,h]=y.useState(null),[f,b]=y.useState({activation:"",hostName:""}),[w,S]=y.useState(!1),[R,d]=y.useState(!1),[C,p]=y.useState(null),[N,I]=y.useState(null),[$,O]=y.useState("installed"),[D,q]=y.useState(null),[H,L]=y.useState(null),[ee,G]=y.useState(o),T=n==null?void 0:n.store.plugins.find(x=>x.id===ee),K=y.useRef(!1),te=!!(n!=null&&n.store.available)&&f.activation===e.activation;function _(x){b({activation:e.activation,hostName:(n==null?void 0:n.host.name)??"the selected host"}),h(x)}y.useEffect(()=>{!c||te&&!(r&&w)||(S(!1),h(null),p("The host connection or plugin execution state changed. Review the package again before installing."),i.cancel(c).catch(()=>{}))},[i,c,te,r,w]),y.useEffect(()=>()=>{c&&i.cancel(c).catch(()=>{})},[i,c]);async function J(x){if(!K.current){K.current=!0,d(!0),p(null),I(null);try{await x()}catch(E){p(E instanceof Error?E.message:"Plugin action failed")}finally{K.current=!1,d(!1)}}}function z(){const x=c;S(!1),h(null),x&&i.cancel(x).catch(()=>{})}async function U(){if(!H||!D&&!g&&m)return;const x=await i.stage(H,(D==null?void 0:D.scope)??j);if(D&&x.manifest.id!==D.id)throw await i.cancel(x),new Error(`Choose a package for ${D.manifest.name} (${D.id}).`);_(x)}const F=R||w||!(n!=null&&n.store.available);return t.jsx(ft,{open:!0,onOpenChange:x=>{!x&&!R&&!w&&(z(),l())},children:t.jsxs(xt,{className:"flex max-h-[85dvh] flex-col sm:max-w-2xl",showCloseButton:!R&&!w,children:[t.jsxs(gt,{children:[t.jsx(jt,{children:"Plugins"}),t.jsx(bt,{children:n?`Installed on ${n.host.name}. Changes apply to every client connected to this host.`:"Connecting to the selected host…"})]}),t.jsxs("div",{className:"flex min-h-0 flex-col gap-4 overflow-y-auto",children:[(e.error||C||(n==null?void 0:n.store.error))&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:n!=null&&n.store.available&&!C&&!e.error?"Plugin setup needs attention":"Plugin action unavailable"}),t.jsx(ne,{children:C??e.error??(n==null?void 0:n.store.error)})]}),N&&t.jsx(se,{children:t.jsx(ne,{children:N})}),r&&t.jsxs(se,{children:[t.jsx(Ee,{children:"Plugin safe mode"}),t.jsxs(ne,{children:["Plugin panels are stopped. You can disable or uninstall plugins here.",(n==null?void 0:n.safeMode)&&" The host owner must restart Cogpit without COGPIT_DISABLE_PLUGINS=1 to resume plugins on this host."]})]}),t.jsx(P,{size:"sm",variant:"outline",disabled:R||w||(n==null?void 0:n.safeMode),onClick:()=>vt(!u),children:u?"Resume plugins in this browser":"Pause plugins in this browser"}),(n==null?void 0:n.store.recoveryCode)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:n.store.recoveryCode==="STORE_LOCKED"?"Close the other Cogpit process using this data directory, then restart this host.":n.store.recoveryCode==="STORE_VERSION"?"Open this host with the Cogpit version that last used its plugin store, or a newer compatible version.":"Keep the plugin data directory intact. Restart with plugin safe mode enabled and check the host log before restoring a verified backup."}),!n&&t.jsxs(P,{variant:"outline",disabled:R,onClick:()=>{J(()=>i.refresh())},children:[t.jsx(Rt,{"data-icon":"inline-start"}),"Retry connection"]}),n&&T&&!c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[t.jsx("h2",{className:"font-medium",children:T.manifest.name}),t.jsx(P,{variant:"outline",size:"sm",onClick:()=>G(void 0),children:"Back to installed"})]}),T.manifest.permissions.connections.length>0&&T.manifest.contributes.settings&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect the service first. Its settings below take effect once it is connected."}),T.manifest.permissions.connections.length>0&&t.jsx(qt,{client:i,status:n,pluginId:T.id,initialProjectId:(v==null?void 0:v.id)??null},`${T.id}:${n.store.revision}`),T.manifest.contributes.settings&&t.jsx(Mt,{client:i,pluginId:T.id,projectId:(v==null?void 0:v.id)??null,definition:T.manifest.contributes.settings},`settings:${T.id}:${n.store.revision}`)]}),n&&!T&&!c&&t.jsxs(yt,{value:$,onValueChange:x=>{O(String(x)),q(null),L(null)},children:[t.jsxs(wt,{className:"h-auto flex-wrap",children:[t.jsx(Oe,{value:"installed",children:"Installed"}),t.jsx(Oe,{value:"browse",children:"Browse"}),t.jsx(Oe,{value:"install",children:"Install from file"}),t.jsx(Oe,{value:"publishers",children:"Publishers"})]}),t.jsx(Fe,{value:"installed",children:t.jsx("div",{className:"flex flex-col gap-3 pt-4",children:n.store.plugins.length?n.store.plugins.map(x=>t.jsx(Ht,{plugin:x,status:n,client:i,busy:F,run:E=>{J(E)},onPreview:_,onConnections:G,onUpdate:E=>{q(E),L(null),O("install")}},`${x.id}:${n.store.revision}`)):t.jsx(Ct,{children:t.jsxs(St,{children:[t.jsx(Nt,{variant:"icon",children:t.jsx(Dt,{})}),t.jsx(kt,{children:"No installed plugins"}),t.jsx($t,{children:"Browse available plugins or install a signed package to add panels to this host."})]})})})}),t.jsx(Fe,{value:"browse",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground",children:["These optional plugins are available with this Cogpit release. Choose which ones to install on ",n.host.name,"."]}),t.jsx(Ue,{value:j,onChange:k,projects:n.projects,disabled:F}),(n.store.availableSeeds??[]).map(x=>{const E=n.store.plugins.find(B=>B.id===x.manifest.id),W=E&&It(x.manifest.version,E.manifest.version)===1;return t.jsxs("article",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border p-4",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:x.manifest.name}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:[x.manifest.version," · ",x.manifest.publisher]})]}),W?t.jsx(P,{size:"sm",disabled:F||E.pinned,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,E.scope)))},children:E.pinned?"Pinned to installed version":"Review update"}):E?t.jsx(De,{variant:"outline",children:"Installed"}):t.jsx(P,{size:"sm",disabled:F||!g&&m,onClick:()=>{J(async()=>_(await i.stageSeed(x.manifest.id,j)))},children:"Review installation"})]},x.manifest.id)}),!((V=n.store.availableSeeds)!=null&&V.length)&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"This host has no bundled plugin packages. You can install a signed package from a file."})]})}),t.jsx(Fe,{value:"install",children:t.jsx("form",{className:"pt-4",onSubmit:x=>{x.preventDefault(),J(U)},children:t.jsxs(Ie,{children:[D&&t.jsxs("p",{className:"text-sm",children:["Update ",D.manifest.name," from ",D.manifest.version,". Existing project access is retained."]}),t.jsxs(Z,{children:[t.jsx(Q,{htmlFor:`${a}-package`,children:"Signed plugin package"}),t.jsx(re,{id:`${a}-package`,type:"file",accept:".cogpit-plugin",disabled:F,required:!0,onChange:x=>{var E;return L(((E=x.target.files)==null?void 0:E[0])??null)}})]}),!D&&t.jsx(Ue,{value:j,onChange:k,projects:n.projects,disabled:F}),t.jsxs(P,{type:"submit",disabled:F||!H||!D&&!g&&m,children:["Review ",D?"update":"installation"," on ",n.host.name]})]})})}),t.jsx(Fe,{value:"publishers",children:t.jsxs("div",{className:"flex flex-col gap-4 pt-4",children:[n.store.publishers.map(x=>t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs("p",{className:"text-sm font-medium",children:[x.label," ",t.jsx(De,{variant:"outline",children:x.kind})]}),t.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[x.id," · ",x.fingerprint]})]},x.id)),t.jsxs("details",{children:[t.jsx("summary",{className:"cursor-pointer text-sm",children:"Trust a development publisher"}),t.jsx("div",{className:"pt-4",children:t.jsx(Pt,{client:i,busy:F,run:x=>{J(x)}})})]})]})})]}),c&&t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsxs("h2",{className:"text-lg font-medium",children:[c.manifest.name," ",c.manifest.version]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:[c.oldVersion?`Replaces ${c.oldVersion}`:"New installation"," on ",f.hostName]}),t.jsx(De,{variant:"outline",children:c.publisherKind==="development"?"Development publisher":"Official publisher"})]}),t.jsx(Zt,{preview:c}),t.jsxs("p",{className:"text-sm",children:["Available in: ",c.scope.type==="all"?"all projects on this host, including new projects":c.scope.projectIds.length?c.scope.projectIds.map(x=>{var E;return((E=n==null?void 0:n.projects.find(W=>W.id===x))==null?void 0:E.name)??"unavailable project"}).join(", "):"no projects until you choose one","."]}),!c.compatibility.compatible&&t.jsxs(se,{variant:"destructive",children:[t.jsx(Ee,{children:"Incompatible version"}),t.jsx(ne,{children:t.jsx("ul",{className:"flex flex-col gap-1",children:c.compatibility.issues.map(x=>t.jsxs("li",{children:[x.side,": ",x.name," requires ",x.required,"; available ",x.actual??"none","."]},`${x.side}:${x.code}:${x.name}`))})})]}),c.compatibility.unavailableOptional.length>0&&t.jsx(se,{children:t.jsxs(ne,{children:["Some optional features are unavailable: ",c.compatibility.unavailableOptional.map(x=>x.name).join(", "),"."]})}),w&&te&&!r?t.jsxs(t.Fragment,{children:[t.jsx(Ft,{client:i,preview:c,activation:e.activation,onComplete:()=>{S(!1),h(null),I(`${c.manifest.name} ${c.manifest.version} is ${c.operation==="rollback"?"restored":c.oldVersion?"updated":"installed"} on ${f.hostName}.`),O("installed"),q(null)},onError:x=>{p(x.message),z()}}),t.jsxs(P,{variant:"outline",onClick:z,children:["Cancel ",c.operation==="rollback"?"rollback":c.oldVersion?"update":"installation"]})]}):t.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[t.jsx(P,{variant:"outline",disabled:R,onClick:z,children:"Cancel"}),t.jsxs(P,{disabled:F||!te||!c.compatibility.compatible||r,onClick:()=>{p(null),S(!0)},children:[c.operation==="rollback"?"Roll back":c.oldVersion?"Update":"Install"," on ",f.hostName]})]})]})]})]})})}export{us as PluginsDialog};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as s,j as t}from"./vendor-react-gGw_S5I_.js";import{aR as ne,B as g,S as K,aC as ie,ae as oe,az as le,aw as ce,ax as de,ay as G,at as ue,aB as he,aA as pe,c as me,E as fe,f as xe,U as we,h as ve,i as ge,aZ as be,F as je,X as b}from"./index-
|
|
1
|
+
import{r as s,j as t}from"./vendor-react-gGw_S5I_.js";import{aR as ne,B as g,S as K,aC as ie,ae as oe,az as le,aw as ce,ax as de,ay as G,at as ue,aB as he,aA as pe,c as me,E as fe,f as xe,U as we,h as ve,i as ge,aZ as be,F as je,X as b}from"./index-Bg4A-xl7.js";import{dh as H,X as Se,V as ye,bN as Ne,b5 as ke,dk as Ie,dj as Ee,di as Me,bq as Pe,du as ze,dv as Re}from"./vendor-ui-Dc_kJXxz.js";import"./vendor-markdown-BEJ8yVzA.js";const W=360,Ce=560,V="cogpit-preview-width",Y="cogpit-preview-viewport",_="cogpit-preview-zoom",I=.5,E=1.5,k=.1,h={responsive:{label:"Responsive",width:null,height:null,icon:Pe},phone:{label:"Phone",width:390,height:844,icon:Me},tablet:{label:"Tablet",width:768,height:1024,icon:Ee},desktop:{label:"Desktop",width:1280,height:800,icon:Ie}};function De(){try{const a=Number(localStorage.getItem(V));if(Number.isFinite(a)&&a>=W)return a}catch{}return Ce}function Te(){try{const a=localStorage.getItem(Y);if(a&&a in h)return a}catch{}return"responsive"}function We(){try{const a=localStorage.getItem(_);if(a===null)return 1;const i=Number(a);if(Number.isFinite(i))return Math.min(E,Math.max(I,i))}catch{}return 1}function X(a){return be(`cogpit-preview-url:${a}`)}function A(a){const i=a.trim();if(!i||/^[a-z][a-z\d+.-]*:/i.test(i)&&!/^https?:\/\//i.test(i)&&!/^[^/]+:\d+(?:\/|$)/.test(i))return null;const j=/^https?:\/\//i.test(i)?i:`http://${i}`;try{const n=new URL(j);return n.protocol!=="http:"&&n.protocol!=="https:"?null:n.href}catch{return null}}function B(a,i){return`http://${i||"localhost"}:${a}/`}function Fe({cwd:a,onClose:i}){const[M,j]=s.useState([]),[n,P]=s.useState(""),[$,S]=s.useState(""),[z,R]=s.useState(null),[q,J]=s.useState(0),[Q,C]=s.useState(!1),[y,ee]=s.useState(De),[l,te]=s.useState(Te),[o,p]=s.useState(We),c=s.useRef(null),O=s.useRef(null),D=s.useRef(null),{activeDevice:m}=ne(),N=(m==null?void 0:m.host)??(window.location.hostname||"localhost"),re=m==null?void 0:m.id;s.useEffect(()=>{let e="";try{e=localStorage.getItem(X(a))??""}catch{}const r=e?A(e)??"":"";P(r),S(r),R(null)},[a,re]),s.useEffect(()=>{let e=!1;async function r(){try{const u=await je(`/api/background-tasks?cwd=${encodeURIComponent(a)}`);if(e||!u.ok)return;const x=await u.json(),f=Array.isArray(x)?x:[];j(f);const L=f.flatMap(w=>w.ports.filter(v=>w.portStatus[v])).at(0);if(L){const w=B(L,N);P(v=>v||w),S(v=>v||w)}}catch{e||j([])}}r();const d=window.setInterval(r,1e4);return()=>{e=!0,window.clearInterval(d)}},[a,N]),s.useEffect(()=>{if(n)try{localStorage.setItem(X(a),n)}catch{}},[a,n]),s.useEffect(()=>{try{localStorage.setItem(Y,l),localStorage.setItem(_,String(o))}catch{}},[l,o]);const Z=s.useMemo(()=>[...new Set(M.flatMap(e=>e.ports.filter(r=>e.portStatus[r])))].sort((e,r)=>e-r),[M]),U=s.useCallback(e=>{const r=A(e);if(!r){R("Enter a valid HTTP or HTTPS URL.");return}R(null),P(r),S(r),C(!0)},[]),T=s.useCallback(()=>{n&&(C(!0),J(e=>e+1))},[n]);s.useEffect(()=>{function e(r){var d,u,x;if((d=O.current)!=null&&d.contains(document.activeElement)){if(b("previewRefresh",r)){r.preventDefault(),T();return}if(b("previewFocusUrl",r)){r.preventDefault(),(u=D.current)==null||u.focus(),(x=D.current)==null||x.select();return}if(b("previewZoomIn",r)){r.preventDefault(),p(f=>Math.min(E,Number((f+k).toFixed(1))));return}if(b("previewZoomOut",r)){r.preventDefault(),p(f=>Math.max(I,Number((f-k).toFixed(1))));return}b("previewResetZoom",r)&&(r.preventDefault(),p(1))}}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[T]);const ae=s.useCallback(e=>{e.preventDefault(),c.current={startX:e.clientX,startWidth:y,currentWidth:y},e.currentTarget.setPointerCapture(e.pointerId)},[y]),se=s.useCallback(e=>{if(!c.current)return;const r=Math.max(W,window.innerWidth*.7),d=c.current.startWidth+(c.current.startX-e.clientX),u=Math.min(r,Math.max(W,d));c.current.currentWidth=u,ee(u)},[]),F=s.useCallback(()=>{if(!c.current)return;const e=c.current.currentWidth;c.current=null;try{localStorage.setItem(V,String(e))}catch{}},[]);return t.jsxs("aside",{ref:O,"aria-label":"Development preview",className:"view-transition-right-panel panel-enter-right relative flex min-h-0 shrink-0 flex-col border-l bg-canvas",style:{width:y},children:[t.jsx("div",{"aria-hidden":"true",className:"absolute inset-y-0 left-0 w-1 cursor-col-resize hover:bg-primary/30",onPointerDown:ae,onPointerMove:se,onPointerUp:F,onPointerCancel:F}),t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(H,{"aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Preview"}),t.jsx("span",{className:"flex-1"}),t.jsx(g,{variant:"ghost",size:"icon-sm",onClick:i,"aria-label":"Close preview",children:t.jsx(Se,{"data-icon":"inline-start"})})]}),t.jsx(K,{}),t.jsx("form",{className:"p-2",onSubmit:e=>{e.preventDefault(),U($)},children:t.jsx(ie,{className:"gap-2",children:t.jsxs(oe,{"data-invalid":!!z,children:[t.jsxs(le,{children:[t.jsx(ce,{ref:D,"aria-label":"Preview URL","aria-invalid":!!z,value:$,onChange:e=>S(e.target.value),placeholder:"localhost:3000",spellCheck:!1}),t.jsxs(de,{align:"inline-end",children:[t.jsx(G,{size:"icon-xs",disabled:!n,onClick:T,"aria-label":"Refresh preview",children:t.jsx(ye,{"data-icon":"inline-start",className:Q?"animate-spin":void 0})}),t.jsx(G,{size:"icon-xs",disabled:!n,onClick:()=>window.open(n,"_blank","noopener,noreferrer"),"aria-label":"Open preview in browser",children:t.jsx(Ne,{"data-icon":"inline-start"})})]})]}),t.jsx(ue,{children:z})]})})}),Z.length>0&&t.jsxs("div",{className:"flex shrink-0 items-center gap-1 overflow-x-auto px-2 pb-2",children:[t.jsx(ke,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),Z.map(e=>t.jsxs(g,{variant:"outline",size:"xs",className:"font-mono text-xs",onClick:()=>U(B(e,N)),"aria-label":`Open ${N}:${e} preview`,children:[":",e]},e))]}),t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 px-2 pb-2",children:[t.jsx(he,{"aria-label":"Preview viewport",value:[l],onValueChange:e=>{const r=e[0];r&&r in h&&te(r)},variant:"outline",size:"sm",spacing:0,children:Object.entries(h).map(([e,r])=>{const d=r.icon;return t.jsx(pe,{value:e,"aria-label":`${r.label} viewport`,title:r.width?`${r.label} · ${r.width}×${r.height}`:r.label,children:t.jsx(d,{})},e)})}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o<=I,onClick:()=>p(e=>Math.max(I,Number((e-k).toFixed(1)))),"aria-label":"Zoom preview out",title:"Zoom out",children:t.jsx(ze,{"data-icon":"inline-start"})}),t.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>p(1),"aria-label":"Reset preview zoom",children:[Math.round(o*100),"%"]}),t.jsx(g,{variant:"ghost",size:"icon-sm",disabled:o>=E,onClick:()=>p(e=>Math.min(E,Number((e+k).toFixed(1)))),"aria-label":"Zoom preview in",title:"Zoom in",children:t.jsx(Re,{"data-icon":"inline-start"})})]})]}),t.jsx(K,{}),t.jsx("div",{className:"min-h-0 flex-1 overflow-auto bg-muted/30 p-3",children:n?t.jsx("div",{className:me("relative mx-auto overflow-hidden bg-white ring-1 ring-border",l==="responsive"&&"size-full"),style:l==="responsive"?void 0:{width:h[l].width*o,height:h[l].height*o},children:t.jsx("iframe",{title:"Development preview",src:n,className:"block border-0 bg-white",style:l==="responsive"?{width:`${100/o}%`,height:`${100/o}%`,transform:`scale(${o})`,transformOrigin:"top left"}:{width:h[l].width,height:h[l].height,transform:`scale(${o})`,transformOrigin:"top left"},sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-same-origin allow-scripts",referrerPolicy:"no-referrer",onLoad:()=>C(!1)},`${n}-${q}`)}):t.jsx(fe,{className:"size-full",children:t.jsxs(xe,{children:[t.jsx(we,{variant:"icon",children:t.jsx(H,{})}),t.jsx(ve,{children:"No preview selected"}),t.jsx(ge,{children:"Start a local development server or enter its URL above. Detected ports appear automatically."})]})})})]})}export{Fe as PreviewPanel,A as normalizePreviewUrl};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as l,j as t,c as Ae}from"./vendor-react-gGw_S5I_.js";import{E as X,f as Y,U as
|
|
2
|
-
`,r);if(c<0)return r;r=c+1}return r}function Es({cwd:n,onClose:e,onAddToPrompt:r,openRequest:o}){const c=l.useRef(null),u=l.useRef(null),f=l.useRef(null),[g,S]=l.useState(""),[b,R]=l.useState([]),[m,h]=l.useState(!0),[N,j]=l.useState(null),[k,x]=l.useState(0),[w,y]=l.useState(!1),[D,L]=l.useState(0),F=l.useRef(!1),[i,T]=l.useState(null),[U,Ce]=l.useState(!0),[M,J]=l.useState(""),[ft,re]=l.useState(""),[P,oe]=l.useState(null),[ut,Ue]=l.useState(0),[K,Pe]=l.useState(!1),[Z,Oe]=l.useState(!1),[Be,_]=l.useState(null),[mt,ee]=l.useState(!1),[$,ke]=l.useState("all"),[v,Ge]=l.useState(null),[Ke,He]=l.useState(!1),[xt,Ve]=l.useState(null),[C,ce]=l.useState("edit"),[E,we]=l.useState(null),[de,Xe]=l.useState(!1),[Ye,Ee]=l.useState(null),[fe,H]=l.useState(null),[O,ve]=l.useState(null),[ye,Re]=l.useState(""),[G,ue]=l.useState(null),z=i!==null&&M!==ft,I=l.useMemo(()=>new Map(((v==null?void 0:v.files)??[]).flatMap(s=>[[s.path,s],...s.originalPath?[[s.originalPath,s]]:[]])),[v==null?void 0:v.files]),te=l.useCallback(async()=>{He(!0),Ve(null);try{const s=await ae(`/api/git-status?cwd=${encodeURIComponent(n)}`);if(!s.ok)throw new Error(await pe(s,"Unable to read git status"));const a=await s.json();Ge(a),a.isRepository||ke("all")}catch(s){Ge(null),ke("all"),Ve(s instanceof Error?s.message:"Unable to read git status")}finally{He(!1)}},[n]);l.useEffect(()=>{te()},[te]);const De=$==="all"&&g.trim()==="";l.useEffect(()=>{if(De)return;const s=new AbortController,a=window.setTimeout(async()=>{h(!0),j(null);const d=F.current;F.current=!1;try{const p=await ae(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(g)}&limit=100${d?"&refresh=1":""}`,{signal:s.signal});if(!p.ok)throw new Error(await pe(p,"Unable to list project files"));const B=await p.json();if(s.signal.aborted)return;const tt=Ct(B),st=B.totalMatches;R(tt),x(typeof st=="number"?st:tt.length),y(B.scanLimited===!0)}catch(p){s.signal.aborted||(R([]),j(p instanceof Error?p.message:"Unable to list project files"))}finally{s.signal.aborted||h(!1)}},120);return()=>{window.clearTimeout(a),s.abort()}},[n,g,D,De]),l.useEffect(()=>{T(null),J(""),re(""),oe(null),_(null),H(null),ce("edit"),we(null),Ee(null),ue(null)},[n]),l.useEffect(()=>{if(!z)return;const s=a=>a.preventDefault();return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[z]);const ht=l.useCallback((s,a)=>{const d=u.current;if(!d)return;if(!a||a<1){d.focus();return}const p=ys(s,a);d.blur(),d.setSelectionRange(p,p),d.focus()},[]);l.useEffect(()=>{const s=f.current;!s||!u.current||(f.current=null,ht(s.text,s.line))});const se=l.useCallback(async(s,a)=>{Pe(!0),_(null),ee(!1),H(null);try{const d=await ae(`/api/project-file?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}`);if(!d.ok)throw new Error(await pe(d,"Unable to open file"));const p=await d.json();J(p.content),re(p.content),oe(p.mtimeMs),Ue(p.size),f.current={text:p.content,line:a}}catch(d){J(""),re(""),oe(null),_(d instanceof Error?d.message:"Unable to open file")}finally{Pe(!1)}},[n]),ne=l.useCallback(async(s,a)=>{Xe(!0),Ee(null),we(null);try{const d=a?`&originalPath=${encodeURIComponent(a)}`:"",p=await ae(`/api/git-diff?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}${d}`);if(!p.ok)throw new Error(await pe(p,"Unable to diff file"));we(await p.json())}catch(d){Ee(d instanceof Error?d.message:"Unable to diff file")}finally{Xe(!1)}},[n]),be=l.useCallback(({path:s,mode:a,line:d})=>{var p;if(T(s),Ce(!1),a==="edit"){ce(rt(s)&&!d?"preview":"edit"),se(s,d);return}ce(a),J(""),re(""),oe(null),_(null),ee(!1),H(null),ne(s,(p=I.get(s))==null?void 0:p.originalPath)},[I,ne,se]),Ne=l.useCallback(s=>{if(z){ue({type:"file",target:s});return}be(s)},[z,be]),
|
|
1
|
+
import{r as l,j as t,c as Ae}from"./vendor-react-gGw_S5I_.js";import{E as X,f as Y,U as Q,h as W,i as q,F as ae,c as ie,c$ as ot,x as je,B as A,d0 as Ct,t as kt,d1 as Et,d2 as Rt,S as xe,k as le,az as Dt,ax as Ft,aw as Lt,aB as nt,aA as he,m as Tt,d3 as Mt,d4 as $t,s as zt,o as It,n as At,l as Ut,D as Pt,j as Ot,ad as Bt,aE as Gt,aa as Kt,a9 as Ht,a5 as Vt,a3 as Xt,a4 as Yt,a7 as Qt,a6 as Wt,a8 as qt,X as Jt}from"./index-Bg4A-xl7.js";import{H as Zt}from"./HighlightedEditor-D1S-wotA.js";import{T as ge,cF as Ie,bl as _t,c8 as es,A as ts,X as ss,a7 as ns,ak as ls,V as lt,cN as as,dx as at,ds as is,c1 as $e}from"./vendor-ui-Dc_kJXxz.js";import{M as rs}from"./vendor-markdown-BEJ8yVzA.js";const os=12,ct="h-6 w-full justify-start gap-1 rounded-none px-2 text-left font-normal";function Se(n,e){return{paddingLeft:8+n*os+(e?0:16)}}function cs(n){const e=n;return typeof e=="object"&&e!==null&&typeof e.name=="string"&&(e.type==="file"||e.type==="directory")}function ds(n){const e=n==null?void 0:n.entries;return Array.isArray(e)?e.filter(cs):[]}async function it(n,e,r){try{const o=await ae(`/api/project-files/tree?cwd=${encodeURIComponent(n)}&dir=${encodeURIComponent(e)}${r?"&refresh=1":""}`);if(!o.ok){const u=await o.json().catch(()=>null),f=u==null?void 0:u.error;throw new Error(typeof f=="string"?f:"Unable to list directory")}const c=await o.json();return{status:"ready",entries:ds(c),scanLimited:c.scanLimited===!0}}catch(o){return{status:"error",message:o instanceof Error?o.message:"Unable to list directory"}}}function fs(n){const e=n.split("/");return e.slice(0,-1).map((r,o)=>e.slice(0,o+1).join("/"))}function us({cwd:n,selectedPath:e,onSelect:r,fileStatus:o,reloadToken:c}){const[u,f]=l.useState(()=>new Map),[g,S]=l.useState(()=>new Set),b=l.useRef(new Set),R=l.useRef(n);R.current=n;const m=l.useCallback(async x=>{if(b.current.has(x))return;b.current.add(x),f(y=>new Map(y).set(x,{status:"loading"}));const w=await it(n,x,!1);b.current.delete(x),R.current===n&&f(y=>new Map(y).set(x,w))},[n]),h=l.useRef(null);l.useEffect(()=>{const x=h.current===n;h.current=n,x||S(new Set),f(new Map([["",{status:"loading"}]]));let w=!1;return it(n,"",x).then(y=>{w||f(new Map([["",y]]))}),()=>{w=!0}},[n,c]),l.useEffect(()=>{if(!e)return;const x=fs(e);x.length!==0&&S(w=>{if(x.every(D=>w.has(D)))return w;const y=new Set(w);for(const D of x)y.add(D);return y})},[e]);const N=l.useCallback(x=>{S(w=>{const y=new Set(w);return y.has(x)?y.delete(x):y.add(x),y})},[]),j=u.get(""),k=ms(j);return t.jsxs("div",{"aria-label":"Project file tree",className:"flex flex-col py-1",children:[k?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(k.Icon,{})}),t.jsx(W,{children:k.title}),t.jsx(q,{children:k.description})]})}):t.jsx(dt,{directory:"",depth:0,state:j,directories:u,expanded:g,selectedPath:e,onSelect:r,onToggle:N,onLoad:m,fileStatus:o}),(j==null?void 0:j.status)==="ready"&&j.scanLimited&&t.jsx("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:"This project is too large to scan completely."})]})}function ms(n){return(n==null?void 0:n.status)==="error"?{Icon:ge,title:"Could not load files",description:n.message}:(n==null?void 0:n.status)==="ready"&&n.entries.length===0?{Icon:Ie,title:"No files",description:"This project has no files to show."}:null}function dt(n){const e=Ae.c(22),{directory:r,depth:o,state:c,onLoad:u,...f}=n;let g,S;if(e[0]!==r||e[1]!==u||e[2]!==c?(g=()=>{c===void 0&&r!==""&&u(r)},S=[r,u,c],e[0]=r,e[1]=u,e[2]=c,e[3]=g,e[4]=S):(g=e[3],S=e[4]),l.useEffect(g,S),!c||c.status==="loading"){let m;e[5]!==o?(m=Se(o,!1),e[5]=o,e[6]=m):m=e[6];let h;e[7]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(je,{className:"size-3"}),e[7]=h):h=e[7];const N=r===""&&"Loading files…";let j;return e[8]!==m||e[9]!==N?(j=t.jsxs("div",{role:"status",className:"flex h-6 items-center gap-2 text-xs text-muted-foreground",style:m,children:[h,N]}),e[8]=m,e[9]=N,e[10]=j):j=e[10],j}if(c.status==="error"){let m;e[11]!==o?(m=Se(o,!1),e[11]=o,e[12]=m):m=e[12];let h;e[13]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(ge,{"aria-hidden":"true",className:"size-3 shrink-0"}),e[13]=h):h=e[13];let N;e[14]!==c.message?(N=t.jsx("span",{className:"truncate",children:c.message}),e[14]=c.message,e[15]=N):N=e[15];let j;return e[16]!==c.message||e[17]!==m||e[18]!==N?(j=t.jsxs("div",{role:"alert",className:"flex h-6 items-center gap-1.5 truncate text-xs text-destructive",style:m,title:c.message,children:[h,N]}),e[16]=c.message,e[17]=m,e[18]=N,e[19]=j):j=e[19],j}const b=c.entries.map(m=>{const h=r?`${r}/${m.name}`:m.name;return m.type==="directory"?t.jsx(xs,{path:h,name:m.name,depth:o,onLoad:u,...f},h):t.jsx(hs,{path:h,name:m.name,depth:o,selected:f.selectedPath===h,status:f.fileStatus(h),onSelect:f.onSelect},h)});let R;return e[20]!==b?(R=t.jsx(t.Fragment,{children:b}),e[20]=b,e[21]=R):R=e[21],R}function xs(n){const e=Ae.c(48);let r,o,c,u,f,g,S,b,R,m,h,N,j,k,x,w,y;e[0]!==n?({path:S,name:f,depth:u,...b}=n,g=b.expanded.has(S),r=g?_t:es,c=A,h="ghost",N="sm",j=g,k=ct,e[18]!==u?(x=Se(u,!0),e[18]=u,e[19]=x):x=e[19],w=()=>b.onToggle(S),y=S,o=ts,R="true",m=ie("size-3 shrink-0 text-muted-foreground transition-transform",g&&"rotate-90"),e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=u,e[5]=f,e[6]=g,e[7]=S,e[8]=b,e[9]=R,e[10]=m,e[11]=h,e[12]=N,e[13]=j,e[14]=k,e[15]=x,e[16]=w,e[17]=y):(r=e[1],o=e[2],c=e[3],u=e[4],f=e[5],g=e[6],S=e[7],b=e[8],R=e[9],m=e[10],h=e[11],N=e[12],j=e[13],k=e[14],x=e[15],w=e[16],y=e[17]);let D;e[20]!==o||e[21]!==R||e[22]!==m?(D=t.jsx(o,{"aria-hidden":R,className:m}),e[20]=o,e[21]=R,e[22]=m,e[23]=D):D=e[23];let L;e[24]!==r?(L=t.jsx(r,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[24]=r,e[25]=L):L=e[25];let F;e[26]!==f?(F=t.jsx("span",{className:"min-w-0 flex-1 truncate text-xs",children:f}),e[26]=f,e[27]=F):F=e[27];let i;e[28]!==c||e[29]!==D||e[30]!==L||e[31]!==F||e[32]!==h||e[33]!==N||e[34]!==j||e[35]!==k||e[36]!==x||e[37]!==w||e[38]!==y?(i=t.jsxs(c,{variant:h,size:N,"aria-expanded":j,className:k,style:x,onClick:w,title:y,children:[D,L,F]}),e[28]=c,e[29]=D,e[30]=L,e[31]=F,e[32]=h,e[33]=N,e[34]=j,e[35]=k,e[36]=x,e[37]=w,e[38]=y,e[39]=i):i=e[39];let T;e[40]!==u||e[41]!==g||e[42]!==S||e[43]!==b?(T=g&&t.jsx("div",{children:t.jsx(dt,{directory:S,depth:u+1,state:b.directories.get(S),...b})}),e[40]=u,e[41]=g,e[42]=S,e[43]=b,e[44]=T):T=e[44];let U;return e[45]!==i||e[46]!==T?(U=t.jsxs("div",{children:[i,T]}),e[45]=i,e[46]=T,e[47]=U):U=e[47],U}function hs(n){const e=Ae.c(28),{path:r,name:o,depth:c,selected:u,status:f,onSelect:g}=n,S=l.useRef(null);let b;e[0]!==r?(b=ot(r),e[0]=r,e[1]=b):b=e[1];const R=b;let m,h;e[2]!==u?(m=()=>{var T,U;u&&((U=(T=S.current)==null?void 0:T.scrollIntoView)==null||U.call(T,{block:"nearest"}))},h=[u],e[2]=u,e[3]=m,e[4]=h):(m=e[3],h=e[4]),l.useEffect(m,h);const N=u||void 0,j=u?"secondary":"ghost";let k;e[5]!==c?(k=Se(c,!1),e[5]=c,e[6]=k):k=e[6];let x;e[7]!==g||e[8]!==r?(x=()=>g(r),e[7]=g,e[8]=r,e[9]=x):x=e[9];let w;e[10]!==R?(w=t.jsx(R,{"aria-hidden":"true",className:"size-3.5 shrink-0 text-muted-foreground"}),e[10]=R,e[11]=w):w=e[11];const y=f&&f.className;let D;e[12]!==y?(D=ie("min-w-0 flex-1 truncate text-xs",y),e[12]=y,e[13]=D):D=e[13];let L;e[14]!==o||e[15]!==D?(L=t.jsx("span",{className:D,children:o}),e[14]=o,e[15]=D,e[16]=L):L=e[16];let F;e[17]!==f?(F=f&&t.jsx("span",{className:ie("shrink-0 font-mono text-[10px]",f.className),title:f.label,children:f.code}),e[17]=f,e[18]=F):F=e[18];let i;return e[19]!==r||e[20]!==L||e[21]!==F||e[22]!==N||e[23]!==j||e[24]!==k||e[25]!==x||e[26]!==w?(i=t.jsxs(A,{ref:S,"aria-current":N,variant:j,size:"sm",className:ct,style:k,onClick:x,title:r,children:[w,L,F]}),e[19]=r,e[20]=L,e[21]=F,e[22]=N,e[23]=j,e[24]=k,e[25]=x,e[26]=w,e[27]=i):i=e[27],i}const ps={"?":{label:"Untracked",className:"text-info"},A:{label:"Added",className:"text-success"},M:{label:"Modified",className:"text-warning"},D:{label:"Deleted",className:"text-destructive"},R:{label:"Renamed",className:"text-info"},C:{label:"Copied",className:"text-info"},U:{label:"Conflicted",className:"text-destructive"}};function ze(n){const e=n.workTreeStatus.trim()||n.indexStatus.trim();return ps[e]??{label:"Changed",className:"text-muted-foreground"}}function js(n){return`${n.indexStatus}${n.workTreeStatus}`.trim()||"?"}const gs=new Set([".md",".mdx",".markdown"]);function rt(n){const e=n.lastIndexOf(".");return e!==-1&&gs.has(n.slice(e).toLowerCase())}function ws(n,e,r){if(!n||/^(?:[a-z]+:|\/|#)/i.test(n))return n;const o=r.includes("/")?r.slice(0,r.lastIndexOf("/")):"",c=[];for(const f of[...o.split("/"),...n.split("/")])f===".."?c.pop():f&&f!=="."&&c.push(f);const u=e.includes("\\")?"\\":"/";return[e.replace(/[\\/]+$/,""),...c].join(u)}async function pe(n,e){try{const r=await n.json();if(r&&typeof r=="object"&&typeof r.error=="string")return r.error}catch{}return e}function vs(n){return n<1024?`${n} B`:`${(n/1024).toFixed(n<10*1024?1:0)} KB`}function ys(n,e){let r=0;for(let o=1;o<e;o+=1){const c=n.indexOf(`
|
|
2
|
+
`,r);if(c<0)return r;r=c+1}return r}function Es({cwd:n,onClose:e,onAddToPrompt:r,openRequest:o}){const c=l.useRef(null),u=l.useRef(null),f=l.useRef(null),[g,S]=l.useState(""),[b,R]=l.useState([]),[m,h]=l.useState(!0),[N,j]=l.useState(null),[k,x]=l.useState(0),[w,y]=l.useState(!1),[D,L]=l.useState(0),F=l.useRef(!1),[i,T]=l.useState(null),[U,Ce]=l.useState(!0),[M,J]=l.useState(""),[ft,re]=l.useState(""),[P,oe]=l.useState(null),[ut,Ue]=l.useState(0),[K,Pe]=l.useState(!1),[Z,Oe]=l.useState(!1),[Be,_]=l.useState(null),[mt,ee]=l.useState(!1),[$,ke]=l.useState("all"),[v,Ge]=l.useState(null),[Ke,He]=l.useState(!1),[xt,Ve]=l.useState(null),[C,ce]=l.useState("edit"),[E,we]=l.useState(null),[de,Xe]=l.useState(!1),[Ye,Ee]=l.useState(null),[fe,H]=l.useState(null),[O,ve]=l.useState(null),[ye,Re]=l.useState(""),[G,ue]=l.useState(null),z=i!==null&&M!==ft,I=l.useMemo(()=>new Map(((v==null?void 0:v.files)??[]).flatMap(s=>[[s.path,s],...s.originalPath?[[s.originalPath,s]]:[]])),[v==null?void 0:v.files]),te=l.useCallback(async()=>{He(!0),Ve(null);try{const s=await ae(`/api/git-status?cwd=${encodeURIComponent(n)}`);if(!s.ok)throw new Error(await pe(s,"Unable to read git status"));const a=await s.json();Ge(a),a.isRepository||ke("all")}catch(s){Ge(null),ke("all"),Ve(s instanceof Error?s.message:"Unable to read git status")}finally{He(!1)}},[n]);l.useEffect(()=>{te()},[te]);const De=$==="all"&&g.trim()==="";l.useEffect(()=>{if(De)return;const s=new AbortController,a=window.setTimeout(async()=>{h(!0),j(null);const d=F.current;F.current=!1;try{const p=await ae(`/api/project-files?cwd=${encodeURIComponent(n)}&q=${encodeURIComponent(g)}&limit=100${d?"&refresh=1":""}`,{signal:s.signal});if(!p.ok)throw new Error(await pe(p,"Unable to list project files"));const B=await p.json();if(s.signal.aborted)return;const tt=Ct(B),st=B.totalMatches;R(tt),x(typeof st=="number"?st:tt.length),y(B.scanLimited===!0)}catch(p){s.signal.aborted||(R([]),j(p instanceof Error?p.message:"Unable to list project files"))}finally{s.signal.aborted||h(!1)}},120);return()=>{window.clearTimeout(a),s.abort()}},[n,g,D,De]),l.useEffect(()=>{T(null),J(""),re(""),oe(null),_(null),H(null),ce("edit"),we(null),Ee(null),ue(null)},[n]),l.useEffect(()=>{if(!z)return;const s=a=>a.preventDefault();return window.addEventListener("beforeunload",s),()=>window.removeEventListener("beforeunload",s)},[z]);const ht=l.useCallback((s,a)=>{const d=u.current;if(!d)return;if(!a||a<1){d.focus();return}const p=ys(s,a);d.blur(),d.setSelectionRange(p,p),d.focus()},[]);l.useEffect(()=>{const s=f.current;!s||!u.current||(f.current=null,ht(s.text,s.line))});const se=l.useCallback(async(s,a)=>{Pe(!0),_(null),ee(!1),H(null);try{const d=await ae(`/api/project-file?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}`);if(!d.ok)throw new Error(await pe(d,"Unable to open file"));const p=await d.json();J(p.content),re(p.content),oe(p.mtimeMs),Ue(p.size),f.current={text:p.content,line:a}}catch(d){J(""),re(""),oe(null),_(d instanceof Error?d.message:"Unable to open file")}finally{Pe(!1)}},[n]),ne=l.useCallback(async(s,a)=>{Xe(!0),Ee(null),we(null);try{const d=a?`&originalPath=${encodeURIComponent(a)}`:"",p=await ae(`/api/git-diff?cwd=${encodeURIComponent(n)}&path=${encodeURIComponent(s)}${d}`);if(!p.ok)throw new Error(await pe(p,"Unable to diff file"));we(await p.json())}catch(d){Ee(d instanceof Error?d.message:"Unable to diff file")}finally{Xe(!1)}},[n]),be=l.useCallback(({path:s,mode:a,line:d})=>{var p;if(T(s),Ce(!1),a==="edit"){ce(rt(s)&&!d?"preview":"edit"),se(s,d);return}ce(a),J(""),re(""),oe(null),_(null),ee(!1),H(null),ne(s,(p=I.get(s))==null?void 0:p.originalPath)},[I,ne,se]),Ne=l.useCallback(s=>{if(z){ue({type:"file",target:s});return}be(s)},[z,be]),Qe=l.useCallback(s=>{if(s===i){Ce(!1);return}const a=$==="changes"&&I.has(s)?"diff":"edit";Ne({path:s,mode:a})},[I,$,Ne,i]),We=l.useRef(0);l.useEffect(()=>{!o||o.token===We.current||(We.current=o.token,Ne({path:o.file,mode:o.mode,line:o.line}))},[o,Ne]);const pt=l.useCallback(()=>{var s;!i||C==="diff"||(ce("diff"),(E==null?void 0:E.path)!==i&&!de&&ne(i,(s=I.get(i))==null?void 0:s.originalPath))},[I,E==null?void 0:E.path,de,ne,i,C]),jt=l.useCallback(s=>{!i||C===s||(ce(s),P===null&&!K&&se(i))},[K,se,P,i,C]),Fe=l.useCallback(()=>{var s;if(i){if(C==="diff"){ne(i,(s=I.get(i))==null?void 0:s.originalPath);return}se(i)}},[I,ne,se,i,C]),gt=l.useCallback(()=>{F.current=!0,L(s=>s+1),te(),C==="diff"&&Fe()},[te,Fe,C]),Le=l.useCallback(async()=>{if(!(!i||P===null||!z||Z)){Oe(!0),_(null),ee(!1);try{const s=await ae("/api/project-file",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:n,path:i,content:M,expectedMtimeMs:P})});if(!s.ok)throw new Error(await pe(s,"Unable to save file"));const a=await s.json();re(M),oe(a.mtimeMs),Ue(a.size),ee(!0),we(null),te()}catch(s){_(s instanceof Error?s.message:"Unable to save file")}finally{Oe(!1)}}},[M,n,z,te,P,Z,i]);l.useEffect(()=>{function s(a){var d;(d=c.current)!=null&&d.contains(document.activeElement)&&Jt("projectFileSave",a)&&(a.preventDefault(),Le())}return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[Le]);const wt=l.useCallback(()=>{if(z){ue({type:"close"});return}e()},[z,e]),vt=l.useCallback(()=>{if(!G)return;const s=G;if(ue(null),s.type==="file"){be(s.target);return}e()},[e,be,G]),yt=l.useCallback(s=>{if(s.key!=="Tab")return;s.preventDefault();const a=s.currentTarget,d=a.selectionStart,p=a.selectionEnd,B=`${M.slice(0,d)} ${M.slice(p)}`;J(B),ee(!1),H(null),requestAnimationFrame(()=>{a.selectionStart=d+2,a.selectionEnd=d+2})},[M]),bt=l.useCallback(s=>{const a=s.currentTarget;if(a.selectionStart===a.selectionEnd){H(null);return}const d=M.slice(a.selectionStart,a.selectionEnd),p=M.slice(0,a.selectionStart).split(`
|
|
3
3
|
`).length,B=p+d.split(`
|
|
4
|
-
`).length-1;H({text:d,startLine:p,endLine:B})},[M]),Te=l.useMemo(()=>(i==null?void 0:i.split("/").at(-1))??null,[i]),me=i?I.get(i):void 0,qe=i!==null&&rt(i),Je=l.useCallback(s=>{const a=I.get(s);return a?{code:js(a),...ze(a)}:null},[I]),Nt=l.useMemo(()=>({...kt,img:s=>t.jsx(Et,{src:ws(s.src,n,i??""),alt:s.alt})}),[n,i]),Me=l.useMemo(()=>E&&!E.binary&&!E.tooLarge?Rt(E.original??"",E.current??""):null,[E]),V=l.useMemo(()=>{if($==="all")return b;const s=g.trim().toLowerCase();return((v==null?void 0:v.files)??[]).map(a=>a.path).filter((a,d,p)=>p.indexOf(a)===d).filter(a=>!s||a.toLowerCase().includes(s)).sort((a,d)=>a.localeCompare(d))},[$,b,v==null?void 0:v.files,g]),Ze=l.useMemo(()=>i&&!V.includes(i)?[i,...V]:V,[V,i]),St=$==="changes"?Ke:m,_e=$==="changes"?xt:N,et=Ke;return t.jsxs("aside",{ref:c,"aria-label":"Project files",className:"relative flex size-full min-h-0 flex-col bg-canvas",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(Ie,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:n,children:n}),t.jsx(A,{variant:"ghost",size:"icon-sm",onClick:wt,"aria-label":"Close project files",children:t.jsx(ss,{"data-icon":"inline-start"})})]}),t.jsx(xe,{}),(v==null?void 0:v.isRepository)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[t.jsx(ns,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),t.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:v.branch??"Detached HEAD",children:v.branch??"detached HEAD"}),v.upstream&&t.jsxs("span",{className:"truncate",children:["tracks ",v.upstream]}),(v.ahead??0)>0&&t.jsxs(le,{variant:"outline",children:["↑ ",v.ahead]}),(v.behind??0)>0&&t.jsxs(le,{variant:"outline",children:["↓ ",v.behind]}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{children:[v.files.length," changed"]})]}),t.jsx(xe,{})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("section",{"aria-label":"File browser",className:ie("min-h-0 shrink-0 flex-col md:flex md:w-56",i&&!U?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(Dt,{className:"min-w-0 flex-1",children:[t.jsx(Ft,{children:t.jsx(ls,{"data-icon":"inline-start"})}),t.jsx(Lt,{"aria-label":"Search project files",value:g,onChange:s=>S(s.target.value),placeholder:"Filter files…",spellCheck:!1})]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:et,onClick:gt,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:t.jsx(lt,{"data-icon":"inline-start",className:et?"animate-spin":void 0})})]}),(v==null?void 0:v.isRepository)&&t.jsxs(nt,{"aria-label":"File scope",value:[$],onValueChange:s=>{const a=s[0];(a==="all"||a==="changes")&&ke(a)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsx(he,{value:"all",className:"flex-1",children:"All files"}),t.jsx(he,{value:"changes",className:"flex-1",children:"Changes"})]})]}),t.jsx(xe,{}),t.jsx(Tt,{className:"min-h-0 flex-1",children:De?t.jsx(us,{cwd:n,selectedPath:i,onSelect:We,fileStatus:Je,reloadToken:D}):St?t.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading files…"]}):_e?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(Q,{children:"Could not load files"}),t.jsx(q,{children:_e})]})}):Ze.length===0?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(Ie,{})}),t.jsx(Q,{children:$==="changes"?"No working-tree changes":"No matching files"}),t.jsx(q,{children:$==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):t.jsxs("div",{className:"flex flex-col py-1",children:[Ze.map(s=>{const a=s.split("/").at(-1)??s,d=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",p=Je(s),B=ot(s);return t.jsxs(A,{variant:i===s?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>We(s),title:s,children:[t.jsx(B,{"data-icon":"inline-start",className:"text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-xs",children:a}),d&&t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:d})]}),p&&t.jsx(le,{variant:"outline",className:ie("font-mono",p.className),title:p.label,children:p.code})]},s)}),$==="all"&&(k>V.length||w)&&t.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[k>V.length&&`Showing ${V.length} of ${k} matches. Type to narrow the list. `,w&&"This project is too large to scan completely."]})]})})]}),t.jsx(xe,{orientation:"vertical",className:"hidden md:block"}),t.jsx("section",{"aria-label":"File editor",className:ie("min-h-0 min-w-0 flex-1 flex-col md:flex",i&&!U?"flex":"hidden"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center gap-2 px-3 py-1 md:flex-nowrap",children:[t.jsx(A,{variant:"ghost",size:"icon-lg",className:"md:hidden",onClick:()=>Ce(!0),"aria-label":"Back to file browser",children:t.jsx(as,{"data-icon":"inline-start"})}),t.jsxs("div",{className:"min-w-0 flex-1 basis-[calc(100%-3.25rem)] md:basis-auto",children:[t.jsx("p",{className:"truncate text-xs font-medium",title:i,children:Te}),t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:i})]}),(me||C==="diff"||qe)&&t.jsxs(nt,{"aria-label":"File view",value:[C],onValueChange:s=>{s[0]==="diff"?pt():(s[0]==="edit"||s[0]==="preview")&&jt(s[0])},variant:"outline",size:"sm",spacing:0,children:[(me||C==="diff")&&t.jsx(he,{value:"diff",children:"Diff"}),qe&&t.jsx(he,{value:"preview",children:"Preview"}),t.jsx(he,{value:"edit",children:"Edit"})]}),C==="diff"&&me&&t.jsx(le,{variant:"outline",className:ze(me).className,children:ze(me).label}),C==="diff"&&Me&&t.jsx(Mt,{add:Me.add,del:Me.del}),C!=="diff"&&z&&t.jsx(le,{variant:"outline",children:"Unsaved"}),C!=="diff"&&!z&&mt&&t.jsx(le,{variant:"secondary",children:"Saved"}),C!=="diff"&&P!==null&&t.jsx("span",{className:"hidden text-xs text-muted-foreground md:inline",children:vs(ut)}),r&&t.jsxs(A,{variant:"outline",size:"sm",disabled:C==="diff"?de||E===null:K||P===null,onClick:()=>{fe?(Re(""),ve(fe)):r({path:i})},"aria-label":fe?"Add selected lines to prompt":"Reference file in prompt",title:fe?"Add selected lines to prompt":"Reference file in prompt",children:[t.jsx(at,{"data-icon":"inline-start"}),fe?"Add selection":"Reference"]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:C==="diff"?de:K||Z,onClick:Fe,"aria-label":C==="diff"?"Reload diff":"Reload file",title:C==="diff"?"Reload diff":"Reload file",children:t.jsx(lt,{"data-icon":"inline-start"})}),C!=="diff"&&t.jsxs(A,{size:"sm",disabled:!z||K||Z||P===null,onClick:()=>void Le(),children:[Z?t.jsx(je,{"data-icon":"inline-start"}):t.jsx(is,{"data-icon":"inline-start"}),Z?"Saving…":"Save"]})]}),t.jsx(xe,{}),C!=="diff"&&Be&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[t.jsx(ge,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),t.jsx("span",{children:Be})]}),C==="diff"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:de?t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading diff…"]}):Ye?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(Q,{children:"Could not diff this file"}),t.jsx(q,{children:Ye})]})}):E===null?null:E.binary||E.tooLarge?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx($e,{})}),t.jsx(Q,{children:E.binary?"Binary file":"File is too large to diff"}),t.jsx(q,{children:E.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):E.original===E.current?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx($e,{})}),t.jsx(Q,{children:"No content changes"}),t.jsx(q,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx($t,{oldString:E.original??"",newString:E.current??"",filePath:i,compact:!1,hideHeader:!0})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K&&t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Opening file…"]}),!K&&P!==null&&(C==="preview"?t.jsx("div",{"aria-label":`Preview of ${i}`,className:"min-h-0 flex-1 overflow-auto break-words px-6 py-4 text-sm",children:t.jsx(rs,{components:Nt,remarkPlugins:zt,children:M})}):t.jsx(Zt,{textareaRef:u,ariaLabel:`Editing ${i}`,filePath:i,value:M,readOnly:!1,onChange:s=>{J(s),ee(!1),H(null)},onKeyDown:yt,onSelect:bt}))]})]}):t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(W,{variant:"icon",children:t.jsx($e,{})}),t.jsx(Q,{children:"Select a file"}),t.jsx(q,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),t.jsx(It,{open:O!==null,onOpenChange:s=>{s||ve(null)},children:t.jsxs(At,{children:[t.jsxs(Ut,{children:[t.jsx(Pt,{children:"Comment on selected lines"}),t.jsxs(Ot,{children:["Add a review instruction for ",i," lines ",O==null?void 0:O.startLine,"-",O==null?void 0:O.endLine,"."]})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:s=>{s.preventDefault();const a=ye.trim();!i||!O||!a||!r||(r({path:i,...O,comment:a}),ve(null),Re(""))},children:[t.jsx(Bt,{autoFocus:!0,"aria-label":"Review comment",value:ye,onChange:s=>Re(s.target.value),placeholder:"Describe the change you want…",onKeyDown:s=>{var a;(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&ye.trim()&&(s.preventDefault(),(a=s.currentTarget.form)==null||a.requestSubmit())}}),t.jsxs(Gt,{children:[t.jsx(A,{type:"button",variant:"outline",onClick:()=>ve(null),children:"Cancel"}),t.jsxs(A,{type:"submit",disabled:!ye.trim(),children:[t.jsx(at,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),t.jsx(Kt,{open:G!==null,onOpenChange:s=>{s||ue(null)},children:t.jsxs(Ht,{size:"sm",children:[t.jsxs(Vt,{children:[t.jsx(Xt,{children:"Discard unsaved changes?"}),t.jsx(Yt,{children:(G==null?void 0:G.type)==="file"?`Your edits to ${Te??"this file"} will be lost when you open ${G.target.path}.`:`Your edits to ${Te??"this file"} will be lost when you close the file workspace.`})]}),t.jsxs(Wt,{children:[t.jsx(Qt,{size:"sm",children:"Keep editing"}),t.jsx(qt,{variant:"destructive",size:"sm",onClick:vt,children:"Discard changes"})]})]})})]})}export{Es as ProjectFilesPanel};
|
|
4
|
+
`).length-1;H({text:d,startLine:p,endLine:B})},[M]),Te=l.useMemo(()=>(i==null?void 0:i.split("/").at(-1))??null,[i]),me=i?I.get(i):void 0,qe=i!==null&&rt(i),Je=l.useCallback(s=>{const a=I.get(s);return a?{code:js(a),...ze(a)}:null},[I]),Nt=l.useMemo(()=>({...kt,img:s=>t.jsx(Et,{src:ws(s.src,n,i??""),alt:s.alt})}),[n,i]),Me=l.useMemo(()=>E&&!E.binary&&!E.tooLarge?Rt(E.original??"",E.current??""):null,[E]),V=l.useMemo(()=>{if($==="all")return b;const s=g.trim().toLowerCase();return((v==null?void 0:v.files)??[]).map(a=>a.path).filter((a,d,p)=>p.indexOf(a)===d).filter(a=>!s||a.toLowerCase().includes(s)).sort((a,d)=>a.localeCompare(d))},[$,b,v==null?void 0:v.files,g]),Ze=l.useMemo(()=>i&&!V.includes(i)?[i,...V]:V,[V,i]),St=$==="changes"?Ke:m,_e=$==="changes"?xt:N,et=Ke;return t.jsxs("aside",{ref:c,"aria-label":"Project files",className:"relative flex size-full min-h-0 flex-col bg-canvas",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-2 px-3",children:[t.jsx(Ie,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 text-muted-foreground"}),t.jsx("h2",{className:"text-sm font-medium",children:"Project files"}),t.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground",title:n,children:n}),t.jsx(A,{variant:"ghost",size:"icon-sm",onClick:wt,"aria-label":"Close project files",children:t.jsx(ss,{"data-icon":"inline-start"})})]}),t.jsx(xe,{}),(v==null?void 0:v.isRepository)&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-8 shrink-0 items-center gap-2 px-3 text-xs text-muted-foreground",children:[t.jsx(ns,{"data-icon":"inline-start","aria-hidden":"true",className:"size-3.5"}),t.jsx("span",{className:"max-w-40 truncate font-mono text-foreground",title:v.branch??"Detached HEAD",children:v.branch??"detached HEAD"}),v.upstream&&t.jsxs("span",{className:"truncate",children:["tracks ",v.upstream]}),(v.ahead??0)>0&&t.jsxs(le,{variant:"outline",children:["↑ ",v.ahead]}),(v.behind??0)>0&&t.jsxs(le,{variant:"outline",children:["↓ ",v.behind]}),t.jsx("span",{className:"flex-1"}),t.jsxs("span",{children:[v.files.length," changed"]})]}),t.jsx(xe,{})]}),t.jsxs("div",{className:"flex min-h-0 flex-1",children:[t.jsxs("section",{"aria-label":"File browser",className:ie("min-h-0 shrink-0 flex-col md:flex md:w-56",i&&!U?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex flex-col gap-2 p-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsxs(Dt,{className:"min-w-0 flex-1",children:[t.jsx(Ft,{children:t.jsx(ls,{"data-icon":"inline-start"})}),t.jsx(Lt,{"aria-label":"Search project files",value:g,onChange:s=>S(s.target.value),placeholder:"Filter files…",spellCheck:!1})]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:et,onClick:gt,"aria-label":"Refresh files and git status",title:"Refresh files and git status",children:t.jsx(lt,{"data-icon":"inline-start",className:et?"animate-spin":void 0})})]}),(v==null?void 0:v.isRepository)&&t.jsxs(nt,{"aria-label":"File scope",value:[$],onValueChange:s=>{const a=s[0];(a==="all"||a==="changes")&&ke(a)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsx(he,{value:"all",className:"flex-1",children:"All files"}),t.jsx(he,{value:"changes",className:"flex-1",children:"Changes"})]})]}),t.jsx(xe,{}),t.jsx(Tt,{className:"min-h-0 flex-1",children:De?t.jsx(us,{cwd:n,selectedPath:i,onSelect:Qe,fileStatus:Je,reloadToken:D}):St?t.jsxs("div",{className:"flex items-center justify-center gap-2 p-6 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading files…"]}):_e?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(W,{children:"Could not load files"}),t.jsx(q,{children:_e})]})}):Ze.length===0?t.jsx(X,{className:"min-h-48 rounded-none p-4",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(Ie,{})}),t.jsx(W,{children:$==="changes"?"No working-tree changes":"No matching files"}),t.jsx(q,{children:$==="changes"?"This project has no changed files matching the filter.":"Try a different path or filename."})]})}):t.jsxs("div",{className:"flex flex-col py-1",children:[Ze.map(s=>{const a=s.split("/").at(-1)??s,d=s.includes("/")?s.slice(0,s.lastIndexOf("/")):"",p=Je(s),B=ot(s);return t.jsxs(A,{variant:i===s?"secondary":"ghost",size:"sm",className:"h-auto w-full justify-start rounded-none px-2 py-1.5 text-left",onClick:()=>Qe(s),title:s,children:[t.jsx(B,{"data-icon":"inline-start",className:"text-muted-foreground"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-xs",children:a}),d&&t.jsx("span",{className:"block truncate font-mono text-xs text-muted-foreground",children:d})]}),p&&t.jsx(le,{variant:"outline",className:ie("font-mono",p.className),title:p.label,children:p.code})]},s)}),$==="all"&&(k>V.length||w)&&t.jsxs("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:[k>V.length&&`Showing ${V.length} of ${k} matches. Type to narrow the list. `,w&&"This project is too large to scan completely."]})]})})]}),t.jsx(xe,{orientation:"vertical",className:"hidden md:block"}),t.jsx("section",{"aria-label":"File editor",className:ie("min-h-0 min-w-0 flex-1 flex-col md:flex",i&&!U?"flex":"hidden"),children:i?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex min-h-10 shrink-0 flex-wrap items-center gap-2 px-3 py-1 md:flex-nowrap",children:[t.jsx(A,{variant:"ghost",size:"icon-lg",className:"md:hidden",onClick:()=>Ce(!0),"aria-label":"Back to file browser",children:t.jsx(as,{"data-icon":"inline-start"})}),t.jsxs("div",{className:"min-w-0 flex-1 basis-[calc(100%-3.25rem)] md:basis-auto",children:[t.jsx("p",{className:"truncate text-xs font-medium",title:i,children:Te}),t.jsx("p",{className:"truncate font-mono text-xs text-muted-foreground",children:i})]}),(me||C==="diff"||qe)&&t.jsxs(nt,{"aria-label":"File view",value:[C],onValueChange:s=>{s[0]==="diff"?pt():(s[0]==="edit"||s[0]==="preview")&&jt(s[0])},variant:"outline",size:"sm",spacing:0,children:[(me||C==="diff")&&t.jsx(he,{value:"diff",children:"Diff"}),qe&&t.jsx(he,{value:"preview",children:"Preview"}),t.jsx(he,{value:"edit",children:"Edit"})]}),C==="diff"&&me&&t.jsx(le,{variant:"outline",className:ze(me).className,children:ze(me).label}),C==="diff"&&Me&&t.jsx(Mt,{add:Me.add,del:Me.del}),C!=="diff"&&z&&t.jsx(le,{variant:"outline",children:"Unsaved"}),C!=="diff"&&!z&&mt&&t.jsx(le,{variant:"secondary",children:"Saved"}),C!=="diff"&&P!==null&&t.jsx("span",{className:"hidden text-xs text-muted-foreground md:inline",children:vs(ut)}),r&&t.jsxs(A,{variant:"outline",size:"sm",disabled:C==="diff"?de||E===null:K||P===null,onClick:()=>{fe?(Re(""),ve(fe)):r({path:i})},"aria-label":fe?"Add selected lines to prompt":"Reference file in prompt",title:fe?"Add selected lines to prompt":"Reference file in prompt",children:[t.jsx(at,{"data-icon":"inline-start"}),fe?"Add selection":"Reference"]}),t.jsx(A,{variant:"ghost",size:"icon-sm",disabled:C==="diff"?de:K||Z,onClick:Fe,"aria-label":C==="diff"?"Reload diff":"Reload file",title:C==="diff"?"Reload diff":"Reload file",children:t.jsx(lt,{"data-icon":"inline-start"})}),C!=="diff"&&t.jsxs(A,{size:"sm",disabled:!z||K||Z||P===null,onClick:()=>void Le(),children:[Z?t.jsx(je,{"data-icon":"inline-start"}):t.jsx(is,{"data-icon":"inline-start"}),Z?"Saving…":"Save"]})]}),t.jsx(xe,{}),C!=="diff"&&Be&&t.jsxs("div",{role:"alert",className:"flex items-center gap-2 px-3 py-2 text-xs text-destructive",children:[t.jsx(ge,{"data-icon":"inline-start","aria-hidden":"true",className:"size-4 shrink-0"}),t.jsx("span",{children:Be})]}),C==="diff"?t.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:de?t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Loading diff…"]}):Ye?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx(ge,{})}),t.jsx(W,{children:"Could not diff this file"}),t.jsx(q,{children:Ye})]})}):E===null?null:E.binary||E.tooLarge?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx($e,{})}),t.jsx(W,{children:E.binary?"Binary file":"File is too large to diff"}),t.jsx(q,{children:E.binary?"Git tracks this change, but there is no text diff to show.":"Review this change in your editor instead."})]})}):E.original===E.current?t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx($e,{})}),t.jsx(W,{children:"No content changes"}),t.jsx(q,{children:"This file matches the last commit — only its mode or index entry differs."})]})}):t.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:t.jsx($t,{oldString:E.original??"",newString:E.current??"",filePath:i,compact:!1,hideHeader:!0})})}):t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[K&&t.jsxs("div",{className:"flex size-full items-center justify-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(je,{}),"Opening file…"]}),!K&&P!==null&&(C==="preview"?t.jsx("div",{"aria-label":`Preview of ${i}`,className:"min-h-0 flex-1 overflow-auto break-words px-6 py-4 text-sm",children:t.jsx(rs,{components:Nt,remarkPlugins:zt,children:M})}):t.jsx(Zt,{textareaRef:u,ariaLabel:`Editing ${i}`,filePath:i,value:M,readOnly:!1,onChange:s=>{J(s),ee(!1),H(null)},onKeyDown:yt,onSelect:bt}))]})]}):t.jsx(X,{className:"rounded-none",children:t.jsxs(Y,{children:[t.jsx(Q,{variant:"icon",children:t.jsx($e,{})}),t.jsx(W,{children:"Select a file"}),t.jsx(q,{children:"Browse or filter project files, then open one to inspect and edit it."})]})})})]}),t.jsx(It,{open:O!==null,onOpenChange:s=>{s||ve(null)},children:t.jsxs(At,{children:[t.jsxs(Ut,{children:[t.jsx(Pt,{children:"Comment on selected lines"}),t.jsxs(Ot,{children:["Add a review instruction for ",i," lines ",O==null?void 0:O.startLine,"-",O==null?void 0:O.endLine,"."]})]}),t.jsxs("form",{className:"flex flex-col gap-4",onSubmit:s=>{s.preventDefault();const a=ye.trim();!i||!O||!a||!r||(r({path:i,...O,comment:a}),ve(null),Re(""))},children:[t.jsx(Bt,{autoFocus:!0,"aria-label":"Review comment",value:ye,onChange:s=>Re(s.target.value),placeholder:"Describe the change you want…",onKeyDown:s=>{var a;(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&ye.trim()&&(s.preventDefault(),(a=s.currentTarget.form)==null||a.requestSubmit())}}),t.jsxs(Gt,{children:[t.jsx(A,{type:"button",variant:"outline",onClick:()=>ve(null),children:"Cancel"}),t.jsxs(A,{type:"submit",disabled:!ye.trim(),children:[t.jsx(at,{"data-icon":"inline-start"}),"Add to prompt"]})]})]})]})}),t.jsx(Kt,{open:G!==null,onOpenChange:s=>{s||ue(null)},children:t.jsxs(Ht,{size:"sm",children:[t.jsxs(Vt,{children:[t.jsx(Xt,{children:"Discard unsaved changes?"}),t.jsx(Yt,{children:(G==null?void 0:G.type)==="file"?`Your edits to ${Te??"this file"} will be lost when you open ${G.target.path}.`:`Your edits to ${Te??"this file"} will be lost when you close the file workspace.`})]}),t.jsxs(Qt,{children:[t.jsx(Wt,{size:"sm",children:"Keep editing"}),t.jsx(qt,{variant:"destructive",size:"sm",onClick:vt,children:"Discard changes"})]})]})})]})}export{Es as ProjectFilesPanel};
|
package/dist/web/assets/{ProjectSwitcherModal-BoSCOiv9.js → ProjectSwitcherModal-BnWbJWEX.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as C,r as E,j as m}from"./vendor-react-gGw_S5I_.js";import{ag as y,l as L,D as F,j as K,n as k,bK as R,o as _,X as A,bL as H}from"./index-
|
|
1
|
+
import{c as C,r as E,j as m}from"./vendor-react-gGw_S5I_.js";import{ag as y,l as L,D as F,j as K,n as k,bK as R,o as _,X as A,bL as H}from"./index-Bg4A-xl7.js";import"./vendor-ui-Dc_kJXxz.js";import"./vendor-markdown-BEJ8yVzA.js";function X(v){const e=C.c(28),{open:r,onClose:t,onNewSession:i,onNewFolder:j,defaultAgentKind:x,currentProjectDirName:a,currentProjectCwd:o,initialView:D}=v,s=y(r);let h,p;e[0]!==o||e[1]!==a||e[2]!==t||e[3]!==i||e[4]!==r||e[5]!==s?(h=()=>{if(!r)return;const n=function(N){var S;if(A("newSession",N)&&a){N.preventDefault();const P=o?H(s,o,"claude")??((S=s.find(b=>b.path===o))==null?void 0:S.dirName)??a:a;i(P,o??void 0),t()}};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},p=[r,s,a,o,i,t],e[0]=o,e[1]=a,e[2]=t,e[3]=i,e[4]=r,e[5]=s,e[6]=h,e[7]=p):(h=e[6],p=e[7]),E.useEffect(h,p);let l;e[8]!==t?(l=n=>{n||t()},e[8]=t,e[9]=l):l=e[9];let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=m.jsxs(L,{className:"sr-only",children:[m.jsx(F,{children:"Start a session"}),m.jsx(K,{children:"Choose a project, enter an absolute folder path, or browse the folders."})]}),e[10]=w):w=e[10];let c;e[11]!==t||e[12]!==i?(c=(n,g)=>{i(n,g),t()},e[11]=t,e[12]=i,e[13]=c):c=e[13];let d;e[14]!==t||e[15]!==j?(d=n=>{j(n),t()},e[14]=t,e[15]=j,e[16]=d):d=e[16];let f;e[17]!==o||e[18]!==x||e[19]!==D||e[20]!==s||e[21]!==c||e[22]!==d?(f=m.jsxs(k,{className:"max-w-md gap-0 overflow-hidden p-0",children:[w,m.jsx(R,{projects:s,currentPath:o,onNewSession:c,onNewFolder:d,defaultAgentKind:x,initialView:D})]}),e[17]=o,e[18]=x,e[19]=D,e[20]=s,e[21]=c,e[22]=d,e[23]=f):f=e[23];let u;return e[24]!==r||e[25]!==l||e[26]!==f?(u=m.jsx(_,{open:r,onOpenChange:l,children:f}),e[24]=r,e[25]=l,e[26]=f,e[27]=u):u=e[27],u}export{X as ProjectSwitcherModal};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{W as Gr,X as as,B as Jr}from"./index-
|
|
1
|
+
import{r as Ce,j as Rt}from"./vendor-react-gGw_S5I_.js";import{W as Gr,X as as,B as Jr}from"./index-Bg4A-xl7.js";import{d2 as Zr}from"./vendor-ui-Dc_kJXxz.js";import"./vendor-markdown-BEJ8yVzA.js";/**
|
|
2
2
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
3
3
|
* @license MIT
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{bM as W,aA as $,l as L,D as U,j as Y,aB as H,n as q,o as J}from"./index-
|
|
1
|
+
import{c as O,r as g,j as n}from"./vendor-react-gGw_S5I_.js";import{bM as W,aA as $,l as L,D as U,j as Y,aB as H,n as q,o as J}from"./index-Bg4A-xl7.js";import{u as Q,df as V}from"./vendor-ui-Dc_kJXxz.js";import"./vendor-markdown-BEJ8yVzA.js";const I=[{id:"narrow",name:"Narrow",css:"44rem"},{id:"medium",name:"Medium",css:"56rem"},{id:"wide",name:"Wide",css:"64rem"},{id:"full",name:"Full",css:"100%"}],B="cogpit-chat-width",R="medium";function X(){try{const s=localStorage.getItem(B);if(I.some(e=>e.id===s))return s}catch{}return R}let _=typeof window>"u"?R:X();const G=new Set;function K(s){if(typeof document>"u")return;const e=I.find(t=>t.id===s)??I[1];document.documentElement.style.setProperty("--chat-width",e.css)}K(_);function Z(){return _}function ee(s){_=s;try{localStorage.setItem(B,s)}catch{}K(s),G.forEach(e=>e())}function te(s){return G.add(s),()=>G.delete(s)}function se(){const s=O.c(2),e=g.useSyncExternalStore(te,Z,ae);let t;return s[0]!==e?(t=[e,ee],s[0]=e,s[1]=t):t=s[1],t}function ae(){return R}function ce(s){const e=O.c(42),{open:t,onClose:r,currentTheme:i,onSelectTheme:k,onPreviewTheme:l}=s,[p,A]=g.useState(0),[M,P]=se();let j,w;e[0]!==i||e[1]!==t?(j=()=>{if(t){const a=W.findIndex(D=>D.id===i);A(a>=0?a:0)}},w=[t,i],e[0]=i,e[1]=t,e[2]=j,e[3]=w):(j=e[2],w=e[3]),g.useEffect(j,w);let b,N;e[4]!==l||e[5]!==t||e[6]!==p?(b=()=>{t&&l(W[p].id)},N=[p,t,l],e[4]=l,e[5]=t,e[6]=p,e[7]=b,e[8]=N):(b=e[7],N=e[8]),g.useEffect(b,N);let S,y;e[9]!==l||e[10]!==t?(S=()=>{t||l(null)},y=[t,l],e[9]=l,e[10]=t,e[11]=S,e[12]=y):(S=e[11],y=e[12]),g.useEffect(S,y);let C;e[13]!==r||e[14]!==k?(C=a=>{k(a.id),r()},e[13]=r,e[14]=k,e[15]=C):C=e[15];const z=C;let o;e[16]!==r?(o=a=>{a||r()},e[16]=r,e[17]=o):o=e[17];let E;e[18]===Symbol.for("react.memo_cache_sentinel")?(E=n.jsxs(L,{className:"border-b p-4 pr-12",children:[n.jsxs(U,{className:"flex items-center gap-2 text-sm",children:[n.jsx(V,{"data-icon":"inline-start",className:"size-4 text-muted-foreground"}),"Appearance"]}),n.jsx(Y,{children:"Preview a color theme and set the chat width."})]}),e[18]=E):E=e[18];const F=W[p];let c;e[19]!==F.id?(c=[F.id],e[19]=F.id,e[20]=c):c=e[20];let d;e[21]!==i||e[22]!==z?(d=W.map((a,D)=>n.jsxs($,{value:a.id,className:"h-auto w-full justify-start gap-3 px-3 py-2.5 text-left text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>z(a),onMouseEnter:()=>A(D),onFocus:()=>A(D),children:[n.jsx("div",{className:"flex gap-1",children:a.swatches.map(ne)}),n.jsx("span",{className:"flex-1 text-sm font-medium",children:a.name}),i===a.id&&n.jsx(Q,{"data-icon":"inline-end",className:"size-4 shrink-0 text-foreground"})]},a.id)),e[21]=i,e[22]=z,e[23]=d):d=e[23];let m;e[24]!==c||e[25]!==d?(m=n.jsx(H,{"aria-label":"Theme",orientation:"vertical",value:c,className:"w-full items-stretch p-1",children:d}),e[24]=c,e[25]=d,e[26]=m):m=e[26];let v;e[27]===Symbol.for("react.memo_cache_sentinel")?(v=n.jsx("div",{className:"px-1 pb-2 text-xs font-medium text-muted-foreground",children:"Chat width"}),e[27]=v):v=e[27];let f;e[28]!==M?(f=[M],e[28]=M,e[29]=f):f=e[29];let u;e[30]!==P?(u=I.map(a=>n.jsx($,{value:a.id,className:"flex-1 text-xs text-muted-foreground data-pressed:bg-accent data-pressed:text-accent-foreground",onClick:()=>P(a.id),children:a.name},a.id)),e[30]=P,e[31]=u):u=e[31];let h;e[32]!==f||e[33]!==u?(h=n.jsxs("div",{className:"border-t p-3",children:[v,n.jsx(H,{"aria-label":"Chat width",value:f,className:"w-full items-stretch gap-1",children:u})]}),e[32]=f,e[33]=u,e[34]=h):h=e[34];let x;e[35]!==m||e[36]!==h?(x=n.jsxs(q,{className:"max-w-sm gap-0 overflow-hidden p-0",children:[E,m,h]}),e[35]=m,e[36]=h,e[37]=x):x=e[37];let T;return e[38]!==t||e[39]!==x||e[40]!==o?(T=n.jsx(J,{open:t,onOpenChange:o,children:x}),e[38]=t,e[39]=x,e[40]=o,e[41]=T):T=e[41],T}function ne(s,e){return n.jsx("div",{className:"size-4 rounded-full border",style:{backgroundColor:s}},e)}export{ce as ThemeSelectorModal};
|