e.request(`/approvals/${t}/decision`,{method:`POST`,body:{decision:`approved`}}),request:(t,n)=>e.request(t,n),closed:Oe,refresh:Ce,notice:l,confirm:e=>confirm(e)});return(0,Q.jsx)(Zn,{id:String(n.id),left:u.left,right:u.right,children:(0,Q.jsx)(wo,{session:c,approval:fe.get(n.id),projects:t,api:e,progressError:oe[n.id],mediaCount:d[n.id]||0,onMedia:f,onRefresh:Ce,onNotice:l,onAttach:e=>void Se(e),onChat:e=>{i?.(e),P(e)},onReview:a,onMergeReview:o,onHandoff:A,onSwitch:s,onGroup:V,onHistory:L,onWorkspace:z,onRestore:e=>void Ee(e),onRevive:e=>void Ae(e),onClosed:Oe,onArchive:t=>{e.request(`/sessions/${t.id}/archive/history`).then(e=>U({name:t.name,...e})).catch(e=>l(String(e),!0))},onDiscover:()=>A(`discover`)},n.id)},n.id)}let Fe=y===`active`&&!x&&_.length===0;return(0,Q.jsxs)(`section`,{className:`list wide${Fe?` first-run`:``}`,children:[(0,Q.jsxs)(`div`,{className:`sesshead`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{children:J(`sessions.list.title`)}),(0,Q.jsx)(`p`,{children:J(`sessions.list.activeSummary`,{active:_.filter(e=>!e.ended_at&&e.status!==`dead`).length})})]}),(0,Q.jsx)(Bn,{api:e}),(0,Q.jsx)(`button`,{className:`b`,id:`sess-recent`,"aria-expanded":te,"aria-label":J(`sessions.list.restoreClosedLabel`),onClick:()=>G(e=>!e),children:J(`sessions.list.restoreButton`)}),(0,Q.jsx)(`button`,{className:`b ok`,id:`sess-new`,onClick:()=>A(`new`),children:J(`sessions.list.newSession`)})]}),(0,Q.jsxs)(`nav`,{className:`sessions-views`,"aria-label":`Session views`,children:[(0,Q.jsx)(`a`,{href:`#sessions`,"aria-current":`page`,children:J(`sessions.list.title`)}),(0,Q.jsx)(`a`,{href:`#terminals`,children:J(`nav.terminals`)})]}),ie.length>0&&(0,Q.jsxs)(`div`,{className:`restore-banner relaunch-notice`,role:`status`,children:[(0,Q.jsxs)(`span`,{children:[J(`sessions.list.relaunched`,{count:ie.length}),` `,ie.map((e,t)=>(0,Q.jsxs)(X.Fragment,{children:[t>0&&`, `,(0,Q.jsx)(`button`,{className:`linkish`,onClick:()=>we(e),children:e.name||`#${e.id}`})]},e.id)),`.`]}),(0,Q.jsx)(`button`,{className:`b`,id:`relaunch-dismiss`,onClick:()=>void ke(),children:J(`sessions.list.dismiss`)})]}),Me.length>0&&(0,Q.jsxs)(`div`,{className:`restore-banner`,role:`status`,children:[(0,Q.jsx)(`span`,{children:J(`sessions.list.interrupted`,{count:Me.length})}),(0,Q.jsx)(`button`,{className:`b ok`,id:`restore-interrupted`,disabled:q,onClick:()=>void Ne(),children:q?J(`sessions.list.restoring`):Me.length===1?J(`sessions.list.restoreIt`):J(`sessions.list.restoreCount`,{count:Me.length})})]}),(0,Q.jsx)(Go,{rows:_,approvalsCount:ue.length,onShowSession:we,onShowApprovals:Te}),(0,Q.jsx)(`input`,{id:`sess-search`,className:`f`,type:`search`,placeholder:J(`sessions.list.searchPlaceholder`),"aria-label":J(`sessions.list.searchLabel`),value:x,onChange:e=>S(e.target.value)}),(0,Q.jsxs)(`details`,{className:`session-filter-options`,open:_.length>5||w!==`none`||y!==`active`,children:[(0,Q.jsx)(`summary`,{children:J(`sessions.list.filterOptions`,void 0,`Filter sessions`)}),(0,Q.jsxs)(`div`,{className:`session-filters`,children:[(0,Q.jsxs)(`label`,{className:`session-grouping`,children:[J(`sessions.list.groupBy`),` `,(0,Q.jsxs)(`select`,{className:`f`,id:`sess-grouping`,"aria-label":J(`sessions.list.groupByLabel`),value:w,onChange:e=>{let t=e.target.value;T(t),sessionStorage.setItem(`lec-session-grouping`,t)},children:[(0,Q.jsx)(`option`,{value:`none`,children:J(`sessions.list.groupNone`)}),(0,Q.jsx)(`option`,{value:`group`,children:J(`sessions.list.groupNamed`)}),(0,Q.jsx)(`option`,{value:`project`,children:J(`sessions.list.groupProject`)}),(0,Q.jsx)(`option`,{value:`target`,children:J(`sessions.list.groupTarget`)})]})]}),(0,Q.jsxs)(`label`,{className:`session-grouping session-scope`,children:[J(`sessions.list.show`),` `,(0,Q.jsxs)(`select`,{className:`f`,id:`sess-scope`,value:y,onChange:e=>b(e.target.value),children:[(0,Q.jsx)(`option`,{value:`active`,children:J(`sessions.list.scopeActive`)}),(0,Q.jsx)(`option`,{value:`all`,children:J(`sessions.list.scopeAll`)}),(0,Q.jsx)(`option`,{value:`archived`,children:J(`sessions.list.scopeArchived`)})]})]})]})]}),te&&(0,Q.jsxs)(`section`,{"aria-label":J(`sessions.list.restoreClosedLabel`),children:[(0,Q.jsxs)(`div`,{className:`restore-tools`,children:[(0,Q.jsxs)(`button`,{className:`b`,id:`sess-saved-search`,onClick:()=>W(!0),"aria-label":J(`sessions.list.searchSavedLabel`),children:[J(`sessions.list.searchSaved`),(0,Q.jsx)(`span`,{className:`wide-only`,children:J(`sessions.list.searchSavedWide`)})]}),(0,Q.jsxs)(`button`,{className:`b`,id:`sess-discover`,onClick:()=>A(`discover`),"aria-label":J(`sessions.list.findAgentsLabel`),children:[J(`sessions.list.findAgentsFind`),(0,Q.jsx)(`span`,{className:`wide-only`,children:J(`sessions.list.findAgentsWide`)}),J(`sessions.list.findAgentsEnd`)]})]}),(0,Q.jsx)(Ao,{api:e,onNotice:l,refreshVersion:u,onReopen:async e=>{await Ee(e)},onElsewhere:K})]}),ne&&(0,Q.jsx)(Lo,{api:e,session:ne,mode:`restore`,onClose:()=>K(void 0),onChoose:async e=>{if(!await Ee(ne,{agent:e.agent,model:e.model,profile_id:e.profile}))throw Error(J(`sessions.list.restoreFailed`))}}),(0,Q.jsxs)(`div`,{id:`sesslist`,children:[(0,Q.jsxs)(`section`,{className:`session-section`,id:`regular-sessions`,"aria-labelledby":`regular-sessions-title`,children:[(0,Q.jsx)(`h3`,{className:`session-section-title`,id:`regular-sessions-title`,children:J(`sessions.list.sectionTitle`)}),(0,Q.jsx)(`div`,{className:`session-grid`,children:ye.length?(0,Q.jsx)(To,{items:ye,mode:w,query:x.trim(),collapsed:E,onToggle:xe,render:Pe}):x||y!==`active`?(0,Q.jsx)(`div`,{className:`hint`,children:J(x?`sessions.list.noMatch`:y===`archived`?`sessions.list.noArchived`:`sessions.list.empty`)}):(0,Q.jsx)(Ko,{request:e.request,onStart:()=>A(`new`),onDemo:je,onFind:()=>A(`discover`)})})]}),(be.length>0||_.length>5)&&(0,Q.jsx)(Eo,{items:be,mode:w,query:x.trim(),collapsed:E,onToggle:xe,render:Pe})]}),(0,Q.jsx)(Vo,{api:e,rows:_,refreshVersion:u,onChat:e=>{i?.(e),P(e)},onAttach:e=>void Se(e),onReview:a,onShowSession:we,onOpenTask:c,onChanged:()=>void _e(),onNotice:l,pushPrompt:g}),k===`new`&&(0,Q.jsx)(wr,{api:e,projects:t,targets:n,initialProject:j,onClose:()=>{A(void 0),M(void 0)},onCreated:()=>void Ce(),onNotice:l}),` `,k===`discover`&&(0,Q.jsx)(Tr,{api:e,projects:t,onClose:()=>A(void 0),onCreated:()=>void Ce(),onNotice:l}),` `,typeof k==`object`&&(0,Q.jsx)(Er,{api:e,session:k,onClose:()=>A(void 0),onCreated:()=>void _e(),onNotice:l}),` `,B&&(0,Q.jsx)(Zo,{api:e,session:B,groups:_.map(e=>e.group_path).filter(Boolean),onClose:()=>V(void 0),onSaved:()=>void _e()}),` `,N&&(0,Q.jsx)(ro,{kind:`session`,id:N.id,name:N.name,session:_.find(e=>e.id===N.id)||N,onOpenSession:P,api:e,onClose:()=>P(void 0),onNotice:l,onAttach:()=>void Se(N),onSwitch:s&&N.agent!==`shell`&&!N.ended_at&&N.status!==`dead`?()=>{P(void 0),s(N)}:void 0},`session-${N.id}`),` `,R&&(0,Q.jsx)(oo,{api:e,session:R,onClose:()=>z(void 0),onChanged:()=>void _e(),onNotice:l}),` `,F&&(0,Q.jsx)(C,{api:e,session:F,onClose:()=>L(void 0),onSession:(e,t)=>{L(void 0),_e(),e.setup_state===`creating`?l(J(`sessions.list.forkSetupStarted`)):t===`resume`?Se(e):l(J(`sessions.list.forkStarted`))},onNotice:l}),` `,ee&&(0,Q.jsx)(De,{api:e,targets:n,onClose:()=>W(!1),onFork:e=>{W(!1),_e(),e.setup_state===`creating`?l(J(`sessions.list.forkSetupStarted`)):Se(e)},onNotice:l}),` `,H&&(0,Q.jsxs)(O,{className:`sheet archive-output`,"aria-label":J(`sessions.list.archivedOutput`),onCancel:()=>U(void 0),children:[(0,Q.jsx)(`h2`,{children:H.name}),(0,Q.jsx)(`button`,{className:`b`,"aria-label":J(`sessions.list.closeArchivedOutput`),"data-close":!0,onClick:()=>U(void 0),children:J(`sessions.list.close`)}),(0,Q.jsx)(`p`,{children:H.note}),(0,Q.jsx)(`pre`,{children:H.text||J(`sessions.list.noOutput`)})]}),(0,Q.jsx)(tr,{api:e,onNotice:l})]})}function Zo({api:e,session:t,groups:n,onClose:r,onSaved:i}){Y();let[a,o]=(0,X.useState)(t.group_path||``),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1);return(0,Q.jsxs)(O,{id:`sheet`,className:`sheet`,"aria-label":J(`sessions.groupEditor.title`),onCancel:r,children:[(0,Q.jsxs)(`div`,{className:`sheet-head`,children:[(0,Q.jsx)(`h2`,{children:J(`sessions.groupEditor.title`)}),(0,Q.jsx)(`button`,{className:`x`,"aria-label":J(`sessions.groupEditor.close`),"data-close":!0,onClick:r,children:`✕`})]}),(0,Q.jsx)(`p`,{children:t.name}),(0,Q.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),u(!0);try{await e.request(`/sessions/${t.id}`,{method:`PATCH`,body:{group_path:a}}),i(),r()}catch(e){c(String(e))}finally{u(!1)}},children:[(0,Q.jsx)(`label`,{className:`f`,htmlFor:`sg-path`,children:J(`sessions.groupEditor.path`)}),(0,Q.jsx)(`input`,{className:`f`,id:`sg-path`,list:`sg-existing`,placeholder:J(`sessions.groupEditor.pathPlaceholder`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,Q.jsx)(`datalist`,{id:`sg-existing`,children:[...new Set(n)].sort().map(e=>(0,Q.jsx)(`option`,{value:e},e))}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`sessions.groupEditor.hint`)}),(0,Q.jsx)(`p`,{id:`sg-error`,role:`status`,children:s}),(0,Q.jsx)(`button`,{className:`b ok`,id:`sg-save`,disabled:l,children:J(`sessions.groupEditor.save`)})]})]})}function Qo(){Y();let[e,t]=(0,X.useState)(qr),[n,r]=(0,X.useState)();(0,X.useEffect)(()=>{Qr(!0).then(r)},[]);let i=typeof window<`u`&&!ue()&&!!ri(window),a=e=>{t(e),Jr(e)};return(0,Q.jsxs)(`article`,{className:`voice-settings`,"data-testid":`voice-settings`,children:[(0,Q.jsx)(`h3`,{children:J(`voice.title`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`voice.help`)}),(0,Q.jsxs)(`label`,{className:`voice-choice`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`voice-engine`,value:`device`,checked:e===`device`,disabled:!i,onChange:()=>a(`device`)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:J(`voice.device`)}),` — `,J(`voice.deviceHelp`),` `,J(i?`voice.availableHere`:`voice.deviceMissing`)]})]}),(0,Q.jsxs)(`label`,{className:`voice-choice`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`voice-engine`,value:`host`,checked:e===`host`,disabled:!n?.available,onChange:()=>a(`host`)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:J(`voice.host`)}),` — `,J(`voice.hostHelp`),` `,n===void 0?J(`voice.checking`):n.available?J(`voice.hostAvailable`,{model:n.model||``}):n.hint||J(`voice.hostMissing`)]})]}),(0,Q.jsxs)(`label`,{className:`voice-choice`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`voice-engine`,value:`auto`,checked:e===`auto`,onChange:()=>a(`auto`)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:J(`voice.auto`)}),` — `,J(`voice.autoHelp`)]})]})]})}function $o(){Y();let e=Me(),[t,r]=(0,X.useState)(n);return(0,X.useEffect)(()=>{let e=()=>r(n());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),!e?.hosts||!t.length?null:(0,Q.jsxs)(`article`,{className:`devices-panel app-hosts`,"data-testid":`app-hosts`,children:[(0,Q.jsx)(`h3`,{children:J(`appHosts.title`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`appHosts.help`)}),(0,Q.jsx)(`ul`,{className:`device-list`,children:t.map(t=>(0,Q.jsxs)(`li`,{className:`device-row`,"data-host-id":t.id,children:[(0,Q.jsxs)(`div`,{className:`device-info`,children:[(0,Q.jsx)(`strong`,{children:t.label}),(0,Q.jsxs)(`span`,{className:`subhint`,children:[t.mode===`relay`?J(`appHosts.relay`):t.origin,t.active?` · `+J(`appHosts.open`):``]})]}),!t.active&&(0,Q.jsx)(`button`,{className:`b`,onClick:()=>e.switchHost?.(t.id),children:J(`appHosts.switch`)})]},t.id))}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>e.openHosts?.(),children:J(`appHosts.manage`)})]})}var es;(function(e){class t{version;errorCorrectionLevel;static encodeText(e,n){let r=es.QrSegment.makeSegments(e);return t.encodeSegments(r,n)}static encodeBinary(e,n){let r=es.QrSegment.makeBytes(e);return t.encodeSegments([r],n)}static encodeSegments(e,r,o=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=o&&o<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=o;;u++){let n=t.getNumDataCodewords(u,r)*8,i=a.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.lengthm[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}size;mask;modules=[];isFunction=[];constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,et.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e>>9)*1335;let a=(t<<10|n)^21522;i(!(a>>>15));for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(!(t>>>18));for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;ne+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=Math.floor((this.version*8+e*3+5)/(e*4-4))*2,n=[6];for(let r=this.size-7;n.lengtht.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(!(n>>>8)),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}static MIN_VERSION=1;static MAX_VERSION=40;static PENALTY_N1=3;static PENALTY_N2=3;static PENALTY_N3=40;static PENALTY_N4=10;static ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]];static NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]]}e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return!!(e>>>t&1)}function i(e){if(!e)throw Error(`Assertion error`)}class a{mode;numChars;bitData;static makeBytes(e){let t=[];for(let r of e)n(r,8,t);return new a(a.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!a.isNumeric(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let r=0;r=1<void Ce(e,()=>{}).then(()=>t(J(`pairLink.copied`))).catch(e=>t(String(e),!0)),children:J(`pairLink.copy`)}),r&&(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void navigator.share({title:J(`pairLink.shareTitle`),url:e}).catch(()=>void 0),children:J(`pairLink.share`)}),n&&(0,Q.jsx)(`a`,{className:`b`,href:n,"data-testid":`app-pair-link`,title:J(`pairLink.appTitle`),children:J(`pairLink.openApp`)})]})}function ss({intent:e}){return Y(),e?(0,Q.jsxs)(`p`,{className:`pair-open-app`,"data-testid":`open-in-app`,children:[J(`pairLink.usingApp`),` `,(0,Q.jsx)(`a`,{href:e,children:J(`pairLink.pairApp`)})]}):null}function cs(e){let t=``;try{t=new URL(e).hostname}catch{return!1}return t=t.replace(/^\[|\]$/g,``),t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||/^127\./.test(t)||t===`0.0.0.0`}function ls(e,t){let n=[],r=t&&!cs(t)?t.replace(/\/+$/,``):``;r&&n.push({kind:`current`,url:r,available:!0,secure:r.startsWith(`https:`)});for(let t of e?.options||[]){if(t.url&&r&&t.url.replace(/\/+$/,``)===r)continue;let e=!!t.url&&cs(t.url);n.push(e?{...t,available:!1,reason:t.reason||`loopback_only`}:t)}return n}function us(e){return e.find(e=>e.available)}function ds(e,t){return`${e.replace(/\/+$/,``)}/pair#code=${encodeURIComponent(t)}`}var fs=`__LECTERN_API__`;function ps(e,t){return e.split(fs).join(t)}function ms(e,t,n){return t?{command:`lectern`,args:[`mcp`],env:{LECTERN_API:n}}:{command:e,args:[`mcp`]}}function hs(e,t,n){return JSON.stringify({mcpServers:{lectern:ms(e,t,n)}},null,2)}function gs(e,t,n){return`cursor://anysphere.cursor-deeplink/mcp/install?name=lectern&config=${btoa(JSON.stringify(ms(e,t,n)))}`}function _s(e,t,n){let r={name:`lectern`,...ms(e,t,n)};return`vscode:mcp/install?${encodeURIComponent(JSON.stringify(r))}`}function vs(e,t=Date.now()){let n=Math.max(0,Math.round(t/1e3-e));if(n<45)return J(`settings.connect.justNow`);let r=Math.round(n/60);if(r<60)return J(`settings.connect.minAgo`,{n:r});let i=Math.round(r/60);if(i<24)return J(`settings.connect.hoursAgo`,{n:i});let a=Math.round(i/24);return J(`settings.connect.daysAgo`,{n:a})}function ys(e){return e.last_seen?J(`settings.connect.usedAgo`,{name:e.name,ago:vs(e.last_seen.at)}):e.installed===!0?`✓ ${e.detail||J(`settings.connect.alreadyConnected`)}`:e.detail}function bs({api:e,onNotice:t}){Y();let[n,r]=(0,X.useState)([]),[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)({}),f=typeof window<`u`&&window.location?window.location.origin:``;function p(){e.request(`/mcp-clients`).then(e=>{r(e),a(!0)}).catch(e=>t(String(e),!0))}(0,X.useEffect)(()=>{p()},[]);async function m(n){l(n);try{let r=await e.request(`/mcp-clients/${n}/install`,{method:`POST`});d(e=>({...e,[n]:r})),t(r.ok?J(`settings.connect.connected`):r.output||J(`settings.connect.installFailed`),!r.ok),p()}catch(e){d(t=>({...t,[n]:{ok:!1,output:String(e)}})),t(String(e),!0)}finally{l(void 0)}}function h(e){navigator.clipboard?.writeText&&navigator.clipboard.writeText(e).then(()=>t(J(`settings.connect.copied`)),()=>t(J(`settings.connect.copyFailed`),!0))}return(0,Q.jsxs)(`section`,{className:`connect-tools`,"aria-labelledby":`connect-tools-heading`,children:[(0,Q.jsx)(`h3`,{id:`connect-tools-heading`,"data-setting":`machines.connect`,children:J(`settings.connect.title`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.connect.hint`)}),(0,Q.jsxs)(`label`,{className:`connect-remote-toggle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),` `,J(`settings.connect.remote`)]}),!i&&(0,Q.jsx)(`p`,{role:`status`,className:`sub`,children:J(`settings.common.loading`)}),(0,Q.jsx)(`div`,{className:`connect-tools-grid`,id:`connect-tools-grid`,children:n.map(e=>{let t=o&&e.id!==`web-connectors`?e.remote_command:e.command,n=t?ps(t,f):void 0,r=u[e.id];return(0,Q.jsxs)(`article`,{className:`rowcard connect-client`,"data-client":e.id,children:[(0,Q.jsx)(`h3`,{children:e.name}),(0,Q.jsx)(`p`,{className:`sub connect-status`,role:`status`,children:ys(e)}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[e.can_install&&(0,Q.jsx)(`button`,{className:`b`,type:`button`,disabled:c===e.id,"aria-label":J(`settings.connect.connectName`,{name:e.name}),onClick:()=>void m(e.id),children:c===e.id?J(`settings.connect.connecting`):e.installed?J(`settings.connect.reinstall`):J(`settings.connect.connect`)}),e.id===`claude-desktop`&&(0,Q.jsx)(`a`,{className:`b connect-deeplink`,href:`claude://`,children:J(`settings.connect.openClaudeDesktop`)}),e.id===`cursor`&&e.lectern_path&&(0,Q.jsx)(`a`,{className:`b connect-deeplink`,href:gs(e.lectern_path,o,f),children:J(`settings.connect.connectCursor`)}),e.id===`vscode`&&e.lectern_path&&(0,Q.jsx)(`a`,{className:`b connect-deeplink`,href:_s(e.lectern_path,o,f),children:J(`settings.connect.connectVscode`)}),e.external_url&&(0,Q.jsx)(`a`,{className:`b connect-deeplink`,href:e.external_url,target:`_blank`,rel:`noreferrer`,children:J(`settings.connect.openClaudeConnectors`)}),e.id===`web-connectors`&&(0,Q.jsx)(`a`,{className:`b connect-deeplink`,href:`https://chatgpt.com/#settings`,target:`_blank`,rel:`noreferrer`,children:J(`settings.connect.openChatgpt`)})]}),r&&(0,Q.jsxs)(`p`,{className:`connect-result ${r.ok?`ok`:`err`}`,role:`status`,children:[r.ok?`✓ `:`✗ `,r.output]}),n&&(0,Q.jsxs)(`div`,{className:`connect-snippet`,children:[(0,Q.jsx)(`pre`,{children:n}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,onClick:()=>h(n),children:J(`settings.connect.copyCommand`)})]}),e.id===`claude-desktop`&&e.lectern_path&&(0,Q.jsxs)(`div`,{className:`connect-snippet`,children:[(0,Q.jsx)(`pre`,{children:hs(e.lectern_path,o,f)}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,onClick:()=>h(hs(e.lectern_path,o,f)),children:J(`settings.connect.copyConfig`)})]})]},e.id)})})]})}function xs(e,t,n){return`${(t||n).replace(/\/+$/,``)}/relay-pair#p=${e}`}function Ss(){Y();let e=typeof window<`u`?window.__lecternRelay:void 0,[,t]=(0,X.useState)(0);if((0,X.useEffect)(()=>{if(!e)return;let n=()=>t(e=>e+1);return e.addEventListener(`status`,n),()=>e.removeEventListener(`status`,n)},[e]),!K())return ue()?(0,Q.jsxs)(`div`,{className:`relay-this-device`,"data-testid":`app-this-device`,children:[(0,Q.jsx)(`h4`,{children:J(`settings.relay.thisApp`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.relay.directTo`,{host:window.location.host})}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>{confirm(J(`settings.relay.disconnectConfirm`))&&g()},children:J(`settings.relay.disconnect`)})]}):null;let n=S();async function r(){confirm(J(`settings.relay.forgetConfirm`))&&(await g(),window.location.reload())}return(0,Q.jsxs)(`div`,{className:`relay-this-device`,"data-testid":`relay-this-device`,children:[(0,Q.jsx)(`h4`,{children:J(`settings.relay.thisDevice`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:n?J(`settings.relay.pairedDirect`):`${J(`settings.relay.through`,{status:e?.status??J(`settings.relay.starting`)})}${e?.detail?` — ${e.detail}`:``}`}),!ue()&&(0,Q.jsxs)(`label`,{className:`devices-toggle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>{re(e.target.checked),window.location.reload()}}),J(`settings.relay.preferDirect`)]}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void r(),children:J(`settings.relay.forget`)})]})}function Cs({api:e,onNotice:t}){Y();let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(0),[c,l]=(0,X.useState)(!1);function u(){e.request(`/relay`).then(r).catch(()=>r(void 0))}(0,X.useEffect)(u,[]),(0,X.useEffect)(()=>{if(!i)return;let e=()=>{let e=Math.max(0,Math.round(i.expires_at-Date.now()/1e3));s(e),e%5==0&&u()};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[i]);async function d(){l(!0);try{a(await e.request(`/relay/pair`,{method:`POST`}))}catch(e){t(String(e),!0)}finally{l(!1)}}async function f(n){if(confirm(J(`settings.relay.revokeConfirm`,{name:n.name})))try{await e.request(`/relay/devices/${n.id}`,{method:`DELETE`}),u()}catch(e){t(String(e),!0)}}let p=!!i&&o<=0,m=typeof window<`u`?window.location.origin:``;return(0,Q.jsxs)(`article`,{className:`devices-panel relay-panel`,"data-testid":`relay-panel`,children:[(0,Q.jsx)(`h3`,{"data-setting":`devices.relay`,children:J(`settings.relay.title`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.relay.hint`)}),(0,Q.jsx)(Ss,{}),n?n.configured?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`subhint`,"data-testid":`relay-state`,children:[n.connected?J(`settings.relay.connectedTo`):J(`settings.relay.notConnectedTo`),` `,(0,Q.jsx)(`code`,{children:n.relay_url}),!n.connected&&n.error?` — ${n.error}`:``,(0,Q.jsx)(`br`,{}),J(`settings.relay.lecternKey`),` `,(0,Q.jsx)(`code`,{children:n.host_fingerprint}),` · `,J(`settings.relay.shellKey`),` `,(0,Q.jsx)(`code`,{children:n.shell_fingerprint})]}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void d(),disabled:c||!n.connected,children:J(c?`settings.devices.generating`:`settings.relay.pair`)}),i&&!p&&(0,Q.jsxs)(`div`,{className:`pairing-mint`,"data-testid":`relay-pairing-mint`,children:[(0,Q.jsx)(ts,{value:xs(i.fragment,i.shell_url,m),size:220}),(0,Q.jsxs)(`div`,{className:`pairing-mint-code`,children:[(0,Q.jsxs)(`p`,{className:`subhint`,children:[J(`settings.relay.scanBefore`),` `,(0,Q.jsx)(`code`,{children:i.shell_url||m}),` `,J(`settings.relay.scanAfter`)]}),(0,Q.jsxs)(`p`,{className:`subhint`,children:[J(`settings.relay.lecternKeyColon`),` `,(0,Q.jsx)(`code`,{children:i.host_fingerprint})]}),(0,Q.jsx)(`a`,{className:`relay-pair-link`,href:xs(i.fragment,i.shell_url,m),children:J(`settings.relay.link`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.expires`,{seconds:o})}),(0,Q.jsx)(os,{link:xs(i.fragment,i.shell_url,m),onNotice:t})]})]}),i&&p&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.expired`)}),(0,Q.jsx)(`h4`,{children:J(`settings.relay.devices`)}),n.devices.length===0?(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.relay.none`)}):(0,Q.jsx)(`ul`,{className:`device-list`,children:n.devices.map(e=>(0,Q.jsxs)(`li`,{className:`device-row`,"data-testid":`relay-device`,children:[(0,Q.jsxs)(`div`,{className:`device-info`,children:[(0,Q.jsx)(`strong`,{children:e.name}),(0,Q.jsxs)(`span`,{className:`subhint`,children:[e.connected?`${J(`settings.relay.connectedNow`)} · `:``,J(`settings.relay.key`),` `,(0,Q.jsx)(`code`,{children:e.fingerprint}),` · `,J(`settings.relay.pairedSeen`,{paired:vs(e.paired_at),seen:vs(e.last_seen_at)})]})]}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void f(e),children:J(`settings.devices.revoke`)})]},e.id))})]}):(0,Q.jsxs)(`p`,{className:`subhint`,children:[J(`settings.relay.notSetUp1`),` `,(0,Q.jsx)(`code`,{children:`lectern relay`}),` `,J(`settings.relay.notSetUp2`),` `,(0,Q.jsx)(`code`,{children:`LECTERN_RELAY_URL`}),` `,J(`settings.relay.notSetUp3`),` `,(0,Q.jsx)(`code`,{children:`LECTERN_RELAY_HOST_SECRET`}),J(`settings.relay.notSetUp4`)]}):null]})}function ws({api:e,onNotice:t,onClose:n}){Y();let[r,i]=(0,X.useState)(),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(),[l,u]=(0,X.useState)(),[d,f]=(0,X.useState)(0),[p,m]=(0,X.useState)(!1),h=typeof window<`u`?window.location.origin:``;(0,X.useEffect)(()=>{e.request(`/phone/addresses`).then(i).catch(e=>o(String(e instanceof Error?e.message:e)))},[]);let g=ls(r,h);(0,X.useEffect)(()=>{!s&&r&&c(us(g))},[r]),(0,X.useEffect)(()=>{if(!l)return;let e=()=>f(Math.max(0,Math.round(l.expiresAt-Date.now()/1e3)));e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[l]);async function _(){if(s?.available){m(!0),u(void 0);try{if(s.kind===`relay`){let t=await e.request(`/relay/pair`,{method:`POST`});u({url:xs(t.fragment,t.shell_url,h),expiresAt:t.expires_at})}else{let t=await e.request(`/pair/settings`);if(!t.enabled){if(t.env_forced)throw Error(J(`phone.pairingForcedOff`));await e.request(`/pair/settings`,{method:`PUT`,body:{enabled:!0}})}let n=await e.request(`/pair/mint`,{method:`POST`});u({url:ds(s.url,n.code),expiresAt:n.expires_at})}}catch(e){t(String(e instanceof Error?e.message:e),!0)}finally{m(!1)}}}async function v(){m(!0);try{let t=await e.request(`/phone/wifi`,{method:`POST`});i(await e.request(`/phone/addresses`)),c({kind:`lan`,url:t.url,available:!0,secure:!1}),u(void 0)}catch(e){t(String(e),!0)}finally{m(!1)}}let y=!!r&&!g.some(e=>e.available);return(0,Q.jsxs)(O,{className:`sheet phone-wizard`,id:`phone-wizard`,"aria-label":J(`phone.title`),onCancel:n,children:[(0,Q.jsxs)(`div`,{className:`sheet-head`,children:[(0,Q.jsx)(`h2`,{children:J(`phone.title`)}),(0,Q.jsx)(`button`,{className:`x`,"aria-label":J(`phone.close`),"data-close":!0,onClick:n,children:`✕`})]}),(0,Q.jsx)(`p`,{children:J(`phone.intro`)}),a&&(0,Q.jsx)(`p`,{className:`subhint error`,role:`alert`,children:a}),!r&&!a&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`phone.checking`)}),(0,Q.jsx)(`div`,{className:`phone-choices`,role:`radiogroup`,"aria-label":J(`phone.choices`),children:g.map(e=>(0,Q.jsxs)(`label`,{className:`phone-choice`,"data-kind":e.kind,"data-available":e.available?`true`:`false`,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`phone-choice`,value:e.kind,disabled:!e.available,checked:s?.kind===e.kind,onChange:()=>{c(e),u(void 0)}}),(0,Q.jsxs)(`span`,{className:`phone-choice-body`,children:[(0,Q.jsxs)(`span`,{className:`phone-choice-title`,children:[J(`phone.kind.${e.kind}`),e.url&&e.kind!==`relay`&&(0,Q.jsx)(`code`,{children:e.url})]}),(0,Q.jsxs)(`span`,{className:`phone-choice-note`,children:[e.kind===`lan`&&e.available&&(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`⚠ `}),J(`phone.explain.${e.kind}`)]}),!e.available&&e.reason&&(0,Q.jsx)(`span`,{className:`phone-choice-why`,children:J(`phone.why.${e.reason}`)})]})]},e.kind))}),y&&(0,Q.jsx)(`p`,{className:`subhint`,id:`phone-none`,role:`status`,children:J(`phone.none`)}),r?.can_enable_wifi&&!r.options.some(e=>e.kind===`lan`&&e.available)&&(0,Q.jsxs)(`div`,{className:`phone-wifi-enable`,children:[(0,Q.jsx)(`p`,{children:J(`phone.wifiWarning`,void 0,`Both devices must be on this network. Wi-Fi HTTP is unencrypted; enable it only on a trusted network. Access ends when this local runtime stops.`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,disabled:p,onClick:()=>void v(),children:J(`phone.enableWiFi`,void 0,`Let my phone connect on this Wi-Fi`)})]}),(0,Q.jsxs)(`div`,{className:`phone-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`b ok`,id:`phone-show-qr`,disabled:!s?.available||p,"aria-describedby":s?.available?void 0:`phone-show-why`,onClick:()=>void _(),children:J(p?`phone.making`:`phone.show`)}),!s?.available&&r&&(0,Q.jsx)(`span`,{className:`subhint`,id:`phone-show-why`,children:J(`phone.showWhy`)})]}),l&&d>0&&(0,Q.jsxs)(`div`,{className:`pairing-mint phone-qr`,"data-testid":`phone-qr`,"data-url":l.url,children:[(0,Q.jsx)(ts,{value:l.url,size:220}),(0,Q.jsxs)(`div`,{className:`pairing-mint-code`,children:[(0,Q.jsx)(`p`,{className:`subhint`,children:J(`phone.scan`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.expires`,{seconds:d})}),(0,Q.jsx)(os,{link:l.url,onNotice:t})]})]}),l&&d<=0&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.expired`)})]})}function Ts({api:e,values:t,onNotice:n,onSection:r,onEnablePush:a,pushAvailable:o,pushUnavailableReason:s,pushEndpoint:c,onChanged:l}){Y();let u=T(),[d,f]=(0,X.useState)(),[m,h]=(0,X.useState)(String(t.session_permission_mode??``)===`ask`),[g,_]=(0,X.useState)(!1),[v,y]=i(Ri,`auto`);(0,X.useEffect)(()=>h(String(t.session_permission_mode??``)===`ask`),[t.session_permission_mode]),(0,X.useEffect)(()=>{e.request(`/onboarding`).then(e=>f(e.agents)).catch(()=>f([]))},[]);async function b(t){h(t);try{await e.request(`/settings`,{method:`PUT`,body:{session_permission_mode:t?`ask`:`bypass`}}),n(J(t?`basics.askOn`:`basics.askOff`)),l()}catch(e){h(!t),n(String(e),!0)}}return(0,Q.jsxs)(`article`,{className:`basics`,id:`settings-basics`,children:[(0,Q.jsx)(`h3`,{children:J(`settings.section.basics`)}),(0,Q.jsxs)(`div`,{className:`basics-row`,"data-setting":`basics.agents`,children:[(0,Q.jsx)(`span`,{className:`basics-label`,children:J(`basics.agents`)}),(0,Q.jsxs)(`span`,{className:`basics-value`,id:`basics-agents`,children:[d?(0,Q.jsxs)(Q.Fragment,{children:[d.filter(e=>e.found).map(e=>(0,Q.jsxs)(`span`,{className:`chip ok`,"data-found":`true`,children:[`✓ `,e.name]},e.name)),!d.some(e=>e.found)&&(0,Q.jsx)(`span`,{className:`basics-hint`,children:J(`basics.noAgents`)}),d.some(e=>!e.found)&&(0,Q.jsx)(`span`,{className:`basics-hint`,id:`basics-agents-missing`,children:J(`basics.notInstalledList`,{names:d.filter(e=>!e.found).map(e=>e.name).join(`, `)})})]}):`…`,(0,Q.jsx)(`button`,{type:`button`,className:`linkish`,onClick:()=>r(`agents`),children:J(`basics.manageAgents`)})]})]}),(0,Q.jsxs)(`label`,{className:`basics-row`,"data-setting":`basics.ask`,children:[(0,Q.jsxs)(`span`,{className:`basics-label`,children:[J(`start.sheet.ask`),(0,Q.jsx)(`span`,{className:`basics-hint`,children:J(`basics.askHint`)})]}),(0,Q.jsx)(`input`,{type:`checkbox`,role:`switch`,id:`basics-ask`,checked:m,onChange:e=>void b(e.target.checked)})]}),(0,Q.jsxs)(`div`,{className:`basics-row`,"data-setting":`basics.phone`,children:[(0,Q.jsxs)(`span`,{className:`basics-label`,children:[J(`basics.phone`),(0,Q.jsx)(`span`,{className:`basics-hint`,children:J(`basics.phoneHint`)})]}),(0,Q.jsx)(`button`,{type:`button`,className:`b ok`,id:`basics-phone`,onClick:()=>_(!0),children:J(`phone.title`)})]}),(0,Q.jsxs)(`div`,{className:`basics-row`,"data-setting":`basics.alerts`,children:[(0,Q.jsxs)(`span`,{className:`basics-label`,children:[J(`basics.alerts`),(0,Q.jsx)(`span`,{className:`basics-hint`,children:J(`basics.alertsHint`)})]}),o?c?(0,Q.jsx)(`span`,{className:`chip ok`,id:`basics-alerts-on`,children:J(`basics.alertsOn`)}):(0,Q.jsx)(`button`,{type:`button`,className:`b`,id:`basics-alerts`,onClick:a,children:J(`settings.notifications.enable`)}):(0,Q.jsx)(`span`,{className:`basics-hint`,id:`basics-alerts-why`,children:s||J(`settings.notifications.unavailable`)})]}),(0,Q.jsxs)(`label`,{className:`basics-row`,"data-setting":`appearance.theme`,children:[(0,Q.jsx)(`span`,{className:`basics-label`,children:J(`settings.appearance.theme`)}),(0,Q.jsxs)(`select`,{id:`basics-theme`,value:u.theme,onChange:e=>p({theme:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`system`,children:J(`basics.themeSystem`)}),(0,Q.jsx)(`option`,{value:`light`,children:J(`basics.themeLight`)}),(0,Q.jsx)(`option`,{value:`dark`,children:J(`basics.themeDark`)})]})]}),(0,Q.jsxs)(`label`,{className:`basics-row`,"data-setting":`appearance.language`,children:[(0,Q.jsx)(`span`,{className:`basics-label`,children:J(`settings.appearance.language`)}),(0,Q.jsx)(`select`,{id:`basics-language`,value:u.language,onChange:e=>p({language:e.target.value}),children:Qe.filter(e=>e.tag!==`en-XA`).map(e=>(0,Q.jsx)(`option`,{value:e.tag,children:e.tag?e.name:J(`settings.appearance.browserLanguage`)},e.tag))})]}),(0,Q.jsxs)(`label`,{className:`basics-row`,"data-setting":`basics.enter`,children:[(0,Q.jsxs)(`span`,{className:`basics-label`,children:[J(`basics.enter`),(0,Q.jsx)(`span`,{className:`basics-hint`,children:J(`basics.enterHint`)})]}),(0,Q.jsxs)(`select`,{id:`basics-enter`,value:v,onChange:e=>y(e.target.value),children:[(0,Q.jsx)(`option`,{value:`auto`,children:J(`basics.enterAuto`)}),(0,Q.jsx)(`option`,{value:`send`,children:J(`basics.enterSend`)}),(0,Q.jsx)(`option`,{value:`newline`,children:J(`basics.enterNewline`)})]})]}),(0,Q.jsx)(`p`,{className:`subhint basics-more`,children:J(`basics.more`)}),g&&(0,Q.jsx)(ws,{api:e,onNotice:n,onClose:()=>_(!1)})]})}var Es=[`Popular`,`Vendor agents`,`Open source & community`,`ACP adapters`];function Ds(e,t){let n=t.toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return!0;let r=[e.display_name,e.name,e.command,e.vendor||``,e.group||``].join(` `).toLowerCase();return n.every(e=>r.includes(e))}function Os(e,t){let n=new Map;for(let r of e){if(!Ds(r,t))continue;let e=r.group||`Other`;n.has(e)||n.set(e,[]),n.get(e).push(r)}let r=e=>{let t=Es.indexOf(e);return t<0?Es.length:t};return[...n.entries()].sort(([e],[t])=>r(e)-r(t)||e.localeCompare(t)).map(([e,t])=>({group:e,items:[...t].sort((e,t)=>e.display_name.localeCompare(t.display_name))}))}var ks=()=>[[`resume`,J(`agentSettings.catalog.chip.resume`)],[`exact`,J(`agentSettings.catalog.chip.exact`)],[`fork`,J(`agentSettings.catalog.chip.fork`)],[`model`,J(`agentSettings.catalog.chip.model`)],[`yolo`,J(`agentSettings.catalog.chip.yolo`)],[`task`,J(`agentSettings.catalog.chip.task`)],[`acp`,`ACP`],[`mcp`,`MCP`],[`skills`,J(`agentSettings.catalog.chip.skills`)]];function As(e){let t=e.capabilities||{};return ks().flatMap(([e,n])=>{let r=t[e];return r?[{key:e,label:n,available:!!r.available,title:r.reason||(r.available?J(`agentSettings.catalog.supported`,{label:n}):J(`agentSettings.catalog.unavailable`,{label:n}))}]:[]})}function js(e,t){if(e.length===0)return;let n=!1;for(let r of e){if(!r.info_json)continue;let e;try{e=JSON.parse(r.info_json)}catch{continue}if(t in e&&(n=!0,e[t]))return!0}return!n&&void 0}function Ms(e,t){if(!e.trim())return[];let n;try{n=JSON.parse(e)}catch{n=e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean)}if(!Array.isArray(n)||n.some(e=>typeof e!=`string`))throw Error(J(`agentSettings.editor.argsNotArray`,{label:t}));return n}function Ns(e){return Ps(e?.env)}function Ps(e){return Object.entries(e||{}).map(([e,t])=>`${e}=${typeof t==`object`?`••••`:String(t)}`).join(`
-`)}function Fs(e,t={}){let n={...t};for(let t of e.split(/\r?\n/)){if(!t.trim())continue;let e=t.indexOf(`=`);if(e<1)throw Error(J(`agentSettings.editor.envLineFormat`));let r=t.slice(0,e).trim(),i=t.slice(e+1);if(!/^[A-Za-z_][A-Za-z0-9_]*$/.test(r))throw Error(J(`agentSettings.editor.envInvalidName`,{name:r}));i!==`••••`&&i!==`***`&&(i===``?delete n[r]:n[r]=i)}return n}function Is({api:e,source:t,all:n,targets:r,onClose:i,onSaved:a,onNotice:o}){Y();let[s,c]=(0,X.useState)(t?.name||``),[l,u]=(0,X.useState)(t?.command||``),[d,f]=(0,X.useState)(JSON.stringify(t?.args||[],null,2)),[p,m]=(0,X.useState)(t?.model_flag||``),[h,g]=(0,X.useState)(typeof t?.env?.OPENAI_BASE_URL==`string`?t.env.OPENAI_BASE_URL:``),[_,v]=(0,X.useState)(!!t?.prompt_arg),[y,b]=(0,X.useState)(JSON.stringify(t?.prompt_args||[],null,2)),[x,S]=(0,X.useState)(JSON.stringify(t?.resume_args||[],null,2)),[C,w]=(0,X.useState)(JSON.stringify(t?.resume_id_args||[],null,2)),[T,E]=(0,X.useState)(JSON.stringify(t?.fork_args||[],null,2)),[D,k]=(0,X.useState)(t?.models_command||``),[A,j]=(0,X.useState)(t?.trust_command||``),[M,N]=(0,X.useState)(JSON.stringify(t?.yolo_args||[],null,2)),[P,F]=(0,X.useState)(Ps(t?.yolo_env)),[I,L]=(0,X.useState)(Ns(t)),[R,z]=(0,X.useState)(``),[B,V]=(0,X.useState)([]),[H,U]=(0,X.useState)(!!t?.task),[ee,W]=(0,X.useState)(t?.task?.command||``),[te,G]=(0,X.useState)(JSON.stringify(t?.task?.args||[],null,2)),[ne,K]=(0,X.useState)(t?.task?.prompt_template||``),[q,re]=(0,X.useState)(t?.task?.output_mode||`plain`),[ie,ae]=(0,X.useState)(JSON.stringify(t?.task?.permission_args||{},null,2)),[oe,se]=(0,X.useState)(!!t?.acp),[ce,le]=(0,X.useState)(t?.acp?.command||``),[ue,de]=(0,X.useState)(JSON.stringify(t?.acp?.args||[],null,2)),[fe,pe]=(0,X.useState)(Object.entries(t?.acp?.env||{}).map(([e,t])=>`${e}=${typeof t==`object`?`••••`:String(t)}`).join(`
-`)),[me,he]=(0,X.useState)(!1),[ge,_e]=(0,X.useState)(``),[ve,ye]=(0,X.useState)(`custom`);(0,X.useEffect)(()=>{t||e.request(`/agents/catalog`).then(V).catch(()=>V([]))},[]);function be(e){if(e===`custom`)return;let t=B.find(t=>t.name===e);t&&(c(t.name),u(t.command),f(JSON.stringify(t.args||[],null,2)),m(t.model_flag||``),v(!!t.prompt_arg),b(JSON.stringify(t.prompt_args||[],null,2)),F(Ps(t.yolo_env)),S(JSON.stringify(t.resume_args||[],null,2)),w(JSON.stringify(t.resume_id_args||[],null,2)),E(JSON.stringify(t.fork_args||[],null,2)),N(JSON.stringify(t.yolo_args||[],null,2)),k(t.models_command||``),j(t.trust_command||``),L(Object.entries(t.env||{}).map(([e,t])=>`${e}=${String(t)}`).join(`
-`)),t.acp?(se(!0),U(!1),le(t.acp.command||``),de(JSON.stringify(t.acp.args||[],null,2)),pe(Object.entries(t.acp.env||{}).map(([e,t])=>`${e}=${String(t)}`).join(`
-`))):(se(!1),t.task?(U(!0),W(t.task.command||``),G(JSON.stringify(t.task.args||[],null,2)),K(t.task.prompt_template||``),re(t.task.output_mode||`plain`),ae(JSON.stringify(t.task.permission_args||{},null,2))):U(!1)))}js(r||[],`npx`),js(r||[],`gemini`);async function xe(){if(!s.trim()||!l.trim())throw Error(J(`agentSettings.editor.nameCommandRequired`));let r;try{r=JSON.parse(ie||`{}`)}catch{throw Error(J(`agentSettings.editor.permissionsNotJson`))}if(!r||Array.isArray(r)||typeof r!=`object`)throw Error(J(`agentSettings.editor.permissionsNotObject`));let o={...t,name:s.trim(),command:l.trim(),args:Ms(d,J(`agentSettings.editor.fixedArgs`)),model_flag:p.trim(),prompt_arg:_,prompt_args:Ms(y,J(`agentSettings.editor.promptArgsName`)),resume_args:Ms(x,J(`agentSettings.editor.resumeArgsName`)),resume_id_args:Ms(C,J(`agentSettings.editor.resumeIdArgsName`)),fork_args:Ms(T,J(`agentSettings.editor.forkArgsName`)),yolo_args:Ms(M,J(`agentSettings.editor.yoloArgs`)),yolo_env:Fs(P,t?.yolo_env),models_command:D.trim(),trust_command:A.trim(),env:Fs(I,{...t?.env,...h.trim()?{OPENAI_BASE_URL:h.trim()}:{}})};if(delete o.builtin,oe){if(!ce.trim())throw Error(J(`agentSettings.editor.acpCommandRequired`));o.acp={command:ce.trim(),args:Ms(ue,J(`agentSettings.editor.acpArgsName`)),env:Fs(fe,t?.acp?.env)},delete o.task}else delete o.acp,H?o.task={command:ee.trim()||o.command,args:Ms(te,J(`agentSettings.editor.taskArgsName`)),prompt_template:ne.trim(),output_mode:q,permission_args:r}:delete o.task;let c=n.filter(e=>!e.builtin&&e.name!==t?.name).map(e=>{let t={...e};return delete t.builtin,t});he(!0),_e(J(`agentSettings.editor.saving`));try{await e.request(`/agents`,{method:`PUT`,body:[...c,o]}),await a(),i()}catch(e){_e(e instanceof Error?e.message:String(e))}finally{he(!1)}}return(0,Q.jsxs)(O,{className:`agent-settings-dialog`,"aria-label":t?J(`agentSettings.editor.editAgentNamed`,{name:t.name}):J(`agentSettings.editor.addAgent`),onCancel:e=>{me?e.preventDefault():i()},children:[(0,Q.jsx)(`h2`,{children:J(t?`agentSettings.editor.editAgent`:`agentSettings.editor.addAgent`)}),(0,Q.jsx)(`button`,{disabled:me,onClick:i,children:J(`agentSettings.editor.close`)}),!t&&(0,Q.jsxs)(`section`,{className:`agent-catalog`,"aria-label":J(`agentSettings.editor.catalog`),children:[(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.starterTemplate`),(0,Q.jsx)(`input`,{type:`search`,"aria-label":J(`agentSettings.editor.searchCatalog`),placeholder:J(`agentSettings.editor.searchPlaceholder`,{n:B.length||``}),value:R,onChange:e=>z(e.target.value)})]}),(0,Q.jsxs)(`div`,{className:`agent-catalog-list`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`agent-catalog-item agent-catalog-custom`,"aria-pressed":ve===`custom`,onClick:()=>ye(`custom`),children:[(0,Q.jsx)(`span`,{className:`agent-catalog-icon`,"aria-hidden":`true`,children:`+`}),(0,Q.jsxs)(`span`,{className:`agent-catalog-text`,children:[(0,Q.jsx)(`b`,{children:J(`agentSettings.editor.customRunner`)}),(0,Q.jsx)(`span`,{className:`agent-catalog-meta`,children:J(`agentSettings.editor.customRunnerHint`)})]})]}),Os(B,R).map(e=>(0,Q.jsxs)(`div`,{className:`agent-catalog-group`,role:`group`,"aria-label":e.group===`Other`?J(`agentSettings.editor.groupOther`):e.group,children:[(0,Q.jsx)(`h3`,{children:e.group===`Other`?J(`agentSettings.editor.groupOther`):e.group}),e.items.map(e=>{let t=e.name===`claude-code-acp`||e.name===`codex-acp`?`npx`:e.name===`gemini-acp`?`gemini`:``,n=t?js(r||[],t):void 0,i=e.added||(t?n===!1:!1),a=e.added?J(`agentSettings.editor.alreadyAdded`):t&&n===!1?J(`agentSettings.editor.binaryNotDetected`,{binary:t}):e.installed?J(`agentSettings.editor.installedHere`):``;return(0,Q.jsxs)(`button`,{type:`button`,"data-preset":e.name,className:`agent-catalog-item`,"aria-pressed":ve===e.name,disabled:i,onClick:()=>{ye(e.name),be(e.name)},children:[(0,Q.jsx)(`span`,{className:`agent-catalog-icon`,"aria-hidden":`true`,style:e.icon?{background:e.icon.color}:void 0,children:e.icon?.glyph||e.display_name.slice(0,1)}),(0,Q.jsxs)(`span`,{className:`agent-catalog-text`,children:[(0,Q.jsx)(`b`,{children:e.display_name}),(0,Q.jsxs)(`span`,{className:`agent-catalog-meta`,children:[e.vendor?`${e.vendor} · `:``,(0,Q.jsx)(`code`,{children:e.command}),a&&` · ${a}`]}),(0,Q.jsx)(`span`,{className:`agent-catalog-chips`,children:As(e).map(e=>(0,Q.jsx)(`span`,{className:e.available?`agent-cap on`:`agent-cap off`,title:e.title,children:e.available?e.label:J(`agentSettings.editor.capabilityMissing`,{label:e.label})},e.key))})]})]},e.name)})]},e.group)),B.length>0&&Os(B,R).length===0&&(0,Q.jsx)(`p`,{className:`sub`,children:J(`agentSettings.editor.noMatch`,{query:R})})]})]}),!t&&ve!==`custom`&&(()=>{let e=B.find(e=>e.name===ve);return e?(0,Q.jsxs)(`p`,{className:`sub agent-preset-hint`,children:[e.description,e.unverified&&e.unverified.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`b`,{children:J(`agentSettings.editor.unverifiedFields`)}),` `,e.unverified.join(`, `),`.`]}),e.sessions_hint&&(0,Q.jsxs)(Q.Fragment,{children:[` `,J(`agentSettings.editor.sessionIds`),` `,(0,Q.jsx)(`code`,{children:e.sessions_hint}),`.`]}),` `,J(`agentSettings.editor.checkedAgainst`,{date:e.verified_at,by:e.verified_by===`docs`?J(`agentSettings.editor.vendorDocs`):e.verified_by||J(`agentSettings.editor.itsDocs`),source:e.source}),!e.installed&&(0,Q.jsxs)(Q.Fragment,{children:[` `,J(`agentSettings.editor.install`),` `,(0,Q.jsx)(`code`,{children:e.install_hint})]})]}):null})(),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.name`),(0,Q.jsx)(`input`,{value:s,onChange:e=>c(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.command`),(0,Q.jsx)(`input`,{value:l,onChange:e=>u(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.fixedArgs`),(0,Q.jsx)(`textarea`,{value:d,onChange:e=>f(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.modelFlag`),(0,Q.jsx)(`input`,{value:p,onChange:e=>m(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.providerUrl`),(0,Q.jsx)(`input`,{value:h,onChange:e=>g(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:_,onChange:e=>v(e.target.checked)}),` `,J(`agentSettings.editor.promptPositional`)]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.promptArgs`),(0,Q.jsx)(`textarea`,{value:y,onChange:e=>b(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.resumeArgs`),(0,Q.jsx)(`textarea`,{value:x,onChange:e=>S(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.resumeIdArgs`),(0,Q.jsx)(`textarea`,{value:C,onChange:e=>w(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.forkArgs`),(0,Q.jsx)(`textarea`,{value:T,onChange:e=>E(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.modelsCommand`),(0,Q.jsx)(`input`,{value:D,onChange:e=>k(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.trustCommand`),(0,Q.jsx)(`input`,{value:A,onChange:e=>j(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.yoloArgs`),(0,Q.jsx)(`textarea`,{value:M,onChange:e=>N(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.yoloEnv`),(0,Q.jsx)(`textarea`,{value:P,onChange:e=>F(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.environment`),(0,Q.jsx)(`textarea`,{"aria-label":J(`agentSettings.editor.environment`),value:I,onChange:e=>L(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:H,disabled:oe,onChange:e=>U(e.target.checked)}),` `,J(`agentSettings.editor.enableTasks`)]}),oe&&(0,Q.jsx)(`p`,{className:`sub`,children:J(`agentSettings.editor.tasksDisabledByAcp`)}),H&&!oe&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.taskCommand`),(0,Q.jsx)(`input`,{value:ee,onChange:e=>W(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.taskArgs`),(0,Q.jsx)(`textarea`,{"aria-label":J(`agentSettings.editor.taskArgs`),value:te,onChange:e=>G(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.promptTemplate`),(0,Q.jsx)(`input`,{"aria-label":J(`agentSettings.editor.promptTemplate`),value:ne,onChange:e=>K(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.taskOutput`),(0,Q.jsxs)(`select`,{value:q,onChange:e=>re(e.target.value),children:[(0,Q.jsx)(`option`,{value:`plain`,children:J(`agentSettings.editor.outputPlain`)}),(0,Q.jsx)(`option`,{value:`jsonl`,children:J(`agentSettings.editor.outputJsonl`)})]})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.permissionArgs`),(0,Q.jsx)(`textarea`,{value:ie,onChange:e=>ae(e.target.value)})]})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:oe,disabled:H,onChange:e=>se(e.target.checked)}),` `,J(`agentSettings.editor.useAcp`)]}),H&&!oe&&(0,Q.jsx)(`p`,{className:`sub`,children:J(`agentSettings.editor.acpDisabledByTasks`)}),oe&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sub`,children:[J(`agentSettings.editor.acpPermissions`),` `,(0,Q.jsx)(`a`,{href:`https://agentclientprotocol.com`,target:`_blank`,rel:`noreferrer`,children:`agentclientprotocol.com`}),`.`]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.acpCommand`),(0,Q.jsx)(`input`,{"aria-label":J(`agentSettings.editor.acpCommand`),value:ce,onChange:e=>le(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.acpArgs`),(0,Q.jsx)(`textarea`,{"aria-label":J(`agentSettings.editor.acpArgs`),value:ue,onChange:e=>de(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.acpEnvironment`),(0,Q.jsx)(`textarea`,{"aria-label":J(`agentSettings.editor.acpEnvironment`),value:fe,onChange:e=>pe(e.target.value)})]})]}),(0,Q.jsx)(`button`,{disabled:me,onClick:()=>void xe().catch(e=>{let t=e instanceof Error?e.message:String(e);_e(t),o(t,!0)}),children:J(`agentSettings.editor.saveRunner`)}),(0,Q.jsx)(`p`,{className:`agent-dialog-status`,role:`status`,children:ge}),(0,Q.jsx)(`button`,{disabled:me,onClick:i,children:J(`agentSettings.editor.cancel`)})]})}var Ls=[[`claude`,`Claude Code`],[`codex`,`Codex`],[`gemini`,`Gemini CLI`],[`qwen`,`Qwen Code`],[`opencode`,`OpenCode`],[`copilot`,`GitHub Copilot CLI`]];function Rs({api:e,projectId:t,defaultAgent:n,onNotice:r,sourceText:i,onSourceText:a}){Y();let[o,s]=(0,X.useState)(Ls.some(([e])=>e===n)?n:`claude`),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)(()=>J(`agentSettings.skills.loading`)),[v,y]=(0,X.useState)(``),b=(0,X.useRef)(0);async function x(){let n=++b.current;h(!0);try{let[r,i]=await Promise.all([e.request(`/skills?project_id=${t}&agent=${encodeURIComponent(o)}`),e.request(`/projects/${t}/skills?agent=${encodeURIComponent(o)}`)]);if(n!==b.current)return;l(r.skills||[]),d(i.attachments||[]);let a=(r.skills||[]).filter(e=>!e.id.startsWith(`lectern-workflow/`)&&e.source!==`lectern-bundled`),s=(i.attachments||[]).filter(e=>!e.source_id?.startsWith(`lectern-bundled/`));_(J(`agentSettings.skills.summary`,{available:a.length,attached:s.length}))}catch(e){if(n!==b.current)return;_(e instanceof Error?e.message:String(e)),r(String(e),!0)}finally{h(!1)}}(0,X.useEffect)(()=>{x()},[o,t]);async function S(n){h(!0);try{await e.request(`/projects/${t}/skills`,{method:`POST`,body:{agent:o,skill_id:n}}),await x(),_(J(`agentSettings.skills.attachedStatus`))}catch(e){let t=e instanceof Error?e.message:String(e);_(t.includes(`destination already exists`)?J(`agentSettings.skills.destinationOccupied`,{message:t}):t),r(String(e),!0),h(!1)}}async function C(n){h(!0);try{await e.request(`/projects/${t}/skills/${n}`,{method:`DELETE`}),await x(),_(J(`agentSettings.skills.detachedStatus`))}catch(e){r(String(e),!0),h(!1)}}let w=u.filter(e=>!e.source_id?.startsWith(`lectern-bundled/`)),T=new Set(w.map(e=>e.skill_id));return(0,Q.jsxs)(`section`,{className:`project-skills`,"data-setting":`projects.skills`,children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.skills.title`)}),(0,Q.jsx)(`p`,{children:J(`agentSettings.skills.intro`)}),(0,Q.jsx)(`p`,{className:`skills-status`,role:`status`,children:g}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.skills.provider`),(0,Q.jsx)(`select`,{className:`skills-agent`,"aria-label":J(`agentSettings.skills.providerLabel`),value:o,onChange:e=>s(e.target.value),children:Ls.map(([e,t])=>(0,Q.jsx)(`option`,{value:e,children:t},e))})]}),(0,Q.jsx)(`button`,{className:`skills-reload`,disabled:m,onClick:()=>void x(),children:J(`agentSettings.skills.reload`)}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.skills.searchCatalog`),(0,Q.jsx)(`input`,{className:`skills-search`,value:f,onChange:e=>p(e.target.value),placeholder:J(`agentSettings.skills.searchPlaceholder`)})]}),(0,Q.jsx)(`h5`,{children:J(`agentSettings.skills.attachedHeading`)}),!w.length&&(0,Q.jsx)(`p`,{children:J(`agentSettings.skills.noneAttached`)}),w.map(e=>(0,Q.jsxs)(`div`,{className:`attached-skill`,children:[(0,Q.jsx)(`b`,{children:e.entry_name||e.skill_id}),(0,Q.jsxs)(`small`,{children:[e.source_id,` · `,e.skill_id]}),(0,Q.jsx)(`button`,{className:`skill-detach`,disabled:m,onClick:()=>void C(e.id),children:J(`agentSettings.skills.detach`)})]},e.id)),(0,Q.jsx)(`h5`,{children:J(`agentSettings.skills.available`)}),c.filter(e=>!f||`${e.name} ${e.entry_name} ${e.source} ${e.description} ${e.id}`.toLowerCase().includes(f.toLowerCase())).map(e=>(0,Q.jsxs)(`div`,{className:`catalog-skill`,children:[(0,Q.jsx)(`b`,{children:e.name||e.entry_name||e.id}),(0,Q.jsxs)(`small`,{children:[e.source,` · `,e.description]}),(0,Q.jsx)(`button`,{className:`skill-attach`,disabled:m||T.has(e.id),onClick:()=>void S(e.id),children:T.has(e.id)?J(`agentSettings.skills.attachedButton`):J(`agentSettings.skills.attach`)})]},e.id)),(0,Q.jsxs)(`details`,{className:`skills-sources`,children:[(0,Q.jsx)(`summary`,{children:J(`agentSettings.skills.sourceDirs`)}),(0,Q.jsx)(`textarea`,{className:`skills-source-input`,"aria-label":J(`agentSettings.skills.sourceDirs`),value:i,onChange:e=>{a(e.target.value),y(J(`agentSettings.skills.unsavedDirs`))}}),(0,Q.jsx)(`button`,{className:`skills-source-clear`,onClick:()=>{a(``),y(J(`agentSettings.skills.unsavedDirs`))},children:J(`agentSettings.skills.clear`)}),(0,Q.jsx)(`button`,{className:`skills-source-save`,onClick:()=>void e.request(`/projects/${t}`,{method:`PATCH`,body:{skill_sources:i.split(`
-`).map(e=>e.trim()).filter(Boolean)}}).then(()=>y(J(`agentSettings.skills.dirsSaved`))).catch(e=>y(e instanceof Error?e.message:String(e))),children:J(`agentSettings.skills.saveDirs`)}),(0,Q.jsx)(`p`,{className:`skills-source-status`,role:`status`,children:v})]})]})}var zs=e=>e===`codex`?`Codex`:`Claude Code`,Bs=(e,t)=>e.startsWith(`/`)||e.startsWith(`$`)?e:`${t===`codex`?`$`:`/`}${e}`;function Vs({api:e,projectId:t,defaultAgent:n,onNotice:r}){Y();let[i,a]=(0,X.useState)(n===`codex`?`codex`:`claude`),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(()=>J(`agentSettings.workflows.loading`)),m=(0,X.useRef)(0),h=(0,X.useRef)(!0);(0,X.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);async function g(){let n=++m.current;l(!0),d(!1),p(J(`agentSettings.workflows.loading`));try{let r=await e.request(`/projects/${t}/workflows?agent=${encodeURIComponent(i)}`);if(!h.current||n!==m.current)return;let a=Array.isArray(r.workflows)?r.workflows:[];s(a),p(J(`agentSettings.workflows.available`,{count:a.length,provider:zs(i)}))}catch(e){if(!h.current||n!==m.current)return;let t=e instanceof Error?e.message:String(e);s([]),d(!0),p(t),r(t,!0)}finally{h.current&&n===m.current&&l(!1)}}(0,X.useEffect)(()=>{g()},[i,t]);async function _(n){let a=m.current;l(!0);try{let r=await e.request(`/projects/${t}/workflows/${encodeURIComponent(n.id)}`,{method:`PUT`,body:{agent:i,enabled:!n.enabled}});h.current&&a===m.current&&(s(e=>e.map(e=>e.id===n.id?{...e,enabled:!!r.enabled}:e)),p(r.enabled?J(`agentSettings.workflows.enabledStatus`,{name:n.name,provider:zs(i)}):J(`agentSettings.workflows.disabledStatus`,{name:n.name,provider:zs(i)})))}catch(e){let t=e instanceof Error?e.message:String(e);h.current&&a===m.current&&(p(t),r(t,!0))}finally{h.current&&a===m.current&&l(!1)}}return(0,Q.jsxs)(`section`,{className:`project-workflows`,"data-setting":`projects.workflows`,children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.workflows.title`)}),(0,Q.jsx)(`p`,{children:J(`agentSettings.workflows.intro`)}),(0,Q.jsx)(`p`,{className:`workflows-status`,role:`status`,children:f}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.skills.provider`),(0,Q.jsxs)(`select`,{className:`workflows-agent`,"aria-label":J(`agentSettings.workflows.providerLabel`),value:i,disabled:c,onChange:e=>a(e.target.value),children:[(0,Q.jsx)(`option`,{value:`claude`,children:`Claude Code`}),(0,Q.jsx)(`option`,{value:`codex`,children:`Codex`})]})]}),(0,Q.jsx)(`button`,{className:`workflows-reload`,disabled:c,onClick:()=>void g(),children:J(c?`agentSettings.workflows.loadingShort`:u?`agentSettings.workflows.retry`:`agentSettings.skills.reload`)}),!o.length&&!c&&(0,Q.jsx)(`p`,{children:J(`agentSettings.workflows.none`)}),o.map(e=>(0,Q.jsxs)(`article`,{className:`workflow-card`,children:[(0,Q.jsxs)(`div`,{className:`workflow-card-copy`,children:[(0,Q.jsx)(`h5`,{children:e.name}),(0,Q.jsx)(`p`,{children:e.description}),(0,Q.jsxs)(`p`,{className:`workflow-version`,children:[J(`agentSettings.workflows.pinnedVersion`),` `,(0,Q.jsx)(`code`,{children:e.version}),` · `,(0,Q.jsx)(`a`,{href:e.upstream_url,target:`_blank`,rel:`noreferrer`,children:J(`agentSettings.workflows.upstream`)})]})]}),(0,Q.jsx)(`button`,{className:`workflow-toggle`,"aria-label":e.enabled?J(`agentSettings.workflows.disableNamed`,{name:e.name}):J(`agentSettings.workflows.enableNamed`,{name:e.name}),disabled:c,onClick:()=>void _(e),children:e.enabled?J(`agentSettings.workflows.enabled`):J(`agentSettings.workflows.enable`)}),e.enabled&&(0,Q.jsxs)(`div`,{className:`workflow-commands`,children:[(0,Q.jsx)(`b`,{children:J(`agentSettings.workflows.commands`)}),(0,Q.jsx)(`ul`,{children:e.commands.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{children:Bs(e,i)})},e))}),(0,Q.jsx)(`p`,{className:`workflow-reload-note`,children:J(`agentSettings.workflows.reloadNote`,{provider:zs(i)})})]})]},e.id))]})}var Hs=`lectern.agent-catalog`,Us=[`agents`,`mcp_servers`,`skills`,`workflows`,`hooks`,`sandbox_providers`,`quick_commands`,`themes`,`palette_commands`],Ws=e=>e?e.slice(0,12):``,Gs=e=>e instanceof Error?e.message:String(e);function Ks({counts:e}){let t=Us.filter(t=>e?.[t]);return t.length?(0,Q.jsx)(Q.Fragment,{children:t.map(t=>(0,Q.jsxs)(`span`,{className:`plugin-chip`,children:[J(`plugins.kind.`+t),` `,e[t]]},t))}):(0,Q.jsx)(`span`,{className:`plugin-chip`,children:J(`plugins.contributesNothing`)})}function qs({capabilities:e,grown:t=[]}){if(!e.length)return(0,Q.jsx)(`p`,{className:`plugin-caps-none`,children:J(`plugins.cap.none`)});let n=(e,n)=>t.includes(n?`${e}: ${n}`:e);return(0,Q.jsx)(`ul`,{className:`plugin-caps`,children:e.map(e=>(0,Q.jsxs)(`li`,{"data-cap":e.key,className:e.key===`host_exec`||e.key===`target_exec`?`risky`:void 0,children:[(0,Q.jsx)(`b`,{children:J(`plugins.cap.`+e.key)}),n(e.key)&&(0,Q.jsx)(`span`,{className:`plugin-new`,children:J(`plugins.new`)}),!!e.detail?.length&&(0,Q.jsx)(`ul`,{children:e.detail.map(t=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`code`,{children:t}),n(e.key,t)&&(0,Q.jsx)(`span`,{className:`plugin-new`,children:J(`plugins.new`)})]},t))})]},e.key))})}function Js({preview:e,mode:t,busy:n,onConsent:r,onClose:i}){let[a,o]=(0,X.useState)(!1),s=e.manifest,c=J(t===`install`?`plugins.consent.installTitle`:t===`update`?`plugins.consent.updateTitle`:`plugins.consent.trustTitle`,{name:s.name}),l=e.source.url||e.source.path||``;return(0,Q.jsxs)(O,{id:`plugin-consent`,className:`plugin-consent`,"aria-labelledby":`plugin-consent-title`,onCancel:e=>{e.preventDefault(),i()},children:[(0,Q.jsxs)(`header`,{className:`plugin-consent-head`,children:[(0,Q.jsx)(`h3`,{id:`plugin-consent-title`,children:c}),(0,Q.jsx)(`button`,{type:`button`,className:`x`,"aria-label":J(`settings.common.close`),"data-close":!0,onClick:i,children:`×`})]}),(0,Q.jsxs)(`div`,{className:`plugin-consent-body`,children:[(0,Q.jsxs)(`p`,{className:`plugin-consent-id`,children:[(0,Q.jsx)(`code`,{children:s.id}),` `,e.from_version?J(`plugins.consent.versionChange`,{from:e.from_version,to:s.version}):s.version,s.author&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,s.author]})]}),s.description&&(0,Q.jsx)(`p`,{children:s.description}),(0,Q.jsxs)(`dl`,{className:`plugin-facts`,children:[l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{children:J(`plugins.source`)}),(0,Q.jsxs)(`dd`,{children:[(0,Q.jsx)(`code`,{children:l}),e.source.ref&&(0,Q.jsxs)(Q.Fragment,{children:[` @ `,(0,Q.jsx)(`code`,{children:e.source.ref})]})]})]}),e.source.index&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{children:J(`plugins.fromSource`)}),(0,Q.jsx)(`dd`,{children:e.source.index})]}),e.commit&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{children:J(`plugins.commit`)}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(`code`,{children:Ws(e.commit)})})]}),(0,Q.jsx)(`dt`,{children:J(`plugins.contentHash`)}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(`code`,{children:Ws(e.hash)})})]}),(0,Q.jsx)(`h4`,{children:J(`plugins.contributes`)}),(0,Q.jsx)(`p`,{className:`plugin-chips`,children:(0,Q.jsx)(Ks,{counts:e.contributions})}),(0,Q.jsx)(`h4`,{children:J(`plugins.consent.capabilities`)}),(0,Q.jsx)(qs,{capabilities:e.capabilities,grown:e.grown}),!!e.grown?.length&&(0,Q.jsx)(`p`,{className:`plugin-warning`,role:`note`,children:J(`plugins.consent.grown`,{count:e.grown.length})}),e.format===`claude`&&(0,Q.jsx)(`p`,{className:`plugin-note`,children:J(`plugins.consent.claude`)}),!!e.skipped?.length&&(0,Q.jsx)(`p`,{className:`plugin-note`,children:J(`plugins.consent.skipped`,{items:e.skipped.join(`, `)})}),e.unchanged?(0,Q.jsx)(`p`,{className:`plugin-note`,role:`status`,children:J(`plugins.consent.unchanged`)}):(0,Q.jsxs)(`label`,{className:`plugin-allow`,children:[(0,Q.jsx)(`input`,{id:`plugin-consent-check`,type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),e.capabilities.length?J(`plugins.consent.allow`):J(`plugins.consent.allowNone`)]})]}),(0,Q.jsxs)(`div`,{className:`btnrow plugin-consent-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`b`,onClick:i,children:J(`plugins.cancel`)}),!e.unchanged&&(0,Q.jsx)(`button`,{id:`plugin-consent-install`,type:`button`,className:`b primary`,disabled:!a||n,onClick:r,children:J(t===`install`?`plugins.consent.install`:t===`update`?`plugins.consent.update`:`plugins.consent.trust`)})]})]})}function Ys({plugin:e,projects:t,onSave:n}){let[r,i]=(0,X.useState)(e.project_ids||[]),[a,o]=(0,X.useState)((e.project_ids||[]).length>0);return(0,X.useEffect)(()=>{i(e.project_ids||[]),o((e.project_ids||[]).length>0)},[e.project_ids?.join(`,`)]),(0,Q.jsxs)(`fieldset`,{className:`plugin-scope`,children:[(0,Q.jsx)(`legend`,{children:J(`plugins.scope`)}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`radio`,name:`scope-`+e.id,checked:!a,onChange:()=>o(!1)}),` `,J(`plugins.scope.everywhere`)]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`radio`,name:`scope-`+e.id,checked:a,onChange:()=>o(!0)}),` `,J(`plugins.scope.chosen`)]}),a&&(0,Q.jsx)(`div`,{className:`plugin-scope-projects`,children:t.map(e=>(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:r.includes(e.id),onChange:t=>i(t.target.checked?[...r,e.id]:r.filter(t=>t!==e.id))}),e.name]},e.id))}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`plugins.scope.hint`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,disabled:a&&!r.length,onClick:()=>n(a?r:[]),children:J(`plugins.scope.save`)})]})}function Xs({plugin:e,onSave:t}){let[n,r]=(0,X.useState)({});return e.secrets?.length?(0,Q.jsxs)(`fieldset`,{className:`plugin-secrets`,children:[(0,Q.jsx)(`legend`,{children:J(`plugins.secrets`)}),e.secrets.map(i=>(0,Q.jsxs)(`label`,{children:[(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`code`,{children:i}),` `,e.secrets_set?.includes(i)?J(`plugins.secrets.set`):J(`plugins.secrets.unset`)]}),(0,Q.jsxs)(`span`,{className:`plugin-secret-row`,children:[(0,Q.jsx)(`input`,{type:`password`,autoComplete:`off`,"aria-label":J(`plugins.secrets.value`,{name:i}),value:n[i]||``,onChange:e=>r({...n,[i]:e.target.value})}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,onClick:()=>{t(i,n[i]||``),r({...n,[i]:``})},children:n[i]?J(`plugins.secrets.save`):J(`plugins.secrets.clear`)})]})]},i))]}):null}function Zs({api:e,id:t,projects:n,onChanged:r,onNotice:i}){let[a,o]=(0,X.useState)(null),s=()=>e.request(`/plugins/${encodeURIComponent(t)}`).then(o).catch(e=>i(Gs(e),!0));if((0,X.useEffect)(()=>void s(),[t]),!a)return(0,Q.jsx)(`p`,{className:`plugin-loading`,children:J(`plugins.loading`)});let c=a.detail||{},l=async(n,a,o)=>{try{await e.request(`/plugins/${encodeURIComponent(t)}${n}`,{method:`PUT`,body:a}),i(o),await s(),r()}catch(e){i(Gs(e),!0)}},u=(e,t)=>t.length>0&&(0,Q.jsxs)(`div`,{className:`plugin-detail-row`,children:[(0,Q.jsx)(`b`,{children:J(`plugins.kind.`+e)}),(0,Q.jsx)(`span`,{children:t.join(`, `)})]},e);return(0,Q.jsxs)(`div`,{className:`plugin-detail`,children:[(0,Q.jsx)(`h4`,{children:J(`plugins.consent.capabilities`)}),(0,Q.jsx)(qs,{capabilities:a.capabilities||[]}),(0,Q.jsx)(`h4`,{children:J(`plugins.contributes`)}),u(`agents`,[...c.agents||[],...a.agents_more?[J(`plugins.more`,{count:a.agents_more})]:[]]),u(`mcp_servers`,c.mcp_servers||[]),u(`skills`,(c.skills||[]).map(e=>e.id)),u(`workflows`,(c.workflows||[]).map(e=>e.name)),u(`hooks`,(c.hooks||[]).map(e=>`${e.event} (${e.run===`host`?J(`plugins.hook.host`):J(`plugins.hook.target`)})`)),u(`sandbox_providers`,(c.sandbox_providers||[]).map(e=>e.name)),u(`quick_commands`,(c.quick_commands||[]).map(e=>e.label||e.text)),u(`themes`,(c.themes||[]).map(e=>e.name)),u(`palette_commands`,(c.palette_commands||[]).map(e=>e.title)),!a.bundled&&a.source&&(0,Q.jsxs)(`dl`,{className:`plugin-facts`,children:[(0,Q.jsx)(`dt`,{children:J(`plugins.source`)}),(0,Q.jsxs)(`dd`,{children:[(0,Q.jsx)(`code`,{children:a.source.source}),a.source.ref&&(0,Q.jsxs)(Q.Fragment,{children:[` @ `,(0,Q.jsx)(`code`,{children:a.source.ref})]})]}),a.source.commit&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{children:J(`plugins.commit`)}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(`code`,{children:Ws(a.source.commit)})})]}),(0,Q.jsx)(`dt`,{children:J(`plugins.contentHash`)}),(0,Q.jsx)(`dd`,{children:(0,Q.jsx)(`code`,{children:Ws(a.content_hash)})}),a.consented_by&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{children:J(`plugins.consentedBy`)}),(0,Q.jsx)(`dd`,{children:a.consented_by})]})]}),(0,Q.jsx)(Ys,{plugin:a,projects:n,onSave:e=>void l(``,{project_ids:e},J(`plugins.scope.saved`))}),(0,Q.jsx)(Xs,{plugin:a,onSave:(e,t)=>void l(`/secrets`,{[e]:t},J(`plugins.secrets.saved`))}),!!a.hook_runs?.length&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h4`,{children:J(`plugins.hookRuns`)}),(0,Q.jsx)(`ul`,{className:`plugin-runs`,children:a.hook_runs.map(e=>(0,Q.jsxs)(`li`,{className:e.ok?`ok`:`failed`,children:[(0,Q.jsx)(`b`,{children:e.event}),` `,e.ok?J(`plugins.hookRun.ok`):J(`plugins.hookRun.failed`),` · `,e.duration_ms,` ms`,(e.message||e.error)&&(0,Q.jsx)(`div`,{className:`plugin-run-msg`,children:e.message||e.error})]},e.id))})]})]})}function Qs({api:e,projects:t,onNotice:n}){Y();let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)({agents:[],mcp_servers:[]}),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(`git`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)([]),[T,E]=(0,X.useState)([]),[D,O]=(0,X.useState)([]),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(``),[N,P]=(0,X.useState)(``);async function I(){try{let t=await e.request(`/plugins`);i(t.plugins||[]),o(t.local||{agents:[],mcp_servers:[]});let n=await e.request(`/plugin-sources`);w(n.sources||[])}catch(e){n(Gs(e),!0)}finally{c(!0)}}(0,X.useEffect)(()=>void I(),[]);async function L(){await I(),F().catch(()=>{})}async function R(e,t){b(!0);try{v({data:await e(),mode:t})}catch(e){n(Gs(e),!0)}finally{b(!1)}}let z=t=>R(()=>e.request(`/plugins/preview`,{method:`POST`,body:t}),`install`);async function B(){if(_){b(!0);try{await e.request(`/plugins/install`,{method:`POST`,body:{hash:_.data.hash,accept:_.data.accept}}),n(_.mode===`install`?J(`plugins.installed`,{name:_.data.manifest.name}):J(`plugins.updated`,{name:_.data.manifest.name})),v(null),await L()}catch(e){n(Gs(e),!0)}finally{b(!1)}}}async function V(t){let n=[];t.id===Hs&&n.push(J(`plugins.disableCatalog`));let r=(await e.request(`/plugins/${encodeURIComponent(t.id)}`)).attachments||[];if(r.length){n.push(J(`plugins.disableDetach`));for(let e of r)n.push(`• `+J(`plugins.detachItem`,{name:e.name,project:e.project,agent:e.agent}))}return n}function H(e){e.detach_problems?.length&&n(J(`plugins.detachProblems`,{items:e.detach_problems.join(`; `)}),!0)}async function U(t){try{if(t.enabled){let e=await V(t);if(e.length&&!window.confirm([J(`plugins.disableConfirm`,{name:t.name}),``,...e].join(`
-`)))return}let r=await e.request(`/plugins/${encodeURIComponent(t.id)}`,{method:`PUT`,body:{enabled:!t.enabled}});n(t.enabled?J(`plugins.disabledNotice`,{name:t.name}):J(`plugins.enabledNotice`,{name:t.name})),H(r),await L()}catch(e){n(Gs(e),!0)}}async function ee(t){try{let r=await V(t);if(!window.confirm([J(`plugins.removeConfirm`,{name:t.name}),...r.length?[``,...r]:[]].join(`
-`)))return;let i=await e.request(`/plugins/${encodeURIComponent(t.id)}`,{method:`DELETE`});n(J(`plugins.removed`,{name:t.name})),H(i),await L()}catch(e){n(Gs(e),!0)}}async function W(){b(!0);try{let t=await e.request(`/plugins/search?q=${encodeURIComponent(k)}&refresh=1`);E(t.plugins||[]),O(t.problems||[])}catch(e){n(Gs(e),!0)}finally{b(!1)}}async function te(){b(!0);try{await e.request(`/plugin-sources`,{method:`POST`,body:{name:j.trim(),url:N.trim()}}),M(``),P(``),n(J(`plugins.sources.added`)),await I()}catch(e){n(Gs(e),!0)}finally{b(!1)}}let G=e=>J(`plugins.status.`+e.status);return(0,Q.jsxs)(`section`,{className:`plugins-page`,"aria-labelledby":`plugins-heading`,children:[(0,Q.jsx)(`h3`,{id:`plugins-heading`,"data-setting":`plugins.installed`,children:J(`plugins.title`)}),(0,Q.jsx)(`p`,{className:`plugins-intro`,children:J(`plugins.intro`)}),(0,Q.jsxs)(`div`,{className:`rowcard plugin-add`,"data-setting":`plugins.add`,children:[(0,Q.jsx)(`h4`,{children:J(`plugins.add.title`)}),(0,Q.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":J(`plugins.add.from`),children:[`git`,`path`,`source`].map(e=>(0,Q.jsxs)(`label`,{className:l===e?`on`:``,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`plugin-add-kind`,value:e,checked:l===e,onChange:()=>u(e)}),J(`plugins.add.kind.`+e)]},e))}),l===`git`&&(0,Q.jsxs)(`form`,{className:`plugin-add-form`,onSubmit:e=>{e.preventDefault(),z({kind:`git`,url:p.trim(),ref:h.trim()})},children:[(0,Q.jsxs)(`label`,{children:[J(`plugins.add.gitURL`),(0,Q.jsx)(`input`,{id:`plugin-git-url`,inputMode:`url`,autoCapitalize:`off`,spellCheck:!1,placeholder:`https://github.com/owner/plugin.git`,value:p,onChange:e=>m(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`plugins.add.ref`),(0,Q.jsx)(`input`,{id:`plugin-git-ref`,autoCapitalize:`off`,spellCheck:!1,placeholder:`main`,value:h,onChange:e=>g(e.target.value)})]}),(0,Q.jsx)(`button`,{className:`b`,id:`plugin-preview-git`,disabled:y||!p.trim(),children:J(`plugins.add.preview`)})]}),l===`path`&&(0,Q.jsxs)(`form`,{className:`plugin-add-form`,onSubmit:e=>{e.preventDefault(),z({kind:`path`,path:d.trim()})},children:[(0,Q.jsxs)(`label`,{children:[J(`plugins.add.path`),(0,Q.jsx)(`input`,{id:`plugin-path`,autoCapitalize:`off`,spellCheck:!1,placeholder:`/home/you/my-plugin`,value:d,onChange:e=>f(e.target.value)})]}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`plugins.add.pathHint`)}),(0,Q.jsx)(`button`,{className:`b`,id:`plugin-preview-path`,disabled:y||!d.trim(),children:J(`plugins.add.preview`)})]}),l===`source`&&(0,Q.jsxs)(`div`,{className:`plugin-available`,"data-setting":`plugins.sources`,children:[!C.length&&(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`plugins.sources.none`)}),(0,Q.jsxs)(`form`,{className:`plugin-search`,onSubmit:e=>{e.preventDefault(),W()},children:[(0,Q.jsx)(`input`,{id:`plugin-search`,type:`search`,"aria-label":J(`plugins.sources.search`),placeholder:J(`plugins.sources.search`),value:k,onChange:e=>A(e.target.value)}),(0,Q.jsx)(`button`,{className:`b`,disabled:y||!C.length,children:J(`plugins.sources.searchButton`)})]}),D.map(e=>(0,Q.jsx)(`p`,{className:`plugin-warning`,children:e},e)),T.map(e=>(0,Q.jsxs)(`div`,{className:`plugin-listing`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`b`,{children:e.name||e.id}),` `,(0,Q.jsx)(`code`,{children:e.id}),` `,e.version,e.description&&(0,Q.jsx)(`div`,{className:`plugin-desc`,children:e.description}),(0,Q.jsx)(`div`,{className:`plugin-desc`,children:J(`plugins.sources.listedIn`,{source:e.index,commit:Ws(e.commit)})})]}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,disabled:y,onClick:()=>void z({kind:`index`,id:e.id,index:e.index}),children:e.installed?J(`plugins.sources.reinstall`):J(`plugins.add.preview`)})]},e.index+e.id)),(0,Q.jsx)(`h4`,{children:J(`plugins.sources.title`)}),(0,Q.jsx)(`ul`,{className:`plugin-sources`,children:C.map(t=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`b`,{children:t.name}),` `,(0,Q.jsx)(`code`,{children:t.url}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,"aria-label":J(`plugins.sources.remove`,{name:t.name}),onClick:()=>void e.request(`/plugin-sources/${encodeURIComponent(t.name)}`,{method:`DELETE`}).then(I,e=>n(Gs(e),!0)),children:J(`plugins.remove`)})]},t.name))}),(0,Q.jsxs)(`form`,{className:`plugin-add-form`,onSubmit:e=>{e.preventDefault(),te()},children:[(0,Q.jsxs)(`label`,{children:[J(`plugins.sources.name`),(0,Q.jsx)(`input`,{id:`plugin-source-name`,autoCapitalize:`off`,spellCheck:!1,value:j,onChange:e=>M(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`plugins.sources.url`),(0,Q.jsx)(`input`,{id:`plugin-source-url`,inputMode:`url`,autoCapitalize:`off`,spellCheck:!1,placeholder:`https://github.com/owner/marketplace.git`,value:N,onChange:e=>P(e.target.value)})]}),(0,Q.jsx)(`button`,{className:`b`,disabled:y||!j.trim()||!N.trim(),children:J(`plugins.sources.add`)})]})]})]}),!s&&(0,Q.jsx)(`p`,{className:`plugin-loading`,children:J(`plugins.loading`)}),(0,Q.jsx)(`div`,{className:`plugin-list`,children:r.map(r=>(0,Q.jsxs)(`article`,{className:`rowcard plugin-card status-`+r.status,"data-plugin":r.id,children:[(0,Q.jsxs)(`header`,{className:`plugin-card-head`,children:[(0,Q.jsx)(`h4`,{children:r.name}),r.version&&(0,Q.jsx)(`span`,{className:`plugin-version`,children:r.version}),r.bundled&&(0,Q.jsx)(`span`,{className:`plugin-badge`,children:J(`plugins.bundled`)}),(0,Q.jsx)(`span`,{className:`plugin-status `+r.status,children:G(r)})]}),r.description&&(0,Q.jsx)(`p`,{className:`plugin-desc`,children:r.description}),r.problem&&(0,Q.jsx)(`p`,{className:`plugin-warning`,children:r.problem}),(0,Q.jsxs)(`p`,{className:`plugin-chips`,children:[(0,Q.jsx)(Ks,{counts:r.contributions}),r.project_ids?.length?(0,Q.jsx)(`span`,{className:`plugin-chip scope`,children:J(`plugins.scope.projects`,{count:r.project_ids.length})}):null]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`b`,"aria-expanded":x===r.id,onClick:()=>S(x===r.id?null:r.id),children:x===r.id?J(`plugins.hideDetails`):J(`plugins.details`)}),(r.status===`active`||r.status===`disabled`)&&(0,Q.jsx)(`button`,{type:`button`,className:`b plugin-toggle`,"aria-pressed":r.enabled,onClick:()=>void U(r),children:r.enabled?J(`plugins.disable`):J(`plugins.enable`)}),r.status===`modified`&&(0,Q.jsx)(`button`,{type:`button`,className:`b plugin-trust`,disabled:y,onClick:()=>void R(()=>e.request(`/plugins/${encodeURIComponent(r.id)}/trust`,{method:`POST`}),`trust`),children:J(`plugins.trustAgain`)}),!r.bundled&&(0,Q.jsx)(`button`,{type:`button`,className:`b plugin-update`,disabled:y,onClick:()=>void R(()=>e.request(`/plugins/${encodeURIComponent(r.id)}/update`,{method:`POST`,body:{}}),`update`),children:J(`plugins.update`)}),!r.bundled&&(0,Q.jsx)(`button`,{type:`button`,className:`b plugin-remove`,onClick:()=>void ee(r),children:J(`plugins.remove`)})]}),x===r.id&&(0,Q.jsx)(Zs,{api:e,id:r.id,projects:t,onChanged:()=>void L(),onNotice:n})]},r.id))}),(0,Q.jsxs)(`div`,{className:`rowcard plugin-local`,"data-setting":`plugins.local`,children:[(0,Q.jsx)(`h4`,{children:J(`plugins.local.title`)}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`plugins.local.intro`)}),!a.agents.length&&!a.mcp_servers.length&&(0,Q.jsx)(`p`,{className:`plugin-desc`,children:J(`plugins.local.none`)}),!!a.agents.length&&(0,Q.jsxs)(`div`,{className:`plugin-detail-row`,children:[(0,Q.jsx)(`b`,{children:J(`plugins.local.agents`)}),(0,Q.jsx)(`span`,{children:a.agents.join(`, `)})]}),a.mcp_servers.map(e=>(0,Q.jsxs)(`div`,{className:`plugin-detail-row`,children:[(0,Q.jsx)(`b`,{children:J(`plugins.local.mcp`,{project:e.project})}),(0,Q.jsx)(`span`,{children:e.servers.join(`, `)})]},e.project_id))]}),_&&(0,Q.jsx)(Js,{preview:_.data,mode:_.mode,busy:y,onConsent:()=>void B(),onClose:()=>v(null)})]})}var $s={github:`GitHub`,slack:`Slack`,linear:`Linear`,jira:`Jira`},ec={github:JSON.stringify({repo:`owner/repo`,label:`lectern`,mention_handle:`@lectern`,allowed_authors:[]},null,2),slack:JSON.stringify({channel:``,allowed_users:[]},null,2),linear:JSON.stringify({team_key:`ENG`,label:`lectern`,allowed_users:[]},null,2),jira:JSON.stringify({base_url:`https://yourteam.atlassian.net`,email:`you@example.com`,project_key:`OPS`,label:`lectern`,allowed_users:[],done_transition:`Done`},null,2)},tc={github:`{}`,slack:JSON.stringify({app_token:``,bot_token:``},null,2),linear:JSON.stringify({api_key:``},null,2),jira:JSON.stringify({token:``},null,2)},nc=()=>({linear:{key:`api_key`,label:J(`agentSettings.triggers.linearApiKey`)},jira:{key:`token`,label:J(`agentSettings.triggers.jiraToken`)}});function rc(e){if(!e)return J(`agentSettings.triggers.never`);let t=Date.now()/1e3-e;return t<60?J(`agentSettings.triggers.justNow`):t<3600?J(`agentSettings.triggers.minutesAgo`,{n:Math.floor(t/60)}):t<86400?J(`agentSettings.triggers.hoursAgo`,{n:Math.floor(t/3600)}):J(`agentSettings.triggers.daysAgo`,{n:Math.floor(t/86400)})}function ic({api:e,projectId:t,onNotice:n}){Y();let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)([]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(`github`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)({}),[h,g]=(0,X.useState)({}),[_,v]=(0,X.useState)({});async function y(){try{let[n,r]=await Promise.all([e.request(`/projects/${t}/triggers`),e.request(`/projects/${t}/trigger-events`)]);i(n),o(r)}catch(e){n(J(`agentSettings.triggers.loadFailed`,{message:e.message}),!0)}}(0,X.useEffect)(()=>{y()},[t]);function b(e){return _[e.id]||{name:e.name,config:JSON.stringify(e.config,null,2),secrets:tc[e.kind],interval:String(e.interval_s)}}let x=nc();async function S(){c(!0);try{await e.request(`/projects/${t}/triggers`,{method:`POST`,body:{kind:l,name:$s[l],config:JSON.parse(ec[l]),secrets:x[l]&&d.trim()?{[x[l].key]:d.trim()}:{}}}),f(``),n(J(`agentSettings.triggers.added`,{kind:$s[l]})),await y()}catch(e){n(e.message,!0)}finally{c(!1)}}async function C(t){try{await e.request(`/triggers/${t.id}`,{method:`PATCH`,body:{enabled:!t.enabled}}),await y()}catch(e){n(e.message,!0)}}async function w(t){let r=b(t),i,a;try{i=JSON.parse(r.config)}catch{n(J(`agentSettings.triggers.configInvalid`),!0);return}try{a=r.secrets.trim()?JSON.parse(r.secrets):{}}catch{n(J(`agentSettings.triggers.secretsInvalid`),!0);return}c(!0);try{let o=r.secrets.trim()&&Object.values(a).some(e=>String(e).trim()),s=Number(r.interval);await e.request(`/triggers/${t.id}`,{method:`PATCH`,body:{name:r.name,config:i,...s>0?{interval_s:s}:{},...o?{secrets:a}:{}}}),n(J(`agentSettings.triggers.saved`,{name:t.name||$s[t.kind]})),await y()}catch(e){n(e.message,!0)}finally{c(!1)}}async function T(t){if(confirm(J(`agentSettings.triggers.confirmDelete`,{kind:$s[t.kind],name:t.name||t.kind})))try{await e.request(`/triggers/${t.id}`,{method:`DELETE`}),await y()}catch(e){n(e.message,!0)}}async function E(t){m(e=>({...e,[t.id]:J(`agentSettings.triggers.testing`)}));try{let n=await e.request(`/triggers/${t.id}/test`,{method:`POST`});m(e=>({...e,[t.id]:n.ok?`✓ ${n.message}`:`✗ ${n.error}`}))}catch(e){m(n=>({...n,[t.id]:`✗ ${e.message}`}))}}return(0,Q.jsxs)(`section`,{className:`project-triggers`,"data-setting":`projects.triggers`,children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.triggers.title`)}),(0,Q.jsx)(`p`,{children:J(`agentSettings.triggers.intro`)}),(0,Q.jsxs)(`div`,{className:`trigger-add`,children:[(0,Q.jsxs)(`select`,{"aria-label":J(`agentSettings.triggers.kind`),value:l,onChange:e=>u(e.target.value),disabled:s,children:[(0,Q.jsx)(`option`,{value:`github`,children:`GitHub`}),(0,Q.jsx)(`option`,{value:`slack`,children:`Slack`}),(0,Q.jsx)(`option`,{value:`linear`,children:`Linear`}),(0,Q.jsx)(`option`,{value:`jira`,children:`Jira`})]}),x[l]&&(0,Q.jsx)(`input`,{type:`password`,autoComplete:`new-password`,"aria-label":x[l].label,placeholder:x[l].label,value:d,onChange:e=>f(e.target.value)}),(0,Q.jsx)(`button`,{onClick:()=>void S(),disabled:s,children:J(`agentSettings.triggers.add`)})]}),r.length===0&&(0,Q.jsx)(`p`,{children:J(`agentSettings.triggers.none`)}),r.map(e=>{let t=b(e),n=h[e.id]??!1;return(0,Q.jsxs)(`article`,{className:`trigger-source-row`,children:[(0,Q.jsxs)(`div`,{className:`trigger-source-head`,children:[(0,Q.jsx)(`b`,{children:$s[e.kind]}),(0,Q.jsx)(`span`,{className:`trigger-source-name`,children:e.name||J(`agentSettings.triggers.unnamed`)}),(0,Q.jsx)(`span`,{className:`trigger-status trigger-status-${e.status}`,children:e.status}),(0,Q.jsx)(`span`,{className:`trigger-last-poll`,children:J(`agentSettings.triggers.lastPoll`,{time:rc(e.last_poll_at)})})]}),e.last_error&&(0,Q.jsx)(`p`,{className:`trigger-error`,role:`status`,children:e.last_error}),(0,Q.jsxs)(`div`,{className:`trigger-source-actions`,children:[(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>void C(e)}),` `,J(`agentSettings.triggers.enabled`)]}),(0,Q.jsx)(`button`,{onClick:()=>g(t=>({...t,[e.id]:!n})),children:J(n?`agentSettings.triggers.hideSettings`:`agentSettings.triggers.edit`)}),(0,Q.jsx)(`button`,{onClick:()=>void E(e),children:J(`agentSettings.triggers.testConnection`)}),(0,Q.jsx)(`button`,{className:`trigger-delete`,onClick:()=>void T(e),children:J(`agentSettings.triggers.delete`)})]}),p[e.id]&&(0,Q.jsx)(`p`,{className:`trigger-test-result`,role:`status`,children:p[e.id]}),n&&(0,Q.jsxs)(`div`,{className:`trigger-source-edit`,children:[(0,Q.jsxs)(`label`,{children:[J(`agentSettings.editor.name`),(0,Q.jsx)(`input`,{value:t.name,onChange:n=>v(r=>({...r,[e.id]:{...t,name:n.target.value}}))})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.triggers.pollInterval`),(0,Q.jsx)(`input`,{value:t.interval,onChange:n=>v(r=>({...r,[e.id]:{...t,interval:n.target.value}}))})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.triggers.config`),(0,Q.jsx)(`textarea`,{className:`trigger-config`,value:t.config,onChange:n=>v(r=>({...r,[e.id]:{...t,config:n.target.value}}))})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.triggers.secrets`,{set:Object.entries(e.secrets).filter(([,e])=>e).length,total:Object.keys(e.secrets).length||0}),(0,Q.jsx)(`textarea`,{className:`trigger-secrets`,placeholder:tc[e.kind],value:t.secrets===tc[e.kind]?``:t.secrets,onChange:n=>v(r=>({...r,[e.id]:{...t,secrets:n.target.value}}))})]}),(0,Q.jsx)(`button`,{onClick:()=>void w(e),disabled:s,children:J(`agentSettings.triggers.save`)})]})]},e.id)}),(0,Q.jsx)(`h4`,{children:J(`agentSettings.triggers.recentEvents`)}),a.length===0&&(0,Q.jsx)(`p`,{children:J(`agentSettings.triggers.noEvents`)}),(0,Q.jsx)(`ul`,{className:`trigger-events`,children:a.map(e=>(0,Q.jsxs)(`li`,{className:`trigger-event-row`,children:[(0,Q.jsx)(`span`,{className:`trigger-event-time`,children:rc(e.created_at)}),(0,Q.jsx)(`span`,{className:`trigger-event-kind`,children:e.kind}),(0,Q.jsx)(`span`,{className:`trigger-event-author`,children:e.author||`—`}),(0,Q.jsx)(`span`,{className:`trigger-event-action trigger-event-${e.action}`,children:e.action===`task_created`&&e.task_id?J(`agentSettings.triggers.taskCreated`,{id:e.task_id,status:e.task_status||`?`}):e.reason||e.action})]},e.id))})]})}var ac={github:`GitHub`,gitlab:`GitLab`,bitbucket:`Bitbucket`,gitea:`Gitea`,azure:`Azure DevOps`,linear:`Linear`,jira:`Jira`};function oc(e){return e===`github`||e===`gitlab`||e===`bitbucket`||e===`gitea`||e===`azure`}function sc(e){return e.source===`linear`||e.source===`jira`||e.source===`azure`&&e.kind===`issue`}function cc(e){return e===`github`||e===`gitlab`||e===`gitea`||e===`linear`}var lc=[[`+1`,`👍`],[`-1`,`👎`],[`laugh`,`😄`],[`hooray`,`🎉`],[`confused`,`😕`],[`heart`,`❤️`],[`rocket`,`🚀`],[`eyes`,`👀`]];function uc(e){return J(e===`azure`?`trackers.hub.tab.workItems`:`trackers.hub.tab.issues`)}function dc(e){return oc(e.source)?(e.kind===`pr`&&(e.source===`gitlab`||e.source===`azure`)?`!`:`#`)+e.id:e.id}var fc=[`github`,`gitlab`,`bitbucket`,`gitea`,`azure`,`linear`,`jira`];function pc(e){let t=e.replace(/^#/,``);try{t=decodeURIComponent(t)}catch{return{}}let[n,r,i,a,o,s]=t.split(`/`);if(n!==`issues`&&n!==`tasks`)return{};let c=/^[1-9]\d*$/.test(r||``)?Number(r):void 0;if(!c)return{};if(!fc.includes(i)||a!==`pr`&&a!==`issue`||!o)return{project:c};let l={source:i,kind:a,id:o};return/^[1-9]\d*$/.test(s||``)&&(l.connection_id=Number(s)),{project:c,ref:l}}function mc(e,t){if(!t)return`#issues/${e}`;let n=t.connection_id?`/${t.connection_id}`:``;return`#issues/${e}/${t.source}/${t.kind}/${encodeURIComponent(t.id)}${n}`}function hc(e,t){return!!e&&!!t&&e.source===t.source&&e.kind===t.kind&&e.id===t.id&&(e.connection_id||0)===(t.connection_id||0)}var gc=()=>({merge:J(`trackers.merge.method.merge`),squash:J(`trackers.merge.method.squash`),rebase:J(`trackers.merge.method.rebase`)});function _c(e){return gc()[e]}function vc(e,t,n){return n?J(`trackers.merge.enableAuto`):e.merge.merge_queue?J(`trackers.merge.addToQueue`):gc()[t]}function yc(e){if(e.state!==`open`)return{block:J(`trackers.merge.block.state`,{state:e.state}),warn:``,autoOnly:!1};if(e.draft)return{block:J(`trackers.merge.block.draft`),warn:``,autoOnly:!1};if(!e.merge.can_merge)return{block:J(`trackers.merge.block.permission`),warn:``,autoOnly:!1};if(e.mergeable===`conflicting`)return{block:J(`trackers.merge.block.conflicts`),warn:``,autoOnly:!1};let t=[],n=!1;return e.checks===`fail`&&t.push(J(`trackers.merge.warn.checksFailing`)),e.checks===`pending`&&(t.push(J(`trackers.merge.warn.checksRunning`)),n=e.merge.auto_merge_allowed),e.review===`changes_requested`&&t.push(J(`trackers.merge.warn.changesRequested`)),e.review===`review_required`&&t.push(J(`trackers.merge.warn.reviewRequired`)),{block:``,warn:t.join(` `),autoOnly:n}}var bc=[`triage`,`backlog`,`unstarted`,`new`,`started`,`indeterminate`,`completed`,`done`,`canceled`];function xc(e,t=[]){let n=new Map;for(let e of t)n.set(e.name,{key:e.name,title:e.name,type:e.type,items:[]});for(let t of e){let e=Sc(t);n.has(e)||n.set(e,{key:e,title:e,type:t.status_type||t.state,items:[]}),n.get(e).items.push(t)}let r=[...n.values()];if(!t.length){let e=e=>{let t=bc.indexOf(e.type||``);return t<0?bc.length:t};r.sort((t,n)=>e(t)-e(n))}return r}function Sc(e){return sc(e)?e.state||J(`trackers.column.noStatus`):e.kind===`pr`?e.state===`open`?e.draft?J(`trackers.column.draft`):e.checks===`fail`?J(`trackers.column.checksFailing`):e.conflicts?J(`trackers.column.conflicts`):e.review===`approved`?J(`trackers.column.approved`):e.review===`changes_requested`?J(`trackers.column.changesRequested`):J(`trackers.column.inReview`):e.state===`merged`?J(`trackers.column.merged`):J(`trackers.column.closed`):e.state===`open`?J(`trackers.column.open`):J(`trackers.column.closed`)}function Cc(e,t){let n=t.trim().toLowerCase();if(!n)return!0;let r=[e.id,e.title,e.author,e.head,e.state,...e.assignees,...e.labels.map(e=>e.name)].filter(Boolean).join(` `).toLowerCase();return n.split(/\s+/).every(e=>r.includes(e))}function wc(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(Number.isNaN(n))return``;let r=Math.max(0,(t-n)/1e3);return r<60?J(`trackers.ago.justNow`):r<3600?J(`trackers.ago.minutes`,{n:Math.floor(r/60)}):r<86400?J(`trackers.ago.hours`,{n:Math.floor(r/3600)}):r<2592e3?J(`trackers.ago.days`,{n:Math.floor(r/86400)}):new Date(n).toISOString().slice(0,10)}function Tc(e,t=`dark`){if(!e||!/^[0-9a-f]{6}$/i.test(e))return{};let n=h(t)[t===`dark`?`panel-2`:`bg-soft`];return{borderColor:`#${e}99`,color:fe(`#${e}`,n)}}function Ec(e,t){return oc(t.source)?`/projects/${e}/forge/issues/${encodeURIComponent(t.id)}`:`/trackers/${t.connection_id}/issues/${encodeURIComponent(t.id)}`}function Dc(e){return e instanceof Error?e.message:String(e)}var Oc=()=>({github:[{key:`repo`,label:J(`trackers.settings.field.repository`),placeholder:`owner/repo`,hint:J(`trackers.settings.hint.originRemote`)},{key:`host`,label:J(`trackers.settings.field.host`),placeholder:`github.com`,hint:J(`trackers.settings.hint.githubEnterprise`)}],gitlab:[{key:`repo`,label:J(`trackers.settings.field.projectPath`),placeholder:`group/subgroup/project`,hint:J(`trackers.settings.hint.originRemote`)},{key:`host`,label:J(`trackers.settings.field.host`),placeholder:`gitlab.com`,hint:J(`trackers.settings.hint.gitlabSelfManaged`)}],bitbucket:[{key:`repo`,label:J(`trackers.settings.field.repository`),placeholder:J(`trackers.settings.placeholder.bitbucketRepo`),hint:J(`trackers.settings.hint.originRemote`)},{key:`host`,label:J(`trackers.settings.field.host`),placeholder:`bitbucket.org`,hint:J(`trackers.settings.hint.bitbucketHost`)},{key:`flavor`,label:J(`trackers.settings.field.deployment`),options:[``,`cloud`,`server`],hint:J(`trackers.settings.hint.bitbucketDeployment`)},{key:`base_url`,label:J(`trackers.settings.field.apiUrl`),placeholder:`https://bitbucket.example.com`,hint:J(`trackers.settings.hint.bitbucketApiUrl`)},{key:`username`,label:J(`trackers.settings.field.cloudAccount`),placeholder:`you@example.com`,hint:J(`trackers.settings.hint.bitbucketAccount`)},{key:`token`,label:J(`trackers.settings.field.token`),secret:!0,hint:J(`trackers.settings.hint.bitbucketToken`)}],gitea:[{key:`host`,label:J(`trackers.settings.field.host`),placeholder:`codeberg.org`},{key:`repo`,label:J(`trackers.settings.field.repository`),placeholder:`owner/repo`,hint:J(`trackers.settings.hint.originRemote`)},{key:`base_url`,label:J(`trackers.settings.field.apiUrl`),placeholder:`https://git.example.com/api/v1`},{key:`token`,label:J(`trackers.settings.field.accessToken`),secret:!0,hint:J(`trackers.settings.hint.giteaToken`)}],azure:[{key:`repo`,label:J(`trackers.settings.field.repository`),placeholder:`organisation/project/repo`,hint:J(`trackers.settings.hint.originRemote`)},{key:`base_url`,label:J(`trackers.settings.field.serverUrl`),placeholder:`https://devops.example.com/tfs`,hint:J(`trackers.settings.hint.azureServerUrl`)},{key:`token`,label:J(`trackers.settings.field.pat`),secret:!0,hint:J(`trackers.settings.hint.azureToken`)}],linear:[{key:`team_key`,label:J(`trackers.settings.field.teamKey`),placeholder:`ENG`,hint:J(`trackers.settings.hint.teamKey`)},{key:`api_key`,label:J(`trackers.settings.field.apiKey`),secret:!0,placeholder:`lin_api_…`,hint:J(`trackers.settings.hint.linearKey`)}],jira:[{key:`base_url`,label:J(`trackers.settings.field.siteUrl`),placeholder:`https://yourteam.atlassian.net`},{key:`flavor`,label:J(`trackers.settings.field.deployment`),options:[``,`cloud`,`server`],hint:J(`trackers.settings.hint.deployment`)},{key:`email`,label:J(`trackers.settings.field.email`),placeholder:`you@example.com`,hint:J(`trackers.settings.hint.email`)},{key:`token`,label:J(`trackers.settings.field.token`),secret:!0,hint:J(`trackers.settings.hint.token`)},{key:`project_key`,label:J(`trackers.settings.field.projectKey`),placeholder:`OPS`},{key:`jql`,label:J(`trackers.settings.field.jql`),placeholder:`project = OPS AND component = api`,hint:J(`trackers.settings.hint.jql`)}]}),kc=new Set([`api_key`,`token`]),Ac=()=>({"":J(`trackers.settings.flavor.guessHost`),cloud:J(`trackers.settings.flavor.cloudAny`),server:J(`trackers.settings.flavor.server`)});function jc({api:e,projectId:t,onNotice:n}){Y();let[r,i]=(0,X.useState)(),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)({}),[l,u]=(0,X.useState)(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)({}),h=(0,X.useCallback)(()=>{e.request(`/projects/${t}/trackers`).then(i).catch(e=>n(J(`trackers.settings.loadFailed`,{error:Dc(e)}),!0))},[e,t,n]);(0,X.useEffect)(h,[h]);function g(e,t){let n={},r={};for(let i of Oc()[e]){let e=(t[i.key]||``).trim();kc.has(i.key)?e&&(r[i.key]=e):e&&(n[i.key]=e)}return{config:n,secrets:r}}async function _(r,i){f(!0);try{let{config:a,secrets:l}=g(r,s);i?await e.request(`/trackers/${i}`,{method:`PATCH`,body:{config:a,secrets:l}}):await e.request(`/projects/${t}/trackers`,{method:`POST`,body:{kind:r,name:s.name||ac[r],config:a,secrets:l}}),n(J(i?`trackers.settings.saved`:`trackers.settings.connected`,{source:ac[r]})),o(``),u(void 0),c({}),h()}catch(e){n(Dc(e),!0)}finally{f(!1)}}async function v(t){m(e=>({...e,[t.id]:J(`trackers.settings.testing`)}));try{let n=await e.request(`/trackers/${t.id}/test`,{method:`POST`});m(e=>({...e,[t.id]:n.ok?`✓ ${n.message}`:`✗ ${n.error}`}))}catch(e){m(n=>({...n,[t.id]:`✗ ${Dc(e)}`}))}}async function y(t){if(confirm(J(`trackers.settings.confirmDisconnect`,{name:t.name})))try{await e.request(`/trackers/${t.id}`,{method:`DELETE`}),h()}catch(e){n(Dc(e),!0)}}function b(e,t,n){return(0,Q.jsxs)(`form`,{className:`th-conn-form`,onSubmit:n=>{n.preventDefault(),_(e,t)},children:[!t&&(0,Q.jsxs)(`label`,{children:[J(`trackers.settings.name`),(0,Q.jsx)(`input`,{value:s.name||``,placeholder:ac[e],onChange:e=>c({...s,name:e.target.value})})]}),Oc()[e].map(e=>(0,Q.jsxs)(`label`,{children:[e.label,e.options?(0,Q.jsx)(`select`,{value:s[e.key]||``,onChange:t=>c({...s,[e.key]:t.target.value}),children:e.options.map(e=>(0,Q.jsx)(`option`,{value:e,children:Ac()[e]},e))}):(0,Q.jsx)(`input`,{type:e.secret?`password`:`text`,autoComplete:e.secret?`new-password`:`off`,spellCheck:!1,value:s[e.key]||``,placeholder:e.secret&&n?.[e.key]?J(`trackers.settings.secretSet`):e.placeholder,onChange:t=>c({...s,[e.key]:t.target.value})}),e.hint&&(0,Q.jsx)(`small`,{className:`th-muted`,children:e.hint})]},e.key)),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b ok`,type:`submit`,disabled:d,children:J(t?`trackers.settings.save`:`trackers.settings.connect`)}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,onClick:()=>{o(``),u(void 0),c({})},children:J(`trackers.cancel`)})]})]})}let x=r?.forge;return(0,Q.jsxs)(`section`,{className:`project-trackers`,children:[(0,Q.jsx)(`h4`,{children:J(`trackers.settings.title`)}),(0,Q.jsxs)(`p`,{children:[J(`trackers.settings.intro1`),` `,(0,Q.jsx)(`code`,{children:`gh`}),` / `,(0,Q.jsx)(`code`,{children:`glab`}),` `,J(`trackers.settings.intro2Tokens`)]}),(0,Q.jsx)(`p`,{className:`th-forge-line`,children:x?.repo?(0,Q.jsxs)(Q.Fragment,{children:[ac[x.kind||`github`],` · `,(0,Q.jsx)(`b`,{children:x.repo}),` `,(0,Q.jsxs)(`span`,{className:`th-muted`,children:[`(`,x.source===`connection`?J(`trackers.settings.setHere`):J(`trackers.settings.fromOrigin`),`)`]})]}):(0,Q.jsx)(`span`,{className:`th-muted`,children:x?.error||J(`trackers.settings.checking`)})}),(0,Q.jsx)(`ul`,{className:`th-conns`,children:(r?.connections||[]).map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`div`,{className:`th-conn-head`,children:[(0,Q.jsx)(`b`,{children:ac[e.kind]}),` `,(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`span`,{className:`th-muted`,children:Object.entries(e.config).filter(([e,t])=>t&&e!==`api_url`).map(([e,t])=>`${e}: ${String(t)}`).join(` · `)}),Object.entries(e.secrets).map(([e,t])=>(0,Q.jsx)(`span`,{className:`th-badge ${t?`th-review-approved`:``}`,children:J(t?`trackers.settings.secretIsSet`:`trackers.settings.secretNotSet`,{name:e})},e)),e.borrowed&&(0,Q.jsx)(`span`,{className:`th-badge`,children:J(`trackers.settings.borrowed`)})]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void v(e),children:J(`trackers.settings.test`)}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>{u(e.id),o(``),c(Object.fromEntries(Object.entries(e.config).map(([e,t])=>[e,String(t??``)])))},children:J(`trackers.settings.edit`)}),(0,Q.jsx)(`button`,{className:`b no`,onClick:()=>void y(e),children:J(`trackers.settings.disconnect`)})]}),p[e.id]&&(0,Q.jsx)(`p`,{className:`th-muted`,role:`status`,children:p[e.id]}),l===e.id&&b(e.kind,e.id,e.secrets)]},e.id))}),a?b(a):(0,Q.jsx)(`div`,{className:`btnrow`,children:[`linear`,`jira`,`github`,`gitlab`,`bitbucket`,`gitea`,`azure`].map(e=>(0,Q.jsx)(`button`,{className:`b`,onClick:()=>{o(e),u(void 0),c({})},children:oc(e)?J(`trackers.settings.addRepository`,{source:ac[e]}):J(`trackers.settings.addSource`,{source:ac[e]})},e))})]})}function Mc({api:e,agents:t,projects:n,onNotice:r,onChanged:i}){Y();let[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(0);async function _(){try{o(await e.request(`/delegation`))}catch(e){r(J(`settings.delegation.loadError`,{error:e.message}),!0)}}(0,X.useEffect)(()=>{_()},[]);async function v(t){c(!0);try{o(await e.request(`/delegation`,{method:`PUT`,body:t})),i()}catch(e){r(e.message,!0)}finally{c(!1)}}async function y(){c(!0);try{o(await e.request(`/delegation/preset`,{method:`POST`,body:{api_key:d}})),f(``),r(J(`settings.delegation.presetInstalled`)),i()}catch(e){r(e.message,!0)}finally{c(!1)}}async function b(){c(!0),m(J(`settings.delegation.checking`));try{let t=await e.request(`/delegation/check`,{method:`POST`,body:{}});m(t.ok?J(`settings.delegation.answered`,{seconds:t.seconds.toFixed(1)}):J(`settings.delegation.noAnswer`,{error:t.error||(t.tail||``).trim().slice(-300)}))}catch(e){m(e.message)}finally{c(!1)}}async function x(t){if(h){c(!0);try{await e.request(`/projects/${h}/workflows/delegate`,{method:`PUT`,body:{agent:t,enabled:!0}}),r(J(`settings.delegation.skillInstalled`,{agent:t}))}catch(e){r(e.message,!0)}finally{c(!1)}}}if(!a||!a.settings||typeof a.settings.enabled!=`boolean`)return null;let S=a.settings,C=t.filter(e=>e.task||e.builtin),w=S.enabled;return(0,Q.jsxs)(`section`,{id:`delegation`,"data-setting":`delegation`,className:`delegation-banner`+(w?` on`:``),"aria-label":J(`settings.delegation.title`),children:[(0,Q.jsxs)(`div`,{className:`delegation-head`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h3`,{children:[J(`settings.delegation.title`),` `,(0,Q.jsx)(`span`,{className:`delegation-state`,children:J(w?`settings.delegation.stateOn`:`settings.delegation.stateOff`)})]}),(0,Q.jsxs)(`p`,{children:[w?J(`settings.delegation.onText`,{worker:`${S.worker_agent}${S.worker_model?` (${S.worker_model})`:``}`}):J(`settings.delegation.offText`),w&&!a.worker_ready&&(0,Q.jsxs)(`strong`,{children:[` `,J(`settings.delegation.notRunnable`,{problem:a.worker_problem})]})]})]}),(0,Q.jsxs)(`label`,{className:`delegation-switch`,children:[(0,Q.jsx)(`input`,{id:`delegation-enabled`,type:`checkbox`,role:`switch`,"aria-checked":w,checked:w,disabled:s,onChange:e=>void v({enabled:e.target.checked})}),(0,Q.jsx)(`span`,{children:J(w?`settings.delegation.on`:`settings.delegation.off`)})]})]}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,onClick:()=>u(!l),"aria-expanded":l,children:J(l?`settings.delegation.hideSetup`:`settings.delegation.setup`)}),l&&(0,Q.jsxs)(`div`,{className:`delegation-setup`,children:[(0,Q.jsxs)(`label`,{children:[J(`settings.delegation.workerAgent`),(0,Q.jsxs)(`select`,{value:S.worker_agent,disabled:s,onChange:e=>void v({worker_agent:e.target.value}),children:[(0,Q.jsx)(`option`,{value:``,children:J(`settings.delegation.choose`)}),C.map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.name},e.name))]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.delegation.workerModel`),(0,Q.jsx)(`input`,{value:S.worker_model,disabled:s,placeholder:J(`settings.delegation.agentDefault`),onBlur:e=>e.target.value!==S.worker_model&&void v({worker_model:e.target.value}),onChange:e=>o({...a,settings:{...S,worker_model:e.target.value}})})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.delegation.permissions`),(0,Q.jsxs)(`select`,{value:S.permission_mode,disabled:s,onChange:e=>void v({permission_mode:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`acceptEdits`,children:J(`settings.delegation.acceptEdits`)}),(0,Q.jsx)(`option`,{value:`plan`,children:J(`settings.delegation.plan`)}),(0,Q.jsx)(`option`,{value:`bypassPermissions`,children:`bypassPermissions`})]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.delegation.leadAgent`),(0,Q.jsxs)(`select`,{value:S.lead_agent||``,disabled:s,onChange:e=>void v({lead_agent:e.target.value}),children:[(0,Q.jsx)(`option`,{value:``,children:J(`settings.delegation.projectDefault`)}),(0,Q.jsx)(`option`,{value:`claude`,children:`Claude Code`}),(0,Q.jsx)(`option`,{value:`codex`,children:`Codex`})]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.delegation.leadModel`),(0,Q.jsx)(`input`,{value:S.lead_model||``,disabled:s,placeholder:J(`settings.delegation.agentDefault`),onBlur:e=>e.target.value!==(S.lead_model||``)&&void v({lead_model:e.target.value}),onChange:e=>o({...a,settings:{...S,lead_model:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`delegation-preset`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`strong`,{children:J(`settings.delegation.presetTitle`)}),` `,J(`settings.delegation.presetBefore`),` `,(0,Q.jsx)(`code`,{children:`flash-builder`}),` `,J(`settings.delegation.presetAfter`)]}),(0,Q.jsx)(`input`,{type:`password`,value:d,placeholder:J(`settings.delegation.keyPlaceholder`),autoComplete:`off`,onChange:e=>f(e.target.value)}),(0,Q.jsx)(`button`,{className:`b ok`,type:`button`,disabled:s||!d&&S.worker_agent!==`flash-builder`,onClick:()=>void y(),children:J(`settings.delegation.installPreset`)})]}),(0,Q.jsxs)(`div`,{className:`delegation-check`,children:[(0,Q.jsx)(`button`,{className:`b`,type:`button`,disabled:s||!a.worker_ready,onClick:()=>void b(),children:J(`settings.delegation.check`)}),p&&(0,Q.jsx)(`span`,{children:p})]}),(0,Q.jsxs)(`div`,{className:`delegation-install`,children:[(0,Q.jsxs)(`p`,{children:[J(`settings.delegation.installBefore`),(0,Q.jsx)(`code`,{children:`lectern-delegate`}),J(`settings.delegation.installAfter`)]}),(0,Q.jsxs)(`select`,{value:h,onChange:e=>g(Number(e.target.value)),children:[(0,Q.jsx)(`option`,{value:0,children:J(`settings.delegation.project`)}),n.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,disabled:s||!h,onClick:()=>void x(`claude`),children:J(`settings.delegation.forClaude`)}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,disabled:s||!h,onClick:()=>void x(`codex`),children:J(`settings.delegation.forCodex`)})]}),(0,Q.jsxs)(`p`,{className:`delegation-note`,children:[J(`settings.delegation.note1`),` `,(0,Q.jsx)(`code`,{children:`lectern`}),` `,J(`settings.delegation.note2`),` `,(0,Q.jsx)(`em`,{children:J(`settings.delegation.noteSession`)}),` `,J(`settings.delegation.note3`),` `,(0,Q.jsx)(`code`,{children:`tool_timeout_sec = 3600`}),` `,J(`settings.delegation.note4`),` `,(0,Q.jsx)(`code`,{children:`wait_build`}),` `,J(`settings.delegation.note5`)]})]})]})}function Nc(e){return`${typeof window<`u`?window.location.origin:``}/pair#code=${encodeURIComponent(e)}`}function Pc({api:e,onNotice:t}){Y();let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)([]),[o,s]=(0,X.useState)(),[c,l]=(0,X.useState)(0),[u,d]=(0,X.useState)(`30`),[f,p]=(0,X.useState)(!1);function m(){e.request(`/pair/settings`).then(e=>{r(e),d(String(e.idle_days))}).catch(e=>t(String(e),!0)),e.request(`/pair/devices`).then(a).catch(()=>a([]))}(0,X.useEffect)(m,[]),(0,X.useEffect)(()=>{if(!o)return;let e=()=>l(Math.max(0,Math.round(o.expires_at-Date.now()/1e3)));e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[o]);async function h(n){try{let t=await e.request(`/pair/settings`,{method:`PUT`,body:{enabled:n}});r(t),n||s(void 0)}catch(e){t(String(e),!0)}}async function g(){let n=Number(u);if(!Number.isFinite(n)||n<=0){t(J(`settings.devices.idleInvalid`),!0);return}try{let i=await e.request(`/pair/settings`,{method:`PUT`,body:{idle_days:n}});r(i),t(J(`settings.devices.saved`))}catch(e){t(String(e),!0)}}async function _(){p(!0);try{let t=await e.request(`/pair/mint`,{method:`POST`});s(t)}catch(e){t(String(e),!0)}finally{p(!1)}}async function v(n){if(confirm(J(`settings.devices.revokeConfirm`)))try{await e.request(`/pair/devices/${n}`,{method:`DELETE`}),a(e=>e.filter(e=>e.id!==n))}catch(e){t(String(e),!0)}}if(!n)return(0,Q.jsx)(Cs,{api:e,onNotice:t});let y=!!o&&c<=0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`article`,{className:`devices-panel`,children:[(0,Q.jsx)(`h3`,{children:J(`settings.section.devices`)}),(0,Q.jsxs)(`p`,{className:`subhint`,children:[J(`settings.devices.introBefore`),` `,(0,Q.jsx)(`code`,{children:`tailscale funnel`}),J(`settings.devices.introAfter`)]}),n.untrusted_origin_hint&&(0,Q.jsx)(`p`,{className:`subhint pairing-hint`,role:`alert`,children:J(`settings.devices.untrusted`)}),(0,Q.jsxs)(`label`,{className:`devices-toggle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:n.enabled,disabled:n.env_forced,onChange:e=>void h(e.target.checked)}),J(`settings.devices.allow`),n.env_forced&&(0,Q.jsxs)(`span`,{className:`subhint`,children:[` `,J(`settings.devices.forced`)]})]}),n.enabled&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`devices-idle`,children:(0,Q.jsxs)(`label`,{children:[J(`settings.devices.idleDays`),(0,Q.jsx)(`input`,{type:`number`,min:1,value:u,onChange:e=>d(e.target.value),onBlur:g})]})}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void _(),disabled:f,children:J(f?`settings.devices.generating`:`settings.devices.pair`)}),o&&!y&&(0,Q.jsxs)(`div`,{className:`pairing-mint`,"data-testid":`pairing-mint`,children:[(0,Q.jsx)(ts,{value:Nc(o.code),size:200}),(0,Q.jsxs)(`div`,{className:`pairing-mint-code`,children:[(0,Q.jsxs)(`p`,{className:`subhint`,children:[J(`settings.devices.scanBefore`),` `,(0,Q.jsxs)(`code`,{children:[typeof window<`u`?window.location.origin:``,`/pair`]}),` `,J(`settings.devices.scanAfter`)]}),(0,Q.jsx)(`code`,{className:`pairing-code-text`,children:Fc(o.code)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.expires`,{seconds:c})}),(0,Q.jsx)(os,{link:Nc(o.code),onNotice:t})]})]}),o&&y&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.expired`)}),(0,Q.jsx)(`h4`,{"data-setting":`devices.paired`,children:J(`settings.devices.paired`)}),i.length===0?(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.devices.none`)}):(0,Q.jsx)(`ul`,{className:`device-list`,children:i.map(e=>(0,Q.jsxs)(`li`,{className:`device-row`,children:[(0,Q.jsxs)(`div`,{className:`device-info`,children:[(0,Q.jsx)(`strong`,{children:e.name}),(0,Q.jsxs)(`span`,{className:`subhint`,children:[J(`settings.devices.pairedSeen`,{paired:vs(e.paired_at),seen:vs(e.last_seen_at)}),e.user_agent?` · ${e.user_agent}`:``]})]}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void v(e.id),children:J(`settings.devices.revoke`)})]},e.id))})]})]}),(0,Q.jsx)(Cs,{api:e,onNotice:t})]})}function Fc(e){let t=e.toUpperCase(),n=[];for(let e=0;eJ(`agentSettings.commands.checking`));async function s(){o(J(`agentSettings.commands.checking`));try{i(await e.request(`/targets/${t.id}/agents`)),o(J(`agentSettings.commands.complete`))}catch(e){i([]),o(e instanceof Error?e.message:String(e))}}return(0,X.useEffect)(()=>{s()},[]),(0,Q.jsxs)(O,{className:`agent-commands`,"aria-label":J(`agentSettings.commands.title`),onCancel:n,children:[(0,Q.jsx)(`h2`,{children:J(`agentSettings.commands.title`)}),(0,Q.jsx)(`button`,{onClick:n,children:J(`agentSettings.editor.close`)}),(0,Q.jsx)(`p`,{children:t.name}),(0,Q.jsx)(`p`,{children:J(`agentSettings.commands.intro`)}),(0,Q.jsx)(`p`,{className:`ac-status`,role:`status`,children:a}),(0,Q.jsx)(`ul`,{className:`ac-results`,children:r.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`b`,{children:e.name}),(0,Q.jsxs)(`span`,{children:[e.state===`available`?J(`agentSettings.commands.found`):e.state===`missing`?J(`agentSettings.commands.notFound`):J(`agentSettings.commands.notChecked`),` `,`— `,e.path||e.detail]})]},e.name))}),(0,Q.jsx)(`button`,{onClick:()=>void s(),children:J(`agentSettings.commands.checkAgain`)})]})}var Lc=e=>J(`remote.usage.window.${e}`),Rc=e=>e===`Default`?J(`remote.usage.defaultAccount`):e;function zc({w:e,warnAt:t}){let n=Math.max(0,Math.min(100,e.used_percentage));return(0,Q.jsxs)(`div`,{className:`pu-meter${e.warn?` warn`:``}`,"data-window":e.name,children:[(0,Q.jsxs)(`span`,{className:`pu-meter-label`,children:[Lc(e.name),e.account!==`Default`||e.target?(0,Q.jsxs)(`small`,{children:[` · `,e.target?J(`remote.usage.accountOn`,{account:Rc(e.account),machine:e.target}):Rc(e.account)]}):null]}),(0,Q.jsxs)(`i`,{role:`meter`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":J(`remote.usage.windowUsed`,{window:Lc(e.name)}),children:[(0,Q.jsx)(`b`,{style:{width:`${n}%`}}),(0,Q.jsx)(`em`,{style:{left:`${t}%`},"aria-hidden":!0})]}),(0,Q.jsxs)(`span`,{className:`pu-meter-value`,children:[Math.round(e.used_percentage),`%`,e.resets_at?` · ${xn(e.resets_at)}`:``]})]})}function Bc({days:e}){let t=Math.max(1e-4,...e.map(e=>e.cost_usd)),n=Math.max(1,...e.map(e=>e.input_tokens+e.output_tokens)),r=e.every(e=>e.cost_usd===0)&&e.some(e=>e.input_tokens+e.output_tokens>0);return(0,Q.jsx)(`div`,{className:`pu-bars`,"aria-label":J(r?`remote.usage.tokensByDay`:`remote.usage.costByDay`),children:e.map(e=>{let i=r?(e.input_tokens+e.output_tokens)/n:e.cost_usd/t;return(0,Q.jsx)(`span`,{title:`${e.date}: ${yn(e.cost_usd)} · ${J(`remote.usage.tokensInOut`,{input:vn(e.input_tokens),output:vn(e.output_tokens)})}`,children:(0,Q.jsx)(`i`,{style:{height:`${i>0?Math.max(4,i*100):0}%`}})},e.date)})})}function Vc({p:e,warnAt:t}){let[n,r]=(0,X.useState)(!1),i=e.cost_usd===0&&e.input_tokens===0&&e.windows.length===0;return(0,Q.jsxs)(`article`,{className:`pu-card${e.warn?` warn`:``}${i?` idle`:``}`,"data-provider":e.agent,children:[(0,Q.jsxs)(`header`,{children:[(0,Q.jsx)(`h4`,{children:e.label}),e.warn&&(0,Q.jsx)(`span`,{className:`chip warn`,role:`status`,children:J(`remote.usage.over`,{pct:t})})]}),(0,Q.jsxs)(`div`,{className:`pu-figures`,children:[(0,Q.jsx)(`b`,{children:yn(e.cost_usd)}),(0,Q.jsxs)(`span`,{className:`sub`,children:[J(`remote.usage.tokensInOutDot`,{input:vn(e.input_tokens),output:vn(e.output_tokens)}),e.estimated_usd>0&&` · ${J(`remote.usage.estimated`,{cost:yn(e.estimated_usd)})}`]})]}),(0,Q.jsx)(Bc,{days:e.daily}),e.windows.length>0?(0,Q.jsx)(`div`,{className:`pu-windows`,children:e.windows.map((e,n)=>(0,Q.jsx)(zc,{w:e,warnAt:t},n))}):(0,Q.jsx)(`p`,{className:`sub pu-nowindow`,children:J(i?`remote.usage.idle`:`remote.usage.noWindows`)}),e.accounts.length>1&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{type:`button`,className:`linkish`,"aria-expanded":n,onClick:()=>r(!n),children:J(n?`remote.usage.hideAccounts`:`remote.usage.byAccount`,{n:e.accounts.length})}),n&&(0,Q.jsx)(`table`,{className:`usage-table pu-accounts`,children:(0,Q.jsx)(`tbody`,{children:e.accounts.map(e=>(0,Q.jsxs)(`tr`,{className:e.warn?`warn`:``,children:[(0,Q.jsxs)(`td`,{children:[Rc(e.label),(0,Q.jsxs)(`small`,{className:`sub`,children:[` `,e.target]})]}),(0,Q.jsx)(`td`,{children:yn(e.cost_usd)}),(0,Q.jsx)(`td`,{className:`sub`,children:e.windows.map(e=>`${Lc(e.name)} ${Math.round(e.used_percentage)}%`).join(` · `)||`—`})]},e.key))})})]})]})}function Hc({api:e,days:t}){Y();let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(``);if((0,X.useEffect)(()=>{let n=!0;return e.request(`/usage/providers?days=${t}`).then(e=>{n&&Array.isArray(e?.providers)&&(r(e),s(String(e.warn_percent)))}).catch(e=>n&&a(String(e))),()=>{n=!1}},[e,t]),i)return(0,Q.jsx)(`p`,{className:`usage-error`,children:i});if(!n)return null;let c=()=>{let i=Number(o);i>=1&&i<=100&&i!==n.warn_percent&&e.request(`/budgets`).then(t=>e.request(`/budgets`,{method:`PUT`,body:{...t,usage_warn_percent:i}})).then(()=>e.request(`/usage/providers?days=${t}`)).then(r).catch(e=>a(String(e)))},l=n.providers.filter(e=>e.warn);return(0,Q.jsxs)(`section`,{className:`provider-usage`,"aria-label":J(`remote.usage.title`),"data-setting":`usage.providers`,children:[(0,Q.jsxs)(`div`,{className:`pu-head`,children:[(0,Q.jsx)(`h4`,{children:J(`remote.usage.byProvider`)}),(0,Q.jsxs)(`label`,{"data-setting":`usage.warnPercent`,children:[J(`remote.usage.warnAt`),(0,Q.jsx)(`input`,{type:`number`,min:1,max:100,value:o,onChange:e=>s(e.target.value),onBlur:c,onKeyDown:e=>e.key===`Enter`&&c()}),`%`]})]}),l.length>0&&(0,Q.jsx)(`p`,{className:`pu-alert`,role:`alert`,children:J(`remote.usage.alert`,{count:l.length,names:l.map(e=>e.label).join(`, `),pct:n.warn_percent})}),(0,Q.jsx)(`div`,{className:`pu-grid`,children:n.providers.map(e=>(0,Q.jsx)(Vc,{p:e,warnAt:n.warn_percent},e.agent))}),(0,Q.jsxs)(`details`,{className:`pu-costs`,open:n.cost_table.length>0&&n.cost_table.length<=6,children:[(0,Q.jsx)(`summary`,{children:J(`remote.usage.costTable`)}),(0,Q.jsxs)(`table`,{className:`usage-table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:J(`remote.usage.col.model`)}),(0,Q.jsx)(`th`,{children:J(`remote.usage.col.tokens`)}),(0,Q.jsx)(`th`,{children:J(`remote.usage.col.reported`)}),(0,Q.jsx)(`th`,{children:J(`remote.usage.col.estimated`)}),(0,Q.jsx)(`th`,{children:J(`remote.usage.col.list`)})]})}),(0,Q.jsxs)(`tbody`,{children:[n.cost_table.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsxs)(`td`,{children:[e.agent,e.model?` · ${e.model}`:``]}),(0,Q.jsxs)(`td`,{className:`sub`,children:[vn(e.input_tokens),` / `,vn(e.output_tokens)]}),(0,Q.jsx)(`td`,{children:yn(e.reported_usd)}),(0,Q.jsx)(`td`,{children:e.estimated_usd>0?yn(e.estimated_usd):`—`}),(0,Q.jsx)(`td`,{children:e.priced?yn(e.list_usd||0):(0,Q.jsx)(`span`,{className:`sub`,children:J(`remote.usage.addPrice`)})})]},e.agent+e.model)),n.cost_table.length===0&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:5,className:`sub`,children:J(`remote.usage.nothing`)})})]})]}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`remote.usage.listHint`)})]})]})}function Uc({api:e}){Y();let[t,n]=(0,X.useState)(30),[r,i]=(0,X.useState)(),[a,o]=(0,X.useState)(``);if((0,X.useEffect)(()=>{let n=!1;return e.request(`/usage?days=${t}`).then(e=>{n||i(e)}).catch(e=>!n&&o(String(e))),()=>{n=!0}},[e,t]),a)return(0,Q.jsx)(`p`,{className:`usage-error`,children:a});if(!r)return(0,Q.jsx)(`p`,{children:J(`agentSettings.usage.loading`)});let s=Math.max(1e-4,...r.daily.map(e=>e.cost_usd)),c=r.quota,l=r.budgets,u=l?[[J(`agentSettings.usage.overall`),l.overall],...Object.entries(l.per_agent)]:[];return(0,Q.jsxs)(`div`,{className:`usage-panel`,children:[u.some(([,e])=>e.daily||e.weekly)&&(0,Q.jsxs)(`section`,{className:`usage-budgets`,"aria-label":J(`agentSettings.usage.budgets`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.budgets`)}),u.map(([e,t])=>[`daily`,`weekly`].map(n=>{let r=t[n];return r?(0,Q.jsx)(Gc,{label:J(`agentSettings.usage.budgetRowLabel`,{label:e,period:J(n===`daily`?`agentSettings.usage.daily`:`agentSettings.usage.weekly`)}),period:r},e+n):null}))]}),!c.empty&&(0,Q.jsxs)(`section`,{className:`usage-quota`,"aria-label":J(`agentSettings.usage.accountQuota`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.accountQuota`)}),(0,Q.jsxs)(`div`,{className:`usage-quota-rows${c.stale?` stale`:``}`,children:[(0,Q.jsx)(Kc,{label:J(`agentSettings.usage.fiveHour`),window:c.five_hour}),(0,Q.jsx)(Kc,{label:J(`agentSettings.usage.sevenDay`),window:c.seven_day})]}),c.stale&&(0,Q.jsx)(`p`,{className:`sub`,children:J(`agentSettings.usage.quotaStale`,{age:Tn(c.at)})})]}),(0,Q.jsxs)(`section`,{className:`usage-totals`,children:[(0,Q.jsxs)(`div`,{className:`usage-stat`,children:[(0,Q.jsx)(`b`,{children:yn(r.today_usd)}),(0,Q.jsx)(`span`,{children:J(`agentSettings.usage.today`)})]}),(0,Q.jsxs)(`div`,{className:`usage-stat`,children:[(0,Q.jsx)(`b`,{children:yn(r.week_usd)}),(0,Q.jsx)(`span`,{children:J(`agentSettings.usage.thisWeek`)})]}),(0,Q.jsxs)(`label`,{className:`usage-days`,children:[J(`agentSettings.usage.window`),` `,(0,Q.jsx)(`select`,{value:t,onChange:e=>n(Number(e.target.value)),children:[7,14,30,90].map(e=>(0,Q.jsx)(`option`,{value:e,children:J(`agentSettings.usage.days`,{n:e})},e))})]})]}),(0,Q.jsx)(Hc,{api:e,days:t}),(0,Q.jsxs)(`section`,{className:`usage-daily-chart`,"aria-label":J(`agentSettings.usage.costByDay`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.costByDay`)}),(0,Q.jsxs)(`div`,{className:`usage-bars`,children:[r.daily.map(e=>(0,Q.jsx)(`div`,{className:`usage-bar`,title:`${e.date}: ${yn(e.cost_usd)}`,children:(0,Q.jsx)(`i`,{style:{height:`${Math.max(2,e.cost_usd/s*100)}%`}})},e.date)),r.daily.length===0&&(0,Q.jsx)(`p`,{className:`sub`,children:J(`agentSettings.usage.noUsage`)})]})]}),(0,Q.jsxs)(`div`,{className:`usage-split-grid`,children:[(0,Q.jsxs)(`section`,{"aria-label":J(`agentSettings.usage.byAgentModelLabel`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.byAgentModel`)}),(0,Q.jsx)(`table`,{className:`usage-table`,children:(0,Q.jsxs)(`tbody`,{children:[r.by_agent_model.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsxs)(`td`,{children:[e.agent,e.model?` · ${e.model}`:``]}),(0,Q.jsxs)(`td`,{children:[yn(e.cost_usd),(e.estimated_usd??0)>0&&(0,Q.jsxs)(`span`,{className:`sub`,title:J(`agentSettings.usage.estimatedTitle`),children:[` `,J(`agentSettings.usage.estimated`,{cost:yn(e.estimated_usd??0)})]})]}),(0,Q.jsx)(`td`,{className:`sub`,children:J(`agentSettings.usage.tokensInOut`,{input:vn(e.input_tokens),output:vn(e.output_tokens)})})]},e.key)),r.by_agent_model.length===0&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:3,className:`sub`,children:J(`agentSettings.usage.nothingYet`)})})]})})]}),(0,Q.jsxs)(`section`,{"aria-label":J(`agentSettings.usage.byProject`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.byProject`)}),(0,Q.jsx)(`table`,{className:`usage-table`,children:(0,Q.jsxs)(`tbody`,{children:[r.by_project.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:e.project_name||J(`agentSettings.usage.unassigned`)}),(0,Q.jsx)(`td`,{children:yn(e.cost_usd)})]},e.key)),r.by_project.length===0&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:2,className:`sub`,children:J(`agentSettings.usage.nothingYet`)})})]})})]})]}),(0,Q.jsxs)(`div`,{className:`usage-split-grid`,children:[(0,Q.jsxs)(`section`,{"aria-label":J(`agentSettings.usage.topSessionsLabel`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.topSessions`)}),(0,Q.jsxs)(`ol`,{className:`usage-top-list`,children:[r.top_sessions.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(`b`,{children:yn(e.cost_usd)})]},e.id)),r.top_sessions.length===0&&(0,Q.jsx)(`li`,{className:`sub`,children:J(`agentSettings.usage.noneYet`)})]})]}),(0,Q.jsxs)(`section`,{"aria-label":J(`agentSettings.usage.topTasksLabel`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.usage.topTasks`)}),(0,Q.jsxs)(`ol`,{className:`usage-top-list`,children:[r.top_tasks.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{children:e.title}),(0,Q.jsx)(`b`,{children:yn(e.cost_usd)})]},e.id)),r.top_tasks.length===0&&(0,Q.jsx)(`li`,{className:`sub`,children:J(`agentSettings.usage.noneYet`)})]})]})]})]})}function Wc(e){return e.blocked?`budget-red budget-blocked`:e.percent>=90?`budget-red`:e.percent>=75?`budget-amber`:``}function Gc({label:e,period:t}){return(0,Q.jsxs)(`div`,{className:`usage-budget-row ${Wc(t)}`,children:[(0,Q.jsx)(`span`,{className:`budget-label`,children:e}),(0,Q.jsx)(`i`,{children:(0,Q.jsx)(`b`,{style:{width:`${Math.max(0,Math.min(100,t.percent))}%`}})}),(0,Q.jsxs)(`span`,{children:[yn(t.spent_usd),` / `,yn(t.cap_usd),t.blocked?` · ${J(`agentSettings.usage.blocked`)}`:``]})]})}function Kc({label:e,window:t}){return(0,Q.jsxs)(`div`,{className:`usage-quota-row ${Sn(t.used_percentage)}`,children:[(0,Q.jsx)(`span`,{children:e}),(0,Q.jsx)(`i`,{children:(0,Q.jsx)(`b`,{style:{width:`${Math.max(0,Math.min(100,t.used_percentage))}%`}})}),(0,Q.jsxs)(`span`,{children:[t.used_percentage,`% `,xn(t.resets_at)]})]})}var qc=()=>[{key:`agent`,label:J(`agentSettings.outcomes.group.agent`)},{key:`model`,label:J(`agentSettings.outcomes.group.model`)},{key:`project`,label:J(`agentSettings.outcomes.group.project`)}],Jc=()=>[{key:`cost_usd`,label:J(`agentSettings.outcomes.col.totalCost`),fmt:e=>yn(e??0)},{key:`cost_per_pass`,label:J(`agentSettings.outcomes.col.perPass`),fmt:Yc},{key:`cost_per_accepted`,label:J(`agentSettings.outcomes.col.perAccepted`),fmt:Yc},{key:`cost_per_100_lines`,label:J(`agentSettings.outcomes.col.per100Lines`),fmt:Yc},{key:`passes_per_10usd`,label:J(`agentSettings.outcomes.col.passesPer10`),fmt:e=>e==null?`—`:e.toFixed(1)},{key:`median_time_to_pass_s`,label:J(`agentSettings.outcomes.col.medianTime`),fmt:Xc}];function Yc(e){return e==null?`—`:yn(e)}function Xc(e){return e==null?`—`:e<90?J(`agentSettings.outcomes.seconds`,{n:e.toFixed(0)}):J(`agentSettings.outcomes.minutes`,{n:(e/60).toFixed(1)})}function Zc({api:e}){Y();let[t,n]=(0,X.useState)(30),[r,i]=(0,X.useState)(`agent`),[a,o]=(0,X.useState)(),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(`cost_usd`),[d,f]=(0,X.useState)(!0);(0,X.useEffect)(()=>{let n=!1;return e.request(`/outcomes?days=${t}&group=${r}`).then(e=>{n||o(e)}).catch(e=>!n&&c(String(e))),()=>{n=!0}},[e,t,r]);let p=(0,X.useMemo)(()=>{if(!a)return[];let e=[...a.rows];return e.sort((e,t)=>{let n=e[l]??-1/0,r=t[l]??-1/0;return d?r-n:n-r}),e},[a,l,d]);function m(e){e===l?f(e=>!e):(u(e),f(!0))}if(s)return(0,Q.jsx)(`p`,{className:`usage-error`,children:s});if(!a)return(0,Q.jsx)(`p`,{children:J(`agentSettings.outcomes.loading`)});let h=Math.max(1e-4,...p.map(e=>e.cost_usd));return(0,Q.jsxs)(`div`,{className:`outcomes-panel`,children:[(0,Q.jsxs)(`section`,{className:`usage-totals`,children:[(0,Q.jsxs)(`label`,{className:`usage-days`,children:[J(`agentSettings.outcomes.groupBy`),` `,(0,Q.jsx)(`select`,{value:r,onChange:e=>i(e.target.value),children:qc().map(e=>(0,Q.jsx)(`option`,{value:e.key,children:e.label},e.key))})]}),(0,Q.jsxs)(`label`,{className:`usage-days`,children:[J(`agentSettings.usage.window`),` `,(0,Q.jsx)(`select`,{value:t,onChange:e=>n(Number(e.target.value)),children:[7,14,30,90].map(e=>(0,Q.jsx)(`option`,{value:e,children:J(`agentSettings.usage.days`,{n:e})},e))})]})]}),(0,Q.jsxs)(`section`,{"aria-label":J(`agentSettings.outcomes.spendComparison`),children:[(0,Q.jsx)(`h4`,{children:J(r===`agent`?`agentSettings.outcomes.spendByAgent`:r===`model`?`agentSettings.outcomes.spendByModel`:`agentSettings.outcomes.spendByProject`)}),(0,Q.jsxs)(`ol`,{className:`usage-top-list outcomes-bars`,children:[p.map(e=>(0,Q.jsxs)(`li`,{className:`outcomes-bar-row`,children:[(0,Q.jsx)(`span`,{children:e.label}),(0,Q.jsx)(`i`,{className:`outcomes-bar-track`,children:(0,Q.jsx)(`b`,{style:{width:`${Math.max(2,e.cost_usd/h*100)}%`}})}),(0,Q.jsx)(`b`,{children:yn(e.cost_usd)})]},e.key)),p.length===0&&(0,Q.jsx)(`li`,{className:`sub`,children:J(`agentSettings.outcomes.empty`)})]})]}),(0,Q.jsxs)(`section`,{"aria-label":J(`agentSettings.outcomes.table`),children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.outcomes.costPerOutcome`)}),(0,Q.jsx)(`div`,{style:{overflowX:`auto`},children:(0,Q.jsxs)(`table`,{className:`usage-table outcomes-table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:J(r===`agent`?`agentSettings.outcomes.group.agent`:r===`model`?`agentSettings.outcomes.group.model`:`agentSettings.outcomes.group.project`)}),(0,Q.jsx)(`th`,{children:J(`agentSettings.outcomes.passed`)}),(0,Q.jsx)(`th`,{children:J(`agentSettings.outcomes.accepted`)}),(0,Q.jsx)(`th`,{title:J(`agentSettings.outcomes.shippedTitle`),children:J(`agentSettings.outcomes.shipped`)}),Jc().map(e=>(0,Q.jsx)(`th`,{children:(0,Q.jsxs)(`button`,{type:`button`,className:`outcomes-sort-btn`,"aria-sort":l===e.key?d?`descending`:`ascending`:`none`,onClick:()=>m(e.key),children:[e.label,l===e.key?d?` ▼`:` ▲`:``]})},e.key))]})}),(0,Q.jsxs)(`tbody`,{children:[p.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsxs)(`td`,{children:[e.label,e.partial&&(0,Q.jsxs)(`span`,{className:`outcomes-flag`,title:J(`agentSettings.outcomes.partialTitle`),children:[` `,J(`agentSettings.outcomes.partial`)]}),e.estimated&&!e.partial&&(0,Q.jsxs)(`span`,{className:`outcomes-flag`,title:J(`agentSettings.outcomes.estimatedTitle`),children:[` `,J(`agentSettings.outcomes.estimated`)]})]}),(0,Q.jsx)(`td`,{children:e.checked?`${e.passed}/${e.checked}`:`—`}),(0,Q.jsx)(`td`,{children:e.accepted||`—`}),(0,Q.jsx)(`td`,{className:`outcomes-shipped`,children:e.pull_requests==null&&e.commits==null?`—`:`${e.pull_requests??0} / ${e.commits??0}`}),(0,Q.jsx)(`td`,{children:yn(e.cost_usd)}),(0,Q.jsx)(`td`,{children:Yc(e.cost_per_pass)}),(0,Q.jsx)(`td`,{children:Yc(e.cost_per_accepted)}),(0,Q.jsx)(`td`,{children:Yc(e.cost_per_100_lines)}),(0,Q.jsx)(`td`,{children:e.passes_per_10usd==null?`—`:e.passes_per_10usd.toFixed(1)}),(0,Q.jsx)(`td`,{children:Xc(e.median_time_to_pass_s)})]},e.key)),p.length===0&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:10,className:`sub`,children:J(`agentSettings.usage.nothingYet`)})})]})]})}),(0,Q.jsx)(`p`,{className:`sub`,children:J(`agentSettings.outcomes.footnote`)})]})]})}var Qc={daily_usd:0,weekly_usd:0,mode:`warn`};function $c(e){let t=Number(e);return Number.isFinite(t)&&t>=0?t:0}function el({api:e,onNotice:t}){Y();let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)(Qc),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(`75,90,100`),[u,d]=(0,X.useState)(`75,90`),[f,p]=(0,X.useState)(!0),[m,h]=(0,X.useState)(`3`);function g(e){a(e.overall),s(Object.entries(e.per_agent)),l(e.thresholds.join(`,`)),d(e.quota_thresholds.join(`,`)),p(e.anomaly_enabled),h(String(e.anomaly_multiplier))}function _(){e.request(`/budgets`).then(e=>{r(e),g(e.config)}).catch(e=>t(String(e),!0))}(0,X.useEffect)(_,[]);function v(e){return e.split(`,`).map(e=>Number(e.trim())).filter(e=>Number.isFinite(e)&&e>0&&e<=100)}function y(){let n={overall:i,per_agent:Object.fromEntries(o.filter(([e])=>e.trim()!==``)),thresholds:v(c),quota_thresholds:v(u),anomaly_enabled:f,anomaly_multiplier:$c(m)||3};e.request(`/budgets`,{method:`PUT`,body:n}).then(e=>{r(e),g(e.config),t(J(`agentSettings.budgets.saved`))}).catch(e=>t(String(e),!0))}return n?(0,Q.jsxs)(`article`,{id:`budgets-panel`,className:`budgets-editor`,"data-setting":`budgets.budgets`,children:[(0,Q.jsx)(`h3`,{children:J(`agentSettings.budgets.title`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`agentSettings.budgets.intro`)}),(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{children:J(`agentSettings.usage.overall`)}),(0,Q.jsxs)(`div`,{className:`limit-row`,children:[(0,Q.jsxs)(`label`,{children:[J(`agentSettings.budgets.dailyCap`),(0,Q.jsx)(`input`,{id:`budget-overall-daily`,type:`number`,min:`0`,step:`0.01`,value:i.daily_usd||``,onChange:e=>{let t=$c(e.target.value);a(e=>({...e,daily_usd:t}))},placeholder:J(`agentSettings.budgets.noCap`)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.budgets.weeklyCap`),(0,Q.jsx)(`input`,{id:`budget-overall-weekly`,type:`number`,min:`0`,step:`0.01`,value:i.weekly_usd||``,onChange:e=>{let t=$c(e.target.value);a(e=>({...e,weekly_usd:t}))},placeholder:J(`agentSettings.budgets.noCap`)})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.budgets.mode`),(0,Q.jsxs)(`select`,{id:`budget-overall-mode`,value:i.mode,onChange:e=>{let t=e.target.value;a(e=>({...e,mode:t}))},children:[(0,Q.jsx)(`option`,{value:`warn`,children:J(`agentSettings.budgets.warnOnly`)}),(0,Q.jsx)(`option`,{value:`stop`,children:J(`agentSettings.budgets.stopAt100`)})]})]})]}),n?.overall&&(n.overall.daily?.blocked||n.overall.weekly?.blocked)&&(0,Q.jsx)(`p`,{className:`budget-blocked-note`,children:J(`agentSettings.budgets.overallExhausted`)})]}),(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{children:J(`agentSettings.budgets.perAgent`)}),o.map(([e,t],n)=>(0,Q.jsxs)(`div`,{className:`per-agent-row`,children:[(0,Q.jsx)(`input`,{placeholder:J(`agentSettings.budgets.agentNamePlaceholder`),value:e,onChange:e=>{let t=e.target.value;s(e=>e.map((e,r)=>r===n?[t,e[1]]:e))}}),(0,Q.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,placeholder:J(`agentSettings.budgets.dailyPlaceholder`),value:t.daily_usd||``,onChange:e=>{let t=$c(e.target.value);s(e=>e.map((e,r)=>r===n?[e[0],{...e[1],daily_usd:t}]:e))}}),(0,Q.jsx)(`input`,{type:`number`,min:`0`,step:`0.01`,placeholder:J(`agentSettings.budgets.weeklyPlaceholder`),value:t.weekly_usd||``,onChange:e=>{let t=$c(e.target.value);s(e=>e.map((e,r)=>r===n?[e[0],{...e[1],weekly_usd:t}]:e))}}),(0,Q.jsxs)(`select`,{value:t.mode,onChange:e=>{let t=e.target.value;s(e=>e.map((e,r)=>r===n?[e[0],{...e[1],mode:t}]:e))},children:[(0,Q.jsx)(`option`,{value:`warn`,children:J(`agentSettings.budgets.warn`)}),(0,Q.jsx)(`option`,{value:`stop`,children:J(`agentSettings.budgets.stop`)})]}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>s(e=>e.filter((e,t)=>t!==n)),children:`✕`})]},n)),(0,Q.jsx)(`button`,{className:`b`,id:`budget-add-agent`,onClick:()=>s(e=>[...e,[``,{...Qc}]]),children:J(`agentSettings.budgets.addAgentLimit`)})]}),(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{children:J(`agentSettings.budgets.alerts`)}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.budgets.spendThresholds`),(0,Q.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),placeholder:`75,90,100`})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.budgets.quotaThresholds`),(0,Q.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),placeholder:`75,90`})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,J(`agentSettings.budgets.anomalyDetection`)]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.budgets.anomalyMultiplier`),(0,Q.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),disabled:!f})]})]}),(0,Q.jsx)(`button`,{id:`budget-save`,onClick:y,children:J(`agentSettings.budgets.save`)})]}):(0,Q.jsxs)(`article`,{id:`budgets-panel`,className:`budgets-editor`,"data-setting":`budgets.budgets`,children:[(0,Q.jsx)(`h3`,{children:J(`agentSettings.budgets.title`)}),(0,Q.jsx)(`p`,{children:J(`agentSettings.budgets.loading`)})]})}function tl(e){return Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>({name:e,input:String(t.input_per_1m),cached:t.cached_input_per_1m==null?``:String(t.cached_input_per_1m),output:String(t.output_per_1m)}))}function nl(e){if(e.trim()===``)return;let t=Number(e);return Number.isFinite(t)&&t>=0?t:NaN}function rl(e){let t={};for(let n of e){let e=n.name.trim();if(!e)return{error:J(`agentSettings.prices.needsName`)};if(t[e])return{error:J(`agentSettings.prices.listedTwice`,{name:e})};let r=nl(n.input),i=nl(n.output),a=nl(n.cached);if(r===void 0||i===void 0)return{error:J(`agentSettings.prices.needsRates`,{name:e})};if(Number.isNaN(r)||Number.isNaN(i)||Number.isNaN(a??0))return{error:J(`agentSettings.prices.ratesInvalid`,{name:e})};t[e]={input_per_1m:r,output_per_1m:i,...a===void 0?{}:{cached_input_per_1m:a}}}return{prices:t}}function il(e){let t=e.filter(e=>!e.priced);if(t.length===0)return``;let n=new Map;for(let e of t){let t=n.get(e.agent)??[];t.push(e.model||e.agent),n.set(e.agent,t)}return[...n.entries()].map(([e,t])=>{let n=e?e.charAt(0).toUpperCase()+e.slice(1):J(`agentSettings.prices.tokenOnly`);return J(`agentSettings.prices.unpricedNotice`,{label:n,models:t.join(`, `)})}).join(` `)}function al(e){return J(e===`input`?`agentSettings.prices.field.input`:e===`cached`?`agentSettings.prices.field.cached`:`agentSettings.prices.field.output`)}function ol({api:e,onNotice:t}){Y();let[n,r]=(0,X.useState)(),[i,a]=(0,X.useState)([]);function o(e){r(tl(e.prices||{})),a(e.seen||[])}if((0,X.useEffect)(()=>{e.request(`/model-prices`).then(o).catch(e=>t(String(e),!0))},[]),!n)return(0,Q.jsxs)(`article`,{id:`model-prices`,className:`budgets-editor`,"data-setting":`budgets.prices`,children:[(0,Q.jsx)(`h3`,{children:J(`agentSettings.prices.title`)}),(0,Q.jsx)(`p`,{children:J(`agentSettings.prices.loading`)})]});let{prices:s,error:c}=rl(n),l=il(i),u=new Set(n.map(e=>e.name.trim())),d=i.filter(e=>!e.priced&&!u.has(e.model||e.agent)),f=(e,t,n)=>r(r=>r?.map((r,i)=>i===e?{...r,[t]:n}:r));function p(){s&&e.request(`/model-prices`,{method:`PUT`,body:{prices:s}}).then(e=>{o(e),t(J(`agentSettings.prices.saved`))}).catch(e=>t(String(e),!0))}return(0,Q.jsxs)(`article`,{id:`model-prices`,className:`budgets-editor`,"data-setting":`budgets.prices`,children:[(0,Q.jsx)(`h3`,{children:J(`agentSettings.prices.title`)}),(0,Q.jsxs)(`p`,{className:`subhint`,children:[J(`agentSettings.prices.introBefore`),` `,(0,Q.jsx)(`code`,{children:`codex`}),J(`agentSettings.prices.introAfter`)]}),l&&(0,Q.jsx)(`p`,{className:`budget-blocked-note`,id:`model-prices-unpriced`,role:`status`,children:l}),(0,Q.jsxs)(`div`,{className:`mp-grid`,role:`table`,"aria-label":J(`agentSettings.prices.title`),children:[(0,Q.jsxs)(`div`,{className:`mp-row mp-head`,role:`row`,children:[(0,Q.jsx)(`span`,{role:`columnheader`,children:J(`agentSettings.prices.modelOrAgent`)}),(0,Q.jsx)(`span`,{role:`columnheader`,children:J(`agentSettings.prices.input`)}),(0,Q.jsx)(`span`,{role:`columnheader`,children:J(`agentSettings.prices.cachedInput`)}),(0,Q.jsx)(`span`,{role:`columnheader`,children:J(`agentSettings.prices.output`)}),(0,Q.jsx)(`span`,{})]}),n.map((e,t)=>(0,Q.jsxs)(`div`,{className:`mp-row`,role:`row`,children:[(0,Q.jsx)(`input`,{type:`text`,"aria-label":J(`agentSettings.prices.modelOrAgent`),placeholder:J(`agentSettings.prices.modelOrAgentPlaceholder`),value:e.name,onChange:e=>f(t,`name`,e.target.value)}),[`input`,`cached`,`output`].map(n=>(0,Q.jsx)(`input`,{"aria-label":J(`agentSettings.prices.rateLabel`,{name:e.name||J(`agentSettings.prices.newRow`),field:al(n)}),type:`number`,min:`0`,step:`0.001`,inputMode:`decimal`,placeholder:J(`agentSettings.prices.ratePlaceholder`,{field:al(n)}),value:e[n],onChange:e=>f(t,n,e.target.value)},n)),(0,Q.jsx)(`button`,{className:`b`,"aria-label":J(`agentSettings.prices.remove`,{name:e.name}),onClick:()=>r(e=>e?.filter((e,n)=>n!==t)),children:`✕`})]},t)),d.map(e=>(0,Q.jsxs)(`div`,{className:`mp-row model-price-missing`,role:`row`,children:[(0,Q.jsxs)(`span`,{className:`mp-name`,children:[(0,Q.jsx)(`b`,{children:e.model||e.agent}),` `,(0,Q.jsx)(`span`,{className:`sub`,children:J(`agentSettings.prices.unpricedRow`,{agent:e.agent,tokens:e.tokens.toLocaleString()})})]}),(0,Q.jsx)(`button`,{className:`b mp-set`,onClick:()=>r(t=>[...t??[],{name:e.model||e.agent,input:``,cached:``,output:``}]),children:J(`agentSettings.prices.setPrice`)})]},`${e.agent}/${e.model}`))]}),c&&n.length>0&&(0,Q.jsx)(`p`,{className:`budget-blocked-note`,role:`alert`,children:c}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b`,onClick:()=>r(e=>[...e??[],{name:``,input:``,cached:``,output:``}]),children:J(`agentSettings.prices.addPrice`)}),(0,Q.jsx)(`button`,{id:`model-prices-save`,disabled:!s,onClick:p,children:J(`agentSettings.prices.save`)})]})]})}var sl=()=>[[`notify`,J(`agentSettings.limits.mode.notify`)],[`wait`,J(`agentSettings.limits.mode.wait`)],[`handoff`,J(`agentSettings.limits.mode.handoff`)]];function cl(e){switch(e){case`notify`:return J(`agentSettings.limits.modeName.notify`);case`wait`:return J(`agentSettings.limits.modeName.wait`);case`handoff`:return J(`agentSettings.limits.modeName.handoff`);case`swap`:return J(`agentSettings.limits.modeName.swap`);default:return e}}function ll({api:e,projectId:t,onNotice:n}){Y();let r=t?`?project_id=${t}`:``,[i,a]=(0,X.useState)(null),[o,s]=(0,X.useState)(t?``:`notify`),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)([]),[g,_]=(0,X.useState)(``);(0,X.useEffect)(()=>{e.request(`/limits/policy${r}`).then(e=>{a(e);let n=e.own;l(n?.mode===`swap`),s(n?n.mode===`swap`?n.then||`notify`:n.mode:t?``:`notify`),d(n?.fallback_agent||``),p(n?.fallback_model||``)}).catch(()=>void 0),e.request(`/agents`).then(e=>h((e||[]).map(e=>e.name).filter(e=>e!==`shell`))).catch(()=>void 0)},[r]);async function v(){let r={policy:o===``?null:c?{mode:`swap`,then:o,fallback_agent:u,fallback_model:f}:{mode:o,fallback_agent:u,fallback_model:f}};t&&(r.project_id=t);try{let t=await e.request(`/limits/policy`,{method:`PUT`,body:r});a(t),_(J(`agentSettings.limits.savedStatus`)),n(J(`agentSettings.limits.saved`))}catch(e){_(e instanceof Error?e.message:String(e))}}let y=i&&!i.own?i.effective:null;return(0,Q.jsxs)(`section`,{className:`limit-policy`,"data-setting":`budgets.limits`,children:[(0,Q.jsx)(`h4`,{children:J(`agentSettings.limits.title`)}),o!==``&&(0,Q.jsxs)(`label`,{className:`limit-policy-swap`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":J(`agentSettings.limits.swapAccounts`),checked:c,onChange:e=>l(e.target.checked)}),J(`agentSettings.limits.swapHint`)]}),(0,Q.jsxs)(`label`,{children:[J(c&&o!==``?`agentSettings.limits.whenAllLimited`:`agentSettings.limits.policy`),(0,Q.jsxs)(`select`,{"aria-label":J(`agentSettings.limits.policyLabel`),value:o,onChange:e=>s(e.target.value),children:[t&&(0,Q.jsx)(`option`,{value:``,children:y?J(`agentSettings.limits.useDefaultInherited`,{policy:y.mode===`swap`?J(`agentSettings.limits.swapThen`,{then:cl(String(y.then))}):cl(y.mode)}):J(`agentSettings.limits.useDefault`)}),sl().map(([e,t])=>(0,Q.jsx)(`option`,{value:e,children:t},e))]})]}),o!==``&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{children:[J(o===`handoff`?`agentSettings.limits.fallbackAgent`:`agentSettings.limits.fallbackAgentForHandoff`),(0,Q.jsxs)(`select`,{"aria-label":J(`agentSettings.limits.fallbackAgent`),value:u,onChange:e=>d(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:J(`agentSettings.limits.none`)}),m.map(e=>(0,Q.jsx)(`option`,{children:e},e))]})]}),(0,Q.jsxs)(`label`,{children:[J(`agentSettings.limits.fallbackModel`),(0,Q.jsx)(`input`,{"aria-label":J(`agentSettings.limits.fallbackModel`),value:f,placeholder:J(`agentSettings.limits.agentDefault`),onChange:e=>p(e.target.value)})]})]}),(0,Q.jsx)(`button`,{onClick:()=>void v(),children:J(`agentSettings.limits.save`)}),(0,Q.jsx)(`p`,{className:`limit-policy-status`,role:`status`,children:g})]})}var ul=[`claude`,`codex`,`gemini`];function dl(e){let t=e.usage;if(!t)return J(`settings.accounts.noUsage`);let n=[];return t.rate_5h_pct!=null&&n.push(J(`settings.accounts.usage5h`,{pct:t.rate_5h_pct})),t.rate_7d_pct!=null&&n.push(J(`settings.accounts.usage7d`,{pct:t.rate_7d_pct})),n.length?n.join(` · `):J(`settings.accounts.noUsage`)}function fl({api:e,targets:t,onNotice:n,onOpenTerminal:r}){Y();let[i,a]=(0,X.useState)(null),o=t.filter(e=>e.kind!==`sandbox`),[s,c]=(0,X.useState)(0),[l,u]=(0,X.useState)(`claude`),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!1);function h(){e.request(`/accounts`).then(e=>a(e||[])).catch(e=>n(String(e),!0))}(0,X.useEffect)(h,[]);async function g(){m(!0);try{await e.request(`/accounts`,{method:`POST`,body:{agent:l,label:d.trim(),target_id:s||o[0]?.id||0}}),f(``),n(J(`settings.accounts.added`,{agent:l,label:d.trim()})),h()}catch(e){n(e instanceof Error?e.message:String(e),!0)}finally{m(!1)}}async function _(t){try{r(`/terminal/session/${(await e.request(`/accounts/${t.id}/login`,{method:`POST`})).id}`,J(`settings.accounts.signInTitle`,{label:t.label}))}catch(e){n(e instanceof Error?e.message:String(e),!0)}}async function v(t){if(window.confirm(J(`settings.accounts.forgetConfirm`,{agent:t.agent,label:t.label,target:t.target_name})))try{await e.request(`/accounts/${t.id}`,{method:`DELETE`}),h()}catch(e){n(e instanceof Error?e.message:String(e),!0)}}let y=Date.now()/1e3;return(0,Q.jsxs)(`article`,{id:`accounts-panel`,className:`accounts-panel`,children:[(0,Q.jsx)(`h3`,{children:J(`settings.section.accounts`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.accounts.hint`)}),i===null?(0,Q.jsx)(`p`,{children:J(`settings.accounts.loading`)}):i.length===0?(0,Q.jsx)(`p`,{children:J(`settings.accounts.empty`)}):(0,Q.jsx)(`ul`,{className:`accounts-list`,children:i.map(e=>(0,Q.jsxs)(`li`,{"data-account-id":e.id,className:`accounts-row`,children:[(0,Q.jsxs)(`div`,{className:`accounts-who`,children:[(0,Q.jsxs)(`strong`,{children:[e.agent,` · `,e.label]}),e.default&&(0,Q.jsxs)(`span`,{className:`subhint`,children:[` `,J(`settings.accounts.ownLogin`)]}),(0,Q.jsxs)(`span`,{className:`subhint`,children:[` `,J(`settings.accounts.onTarget`,{target:e.target_name})]})]}),(0,Q.jsxs)(`div`,{className:`accounts-state`,children:[(0,Q.jsx)(`span`,{children:e.signed_in==null?J(`settings.accounts.signInUnknown`):e.signed_in?J(`settings.accounts.signedIn`):J(`settings.accounts.notSignedIn`)}),(0,Q.jsx)(`span`,{children:e.blocked_until&&e.blocked_until>y?J(`settings.accounts.limitedUntil`,{time:St(e.blocked_until,y)}):J(`settings.accounts.free`)}),(0,Q.jsx)(`span`,{children:dl(e)}),e.live_sessions>0&&(0,Q.jsx)(`span`,{children:J(`settings.accounts.running`,{n:e.live_sessions})})]}),(0,Q.jsxs)(`div`,{className:`accounts-actions`,children:[(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void _(e),children:J(`settings.accounts.signIn`)}),(0,Q.jsx)(`button`,{className:`b`,"aria-label":J(`settings.remove`,{name:e.label}),onClick:()=>void v(e),children:J(`settings.common.remove`)})]})]},e.id))}),(0,Q.jsxs)(`fieldset`,{children:[(0,Q.jsx)(`legend`,{children:J(`settings.accounts.add`)}),(0,Q.jsxs)(`div`,{className:`limit-row`,children:[(0,Q.jsxs)(`label`,{children:[J(`settings.accounts.agent`),(0,Q.jsx)(`select`,{"aria-label":J(`settings.accounts.agentAria`),value:l,onChange:e=>u(e.target.value),children:ul.map(e=>(0,Q.jsx)(`option`,{children:e},e))})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.accounts.machine`),(0,Q.jsx)(`select`,{"aria-label":J(`settings.accounts.machineAria`),value:s||o[0]?.id||0,onChange:e=>c(Number(e.target.value)),children:o.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.accounts.label`),(0,Q.jsx)(`input`,{"aria-label":J(`settings.accounts.labelAria`),value:d,maxLength:40,placeholder:J(`settings.accounts.labelPlaceholder`),onChange:e=>f(e.target.value)})]})]}),(0,Q.jsx)(`button`,{disabled:p||!d.trim(),onClick:()=>void g(),children:J(`settings.accounts.addButton`)})]})]})}function pl(e){let t=e.navigator;return{isSecureContext:e.isSecureContext===!0,hasServiceWorker:`serviceWorker`in t,hasPushManager:`PushManager`in e,hasNotification:`Notification`in e,isIOS:/iphone|ipad|ipod/i.test(t.userAgent),isStandalone:typeof e.matchMedia==`function`&&e.matchMedia(`(display-mode: standalone)`).matches||t.standalone===!0}}function ml(e){return e.isSecureContext?e.isIOS&&!e.isStandalone?{available:!1,reason:J(`app.push.iosNotInstalled`),reasonKind:`ios-not-installed`}:!e.hasServiceWorker||!e.hasPushManager||!e.hasNotification?{available:!1,reason:J(`app.push.unsupported`),reasonKind:`unsupported`}:{available:!0}:{available:!1,reason:J(`app.push.insecure`),reasonKind:`insecure`}}function hl(e){try{let t=new URL(e),n=t.pathname.replace(/\/$/,``).split(`/`).pop()||``;return n?`${t.host}/…${n.slice(-6)}`:t.host}catch{return e.length>28?`…${e.slice(-28)}`:e}}var gl=.08,_l=40,vl=0;function yl(e){return vl=(vl+1)%1e6,e+Date.now().toString(36).slice(-4)+vl.toString(36)+Math.random().toString(36).slice(2,5)}function bl(){let e=yl(`g`);return{panes:[],root:{type:`group`,id:e,panes:[],active:null},focus:e,maximized:null,mru:[],closed:[]}}function xl(e){return e.type===`group`?[e]:e.children.flatMap(xl)}function Sl(e,t){return xl(e.root).find(e=>e.id===t)}function Cl(e,t){return xl(e.root).find(e=>e.panes.includes(t))}function wl(e,t){return t?e.panes.find(e=>e.id===t):void 0}function Tl(e){return Sl(e,e.focus)||xl(e.root)[0]}function El(e){return Tl(e).active}function Dl(e){return(e.maximized?xl(e.root).filter(t=>t.id===e.maximized):xl(e.root)).map(e=>e.active).filter(e=>!!e)}function Ol(e,t){return t(e.type===`split`?{...e,children:e.children.map(e=>Ol(e,t))}:e)}function kl(e,t,n){return{...e,root:Ol(e.root,e=>e.type===`group`&&e.id===t?n(e):e)}}function Al(e){return Array.from({length:e},()=>1/e)}function jl(e,t){let n=e.length===t&&e.every(e=>Number.isFinite(e)&&e>0)?e:Al(t);n=n.map(e=>Math.max(gl,e));let r=n.reduce((e,t)=>e+t,0);return n.map(e=>e/r)}function Ml(e,t){if(e.type===`group`){let n=e.panes.filter(e=>t.has(e)).sort((e,n)=>t.get(e)-t.get(n));return n.length?{...e,panes:n,active:e.active&&n.includes(e.active)?e.active:n[0]}:null}let n=[],r=[];return e.children.forEach((i,a)=>{let o=e.sizes[a]??1/e.children.length,s=Ml(i,t);s&&(s.type===`split`&&s.dir===e.dir?s.children.forEach((e,t)=>{n.push(e),r.push(o*(s.sizes[t]??1/s.children.length))}):(n.push(s),r.push(o)))}),n.length?n.length===1?n[0]:{...e,children:n,sizes:jl(r,n.length)}:null}function Nl(e){let t=new Set,n=e.panes.filter(e=>!t.has(e.id)&&t.add(e.id)).slice(0,_l),r=new Map(n.map((e,t)=>[e.id,t])),i=new Set,a=Ol(e.root,e=>{if(e.type!==`group`)return e;let t=e.panes.filter(e=>r.has(e)&&!i.has(e));return t.forEach(e=>i.add(e)),{...e,panes:t}}),o=n.filter(e=>!i.has(e.id)).map(e=>e.id);if(o.length){let t=xl(a).find(t=>t.id===e.focus)||xl(a)[0];a=Ol(a,e=>e.type===`group`&&e.id===t.id?{...e,panes:[...e.panes,...o],active:e.active||o[0]}:e)}let s=Ml(a,r)||{type:`group`,id:xl(a)[0]?.id||yl(`g`),panes:[],active:null},c=xl(s);return{panes:n,root:s,focus:c.some(t=>t.id===e.focus)?e.focus:c[0].id,maximized:e.maximized&&c.length>1&&c.some(t=>t.id===e.maximized)?e.maximized:null,mru:e.mru.filter((t,n)=>r.has(t)&&e.mru.indexOf(t)===n),closed:e.closed.slice(0,10)}}function Pl(e,t){return t?{...e,mru:[t,...e.mru.filter(e=>e!==t)]}:e}function Fl(e,t,n={}){if(wl(e,t.id)){let r={...e,panes:e.panes.map(e=>e.id===t.id?{...e,title:t.title||e.title,params:{...e.params,...t.params}}:e)};return n.edge&&n.edge!==`center`&&n.group?Bl(r,t.id,n.group,n.edge):n.activate===!1?r:Il(r,t.id)}let r=n.group&&Sl(e,n.group)||Tl(e),i=r.active?e.panes.findIndex(e=>e.id===r.active):-1,a=[...e.panes];a.splice(i>=0?i+1:a.length,0,t);let o={...e,panes:a,closed:e.closed.filter(e=>e.id!==t.id)};return o=kl(o,r.id,e=>({...e,panes:[...e.panes,t.id],active:n.activate===!1&&e.active?e.active:t.id})),n.edge&&n.edge!==`center`?Bl(Nl(o),t.id,r.id,n.edge):(n.activate!==!1&&(o=Pl({...o,focus:r.id},t.id)),Nl(o))}function Il(e,t){let n=Cl(e,t);return n?Pl({...kl(e,n.id,e=>({...e,active:t})),focus:n.id,maximized:e.maximized&&e.maximized!==n.id?n.id:e.maximized},t):e}function Ll(e,t){let n=Sl(e,t);return n?Pl({...e,focus:t},n.active):e}function Rl(e,t){let n=wl(e,t);if(!n)return e;let r=Cl(e,t),i={...e,panes:e.panes.filter(e=>e.id!==t),closed:[n,...e.closed.filter(e=>e.id!==t)].slice(0,10)};if(r){let e=r.panes.indexOf(t),n=r.panes.filter(e=>e!==t),a=r.active===t?n[e]||n[e-1]||null:r.active;if(i=kl(i,r.id,e=>({...e,panes:n,active:a})),!n.length&&xl(i.root).length>1){let e=i.mru.find(e=>e!==t&&i.panes.some(t=>t.id===e)),n=e?xl(i.root).find(t=>t.panes.includes(e)):void 0;n&&(i={...i,focus:n.id})}}i=Nl({...i,mru:i.mru.filter(e=>e!==t)});let a=El(i);return a?Pl(i,a):i}function zl(e){let[t,...n]=e.closed;return t?Fl({...e,closed:n},t):e}function Bl(e,t,n,r,i){let a=Cl(e,t),o=Sl(e,n);if(!a||!o)return e;if(a.id===o.id&&(r===`center`||a.panes.length===1))return r===`center`&&i!==void 0?Vl(e,t,i,o.id):Il(e,t);let s=kl(e,a.id,e=>{let n=e.panes.filter(e=>e!==t),r=e.panes.indexOf(t);return{...e,panes:n,active:e.active===t?n[r]||n[r-1]||null:e.active}});if(r===`center`)return s=kl(s,o.id,e=>({...e,panes:[...e.panes,t],active:t})),s=Nl({...s,focus:o.id,maximized:null}),i===void 0?Pl(s,t):Vl(s,t,i,o.id);let c={type:`group`,id:yl(`g`),panes:[t],active:t},l=r===`left`||r===`right`?`row`:`column`,u=r===`left`||r===`top`,d=Ol(s.root,e=>e.type===`group`&&e.id===o.id?{type:`split`,id:yl(`s`),dir:l,children:u?[c,e]:[e,c],sizes:[.5,.5]}:e);return Pl(Nl({...s,root:d,focus:c.id,maximized:null}),t)}function Vl(e,t,n,r){let i=e.panes.findIndex(e=>e.id===t);if(i<0)return e;let a=e.panes[i],o=e.panes.filter(e=>e.id!==t),s=Math.max(0,Math.min(o.length,n));if(r){let t=o.filter(t=>Sl(e,r)?.panes.includes(t.id)),i=t[Math.max(0,Math.min(t.length,n))];s=i?o.indexOf(i):t.length?o.indexOf(t.at(-1))+1:o.length}return o.splice(s,0,a),Nl({...e,panes:o})}function Hl(e,t,n){let r=Cl(e,t);if(!r)return e;let i=r.panes.indexOf(t);return Vl(e,t,Math.max(0,Math.min(r.panes.length-1,i+n)),r.id)}function Ul(e,t=e.focus){let n=new Set(Dl(e)),r=Sl(e,t);return[...e.mru,...e.panes.map(e=>e.id)].find(t=>!n.has(t)&&wl(e,t))||r?.panes.find(e=>e!==r.active)}function Wl(e,t,n=e.focus){let r=Ul(e,n);return r?Bl(e,r,n,t===`row`?`right`:`bottom`):e}function Gl(e){let t=El(e),n=Tl(e).id;return Nl({...e,root:{type:`group`,id:n,panes:e.panes.map(e=>e.id),active:t},focus:n,maximized:null})}function Kl(e,t,n){return{...e,root:Ol(e.root,e=>e.type===`split`&&e.id===t?{...e,sizes:jl(n,e.children.length)}:e)}}function ql(e,t,n,r){let i=Jl(e.root,t);if(!i||n<0||n>=i.children.length-1)return e;let a=[...i.sizes],o=a[n]+a[n+1],s=Math.max(gl,Math.min(o-gl,a[n]+r));return a[n]=s,a[n+1]=o-s,Kl(e,t,a)}function Jl(e,t){if(e.type!==`group`)return e.id===t?e:e.children.map(e=>Jl(e,t)).find(Boolean)}function Yl(e){return{...e,root:Ol(e.root,e=>e.type===`split`?{...e,sizes:Al(e.children.length)}:e)}}function Xl(e,t=e.focus){return xl(e.root).length<2?{...e,maximized:null}:{...e,maximized:e.maximized===t?null:t,focus:t}}function Zl(e,t){let n=Tl(e);if(n.panes.length<2||!n.active)return e;let r=n.panes.indexOf(n.active),i=n.panes[(r+t+n.panes.length)%n.panes.length];return Il(e,i)}function Ql(e,t){let n=xl(e.root);return Ll(e,n[(n.findIndex(t=>t.id===e.focus)+t+n.length)%n.length].id)}function $l(e,t){let n=El(e),r=xl(e.root);return!n||r.length<2?e:Bl(e,n,r[(r.findIndex(t=>t.id===e.focus)+t+r.length)%r.length].id,`center`)}function eu(e,t={x:0,y:0,w:1,h:1},n={groups:new Map,handles:[]}){if(e.type===`group`)return n.groups.set(e.id,t),n;let r=0;return e.children.forEach((i,a)=>{let o=e.sizes[a]??1/e.children.length;eu(i,e.dir===`row`?{x:t.x+t.w*r,y:t.y,w:t.w*o,h:t.h}:{x:t.x,y:t.y+t.h*r,w:t.w,h:t.h*o},n),r+=o,a12)return null;let r=e;if(typeof r.id!=`string`||!ru.test(r.id)||t.has(r.id))return null;if(t.add(r.id),r.type===`group`){let e=Array.isArray(r.panes)?r.panes.filter(e=>typeof e==`string`).slice(0,_l):[];return{type:`group`,id:r.id,panes:e,active:typeof r.active==`string`?r.active:null}}if(r.type===`split`&&(r.dir===`row`||r.dir===`column`)&&Array.isArray(r.children)){let e=r.children.slice(0,12).map(e=>iu(e,t,n+1)).filter(e=>!!e);if(!e.length)return null;let i=Array.isArray(r.sizes)?r.sizes.map(Number):[];return{type:`split`,id:r.id,dir:r.dir,children:e,sizes:jl(i,e.length)}}return null}function au(e,t=e=>e){if(!e||typeof e!=`object`)return bl();let n=e;if(n.v!==1||!Array.isArray(n.panes))return bl();let r=[];for(let e of n.panes.slice(0,_l)){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.id!=`string`||typeof n.kind!=`string`)continue;let i={};if(n.params&&typeof n.params==`object`)for(let[e,t]of Object.entries(n.params))typeof t==`string`&&e.length<40&&(i[e]=t.slice(0,500));let a=t({id:n.id.slice(0,200),kind:n.kind.slice(0,40),title:String(n.title||``).slice(0,160),params:i});a&&r.push(a)}return Nl({panes:r,root:iu(n.root,new Set,0)||bl().root,focus:typeof n.focus==`string`?n.focus:``,maximized:typeof n.maximized==`string`?n.maximized:null,mru:Array.isArray(n.mru)?n.mru.filter(e=>typeof e==`string`):[],closed:[]})}function ou(e){return Array.isArray(e)?e.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`&&typeof e.name==`string`&&!!e.layout).slice(0,30).map(e=>({id:e.id,name:e.name.slice(0,80),project_id:typeof e.project_id==`number`?e.project_id:null,saved_at:Number(e.saved_at)||0,layout:e.layout})):[]}var su=[],cu={};function lu(){return _e(),(0,Q.jsx)(`p`,{className:`personal-note`,children:u()?J(`settings.localOnly`):J(`settings.synced`)})}function uu(){Y();let e=T(),t=H(),[n,r]=(0,X.useState)(e.accent||`#8b5cf6`),i=ee(e.theme,typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: dark)`).matches);return(0,Q.jsxs)(`section`,{className:`personal`,"aria-labelledby":`appearance-heading`,children:[(0,Q.jsx)(`h3`,{id:`appearance-heading`,children:J(`settings.section.appearance`)}),(0,Q.jsx)(lu,{}),(0,Q.jsxs)(`fieldset`,{className:`personal-row`,"data-setting":`appearance.theme`,children:[(0,Q.jsx)(`legend`,{children:J(`settings.appearance.theme`)}),(0,Q.jsx)(`div`,{className:`segmented`,role:`radiogroup`,"aria-label":J(`settings.appearance.theme`),children:[`system`,`dark`,`light`].map(t=>(0,Q.jsxs)(`label`,{className:e.theme===t?`on`:``,children:[(0,Q.jsx)(`input`,{type:`radio`,name:`app-theme`,value:t,checked:e.theme===t,onChange:()=>p({theme:t})}),J(`settings.appearance.theme.`+t)]},t))}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.appearance.themeHint`,{mode:J(`settings.appearance.theme.`+i)})})]}),t.themes.length>0&&(0,Q.jsxs)(`label`,{className:`personal-row`,"data-setting":`appearance.preset`,children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.appearance.preset`)}),(0,Q.jsxs)(`select`,{id:`appearance-preset`,value:Ve(e.preset)?e.preset:``,onChange:e=>p({preset:e.target.value}),children:[(0,Q.jsx)(`option`,{value:``,children:J(`settings.appearance.presetDefault`)}),t.themes.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:J(`settings.appearance.presetFromPlugin`,{name:e.name,plugin:e.plugin})},e.id))]}),(0,Q.jsx)(`span`,{className:`personal-hint`,children:J(`settings.appearance.presetHint`)})]}),(0,Q.jsxs)(`fieldset`,{className:`personal-row`,"data-setting":`appearance.accent`,children:[(0,Q.jsx)(`legend`,{children:J(`settings.appearance.accent`)}),(0,Q.jsxs)(`div`,{className:`swatches`,children:[_.map(t=>{let n=t.value||h(i).accent;return(0,Q.jsx)(`button`,{type:`button`,className:`swatch`,"aria-pressed":e.accent===t.value,"aria-label":t.name,title:t.name,style:{background:n},onClick:()=>p({accent:t.value})},t.name)}),(0,Q.jsxs)(`label`,{className:`swatch-custom`,children:[(0,Q.jsx)(`input`,{type:`color`,value:n,"aria-label":J(`settings.appearance.customAccent`),onChange:e=>{r(e.target.value),p({accent:e.target.value})}}),J(`settings.appearance.custom`)]})]}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.appearance.accentHint`)})]}),(0,Q.jsxs)(`fieldset`,{className:`personal-row`,"data-setting":`appearance.zoom`,children:[(0,Q.jsx)(`legend`,{children:J(`settings.appearance.zoom`)}),(0,Q.jsxs)(`div`,{className:`zoom-row`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`b`,"aria-label":J(`shortcut.zoom.out`,void 0,`Zoom out`),disabled:e.zoom<=B[0],onClick:()=>p({zoom:B[Math.max(0,B.indexOf(e.zoom)-1)]??1}),children:`−`}),(0,Q.jsx)(`select`,{"aria-label":J(`settings.appearance.zoom`),value:e.zoom,onChange:e=>p({zoom:Number(e.target.value)}),children:B.map(e=>(0,Q.jsxs)(`option`,{value:e,children:[Math.round(e*100),`%`]},e))}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,"aria-label":J(`shortcut.zoom.in`,void 0,`Zoom in`),disabled:e.zoom>=B.at(-1),onClick:()=>p({zoom:B[Math.min(B.length-1,B.indexOf(e.zoom)+1)]??1}),children:`+`})]})]}),(0,Q.jsxs)(`label`,{className:`personal-row`,"data-setting":`appearance.language`,children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.appearance.language`)}),(0,Q.jsx)(`select`,{value:e.language,onChange:e=>p({language:e.target.value}),children:Qe.map(e=>(0,Q.jsx)(`option`,{value:e.tag,children:e.tag?e.name:J(`settings.appearance.browserLanguage`)},e.tag))}),(0,Q.jsx)(`span`,{className:`personal-hint`,children:J(`settings.appearance.languageHint`)})]})]})}function du({theme:e}){return(0,Q.jsxs)(`span`,{className:`term-swatch`,style:{background:e.theme.background,color:e.theme.foreground},"aria-hidden":`true`,children:[(0,Q.jsx)(`b`,{children:`Aa`}),[`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`].map(t=>(0,Q.jsx)(`i`,{style:{background:e.theme[t]}},t))]})}function fu({projects:e}){let[t,n]=(0,X.useState)(`global`),r=t===`global`?{kind:`global`}:{kind:`project`,id:Number(t)},[a]=i(Ie(r),void 0),o=a===void 0&&r.kind===`global`?s(r):pe(a??[]),[c,l]=(0,X.useState)(``),[u,d]=(0,X.useState)(``),[f,p]=(0,X.useState)(!0),m=e=>R(r,e),h=(e,t)=>{let n=[...o],[r]=n.splice(e,1);n.splice(Math.max(0,Math.min(n.length,e+t)),0,r),m(n)};return(0,Q.jsxs)(`div`,{className:`personal-block`,"data-setting":`workspace.quick`,children:[(0,Q.jsx)(`h4`,{children:J(`settings.workspace.quick`)}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.workspace.quickHint`)}),(0,Q.jsxs)(`label`,{className:`personal-inline`,children:[J(`settings.workspace.quickScope`),(0,Q.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value),"aria-label":J(`settings.workspace.quickScope`),children:[(0,Q.jsx)(`option`,{value:`global`,children:J(`settings.workspace.everywhere`)}),e.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:J(`settings.workspace.projectScope`,{name:e.name})},e.id))]})]}),(0,Q.jsxs)(`ol`,{className:`quick-list`,children:[o.map((e,t)=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`quick-number`,"aria-hidden":`true`,children:t<9?t+1:``}),(0,Q.jsx)(`input`,{className:`quick-label`,"aria-label":J(`settings.workspace.quickLabel`),placeholder:J(`settings.workspace.quickLabel`),value:e.label,onChange:t=>m(o.map(n=>n.id===e.id?{...n,label:t.target.value}:n))}),(0,Q.jsx)(`input`,{className:`quick-text`,"aria-label":J(`settings.workspace.quickText`),value:e.text,onChange:t=>m(o.map(n=>n.id===e.id?{...n,text:t.target.value}:n))}),(0,Q.jsxs)(`label`,{className:`quick-enter`,title:J(`settings.workspace.quickEnter`),children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:e.enter,onChange:t=>m(o.map(n=>n.id===e.id?{...n,enter:t.target.checked}:n))}),`⏎`]}),(0,Q.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":J(`settings.moveUp`,{name:e.label||e.text}),disabled:t===0,onClick:()=>h(t,-1),children:`↑`}),(0,Q.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":J(`settings.moveDown`,{name:e.label||e.text}),disabled:t===o.length-1,onClick:()=>h(t,1),children:`↓`}),(0,Q.jsx)(`button`,{type:`button`,className:`icon-button danger`,"aria-label":J(`settings.remove`,{name:e.label||e.text}),onClick:()=>m(o.filter(t=>t.id!==e.id)),children:`×`})]},e.id)),!o.length&&(0,Q.jsx)(`li`,{className:`quick-empty`,children:J(`settings.workspace.quickEmpty`)})]}),(0,Q.jsxs)(`form`,{className:`quick-add`,onSubmit:e=>{e.preventDefault(),u&&(m([...o,{id:Re(),label:c.trim(),text:u,enter:f}]),l(``),d(``))},children:[(0,Q.jsx)(`input`,{"aria-label":J(`settings.workspace.quickNewLabel`),placeholder:J(`settings.workspace.quickLabel`),value:c,onChange:e=>l(e.target.value)}),(0,Q.jsx)(`input`,{"aria-label":J(`settings.workspace.quickNewText`),placeholder:J(`settings.workspace.quickText`),value:u,autoCapitalize:`off`,spellCheck:!1,onChange:e=>d(e.target.value),required:!0}),(0,Q.jsxs)(`label`,{className:`quick-enter`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),`⏎`]}),(0,Q.jsx)(`button`,{className:`b ok`,disabled:!u,children:J(`settings.add`)})]})]})}function pu({projects:e}){let[t]=i(`workspace.layouts`,su),n=ou(t);return(0,Q.jsxs)(`div`,{className:`personal-block`,"data-setting":`workspace.layouts`,children:[(0,Q.jsx)(`h4`,{children:J(`settings.workspace.layouts`)}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.workspace.layoutsHint`)}),!n.length&&(0,Q.jsx)(`p`,{className:`personal-empty`,children:J(`workspace.noLayouts`)}),(0,Q.jsx)(`ul`,{className:`layout-list`,children:n.map(t=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`input`,{"aria-label":J(`workspace.layoutName`),value:t.name,onChange:e=>j(`workspace.layouts`,n.map(n=>n.id===t.id?{...n,name:e.target.value.slice(0,80)}:n))}),(0,Q.jsxs)(`span`,{className:`personal-hint`,children:[t.project_id?e.find(e=>e.id===t.project_id)?.name||J(`workspace.projectOnly`):J(`workspace.anyProject`),` · `,t.layout.panes.length,` `,J(`workspace.panes`)]}),(0,Q.jsx)(`button`,{type:`button`,className:`icon-button danger`,"aria-label":J(`workspace.deleteLayout`,{name:t.name}),onClick:()=>j(`workspace.layouts`,n.filter(e=>e.id!==t.id)),children:`×`})]},t.id))})]})}function mu(){let e=D(),[t]=i(d,su),n=Pe(t),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),u=e.theme||`slate`,f=(e,t)=>{try{let n=le(e,t),i=Pe(l()).filter(e=>e.custom&&e.id!==n.id);r([...i,n]),ge({theme:n.id}),c(``),o(``)}catch(e){c(e instanceof Error?e.message:String(e))}};return(0,Q.jsxs)(`div`,{className:`personal-block`,children:[(0,Q.jsx)(`h4`,{children:J(`settings.workspace.terminal`)}),(0,Q.jsxs)(`div`,{className:`personal-row`,"data-setting":`workspace.terminalTheme`,children:[(0,Q.jsx)(`span`,{className:`personal-label`,id:`terminal-theme-label`,children:J(`settings.workspace.terminalTheme`)}),(0,Q.jsx)(`div`,{className:`term-themes`,role:`radiogroup`,"aria-labelledby":`terminal-theme-label`,children:n.map(e=>(0,Q.jsxs)(`label`,{className:`term-theme`+(e.id===u?` on`:``),children:[(0,Q.jsx)(`input`,{type:`radio`,name:`terminal-theme`,checked:e.id===u,onChange:()=>ge({theme:e.id})}),(0,Q.jsx)(du,{theme:e}),(0,Q.jsxs)(`span`,{children:[e.name,e.light?` · `+J(`settings.workspace.lightTheme`):``]}),e.custom&&(0,Q.jsx)(`button`,{type:`button`,className:`icon-button danger`,"aria-label":J(`settings.remove`,{name:e.name}),onClick:t=>{t.preventDefault(),r(n.filter(t=>t.custom&&t.id!==e.id)),u===e.id&&ge({theme:``})},children:`×`})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`personal-row`,"data-setting":`workspace.themeImport`,children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.workspace.themeImport`)}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.workspace.themeImportHint`)}),(0,Q.jsx)(`input`,{type:`file`,"aria-label":J(`settings.workspace.themeFile`),accept:`.json,.itermcolors,.conf,.toml,.ini,.Xresources,.theme,text/*`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&t.text().then(e=>f(e,t.name.replace(/\.[^.]+$/,``)))}}),(0,Q.jsx)(`textarea`,{"aria-label":J(`settings.workspace.themePaste`),placeholder:J(`settings.workspace.themePaste`),rows:3,value:a,onChange:e=>o(e.target.value)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,disabled:!a.trim(),onClick:()=>f(a,`Imported`),children:J(`settings.workspace.themeAdd`)}),s&&(0,Q.jsx)(`p`,{role:`alert`,className:`personal-error`,children:s})]}),(0,Q.jsxs)(`label`,{className:`personal-row`,"data-setting":`workspace.lineHeight`,children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.workspace.lineHeight`)}),(0,Q.jsxs)(`select`,{value:e.lineHeight,onChange:e=>ge({lineHeight:Number(e.target.value)}),children:[(0,Q.jsx)(`option`,{value:0,children:J(`settings.workspace.lineHeightDevice`)}),(0,Q.jsx)(`option`,{value:1,children:J(`settings.workspace.compact`)}),(0,Q.jsx)(`option`,{value:1.15,children:J(`settings.workspace.comfortable`)}),(0,Q.jsx)(`option`,{value:1.3,children:J(`settings.workspace.spacious`)})]})]}),(0,Q.jsxs)(`label`,{className:`personal-row personal-check`,"data-setting":`workspace.osc52`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:e.osc52,onChange:e=>ge({osc52:e.target.checked})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.workspace.osc52`)}),(0,Q.jsx)(`span`,{className:`personal-hint`,children:J(`settings.workspace.osc52Hint`)})]})]}),(0,Q.jsxs)(`label`,{className:`personal-row personal-check`,"data-setting":`workspace.extendedKeys`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:e.extendedKeys,onChange:e=>ge({extendedKeys:e.target.checked})}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.workspace.extendedKeys`)}),(0,Q.jsx)(`span`,{className:`personal-hint`,children:J(`settings.workspace.extendedKeysHint`)})]})]}),(0,Q.jsxs)(`fieldset`,{className:`personal-row`,"data-setting":`workspace.find`,children:[(0,Q.jsx)(`legend`,{children:J(`settings.workspace.find`)}),[`findCase`,`findWord`,`findRegex`].map(t=>(0,Q.jsxs)(`label`,{className:`personal-check`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:e[t],onChange:e=>ge({[t]:e.target.checked})}),J(`settings.workspace.`+t)]},t))]}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.workspace.kitty`)})]})}function hu({api:e,values:t,onNotice:n}){let[r,i]=(0,X.useState)(String(t.claude_terminal_mouse??``)!==`0`);return(0,X.useEffect)(()=>i(String(t.claude_terminal_mouse??``)!==`0`),[t.claude_terminal_mouse]),(0,Q.jsxs)(`label`,{className:`personal-row personal-check`,"data-setting":`workspace.claudeMouse`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:r,onChange:t=>{let r=t.target.checked;e.request(`/settings`,{method:`PUT`,body:{claude_terminal_mouse:r?`1`:`0`}}).then(()=>{i(r),n(J(`settings.workspace.claudeMouseSaved`))}).catch(e=>n(String(e),!0))}}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`personal-label`,children:J(`settings.workspace.claudeMouse`)}),(0,Q.jsx)(`span`,{className:`personal-hint`,children:J(`settings.workspace.claudeMouseHint`)})]})]})}function gu({projects:e,api:t,values:n,onNotice:r}){return Y(),(0,Q.jsxs)(`section`,{className:`personal`,"aria-labelledby":`workspace-heading`,children:[(0,Q.jsx)(`h3`,{id:`workspace-heading`,children:J(`settings.section.workspace`)}),(0,Q.jsx)(lu,{}),(0,Q.jsx)(pu,{projects:e}),(0,Q.jsx)(fu,{projects:e}),(0,Q.jsx)(mu,{}),(0,Q.jsx)(hu,{api:t,values:n,onNotice:r})]})}function _u({id:e,current:t,onDone:n}){let[r,i]=(0,X.useState)(null),a=(0,X.useRef)(null);(0,X.useEffect)(()=>a.current?.focus(),[]);let o=r?Ke(e,r,t):[],s=Ze(e)?.context||`global`;return(0,Q.jsxs)(`div`,{className:`shortcut-recorder`,"data-shortcut-capture":!0,ref:a,tabIndex:0,role:`group`,"aria-label":J(`settings.shortcuts.recording`),onKeyDown:e=>{if(e.key===`Tab`)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&!e.shiftKey&&r===null)return n(null);let t=rt(e.nativeEvent);t&&i(t)},children:[(0,Q.jsx)(`span`,{className:`shortcut-live`,children:r?(0,Q.jsx)(`kbd`,{children:Ue(r)}):J(`settings.shortcuts.pressKeys`)}),r&&o.length>0&&(0,Q.jsx)(`p`,{className:`shortcut-conflict`,role:`alert`,children:J(`settings.shortcuts.conflict`,{names:o.map(e=>J(`shortcut.`+e,void 0,Ze(e)?.title)).join(`, `)})}),r&&Je(r,s)&&(0,Q.jsx)(`p`,{className:`personal-hint`,children:Je(r,s)}),(0,Q.jsxs)(`div`,{className:`shortcut-recorder-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`b ok`,disabled:!r,onClick:()=>n(r),children:o.length?J(`settings.shortcuts.saveAnyway`):J(`settings.save`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,onClick:()=>n(null),children:J(`settings.cancel`)})]})]})}function vu({focus:e}){Y();let t=at(),[n]=i(`shortcuts`,cu),r=(0,X.useMemo)(()=>nt(n,t),[n,t]),a=(0,X.useMemo)(()=>Xe(r,t),[r,t]),o=(0,X.useMemo)(()=>Ge(a),[a]),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(null),d=e=>j(`shortcuts`,e);(0,X.useEffect)(()=>{e?.startsWith(`shortcut:`)&&c(J(`shortcut.`+e.slice(9),void 0,Ze(e.slice(9))?.title))},[e]);let f=s.trim().toLocaleLowerCase(),p=We.filter(e=>{if(!f)return!0;let n=(a.get(e.id)||[]).map(e=>Ue(e,t)).join(` `);return[J(`shortcut.`+e.id,void 0,e.title),e.category,e.keywords,n,e.id].join(` `).toLocaleLowerCase().includes(f)}),m=[...new Set(p.map(e=>e.category))],h=We.filter(e=>(a.get(e.id)||[]).length).length;return(0,Q.jsxs)(`section`,{className:`personal shortcuts-panel`,"aria-labelledby":`shortcuts-heading`,"data-setting":`shortcuts.list`,children:[(0,Q.jsx)(`h3`,{id:`shortcuts-heading`,children:J(`settings.shortcuts.title`)}),(0,Q.jsx)(lu,{}),(0,Q.jsx)(`p`,{className:`personal-hint`,children:J(`settings.shortcuts.summary`,{total:We.length,assigned:h})}),(0,Q.jsxs)(`div`,{className:`shortcut-tools`,children:[(0,Q.jsx)(`input`,{type:`search`,"aria-label":J(`settings.shortcuts.search`),placeholder:J(`settings.shortcuts.search`),value:s,onChange:e=>c(e.target.value)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,disabled:!Object.keys(r).length,onClick:()=>d({}),children:J(`settings.shortcuts.resetAll`)})]}),o.length>0&&(0,Q.jsxs)(`div`,{className:`shortcut-conflicts`,role:`alert`,children:[(0,Q.jsx)(`b`,{children:J(`settings.shortcuts.conflicts`)}),(0,Q.jsx)(`ul`,{children:o.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`kbd`,{children:Ue(e.chord,t)}),` — `,e.ids.map(e=>J(`shortcut.`+e,void 0,Ze(e)?.title)).join(`, `)]},e.chord))})]}),m.map(e=>(0,Q.jsxs)(`div`,{className:`shortcut-group`,children:[(0,Q.jsx)(`h4`,{children:J(`settings.shortcuts.category.`+e,void 0,e)}),(0,Q.jsx)(`table`,{className:`shortcut-table`,children:(0,Q.jsx)(`tbody`,{children:p.filter(t=>t.category===e).map(e=>{let n=a.get(e.id)||[],i=e.id in r,s=o.some(t=>t.ids.includes(e.id));return(0,Q.jsxs)(`tr`,{"data-shortcut":e.id,className:s?`clash`:``,children:[(0,Q.jsxs)(`th`,{scope:`row`,children:[J(`shortcut.`+e.id,void 0,e.title),e.context===`terminal`&&(0,Q.jsx)(`span`,{className:`shortcut-context`,children:J(`settings.shortcuts.inTerminal`)})]}),(0,Q.jsxs)(`td`,{className:`shortcut-chords`,children:[n.map(i=>(0,Q.jsxs)(`span`,{className:`shortcut-chord`+(qe(i)?` reserved`:``),title:Je(i,e.context),children:[(0,Q.jsx)(`kbd`,{children:Ue(i,t)}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":J(`settings.shortcuts.removeChord`,{chord:Ue(i,t),name:J(`shortcut.`+e.id,void 0,e.title)}),onClick:()=>d($e(r,e.id,n.filter(e=>e!==i),t)),children:`×`})]},i)),!n.length&&(0,Q.jsx)(`span`,{className:`shortcut-none`,children:J(`settings.shortcuts.unassigned`)}),l===e.id&&(0,Q.jsx)(_u,{id:e.id,current:a,onDone:i=>{u(null),i&&d($e(r,e.id,[...n.filter(e=>e!==i),i].slice(-4),t))}})]}),(0,Q.jsxs)(`td`,{className:`shortcut-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`b`,"aria-label":J(`settings.shortcuts.add`,{name:J(`shortcut.`+e.id,void 0,e.title)}),onClick:()=>u(e.id),children:J(`settings.shortcuts.addShort`)}),i&&(0,Q.jsx)(`button`,{type:`button`,className:`b`,"aria-label":J(`settings.shortcuts.reset`,{name:J(`shortcut.`+e.id,void 0,e.title)}),onClick:()=>d($e(r,e.id,e.defaults,t)),children:J(`settings.shortcuts.resetShort`)})]})]},e.id)})})})]},e)),!p.length&&(0,Q.jsx)(`p`,{className:`personal-empty`,children:J(`settings.shortcuts.noMatch`)})]})}var yu=[[`basics`,`settings.section.basics`],[`machines`,`settings.section.machines`],[`projects`,`settings.section.projects`],[`agents`,`settings.section.agents`],[`notifications`,`settings.section.notifications`],[`devices`,`settings.section.devices`],[`appearance`,`settings.section.appearance`],[`workspace`,`settings.section.workspace`],[`shortcuts`,`settings.section.shortcuts`],[`connections`,`settings.section.connections`],[`plugins`,`settings.section.plugins`],[`accounts`,`settings.section.accounts`],[`budgets`,`settings.section.budgets`],[`about`,`settings.section.about`]],bu=e=>J(yu.find(([t])=>t===e)?.[1]||e),xu=[[`basics`,`basics.ask`,`start.sheet.ask`,`permission mode approvals ask bypass yolo risky safety`],[`basics`,`basics.phone`,`phone.title`,`pair qr code phone mobile tailscale relay connect`],[`basics`,`basics.alerts`,`basics.alerts`,`push notifications phone alerts`],[`basics`,`basics.agents`,`basics.agents`,`installed agents claude codex gemini`],[`basics`,`basics.enter`,`basics.enter`,`chat enter send newline shift keyboard`],[`appearance`,`appearance.theme`,`settings.appearance.theme`,`dark light mode system colour scheme night`],[`appearance`,`appearance.accent`,`settings.appearance.accent`,`color colour brand highlight`],[`appearance`,`appearance.zoom`,`settings.appearance.zoom`,`scale size bigger smaller text`],[`appearance`,`appearance.language`,`settings.appearance.language`,`locale translation i18n`],[`workspace`,`workspace.layouts`,`settings.workspace.layouts`,`saved named layouts panes splits restore`],[`workspace`,`workspace.quick`,`settings.workspace.quick`,`snippets saved replies commands keybar`],[`workspace`,`workspace.terminalTheme`,`settings.workspace.terminalTheme`,`terminal colours palette theme scheme`],[`workspace`,`workspace.themeImport`,`settings.workspace.themeImport`,`iterm windows terminal kitty ghostty alacritty xresources import`],[`workspace`,`workspace.lineHeight`,`settings.workspace.lineHeight`,`terminal line spacing height`],[`workspace`,`workspace.osc52`,`settings.workspace.osc52`,`clipboard copy osc 52 programs tmux vim`],[`workspace`,`workspace.extendedKeys`,`settings.workspace.extendedKeys`,`kitty keyboard protocol shift enter modifyotherkeys csi u extended keys`],[`workspace`,`workspace.find`,`settings.workspace.find`,`search find regex case sensitive terminal`],[`workspace`,`workspace.claudeMouse`,`settings.workspace.claudeMouse`,`mouse select copy links click claude code fullscreen tracking`],[`shortcuts`,`shortcuts.list`,`settings.shortcuts.title`,`keyboard keys bindings remap hotkeys`],[`machines`,`machines.name`,`settings.index.machines.name`,`target ssh add machine`],[`machines`,`machines.host`,`settings.index.machines.host`,`target ssh address`],[`machines`,`machines.user`,`settings.index.machines.user`,`ssh login`],[`machines`,`machines.port`,`settings.index.machines.port`,`ssh`],[`machines`,`machines.key`,`settings.index.machines.key`,`ssh identity private key`],[`connections`,`machines.connect`,`settings.index.machines.connect`,`mcp claude codex tools install connector`],[`connections`,`delegation`,`settings.delegation.title`,`delegated builds worker orchestrate`],[`machines`,`machines.sshImport`,`remote.index.sshImport`,`ssh config import alias hosts proxyjump bastion kerberos gssapi fido2 security key`],[`machines`,`machines.connection`,`remote.index.connection`,`ssh transport openssh alias proxyjump jump host bastion agent forwarding kerberos gssapi fido2 security key reconnect`],[`machines`,`machines.ports`,`remote.index.ports`,`port forward forwarding localhost expose tunnel listening`],[`machines`,`machines.files`,`remote.index.files`,`download file folder tar vs code vscode cursor zed windsurf editor open remote`],[`machines`,`machines.sandboxes`,`remote.index.sandboxes`,`sandbox docker container fly modal vercel cloud provider suspend resume destroy`],[`projects`,`projects.import`,`settings.index.projects.import`,`repositories add scan`],[`projects`,`projects.mcp`,`settings.index.projects.mcp`,`mcp servers tools`],[`projects`,`projects.skills`,`settings.index.projects.skills`,`skills instructions`],[`projects`,`projects.workflows`,`settings.index.projects.workflows`,`workflows automation`],[`plugins`,`plugins.installed`,`plugins.title`,`plugins extensions install marketplace skills mcp hooks`],[`plugins`,`plugins.add`,`plugins.add.title`,`install plugin git url path folder claude code`],[`plugins`,`plugins.sources`,`plugins.sources.title`,`marketplace source index search available`],[`appearance`,`appearance.preset`,`settings.appearance.preset`,`plugin theme colours preset`],[`projects`,`projects.triggers`,`settings.index.projects.triggers`,`triggers webhooks schedule`],[`notifications`,`notifications.push`,`settings.index.notifications.push`,`push alerts phone browser`],[`notifications`,`notifications.sessionAlerts`,`settings.index.notifications.sessionAlerts`,`waiting finished alerts`],[`notifications`,`notifications.sinks`,`settings.index.notifications.sinks`,`ntfy slack discord webhook`],[`devices`,`devices.paired`,`settings.index.devices.paired`,`phone pair qr code`],[`devices`,`devices.relay`,`settings.index.devices.relay`,`encrypted relay remote`],[`about`,`about.spend`,`settings.index.about.spend`,`cost money usage`],[`about`,`about.outcomes`,`settings.index.about.outcomes`,`pull requests commits cost per outcome`],[`about`,`about.signedIn`,`settings.index.about.signedIn`,`identity whoami login`],[`about`,`about.build`,`settings.index.about.build`,`version build revision`],[`about`,`usage.providers`,`remote.index.usageProviders`,`usage provider claude codex gemini quota limit window account cost estimate`],[`about`,`usage.warnPercent`,`remote.index.usageWarn`,`usage warning 80% alert push quota threshold`],[`budgets`,`budgets.budgets`,`settings.index.budgets.budgets`,`spend limit cap`],[`budgets`,`budgets.prices`,`settings.index.budgets.prices`,`model token prices`],[`budgets`,`budgets.limits`,`settings.index.budgets.limits`,`usage limit rate limit continue`],[`agents`,`agents.runners`,`settings.index.agents.runners`,`custom agents providers`],[`agents`,`agents.profiles`,`settings.index.agents.profiles`,`launch profiles accounts`],[`agents`,`agents.starters`,`settings.index.agents.starters`,`starter profiles presets`],[`agents`,`agents.menus`,`settings.index.agents.menus`,`menu visibility`]];function Su(e={}){let t=xu.map(([e,t,n,r])=>({id:t,section:e,sectionLabel:bu(e),label:J(n),keywords:r,kind:`setting`}));if(e.shortcuts)for(let e of We)t.push({id:`shortcut:`+e.id,section:`shortcuts`,sectionLabel:bu(`shortcuts`),label:J(`shortcut.`+e.id,void 0,e.title),keywords:[e.category,e.keywords,`shortcut key`].join(` `),kind:`shortcut`});return t}function Cu(e,t=Su({shortcuts:!0})){let n=e.toLocaleLowerCase().split(/\s+/).filter(Boolean);return n.length?t.map((e,t)=>{let r=e.label.toLocaleLowerCase(),i=[r,e.keywords,e.sectionLabel].join(` `).toLocaleLowerCase();return n.every(e=>i.includes(e))?{entry:e,order:t,score:(r.startsWith(n[0])?4:0)+(n.every(e=>r.includes(e))?2:0)+(e.kind===`shortcut`?0:1)}:null}).filter(e=>!!e).sort((e,t)=>t.score-e.score||e.order-t.order).map(e=>e.entry):[]}function wu(e,t=20){let n=document.querySelector(`[data-setting="${CSS.escape(e.id)}"]`);return n?(n.scrollIntoView({block:`center`}),n.classList.add(`setting-hit`),setTimeout(()=>n.classList.remove(`setting-hit`),2400),(n.matches(`input,select,textarea,button`)?n:n.querySelector(`input,select,textarea,button`)||(n.tagName===`LABEL`?n.control:null))?.focus({preventScroll:!0}),!0):(t>0&&setTimeout(()=>wu(e,t-1),100),!1)}function Tu({onPick:e,focusVersion:t}){Y();let[n,r]=(0,X.useState)(``),[i,a]=(0,X.useState)(0),o=(0,X.useRef)(null);(0,X.useEffect)(()=>{t&&o.current?.focus()},[t]);let s=Cu(n).slice(0,12),c=t=>{t&&(r(``),e(t))};return(0,Q.jsxs)(`div`,{className:`settings-search`,role:`search`,children:[(0,Q.jsx)(`input`,{ref:o,id:`settings-search`,type:`search`,placeholder:J(`settings.search`),"aria-label":J(`settings.search`),autoComplete:`off`,role:`combobox`,"aria-expanded":s.length>0,"aria-controls":`settings-search-results`,"aria-activedescendant":s.length?`settings-hit-${i}`:void 0,value:n,onChange:e=>{r(e.target.value),a(0)},onKeyDown:e=>{e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),a(t=>Math.max(0,Math.min(s.length-1,t+(e.key===`ArrowDown`?1:-1))))):e.key===`Enter`?(e.preventDefault(),c(s[i])):e.key===`Escape`&&r(``)}}),n.trim()&&(0,Q.jsxs)(`div`,{id:`settings-search-results`,role:`listbox`,"aria-label":J(`settings.searchResults`),children:[s.map((e,t)=>(0,Q.jsxs)(`div`,{id:`settings-hit-${t}`,role:`option`,"aria-selected":t===i,className:`settings-hit`,onPointerDown:e=>e.preventDefault(),onClick:()=>c(e),children:[(0,Q.jsx)(`strong`,{children:e.label}),(0,Q.jsxs)(`span`,{children:[e.sectionLabel,e.kind===`shortcut`?` · `+J(`settings.searchShortcut`):``]})]},e.id)),!s.length&&(0,Q.jsx)(`p`,{className:`settings-hit-empty`,children:J(`settings.searchNone`)})]})]})}function Eu({api:e,onClose:t,onImported:n,onNotice:r}){let[i,a]=(0,X.useState)(),[o,s]=(0,X.useState)(new Set),[c,l]=(0,X.useState)(!1);(0,X.useEffect)(()=>{e.request(`/ssh/hosts`).then(e=>{e={...e,hosts:Array.isArray(e.hosts)?e.hosts:[]},a(e),s(new Set(e.hosts.filter(e=>!e.target_id).map(e=>e.alias)))}).catch(e=>r(String(e),!0))},[]),Y();let u=i?.hosts.filter(e=>!e.target_id)||[];return(0,Q.jsxs)(O,{className:`sheet ssh-import`,"aria-label":J(`remote.ssh.importTitle`),onCancel:t,children:[(0,Q.jsxs)(`div`,{className:`sheet-head`,children:[(0,Q.jsx)(`h2`,{children:J(`remote.ssh.importTitle`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:t,"aria-label":J(`settings.common.close`),"data-close":!0,children:`×`})]}),!i&&(0,Q.jsx)(`p`,{children:J(`remote.ssh.reading`)}),i&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{className:`sub`,children:[J(`remote.ssh.fromBefore`),(0,Q.jsx)(`code`,{children:i.path}),J(`remote.ssh.fromAfter`),` `,i.openssh?J(`remote.ssh.viaOpenssh`):J(`remote.ssh.viaBuiltin`)]}),i.error&&(0,Q.jsx)(`p`,{role:`alert`,children:i.error}),(0,Q.jsxs)(`ul`,{className:`ssh-hosts`,children:[i.hosts.map(e=>(0,Q.jsxs)(`li`,{"data-alias":e.alias,children:[(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,disabled:!!e.target_id,checked:o.has(e.alias),onChange:t=>s(n=>{let r=new Set(n);return t.target.checked?r.add(e.alias):r.delete(e.alias),r})}),(0,Q.jsx)(`b`,{children:e.alias}),(0,Q.jsxs)(`span`,{className:`sub`,children:[e.user?`${e.user}@`:``,e.hostname,e.port&&e.port!==22?`:${e.port}`:``]})]}),(0,Q.jsxs)(`span`,{className:`ssh-tags`,children:[e.proxy_jump&&(0,Q.jsx)(`span`,{className:`chip`,children:J(`remote.conn.via`,{host:e.proxy_jump})}),e.proxy_command&&(0,Q.jsx)(`span`,{className:`chip`,children:`ProxyCommand`}),e.forward_agent&&(0,Q.jsx)(`span`,{className:`chip`,children:J(`remote.ssh.tagForwarding`)}),e.gssapi&&(0,Q.jsx)(`span`,{className:`chip`,children:`Kerberos`}),e.security_key&&(0,Q.jsx)(`span`,{className:`chip info`,children:J(`remote.ssh.tagSecurityKey`)}),e.target_id&&(0,Q.jsx)(`span`,{className:`chip ds`,children:J(`remote.ssh.addedAs`,{name:e.target_name||``})})]})]},e.alias)),i.hosts.length===0&&(0,Q.jsx)(`li`,{className:`sub`,children:J(`remote.ssh.noHosts`)})]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[u.length>1&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(new Set(u.map(e=>e.alias))),children:J(`remote.ssh.selectAll`)}),(0,Q.jsx)(`button`,{type:`button`,className:`ok`,id:`ssh-import-go`,disabled:c||o.size===0,onClick:()=>{l(!0),e.request(`/ssh/import`,{method:`POST`,body:{aliases:[...o]}}).then(e=>{let i=e.results.filter(e=>e.target).length,a=e.results.filter(e=>e.error);r(J(`remote.ssh.imported`,{count:i})+(a.length?` · ${a.map(e=>`${e.alias}: ${e.error}`).join(`; `)}`:``),a.length>0&&i===0),n(),t()}).catch(e=>r(String(e),!0)).finally(()=>l(!1))},children:c?J(`remote.ssh.importing`):J(`remote.ssh.importCount`,{count:o.size})})]})]})]})}function Du(e){try{let t=JSON.parse(e.sandbox_json||`{}`);return{...t,provider:t.provider||`proxmox`}}catch{return{provider:`proxmox`}}}function Ou(e){return Object.entries(e||{}).map(([e,t])=>`${e}=${t}`).join(`
-`)}function ku(e){let t={};for(let n of e.split(`
-`)){let e=n.indexOf(`=`);e>0&&(t[n.slice(0,e).trim()]=n.slice(e+1))}return t}function Au({value:e,onChange:t,machines:n}){let r=n=>t({...e,...n});return Y(),(0,Q.jsxs)(`div`,{className:`sandbox-fields`,children:[(0,Q.jsxs)(`label`,{"data-setting":`machines.sandboxProvider`,children:[J(`remote.sandbox.provider`),(0,Q.jsxs)(`select`,{value:e.provider||`proxmox`,onChange:e=>r({provider:e.target.value}),children:[(0,Q.jsx)(`option`,{value:`proxmox`,children:J(`remote.sandbox.providerProxmox`)}),(0,Q.jsx)(`option`,{value:`docker`,children:J(`remote.sandbox.providerDocker`)}),(0,Q.jsx)(`option`,{value:`script`,children:J(`remote.sandbox.providerScript`)})]})]}),e.provider===`docker`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.image`),(0,Q.jsx)(`input`,{value:e.image||``,placeholder:`ghcr.io/you/dev-image:latest`,onChange:e=>r({image:e.target.value})})]}),(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.dockerOn`),(0,Q.jsxs)(`select`,{value:e.machine||``,onChange:e=>r({machine:e.target.value}),children:[(0,Q.jsx)(`option`,{value:``,children:J(`remote.sandbox.thisServer`)}),n.filter(e=>e.kind!==`sandbox`).map(e=>(0,Q.jsx)(`option`,{value:e.name,children:e.name},e.id))]})]}),(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.dockerHost`),(0,Q.jsx)(`input`,{value:e.docker_host||``,placeholder:J(`remote.sandbox.dockerHostPlaceholder`),onChange:e=>r({docker_host:e.target.value})})]}),(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.runArgs`),(0,Q.jsx)(`textarea`,{rows:2,value:(e.run_args||[]).join(`
-`),placeholder:`--memory
-4g`,onChange:e=>r({run_args:e.target.value.split(`
-`).map(e=>e.trim()).filter(Boolean)})})]})]}),e.provider===`script`&&(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.hooksFile`),(0,Q.jsx)(`input`,{value:e.config_path||``,placeholder:`{repo}/lectern.sandbox.yaml`,onChange:e=>r({config_path:e.target.value})})]}),(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.env`),(0,Q.jsx)(`textarea`,{rows:2,defaultValue:Ou(e.env),onBlur:e=>r({env:ku(e.target.value)})})]}),(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.onFinish`),(0,Q.jsxs)(`select`,{value:e.on_finish||``,onChange:e=>r({on_finish:e.target.value}),children:[(0,Q.jsx)(`option`,{value:``,children:J(`remote.sandbox.finishDestroy`)}),(0,Q.jsx)(`option`,{value:`suspend`,children:J(`remote.sandbox.finishSuspend`)}),(0,Q.jsx)(`option`,{value:`keep`,children:J(`remote.sandbox.finishKeep`)})]})]})]})}function ju({api:e,target:t,onNotice:n}){let[r,i]=(0,X.useState)(),a=()=>void e.request(`/targets/${t.id}/sandbox/hooks`).then(e=>i(e&&typeof e.path==`string`?e:void 0)).catch(e=>n(String(e),!0));return(0,X.useEffect)(a,[t.id,t.sandbox_json]),Y(),r?(0,Q.jsxs)(`div`,{className:`sandbox-hooks`,"data-trusted":r.trusted,children:[(0,Q.jsxs)(`div`,{className:`remote-row`,children:[(0,Q.jsx)(`code`,{children:r.path}),r.trusted?(0,Q.jsx)(`span`,{className:`chip ds`,children:J(`remote.sandbox.trusted`)}):(0,Q.jsx)(`span`,{className:`chip warn`,children:J(`remote.sandbox.notTrusted`)})]}),r.error&&(0,Q.jsx)(`p`,{className:`subhint`,role:`alert`,children:r.error}),r.content&&(0,Q.jsx)(`pre`,{className:`sandbox-yaml`,children:r.content}),!r.trusted&&r.content&&!r.error&&(0,Q.jsx)(`button`,{type:`button`,className:`ok`,onClick:()=>void e.request(`/targets/${t.id}/sandbox/trust`,{method:`POST`,body:{path:r.path,sha256:r.sha256}}).then(()=>{n(J(`remote.sandbox.trustedNotice`)),a()}).catch(e=>n(String(e),!0)),children:J(`remote.sandbox.trust`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`remote.sandbox.trustHint`)})]}):null}function Mu({api:e,target:t,machines:n,onChanged:r,onNotice:i}){let[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(()=>Du(t)),[l,u]=(0,X.useState)(``),d=Du(t);return Y(),(0,Q.jsxs)(`div`,{className:`machine-remote sandbox-machine`,children:[(0,Q.jsxs)(`div`,{className:`remote-row`,children:[(0,Q.jsx)(`span`,{className:`chip info`,"data-provider":d.provider,children:d.provider===`docker`?d.machine?J(`remote.sandbox.chipDockerOn`,{image:d.image||``,machine:d.machine}):J(`remote.sandbox.chipDocker`,{image:d.image||``}):d.provider===`script`?J(`remote.sandbox.chipScript`):J(`remote.sandbox.chipProxmox`,{vmid:t.host})}),(0,Q.jsx)(`button`,{type:`button`,className:`linkish`,onClick:()=>o(!a),"aria-expanded":a,children:J(a?`settings.common.close`:`remote.sandbox.provider`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,disabled:!!l,onClick:()=>{u(`create`),e.request(`/sandboxes`,{method:`POST`,body:{target_id:t.id}}).then(()=>{i(J(`remote.sandbox.created`)),window.dispatchEvent(new CustomEvent(`lec-sandboxes-changed`))}).catch(e=>i(String(e),!0)).finally(()=>u(``))},children:J(l===`create`?`remote.sandbox.creating`:`remote.sandbox.create`)})]}),a&&(0,Q.jsxs)(`form`,{className:`remote-form`,onSubmit:n=>{n.preventDefault(),u(`save`),e.request(`/targets/${t.id}/sandbox`,{method:`PUT`,body:s}).then(()=>{i(J(`remote.sandbox.saved`,{name:t.name})),r()}).catch(e=>i(String(e),!0)).finally(()=>u(``))},children:[(0,Q.jsx)(Au,{value:s,onChange:c,machines:n}),(0,Q.jsx)(`button`,{type:`submit`,disabled:!!l,children:J(`remote.sandbox.save`)})]}),d.provider===`script`&&a&&(0,Q.jsx)(ju,{api:e,target:t,onNotice:i})]})}function Nu(e){return et(e*1e3,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Pu({api:e,onNotice:t,onOpenTask:n}){let[r,i]=(0,X.useState)(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(0),l=()=>void e.request(`/sandboxes${a?`?all=1`:``}`).then(e=>i(Array.isArray(e)?e:[])).catch(()=>i([]));if((0,X.useEffect)(()=>{l();let e=()=>l();return window.addEventListener(`lec-sandboxes-changed`,e),()=>window.removeEventListener(`lec-sandboxes-changed`,e)},[a]),Y(),!r)return null;let u=(n,r)=>{(r!==`destroy`||confirm(J(`remote.sandbox.destroyConfirm`,{id:n.ext_id})))&&(c(n.id),e.request(`/sandboxes/${n.id}/${r}`,{method:`POST`}).then(l).catch(e=>t(String(e),!0)).finally(()=>c(0)))};return(0,Q.jsxs)(`section`,{className:`sandbox-list`,"aria-label":J(`remote.sandbox.list`),"data-setting":`machines.sandboxes`,children:[(0,Q.jsxs)(`div`,{className:`remote-row`,children:[(0,Q.jsx)(`h3`,{children:J(`remote.sandbox.list`)}),(0,Q.jsxs)(`label`,{className:`check`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),` `,J(`remote.sandbox.showDestroyed`)]})]}),r.length===0&&(0,Q.jsx)(`p`,{className:`sub`,children:J(`remote.sandbox.none`)}),(0,Q.jsx)(`div`,{className:`sandbox-cards`,children:r.map(e=>(0,Q.jsxs)(`article`,{className:`sandbox-card s-${e.status}`,"data-sandbox":e.ext_id,children:[(0,Q.jsxs)(`header`,{children:[(0,Q.jsx)(`b`,{children:e.ext_id}),(0,Q.jsx)(`span`,{className:`chip ${e.status===`running`?`ds`:e.status===`suspended`?`warn`:``}`,children:J(`remote.sandbox.status.${e.status}`,void 0,e.status)})]}),(0,Q.jsxs)(`p`,{className:`sub`,children:[J(`remote.sandbox.where`,{provider:e.provider,machine:e.target_name}),` · `,Nu(e.created_at),e.task_id?(0,Q.jsxs)(Q.Fragment,{children:[` · `,(0,Q.jsxs)(`button`,{type:`button`,className:`linkish`,onClick:()=>n?.(e.task_id),children:[e.task_title,` #`,e.attempt_n]})]}):` · ${J(`remote.sandbox.byHand`)}`]}),!e.destroyed_at&&(0,Q.jsxs)(`div`,{className:`btnrow`,children:[e.can.suspend&&(0,Q.jsx)(`button`,{type:`button`,disabled:s===e.id,onClick:()=>u(e,`suspend`),children:J(`remote.sandbox.suspend`)}),e.can.resume&&(0,Q.jsx)(`button`,{type:`button`,disabled:s===e.id,onClick:()=>u(e,`resume`),children:J(`remote.sandbox.resume`)}),e.can.destroy&&(0,Q.jsx)(`button`,{type:`button`,className:`danger`,disabled:s===e.id,onClick:()=>u(e,`destroy`),children:J(`remote.sandbox.destroy`)})]})]},e.id))})]})}function Fu(e,t){return t&&typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===1&&`__lectern_retained`in t?structuredClone(t):Array.isArray(e)&&Array.isArray(t)?e.map((e,n)=>Fu(e,t[n])):e&&t&&typeof e==`object`&&typeof t==`object`&&!Array.isArray(e)&&!Array.isArray(t)?Object.fromEntries(Object.entries(e).map(([e,n])=>[e,Fu(n,t[e])])):e}function Iu({api:e,onNotice:t,onEnablePush:n,pushAvailable:r=!0,pushUnavailableReason:i,pushUnavailableReasonKind:a,pushEndpoint:o,onUnsubscribePush:s,initialSection:c=`basics`,section:l,projectEdit:u,launchProfilesVersion:d=0,onExternalActionConsumed:f=()=>{},onMetadataRefresh:p,onOpenTerminal:m=()=>{}}){Y();let[h,g]=(0,X.useState)(0),[_,v]=(0,X.useState)(),[y,b]=(0,X.useState)(c),[x,S]=(0,X.useState)([]),[C,w]=(0,X.useState)([]),[T,E]=(0,X.useState)({}),[D,O]=(0,X.useState)(),[k,A]=(0,X.useState)([]),[j,M]=(0,X.useState)([]),[N,P]=(0,X.useState)(``);async function F(){let[t,n,r,i,a,o]=await Promise.all([e.request(`/targets`),e.request(`/projects`),e.request(`/settings`),e.request(`/agents`),e.request(`/launch-profiles`),e.request(`/stats`)]);S(t),w(n),E(r),A(i),M(a),O(o),p?.()}return(0,X.useEffect)(()=>{F().catch(e=>t(String(e),!0))},[]),(0,X.useEffect)(()=>{l?.version&&(b(l.name),l.focus===`search`?g(Date.now()):l.focus&&(v(l.focus),requestAnimationFrame(()=>wu({id:l.focus}))),f(`section`))},[l?.version]),(0,X.useEffect)(()=>{u?.version&&(b(`projects`),requestAnimationFrame(()=>document.getElementById(`project-${u.id}`)?.scrollIntoView({behavior:`smooth`,block:`start`})),f(`project`))},[u?.version,C.length]),(0,X.useEffect)(()=>{d&&(b(`agents`),requestAnimationFrame(()=>document.getElementById(`launch-profiles`)?.scrollIntoView({behavior:`smooth`,block:`start`})),f(`launchProfiles`))},[d]),(0,Q.jsxs)(`section`,{className:`settings-page`,children:[(0,Q.jsxs)(`header`,{children:[(0,Q.jsx)(`h2`,{children:J(`settings.title`)}),(0,Q.jsx)(`p`,{children:J(`settings.subtitle`)})]}),(0,Q.jsx)(Tu,{focusVersion:h,onPick:e=>{b(e.section),v(e.id),requestAnimationFrame(()=>wu(e))}}),(0,Q.jsx)(`nav`,{role:`tablist`,className:`settings-tabs`,"aria-label":J(`settings.title`),children:yu.map(([e,t])=>[e,J(t)]).map(([e,t])=>(0,Q.jsxs)(X.Fragment,{children:[e===`machines`&&(0,Q.jsx)(`span`,{className:`settings-group-label`,role:`presentation`,children:J(`settings.advanced`)}),(0,Q.jsx)(`button`,{"data-settings":e,role:`tab`,"aria-selected":y===e,onKeyDown:t=>{if(t.key!==`ArrowRight`&&t.key!==`ArrowLeft`)return;let n=yu.map(([e])=>e),r=n[(n.indexOf(e)+(t.key===`ArrowRight`?1:n.length-1))%n.length];b(r),requestAnimationFrame(()=>document.querySelector(`[data-settings="${r}"]`)?.focus())},onClick:()=>b(e),children:t})]},e))}),y===`basics`&&(0,Q.jsx)(Ts,{api:e,values:T,onNotice:t,onSection:b,onEnablePush:n,pushAvailable:r,pushUnavailableReason:i,pushEndpoint:o,onChanged:()=>void F().catch(e=>t(String(e),!0))}),y===`connections`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(bs,{api:e,onNotice:t}),(0,Q.jsx)(Mc,{api:e,agents:k,projects:C,onNotice:t,onChanged:F})]}),y===`machines`&&(0,Q.jsx)(Lu,{api:e,rows:x,onChanged:F,onNotice:t}),` `,y===`projects`&&(0,Q.jsx)(zu,{api:e,rows:C,targets:x,onChanged:F,onNotice:t,editRequest:u,onOpenTerminal:m,root:N,setRoot:P}),` `,y===`notifications`&&(0,Q.jsx)(Hu,{api:e,values:T,onEnablePush:n,pushAvailable:r,pushUnavailableReason:i,pushUnavailableReasonKind:a,pushEndpoint:o,onUnsubscribePush:s,onNotice:t}),` `,y===`notifications`&&(0,Q.jsx)(Qo,{}),y===`devices`&&(0,Q.jsx)(qu,{api:e,onNotice:t}),y===`devices`&&(0,Q.jsx)($o,{}),y===`devices`&&(0,Q.jsx)(Pc,{api:e,onNotice:t}),` `,y===`about`&&(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{"data-setting":`about.spend`,children:J(`settings.about.spend`)}),D&&(0,Q.jsx)(`p`,{children:J(`settings.about.spendLine`,{total:Number(D.total_cost_usd).toFixed(2),week:Number(D.last_7d_usd).toFixed(2),tasks:D.tasks_done})}),(0,Q.jsx)(Uc,{api:e}),(0,Q.jsx)(`h3`,{"data-setting":`about.outcomes`,children:J(`settings.about.outcomes`)}),(0,Q.jsx)(Zc,{api:e}),(0,Q.jsx)(Uu,{api:e}),(0,Q.jsx)(Wu,{api:e})]}),` `,y===`budgets`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(el,{api:e,onNotice:t}),(0,Q.jsx)(ol,{api:e,onNotice:t}),(0,Q.jsx)(ll,{api:e,onNotice:t})]}),` `,y===`accounts`&&(0,Q.jsx)(fl,{api:e,targets:x,onNotice:t,onOpenTerminal:m}),` `,y===`plugins`&&(0,Q.jsx)(Qs,{api:e,projects:C,onNotice:t}),y===`appearance`&&(0,Q.jsx)(uu,{}),y===`workspace`&&(0,Q.jsx)(gu,{projects:C,api:e,values:T,onNotice:t}),y===`shortcuts`&&(0,Q.jsx)(vu,{focus:_}),y===`agents`&&(0,Q.jsx)(Gu,{api:e,agents:k,profiles:j,targets:x,onChanged:F,onNotice:t})]})}function Lu({api:e,rows:t,onChanged:n,onNotice:r}){Y();let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)({});return(0,Q.jsxs)(`div`,{className:`settings-grid`,children:[(0,Q.jsxs)(`div`,{className:`btnrow grid-span`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>a(!0),children:J(`settings.targets.addMachine`)}),(0,Q.jsx)(`button`,{type:`button`,id:`ssh-import`,"data-setting":`machines.sshImport`,onClick:()=>s(!0),children:J(`remote.ssh.importButton`)})]}),i&&(0,Q.jsx)(Ru,{api:e,machines:t,onClose:()=>a(!1),onChanged:n}),o&&(0,Q.jsx)(Eu,{api:e,onClose:()=>s(!1),onImported:()=>void n(),onNotice:r}),t.map(i=>(0,Q.jsxs)(`article`,{className:`rowcard`,children:[(0,Q.jsx)(`h3`,{children:i.name}),(0,Q.jsxs)(`p`,{children:[i.kind,i.host&&` · ${i.user}@${i.host}`,` · `,J(`settings.targets.slots`,{n:i.max_concurrent}),i.sandbox?` · ${J(`settings.targets.sandbox`)}`:``]}),(0,Q.jsx)(`button`,{onClick:()=>void e.request(`/targets/${i.id}/check`,{method:`POST`}).then(e=>{let t=e.info_json||e.status||J(`settings.targets.probeComplete`);try{t=JSON.stringify(JSON.parse(t))}catch{}return d(e=>({...e,[i.id]:t})),n()}).catch(e=>r(String(e),!0)),children:J(`settings.targets.probe`)}),u[i.id]&&(0,Q.jsx)(`p`,{className:`sub`,role:`status`,children:u[i.id]}),(0,Q.jsx)(`button`,{onClick:()=>l(i),children:J(`settings.targets.agentCommands`)}),i.kind===`sandbox`?(0,Q.jsx)(Mu,{api:e,target:i,machines:t,onChanged:()=>void n(),onNotice:r}):(0,Q.jsx)(rn,{api:e,target:i,onChanged:()=>void n(),onNotice:r})]},i.id)),(0,Q.jsx)(Pu,{api:e,onNotice:r}),c&&(0,Q.jsx)(Ic,{api:e,target:c,onClose:()=>l(void 0)})]})}function Ru({api:e,machines:t,onClose:n,onChanged:r}){Y();let[i,a]=(0,X.useState)(`ssh`),[o,s]=(0,X.useState)({provider:`docker`}),[c,l]=(0,X.useState)(!1),[u,d]=(0,X.useState)(``);return(0,Q.jsxs)(O,{className:`sheet machine-sheet`,"aria-label":J(`settings.targets.addMachine`),onCancel:n,children:[(0,Q.jsxs)(`div`,{className:`sheet-head`,children:[(0,Q.jsx)(`h2`,{children:J(`settings.targets.addMachine`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:n,"aria-label":J(`settings.common.close`),"data-close":!0,children:`×`})]}),(0,Q.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault();let a=new FormData(t.currentTarget);l(!0),d(``);try{await e.request(`/targets`,{method:`POST`,body:{name:String(a.get(`name`)||``).trim(),kind:i,...i===`ssh`?{host:String(a.get(`host`)||``).trim(),user:String(a.get(`user`)||``).trim(),port:Number(a.get(`port`)||22),key_path:String(a.get(`key_path`)||``).trim()}:{},...i===`sandbox`?{sandbox:!0,host:String(a.get(`template`)||``).trim(),sandbox_config:o}:{}}}),await r(),n()}catch(e){d(String(e))}finally{l(!1)}},children:[(0,Q.jsxs)(`label`,{"data-setting":`machines.name`,children:[J(`settings.targets.name`),(0,Q.jsx)(`input`,{name:`name`,required:!0,maxLength:100})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.targets.connection`),(0,Q.jsxs)(`select`,{value:i,onChange:e=>a(e.target.value),children:[(0,Q.jsx)(`option`,{value:`ssh`,children:J(`settings.targets.remote`)}),(0,Q.jsx)(`option`,{value:`local`,children:J(`settings.targets.local`)}),(0,Q.jsx)(`option`,{value:`sandbox`,children:J(`remote.sandbox.kindOption`)})]})]}),i===`sandbox`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Au,{value:o,onChange:s,machines:t}),o.provider===`proxmox`&&(0,Q.jsxs)(`label`,{children:[J(`remote.sandbox.template`),(0,Q.jsx)(`input`,{name:`template`,required:!0,inputMode:`numeric`,placeholder:`110`})]}),(0,Q.jsx)(`p`,{className:`sub`,children:J(`remote.sandbox.kindHint`)})]}),i===`sandbox`?null:i===`ssh`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{"data-setting":`machines.host`,children:[J(`settings.targets.host`),(0,Q.jsx)(`input`,{name:`host`,required:!0,placeholder:`server.example`})]}),(0,Q.jsxs)(`label`,{"data-setting":`machines.user`,children:[J(`settings.targets.user`),(0,Q.jsx)(`input`,{name:`user`,required:!0,autoComplete:`username`})]}),(0,Q.jsxs)(`label`,{"data-setting":`machines.port`,children:[J(`settings.targets.port`),(0,Q.jsx)(`input`,{name:`port`,type:`number`,min:`1`,max:`65535`,defaultValue:`22`,required:!0})]}),(0,Q.jsxs)(`label`,{"data-setting":`machines.key`,children:[J(`settings.targets.key`),(0,Q.jsx)(`input`,{name:`key_path`,placeholder:`~/.ssh/id_ed25519`})]}),(0,Q.jsx)(`p`,{className:`sub`,children:J(`settings.targets.sshHint`)})]}):(0,Q.jsx)(`p`,{className:`sub`,children:J(`settings.targets.localHint`)}),u&&(0,Q.jsx)(`p`,{role:`alert`,children:u}),(0,Q.jsx)(`button`,{type:`submit`,disabled:c,children:J(c?`settings.targets.adding`:`settings.targets.save`)})]})]})}function zu({api:e,rows:t,targets:n,onChanged:r,onNotice:i,editRequest:a,onOpenTerminal:o,root:s,setRoot:c}){Y();let[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)({}),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)([]),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(),[x,S]=(0,X.useState)(!1);(0,X.useEffect)(()=>{a?.version&&b(t.find(e=>e.id===a.id))},[a?.version,t]),(0,X.useEffect)(()=>{e.request(`/projects/usage`).then(e=>f(Object.fromEntries(e.map(e=>[e.project_id,e])))).catch(()=>{})},[t]);async function C(){if(!h.length)return;let n=t.filter(e=>h.includes(e.id)).map(e=>e.name);if(confirm(J(`settings.projects.deleteConfirm`,{count:n.length,names:n.join(`
-`)}))){for(let t of h)await e.request(`/projects/${t}?cascade=true`,{method:`DELETE`});g([]),m(!1),await r()}}return(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`input`,{id:`pj-search`,value:_,onChange:e=>v(e.target.value),placeholder:J(`settings.projects.filter`)}),(0,Q.jsx)(`button`,{id:`pj-select`,onClick:()=>{m(!p),g([])},children:J(p?`settings.projects.cancelSelection`:`settings.projects.select`)}),p&&h.length>0&&(0,Q.jsx)(`button`,{id:`pj-del`,onClick:()=>void C().catch(e=>i(String(e),!0)),children:J(`settings.projects.deleteSelected`,{count:h.length})})]}),(0,Q.jsxs)(`span`,{id:`pj-count`,children:[t.filter(e=>`${e.name} ${e.repo_path} ${e.target_name||``}`.toLowerCase().includes(_.toLowerCase())).length,` / `,t.length]}),(0,Q.jsx)(`div`,{id:`pj-list`,children:t.filter(e=>`${e.name} ${e.repo_path} ${e.target_name||``}`.toLowerCase().includes(_.toLowerCase())).map(t=>(0,Q.jsxs)(`div`,{id:`project-${t.id}`,className:`pjrow`,role:`button`,tabIndex:0,onClick:()=>!p&&b(t),onKeyDown:e=>{!p&&(e.key===`Enter`||e.key===` `)&&b(t)},children:[p&&(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:h.includes(t.id),onChange:e=>g(n=>e.target.checked?[...n,t.id]:n.filter(e=>e!==t.id))}),` `,J(`settings.projects.selectOne`,{name:t.name})]}),(0,Q.jsx)(`p`,{children:J(`settings.projects.usage`,{tasks:d[t.id]?.tasks||0,open:d[t.id]?.open_tasks||0,sessions:d[t.id]?.sessions||0})}),(0,Q.jsxs)(`div`,{className:`pjmain`,children:[(0,Q.jsx)(`div`,{className:`pjname`,children:t.name}),(0,Q.jsx)(`div`,{className:`pjmeta`,children:t.target_name}),(0,Q.jsx)(`div`,{className:`pjpath`,children:t.repo_path})]}),(0,Q.jsx)(`button`,{"aria-label":J(`settings.projects.shellIn`,{name:t.name}),onClick:n=>{n.stopPropagation(),e.request(`/projects/${t.id}/terminal`,{method:`POST`}).then(e=>{o(e.url,t.name),e.notice&&i(e.notice)}).catch(e=>i(String(e),!0))},children:`⌨`})]},t.id))}),y&&(0,Q.jsxs)(O,{id:`sheet`,open:!0,className:`sheet`,"aria-label":J(`settings.projects.editName`,{name:y.name}),onCancel:()=>b(void 0),children:[(0,Q.jsx)(`button`,{className:`x`,onClick:()=>b(void 0),children:J(`settings.common.close`)}),(0,Q.jsx)(Vu,{api:e,p:y,onChanged:r,onNotice:i})]}),(0,Q.jsxs)(`article`,{children:[(0,Q.jsx)(`h3`,{"data-setting":`projects.import`,children:J(`settings.projects.import`)}),(0,Q.jsx)(`select`,{"aria-label":J(`settings.projects.importTarget`),id:`import-target`,children:n.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,Q.jsx)(`input`,{id:`imp-root`,value:s,onChange:e=>c(e.target.value),placeholder:`/home/you/projects`}),(0,Q.jsx)(`button`,{id:`imp-scan`,onClick:()=>void e.request(`/projects/import/scan?root=${encodeURIComponent(s)}&target_id=${document.querySelector(`#import-target`)?.value}`).then(e=>{u(e),S(!0)}),children:J(`settings.projects.scan`)}),(0,Q.jsx)(`div`,{id:`imp-out`,children:x&&l.length===0?J(`settings.projects.nothingFound`):``}),l.map(e=>(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,disabled:e.registered,defaultChecked:!e.registered,value:e.path}),e.name,` · `,e.path]},e.path)),l.length>0&&(0,Q.jsx)(`button`,{onClick:()=>{let t=[...document.querySelectorAll(`input[type=checkbox]:checked`)].map(e=>e.value);e.request(`/projects/import`,{method:`POST`,body:{target_id:Number(document.querySelector(`#import-target`).value),paths:t,verify:!1}}).then(r).catch(e=>i(String(e),!0))},children:J(`settings.projects.importSelected`)})]})]})}function Bu(e){return J(`settings.projects.capability`,{warn:e.profile===`restricted`?`⚠ `:``,profile:e.profile,servers:e.mcp_servers.join(`, `)||J(`settings.projects.none`),memory:e.memory_dir?J(`settings.projects.memoryShared`):J(`settings.projects.none`),bash:e.allow.includes(`Bash`)?J(`settings.projects.bashUnrestricted`):J(`settings.projects.bashRestricted`)})}function Vu({api:e,p:t,onChanged:n,onNotice:r}){Y();let[i,a]=(0,X.useState)(t.setup_cmd),[o,s]=(0,X.useState)(t.capability_profile),[c,l]=(0,X.useState)(t.default_permission_mode),u=(()=>{try{return JSON.parse(t.default_isolation_json||`{}`)}catch{return{}}})(),[d,f]=(0,X.useState)(u.mode||``),[p,m]=(0,X.useState)(u.network===`deny`?`deny`:`allow`),[h,g]=(0,X.useState)(`{}`),[_,v]=(0,X.useState)(()=>J(`settings.common.loading`)),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!!t.strict_mcp),[C,w]=(0,X.useState)(()=>{try{return JSON.parse(t.skill_sources_json||`[]`).join(`
-`)}catch{return``}}),[T,E]=(0,X.useState)(``),[D,O]=(0,X.useState)(``),[k,A]=(0,X.useState)(t.verify_cmd),[j,M]=(0,X.useState)(``),[N,P]=(0,X.useState)(!!t.ci_loop),[F,I]=(0,X.useState)(t.ci_max_attempts||3),[L,R]=(0,X.useState)(!!t.computer_use),[z,B]=(0,X.useState)(t.claude_terminal_mouse||``),[V,H]=(0,X.useState)();function U(){e.request(`/projects/${t.id}/check-command`).then(H).catch(()=>{})}(0,X.useEffect)(()=>{U()},[t.id]),(0,X.useEffect)(()=>{Promise.all([e.request(`/projects/${t.id}/mcp`),e.request(`/projects/${t.id}/capability`)]).then(([e,t])=>{g(JSON.stringify(e.mcp,null,2)),v(J(`settings.projects.mcpLoaded`)),b(e.revision),S(e.strict_mcp),E(Bu(t))}).catch(()=>{})},[t.id]);async function ee(){await e.request(`/projects/${t.id}`,{method:`PATCH`,body:{setup_cmd:i,capability_profile:o,default_permission_mode:c,isolation:d===``?{mode:``}:{mode:d,network:p}}}),r(J(`settings.projects.saved`)),await n()}function W(n){e.request(`/projects/${t.id}`,{method:`PATCH`,body:n}).then(()=>r(J(`settings.projects.ciSaved`))).catch(e=>r(String(e),!0))}async function te(){try{await e.request(`/projects/${t.id}`,{method:`PATCH`,body:{setup_cmd:i}}),O(J(`settings.projects.setupSaved`)),await n()}catch(e){O(e instanceof Error?e.message:String(e))}}async function G(){try{await e.request(`/projects/${t.id}`,{method:`PATCH`,body:{verify_cmd:k}}),M(J(`settings.projects.checkSaved`)),U(),await n()}catch(e){M(e instanceof Error?e.message:String(e))}}async function ne(){let n;try{n=JSON.parse(h)}catch{return r(J(`settings.projects.mcpInvalid`),!0)}try{let i=await e.request(`/projects/${t.id}/mcp`,{method:`PUT`,body:{mcp:n,revision:y,strict_mcp:x}});b(i.revision),v(J(`settings.projects.mcpSavedStatus`)),r(J(`settings.projects.mcpSaved`))}catch(i){let a=i;if(a.status!==409)return v(a.message||String(i)),r(a.message||String(i),!0);try{let i=await e.request(`/projects/${t.id}/mcp`),a=Fu(n,i.mcp);g(JSON.stringify(a,null,2)),b(i.revision),v(J(`settings.projects.mcpConflict`)),r(J(`settings.projects.mcpConflict`),!0)}catch(e){r(J(`settings.projects.mcpConflictLoad`,{error:String(e)}),!0)}}}function K(){try{let e=JSON.parse(h);return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}catch{return{}}}function q(e,t,n){let r=Object.entries(K()),[i=``,a={}]=r[e]||[],o=a&&typeof a==`object`&&!Array.isArray(a)?{...a}:{},s=i;if(t===`name`)s=n;else if(t===`type`)n===`http`?(o.url=typeof o.url==`string`?o.url:String(o.command||``),delete o.command):(o.command=typeof o.command==`string`?o.command:String(o.url||``),delete o.url);else if(t===`command`)typeof o.url==`string`?o.url=n:o.command=n;else try{let e=JSON.parse(n),t=o.command,r=o.url;for(let e of Object.keys(o))delete o[e];Object.assign(o,e),r===void 0?t!==void 0&&(o.command=t):o.url=r}catch{return}r[e]=[s,o],g(JSON.stringify(Object.fromEntries(r),null,2))}return(0,Q.jsxs)(`article`,{className:`rowcard project-mcp`,children:[(0,Q.jsx)(`h3`,{children:t.name}),(0,Q.jsxs)(`p`,{children:[t.target_name,` · `,t.repo_path]}),(0,Q.jsxs)(`label`,{children:[J(`settings.projects.capabilityLabel`),(0,Q.jsxs)(`select`,{className:`cap-sel`,value:o,onChange:n=>{let i=n.target.value;s(i),e.request(`/projects/${t.id}`,{method:`PATCH`,body:{capability_profile:i}}).then(async()=>{let n=await e.request(`/projects/${t.id}/capability`);E(Bu(n))}).catch(e=>r(String(e),!0))},children:[(0,Q.jsx)(`option`,{value:`restricted`,children:J(`settings.projects.capRestricted`)}),(0,Q.jsx)(`option`,{value:`parity`,children:J(`settings.projects.capParity`)})]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.projects.permission`),(0,Q.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:J(`settings.projects.taskDefault`)}),(0,Q.jsx)(`option`,{children:`default`}),(0,Q.jsx)(`option`,{children:`acceptEdits`}),(0,Q.jsx)(`option`,{children:`plan`}),(0,Q.jsx)(`option`,{children:`bypassPermissions`})]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.projects.isolation`),(0,Q.jsxs)(`select`,{value:d,onChange:e=>f(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:J(`settings.projects.isolationNone`)}),(0,Q.jsx)(`option`,{value:`bwrap`,children:J(`settings.projects.isolationBwrap`)}),(0,Q.jsx)(`option`,{value:`docker`,children:J(`settings.projects.isolationDocker`)})]})]}),d!==``&&(0,Q.jsxs)(`label`,{children:[J(`settings.projects.isolationNetwork`),(0,Q.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),children:[(0,Q.jsx)(`option`,{value:`allow`,children:J(`settings.projects.networkAllow`)}),(0,Q.jsx)(`option`,{value:`deny`,children:J(`settings.projects.networkDeny`)})]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.projects.check`),(0,Q.jsx)(`input`,{"aria-label":J(`settings.projects.check`),value:k,placeholder:V?.source===`auto`?J(`settings.projects.autoDetected`,{command:V.command}):J(`settings.projects.checkExample`),onChange:e=>A(e.target.value)})]}),(0,Q.jsx)(`button`,{onClick:()=>void G(),children:J(`settings.projects.saveCheck`)}),(0,Q.jsx)(`p`,{className:`project-check-status`,role:`status`,children:j||(k?``:V?.source===`auto`?J(`settings.projects.checkAuto`,{command:V.command}):J(`settings.projects.checkNone`))}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":J(`settings.projects.ciFix`),checked:N,onChange:e=>{P(e.target.checked),W({ci_loop:e.target.checked})}}),` `,J(`settings.projects.ciFixHint`)]}),N&&(0,Q.jsxs)(`label`,{children:[J(`settings.projects.ciAttempts`),(0,Q.jsx)(`input`,{type:`number`,"aria-label":J(`settings.projects.ciAttempts`),min:1,max:10,value:F,onChange:e=>I(Math.min(10,Math.max(1,Number(e.target.value)||1))),onBlur:()=>W({ci_max_attempts:F})})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":J(`settings.projects.computerUse`),checked:L,onChange:n=>{let i=n.target.checked;e.request(`/projects/${t.id}`,{method:`PATCH`,body:{computer_use:i}}).then(()=>{R(i),r(J(i?`settings.projects.computerUseOn`:`settings.projects.computerUseOff`))}).catch(e=>r(String(e),!0))}}),` `,J(`settings.projects.computerUseHint`)]}),(0,Q.jsxs)(`label`,{"data-setting":`projects.claudeMouse`,children:[J(`settings.projects.claudeMouse`),(0,Q.jsxs)(`select`,{value:z,onChange:n=>{let i=n.target.value;e.request(`/projects/${t.id}`,{method:`PATCH`,body:{claude_terminal_mouse:i}}).then(()=>{B(i),r(J(`settings.projects.claudeMouseSaved`))}).catch(e=>r(String(e),!0))},children:[(0,Q.jsx)(`option`,{value:``,children:J(`settings.projects.claudeMouseInherit`)}),(0,Q.jsx)(`option`,{value:`1`,children:J(`settings.projects.claudeMouseOn`)}),(0,Q.jsx)(`option`,{value:`0`,children:J(`settings.projects.claudeMouseOff`)})]})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.projects.setup`),(0,Q.jsx)(`textarea`,{"aria-label":J(`settings.projects.setup`),value:i,onChange:e=>a(e.target.value)})]}),(0,Q.jsx)(`button`,{onClick:()=>void te(),children:J(`settings.projects.saveSetup`)}),(0,Q.jsx)(`p`,{className:`project-setup-status`,role:`status`,children:D}),(0,Q.jsx)(`button`,{onClick:()=>void ee().catch(e=>r(String(e),!0)),children:J(`settings.projects.save`)}),(0,Q.jsx)(`p`,{className:`cap-info`,children:T}),(0,Q.jsxs)(`section`,{className:`project-mcp-editor`,children:[(0,Q.jsx)(`h4`,{"data-setting":`projects.mcp`,children:J(`settings.projects.mcpServers`)}),(0,Q.jsx)(`p`,{className:`project-mcp-status`,role:`status`,children:_}),Object.entries(K()).map(([e,t],n)=>{let r=t&&typeof t==`object`&&!Array.isArray(t)?t:{},i=typeof r.url==`string`,a=Object.fromEntries(Object.entries(r).filter(([e])=>e!==`command`&&e!==`url`));return(0,Q.jsxs)(`div`,{className:`mcp-row`,children:[(0,Q.jsx)(`input`,{className:`mcp-name`,"aria-label":J(`settings.projects.serverName`),value:e,onChange:e=>q(n,`name`,e.target.value)}),(0,Q.jsxs)(`select`,{className:`mcp-type`,"aria-label":J(`settings.projects.serverType`),value:i?`http`:`stdio`,onChange:e=>q(n,`type`,e.target.value),children:[(0,Q.jsx)(`option`,{value:`stdio`,children:`stdio`}),(0,Q.jsx)(`option`,{value:`http`,children:`http`})]}),(0,Q.jsx)(`input`,{className:`mcp-command`,"aria-label":J(i?`settings.projects.serverUrl`:`settings.projects.serverCommand`),value:String(i?r.url||``:r.command||``),onChange:e=>q(n,`command`,e.target.value)}),(0,Q.jsx)(`textarea`,{className:`mcp-extra`,"aria-label":J(`settings.projects.serverExtra`),value:JSON.stringify(a,null,2),onChange:e=>q(n,`extra`,e.target.value)}),(0,Q.jsx)(`button`,{className:`mcp-remove`,onClick:()=>{let e=Object.entries(K());e.splice(n,1),g(JSON.stringify(Object.fromEntries(e),null,2))},children:J(`settings.common.remove`)})]},`${n}-${e}`)}),(0,Q.jsx)(`button`,{className:`project-mcp-add`,onClick:()=>{let e=Object.entries(K());e.push([`server_${e.length+1}`,{command:``}]),g(JSON.stringify(Object.fromEntries(e),null,2))},children:J(`settings.projects.addServer`)})]}),(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),` `,J(`settings.projects.strictMcp`)]}),(0,Q.jsx)(`button`,{className:`project-mcp-save`,onClick:()=>void ne(),children:J(`settings.projects.saveMcp`)}),(0,Q.jsx)(ll,{api:e,projectId:t.id,onNotice:r}),(0,Q.jsx)(Rs,{api:e,projectId:t.id,defaultAgent:t.default_agent,onNotice:r,sourceText:C,onSourceText:w}),(0,Q.jsx)(Vs,{api:e,projectId:t.id,defaultAgent:t.default_agent,onNotice:r}),(0,Q.jsx)(ic,{api:e,projectId:t.id,onNotice:r}),(0,Q.jsx)(jc,{api:e,projectId:t.id,onNotice:r}),(0,Q.jsx)(`button`,{onClick:()=>{confirm(J(`settings.projects.deleteOne`,{name:t.name}))&&e.request(`/projects/${t.id}?cascade=true`,{method:`DELETE`}).then(n)},children:J(`settings.projects.delete`)})]})}function Hu({api:e,values:t,onEnablePush:n,pushAvailable:r=!0,pushUnavailableReason:i,pushUnavailableReasonKind:a,pushEndpoint:o,onUnsubscribePush:s,onNotice:c}){Y();let[l,u]=(0,X.useState)(String(t.discord_webhook??``)),[d,f]=(0,X.useState)(String(t.ntfy_server??``)),[p,m]=(0,X.useState)(String(t.ntfy_topic??``)),h=[[`alert_waiting_permission`,J(`settings.notifications.alertPermission`)],[`alert_waiting_input`,J(`settings.notifications.alertInput`)],[`alert_idle`,J(`settings.notifications.alertIdle`)],[`alert_error`,J(`settings.notifications.alertError`)],[`alert_compacting`,J(`settings.notifications.alertCompacting`)]],[g,_]=(0,X.useState)(()=>Object.fromEntries(h.map(([e])=>[e,String(t[e]??``)!==`0`]))),[v,y]=(0,X.useState)([]);return(0,X.useEffect)(()=>void e.request(`/push/subscriptions`).then(y).catch(()=>{}),[o]),(0,Q.jsxs)(`article`,{children:[(0,Q.jsx)(`h3`,{children:J(`settings.section.notifications`)}),(0,Q.jsxs)(`div`,{className:`push-status`,"data-setting":`notifications.push`,children:[r?o?(0,Q.jsx)(`p`,{className:`subhint`,id:`push-enabled-hint`,children:J(`settings.notifications.enabled`)}):(0,Q.jsx)(`button`,{id:`s-enable-push`,onClick:n,children:J(`settings.notifications.enable`)}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`subhint`,id:`push-unavailable-reason`,children:i||J(`settings.notifications.unavailable`)}),a===`ios-not-installed`&&(0,Q.jsxs)(`ol`,{className:`push-ios-steps`,id:`push-ios-steps`,children:[(0,Q.jsxs)(`li`,{children:[J(`settings.notifications.iosStep1`),` `,(0,Q.jsx)(`strong`,{children:J(`settings.notifications.iosShare`)}),` `,J(`settings.notifications.iosStep1After`)]}),(0,Q.jsxs)(`li`,{children:[J(`settings.notifications.iosStep2`),` `,(0,Q.jsx)(`strong`,{children:J(`settings.notifications.iosAddToHome`)}),J(`settings.notifications.iosStepEnd`)]}),(0,Q.jsxs)(`li`,{children:[J(`settings.notifications.iosStep3`),` `,(0,Q.jsx)(`strong`,{children:J(`settings.notifications.iosAdd`)}),` `,J(`settings.notifications.iosStep3After`)]}),(0,Q.jsx)(`li`,{children:J(`settings.notifications.iosStep4`)}),(0,Q.jsxs)(`li`,{children:[J(`settings.notifications.iosStep5`),` `,(0,Q.jsx)(`strong`,{children:J(`settings.notifications.enable`)}),J(`settings.notifications.iosStepEnd`)]})]})]}),v.length>0&&(0,Q.jsx)(`ul`,{className:`push-devices`,id:`push-devices`,children:v.map(e=>(0,Q.jsxs)(`li`,{"data-endpoint":e.endpoint,children:[(0,Q.jsxs)(`span`,{children:[hl(e.endpoint),e.endpoint===o&&(0,Q.jsxs)(`em`,{className:`push-this-device`,children:[` · `,J(`settings.notifications.thisDevice`)]})]}),s&&(0,Q.jsx)(`button`,{className:`b`,"aria-label":J(`settings.notifications.unsubscribeName`,{name:hl(e.endpoint)}),onClick:()=>{s(e.endpoint),y(t=>t.filter(t=>t.id!==e.id))},children:J(`settings.notifications.unsubscribe`)})]},e.id))})]}),(0,Q.jsxs)(`label`,{"data-setting":`notifications.sinks`,children:[J(`settings.notifications.discord`),(0,Q.jsx)(`input`,{id:`s-discord`,value:l,onChange:e=>u(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.notifications.ntfyServer`),(0,Q.jsx)(`input`,{id:`s-ntfy-server`,value:d,onChange:e=>f(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.notifications.ntfyTopic`),(0,Q.jsx)(`input`,{id:`s-ntfy-topic`,value:p,onChange:e=>m(e.target.value)})]}),(0,Q.jsx)(`button`,{id:`s-save`,onClick:()=>void e.request(`/settings`,{method:`PUT`,body:{discord_webhook:l.trim(),ntfy_server:d.trim(),ntfy_topic:p.trim()}}).then(()=>c(J(`settings.notifications.sinksSaved`))),children:J(`settings.notifications.saveSinks`)}),(0,Q.jsx)(`button`,{onClick:()=>void e.request(`/settings/test-notification`,{method:`POST`}).then(()=>c(J(`settings.notifications.testSent`))),children:J(`settings.notifications.sendTest`)}),(0,Q.jsx)(`h4`,{"data-setting":`notifications.sessionAlerts`,children:J(`settings.notifications.sessionAlerts`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`settings.notifications.sessionAlertsHint`)}),h.map(([e,t])=>(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:g[e],onChange:t=>_(n=>({...n,[e]:t.target.checked}))}),` `,t]},e)),(0,Q.jsx)(`button`,{id:`s-save-alerts`,onClick:()=>void e.request(`/settings`,{method:`PUT`,body:Object.fromEntries(h.map(([e])=>[e,g[e]?`1`:`0`]))}).then(()=>c(J(`settings.notifications.alertsSaved`))),children:J(`settings.notifications.saveAlerts`)})]})}function Uu({api:e}){Y();let[t,n]=(0,X.useState)();if((0,X.useEffect)(()=>{e.request(`/whoami`).then(n)},[]),!t)return null;let r=t.kind===`tailscale`?`tailscale · ${t.login}${t.node?` (${t.node})`:``}`:t.kind===`token`?J(`settings.about.accessToken`):t.kind===`device`?t.login?J(`settings.about.pairedDeviceAs`,{login:t.login}):J(`settings.about.pairedDevice`):J(`settings.about.local`);return(0,Q.jsxs)(`article`,{id:`whoami`,children:[(0,Q.jsx)(`h3`,{"data-setting":`about.signedIn`,children:J(`settings.about.signedIn`)}),(0,Q.jsx)(`p`,{children:J(`settings.about.identity`,{identity:r,mode:t.mode})})]})}function Wu({api:e}){Y();let[t,n]=(0,X.useState)();return(0,X.useEffect)(()=>{e.request(`/health`).then(n)},[]),(0,Q.jsxs)(`article`,{id:`running-build`,children:[(0,Q.jsx)(`h3`,{"data-setting":`about.build`,children:J(`settings.about.build`)}),(0,Q.jsx)(`p`,{children:t?J(`settings.about.buildLine`,{version:t.version,revision:t.build?.revision?.slice(0,12)||J(`settings.about.revisionUnknown`),state:t.build?.modified===!0?J(`settings.about.localChanges`):t.build?.modified===!1?J(`settings.about.clean`):J(`settings.about.buildUnknown`)}):J(`settings.common.loading`)})]})}function Gu({api:e,agents:t,profiles:n,targets:r,onChanged:i,onNotice:a}){Y();let[o,s]=(0,X.useState)(),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(!1);(0,X.useEffect)(()=>{Nt(e).then(p)},[t.map(e=>e.name).join(`,`)]);async function g(t){p(t),h(!0);try{let n=await Pt(e,t);p(n)}catch(e){a(String(e),!0)}finally{h(!1)}}function _(e,t){g(t?[...f,e]:f.filter(t=>t!==e))}function v(e,t){let n=f.indexOf(e);if(n<0)return;let r=n+t;if(r<0||r>=f.length)return;let i=[...f],a=i[n],o=i[r];a!==void 0&&o!==void 0&&(i[n]=o,i[r]=a,g(i))}let y=t.filter(e=>!f.includes(e.name));return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{"data-setting":`agents.menus`,children:J(`settings.agentsTab.menus`)}),(0,Q.jsx)(`p`,{className:`sub`,children:J(`settings.agentsTab.menusHint`)}),(0,Q.jsx)(`ul`,{className:`agent-menu-order`,"aria-label":J(`settings.agentsTab.shown`),children:f.map((e,t)=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!0,disabled:m,onChange:()=>_(e,!1)}),` `,e]}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":J(`settings.moveUp`,{name:e}),disabled:m||t===0,onClick:()=>v(e,-1),children:`↑`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":J(`settings.moveDown`,{name:e}),disabled:m||t===f.length-1,onClick:()=>v(e,1),children:`↓`})]},e))}),y.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`sub`,children:J(`settings.agentsTab.hiddenHint`)}),(0,Q.jsx)(`ul`,{className:`agent-menu-hidden`,"aria-label":J(`settings.agentsTab.hidden`),children:y.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`label`,{children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:!1,disabled:m,onChange:()=>_(e.name,!0)}),` `,e.name]})},e.name))})]}),(0,Q.jsx)(`h3`,{"data-setting":`agents.runners`,children:J(`settings.agentsTab.runners`)}),t.map(n=>(0,Q.jsxs)(`article`,{className:`agent-card`,children:[(0,Q.jsxs)(`b`,{children:[n.name,n.builtin?` · ${J(`settings.agentsTab.builtin`)}`:` · ${J(`settings.agentsTab.custom`)}`]}),(0,Q.jsxs)(`span`,{children:[n.command,` · `,n.model_flag||J(`settings.agentsTab.noModelFlag`)]}),(0,Q.jsx)(`button`,{onClick:()=>s(n),children:J(`settings.common.edit`)}),!n.builtin&&(0,Q.jsx)(`button`,{onClick:()=>void e.request(`/agents`,{method:`PUT`,body:t.filter(e=>!e.builtin&&e.name!==n.name)}).then(i),children:J(`settings.common.delete`)})]},n.name)),(0,Q.jsx)(`button`,{onClick:()=>s(`new`),children:J(`settings.agentsTab.addAgent`)}),(0,Q.jsx)(`h3`,{id:`launch-profiles`,"data-setting":`agents.profiles`,children:J(`settings.agentsTab.profiles`)}),n.map(t=>(0,Q.jsxs)(`article`,{children:[(0,Q.jsx)(`b`,{children:t.name}),` · `,t.agent,` · `,t.model,t.description&&(0,Q.jsx)(`p`,{children:t.description}),(0,Q.jsx)(`button`,{onClick:()=>l(t),children:J(`settings.agentsTab.editProfile`)}),(0,Q.jsx)(`button`,{onClick:()=>void e.request(`/launch-profiles/${t.id}`,{method:`DELETE`}).then(i),children:J(`settings.agentsTab.deleteProfile`)})]},t.id)),(0,Q.jsx)(`button`,{onClick:()=>l(`new`),children:J(`settings.agentsTab.newProfile`)}),(0,Q.jsx)(`button`,{onClick:()=>d(!0),children:J(`settings.agentsTab.starters`)}),u&&(0,Q.jsx)(lr,{api:e,onClose:()=>d(!1),onChange:()=>void i()}),o&&(0,Q.jsx)(Is,{api:e,source:o===`new`?void 0:o,all:t,targets:r,onClose:()=>s(void 0),onSaved:i,onNotice:a}),c&&(0,Q.jsx)(Ku,{api:e,source:c===`new`?void 0:c,agents:t,onClose:()=>l(void 0),onSaved:i,onNotice:a})]})}function Ku({api:e,source:t,agents:n,onClose:r,onSaved:i,onNotice:a}){Y();let[o,s]=(0,X.useState)(t?.name||``),[c,l]=(0,X.useState)(t?.agent||n[0]?.name||`claude`),[u,d]=(0,X.useState)(t?.command||``),[f,p]=(0,X.useState)(t?.model||``),[m,h]=(0,X.useState)(t?.description||``),[g,_]=(0,X.useState)(t?.instructions||``),[v,y]=(0,X.useState)(()=>{try{return JSON.stringify(JSON.parse(t?.env_json||`{}`),null,2)}catch{return`{}`}}),[b,x]=(0,X.useState)(!1);async function S(){let n;try{n=JSON.parse(v)}catch{throw Error(J(`settings.profileEditor.envInvalid`))}if(!n||Array.isArray(n)||typeof n!=`object`||Object.values(n).some(e=>typeof e!=`string`))throw Error(J(`settings.profileEditor.envShape`));if(!o.trim())throw Error(J(`settings.profileEditor.nameRequired`));x(!0);try{await e.request(t?`/launch-profiles/${t.id}`:`/launch-profiles`,{method:t?`PUT`:`POST`,body:{name:o.trim(),agent:c,command:u.trim(),model:f.trim(),env_json:JSON.stringify(n),description:m.trim(),instructions:g.trim()}}),await i(),r()}finally{x(!1)}}return(0,Q.jsxs)(O,{className:`launch-profiles`,"aria-label":J(`settings.agentsTab.profiles`),onCancel:e=>{b&&e.preventDefault()},children:[(0,Q.jsx)(`h2`,{children:J(t?`settings.profileEditor.edit`:`settings.profileEditor.new`)}),(0,Q.jsx)(`button`,{disabled:b,onClick:r,children:J(`settings.common.close`)}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.name`),(0,Q.jsx)(`input`,{value:o,onChange:e=>s(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.agent`),(0,Q.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),children:n.map(e=>(0,Q.jsx)(`option`,{children:e.name},e.name))})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.description`),(0,Q.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.instructions`),(0,Q.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value)})]}),(0,Q.jsx)(`p`,{className:`lp-hint`,children:rr()}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.command`),(0,Q.jsx)(`input`,{value:u,onChange:e=>d(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.model`),(0,Q.jsx)(`input`,{value:f,onChange:e=>p(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`settings.profileEditor.environment`),(0,Q.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value)})]}),(0,Q.jsx)(`button`,{disabled:b,onClick:()=>void S().catch(e=>a(String(e),!0)),children:J(`settings.profileEditor.save`)})]})}function qu({api:e,onNotice:t}){Y();let[n,r]=(0,X.useState)(!1);return(0,Q.jsxs)(`article`,{className:`phone-connect`,children:[(0,Q.jsx)(`h3`,{children:J(`phone.title`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`basics.phoneHint`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b ok`,id:`devices-phone`,onClick:()=>r(!0),children:J(`phone.title`)}),n&&(0,Q.jsx)(ws,{api:e,onNotice:t,onClose:()=>r(!1)})]})}var Ju=()=>({bold:[`**`,`**`,J(`trackers.format.hint.bold`)],italic:[`*`,`*`,J(`trackers.format.hint.italic`)],strike:[`~~`,`~~`,J(`trackers.format.hint.strike`)],code:["`","`",J(`trackers.format.hint.code`)]});function Yu(e,t,n,r){let i=e.slice(t,n),a=Ju()[r];if(a){let[r,o,s]=a;if(e.slice(t-r.length,t)===r&&e.slice(n,n+o.length)===o)return{text:e.slice(0,t-r.length)+i+e.slice(n+o.length),start:t-r.length,end:n-r.length};let c=i||s;return{text:e.slice(0,t)+r+c+o+e.slice(n),start:t+r.length,end:t+r.length+c.length}}if(r===`link`){let r=i||J(`trackers.format.hint.link`),a=`[${r}](https://)`,o=t+r.length+3;return{text:e.slice(0,t)+a+e.slice(n),start:o,end:o+8}}if(r===`codeblock`){let r=t>0&&e[t-1]!==`
-`?`
-`:``,a=i||J(`trackers.format.hint.code`),o=`${r}\`\`\`\n${a}\n\`\`\`\n`,s=t+r.length+4;return{text:e.slice(0,t)+o+e.slice(n),start:s,end:s+a.length}}let o=e.lastIndexOf(`
-`,t-1)+1,s=e.indexOf(`
-`,n);s<0&&(s=e.length);let c=e.slice(o,s).split(`
-`),l=e=>r===`heading`?`## `:r===`bullet`?`- `:r===`number`?`${e+1}. `:`> `,u=r===`heading`?/^#{1,6}\s/:r===`bullet`?/^[-*+]\s/:r===`number`?/^\d+[.)]\s/:/^>\s?/,d=c.every(e=>u.test(e)),f=c.map((e,t)=>d?e.replace(u,``):l(t)+e).join(`
-`);return{text:e.slice(0,o)+f+e.slice(s),start:o,end:o+f.length}}var Xu=()=>[{format:`bold`,label:`B`,title:J(`trackers.editor.bold`)},{format:`italic`,label:`I`,title:J(`trackers.editor.italic`)},{format:`strike`,label:`S`,title:J(`trackers.editor.strike`)},{format:`code`,label:`>`,title:J(`trackers.editor.code`)},{format:`link`,label:`🔗`,title:J(`trackers.editor.link`)},{format:`heading`,label:`H`,title:J(`trackers.editor.heading`)},{format:`bullet`,label:`•`,title:J(`trackers.editor.bullet`)},{format:`number`,label:`1.`,title:J(`trackers.editor.number`)},{format:`quote`,label:`❝`,title:J(`trackers.editor.quote`)},{format:`codeblock`,label:`{ }`,title:J(`trackers.editor.codeblock`)}];function Zu({value:e,onChange:t,placeholder:n,rows:r=5,label:i,autoFocus:a}){Y();let[o,s]=(0,X.useState)(!1),c=(0,X.useRef)(null);function l(n){let r=c.current;if(!r)return;let i=Yu(e,r.selectionStart,r.selectionEnd,n);t(i.text),requestAnimationFrame(()=>{r.focus(),r.setSelectionRange(i.start,i.end)})}return(0,Q.jsxs)(`div`,{className:`th-editor`,children:[(0,Q.jsxs)(`div`,{className:`th-editor-bar`,role:`toolbar`,"aria-label":J(`trackers.editor.toolbar`,{label:i}),children:[(0,Q.jsxs)(`div`,{className:`th-editor-tabs`,children:[(0,Q.jsx)(`button`,{type:`button`,className:o?``:`on`,"aria-pressed":!o,onClick:()=>s(!1),children:J(`trackers.editor.write`)}),(0,Q.jsx)(`button`,{type:`button`,className:o?`on`:``,"aria-pressed":o,onClick:()=>s(!0),children:J(`trackers.editor.preview`)})]}),!o&&(0,Q.jsx)(`div`,{className:`th-editor-tools`,children:Xu().map(e=>(0,Q.jsx)(`button`,{type:`button`,title:e.title,"aria-label":e.title,onMouseDown:e=>e.preventDefault(),onClick:()=>l(e.format),children:e.label},e.format))})]}),o?(0,Q.jsx)(`div`,{className:`th-editor-preview th-md`,children:e.trim()?(0,Q.jsx)(Ji,{text:e}):(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.editor.nothingToPreview`)})}):(0,Q.jsx)(`textarea`,{ref:c,"aria-label":i,rows:r,value:e,placeholder:n,autoFocus:a,onChange:e=>t(e.target.value),onKeyDown:e=>{if(!(e.ctrlKey||e.metaKey))return;let t={b:`bold`,i:`italic`,k:`link`}[e.key.toLowerCase()];t&&(e.preventDefault(),l(t))}})]})}var Qu=()=>({open:J(`trackers.state.open`),closed:J(`trackers.state.closed`),merged:J(`trackers.state.merged`),draft:J(`trackers.state.draft`)});function $u({item:e}){Y();let t=`open`,n=e.state;return t=sc(e)?{completed:`merged`,done:`merged`,canceled:`closed`,started:`open`,indeterminate:`open`}[e.status_type||``]||`neutral`:e.draft&&e.state===`open`?n=`draft`:e.state,e.source!==`linear`&&e.source!==`jira`&&(n=Qu()[n]||n),(0,Q.jsx)(`span`,{className:`th-state th-state-${t}`,children:n})}var ed={pass:`✓`,fail:`✕`,pending:`●`,skipping:`–`,cancel:`⊘`,none:``};function td({checks:e}){if(Y(),!e||e===`none`)return null;let t={pass:J(`trackers.checks.pass`),fail:J(`trackers.checks.fail`),pending:J(`trackers.checks.pending`)}[e]||e;return(0,Q.jsxs)(`span`,{className:`th-badge th-checks-${e}`,title:t,children:[(0,Q.jsx)(`i`,{"aria-hidden":`true`,children:ed[e]}),(0,Q.jsx)(`span`,{className:`th-badge-text`,children:t})]})}var nd=()=>({pass:J(`trackers.checkStatus.pass`),fail:J(`trackers.checkStatus.fail`),pending:J(`trackers.checkStatus.pending`),skipping:J(`trackers.checkStatus.skipping`),cancel:J(`trackers.checkStatus.cancel`),none:J(`trackers.checkStatus.none`)});function rd({check:e}){return Y(),(0,Q.jsx)(`i`,{className:`th-check-icon th-checks-${e.status}`,"aria-label":nd()[e.status]||e.status,children:ed[e.status]})}function id({review:e}){if(Y(),!e)return null;let t={approved:J(`trackers.review.approved`),changes_requested:J(`trackers.review.changesRequested`),review_required:J(`trackers.review.reviewRequired`)}[e]||e;return(0,Q.jsx)(`span`,{className:`th-badge th-review-${e}`,children:t})}function ad({labels:e,onRemove:t}){return Y(),e.length?(0,Q.jsx)(`span`,{className:`th-labels`,children:e.map(e=>(0,Q.jsxs)(`span`,{className:`th-label`,style:Tc(e.color,document.documentElement.dataset.theme===`light`?`light`:`dark`),children:[e.name,t&&(0,Q.jsx)(`button`,{type:`button`,className:`th-x`,"aria-label":J(`trackers.labels.remove`,{name:e.name}),onClick:()=>t(e.name),children:`×`})]},e.name))}):null}function od({reactions:e}){return Y(),e?.length?(0,Q.jsx)(`span`,{className:`th-reactions`,children:e.map(e=>(0,Q.jsxs)(`span`,{className:`th-reaction`,children:[e.emoji,` `,e.count]},e.emoji))}):null}function sd({reactions:e,onReact:t,label:n}){Y();let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(!1);return t?(0,Q.jsxs)(`span`,{className:`th-reactions`,children:[(e||[]).map(e=>{let n=lc.find(([,t])=>t===e.emoji)?.[0];return(0,Q.jsxs)(`button`,{type:`button`,className:`th-reaction`,disabled:a||!n,"aria-label":J(`trackers.reactions.reactCount`,{emoji:e.emoji,n:e.count}),onClick:()=>{n&&(o(!0),t(n).finally(()=>o(!1)))},children:[e.emoji,` `,e.count]},e.emoji)}),(0,Q.jsxs)(`span`,{className:`th-react-add`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`th-reaction th-react-open`,"aria-label":J(`trackers.reactions.add`,{label:n}),"aria-expanded":r,onClick:()=>i(!r),children:`☺+`}),r&&(0,Q.jsx)(`span`,{className:`th-react-menu`,role:`menu`,children:lc.map(([e,n])=>(0,Q.jsx)(`button`,{type:`button`,role:`menuitem`,"aria-label":J(`trackers.reactions.react`,{emoji:e}),disabled:a,onClick:()=>{i(!1),o(!0),t(e).finally(()=>o(!1))},children:n},e))})]})]}):(0,Q.jsx)(od,{reactions:e})}function cd({name:e}){Y();let t=(e||`?`).replace(/^@/,``).slice(0,1).toUpperCase(),n=0;for(let t of e||``)n=(n*31+t.charCodeAt(0))%360;return(0,Q.jsx)(`span`,{className:`th-avatar`,style:{background:`hsl(${n} 45% 32%)`},"aria-hidden":`true`,children:t})}var ld=()=>({approved:J(`trackers.timeline.review.approved`),changes_requested:J(`trackers.timeline.review.changesRequested`),commented:J(`trackers.timeline.review.commented`),dismissed:J(`trackers.timeline.review.dismissed`)});function ud({events:e,onComment:t,onReact:n,placeholder:r}){Y();let[i,a]=(0,X.useState)(``),[o,s]=(0,X.useState)(!1);return(0,Q.jsxs)(`div`,{className:`th-timeline`,children:[e.length===0&&(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.timeline.empty`)}),e.map((e,t)=>e.kind===`comment`?(0,Q.jsxs)(`article`,{className:`th-comment`,children:[(0,Q.jsxs)(`header`,{children:[(0,Q.jsx)(cd,{name:e.author}),(0,Q.jsx)(`b`,{children:e.author||J(`trackers.timeline.someone`)}),(0,Q.jsx)(`time`,{title:e.at,children:wc(e.at)})]}),(0,Q.jsx)(`div`,{className:`th-md`,children:(0,Q.jsx)(Ji,{text:e.body||``})}),(0,Q.jsx)(sd,{reactions:e.reactions,label:e.author?J(`trackers.reactions.commentBy`,{name:e.author}):J(`trackers.reactions.thisComment`),onReact:n&&e.id?t=>n(e.id,t):void 0})]},t):(0,Q.jsxs)(`div`,{className:`th-event th-event-${e.kind}${e.state?` th-event-`+e.state:``}`,children:[(0,Q.jsx)(`span`,{className:`th-event-dot`,"aria-hidden":`true`}),e.kind===`commit`?(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:e.author}),` `,J(`trackers.timeline.committed`),` `,(0,Q.jsx)(`code`,{children:e.state}),` `,e.body]}):e.kind===`review`?(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:e.author}),` `,ld()[e.state||``]||J(`trackers.timeline.review.commented`),e.body?(0,Q.jsxs)(Q.Fragment,{children:[`: `,e.body]}):null]}):(0,Q.jsxs)(`span`,{children:[e.author?(0,Q.jsxs)(`b`,{children:[e.author,` `]}):null,e.body]}),(0,Q.jsx)(`time`,{title:e.at,children:wc(e.at)})]},t)),t&&(0,Q.jsxs)(`form`,{className:`th-composer`,onSubmit:e=>{e.preventDefault(),i.trim()&&!o&&(s(!0),t(i.trim()).then(()=>a(``)).finally(()=>s(!1)))},children:[(0,Q.jsx)(Zu,{label:J(`trackers.timeline.commentField`),placeholder:r??J(`trackers.timeline.placeholder`),value:i,onChange:a,rows:3}),(0,Q.jsx)(`button`,{className:`b ok`,type:`submit`,disabled:o||!i.trim(),children:J(o?`trackers.timeline.posting`:`trackers.timeline.comment`)})]})]})}function dd({label:e,options:t,onPick:n,busy:r}){Y();let[i,a]=(0,X.useState)(!1),[o,s]=(0,X.useState)(``),c=`th-pick-${e.replace(/\W+/g,`-`).toLowerCase()}`;return i?(0,Q.jsxs)(`form`,{className:`th-picker`,onSubmit:e=>{e.preventDefault(),o.trim()&&(n(o.trim()),s(``),a(!1))},children:[(0,Q.jsx)(`input`,{"aria-label":e,list:c,autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:J(`trackers.picker.placeholder`)}),(0,Q.jsx)(`datalist`,{id:c,children:t.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.hint},e.value))}),(0,Q.jsx)(`button`,{type:`submit`,className:`b ok`,disabled:!o.trim(),children:J(`trackers.picker.add`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,onClick:()=>a(!1),children:J(`trackers.cancel`)})]}):(0,Q.jsxs)(`button`,{type:`button`,className:`th-add`,onClick:()=>a(!0),disabled:r,children:[`+ `,e]})}function fd({api:e,projectId:t,item:n,title:r,branch:i,pr:a,onClose:o,onStarted:s,onNotice:c}){Y();let[l,u]=(0,X.useState)(`session`),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(i||``),[_,v]=(0,X.useState)(``),[y,b]=(0,X.useState)(``),[x,S]=(0,X.useState)(!0),[C,w]=(0,X.useState)(!1);(0,X.useEffect)(()=>{e.request(`/agents`).then(e=>f(e.map(e=>e.name).filter(e=>e&&e!==`shell`))).catch(()=>f([]))},[e]);async function T(){w(!0);try{let r={source:n.source,kind:n.kind,id:n.id,connection_id:n.connection_id??0,mode:a?`session`:l,agent:p,branch:a?``:h.trim(),base:_.trim(),note:y.trim(),dispatch:x};s(await e.request(`/projects/${t}/work/start`,{method:`POST`,body:r}))}catch(e){c(Dc(e),!0)}finally{w(!1)}}return(0,Q.jsx)(O,{className:`th-start`,"aria-labelledby":`th-start-title`,onCancel:o,children:(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),T()},children:[(0,Q.jsxs)(`header`,{className:`sheet-head`,children:[(0,Q.jsx)(`h2`,{id:`th-start-title`,children:J(`trackers.start.title`,{mark:dc(n)})}),(0,Q.jsx)(`button`,{type:`button`,className:`x`,"aria-label":J(`trackers.close`),"data-close":!0,onClick:o,children:`×`})]}),(0,Q.jsx)(`p`,{className:`th-muted th-start-title`,children:r}),!a&&(0,Q.jsxs)(`div`,{className:`th-seg`,role:`radiogroup`,"aria-label":J(`trackers.start.startAs`),children:[(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===`session`,className:l===`session`?`on`:``,onClick:()=>u(`session`),children:[J(`trackers.start.session`),(0,Q.jsx)(`small`,{children:J(`trackers.start.sessionHint`)})]}),(0,Q.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":l===`task`,className:l===`task`?`on`:``,onClick:()=>u(`task`),children:[J(`trackers.start.task`),(0,Q.jsx)(`small`,{children:J(`trackers.start.taskHint`)})]})]}),(0,Q.jsxs)(`label`,{children:[J(`trackers.start.agent`),(0,Q.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:J(`trackers.start.projectDefault`)}),d.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))]})]}),a?(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.start.prHint`)}):l===`session`?(0,Q.jsxs)(`label`,{children:[J(`trackers.start.branch`),(0,Q.jsx)(`input`,{id:`th-start-branch`,value:h,onChange:e=>g(e.target.value),spellCheck:!1,autoCapitalize:`off`})]}):null,!a&&(0,Q.jsxs)(`label`,{children:[J(`trackers.start.baseBranch`),(0,Q.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:J(`trackers.start.basePlaceholder`),spellCheck:!1,autoCapitalize:`off`})]}),(0,Q.jsxs)(`label`,{children:[J(`trackers.start.note`),(0,Q.jsx)(`textarea`,{rows:2,value:y,onChange:e=>b(e.target.value),placeholder:J(`trackers.start.notePlaceholder`)})]}),!a&&l===`task`&&(0,Q.jsxs)(`label`,{className:`th-check`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),` `,J(`trackers.start.dispatchNow`)]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{type:`submit`,className:`b ok grow`,id:`th-start-go`,disabled:C,children:J(C?`trackers.starting`:a||l===`session`?`trackers.startSession`:x?`trackers.start.createAndDispatch`:`trackers.start.createTask`)}),(0,Q.jsx)(`button`,{type:`button`,className:`b`,onClick:o,children:J(`trackers.cancel`)})]})]})})}function pd({api:e,projectId:t,item:n,onClose:r,onOpen:i,onNotice:a,onChanged:o,onStarted:s}){Y();let c=oc(n.source),[l,u]=(0,X.useState)(),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)(),[x,S]=(0,X.useState)(!1),C=Ec(t,n),w=(0,X.useCallback)(async()=>{f(``);try{u(await e.request(C))}catch(e){f(Dc(e))}},[e,C]);(0,X.useEffect)(()=>{u(void 0),w()},[w]),(0,X.useEffect)(()=>{c&&e.request(`/projects/${t}/forge/meta`).then(g).catch(()=>{})},[e,c,t]);async function T(t,n,r){m(!0);try{let i=await e.request(`${C}/${t}`,{method:`POST`,body:n});a(r),`id`in i?u(i):await w(),o()}catch(e){a(Dc(e),!0)}finally{m(!1)}}async function E(){if(y!==void 0){m(!0);try{let t=await e.request(`${C}/description`,{method:`POST`,body:{body:y,confirm_lossy:x}});t&&`id`in t?u(t):await w(),b(void 0),a(J(`trackers.issue.descriptionSaved`)),o()}catch(e){a(Dc(e),!0)}finally{m(!1)}}}let D=(0,Q.jsxs)(`div`,{className:`th-detail-bar`,children:[(0,Q.jsxs)(`button`,{className:`b th-back`,onClick:r,"aria-label":J(`trackers.detail.backToList`),children:[`←`,(0,Q.jsxs)(`span`,{children:[` `,J(`trackers.detail.back`)]})]}),(0,Q.jsx)(`span`,{className:`th-detail-kind`,children:J(`trackers.issue.kind`,{source:ac[n.source]})}),l&&(0,Q.jsx)(`a`,{className:`b`,href:l.url,target:`_blank`,rel:`noreferrer`,children:J(`trackers.detail.openExternal`)})]});if(d)return(0,Q.jsxs)(`div`,{className:`th-detail-inner`,children:[D,(0,Q.jsx)(`p`,{className:`th-error`,role:`alert`,children:d}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void w(),children:J(`trackers.detail.retry`)})]});if(!l)return(0,Q.jsxs)(`div`,{className:`th-detail-inner`,children:[D,(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.detail.loading`,{mark:dc(n)})})]});let O=l.transitions.find(e=>e.name===l.state||e.name.endsWith(`→ ${l.state}`))?.id||``;return(0,Q.jsxs)(`div`,{className:`th-detail-inner`,"data-issue":l.id,children:[D,(0,Q.jsxs)(`header`,{className:`th-pr-head`,children:[(0,Q.jsxs)(`h2`,{children:[l.title,` `,(0,Q.jsx)(`span`,{className:`th-num`,children:dc(l)})]}),(0,Q.jsxs)(`div`,{className:`th-pr-meta`,children:[(0,Q.jsx)($u,{item:l}),l.author&&(0,Q.jsxs)(`span`,{children:[J(`trackers.issue.openedBy`),` `,(0,Q.jsx)(`b`,{children:l.author})]}),l.assignees.length>0&&(0,Q.jsx)(`span`,{children:J(`trackers.issue.assignedTo`,{names:l.assignees.join(`, `)})}),l.priority&&(0,Q.jsx)(`span`,{className:`th-badge`,children:l.priority}),(0,Q.jsx)(`span`,{className:`th-muted`,children:J(`trackers.detail.updated`,{ago:wc(l.updated_at)})}),(0,Q.jsx)(sd,{reactions:l.reactions,label:dc(l),onReact:cc(n.source)?async e=>{await T(`reactions`,{emoji:e},J(`trackers.notice.reactionAdded`))}:void 0})]})]}),(0,Q.jsxs)(`section`,{className:`th-section th-mergebox`,"aria-label":J(`trackers.issue.workOnThis`),children:[(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b ok grow`,id:`th-start`,onClick:()=>v(!0),children:J(`trackers.issue.startSessionOrTask`)}),c&&(0,Q.jsx)(`button`,{className:`b ${l.state===`open`?`no`:``}`,disabled:p,onClick:()=>void T(`state`,{open:l.state!==`open`},l.state===`open`?J(`trackers.notice.closed`):J(`trackers.notice.reopened`)),children:l.state===`open`?J(`trackers.issue.closeIssue`):J(`trackers.reopen`)})]}),(0,Q.jsxs)(`p`,{className:`th-muted th-branch-hint`,children:[J(`trackers.issue.suggestedBranch`),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:l.branch_name})]}),!c&&l.transitions.length>0&&(0,Q.jsxs)(`label`,{className:`th-status-pick`,children:[n.source===`jira`?J(`trackers.issue.moveWithTransition`):J(`trackers.issue.status`),(0,Q.jsxs)(`select`,{"aria-label":J(`trackers.issue.status`),value:n.source===`linear`?O:``,disabled:p,onChange:e=>{let t=l.transitions.find(t=>t.id===e.target.value);t&&T(`status`,{id:t.id},J(`trackers.issue.movedTo`,{name:t.name}))},children:[n.source===`jira`&&(0,Q.jsx)(`option`,{value:``,children:J(`trackers.issue.chooseTransition`,{state:l.state})}),l.transitions.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})]}),(l.parent_item||l.children.length>0)&&(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.issue.related`),children:[l.parent_item&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h3`,{children:J(`trackers.issue.parent`)}),(0,Q.jsxs)(`button`,{className:`th-link-row`,onClick:()=>i({...n,id:l.parent_item.id}),children:[(0,Q.jsx)(`span`,{className:`th-num`,children:l.parent_item.id}),` `,l.parent_item.title]})]}),l.children.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`h3`,{children:[J(`trackers.issue.subIssues`),` `,(0,Q.jsx)(`span`,{className:`th-muted`,children:J(`trackers.issue.subIssuesDone`,{done:l.children.filter(e=>[`completed`,`done`].includes(e.status_type||``)).length,total:l.children.length})})]}),(0,Q.jsx)(`ul`,{className:`th-children`,children:l.children.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{className:`th-link-row`,onClick:()=>i({...n,id:e.id}),children:[(0,Q.jsx)($u,{item:e}),` `,(0,Q.jsx)(`span`,{className:`th-num`,children:e.id}),` `,e.title]})},e.id))})]})]}),(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.labels`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.labels`)}),(0,Q.jsx)(ad,{labels:l.labels,onRemove:c?e=>void T(`labels`,{remove:[e]},J(`trackers.notice.removed`,{name:e})):void 0}),!l.labels.length&&(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.labels.none`)}),c&&(0,Q.jsx)(dd,{label:J(`trackers.labels.add`),busy:p,options:(h?.labels||[]).filter(e=>!l.labels.some(t=>t.name===e.name)).map(e=>({value:e.name})),onPick:e=>void T(`labels`,{add:[e]},J(`trackers.notice.labelled`,{name:e}))})]}),(0,Q.jsxs)(`section`,{className:`th-section th-desc`,"aria-label":J(`trackers.description`),children:[(0,Q.jsxs)(`h3`,{children:[J(`trackers.description`),l.editable&&y===void 0&&(0,Q.jsx)(`button`,{type:`button`,className:`b th-edit-btn`,onClick:()=>{b(l.body),S(!1)},children:J(`trackers.issue.edit`)})]}),y===void 0?(0,Q.jsx)(`div`,{className:`th-md`,children:l.body?(0,Q.jsx)(Ji,{text:l.body}):(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.description.none`)})}):(0,Q.jsxs)(`form`,{className:`th-desc-edit`,onSubmit:e=>{e.preventDefault(),E()},children:[l.body_lossy&&(0,Q.jsxs)(`label`,{className:`th-warn th-check`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:x,onChange:e=>S(e.target.checked)}),J(`trackers.issue.lossyWarning`)]}),(0,Q.jsx)(Zu,{label:J(`trackers.description`),value:y,onChange:b,rows:10,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b ok`,type:`submit`,disabled:p||l.body_lossy&&!x,children:J(p?`trackers.issue.saving`:`trackers.issue.saveDescription`)}),(0,Q.jsx)(`button`,{className:`b`,type:`button`,onClick:()=>b(void 0),children:J(`trackers.cancel`)})]})]})]}),(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.issue.comments`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.issue.comments`)}),(0,Q.jsx)(ud,{events:l.timeline,onComment:async e=>{await T(`comments`,{body:e},J(`trackers.notice.commentPosted`))},onReact:cc(n.source)?async(e,t)=>{await T(`reactions`,{subject:e,emoji:t},J(`trackers.notice.reactionAdded`))}:void 0})]}),_&&(0,Q.jsx)(fd,{api:e,projectId:t,item:{...n,id:l.id},title:l.title,branch:l.branch_name,onClose:()=>v(!1),onNotice:a,onStarted:e=>{v(!1),s(e)}})]})}function md(e){return e?e<90?J(`trackers.queue.eta.minute`):e<3600?J(`trackers.queue.eta.minutes`,{n:Math.round(e/60)}):J(`trackers.queue.eta.hours`,{n:Math.round(e/3600)}):``}function hd({api:e,projectId:t,source:n,onOpen:r,onNotice:i}){Y();let[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(),[d,f]=(0,X.useState)(``),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(),[_,v]=(0,X.useState)(!1),y=J(n===`gitlab`?`trackers.queue.word.train`:`trackers.queue.word.queue`),b=(0,X.useCallback)(async()=>{m(!0),f(``);try{let n=await e.request(`/projects/${t}/forge/queue${a?`?base=${encodeURIComponent(a)}`:``}`);u(n),!a&&n.base&&c(n.base)}catch(e){f(Dc(e))}finally{m(!1)}},[e,t,a]);(0,X.useEffect)(()=>{b()},[b]);async function x(n){v(!0);try{await e.request(`/projects/${t}/forge/queue/remove`,{method:`POST`,body:{base:l?.base||a,id:n.id}}),i(J(`trackers.queue.removed`,{n:n.number,word:y})),g(void 0),await b()}catch(e){i(Dc(e),!0)}finally{v(!1)}}return(0,Q.jsxs)(`div`,{className:`th-queue`,children:[(0,Q.jsxs)(`form`,{className:`th-queue-head`,onSubmit:e=>{e.preventDefault(),o(s.trim())},children:[(0,Q.jsxs)(`label`,{children:[J(`trackers.queue.targetBranch`),(0,Q.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),spellCheck:!1,autoCapitalize:`off`,placeholder:J(`trackers.queue.defaultBranch`)})]}),(0,Q.jsx)(`button`,{className:`b`,type:`submit`,disabled:p,children:J(p?`trackers.loading`:`trackers.queue.show`)})]}),d&&(0,Q.jsx)(`p`,{className:`th-banner th-banner-err`,role:`alert`,children:d}),l&&!l.supported&&(0,Q.jsx)(`p`,{className:`th-empty`,children:J(`trackers.queue.unsupported`,{word:y})}),l?.supported&&l.entries.length===0&&(0,Q.jsxs)(`p`,{className:`th-empty`,children:[J(`trackers.queue.empty`,{word:y}),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:l.base}),J(`trackers.queue.end`)]}),l?.supported&&l.entries.length>0&&(0,Q.jsx)(`ol`,{className:`th-queue-list`,"aria-label":J(`trackers.queue.listLabel`,{word:y,base:String(l.base)}),children:l.entries.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`span`,{className:`th-queue-pos`,"aria-label":J(`trackers.queue.position`,{n:e.position}),children:e.position}),(0,Q.jsxs)(`span`,{className:`th-row-main`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`th-link-row th-queue-title`,onClick:()=>r({source:n,kind:`pr`,id:String(e.number)}),children:[(0,Q.jsxs)(`span`,{className:`th-num`,children:[`#`,e.number]}),` `,e.title]}),(0,Q.jsxs)(`span`,{className:`th-row-meta`,children:[(0,Q.jsx)(`span`,{className:`th-badge th-queue-${e.status}`,children:e.status.replace(/_/g,` `)}),e.pipeline&&(0,Q.jsx)(`span`,{className:`th-badge th-checks-${e.pipeline===`success`?`pass`:e.pipeline===`failed`?`fail`:`pending`}`,children:J(`trackers.queue.pipeline`,{status:e.pipeline})}),e.eta_seconds?(0,Q.jsx)(`span`,{children:J(`trackers.queue.mergesIn`,{eta:md(e.eta_seconds)})}):null,e.enqueued_at&&(0,Q.jsx)(`span`,{children:J(`trackers.queue.queued`,{ago:wc(e.enqueued_at)})}),e.author&&(0,Q.jsx)(`span`,{children:J(`trackers.hub.by`,{name:e.author})})]})]}),e.author&&(0,Q.jsx)(cd,{name:e.author}),(0,Q.jsx)(`button`,{type:`button`,className:`b no th-queue-remove`,onClick:()=>g(e),"aria-label":J(`trackers.queue.removeLabel`,{n:e.number,word:y}),children:J(`trackers.queue.remove`)})]},e.id))}),h&&(0,Q.jsxs)(O,{className:`th-confirm`,"aria-labelledby":`th-dequeue-title`,onCancel:()=>g(void 0),children:[(0,Q.jsx)(`h2`,{id:`th-dequeue-title`,children:J(`trackers.queue.confirmTitle`,{n:h.number,word:y})}),(0,Q.jsxs)(`p`,{children:[J(`trackers.queue.leaves`,{title:h.title,word:y}),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:l?.base}),J(n===`gitlab`?`trackers.queue.leavesEndTrain`:`trackers.queue.leavesEnd`)]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b no grow`,id:`th-dequeue-go`,autoFocus:!0,disabled:_,onClick:()=>void x(h),children:J(_?`trackers.queue.removing`:`trackers.queue.remove`)}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>g(void 0),children:J(`trackers.cancel`)})]})]})]})}function gd({api:e,projectId:t,item:n,onClose:r,onOpen:i,onNotice:a,onChanged:o,onStarted:s,onQueue:c}){Y();let l=`/projects/${t}/forge`,[u,d]=(0,X.useState)(),[f,p]=(0,X.useState)(``),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(),[v,y]=(0,X.useState)(),[b,x]=(0,X.useState)({}),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)(`merge`),[E,D]=(0,X.useState)(!1),[k,A]=(0,X.useState)(``),[j,M]=(0,X.useState)(!1),N=(0,X.useCallback)(async()=>{p(``);try{let t=await e.request(`${l}/prs/${n.id}`);d(t),T(t.merge.methods.includes(t.merge.default)?t.merge.default:t.merge.methods[0]||`merge`),D(t.merge.delete_branch_default),t.mergeable===`conflicting`?e.request(`${l}/prs/${n.id}/conflicts`).then(e=>y(e.conflicts)).catch(e=>y({files:[],checked:!1,detail:Dc(e)})):y(void 0)}catch(e){p(Dc(e))}},[e,l,n.id]);(0,X.useEffect)(()=>{d(void 0),x({}),C(``),N()},[N]),(0,X.useEffect)(()=>{e.request(`${l}/meta`).then(_).catch(()=>{})},[e,l]);async function P(t,n,r,i,s=`POST`){h(t);try{return await e.request(`${l}${n}`,{method:s,body:r}),a(i),await N(),o(),!0}catch(e){return a(Dc(e),!0),!1}finally{h(``)}}async function F(e){u&&(A(``),await P(e?`auto`:`merge`,`/prs/${u.id}/merge`,{method:w,delete_branch:E,auto:e,head_sha:u.head_sha,confirm:!0},e?J(`trackers.pr.notice.autoOn`,{id:u.id}):u.merge.merge_queue?J(`trackers.pr.notice.queued`,{id:u.id}):J(`trackers.pr.notice.merged`,{id:u.id}))||N())}async function I(t){if(u){h(t);try{s({kind:`session`,session:(await e.request(`${l}/prs/${u.id}/${t===`fix`?`fix-checks`:`resolve`}`,{method:`POST`,body:{}})).session}),await N()}catch(e){a(Dc(e),!0)}finally{h(``)}}}async function L(t){if(S===t.id){C(``);return}if(C(t.id),!b[t.id]){x(e=>({...e,[t.id]:J(`trackers.pr.loadingLog`)}));try{let r=await e.request(`${l}/prs/${n.id}/log?check=${encodeURIComponent(t.id)}`);x(e=>({...e,[t.id]:r.log||J(`trackers.pr.emptyLog`)}))}catch(e){x(n=>({...n,[t.id]:Dc(e)}))}}}let R=(0,Q.jsxs)(`div`,{className:`th-detail-bar`,children:[(0,Q.jsxs)(`button`,{className:`b th-back`,onClick:r,"aria-label":J(`trackers.detail.backToList`),children:[`←`,(0,Q.jsxs)(`span`,{children:[` `,J(`trackers.detail.back`)]})]}),(0,Q.jsx)(`span`,{className:`th-detail-kind`,children:J(`trackers.pr.kind`,{source:u?ac[u.source]:``})}),u&&(0,Q.jsx)(`a`,{className:`b`,href:u.url,target:`_blank`,rel:`noreferrer`,children:J(`trackers.detail.openExternal`)})]});if(f)return(0,Q.jsxs)(`div`,{className:`th-detail-inner`,children:[R,(0,Q.jsx)(`p`,{className:`th-error`,role:`alert`,children:f}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void N(),children:J(`trackers.detail.retry`)})]});if(!u)return(0,Q.jsxs)(`div`,{className:`th-detail-inner`,children:[R,(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.detail.loading`,{mark:`#${n.id}`})})]});let z=yc(u),B=u.check_runs.filter(e=>e.status===`fail`||e.status===`cancel`),V=[...u.check_runs].sort((e,t)=>vd(e)-vd(t)),H=new Set(u.reviewers.map(e=>e.login)),U=!!u.ci?.active;return(0,Q.jsxs)(`div`,{className:`th-detail-inner`,"data-pr":u.id,children:[R,(0,Q.jsxs)(`header`,{className:`th-pr-head`,children:[(0,Q.jsxs)(`h2`,{children:[u.title,` `,(0,Q.jsx)(`span`,{className:`th-num`,children:dc(u)})]}),(0,Q.jsxs)(`div`,{className:`th-pr-meta`,children:[(0,Q.jsx)($u,{item:u}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:u.author}),` `,J(`trackers.pr.wantsToMergeInto`),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:u.base}),` `,J(`trackers.pr.from`),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:u.head})]})]}),(0,Q.jsxs)(`div`,{className:`th-pr-meta th-muted`,children:[(u.changed_files>0||u.additions>0||u.deletions>0)&&(0,Q.jsxs)(`span`,{className:`th-diffstat`,children:[(0,Q.jsxs)(`span`,{className:`th-add-n`,children:[`+`,u.additions]}),` `,(0,Q.jsxs)(`span`,{className:`th-del-n`,children:[`−`,u.deletions]}),` · `,J(`trackers.pr.files`,{n:u.changed_files})]}),(0,Q.jsx)(`span`,{children:J(`trackers.detail.updated`,{ago:wc(u.updated_at)})}),(0,Q.jsx)(sd,{reactions:u.reactions,label:`#${u.id}`,onReact:cc(u.source)?async e=>{await P(``,`/prs/${u.id}/reactions`,{emoji:e},J(`trackers.notice.reactionAdded`))}:void 0})]})]}),u.stack&&u.stack.length>1&&(0,Q.jsxs)(`section`,{className:`th-section th-stack`,"aria-label":J(`trackers.pr.stack`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.pr.stack`)}),(0,Q.jsx)(`ol`,{children:u.stack.map(e=>(0,Q.jsxs)(`li`,{style:{paddingLeft:`${e.depth*14}px`},className:e.current?`current`:``,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`th-stack-btn`,disabled:e.current,onClick:()=>i({source:u.source,kind:`pr`,id:String(e.number)}),children:[(0,Q.jsxs)(`span`,{className:`th-num`,children:[`#`,e.number]}),` `,e.title]}),(0,Q.jsxs)(`small`,{className:`th-muted`,children:[e.head,` → `,e.base]})]},e.number))})]}),(0,Q.jsxs)(`section`,{className:`th-section th-mergebox`,"aria-label":J(`trackers.pr.mergeSection`),children:[(0,Q.jsxs)(`div`,{className:`th-status-rows`,children:[(0,Q.jsxs)(`div`,{className:`th-status-row th-checks-${u.checks||`none`}`,children:[(0,Q.jsx)(td,{checks:u.checks}),u.checks===`none`&&(0,Q.jsx)(`span`,{className:`th-muted`,children:J(`trackers.pr.noChecksReported`)}),B.length>0&&(0,Q.jsx)(`span`,{children:J(`trackers.pr.failingCount`,{n:B.length})})]}),(0,Q.jsx)(`div`,{className:`th-status-row`,children:u.review?(0,Q.jsx)(id,{review:u.review}):(0,Q.jsx)(`span`,{className:`th-muted`,children:J(`trackers.pr.noReviewDecision`)})}),u.mergeable===`conflicting`&&(0,Q.jsxs)(`div`,{className:`th-status-row th-conflict`,role:`status`,children:[(0,Q.jsx)(`span`,{className:`th-badge th-conflicts`,children:J(`trackers.conflictsBadge`)}),` `,J(`trackers.pr.branchConflictsWith`),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:u.base})]}),u.ci&&(0,Q.jsxs)(`div`,{className:`th-status-row`,children:[(0,Q.jsx)(`span`,{className:`th-badge th-ci-${u.ci.state}`,children:u.ci.label}),u.ci.session_id&&(0,Q.jsx)(`span`,{className:`th-muted`,children:J(`trackers.pr.ciSession`,{id:u.ci.session_id})})]})]}),u.mergeable===`conflicting`&&(0,Q.jsxs)(`div`,{className:`th-conflicts-box`,children:[(0,Q.jsx)(`h4`,{children:J(`trackers.pr.conflictingFiles`)}),v?v.files.length?(0,Q.jsx)(`ul`,{className:`th-files`,children:v.files.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsx)(`code`,{children:e})},e))}):(0,Q.jsx)(`p`,{className:`th-muted`,children:v.detail||J(`trackers.pr.noConflictingFiles`)}):(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.pr.findingConflicts`)}),(0,Q.jsx)(`button`,{className:`b ok`,id:`th-resolve`,disabled:m!==``||u.state!==`open`,onClick:()=>void I(`resolve`),children:J(m===`resolve`?`trackers.starting`:`trackers.pr.resolveWithAgent`)})]}),u.state===`open`&&(0,Q.jsx)(`div`,{className:`th-merge-actions`,children:z.block?(0,Q.jsx)(`p`,{className:`th-muted`,children:z.block}):(0,Q.jsxs)(Q.Fragment,{children:[z.warn&&(0,Q.jsx)(`p`,{className:`th-warn`,children:z.warn}),u.auto_merge?(0,Q.jsxs)(`div`,{className:`th-auto-on`,children:[(0,Q.jsx)(`span`,{children:u.auto_merge.method?u.auto_merge.enabled_by?J(`trackers.pr.autoOnMethodBy`,{method:u.auto_merge.method,name:u.auto_merge.enabled_by}):J(`trackers.pr.autoOnMethod`,{method:u.auto_merge.method}):u.auto_merge.enabled_by?J(`trackers.pr.autoOnBy`,{name:u.auto_merge.enabled_by}):J(`trackers.pr.autoOn`)}),(0,Q.jsx)(`button`,{className:`b`,disabled:m!==``,onClick:()=>void P(`auto`,`/prs/${u.id}/auto-merge`,{},J(`trackers.pr.notice.autoOff`),`DELETE`),children:J(`trackers.pr.turnOff`)})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`th-merge-opts`,children:[u.merge.methods.length>1&&(0,Q.jsx)(`select`,{"aria-label":J(`trackers.pr.mergeMethod`),value:w,onChange:e=>T(e.target.value),children:u.merge.methods.map(e=>(0,Q.jsx)(`option`,{value:e,children:_c(e)},e))}),(0,Q.jsxs)(`label`,{className:`th-check`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:E,onChange:e=>D(e.target.checked)}),` `,J(`trackers.pr.deleteBranch`)]})]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[!z.autoOnly&&(0,Q.jsx)(`button`,{className:`b ok grow th-merge-btn`,id:`th-merge`,disabled:m!==``,onClick:()=>A(`merge`),children:m===`merge`?J(`trackers.pr.merging`):vc(u,w,!1)}),u.merge.auto_merge_allowed&&(0,Q.jsx)(`button`,{className:`b grow ${z.autoOnly?`ok`:``}`,id:`th-auto`,disabled:m!==``,onClick:()=>A(`auto`),children:J(m===`auto`?`trackers.pr.enabling`:`trackers.pr.autoWhenReady`)})]})]})]})}),(0,Q.jsxs)(`div`,{className:`btnrow th-secondary`,children:[u.state===`open`&&B.length>0&&(0,Q.jsx)(`button`,{className:`b warn`,id:`th-fix`,disabled:m!==``||U,title:U?J(`trackers.pr.ciBusy`):``,onClick:()=>void I(`fix`),children:J(m===`fix`?`trackers.starting`:`trackers.pr.fixChecks`)}),u.state!==`merged`&&(0,Q.jsx)(`button`,{className:`b ${u.state===`open`?`no`:``}`,disabled:m!==``,onClick:()=>A(u.state===`open`?`close`:`reopen`),children:u.state===`open`?J(`trackers.close`):J(`trackers.reopen`)}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>M(!0),children:J(`trackers.startSession`)}),c&&(u.merge.merge_queue||u.auto_merge)&&(0,Q.jsx)(`button`,{className:`b`,id:`th-view-queue`,onClick:c,children:u.source===`gitlab`?J(`trackers.hub.tab.mergeTrain`):J(`trackers.hub.tab.mergeQueue`)})]})]}),(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.pr.checks`),children:[(0,Q.jsxs)(`h3`,{children:[J(`trackers.pr.checks`),` `,(0,Q.jsx)(`span`,{className:`th-muted`,children:u.check_runs.length})]}),V.length===0&&(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.pr.noChecks`)}),(0,Q.jsx)(`ul`,{className:`th-checks`,children:V.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsxs)(`div`,{className:`th-check-row`,children:[(0,Q.jsx)(rd,{check:e}),(0,Q.jsxs)(`span`,{className:`th-check-name`,children:[e.name,e.workflow&&(0,Q.jsxs)(`small`,{className:`th-muted`,children:[` · `,e.workflow]})]}),e.has_log?(0,Q.jsx)(`button`,{className:`b th-log-btn`,"aria-expanded":S===e.id,onClick:()=>void L(e),children:S===e.id?J(`trackers.pr.hideLog`):J(`trackers.pr.log`)}):e.url?(0,Q.jsx)(`a`,{className:`b th-log-btn`,href:e.url,target:`_blank`,rel:`noreferrer`,children:J(`trackers.pr.details`)}):null]}),S===e.id&&(0,Q.jsx)(`pre`,{className:`th-log`,children:b[e.id]})]},e.id))})]}),(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.pr.reviewers`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.pr.reviewers`)}),(0,Q.jsxs)(`ul`,{className:`th-reviewers`,children:[u.reviewers.length===0&&(0,Q.jsx)(`li`,{className:`th-muted`,children:J(`trackers.pr.noReviewers`)}),u.reviewers.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(cd,{name:e.login}),(0,Q.jsxs)(`span`,{className:`th-rev-name`,children:[e.login,e.team&&(0,Q.jsxs)(`small`,{className:`th-muted`,children:[` `,J(`trackers.pr.team`)]})]}),(0,Q.jsx)(`span`,{className:`th-rev-state th-rev-${e.state}`,children:_d()[e.state]||e.state.replace(`_`,` `)}),e.state===`requested`&&(0,Q.jsx)(`button`,{className:`th-x`,"aria-label":J(`trackers.pr.removeReviewer`,{name:e.login}),disabled:m!==``,onClick:()=>void P(`reviewers`,`/prs/${u.id}/reviewers`,{remove:[e.login]},J(`trackers.notice.removed`,{name:e.login})),children:`×`})]},e.login))]}),(0,Q.jsx)(dd,{label:J(`trackers.pr.requestReview`),busy:m!==``,options:(g?.users||[]).filter(e=>!H.has(e.login)).map(e=>({value:e.login,hint:e.name})),onPick:e=>void P(`reviewers`,`/prs/${u.id}/reviewers`,{add:[e]},J(`trackers.pr.notice.askedReview`,{name:e}))})]}),(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.labels`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.labels`)}),(0,Q.jsx)(ad,{labels:u.labels,onRemove:e=>void P(`labels`,`/prs/${u.id}/labels`,{remove:[e]},J(`trackers.notice.removed`,{name:e}))}),!u.labels.length&&(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.labels.none`)}),(0,Q.jsx)(dd,{label:J(`trackers.labels.add`),busy:m!==``,options:(g?.labels||[]).filter(e=>!u.labels.some(t=>t.name===e.name)).map(e=>({value:e.name})),onPick:e=>void P(`labels`,`/prs/${u.id}/labels`,{add:[e]},J(`trackers.notice.labelled`,{name:e}))})]}),(0,Q.jsxs)(`section`,{className:`th-section th-desc`,"aria-label":J(`trackers.description`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.description`)}),(0,Q.jsx)(`div`,{className:`th-md`,children:u.body?(0,Q.jsx)(Ji,{text:u.body}):(0,Q.jsx)(`p`,{className:`th-muted`,children:J(`trackers.description.none`)})})]}),(0,Q.jsxs)(`section`,{className:`th-section`,"aria-label":J(`trackers.pr.conversation`),children:[(0,Q.jsx)(`h3`,{children:J(`trackers.pr.conversation`)}),(0,Q.jsx)(ud,{events:u.timeline,onComment:async e=>{await P(``,`/prs/${u.id}/comments`,{body:e},J(`trackers.notice.commentPosted`))},onReact:cc(u.source)?async(e,t)=>{await P(``,`/prs/${u.id}/reactions`,{subject:e,emoji:t},J(`trackers.notice.reactionAdded`))}:void 0})]}),k&&(0,Q.jsxs)(O,{className:`th-confirm`,"aria-labelledby":`th-confirm-title`,onCancel:()=>A(``),children:[(0,Q.jsx)(`h2`,{id:`th-confirm-title`,children:k===`merge`?J(`trackers.pr.confirm.question`,{action:vc(u,w,!1)}):J(k===`auto`?`trackers.pr.confirm.autoTitle`:k===`close`?`trackers.pr.confirm.closeTitle`:`trackers.pr.confirm.reopenTitle`)}),k===`merge`||k===`auto`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`p`,{children:[k===`auto`?J(`trackers.pr.confirm.whenPasses`)+` `:``,(0,Q.jsx)(`b`,{children:dc(u)}),` `,u.title,` `,k===`auto`?J(`trackers.pr.confirm.willBeMergedInto`):u.merge.merge_queue?J(`trackers.pr.confirm.joinsQueueInto`):J(`trackers.pr.confirm.isMergedInto`),` `,(0,Q.jsx)(`code`,{className:`th-branch`,children:u.base}),` `,J(`trackers.pr.confirm.with`),` `,(0,Q.jsx)(`b`,{children:_c(w).toLowerCase()}),J(E?`trackers.pr.confirm.branchDeleted`:`trackers.pr.confirm.end`)]}),(0,Q.jsxs)(`p`,{className:`th-muted`,children:[J(`trackers.pr.confirm.onlyCommit`),` `,(0,Q.jsx)(`code`,{children:u.head_sha.slice(0,7)}),` `,J(`trackers.pr.confirm.shaRule`)]}),z.warn&&(0,Q.jsx)(`p`,{className:`th-warn`,children:z.warn})]}):(0,Q.jsx)(`p`,{children:J(k===`close`?`trackers.pr.confirm.willClose`:`trackers.pr.confirm.willReopen`,{mark:dc(u)})}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b grow ${k===`close`?`no`:`ok`}`,id:`th-confirm-go`,autoFocus:!0,onClick:()=>{if(k===`merge`||k===`auto`)F(k===`auto`);else{let e=k===`reopen`;A(``),P(`state`,`/prs/${u.id}/state`,{open:e},J(e?`trackers.notice.reopened`:`trackers.notice.closed`))}},children:J(k===`merge`?`trackers.pr.confirm.go`:k===`auto`?`trackers.merge.enableAuto`:k===`close`?`trackers.close`:`trackers.reopen`)}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>A(``),children:J(`trackers.cancel`)})]})]}),j&&(0,Q.jsx)(fd,{api:e,projectId:t,item:{source:u.source,kind:`pr`,id:u.id},title:u.title,pr:!0,onClose:()=>M(!1),onNotice:a,onStarted:e=>{M(!1),s(e)}})]})}var _d=()=>({requested:J(`trackers.pr.reviewer.requested`),approved:J(`trackers.pr.reviewer.approved`),changes_requested:J(`trackers.pr.reviewer.changesRequested`),commented:J(`trackers.pr.reviewer.commented`),dismissed:J(`trackers.pr.reviewer.dismissed`)});function vd(e){return{fail:0,cancel:1,pending:2,pass:3,skipping:4}[e.status]??5}var yd=()=>[{key:`open`,label:J(`trackers.hub.filter.open`)},{key:`assigned`,label:J(`trackers.hub.filter.assigned`)},{key:`review`,label:J(`trackers.hub.filter.review`),pr:!0},{key:`authored`,label:J(`trackers.hub.filter.authored`)},{key:`closed`,label:J(`trackers.hub.filter.closed`)},{key:`all`,label:J(`trackers.hub.filter.all`)}],bd=()=>({list:J(`trackers.hub.view.list`),board:J(`trackers.hub.view.board`),table:J(`trackers.hub.view.table`)});function xd(e){switch(e){case`assigned`:case`review`:case`authored`:return`state=open&mine=${e}`;case`closed`:return`state=closed`;case`all`:return`state=all`}return`state=open`}function Sd(e,t){try{return localStorage.getItem(e)||t}catch{return t}}function Cd(e,t){try{localStorage.setItem(e,t)}catch{}}function wd({api:e,projects:t,refreshVersion:n,onNotice:r,onOpenSession:i,onOpenTask:a,onSettings:o}){Y();let s=pc(location.hash),[c,l]=(0,X.useState)(()=>s.project??(Number(Sd(`lec-tasks-project`,`0`))||void 0)),[u,d]=(0,X.useState)(s.ref),[f,p]=(0,X.useState)(()=>Sd(`lec-tasks-tab`,`all`)),[m,h]=(0,X.useState)(()=>Sd(`lec-tasks-filter`,`open`)),[g,_]=(0,X.useState)(()=>Sd(`lec-tasks-view`,`list`)),[v,y]=(0,X.useState)(``),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(),[w,T]=(0,X.useState)(),[E,D]=(0,X.useState)([]),[O,k]=(0,X.useState)([]),[A,j]=(0,X.useState)(``),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)(``),I=(0,X.useRef)(0),L=(t.find(e=>e.id===c)||t[0])?.id;(0,X.useEffect)(()=>{let e=()=>{let e=pc(location.hash);e.project&&l(e.project),d(e.ref)};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let R=(0,X.useCallback)(e=>{d(e),L&&history.replaceState(null,``,mc(L,e))},[L]);(0,X.useEffect)(()=>{L&&(Cd(`lec-tasks-project`,String(L)),C(void 0),e.request(`/projects/${L}/trackers`).then(C).catch(e=>C({forge:{error:Dc(e)},connections:[]})))},[e,L]);let z=(0,X.useMemo)(()=>(S?.connections||[]).filter(e=>e.kind===`linear`||e.kind===`jira`),[S]),B=f.startsWith(`c`)?z.find(e=>`c${e.id}`===f):void 0;(0,X.useEffect)(()=>{f.startsWith(`c`)&&S&&!B&&p(`all`)},[f,S,B]),(0,X.useEffect)(()=>{f===`queue`&&S&&S.forge.kind!==`github`&&S.forge.kind!==`gitlab`&&p(`all`)},[f,S]);let V=(0,X.useCallback)(async()=>{if(!L||f===`queue`)return;let t=++I.current;N(!0),F(``);let n=b?`&q=${encodeURIComponent(b)}`:``;try{let r;if(B){let t=B.kind===`linear`&&A?`&team=${encodeURIComponent(A)}`:``,i=await e.request(`/trackers/${B.id}/issues?${xd(m)}${n}${t}`);r={items:i,sources:[{source:B.kind,name:B.name,ok:!0,count:i.length,connection_id:B.id}]}}else{let t=f===`pr`||f===`issue`?`&kind=${f}`:``;r=await e.request(`/projects/${L}/work?${xd(m)}${t}${n}`)}t===I.current&&T(r)}catch(e){t===I.current&&(F(Dc(e)),T(void 0))}finally{t===I.current&&N(!1)}},[e,L,B,f,m,b,A]);(0,X.useEffect)(()=>{V()},[V,n]),(0,X.useEffect)(()=>{D([]),B?.kind===`linear`&&e.request(`/trackers/${B.id}/states${A?`?team=${encodeURIComponent(A)}`:``}`).then(D).catch(()=>{})},[e,B,A]),(0,X.useEffect)(()=>{k([]),j(B?.kind===`linear`?String(B.config.team_key||``):``),B?.kind===`linear`&&e.request(`/trackers/${B.id}/teams`).then(k).catch(()=>{})},[e,B]),(0,X.useEffect)(()=>{let e=window.setTimeout(()=>x(v.trim()),450);return()=>window.clearTimeout(e)},[v]);let H=(0,X.useMemo)(()=>(w?.items||[]).filter(e=>Cc(e,v)),[w,v]),U=(w?.sources||[]).filter(e=>!e.ok),ee=(0,X.useMemo)(()=>{let e={pr:0,issue:0};for(let t of w?.sources||[])t.ok&&!t.connection_id&&(t.kind===`pr`||t.kind===`issue`)&&(e[t.kind]+=t.count);return e},[w]);function W(e){e.kind===`session`&&e.session?(r(e.branch?J(`trackers.hub.startedSessionOn`,{name:e.session.name,branch:e.branch}):J(`trackers.hub.startedSession`,{name:e.session.name})),i(e.session.id,e.session.name)):e.task&&(r(J(`trackers.hub.createdTask`,{id:e.task.id})),a(e.task.id))}if(!t.length)return(0,Q.jsx)(`section`,{className:`tasks-hub`,children:(0,Q.jsx)(`div`,{className:`page-heading`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{children:J(`trackers.hub.title`)}),(0,Q.jsx)(`p`,{children:J(`trackers.hub.noProjects`)})]})})});let te=S?.forge,G=te?.kind?ac[te.kind]:`GitHub`,ne=te?.kind===`github`||te?.kind===`gitlab`,K=u&&L?u.kind===`pr`?(0,Q.jsx)(gd,{api:e,projectId:L,item:u,onClose:()=>R(void 0),onOpen:R,onNotice:r,onChanged:()=>void V(),onStarted:W,onQueue:ne?()=>{p(`queue`),R(void 0)}:void 0},`${u.source}/${u.id}`):(0,Q.jsx)(pd,{api:e,projectId:L,item:u,onClose:()=>R(void 0),onOpen:R,onNotice:r,onChanged:()=>void V(),onStarted:W},`${u.source}/${u.connection_id}/${u.id}`):null;return(0,Q.jsxs)(`section`,{className:`tasks-hub ${u?`has-detail`:``} th-view-${g}`,children:[(0,Q.jsxs)(`div`,{className:`page-heading th-heading`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{children:J(`trackers.hub.title`)}),(0,Q.jsx)(`p`,{children:te?.repo?(0,Q.jsxs)(Q.Fragment,{children:[G,` ·`,` `,(0,Q.jsx)(`a`,{href:te.url,target:`_blank`,rel:`noreferrer`,children:te.repo}),z.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[` · `,z.map(e=>e.name).join(` · `)]})]}):J(`trackers.hub.subtitle`)})]}),(0,Q.jsxs)(`div`,{className:`th-head-actions`,children:[t.length>1&&(0,Q.jsx)(`select`,{"aria-label":J(`trackers.hub.project`),value:L,onChange:e=>{l(Number(e.target.value)),R(void 0)},children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void V(),disabled:M,"aria-label":J(`trackers.hub.refresh`),children:J(M?`trackers.loading`:`trackers.hub.refresh`)}),L&&(0,Q.jsx)(`button`,{className:`b`,onClick:()=>o(L),children:J(`trackers.hub.connect`)})]})]}),(0,Q.jsx)(`div`,{className:`th-tabs`,role:`tablist`,"aria-label":J(`trackers.hub.source`),children:[[`all`,J(`trackers.hub.tab.all`)],[`pr`,te?.kind===`gitlab`?J(`trackers.hub.tab.mergeRequests`):J(`trackers.hub.tab.pullRequests`),ee.pr],[`issue`,uc(te?.kind),ee.issue],...ne?[[`queue`,te?.kind===`gitlab`?J(`trackers.hub.tab.mergeTrain`):J(`trackers.hub.tab.mergeQueue`)]]:[],...z.map(e=>[`c${e.id}`,e.name])].map(([e,t,n])=>(0,Q.jsxs)(`button`,{role:`tab`,"aria-selected":f===e,className:f===e?`on`:``,onClick:()=>{p(e),Cd(`lec-tasks-tab`,e)},children:[t,n!==void 0&&f!==`all`&&!B&&w&&(0,Q.jsx)(`b`,{className:`th-count`,children:n})]},e))}),f!==`queue`&&(0,Q.jsxs)(`div`,{className:`th-toolbar`,children:[(0,Q.jsx)(`div`,{className:`th-chips`,role:`group`,"aria-label":J(`trackers.hub.filter`),children:yd().filter(e=>!e.pr||f===`pr`||f===`all`).map(e=>(0,Q.jsx)(`button`,{className:m===e.key?`on`:``,"aria-pressed":m===e.key,onClick:()=>{h(e.key),Cd(`lec-tasks-filter`,e.key)},children:e.label},e.key))}),O.length>1&&(0,Q.jsx)(`select`,{className:`th-team`,"aria-label":J(`trackers.hub.linearTeam`),value:A,onChange:e=>j(e.target.value),children:O.map(e=>(0,Q.jsxs)(`option`,{value:e.key,children:[e.name,` (`,e.key,`)`]},e.key))}),(0,Q.jsx)(`input`,{className:`th-search`,type:`search`,"aria-label":J(`trackers.hub.search`),placeholder:J(`trackers.hub.searchPlaceholder`),value:v,onChange:e=>y(e.target.value)}),(0,Q.jsx)(`div`,{className:`th-viewtoggle`,role:`group`,"aria-label":J(`trackers.hub.view`),children:[`list`,`board`,`table`].map(e=>(0,Q.jsx)(`button`,{className:g===e?`on`:``,"aria-pressed":g===e,onClick:()=>{_(e),Cd(`lec-tasks-view`,e)},children:bd()[e]},e))})]}),te?.error&&!te.repo&&(f===`all`||f===`pr`||f===`issue`)&&(0,Q.jsxs)(`p`,{className:`th-banner`,role:`status`,children:[te.error,` `,L&&(0,Q.jsx)(`button`,{className:`b`,onClick:()=>o(L),children:J(`trackers.hub.setUp`)})]}),U.map((e,t)=>(0,Q.jsxs)(`p`,{className:`th-banner th-banner-err`,role:`status`,children:[(0,Q.jsx)(`b`,{children:e.name}),` (`,ac[e.source],`): `,e.error]},t)),P&&(0,Q.jsx)(`p`,{className:`th-banner th-banner-err`,role:`alert`,children:P}),(0,Q.jsxs)(`div`,{className:`th-body`,children:[(0,Q.jsxs)(`div`,{className:`th-list`,"aria-busy":M,children:[f===`queue`&&L&&ne&&(0,Q.jsx)(hd,{api:e,projectId:L,source:te.kind,onOpen:R,onNotice:r}),f!==`queue`&&!M&&w&&H.length===0&&(0,Q.jsx)(`p`,{className:`th-empty`,children:J(v?`trackers.hub.emptySearch`:`trackers.hub.empty`)}),!w&&M&&(0,Q.jsx)(`p`,{className:`th-empty`,children:J(`trackers.loading`)}),f!==`queue`&&g===`list`&&(0,Q.jsx)(`ul`,{className:`th-rows`,children:H.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{className:`th-row ${hc(u,e)?`on`:``}`,onClick:()=>R({source:e.source,kind:e.kind,id:e.id,connection_id:e.connection_id}),children:[(0,Q.jsx)(`span`,{className:`th-kind th-kind-${e.kind} th-src-${e.source}`,"aria-hidden":`true`,children:e.kind===`pr`?`⇄`:e.source===`linear`?`◆`:e.source===`jira`?`◼`:`●`}),(0,Q.jsxs)(`span`,{className:`th-row-main`,children:[(0,Q.jsx)(`span`,{className:`th-row-title`,children:e.title}),(0,Q.jsxs)(`span`,{className:`th-row-meta`,children:[(0,Q.jsx)(`span`,{className:`th-num`,children:dc(e)}),(0,Q.jsx)($u,{item:e}),e.kind===`pr`&&e.head&&(0,Q.jsx)(`code`,{className:`th-branch`,children:e.head}),e.author&&(0,Q.jsx)(`span`,{children:J(`trackers.hub.by`,{name:e.author})}),(0,Q.jsx)(`span`,{children:wc(e.updated_at)})]}),(0,Q.jsxs)(`span`,{className:`th-row-badges`,children:[(0,Q.jsx)(td,{checks:e.checks}),(0,Q.jsx)(id,{review:e.review}),e.conflicts&&(0,Q.jsx)(`span`,{className:`th-badge th-conflicts`,children:J(`trackers.conflictsBadge`)}),e.priority&&e.priority!==`No priority`&&(0,Q.jsx)(`span`,{className:`th-badge`,children:e.priority}),(0,Q.jsx)(ad,{labels:e.labels})]})]}),e.assignees[0]&&(0,Q.jsx)(cd,{name:e.assignees[0]})]})},`${e.source}/${e.connection_id||0}/${e.kind}/${e.id}`))}),f!==`queue`&&g===`table`&&H.length>0&&(0,Q.jsx)(`div`,{className:`th-table-wrap`,children:(0,Q.jsxs)(`table`,{className:`th-table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:J(`trackers.hub.col.id`)}),(0,Q.jsx)(`th`,{children:J(`trackers.hub.col.title`)}),(0,Q.jsx)(`th`,{children:J(`trackers.hub.col.status`)}),(0,Q.jsx)(`th`,{children:J(`trackers.hub.col.assignees`)}),(0,Q.jsx)(`th`,{children:J(`trackers.hub.col.updated`)})]})}),(0,Q.jsx)(`tbody`,{children:H.map(e=>(0,Q.jsxs)(`tr`,{className:hc(u,e)?`on`:``,onClick:()=>R({source:e.source,kind:e.kind,id:e.id,connection_id:e.connection_id}),children:[(0,Q.jsx)(`td`,{className:`th-num`,children:dc(e)}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`button`,{className:`th-cell-btn`,onClick:t=>{t.stopPropagation(),R({source:e.source,kind:e.kind,id:e.id,connection_id:e.connection_id})},children:e.title}),` `,(0,Q.jsx)(td,{checks:e.checks})]}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)($u,{item:e})}),(0,Q.jsx)(`td`,{children:e.assignees.join(`, `)||`—`}),(0,Q.jsx)(`td`,{children:wc(e.updated_at)})]},`${e.source}/${e.connection_id||0}/${e.kind}/${e.id}`))})]})}),f!==`queue`&&g===`board`&&(0,Q.jsx)(`div`,{className:`th-board`,children:xc(H,B?.kind===`linear`&&(m===`all`||m===`open`)?E.filter(e=>m===`all`||![`completed`,`canceled`].includes(e.type||``)):[]).map(e=>(0,Q.jsxs)(`div`,{className:`th-col`,children:[(0,Q.jsxs)(`h4`,{children:[e.title,` `,(0,Q.jsx)(`b`,{children:e.items.length})]}),e.items.map(e=>(0,Q.jsxs)(`button`,{className:`th-card ${hc(u,e)?`on`:``}`,onClick:()=>R({source:e.source,kind:e.kind,id:e.id,connection_id:e.connection_id}),children:[(0,Q.jsx)(`span`,{className:`th-num`,children:dc(e)}),(0,Q.jsx)(`span`,{className:`th-row-title`,children:e.title}),(0,Q.jsxs)(`span`,{className:`th-row-badges`,children:[(0,Q.jsx)(td,{checks:e.checks}),e.assignees[0]&&(0,Q.jsx)(`span`,{className:`th-muted`,children:e.assignees[0]})]})]},`${e.source}/${e.connection_id||0}/${e.kind}/${e.id}`))]},e.key))})]}),K&&(0,Q.jsx)(`aside`,{className:`th-detail`,"aria-label":J(`trackers.hub.details`),children:K})]})]})}function Td(e){return J(`board.evals.status.${e}`,void 0,e)}function Ed(e){switch(e){case`passed`:return`ev-pass`;case`failed`:return`ev-fail`;case`error`:case`timeout`:return`ev-error`;case`running`:return`ev-running`;default:return`ev-queued`}}function Dd({api:e,projects:t,onClose:n,onNotice:r}){Y();let[i,a]=(0,X.useState)(t[0]?.id??0),[o,s]=(0,X.useState)([]),[c,l]=(0,X.useState)(),[u,d]=(0,X.useState)([]),[f,p]=(0,X.useState)([]),[m,h]=(0,X.useState)(),[g,_]=(0,X.useState)(),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(``),[S,C]=(0,X.useState)(``),[w,T]=(0,X.useState)({name:``,prompt:``,base_ref:``,check_command:``,timeout_s:900,setup_command:``}),[E,D]=(0,X.useState)([{agent:`claude`,model:``,permissionMode:``}]),[k,A]=(0,X.useState)(1),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(!1),[F,I]=(0,X.useState)(20),[L,R]=(0,X.useState)(400),[z,B]=(0,X.useState)(``),[V,H]=(0,X.useState)(!1),[U,ee]=(0,X.useState)(),[W,te]=(0,X.useState)(new Set),[G,ne]=(0,X.useState)(),[K,q]=(0,X.useState)(),[re,ie]=(0,X.useState)(),ae=o.find(e=>e.id===c);async function se(t){try{s(await e.request(`/evals/suites?project_id=${t}`))}catch(e){r(String(e),!0)}}(0,X.useEffect)(()=>{i&&se(i)},[i]);async function ce(t){l(t),h(void 0),_(void 0);try{let n=await e.request(`/evals/suites/${t}`);d(n.cases),p(await e.request(`/evals/suites/${t}/runs`))}catch(e){r(String(e),!0)}}async function le(){if(!b.trim())return r(J(`board.evals.nameRequired`),!0);try{let t=await e.request(`/evals/suites`,{method:`POST`,body:{name:b.trim(),project_id:i,description:S}});x(``),C(``),await se(i),await ce(t.id)}catch(e){r(String(e),!0)}}async function ue(){y(!0);try{let t=await e.request(`/evals/suites/import`,{method:`POST`,body:{project_id:i}});await se(i),r(J(`board.evals.imported`,{n:t.imported.length})+(t.failed.length?J(`board.evals.importFailed`,{n:t.failed.length}):``),t.failed.length>0&&t.imported.length===0)}catch(e){r(String(e),!0)}finally{y(!1)}}async function de(){if(i){H(!0);try{ee(await e.request(`/evals/replay/preview`,{method:`POST`,body:{project_id:i,n:F,max_changed_lines:L}}))}catch(e){r(String(e),!0)}finally{H(!1)}}}async function fe(){if(!z.trim())return r(J(`board.evals.nameRequired`),!0);H(!0);try{let t=await e.request(`/evals/replay/suites`,{method:`POST`,body:{project_id:i,n:F,max_changed_lines:L,name:z.trim()}});B(``),ee(void 0),P(!1),await se(i),await ce(t.suite.id),r(J(`board.evals.replayCreated`))}catch(e){r(String(e),!0)}finally{H(!1)}}async function pe(){if(c){if(!w.name.trim()||!w.prompt.trim())return r(J(`board.evals.namePromptRequired`),!0);try{await e.request(`/evals/suites/${c}/cases`,{method:`POST`,body:w}),T({name:``,prompt:``,base_ref:``,check_command:``,timeout_s:900,setup_command:``});let t=await e.request(`/evals/suites/${c}`);d(t.cases)}catch(e){r(String(e),!0)}}}async function me(t){if(!c)return;await e.request(`/evals/cases/${t}`,{method:`DELETE`});let n=await e.request(`/evals/suites/${c}`);d(n.cases)}async function he(){if(c){y(!0);try{let t=await e.request(`/evals/suites/${c}/runs`,{method:`POST`,body:{variants:E.map(e=>({agent:e.agent,model:e.model,permission_mode:e.permissionMode})),repeats:k,with_judge:j}});p(await e.request(`/evals/suites/${c}/runs`)),await ge(t.id),r(J(`board.evals.runStarted`))}catch(e){r(String(e),!0)}finally{y(!1)}}}async function ge(t){h(t),ne(void 0),q(void 0),ie(void 0);try{_(await e.request(`/evals/runs/${t}`))}catch(e){r(String(e),!0)}}(0,X.useEffect)(()=>{if(!m||g?.run.status===`done`||g?.run.status===`cancelled`)return;let e=setInterval(()=>void ge(m),2e3);return()=>clearInterval(e)},[m,g?.run.status]);async function _e(){if(m)try{await e.request(`/evals/runs/${m}/cancel`,{method:`POST`}),await ge(m)}catch(e){r(String(e),!0)}}async function ve(){let t=Array.from(W),[n,i]=t;if(t.length!==2||n==null||i==null)return r(J(`board.evals.pickTwo`),!0);try{let t=await e.request(`/evals/runs/${n}/compare/${i}`);ne({a:n,b:i,cases:t.cases})}catch(e){r(String(e),!0)}}async function ye(t){if(q(t),ie(void 0),t.task_id)try{ie(await e.request(`/tasks/${t.task_id}/diff`))}catch{}}let be=(0,X.useMemo)(()=>{if(!g)return[];let e=new Map;for(let t of g.results){let n=`${t.case_id}:${t.variant_idx}`,r=e.get(n)??[];r.push(t),e.set(n,r)}return g.cases.map(t=>({case:t,cells:g.variants.map((n,r)=>({variant:n,results:e.get(`${t.id}:${r}`)??[]}))}))},[g]);return(0,Q.jsxs)(O,{id:`evals-sheet`,open:!0,className:`sheet evals-sheet`,"aria-label":J(`board.evals.title`),onCancel:n,children:[(0,Q.jsxs)(`header`,{className:`sheet-head`,children:[(0,Q.jsx)(`h2`,{children:J(`board.evals.title`)}),(0,Q.jsx)(`button`,{onClick:n,children:`✕`})]}),!ae&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`label`,{children:[J(`board.evals.project`),(0,Q.jsx)(`select`,{id:`ev-project`,value:i,onChange:e=>a(Number(e.target.value)),children:t.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.name},e.id))})]}),(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{id:`ev-import-repo`,className:`b`,disabled:v,onClick:()=>void ue(),children:J(`board.evals.importFromRepo`)}),(0,Q.jsx)(`button`,{id:`ev-replay-import-open`,className:`b`,disabled:v,onClick:()=>P(e=>!e),children:J(`board.evals.newReplaySuite`)})]}),N&&(0,Q.jsxs)(`div`,{className:`ev-replay-import`,children:[(0,Q.jsx)(`p`,{className:`subhint`,children:J(`board.evals.replayIntro`)}),(0,Q.jsxs)(`div`,{className:`ev-replay-form`,children:[(0,Q.jsxs)(`label`,{children:[J(`board.evals.prsToConsider`),(0,Q.jsx)(`input`,{id:`ev-replay-n`,type:`number`,min:1,max:100,value:F,onChange:e=>I(Number(e.target.value))})]}),(0,Q.jsxs)(`label`,{children:[J(`board.evals.maxChangedLines`),(0,Q.jsx)(`input`,{id:`ev-replay-max-lines`,type:`number`,min:1,value:L,onChange:e=>R(Number(e.target.value))})]}),(0,Q.jsx)(`button`,{id:`ev-replay-preview`,className:`b`,disabled:V,onClick:()=>void de(),children:J(`board.evals.preview`)})]}),U&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`subhint`,children:J(`board.evals.previewSummary`,{source:U.source===`gh`?J(`board.evals.sourceGh`):J(`board.evals.sourceGitLog`),accepted:U.candidates.filter(e=>e.accepted).length,total:U.candidates.length})}),(0,Q.jsxs)(`div`,{className:`ev-candidate-list`,children:[U.candidates.map(e=>(0,Q.jsxs)(`article`,{className:`ev-candidate-row ${e.accepted?`ev-candidate-ok`:`ev-candidate-skip`}`,children:[(0,Q.jsx)(`span`,{className:`ev-badge ${e.accepted?`ev-pass`:`ev-queued`}`,children:e.accepted?J(`board.evals.included`):J(`board.evals.skipped`)}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`b`,{children:J(`board.evals.prTitle`,{n:e.pr_number,title:e.title})}),(0,Q.jsx)(`span`,{className:`subhint`,children:e.accepted?J(`board.evals.changedLines`,{n:e.changed_lines})+(e.case?.matched_tests?.length?J(`board.evals.matchedTests`,{tests:e.case.matched_tests.join(`, `)}):``):e.skip_reason})]})]},e.pr_number)),U.candidates.length===0&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`board.evals.noMergedPrs`)})]}),(0,Q.jsxs)(`div`,{className:`ev-new-suite`,children:[(0,Q.jsxs)(`label`,{children:[J(`board.evals.suiteName`),(0,Q.jsx)(`input`,{id:`ev-replay-name`,value:z,onChange:e=>B(e.target.value)})]}),(0,Q.jsx)(`button`,{id:`ev-replay-create`,className:`b ok`,disabled:V||!U.candidates.some(e=>e.accepted),onClick:()=>void fe(),children:J(`board.evals.createFromPrs`,{n:U.candidates.filter(e=>e.accepted).length})})]})]})]}),(0,Q.jsxs)(`div`,{className:`ev-suite-list`,children:[o.map(e=>(0,Q.jsxs)(`article`,{className:`ev-suite-row`,onClick:()=>void ce(e.id),children:[(0,Q.jsx)(`b`,{children:e.name}),(0,Q.jsx)(`span`,{className:`subhint`,children:e.description})]},e.id)),o.length===0&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`board.evals.noSuites`)})]}),(0,Q.jsxs)(`div`,{className:`ev-new-suite`,children:[(0,Q.jsxs)(`label`,{children:[J(`board.evals.newSuiteName`),(0,Q.jsx)(`input`,{id:`ev-new-suite-name`,value:b,onChange:e=>x(e.target.value)})]}),(0,Q.jsxs)(`label`,{children:[J(`board.evals.description`),(0,Q.jsx)(`input`,{value:S,onChange:e=>C(e.target.value)})]}),(0,Q.jsx)(`button`,{id:`ev-create-suite`,className:`b ok`,onClick:()=>void le(),children:J(`board.evals.createSuite`)})]})]}),ae&&!m&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsx)(`button`,{className:`b`,onClick:()=>{l(void 0),te(new Set)},children:J(`board.evals.backToSuites`)}),(0,Q.jsx)(`b`,{children:ae.name})]}),(0,Q.jsx)(`h3`,{children:J(`board.evals.cases`)}),(0,Q.jsxs)(`div`,{className:`ev-case-list`,children:[u.map(e=>(0,Q.jsxs)(`article`,{className:`ev-case-row`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`b`,{children:[e.is_replay&&(0,Q.jsx)(`span`,{className:`ev-badge ev-queued`,children:J(`board.evals.prNumber`,{n:e.source_pr_number??``})}),` `,e.name]}),(0,Q.jsx)(`span`,{className:`subhint`,children:e.check_command||J(`board.evals.noCheckCommand`)})]}),(0,Q.jsx)(`button`,{className:`b no`,onClick:()=>void me(e.id),children:`✕`})]},e.id)),u.length===0&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`board.evals.noCases`)})]}),(0,Q.jsxs)(`div`,{className:`ev-new-case`,children:[(0,Q.jsx)(`input`,{placeholder:J(`board.evals.caseNamePlaceholder`),id:`ev-case-name`,value:w.name,onChange:e=>T({...w,name:e.target.value})}),(0,Q.jsx)(`textarea`,{placeholder:J(`board.evals.promptPlaceholder`),id:`ev-case-prompt`,value:w.prompt,onChange:e=>T({...w,prompt:e.target.value})}),(0,Q.jsx)(`input`,{placeholder:J(`board.evals.baseRefPlaceholder`),value:w.base_ref,onChange:e=>T({...w,base_ref:e.target.value})}),(0,Q.jsx)(`input`,{placeholder:J(`board.evals.checkCommandPlaceholder`),value:w.check_command,onChange:e=>T({...w,check_command:e.target.value})}),(0,Q.jsx)(`input`,{placeholder:J(`board.evals.setupCommandPlaceholder`),value:w.setup_command,onChange:e=>T({...w,setup_command:e.target.value})}),(0,Q.jsx)(`input`,{type:`number`,min:1,value:w.timeout_s,onChange:e=>T({...w,timeout_s:Number(e.target.value)})}),(0,Q.jsx)(`button`,{id:`ev-add-case`,className:`b ok`,onClick:()=>void pe(),children:J(`board.evals.addCase`)})]}),(0,Q.jsx)(`h3`,{children:J(`board.evals.runs`)}),(0,Q.jsxs)(`div`,{className:`ev-run-list`,children:[f.map(e=>(0,Q.jsxs)(`article`,{className:`ev-run-row`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,"aria-label":J(`board.evals.selectRun`,{id:e.id}),checked:W.has(e.id),onChange:t=>{te(n=>{let r=new Set(n);return t.target.checked?r.add(e.id):r.delete(e.id),r})}}),(0,Q.jsx)(`span`,{className:`ev-badge ${Ed(e.status)}`,children:Td(e.status)}),(0,Q.jsx)(`span`,{children:J(`board.evals.runRow`,{id:e.id,repeats:e.repeats})}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>void ge(e.id),children:J(`board.evals.open`)})]},e.id)),f.length===0&&(0,Q.jsx)(`p`,{className:`subhint`,children:J(`board.evals.noRuns`)})]}),W.size===2&&(0,Q.jsx)(`button`,{className:`b ok`,onClick:()=>void ve(),children:J(`board.evals.compareSelected`)}),G&&(0,Q.jsxs)(`div`,{className:`ev-compare`,children:[(0,Q.jsx)(`h4`,{children:J(`board.evals.compareHeading`,{a:G.a,b:G.b})}),(0,Q.jsxs)(`table`,{children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:J(`board.evals.case`)}),(0,Q.jsx)(`th`,{children:`A`}),(0,Q.jsx)(`th`,{children:`B`}),(0,Q.jsx)(`th`,{children:`Δ`})]})}),(0,Q.jsx)(`tbody`,{children:G.cases.map(e=>(0,Q.jsxs)(`tr`,{className:`ev-cmp-${e.status}`,children:[(0,Q.jsx)(`td`,{children:u.find(t=>t.id===e.case_id)?.name??J(`board.evals.caseFallback`,{id:e.case_id})}),(0,Q.jsxs)(`td`,{children:[Math.round(e.pass_rate_a*100),`%`]}),(0,Q.jsxs)(`td`,{children:[Math.round(e.pass_rate_b*100),`%`]}),(0,Q.jsxs)(`td`,{children:[e.delta>0?`▲`:e.delta<0?`▼`:`=`,` `,Td(e.status)]})]},e.case_id))})]})]}),(0,Q.jsx)(`h3`,{children:J(`board.evals.newRun`)}),(0,Q.jsxs)(`div`,{className:`ev-variants`,children:[E.map((e,t)=>(0,Q.jsxs)(`div`,{className:`variant-row`,children:[(0,Q.jsxs)(`select`,{value:e.agent,onChange:e=>{let n=e.target.value;D(e=>e.map((e,r)=>r===t?{...e,agent:n}:e))},children:[(0,Q.jsx)(`option`,{value:`claude`,children:`claude`}),(0,Q.jsx)(`option`,{value:`codex`,children:`codex`}),(0,Q.jsx)(`option`,{value:`gemini`,children:`gemini`})]}),(0,Q.jsx)(`input`,{placeholder:J(`board.evals.modelPlaceholder`),value:e.model,onChange:e=>{let n=e.target.value;D(e=>e.map((e,r)=>r===t?{...e,model:n}:e))}}),(0,Q.jsxs)(`select`,{value:e.permissionMode,onChange:e=>{let n=e.target.value;D(e=>e.map((e,r)=>r===t?{...e,permissionMode:n}:e))},children:[(0,Q.jsx)(`option`,{value:``,children:`acceptEdits`}),(0,Q.jsx)(`option`,{value:`plan`,children:`plan`}),(0,Q.jsx)(`option`,{value:`bypassPermissions`,children:`bypass`})]}),E.length>1&&(0,Q.jsx)(`button`,{className:`variant-remove`,onClick:()=>D(e=>e.filter((e,n)=>n!==t)),children:`✕`})]},t)),(0,Q.jsx)(`button`,{className:`b`,disabled:E.length>=8,onClick:()=>D(e=>[...e,{agent:`claude`,model:``,permissionMode:``}]),children:J(`board.evals.addVariant`)})]}),(0,Q.jsxs)(`label`,{children:[J(`board.evals.repeats`),(0,Q.jsx)(`input`,{type:`number`,min:1,max:10,value:k,onChange:e=>A(Number(e.target.value))})]}),u.some(e=>e.is_replay)&&(0,Q.jsxs)(`label`,{className:`ev-with-judge`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:j,onChange:e=>M(e.target.checked)}),J(`board.evals.runJudge`)]}),(0,Q.jsx)(`button`,{id:`ev-run-suite`,className:`b ok`,disabled:v||u.length===0,onClick:()=>void he(),children:J(`board.evals.runSuite`)})]}),ae&&m&&g&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`btnrow`,children:[(0,Q.jsxs)(`button`,{className:`b`,onClick:()=>h(void 0),children:[`← `,ae.name]}),(0,Q.jsx)(`span`,{className:`ev-badge ${Ed(g.run.status)}`,children:Td(g.run.status)}),[`queued`,`running`].includes(g.run.status)&&(0,Q.jsx)(`button`,{className:`b no`,onClick:()=>void _e(),children:J(`board.evals.cancel`)})]}),(0,Q.jsx)(`h3`,{children:J(`board.evals.matrix`)}),(0,Q.jsx)(`div`,{className:`ev-matrix-wrap`,children:(0,Q.jsxs)(`table`,{className:`ev-matrix`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:J(`board.evals.case`)}),g.variants.map((e,t)=>(0,Q.jsxs)(`th`,{children:[J(`board.evals.variantShort`,{n:t+1}),`: `,e.agent,e.model&&` · ${e.model}`]},t))]})}),(0,Q.jsx)(`tbody`,{children:be.map(({case:e,cells:t})=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:e.name}),t.map((e,t)=>{let n=e.results.filter(e=>e.status===`passed`).length,r=e.results.length,i=e.results.find(e=>e.status!==`passed`)??e.results[0];return(0,Q.jsx)(`td`,{className:`ev-cell ${i?Ed(i.status):``}`,onClick:()=>i&&void ye(i),children:r?`${n}/${r}`:`—`},t)})]},e.id))})]})}),K&&(0,Q.jsxs)(`div`,{className:`ev-cell-detail`,children:[(0,Q.jsxs)(`header`,{children:[(0,Q.jsx)(`b`,{className:`ev-badge ${Ed(K.status)}`,children:Td(K.status)}),K.duration_s!=null&&` · ${K.duration_s.toFixed(1)}s`,K.cost_usd!=null&&` · $${K.cost_usd.toFixed(3)}`,K.check_rc!=null&&J(`board.evals.checkRc`,{rc:K.check_rc}),(0,Q.jsx)(`button`,{className:`b`,onClick:()=>q(void 0),children:`✕`})]}),K.check_output_tail&&(0,Q.jsx)(`pre`,{className:`ev-check-output`,children:K.check_output_tail}),(()=>{let e=u.find(e=>e.id===K.case_id),t=e?.is_replay;return(0,Q.jsxs)(Q.Fragment,{children:[t&&(0,Q.jsxs)(`div`,{className:`ev-similarity-row`,children:[K.similarity_files!=null&&(0,Q.jsx)(`span`,{className:`ev-badge ev-queued`,children:J(`board.evals.filesMatch`,{pct:Math.round(K.similarity_files*100)})}),K.similarity_lines!=null&&(0,Q.jsx)(`span`,{className:`ev-badge ev-queued`,children:J(`board.evals.linesMatch`,{pct:Math.round(K.similarity_lines*100)})}),K.size_ratio!=null&&(0,Q.jsx)(`span`,{className:`ev-badge ev-queued`,children:J(`board.evals.sizeRatio`,{ratio:K.size_ratio.toFixed(2)})}),K.judge_status===`done`&&(0,Q.jsx)(`span`,{className:`ev-badge ${K.judge_match?`ev-pass`:`ev-fail`}`,children:J(`board.evals.judgeResult`,{result:K.judge_match?J(`board.evals.judgeMatch`):J(`board.evals.judgeNoMatch`)})}),K.judge_status===`queued`&&(0,Q.jsx)(`span`,{className:`ev-badge ev-running`,children:J(`board.evals.judgePending`)})]}),K.judge_reason&&(0,Q.jsx)(`p`,{className:`subhint`,children:K.judge_reason}),re&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h4`,{children:J(`board.evals.attemptDiff`)}),(0,Q.jsx)(oe,{files:re.files,stats:re.stats,wrap:!1})]}),t&&e?.reference_files&&e.reference_files.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`h4`,{children:J(`board.evals.referenceDiff`,{n:e.source_pr_number??``})}),(0,Q.jsx)(oe,{files:e.reference_files,stats:[],wrap:!1})]})]})})()]}),(0,Q.jsx)(`h3`,{children:J(`board.evals.leaderboard`)}),(0,Q.jsxs)(`table`,{className:`ev-leaderboard`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:J(`board.evals.variant`)}),(0,Q.jsx)(`th`,{children:J(`board.evals.passRate`)}),(0,Q.jsx)(`th`,{children:J(`board.evals.meanDuration`)}),(0,Q.jsx)(`th`,{children:J(`board.evals.totalCost`)}),(0,Q.jsx)(`th`,{children:J(`board.compare.costPerPass`)}),(0,Q.jsx)(`th`,{children:J(`board.evals.meanTokens`)}),g.leaderboard.some(e=>e.scored_count>0)&&(0,Q.jsx)(`th`,{children:J(`board.evals.similarity`)}),g.leaderboard.some(e=>e.judged_count>0)&&(0,Q.jsx)(`th`,{children:J(`board.evals.matchesReference`)})]})}),(0,Q.jsx)(`tbody`,{children:g.leaderboard.map(e=>{let t=g.variants[e.variant_idx];return(0,Q.jsxs)(`tr`,{children:[(0,Q.jsxs)(`td`,{children:[J(`board.evals.variantShort`,{n:e.variant_idx+1}),t&&`: ${t.agent}${t.model?` · ${t.model}`:``}`]}),(0,Q.jsxs)(`td`,{children:[Math.round(e.pass_rate*100),`% (`,e.passed,`/`,e.passed+e.failed+e.errored,`)`]}),(0,Q.jsx)(`td`,{children:e.mean_duration_s?`${e.mean_duration_s.toFixed(1)}s`:`—`}),(0,Q.jsxs)(`td`,{children:[`$`,e.total_cost_usd.toFixed(3)]}),(0,Q.jsx)(`td`,{children:e.cost_per_pass?`$${e.cost_per_pass.toFixed(3)}`:`—`}),(0,Q.jsx)(`td`,{children:J(`board.evals.tokensInOut`,{input:e.mean_input_tokens?Math.round(e.mean_input_tokens):0,output:e.mean_output_tokens?Math.round(e.mean_output_tokens):0})}),g.leaderboard.some(e=>e.scored_count>0)&&(0,Q.jsx)(`td`,{children:e.scored_count?J(`board.evals.similarityValue`,{files:Math.round(e.mean_similarity_files*100),lines:Math.round(e.mean_similarity_lines*100)}):`—`}),g.leaderboard.some(e=>e.judged_count>0)&&(0,Q.jsx)(`td`,{children:e.judged_count?`${Math.round(e.judge_match_rate*100)}% (${e.judged_count})`:`—`})]},e.variant_idx)})})]})]})]})}var Od=[],kd=0;function Ad(e,t){let n=(0,X.useRef)(t);n.current=t,(0,X.useEffect)(()=>{if(!e)return;let t={id:++kd,close:()=>n.current()};return Od.push(t),()=>{let e=Od.indexOf(t);e>=0&&Od.splice(e,1)}},[e])}var jd=`details.action-menu[open], details.terminal-actions[open], details.ws-layouts[open], details[open][data-back-close]`;function Md(e){let t=[e];for(let n of e.querySelectorAll(`iframe`))try{let e=n.contentDocument;e&&n.getClientRects().length&&t.push(...Md(e))}catch{}return t}function Nd(e=document){let t=Md(e);for(let e of t.slice().reverse()){let t=[...e.querySelectorAll(`dialog[open]`)],n=t[t.length-1];if(n){let e=new Event(`cancel`,{cancelable:!0});if(n.dispatchEvent(e),!e.defaultPrevented){let e=n.querySelector(`[data-close], .modal-close, .sheet-close`);e?e.click():n.close()}return!0}let r=[...e.querySelectorAll(`[data-back-overlay]`)].filter(e=>e.getClientRects().length>0);r.sort((e,t)=>Number(e.dataset.backOverlay)-Number(t.dataset.backOverlay));let i=r[r.length-1];if(i){let t=i.querySelector(`:scope > [data-close], :scope > * > [data-close], [data-close]`);return t?t.click():e.dispatchEvent(new KeyboardEvent(`keydown`,{key:`Escape`,bubbles:!0})),!0}let a=[...e.querySelectorAll(jd)],o=a[a.length-1];if(o)return o.open=!1,!0}return!1}var Pd=[],Fd,Id=0;function Ld(e,t=Date.now()){Pd[Pd.length-1]!==e&&(Id||=t,Pd.length===1&&t-Id<2e3?Pd[0]=e:Pd.push(e),Pd.length>50&&Pd.shift())}function Rd(e){Fd=e}function zd(){let e=Od[Od.length-1];return e?(e.close(),!0):Nd()?!0:Pd.length>1&&Fd?(Pd.pop(),Fd(Pd[Pd.length-1]),!0):!1}typeof window<`u`&&(window.__lecternBack=zd);function Bd(e){let t=new URL(e,location.origin),n=t.pathname.replace(/^\/term\//,`/terminal/`).replace(/\/$/,``);if(t.origin!==location.origin||!/^\/terminal\/(session|attempt|project)\/[1-9]\d*$/.test(n))throw Error(J(`terminalPage.tabs.invalidAddress`));return n}var Vd=e=>e&&e.startsWith(`/terminal/`)?`#terminals/`+e.split(`/`).slice(-2).join(`/`):`#terminals`,Hd=e=>`terminal-tab-`+e.replace(/^\/terminal\//,``).replace(/[^A-Za-z0-9_-]+/g,`-`);function Ud(e,t){let n=new AbortController,r,i=(t,r,i=!0)=>e.addEventListener(t,r,{signal:n.signal,passive:i});return i(`touchstart`,e=>{let n=e.touches[0];if(!t.enabled()||e.touches.length!==1||!n||t.blocked(e.target)){r=void 0;return}r={x:n.clientX,y:n.clientY,at:performance.now(),maxVertical:0}}),i(`touchmove`,e=>{let t=e.touches[0];if(!r||e.touches.length!==1||!t){r=void 0;return}r.maxVertical=Math.max(r.maxVertical,Math.abs(t.clientY-r.y))}),i(`touchcancel`,()=>{r=void 0}),i(`touchend`,e=>{let n=r;r=void 0;let i=e.changedTouches[0];if(!n||!t.enabled()||e.changedTouches.length!==1||!i)return;let a=i.clientX-n.x,o=i.clientY-n.y,s=performance.now()-n.at,c=t.width(),l=Math.max(Math.min(72,c*.45),Math.min(140,c*.22));s<=550&&n.maxVertical=l&&Math.abs(a)>=Math.abs(o)*1.6&&!t.selected()&&t.relative(a<0?1:-1)&&e.preventDefault()},!1),()=>n.abort()}function Wd(e){Y();let t=(0,X.useRef)(null),n=(0,X.useRef)(e);n.current=e;let r=()=>{let e=n.current;e.shown&&e.visible&&t.current?.contentWindow?.postMessage({type:`lec-terminal-visible`,mobile:e.mobile,compact:e.mobile&&e.compact},location.origin)},i=()=>{let e=n.current,r=t.current;if(!e.shown||!e.visible||!r)return;let i=r.contentWindow;if(!i)return;let a=he(r);i.postMessage({type:`lec-terminal-viewport`,top:a.top,height:a.height},location.origin)};return(0,X.useEffect)(()=>{r(),i()},[e.shown,e.visible,e.mobile,e.compact,e.primary]),(0,X.useEffect)(()=>{let e=t.current;if(!e)return;let n=new AbortController,r=n.signal,a=window.visualViewport,o,s=()=>{i(),clearTimeout(o),o=window.setTimeout(i,150)};window.addEventListener(`resize`,s,{signal:r}),window.addEventListener(`orientationchange`,s,{signal:r}),a?.addEventListener(`resize`,s,{signal:r}),a?.addEventListener(`scroll`,s,{signal:r}),ae()?.addEventListener(`geometrychange`,s,{signal:r});let c=new ResizeObserver(s);return c.observe(e),()=>{clearTimeout(o),c.disconnect(),n.abort()}},[]),(0,X.useEffect)(()=>{let e=e=>{let r=t.current?.contentWindow;if(!r||e.source!==r||e.origin!==location.origin)return;let a=e.data;if(!a||typeof a!=`object`||!(`type`in a))return;if(a.type===`lec-terminal-need-viewport`){i();return}if(a.type===`lec-terminal-focus`){n.current.onFocus?.();return}if(a.type===`lec-terminal-open-beside`){Gd(n.current.tab.path,a);return}if(a.type!==`lec-terminal-swipe`)return;let o=n.current;o.mobile&&o.visible&&o.shown&&o.primary&&o.relative(`direction`in a&&a.direction===-1?-1:1)};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),(0,Q.jsx)(`iframe`,{ref:t,title:J(`terminalPage.tabs.frameTitle`,{label:e.tab.label}),src:e.tab.path+`?embed=1`,allow:`clipboard-read; clipboard-write`,onLoad:r})}function Gd(e,t){let n=/^\/terminal\/session\/([1-9]\d*)$/.exec(e),r=oa(),i=`path`in t&&typeof t.path==`string`?t.path:``;if(!n||!r||!i||!m(`file`))return;let a=e=>{let n=t[e];return typeof n==`number`&&n>0?n:void 0};ca({...r,session:Number(n[1])},i,a(`line`),a(`column`))}function Kd({machines:e,projects:t,onNew:n}){Y();let[r,i]=(0,X.useState)(!1),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(()=>vr().recent),l=(0,X.useRef)(null),u=(0,X.useRef)(null),d=(0,X.useCallback)(()=>{let e=l.current,t=e?.querySelector(`.terminal-new-picker`),n=e?.querySelector(`summary`);if(!e?.open||!t||!n)return;let r=we(),i=visualViewport?.offsetLeft??0,a=visualViewport?.width??innerWidth;t.style.width=Math.min(340,Math.max(1,a-16))+`px`,t.style.maxHeight=Math.min(440,Math.max(1,r.height-16))+`px`;let o=n.getBoundingClientRect(),s=t.getBoundingClientRect();t.style.left=Math.max(i+8,Math.min(o.right-s.width,i+a-8-s.width))+`px`;let c=o.bottom+6,u=o.top-6-s.height;t.style.top=Math.max(r.top+8,Math.min(c+s.height<=r.top+r.height-8?c:u,r.top+r.height-8-s.height))+`px`},[]);(0,X.useEffect)(()=>{let e=new AbortController,t=e.signal;return addEventListener(`resize`,d,{signal:t}),addEventListener(`scroll`,d,{signal:t,capture:!0}),visualViewport?.addEventListener(`resize`,d,{signal:t}),visualViewport?.addEventListener(`scroll`,d,{signal:t}),ae()?.addEventListener(`geometrychange`,d,{signal:t}),document.addEventListener(`keydown`,e=>{e.key===`Escape`&&l.current?.open&&(e.preventDefault(),l.current.open=!1,l.current.querySelector(`summary`)?.focus())},{signal:t}),()=>e.abort()},[d]),(0,X.useEffect)(()=>{d()},[a,t,e,s,d]);let f=e=>{l.current&&(l.current.open=!1),o(``),i(!0),n(e).finally(()=>{c(vr().recent),i(!1)})};(0,X.useEffect)(()=>{let e=e=>{l.current?.open&&e.target instanceof Node&&!l.current.contains(e.target)&&(l.current.open=!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[]);let p=a.trim().toLowerCase(),m=(...e)=>!p||e.some(e=>e.toLowerCase().includes(p)),h=e.filter(e=>m(e.name)),g=t.filter(e=>m(e.name,e.repo_path,e.target_name||``)),_=e.length>1||t.length>0,{recent:v,rest:y}=Sr(g,s),b=e=>(0,Q.jsxs)(`button`,{role:`menuitem`,className:`terminal-new-project`,disabled:r,onClick:()=>f({projectID:e.id}),children:[(0,Q.jsx)(`span`,{className:`terminal-new-project-name`,children:e.name}),(0,Q.jsxs)(`span`,{className:`terminal-new-project-path`,children:[e.repo_path,e.target_name?` · `+e.target_name:``]})]},`project-`+e.id);return(0,Q.jsxs)(`div`,{className:`terminal-new`,children:[(0,Q.jsx)(`button`,{className:`terminal-new-main`,disabled:r,"aria-label":J(`terminalPage.tabs.newTerminal`),title:J(`terminalPage.tabs.newHint`),onClick:()=>f(),children:r?J(`terminalPage.tabs.opening`):(0,Q.jsxs)(Q.Fragment,{children:[`+`,(0,Q.jsxs)(`span`,{className:`terminal-new-label`,children:[` `,J(`terminalPage.tabs.newTerminal`)]})]})}),_&&(0,Q.jsxs)(`details`,{className:`terminal-new-machines`,ref:l,onToggle:()=>{l.current?.open?(d(),c(vr().recent),matchMedia(`(pointer:fine)`).matches&&u.current?.focus({preventScroll:!0})):o(``)},children:[(0,Q.jsx)(`summary`,{onClick:e=>{e.preventDefault(),l.current&&(l.current.open=!l.current.open,c(vr().recent),d())},"aria-label":J(`terminalPage.tabs.newElsewhere`),title:J(`terminalPage.tabs.newElsewhere`),children:`▾`}),(0,Q.jsxs)(`div`,{className:`terminal-actions-panel terminal-new-picker`,role:`menu`,children:[(0,Q.jsx)(`input`,{ref:u,className:`terminal-new-search`,type:`search`,value:a,"aria-label":J(`terminalPage.tabs.search`),placeholder:J(`terminalPage.tabs.search`),onChange:e=>o(e.target.value)}),v.length>0&&(0,Q.jsx)(`div`,{className:`terminal-new-group`,role:`presentation`,children:J(`terminalPage.tabs.recent`)}),v.map(b),y.length>0&&(0,Q.jsx)(`div`,{className:`terminal-new-group`,role:`presentation`,children:v.length>0?J(`terminalPage.tabs.otherProjects`):J(`terminalPage.tabs.projects`)}),y.map(b),h.length>0&&(0,Q.jsx)(`div`,{className:`terminal-new-group`,role:`presentation`,children:J(`terminalPage.tabs.machines`)}),h.map(e=>(0,Q.jsx)(`button`,{role:`menuitem`,disabled:r,onClick:()=>f({machineID:e.id}),children:e.name},`machine-`+e.id)),h.length===0&&g.length===0&&(0,Q.jsx)(`div`,{className:`terminal-new-empty`,role:`presentation`,children:J(`terminalPage.tabs.noMatches`)})]})]})]})}var qd=(e,t)=>({id:e,kind:`terminal`,title:t,params:{path:e}}),Jd=(e,t)=>({id:`chat:session:${e}`,kind:`chat`,title:J(`panes.chatTitle`,{name:t}),params:{session:String(e)}}),Yd=(e,t)=>({id:`browser:session:${e}`,kind:`browser`,title:J(`panes.browserTitle`,{name:t}),params:{session:String(e)}}),Xd=(e,t)=>({id:`diff:session:${e}`,kind:`diff`,title:J(`panes.diffTitle`,{name:t}),params:{session:String(e)}}),Zd=e=>/^[1-9]\d{0,12}$/.test(e.params.session||``)?Number(e.params.session):0;function Qd(e){if(!e)return 0;if(e.kind===`terminal`){let t=/^\/terminal\/session\/(\d+)$/.exec(e.id);return t?Number(t[1]):0}return Zd(e)}var $d=!1;function ef(){$d||($d=!0,b({kind:`terminal`,label:`Terminal`,icon:`⌨`,check:e=>{try{let t=Bd(e.params.path||e.id);return t===e.id?{...e,params:{path:t}}:null}catch{return null}},popout:e=>e.id,render:({pane:e,shown:t,visible:n,mobile:r,compact:i,primary:a,relative:o,focus:s})=>(0,Q.jsx)(Wd,{tab:{path:e.id,label:e.title},shown:t,visible:n,mobile:r,compact:i,primary:a,relative:o,onFocus:s})}),b({kind:`chat`,label:`Chat`,icon:`💬`,embedsDialog:!0,check:e=>Zd(e)&&e.id===`chat:session:${Zd(e)}`?e:null,render:({pane:e,services:t,close:n})=>{let r=Zd(e);return(0,Q.jsx)(A.Provider,{value:!0,children:(0,Q.jsx)(ro,{kind:`session`,id:r,name:t.sessions.find(e=>e.id===r)?.name||e.title,api:t.api,session:t.sessions.find(e=>e.id===r),onClose:n,onNotice:t.notice,onAttach:()=>t.attach(r),onOpenSession:e=>t.openPane(Jd(e.id,e.name))})})}}),b({kind:`browser`,label:`Browser`,icon:`◎`,check:e=>Zd(e)&&e.id===`browser:session:${Zd(e)}`?e:null,render:({pane:e,services:t,close:n})=>{let r=Zd(e);return(0,Q.jsx)(Qa,{api:t.api,sessionId:r,name:t.sessions.find(e=>e.id===r)?.name||e.title,onClose:n,onNotice:t.notice})}}),b({kind:`diff`,label:`Changes`,icon:`±`,embedsDialog:!0,check:e=>Zd(e)&&e.id===`diff:session:${Zd(e)}`?e:null,render:({pane:e,close:t})=>(0,Q.jsx)(A.Provider,{value:!0,children:(0,Q.jsx)(be,{kind:`session`,id:String(Zd(e)),name:e.title,onClose:t})})}))}var tf=(0,X.lazy)(()=>ot(()=>import(`./PaneViews-DvSfx-Fl.js`).then(e=>({default:e.FilePane})),__vite__mapDeps([0,1,2,3,4,5,6]))),nf=(0,X.lazy)(()=>ot(()=>import(`./PaneViews-DvSfx-Fl.js`).then(e=>({default:e.ExplorerPane})),__vite__mapDeps([0,1,2,3,4,5,6]))),rf=(0,X.lazy)(()=>ot(()=>import(`./PaneViews-DvSfx-Fl.js`).then(e=>({default:e.SearchPane})),__vite__mapDeps([0,1,2,3,4,5,6]))),af=e=>/^[1-9]\d{0,12}$/.test(e.params.session||``)?Number(e.params.session):0,of=()=>(0,Q.jsx)(`p`,{className:`wb-muted`,children:J(`files.loadingViewer`)});b({kind:`file`,label:J(`files.paneFile`),icon:`≡`,check:e=>{let t=af(e),n=e.params.path||``;return t&&n&&!n.startsWith(`//`)&&!n.split(`/`).includes(`..`)&&e.id===`file:session:${t}:${n}`?e:null},popout:e=>`/terminal/session/${af(e)}?open=${encodeURIComponent(e.params.path||``)}${e.params.line?`#L`+e.params.line:``}`,render:({pane:e,services:t,close:n,mobile:r})=>(0,Q.jsx)(X.Suspense,{fallback:of(),children:(0,Q.jsx)(tf,{pane:e,session:af(e),services:t,close:n,mobile:r})})}),b({kind:`files`,label:J(`files.paneExplorer`),icon:`▤`,check:e=>af(e)&&e.id===`files:session:${af(e)}`?e:null,render:({pane:e,services:t,mobile:n})=>(0,Q.jsx)(X.Suspense,{fallback:of(),children:(0,Q.jsx)(nf,{pane:e,session:af(e),services:t,mobile:n})})}),b({kind:`search`,label:J(`files.paneSearch`),icon:`⌕`,check:e=>af(e)&&e.id===`search:session:${af(e)}`?e:null,render:({pane:e,services:t,mobile:n,shown:r})=>(0,Q.jsx)(X.Suspense,{fallback:of(),children:(0,Q.jsx)(rf,{pane:e,session:af(e),services:t,mobile:n,shown:r})})});var sf;function cf(){sf?.unmount(),sf=void 0,document.getElementById(`workspace-quick-open`)?.remove()}ce(`workspace.goToFile`,()=>{let e=oa();if(!e)return!1;cf();let t=document.createElement(`div`);t.id=`workspace-quick-open`,document.body.append(t),sf=(0,Z.createRoot)(t);let n=t=>sf?.render((0,Q.jsx)(je,{index:t.index&&{...t.index,truncated:!1,source:``,elapsed_ms:0},loading:t.loading,error:t.error,recent:[],onClose:cf,onOpen:(t,n,r)=>{cf(),ca(e,t,n,r)}}));n({loading:!0,error:``}),sa(e.session).then(e=>n({index:e,loading:!1,error:``}),e=>n({loading:!1,error:e instanceof Error?e.message:String(e)}))}),ef();var lf=`lec-workspace-v1`,uf=`lec-terminal-tabs-v1`,df=`lec-terminal-tabs-durable-v1`,ff=`workspace.current`,pf=`workspace.layouts`,mf=30,hf=[];function gf(){try{let e=sessionStorage.getItem(lf)||localStorage.getItem(lf);if(e)return au(JSON.parse(e),N);let t=JSON.parse(sessionStorage.getItem(uf)||localStorage.getItem(df)||`null`);if(!t||typeof t!=`object`||!(`tabs`in t)||!Array.isArray(t.tabs))return bl();let n=bl();for(let e of t.tabs.slice(0,30))try{if(!e||typeof e!=`object`||typeof e.path!=`string`)continue;let t=Bd(e.path);n=Fl(n,qd(t,String(e.label||`Terminal`).slice(0,160)),{activate:!1})}catch{}let r=`active`in t&&typeof t.active==`string`?t.active:null,i=`secondary`in t&&typeof t.secondary==`string`?t.secondary:null;return i&&wl(n,i)&&i!==r&&(n=Bl(n,i,xl(n.root)[0].id,`right`)),r&&wl(n,r)&&(n=Il(n,r)),n}catch{return bl()}}function _f(e){let t=JSON.stringify(nu(e));try{sessionStorage.setItem(lf,t)}catch{}try{localStorage.setItem(lf,t)}catch{}}function vf(e){let[t,n]=(0,X.useState)(gf),r=(0,X.useRef)(t),i=(0,X.useRef)(e),a=(0,X.useRef)(void 0);r.current=t,i.current=e;let o=(0,X.useCallback)((e,t=!0)=>{e!==r.current&&(r.current=e,n(e),_f(e),clearTimeout(a.current),a.current=window.setTimeout(()=>j(ff,nu(r.current)),1500),t&&i.current(Vd(El(e))))},[]),s=(0,X.useCallback)((e,t=!0)=>o(e(r.current),t),[o]);(0,X.useEffect)(()=>{if(r.current.panes.length)return;let e=Date.now()+2e4,t=()=>{if(r.current.panes.length||Date.now()>e)return n();if(!f())return;let t=Le(ff,null);if(!t)return;let i=au(t,N);i.panes.length&&(o(i,!1),n())},n=ve(t);return t(),n},[o]);let c=(0,X.useCallback)((e,t)=>{let n=Bd(e),i=wl(r.current,n);s(e=>Fl(e,qd(n,String(t||i?.title||`Terminal`).slice(0,160))))},[s]),l=(0,X.useCallback)((e,t={})=>{let n=N(e);n&&s(e=>{let r=t.beside?Cl(e,t.beside)?.id:void 0;return Fl(e,n,{group:r,edge:r?t.edge:void 0})})},[s]),u=(0,X.useCallback)(e=>s(t=>Il(t,e)),[s]),d=(0,X.useCallback)(e=>{s(t=>Rl(t,e)),requestAnimationFrame(()=>{let e=El(r.current);e&&document.getElementById(Hd(e))?.focus({preventScroll:!0})})},[s]),p=El(t);return{state:t,tabs:(0,X.useMemo)(()=>t.panes.map(e=>({path:e.id,label:e.title})),[t.panes]),active:p,hash:Vd(p),open:c,openPane:l,select:u,close:d,update:s}}function yf({state:e,projectId:t,projectName:n,onRestore:r,onNotice:a,onPlace:o}){let[s]=i(pf,hf),c=ou(s),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(null),[m,h]=(0,X.useState)(!1);(0,X.useEffect)(()=>{m&&o()},[m,o]);let g=c.filter(e=>e.project_id===null||e.project_id===t),_=()=>{let n=l.trim();if(!n)return;let r={id:yl(`l`),name:n.slice(0,80),project_id:d&&t?t:null,saved_at:Date.now(),layout:nu(e)};j(pf,[r,...c.filter(e=>e.name!==r.name||e.project_id!==r.project_id)].slice(0,30)),u(``),a(J(`workspace.layoutSaved`,{name:r.name}))};return(0,Q.jsxs)(`details`,{className:`ws-layouts`,ref:p,onToggle:e=>h(e.currentTarget.open),children:[(0,Q.jsx)(`summary`,{"aria-label":J(`workspace.layouts`),title:J(`workspace.layouts`),children:J(`workspace.layoutsButton`)}),m&&(0,Q.jsxs)(`div`,{className:`terminal-actions-panel ws-layouts-panel`,role:`menu`,children:[g.length===0&&(0,Q.jsx)(`p`,{className:`ws-layouts-empty`,children:J(`workspace.noLayouts`)}),g.map(e=>(0,Q.jsxs)(`div`,{className:`ws-layout-row`,children:[(0,Q.jsxs)(`button`,{role:`menuitem`,className:`ws-layout-restore`,onClick:()=>{r(e),p.current&&(p.current.open=!1)},children:[(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsxs)(`small`,{children:[e.project_id?J(`workspace.projectOnly`):J(`workspace.anyProject`),` · `,e.layout.panes.length,` `,J(`workspace.panes`)]})]}),(0,Q.jsx)(`button`,{className:`ws-layout-delete`,"aria-label":J(`workspace.deleteLayout`,{name:e.name}),onClick:()=>j(pf,c.filter(t=>t.id!==e.id)),children:`×`})]},e.id)),(0,Q.jsxs)(`form`,{className:`ws-layout-save`,onSubmit:e=>{e.preventDefault(),_()},children:[(0,Q.jsx)(`input`,{"aria-label":J(`workspace.layoutName`),placeholder:J(`workspace.layoutName`),value:l,maxLength:80,onChange:e=>u(e.target.value)}),t!==null&&(0,Q.jsxs)(`label`,{className:`ws-layout-scope`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),` `,J(`workspace.onlyFor`,{project:n})]}),(0,Q.jsx)(`button`,{className:`b`,disabled:!l.trim()||!e.panes.length,children:J(`workspace.saveLayout`)})]})]})]})}function bf(e){return[...e.mru,...e.panes.map(e=>e.id)].filter((t,n,r)=>r.indexOf(t)===n&&wl(e,t))}function xf({state:e,index:t,onMove:n,onChoose:r,onCancel:i}){let a=(0,X.useRef)(null),o=bf(e),s=o[(t%o.length+o.length)%o.length];return(0,X.useEffect)(()=>{a.current?.focus({preventScroll:!0})},[]),(0,Q.jsxs)(`div`,{className:`ws-mru`,role:`dialog`,"aria-label":J(`workspace.recentTabs`),tabIndex:-1,ref:a,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||i()},onKeyDown:e=>{e.preventDefault(),e.stopPropagation(),e.key===`Escape`?i():e.key===`Enter`&&s?r(s):e.key===`Tab`||e.key==="`"||e.key===`~`?n(e.shiftKey?-1:1):e.key===`ArrowDown`||e.key===`ArrowRight`?n(1):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&n(-1)},children:[(0,Q.jsx)(`p`,{children:J(`workspace.recentTabs`)}),(0,Q.jsx)(`ol`,{children:o.map(t=>{let n=wl(e,t);return(0,Q.jsxs)(`li`,{"aria-selected":t===s,onPointerDown:e=>e.preventDefault(),onClick:()=>r(t),children:[(0,Q.jsx)(`span`,{className:`ws-mru-icon`,"aria-hidden":`true`,children:m(n.kind)?.icon||`▢`}),(0,Q.jsx)(`span`,{children:n.title}),(0,Q.jsx)(`small`,{children:m(n.kind)?.label})]},t)})})]})}var Sf=e=>`${(e*100).toFixed(4)}%`;function Cf({controller:e,visible:t,machines:n,projects:r,onNew:i,onBrowse:a,onSearch:o,switcher:s,services:c}){Y(),E();let{state:l,update:u}=e;Ad(!!l.maximized,()=>u(e=>Xl(e)));let[d,f]=(0,X.useState)(()=>matchMedia(`(max-width:1023px)`).matches),[p,h]=(0,X.useState)(()=>{try{return localStorage.getItem(`lec-terminal-compact`)!==`0`}catch{return!0}}),[g,_]=(0,X.useState)([]),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(null),[S,C]=(0,X.useState)(null),[w,T]=(0,X.useState)(null),D=(0,X.useRef)(null),O=(0,X.useCallback)(e=>{let t=typeof e==`function`?e(D.current):e;D.current=t,T(t)},[]),k=(0,X.useCallback)(()=>{let e=D.current;if(e===null)return;let t=bf(F.current.controller.state),n=t[(e%t.length+t.length)%t.length];O(null),n&&F.current.controller.select(n)},[O]);(0,X.useEffect)(()=>{let e=e=>{(e.key===`Control`||e.key===`Alt`||e.key===`Meta`)&&k()};return addEventListener(`lec-shortcut-release`,k),addEventListener(`keyup`,e,!0),()=>{removeEventListener(`lec-shortcut-release`,k),removeEventListener(`keyup`,e,!0)}},[k]);let A=(0,X.useRef)(!1),j=(0,X.useRef)(null),M=(0,X.useRef)(null),P=(0,X.useRef)(null),F=(0,X.useRef)({controller:e,visible:t,mobile:d});F.current={controller:e,visible:t,mobile:d};let I=El(l),L=wl(l,I),R=!d&&xl(l.root).length>1,z=d?I?[I]:[]:Dl(l),B=(0,X.useCallback)(()=>{for(let e of document.querySelectorAll(`#terminal-workspace .terminal-tabbar details.terminal-actions, #terminal-workspace .terminal-tabbar details.ws-layouts`)){let t=e.querySelector(`.terminal-actions-panel`),n=e.querySelector(`summary`);if(!e.open||!t||!n)continue;let r=window.visualViewport,i=we(),a=r?.offsetLeft??0,o=i.top,s=r?.width??innerWidth,c=i.height;t.style.width=Math.min(e.classList.contains(`ws-layouts`)?300:240,Math.max(1,s-16))+`px`,t.style.maxHeight=Math.max(1,c-16)+`px`;let l=n.getBoundingClientRect(),u=t.getBoundingClientRect();t.style.left=Math.max(a+8,Math.min(l.right-u.width,a+s-8-u.width))+`px`;let d=l.bottom+6,f=l.top-6-u.height;t.style.top=Math.max(o+8,Math.min(d+u.height<=o+c-8?d:f,o+c-8-u.height))+`px`}},[]);(0,X.useEffect)(()=>{let e=new AbortController,t=e.signal;return addEventListener(`resize`,B,{signal:t}),addEventListener(`scroll`,B,{signal:t,capture:!0}),visualViewport?.addEventListener(`resize`,B,{signal:t}),visualViewport?.addEventListener(`scroll`,B,{signal:t}),ae()?.addEventListener(`geometrychange`,B,{signal:t}),document.addEventListener(`toggle`,B,{signal:t,capture:!0}),document.addEventListener(`pointerdown`,e=>{for(let t of document.querySelectorAll(`#terminal-workspace .terminal-tabbar details.terminal-actions[open], #terminal-workspace .terminal-tabbar details.ws-layouts[open]`))e.target instanceof Node&&!t.contains(e.target)&&(t.open=!1)},{signal:t}),document.addEventListener(`keydown`,e=>{let t=document.querySelector(`#terminal-workspace .terminal-tabbar details.terminal-actions[open], #terminal-workspace .terminal-tabbar details.ws-layouts[open]`);e.key===`Escape`&&t&&(e.preventDefault(),t.open=!1,t.querySelector(`summary`)?.focus())},{signal:t}),()=>e.abort()},[B]),(0,X.useEffect)(()=>{M.current&&(M.current.open=!1)},[I,t]);let V=(0,X.useCallback)(e=>{let t=F.current.controller,n=t.state.panes.map(e=>e.id),r=n[n.indexOf(t.active||``)+e];return r?(t.select(r),!0):!1},[]);(0,X.useEffect)(()=>{let e=matchMedia(`(max-width:1023px)`),t=()=>f(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let H=d&&p&&t&&!!I;(0,X.useEffect)(()=>(document.body.classList.toggle(`terminal-compact`,H),()=>document.body.classList.remove(`terminal-compact`)),[H]),(0,X.useEffect)(()=>{t&&z.length&&(_(e=>z.every(t=>e.includes(t))?e:[...e,...z.filter(t=>!e.includes(t))]),I&&document.getElementById(Hd(I))?.scrollIntoView({block:`nearest`,inline:`nearest`}))},[t,z.join(` `),I]),(0,X.useEffect)(()=>{_(e=>e.filter(e=>wl(l,e)))},[l.panes]),(0,X.useEffect)(()=>{let e=()=>{let e=document.activeElement;if(!(e instanceof HTMLIFrameElement))return;let t=e.closest(`[data-group]`)?.getAttribute(`data-group`);t&&t!==F.current.controller.state.focus&&F.current.controller.update(e=>Ll(e,t),!1)};return addEventListener(`blur`,e),()=>removeEventListener(`blur`,e)},[]),(0,X.useEffect)(()=>{let e=j.current;if(e)return Ud(e,{enabled:()=>F.current.mobile&&F.current.visible&&!!F.current.controller.active,relative:V,width:()=>e.clientWidth||innerWidth,selected:()=>!1,blocked:e=>e instanceof Element&&!!e.closest(`.terminal-tab-close,.terminal-actions,.terminal-search,.terminal-focus,.terminal-split,.terminal-new,a,input,select,textarea,[contenteditable="true"]`)})},[V]);let U=(0,X.useCallback)((e,t,n,r,i)=>{let a=P.current;if(!a)return;e.preventDefault();let o=e.currentTarget;o.setPointerCapture(e.pointerId),a.classList.add(`resizing`);let s=e=>{let o=a.getBoundingClientRect();if(!o.width||!o.height)return;let s=r===`row`?((e.clientX-o.left)/o.width-i.x)/i.w:((e.clientY-o.top)/o.height-i.y)/i.h;F.current.controller.update(e=>{let r=Tf(e,t);if(!r)return e;let i=r.sizes.slice(0,n+1).reduce((e,t)=>e+t,0);return ql(e,t,n,s-i)},!1)},c=()=>{removeEventListener(`pointermove`,s),removeEventListener(`pointerup`,c),removeEventListener(`pointercancel`,c),a.classList.remove(`resizing`);try{o.releasePointerCapture(e.pointerId)}catch{}};addEventListener(`pointermove`,s),addEventListener(`pointerup`,c),addEventListener(`pointercancel`,c)},[]),ee=e=>{let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width,r=(e.clientY-t.top)/t.height,[i,a]=[[`left`,n],[`right`,1-n],[`top`,r],[`bottom`,1-r]].sort((e,t)=>e[1]-t[1])[0];return a<.25?i:`center`},W=(e,t)=>{d||(e.dataTransfer.setData(`application/x-lectern-pane`,t),e.dataTransfer.setData(`text/plain`,wl(l,t)?.title||t),e.dataTransfer.effectAllowed=`move`,A.current=!0,requestAnimationFrame(()=>{A.current&&y(t)}))},te=()=>{A.current=!1,y(null),x(null),C(null)};(0,X.useEffect)(()=>{if(!v)return;let e=()=>te();return document.addEventListener(`dragend`,e,!0),document.addEventListener(`drop`,e),document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`dragend`,e,!0),document.removeEventListener(`drop`,e),document.removeEventListener(`pointerdown`,e,!0)}},[v]);let G=e=>e.dataTransfer.getData(`application/x-lectern-pane`)||v,ne=e=>()=>{let t=e(F.current.controller.state);if(t===F.current.controller.state)return!1;u(()=>t)},K=Qd(L),q=c.sessions.find(e=>e.id===K);(0,X.useEffect)(()=>{aa(K?{session:K,name:q?.name||``,focused:I||``,mobile:d,open:(e,t)=>c.openPane(e,t)}:null)},[K,c,I,d,q?.name]),Te({"workspace.splitRight":ne(e=>Wl(e,`row`)),"workspace.splitDown":ne(e=>Wl(e,`column`)),"workspace.closePane":()=>{I&&e.close(I)},"workspace.reopenClosed":ne(zl),"workspace.maximize":ne(e=>Xl(e)),"workspace.focusLeft":ne(e=>tu(e,`left`)),"workspace.focusRight":ne(e=>tu(e,`right`)),"workspace.focusUp":ne(e=>tu(e,`up`)),"workspace.focusDown":ne(e=>tu(e,`down`)),"workspace.focusNextGroup":ne(e=>Ql(e,1)),"workspace.focusPrevGroup":ne(e=>Ql(e,-1)),"workspace.nextTab":ne(e=>Zl(e,1)),"workspace.prevTab":ne(e=>Zl(e,-1)),"workspace.mruNext":()=>{if(l.panes.length<2)return!1;O(e=>e===null?1:e+1)},"workspace.mruPrev":()=>{if(l.panes.length<2)return!1;O(e=>e===null?-1:e-1)},"workspace.moveTabLeft":()=>{I&&u(e=>Hl(e,I,-1))},"workspace.moveTabRight":()=>{I&&u(e=>Hl(e,I,1))},"workspace.moveToNextGroup":ne(e=>$l(e,1)),"workspace.moveToPrevGroup":ne(e=>$l(e,-1)),"workspace.equalize":ne(Yl),"workspace.unsplit":ne(Gl),"workspace.saveLayout":()=>re(!0),"workspace.layouts":()=>re(!1),"workspace.chatBeside":()=>{if(q&&I)e.openPane(Jd(q.id,q.name),{beside:I,edge:`right`});else return!1},"workspace.browserBeside":()=>{if(q&&I)e.openPane(Yd(q.id,q.name),{beside:I,edge:`right`});else return!1},"workspace.diffBeside":()=>{if(q&&I)e.openPane(Xd(q.id,q.name),{beside:I,edge:`right`});else return!1},"workspace.filesBeside":()=>{if(q&&I)e.openPane(Zi(q.id,q.name),{beside:I,edge:`right`});else return!1},"workspace.searchBeside":()=>{if(q&&I)e.openPane(Qi(q.id,q.name),{beside:I,edge:`right`});else return!1},...Object.fromEntries([1,2,3,4,5,6,7,8,9].map(t=>[`workspace.tab${t}`,()=>{let n=t===9?l.panes.at(-1):l.panes[t-1];if(n)e.select(n.id);else return!1}]))},t);function re(e){let t=document.querySelector(`#terminal-workspace .ws-layouts`);t&&(t.open=!0,B(),setTimeout(()=>(e?t.querySelector(`.ws-layout-save input`):t.querySelector(`button`))?.focus(),60))}let ie=e=>{let t=new Set(c.sessions.filter(e=>!e.ended_at&&e.status!==`dead`).map(e=>e.id)),n=au(e.layout,e=>{let n=N(e);if(!n)return null;let r=Qd(n);return r&&c.sessions.length&&!t.has(r)&&n.kind===`terminal`?null:n});if(!n.panes.length){c.notice(J(`workspace.layoutEmpty`),!0);return}let r=l.panes.filter(e=>!wl(n,e.id));u(()=>Nl({...n,panes:[...n.panes,...r]})),c.notice(J(`workspace.layoutRestored`,{name:e.name}))},{groups:oe,handles:se}=(0,X.useMemo)(()=>eu(l.root),[l.root]),ce=(0,X.useMemo)(()=>{let e=new Map;for(let t of xl(l.root))for(let n of t.panes)e.set(n,t.id);return e},[l.root]),le=e=>d?{x:0,y:0,w:1,h:1}:l.maximized?e===l.maximized?{x:0,y:0,w:1,h:1}:void 0:e?oe.get(e):void 0,ue=!!Ul(l)&&l.panes.length>1,de=q?.project_id??null,fe=q?.project_name||``,pe=L?m(L.kind)?.popout?.(L):void 0,me=xl(l.root).length;return(0,Q.jsxs)(`section`,{id:`terminal-workspace`,hidden:!t,inert:!t,className:v?`ws-dragging`:void 0,children:[(0,Q.jsxs)(`div`,{className:`terminal-tabbar`,children:[(0,Q.jsx)(`div`,{className:`terminal-tablist`,ref:j,role:`tablist`,"aria-multiselectable":R||void 0,"aria-label":J(`workspace.openTabs`),children:l.panes.map((t,n)=>{let r=l.panes.filter(e=>e.kind===t.kind&&e.title===t.title).length>1,i=t.title+(r?` #`+(t.id.split(/[/:]/).at(-1)||``):``),a=z.includes(t.id),o=m(t.kind),s=t.kind===`terminal`?J(`workspace.closeView`,{label:i}):J(`workspace.closeOther`,{kind:o?.label||t.kind,label:i});return(0,Q.jsxs)(`div`,{className:`terminal-tab-item`+(S===n?` ws-insert-before`:``),role:`presentation`,"data-pane-kind":t.kind,onDragOver:e=>{if(!v)return;e.preventDefault();let t=e.currentTarget.getBoundingClientRect();C(e.clientX{let t=G(e);if(!t)return;e.preventDefault();let r=S??n,i=l.panes.findIndex(e=>e.id===t);u(e=>Vl(e,t,iW(e,t.id),onDragEnd:te,onClick:()=>e.select(t.id),onKeyDown:r=>{let i;if(r.altKey&&r.shiftKey&&(r.key===`ArrowLeft`||r.key===`ArrowRight`)){r.preventDefault(),u(e=>Vl(e,t.id,n+(r.key===`ArrowRight`?1:-1))),requestAnimationFrame(()=>document.getElementById(Hd(t.id))?.focus({preventScroll:!0}));return}if(r.key===`ArrowRight`&&(i=l.panes[(n+1)%l.panes.length]),r.key===`ArrowLeft`&&(i=l.panes[(n+l.panes.length-1)%l.panes.length]),r.key===`Home`&&(i=l.panes[0]),r.key===`End`&&(i=l.panes.at(-1)),r.key===`Delete`){r.preventDefault(),e.close(t.id);return}i&&(r.preventDefault(),e.select(i.id),document.getElementById(Hd(i.id))?.focus({preventScroll:!0}))},children:[t.kind!==`terminal`&&(0,Q.jsxs)(`span`,{className:`ws-tab-icon`,"aria-hidden":`true`,children:[o?.icon,` `]}),i]}),(0,Q.jsx)(`button`,{className:`terminal-tab-close`,"aria-label":s,title:J(`workspace.closeViewHint`),onClick:()=>e.close(t.id),children:`×`})]},t.id)})}),s,(0,Q.jsx)(Kd,{machines:n,projects:r,onNew:i}),(0,Q.jsx)(`button`,{className:`b terminal-split`,"aria-pressed":R,hidden:!I||d,disabled:!R&&!ue,title:J(!R&&!ue?`workspace.splitNeedsTwo`:R?`workspace.unsplitHint`:`workspace.splitHint`),onClick:()=>u(e=>xl(e.root).length>1?Gl(e):Wl(e,`row`)),children:J(R?`workspace.unsplit`:`workspace.split`)}),!d&&(0,Q.jsx)(yf,{state:l,projectId:de,projectName:fe,onRestore:ie,onNotice:c.notice,onPlace:B}),(0,Q.jsx)(`a`,{className:`b terminal-popout`,target:`_blank`,rel:`noopener`,title:J(`workspace.popoutHint`),hidden:!pe,href:pe,children:J(`workspace.popout`)}),(0,Q.jsx)(`button`,{className:`terminal-search`,"aria-label":J(`shell.searchLabel`),title:J(`shell.searchLabel`),onClick:o,children:`⌕`}),(0,Q.jsxs)(`details`,{className:`terminal-actions`,ref:M,hidden:!I,onToggle:B,children:[(0,Q.jsx)(`summary`,{"aria-label":J(`workspace.actions`),title:J(`workspace.actions`),onClick:e=>{e.preventDefault(),M.current&&(M.current.open=!M.current.open,B())},children:`⋯`}),(0,Q.jsxs)(`div`,{className:`terminal-actions-panel`,role:`menu`,onClick:e=>{e.target instanceof Element&&e.target.closest(`button,a`)&&M.current&&(M.current.open=!1)},children:[pe&&(0,Q.jsx)(`a`,{className:`terminal-menu-popout`,target:`_blank`,rel:`noopener`,role:`menuitem`,href:pe,children:J(`workspace.openInNewTab`)}),(0,Q.jsx)(`button`,{className:`terminal-menu-close`,role:`menuitem`,onClick:()=>{I&&e.close(I)},children:J(`workspace.closeThisView`)}),q&&L?.kind!==`chat`&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>I&&e.openPane(Jd(q.id,q.name),{beside:I,edge:d?`center`:`right`}),children:J(`workspace.chatBeside`)}),q&&L?.kind!==`diff`&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>I&&e.openPane(Xd(q.id,q.name),{beside:I,edge:d?`center`:`right`}),children:J(`workspace.diffBeside`)}),q&&L?.kind!==`browser`&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>I&&e.openPane(Yd(q.id,q.name),{beside:I,edge:d?`center`:`right`}),children:J(`workspace.browserBeside`)}),q&&L?.kind!==`files`&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>I&&e.openPane(Zi(q.id,q.name),{beside:I,edge:d?`center`:`right`}),children:J(`workspace.filesBeside`)}),q&&L?.kind!==`search`&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>I&&e.openPane(Qi(q.id,q.name),{beside:I,edge:d?`center`:`right`}),children:J(`workspace.searchBeside`)}),!d&&ue&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>u(e=>Wl(e,`row`)),children:J(`workspace.splitRight`)}),!d&&ue&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>u(e=>Wl(e,`column`)),children:J(`workspace.splitDown`)}),!d&&me>1&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>u(e=>Xl(e)),children:l.maximized?J(`workspace.restorePanes`):J(`workspace.maximize`)}),!d&&me>1&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>u(Yl),children:J(`workspace.equalize`)}),l.closed.length>0&&(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>u(zl),children:J(`workspace.reopen`,{name:l.closed[0].title})}),d&&(0,Q.jsx)(wf,{onOpen:()=>re(!1)})]})]}),d&&(0,Q.jsx)(yf,{state:l,projectId:de,projectName:fe,onRestore:ie,onNotice:c.notice,onPlace:B}),(0,Q.jsx)(`button`,{className:`terminal-focus`,"aria-label":J(H?`workspace.showNavigation`:`workspace.focusTerminal`),title:J(H?`workspace.showNavigation`:`workspace.focusTerminal`),"aria-pressed":H,hidden:!I,onClick:()=>{h(!p);try{localStorage.setItem(`lec-terminal-compact`,p?`0`:`1`)}catch{}},children:H?`☰`:`⤢`})]}),(0,Q.jsxs)(`div`,{className:`terminal-panels`+(R?` split`:``),ref:P,hidden:!l.panes.length,children:[R&&xl(l.root).map(t=>{let n=le(t.id);if(!n)return null;let r=t.id===l.focus;return(0,Q.jsxs)(`div`,{className:`ws-group-head`+(r?` focused`:``),"data-group-head":t.id,style:{left:Sf(n.x),top:Sf(n.y),width:Sf(n.w),height:mf},onPointerDown:()=>{r||u(e=>Ll(e,t.id),!1)},onDoubleClick:e=>{e.target===e.currentTarget&&u(e=>Xl(e,t.id))},children:[(0,Q.jsx)(`div`,{className:`ws-chips`,children:t.panes.map(n=>{let r=wl(l,n);return(0,Q.jsxs)(`button`,{className:`ws-chip`,"aria-pressed":t.active===n,draggable:!0,onDragStart:e=>W(e,n),onDragEnd:te,onClick:()=>e.select(n),title:r.title,children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,children:[m(r.kind)?.icon,` `]}),r.title]},n)})}),(0,Q.jsx)(`button`,{className:`ws-head-button`,"aria-label":l.maximized===t.id?J(`workspace.restorePanes`):J(`workspace.maximizePane`),title:l.maximized===t.id?J(`workspace.restorePanes`):J(`workspace.maximizePane`),onClick:()=>u(e=>Xl(e,t.id)),children:l.maximized===t.id?`⤡`:`⤢`}),t.active&&(0,Q.jsx)(`button`,{className:`ws-head-button`,"aria-label":J(`workspace.closePaneTab`,{label:wl(l,t.active)?.title||``}),title:J(`workspace.closeViewHint`),onClick:()=>e.close(t.active),children:`×`})]},t.id)}),l.panes.filter(e=>g.includes(e.id)||t&&z.includes(e.id)).map(n=>{let r=ce.get(n.id),i=z.includes(n.id),a=le(r)||{x:0,y:0,w:1,h:1},o=R?mf:0,s=m(n.kind),f=n.id===I;return(0,Q.jsx)(`div`,{className:`terminal-tabpanel ws-pane`,id:Hd(n.id)+`-panel`,role:`tabpanel`,"aria-labelledby":Hd(n.id),"data-group":r,"data-pane-kind":n.kind,"data-focused":R?r===l.focus:void 0,hidden:!i,inert:!i||!t,style:{left:Sf(a.x),top:`calc(${Sf(a.y)} + ${o}px)`,width:Sf(a.w),height:`calc(${Sf(a.h)} - ${o}px)`},onPointerDownCapture:()=>{r&&r!==l.focus&&u(e=>Ll(e,r),!1)},children:s?s.render({pane:n,shown:i,visible:t,focused:r===l.focus,primary:f,mobile:d,compact:p,services:c,relative:V,close:()=>e.close(n.id),focus:()=>{let e=ce.get(n.id);e&&e!==F.current.controller.state.focus&&F.current.controller.update(t=>Ll(t,e),!1)}}):(0,Q.jsx)(`p`,{className:`ws-missing`,children:J(`workspace.unknownPane`,{kind:n.kind})})},n.id)}),R&&!l.maximized&&se.map(e=>{let t=Tf(l,e.split),n=t?t.sizes.slice(0,e.index+1).reduce((e,t)=>e+t,0):.5,r=e.dir===`row`?{left:Sf(e.rect.x),top:Sf(e.rect.y),height:Sf(e.rect.h)}:{top:Sf(e.rect.y),left:Sf(e.rect.x),width:Sf(e.rect.w)};return(0,Q.jsx)(`div`,{className:`ws-handle ws-handle-`+e.dir,role:`separator`,"aria-label":J(`workspace.resize`),"aria-orientation":e.dir===`row`?`vertical`:`horizontal`,"aria-valuenow":Math.round(n*100),"aria-valuemin":0,"aria-valuemax":100,tabIndex:0,style:r,onPointerDown:t=>U(t,e.split,e.index,e.dir,e.box),onDoubleClick:()=>u(Yl,!1),onKeyDown:t=>{let n=e.dir===`row`?`ArrowLeft`:`ArrowUp`,r=e.dir===`row`?`ArrowRight`:`ArrowDown`;(t.key===n||t.key===r)&&(t.preventDefault(),u(r=>ql(r,e.split,e.index,t.key===n?-.02:.02),!1))}},e.split+`:`+e.index)}),v&&!d&&xl(l.root).map(e=>{let t=le(e.id);if(!t)return null;let n=b?.group===e.id?b.edge:null;return(0,Q.jsx)(`div`,{className:`ws-drop`,"data-drop-group":e.id,style:{left:Sf(t.x),top:Sf(t.y),width:Sf(t.w),height:Sf(t.h)},onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`;let n=ee(t);C(null),(b?.group!==e.id||b.edge!==n)&&x({group:e.id,edge:n})},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||x(null)},onDrop:t=>{t.preventDefault();let n=G(t),r=ee(t);n&&u(t=>Bl(t,n,e.id,r)),te()},children:n&&(0,Q.jsx)(`div`,{className:`ws-drop-preview ws-drop-`+n})},`drop-`+e.id)})]}),(0,Q.jsxs)(`div`,{className:`terminal-empty`,hidden:!!l.panes.length,children:[(0,Q.jsx)(`h2`,{children:J(`workspace.emptyTitle`)}),(0,Q.jsx)(`p`,{children:J(`workspace.emptyBody`)}),(0,Q.jsxs)(`div`,{className:`terminal-empty-actions`,children:[(0,Q.jsx)(Kd,{machines:n,projects:r,onNew:i}),(0,Q.jsx)(`button`,{className:`b`,onClick:a,children:J(`workspace.openSessions`)})]})]}),w!==null&&(0,Q.jsx)(xf,{state:l,index:w,onMove:e=>O(t=>(t??0)+e),onCancel:()=>O(null),onChoose:t=>{O(null),e.select(t)}})]})}function wf({onOpen:e}){return(0,Q.jsx)(`button`,{role:`menuitem`,onClick:()=>requestAnimationFrame(e),children:J(`workspace.layouts`)})}function Tf(e,t){let n=e=>e.type===`group`?void 0:e.id===t?e:e.children.map(n).find(Boolean);return n(e.root)}var Ef=`lec-floating-v1`,Df=`floating.tabs`;function Of(e){if(!Array.isArray(e))return[];let t=[];for(let n of e.slice(0,12))try{if(!n||typeof n!=`object`||typeof n.path!=`string`)continue;let e=Bd(n.path);t.some(t=>t.path===e)||t.push({path:e,label:String(n.label||`Shell`).slice(0,80)})}catch{}return t}function kf(){try{let e=JSON.parse(localStorage.getItem(Ef)||`{}`),t=Of(e.tabs),n=e.box&&[`x`,`y`,`w`,`h`].every(t=>Number.isFinite(e.box[t]))?e.box:null;return{open:!1,tabs:t,active:t.some(t=>t.path===e.active)?e.active:t[0]?.path||null,box:n,maximized:e.maximized===!0}}catch{return{open:!1,tabs:[],active:null,box:null,maximized:!1}}}function Af(e){let t=Math.max(320,Math.min(innerWidth-16,e.w)),n=Math.max(200,Math.min(innerHeight-16,e.h));return{w:t,h:n,x:Math.max(8,Math.min(innerWidth-t-8,e.x)),y:Math.max(8,Math.min(innerHeight-n-8,e.y))}}function jf({services:e,onDock:t}){Y();let[n,r]=(0,X.useState)(kf),[i,a]=(0,X.useState)(()=>matchMedia(`(max-width:1023px)`).matches),[o,s]=(0,X.useState)(!1),[c,l]=(0,X.useState)([]),u=(0,X.useRef)(n);u.current=n;let d=(0,X.useRef)(null),p=(0,X.useCallback)(e=>{u.current=e,r(e);try{localStorage.setItem(Ef,JSON.stringify(e))}catch{}j(Df,e.tabs)},[]);(0,X.useEffect)(()=>{let e=matchMedia(`(max-width:1023px)`),t=()=>a(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,X.useEffect)(()=>{if(u.current.tabs.length)return;let e=()=>{if(!f()||u.current.tabs.length)return;let e=Of(Le(Df,null));if(e.length){let t={...u.current,tabs:e,active:e[0].path};u.current=t,r(t)}t()},t=ve(e);return e(),t},[]),(0,X.useEffect)(()=>{n.open&&n.active&&l(e=>e.includes(n.active)?e:[...e,n.active])},[n.open,n.active]),(0,X.useEffect)(()=>{l(e=>e.filter(e=>n.tabs.some(t=>t.path===e)))},[n.tabs]),(0,X.useEffect)(()=>{n.open&&requestAnimationFrame(()=>d.current?.querySelector(`.floating-body iframe:not([hidden])`)?.focus())},[n.open,n.active]);let m=(0,X.useCallback)(async()=>{if(!o){s(!0);try{let t=await e.api.request(`/shells`,{method:`POST`,body:{}}),n=await e.api.request(`/sessions/${t.id}/terminal`,{method:`POST`}),r=Bd(n.url),i=u.current;p({...i,open:!0,tabs:[...i.tabs,{path:r,label:t.name||J(`floating.shell`)}],active:r}),n.notice&&e.notice(n.notice)}catch(t){e.notice(String(t),!0)}finally{s(!1)}}},[o,p,e]),h=(0,X.useCallback)(()=>{let e=u.current;if(!e.open&&!e.tabs.length){m();return}p({...e,open:!e.open})},[p,m]),g=(0,X.useCallback)(e=>{let t=u.current,n=t.tabs.findIndex(t=>t.path===e);if(n<0)return;let r=t.tabs.filter(t=>t.path!==e);p({...t,tabs:r,open:t.open&&r.length>0,active:t.active===e?r[n]?.path||r[n-1]?.path||null:t.active})},[p]),_=e=>{let t=u.current,n=t.tabs.findIndex(e=>e.path===t.active),r=t.tabs[(n+e+t.tabs.length)%t.tabs.length];r&&p({...t,open:!0,active:r.path})},v=()=>{let e=u.current,n=e.tabs.find(t=>t.path===e.active);n&&(g(n.path),t(n))};Te({"floating.toggle":h,"floating.newTab":()=>void m(),"floating.closeTab":()=>{if(u.current.active)g(u.current.active);else return!1},"floating.nextTab":()=>_(1),"floating.prevTab":()=>_(-1),"floating.dock":v,"floating.maximize":()=>p({...u.current,maximized:!u.current.maximized,open:!0})}),Ad(n.open,()=>p({...u.current,open:!1})),(0,X.useEffect)(()=>{if(!n.open)return;let e=e=>{e.key===`Escape`&&d.current?.contains(document.activeElement)&&document.activeElement?.tagName!==`IFRAME`&&p({...u.current,open:!1})};return addEventListener(`keydown`,e),()=>removeEventListener(`keydown`,e)},[n.open,p]);let b=Af(n.box||{x:innerWidth-Math.min(760,innerWidth-32)-24,y:innerHeight-460-24,w:Math.min(760,innerWidth-32),h:460}),x=(e,t)=>{if(i||n.maximized||e.target.closest(`button`))return;e.preventDefault();let a={x:e.clientX,y:e.clientY,box:b},o=d.current;o?.classList.add(`floating-dragging`);let s=e=>{let n=e.clientX-a.x,i=e.clientY-a.y,o=t===`move`?{...a.box,x:a.box.x+n,y:a.box.y+i}:{...a.box,w:a.box.w+n,h:a.box.h+i},s={...u.current,box:Af(o)};u.current=s,r(s)},c=()=>{removeEventListener(`pointermove`,s),removeEventListener(`pointerup`,c),o?.classList.remove(`floating-dragging`),p(u.current)};addEventListener(`pointermove`,s),addEventListener(`pointerup`,c)},S=y(),C=i||n.maximized?void 0:{left:b.x/S,top:b.y/S,width:b.w/S,height:b.h/S};return(0,Q.jsxs)(`div`,{id:`floating-terminal`,ref:d,role:`dialog`,"aria-label":J(`floating.title`),hidden:!n.open,inert:!n.open,className:(i?`floating-sheet`:`floating-window`)+(n.maximized?` floating-maximized`:``),style:C,children:[(0,Q.jsxs)(`div`,{className:`floating-head`,onPointerDown:e=>x(e,`move`),onDoubleClick:()=>p({...n,maximized:!n.maximized}),children:[(0,Q.jsx)(`span`,{className:`floating-title`,"aria-hidden":`true`,children:`⌨`}),(0,Q.jsx)(`div`,{className:`floating-tabs`,role:`tablist`,"aria-label":J(`floating.tabs`),children:n.tabs.map(e=>(0,Q.jsxs)(`div`,{className:`floating-tab-item`,children:[(0,Q.jsx)(`button`,{role:`tab`,className:`floating-tab`,"aria-selected":e.path===n.active,onClick:()=>p({...n,active:e.path}),children:e.label}),(0,Q.jsx)(`button`,{className:`floating-tab-close`,"aria-label":J(`floating.closeTab`,{label:e.label}),onClick:()=>g(e.path),children:`×`})]},e.path))}),(0,Q.jsx)(`button`,{className:`floating-button`,"aria-label":J(`floating.newTab`),title:J(`floating.newTab`),disabled:o,onClick:()=>void m(),children:`+`}),(0,Q.jsx)(`button`,{className:`floating-button`,"aria-label":J(`floating.dock`),title:J(`floating.dock`),disabled:!n.active,onClick:v,children:`⇲`}),!i&&(0,Q.jsx)(`button`,{className:`floating-button`,"aria-label":n.maximized?J(`floating.restore`):J(`floating.maximize`),title:n.maximized?J(`floating.restore`):J(`floating.maximize`),onClick:()=>p({...n,maximized:!n.maximized}),children:n.maximized?`⤡`:`⤢`}),(0,Q.jsx)(`button`,{className:`floating-button`,"aria-label":J(`floating.hide`),title:J(`floating.hideHint`),onClick:()=>p({...n,open:!1}),children:`▾`})]}),(0,Q.jsxs)(`div`,{className:`floating-body`,children:[n.tabs.filter(e=>c.includes(e.path)).map(e=>(0,Q.jsx)(`div`,{className:`floating-frame`,hidden:e.path!==n.active,children:(0,Q.jsx)(Wd,{tab:e,shown:e.path===n.active,visible:n.open,mobile:i,compact:!1,primary:!1,relative:()=>!1})},e.path)),!n.tabs.length&&(0,Q.jsx)(`p`,{className:`floating-empty`,children:J(o?`floating.opening`:`floating.empty`)})]}),!i&&!n.maximized&&(0,Q.jsx)(`div`,{className:`floating-resize`,"aria-hidden":`true`,onPointerDown:e=>x(e,`resize`)})]})}function Mf(e,t){let n=0;for(let r of t.replace(/\s+/g,``)){if(n=e.indexOf(r,n),n<0)return!1;n++}return!0}function Nf(e,t){let n=t.toLocaleLowerCase().trim(),r=n.split(/\s+/).filter(Boolean);return e.map((e,t)=>{let i=e.title.toLocaleLowerCase(),a=[i,e.category,e.detail,e.keywords].join(` `).toLocaleLowerCase(),o=r.every(e=>a.includes(e));return!o&&r.length&&Mf(i,n)?{item:e,order:t,score:-1}:o?{item:e,order:t,score:r.length?i===n?3:i.startsWith(r[0])?2:+!!r.every(e=>i.includes(e)):0}:null}).filter(e=>e!==null).sort((e,t)=>t.score-e.score||e.order-t.order).map(e=>e.item)}function Pf({items:e,refresh:t,onClose:n,onError:r}){Y();let i=(0,X.useRef)(null),a=(0,X.useRef)(null),o=(0,X.useRef)(null),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(!0),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)([]);(0,X.useEffect)(()=>{let e=new AbortController,t=window.setTimeout(()=>{ta(s,e.signal).then(t=>{e.signal.aborted||g(t)}).catch(()=>{})},150);return()=>{e.abort(),clearTimeout(t)}},[s]);let _=(0,X.useMemo)(()=>Nf(h.length?[...e,...h]:e,s),[e,h,s]),v=_.slice(0,80),y=Math.max(0,v.findIndex(e=>e.id===l));(0,X.useEffect)(()=>{let e=document.activeElement;i.current?.showModal(),a.current?.focus();let n=!0;t().catch(()=>{n&&m(J(`app.palette.refreshFailed`))}).finally(()=>{n&&f(!1)});let r=()=>i.current?.style.setProperty(`--command-height`,`${visualViewport?.height||innerHeight}px`);return r(),visualViewport?.addEventListener(`resize`,r),window.addEventListener(`resize`,r),()=>{n=!1,i.current?.close(),visualViewport?.removeEventListener(`resize`,r),window.removeEventListener(`resize`,r),e instanceof HTMLElement&&e.focus()}},[]),(0,X.useEffect)(()=>{document.getElementById(`command-option-${y}`)?.scrollIntoView({block:`nearest`})},[y,s]);function b(e){e&&(n(),Promise.resolve().then(e.run).catch(e=>r(String(e))))}return(0,Q.jsxs)(`dialog`,{ref:i,className:`command-palette`,"aria-label":J(`app.palette.dialogLabel`),onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{if(!e.nativeEvent.isComposing){if(e.key===`Escape`&&(e.preventDefault(),n()),e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=Math.max(0,Math.min(v.length-1,y+(e.key===`ArrowDown`?1:-1)));u(v[t]?.id||``)}e.key===`Enter`&&e.target===a.current&&(e.preventDefault(),b(v[y])),e.key===`Tab`&&(e.preventDefault(),(document.activeElement===a.current?o.current:a.current)?.focus())}},children:[(0,Q.jsxs)(`div`,{className:`command-search`,children:[(0,Q.jsx)(`label`,{className:`sr-only`,htmlFor:`command-query`,children:J(`palette.label`)}),(0,Q.jsx)(`input`,{ref:a,id:`command-query`,type:`search`,autoComplete:`off`,placeholder:J(`palette.placeholder`),role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":`true`,"aria-controls":`command-results`,"aria-activedescendant":v.length?`command-option-${y}`:void 0,value:s,onChange:e=>{c(e.target.value),u(``)}}),(0,Q.jsxs)(`button`,{ref:o,type:`button`,"aria-label":J(`app.palette.close`),"data-close":!0,onClick:n,children:[(0,Q.jsx)(`span`,{className:`command-close-text`,children:`Esc`}),(0,Q.jsx)(`span`,{className:`command-close-icon`,children:`×`})]})]}),(0,Q.jsx)(`p`,{className:`command-status`,role:`status`,"aria-live":`polite`,children:p||(_.length?`${J(`app.palette.results`,{count:_.length})}${_.length>80?J(`app.palette.showingFirst`):``}${d?J(`app.palette.updating`):``}`:J(d?`app.palette.searching`:`app.palette.noMatches`))}),(0,Q.jsx)(`div`,{id:`command-results`,role:`listbox`,"aria-label":J(`app.palette.resultsLabel`),children:v.map((e,t)=>(0,Q.jsxs)(`div`,{id:`command-option-${t}`,role:`option`,"aria-selected":t===y,className:`command-result`,"data-command-id":e.id,onPointerDown:e=>e.preventDefault(),onClick:()=>b(e),children:[(0,Q.jsxs)(`strong`,{children:[e.title,!!e.shortcut?.length&&(0,Q.jsx)(`kbd`,{className:`command-shortcut`,children:Ue(e.shortcut[0])})]}),(0,Q.jsx)(`span`,{children:[e.category,e.detail].filter(Boolean).join(` · `)})]},e.id))}),(0,Q.jsx)(`p`,{className:`command-help`,children:J(`palette.help`)})]})}var Ff=[`sessions`,`approvals`,`tasks`,`terminals`,`overview`,`issues`,`media`,`evals`,`settings`],If=e=>Ff.includes(e);function Lf(e,t=!1){return t?[...Ff]:[`sessions`,`approvals`,`settings`]}function Rf(e){return[...[`tasks`,`terminals`,`overview`,`issues`,`media`,`evals`].map(e=>({view:e})),{section:`machines`},{section:`plugins`}]}var zf=`sessions`;function Bf(e){let t=e.replace(/^#/,``),[n=``,...r]=t.split(`/`),i=r.length?`/`+r.join(`/`):``;switch(n){case`board`:return`#tasks`;case`deck`:return`#overview`;case`targets`:return`#settings`+(i||`/machines`);case`tasks`:return/^[1-9]\d*$/.test(r[0]||``)?`#issues`+i:`#`+t}return`#`+t}function Vf(e){return typeof e==`string`?e:e===void 0?``:JSON.stringify(e)}function Hf(e){let t=e.payload;return e.type===`text`?Vf(t.text):e.type===`tool_use`?`▸ ${Vf(t.name)} ${Vf(t.input).slice(0,160)}`:e.type===`tool_result`?`↳ ${Vf(t.content).slice(0,80)}`:e.type===`verify`?`verify ${t.rc===0?`PASS`:`FAIL`}`:e.type===`result`?`✔ ${Vf(t.result)}`:e.type}function Uf({task:e,api:t,onTask:n}){let[r,i]=(0,X.useState)([]),[a,o]=(0,X.useState)(``),s=(0,X.useRef)(null);return(0,X.useEffect)(()=>{let n=new AbortController,r=new EventSource(U(`/api/tasks/${e.id}/stream`)),a=e=>i(t=>{let n=new Set;return[...t,...e].filter(e=>!n.has(e.id)&&!!n.add(e.id)).sort((e,t)=>e.id-t.id).slice(-40)});return t.taskEvents(e.id,n.signal).then(e=>{n.signal.aborted||a(e.slice(-15))}).catch(e=>{n.signal.aborted||o(String(e))}),r.addEventListener(`agent_event`,e=>{try{a([JSON.parse(e.data)])}catch{o(J(`app.deck.badEvent`))}}),()=>{n.abort(),r.close()}},[e.id,t]),(0,X.useEffect)(()=>{s.current&&(s.current.scrollTop=s.current.scrollHeight)},[r]),(0,Q.jsxs)(`div`,{className:`pane s-${e.status}`,children:[(0,Q.jsxs)(`button`,{className:`pane-head`,onClick:()=>n(e.id),children:[(0,Q.jsx)(`span`,{className:`statpill`,children:e.status}),(0,Q.jsx)(`span`,{className:`pane-title`,children:e.title}),(0,Q.jsx)(`span`,{className:`pane-sub`,children:e.target_name})]}),(0,Q.jsxs)(`div`,{className:`pane-log`,ref:s,children:[a&&(0,Q.jsx)(`p`,{role:`status`,children:a}),r.map(e=>(0,Q.jsx)(`div`,{className:`pane-line`,children:Hf(e)},e.id))]})]})}function Wf({tasks:e,api:t,onTask:n}){Y();let r=e.filter(e=>[`running`,`review`,`queued`].includes(e.status)).slice(0,16);return r.length?(0,Q.jsx)(`div`,{id:`deck`,children:r.map(e=>(0,Q.jsx)(Uf,{task:e,api:t,onTask:n},e.id))}):(0,Q.jsxs)(`div`,{className:`hint`,children:[J(`app.deck.empty`),(0,Q.jsx)(`br`,{}),J(`app.deck.emptyHint`)]})}function Gf({rows:e,api:t,onChanged:n,onNotice:r,onOpenSession:i,onOpenTask:a,onSettings:o}){Y();let[s,c]=(0,X.useState)();(0,X.useEffect)(()=>{t.request(`/settings`).then(e=>c(e.session_permission_mode===`ask`)).catch(()=>c(void 0))},[t]);async function l(e,i,a){try{await t.request(`/approvals/${e.id}/decision`,{method:`POST`,body:Li(i,a)}),r(J(i===`approved`?`app.approvals.approved`:`app.approvals.denied`)),n()}catch(e){r(String(e),!0)}}return e.length?(0,Q.jsxs)(`section`,{className:`list approvals-page`,id:`approvals-page`,children:[(0,Q.jsxs)(`div`,{className:`page-heading`,children:[(0,Q.jsx)(`h2`,{children:J(`nav.approvals`)}),(0,Q.jsx)(`p`,{className:`subhint`,children:J(`approval.pageHint`)})]}),e.map((e,t)=>(0,Q.jsx)(Ii,{approval:e,showContext:!0,autoFocus:t===0,onDecide:(t,n)=>l(e,t,n),onOpenSession:i,onOpenTask:a},e.id))]}):(0,Q.jsxs)(`div`,{className:`hint empty-state`,id:`approvals-empty`,children:[(0,Q.jsx)(`strong`,{children:J(`app.approvals.empty`)}),(0,Q.jsx)(`br`,{}),J(`app.approvals.emptyHint`),s===!1&&(0,Q.jsxs)(`p`,{className:`subhint`,id:`approvals-ask-off`,children:[J(`approval.askOff`),` `,o&&(0,Q.jsx)(`button`,{type:`button`,className:`linkish`,onClick:o,children:J(`approval.askOffLink`)})]})]})}function Kf({name:e,size:t=20}){return(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,width:t,height:t,fill:`none`,stroke:`currentColor`,strokeWidth:`1.9`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:e===`board`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`4`,width:`5`,height:`16`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`10`,y:`4`,width:`5`,height:`10`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`17`,y:`4`,width:`4`,height:`14`,rx:`1.5`})]}):e===`sessions`||e===`terminals`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`16`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M7 9l3 3-3 3M13 15h4`})]}):e===`media`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`5`,width:`18`,height:`14`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M10 9.5v5l4.5-2.5z`})]}):e===`deck`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`4`,width:`8`,height:`7`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`13`,y:`4`,width:`8`,height:`7`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`3`,y:`13`,width:`8`,height:`7`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`13`,y:`13`,width:`8`,height:`7`,rx:`1.5`})]}):e===`approvals`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{d:`M12 3l7 3v6c0 4.2-2.9 7.6-7 9-4.1-1.4-7-4.8-7-9V6z`}),(0,Q.jsx)(`path`,{d:`M9 12l2 2 4-4`})]}):e===`targets`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`6`,rx:`2`}),(0,Q.jsx)(`rect`,{x:`3`,y:`14`,width:`18`,height:`6`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M7 7h.01M7 17h.01`})]}):e===`brand`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`6`,rx:`2`}),(0,Q.jsx)(`rect`,{x:`3`,y:`14`,width:`10`,height:`6`,rx:`2`}),(0,Q.jsx)(`path`,{d:`M17 14v6M20 17h-6`})]}):e===`search`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`circle`,{cx:`10`,cy:`10`,r:`6`}),(0,Q.jsx)(`path`,{d:`m15 15 5 5`})]}):e===`tasks`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`circle`,{cx:`6`,cy:`6`,r:`2.5`}),(0,Q.jsx)(`circle`,{cx:`6`,cy:`18`,r:`2.5`}),(0,Q.jsx)(`circle`,{cx:`18`,cy:`18`,r:`2.5`}),(0,Q.jsx)(`path`,{d:`M6 8.5v7M18 15.5V10a3 3 0 0 0-3-3h-4M13 5l-2 2 2 2`})]}):e===`evals`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`rect`,{x:`3`,y:`3`,width:`8`,height:`8`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`13`,y:`3`,width:`8`,height:`8`,rx:`1.5`}),(0,Q.jsx)(`rect`,{x:`3`,y:`13`,width:`8`,height:`8`,rx:`1.5`}),(0,Q.jsx)(`path`,{d:`M15.5 15.5l2 2 3-3`})]}):(0,Q.jsx)(`path`,{d:`M12 5v14M5 12h14`})})}var qf=e=>[J(`app.switch.saving`),e.destination?J(`app.switch.starting`,{destination:e.destination}):J(`app.switch.startingNew`),J(`app.switch.ready`)];function Jf({progress:e}){Y();let t=qf(e),n=e.phase===`ready`?3:+(e.phase===`starting`);return(0,Q.jsx)(`ol`,{className:`switch-steps`,role:`status`,"aria-live":`polite`,children:t.map((t,r)=>{let i=e.phase===`failed`?`todo`:r(0,Q.jsx)(Xf,{api:e,source:Number(t),pending:s,onReady:n,onFailed:r,onRetry:i,onReopen:a,onDismiss:o},`${t}-${s.generation}`))}):null}function Xf({api:e,source:t,pending:n,onReady:r,onFailed:i,onRetry:a,onReopen:o,onDismiss:s}){let c=Pr(e,t,n.after,n.generation,!0,n.destination),l=(0,X.useRef)(``);(0,X.useEffect)(()=>{let e=`${n.generation}:${c.phase}:${c.successor?.id??``}:${c.error??``}`;l.current!==e&&(c.phase===`ready`&&c.successor?(l.current=e,r(t,c.successor)):c.phase===`failed`&&(l.current=e,i(t,c.error||J(`app.switch.incomplete`))))},[n.generation,c,t,r,i]);let u=!!n.successor&&!!n.error,d=c.phase===`failed`||u,f=n.error||c.error||J(`app.switch.incomplete`);return(0,Q.jsxs)(`section`,{className:`switch-progress ${d?`failed`:``}`,"aria-label":J(`app.switch.progressLabel`,{id:t}),children:[(0,Q.jsxs)(`div`,{className:`switch-progress-head`,children:[(0,Q.jsx)(`strong`,{children:u?J(`app.switch.openFailed`):d?J(`app.switch.failed`):n.destination?J(`app.switch.switchingTo`,{destination:n.destination}):J(`app.switch.switching`)}),d&&(0,Q.jsx)(`button`,{className:`switch-progress-x`,"aria-label":J(`app.switch.dismiss`),onClick:()=>s(t),children:`✕`})]}),(0,Q.jsx)(Jf,{progress:c}),d&&(0,Q.jsxs)(`div`,{className:`switch-progress-actions`,children:[(0,Q.jsx)(`p`,{role:`alert`,children:f}),n.successor?(0,Q.jsx)(`button`,{className:`b`,onClick:()=>o(t),children:J(`app.switch.openNew`)}):(0,Q.jsx)(`button`,{className:`b`,onClick:()=>a(t),children:J(`app.switch.retry`)})]})]})}var Zf=`lectern-native-push`;function Qf(){let e=Me()?.pushSubscription();if(e)try{let t=JSON.parse(e);return t.endpoint?t:void 0}catch{return}}async function $f(e){let t=Me(),n=Qf();if(t&&n)return n.confirmed||(await e(`/push/subscribe`,{method:`POST`,body:{endpoint:n.endpoint,keys:n.keys}}),t.pushSubscribed(n.endpoint)),n.endpoint}async function ep(e,t=6e4){let n=Me();if(!n)throw Error(J(`app.nativePush.notInApp`));let{key:r}=await e(`/push/vapid`),i=new Promise((e,n)=>{let r=window.setTimeout(()=>{window.removeEventListener(Zf,i),n(Error(J(`app.nativePush.noDistributor`)))},t),i=t=>{let a=t.detail;window.clearTimeout(r),window.removeEventListener(Zf,i),a?.ok?e():n(Error(a?.error||J(`app.nativePush.failed`)))};window.addEventListener(Zf,i)});n.enablePush(r),await i;let a=await $f(e);if(!a)throw Error(J(`app.nativePush.failed`));return a}function tp({approvals:e,waitingSessions:t}){return Math.max(0,e)+Math.max(0,t)}function np(e,t){try{t>0?e.setAppBadge?.(t)?.catch(()=>{}):e.clearAppBadge?.()?.catch(()=>{})}catch{}}var rp=`lec-offline-v1`,ip=15e5;function ap(e,t=`GET`){if(t.toUpperCase()!==`GET`)return!1;let[n=``,r=``]=e.split(`?`,2);return n===`/approvals`?!r||r===`status=pending`:[`/sessions`,`/tasks`,`/projects`,`/targets`,`/live`,`/sessions/relaunched`].includes(n)}function op(e){return e instanceof I?e.status===502||e.status===503||e.status===504:e instanceof TypeError||e instanceof Error&&/network|failed to fetch|load failed|relay/i.test(e.message)}var sp=class extends EventTarget{storage;now;patience;entries;live=!1;staleSince=0;constructor(e=cp(),t=()=>Date.now(),n=1200){super(),this.storage=e,this.now=t,this.patience=n,this.entries=this.read()}get state(){return this.staleSince?{stale:!0,since:this.staleSince}:{stale:!1}}cacheable(e,t){return ap(e,t)}get empty(){return Object.keys(this.entries).length===0}async run(e,t){let n=this.entries[e],r=t().then(t=>(this.store(e,t),this.fresh(),t));if(!n)return r;if(!this.live)return new Promise((e,t)=>{let i=!1,a=setTimeout(()=>{i=!0,e(n.body)},this.patience);r.then(t=>{clearTimeout(a),i?this.dispatchEvent(new Event(`revalidated`)):e(t)},r=>{if(clearTimeout(a),!op(r)){i||t(r);return}this.markStale(n.at),i||e(n.body)})});try{return await r}catch(e){throw op(e)&&this.markStale(n.at),e}}clear(){this.entries={};try{this.storage?.removeItem(rp)}catch{}}fresh(){this.live=!0,this.staleSince&&(this.staleSince=0,this.dispatchEvent(new Event(`change`)))}markStale(e){let t=this.staleSince?Math.min(this.staleSince,e):e;t!==this.staleSince&&(this.staleSince=t,this.dispatchEvent(new Event(`change`)))}read(){try{let e=this.storage?.getItem(rp),t=e?JSON.parse(e):{};return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}store(e,t){this.entries[e]={at:this.now(),body:t};let n=JSON.stringify(this.entries);if(n.length>ip){let e={};for(let[t,n]of Object.entries(this.entries).sort((e,t)=>t[1].at-e[1].at))JSON.stringify({...e,[t]:n}).length<=ip&&(e[t]=n);this.entries=e,n=JSON.stringify(e)}try{this.storage?.setItem(rp,n)}catch{}}};function cp(){try{return typeof localStorage>`u`?void 0:localStorage}catch{return}}function lp(e,t=Date.now()){let n=Math.max(0,Math.round((t-e)/1e3));if(n<45)return J(`offline.justNow`);let r=Math.round(n/60);if(r<60)return J(`offline.minutesAgo`,{count:r});let i=Math.round(r/60);return i<36?J(`offline.hoursAgo`,{count:i}):J(`offline.daysAgo`,{count:Math.round(i/24)})}var up=new sp;function dp({onRetry:e}){Y();let[t,n]=(0,X.useState)(up.state),[,r]=(0,X.useState)(0);return(0,X.useEffect)(()=>{let t=()=>n(up.state),i=()=>e();up.addEventListener(`change`,t),up.addEventListener(`revalidated`,i);let a=window.setInterval(()=>r(e=>e+1),3e4),o=()=>e();return window.addEventListener(`online`,o),()=>{up.removeEventListener(`change`,t),up.removeEventListener(`revalidated`,i),window.removeEventListener(`online`,o),clearInterval(a)}},[e]),t.stale?(0,Q.jsxs)(`div`,{id:`offline-banner`,role:`status`,"data-stale-since":t.since,children:[(0,Q.jsx)(`span`,{className:`offline-dot`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`b`,{children:J(`offline.title`)}),` · `,J(`offline.showing`,{age:lp(t.since)})]}),(0,Q.jsx)(`button`,{className:`b`,onClick:e,children:J(`offline.retry`)})]}):null}var fp=`textarea,input,select,dialog,[role=dialog],.xterm,.no-pull,.action-menu[open],[data-swipe-row]`;function pp({target:e,onRefresh:t}){Y();let n=(0,X.useRef)(null),[r,i]=(0,X.useState)(!1),a=(0,X.useRef)(t);return a.current=t,(0,X.useEffect)(()=>{let t=e();if(!t||!matchMedia(`(pointer: coarse), (hover: none)`).matches)return;let r,o,s=0,c=!1,l=!1,u=(e,t=!1)=>{let r=n.current;r&&(r.style.transition=t?`transform .2s ease, opacity .2s`:`none`,r.style.transform=`translate(-50%, ${e-44}px) rotate(${e*4}deg)`,r.style.opacity=String(Math.min(1,e/64)),r.classList.toggle(`armed`,e>=64))},d=new AbortController,f=d.signal;t.addEventListener(`touchstart`,e=>{if(l||e.touches.length!==1||window.scrollY>0||e.target instanceof Element&&e.target.closest(fp))return;let t=e.touches[0];r={x:t.clientX,y:t.clientY},o=void 0,c=!1},{signal:f,passive:!0}),t.addEventListener(`touchmove`,e=>{if(!r)return;let t=e.touches[0],n=t.clientX-r.x,i=t.clientY-r.y;if(o??=Jn(n,i),o!==`y`||i<=0||window.scrollY>0){o&&(r=o===`y`&&i>0&&window.scrollY<=0?r:void 0),r||u(0,!0);return}e.preventDefault(),s=qn(i),s>=64&&!c&&ie(`tick`),c=s>=64,u(s)},{signal:f,passive:!1});let p=()=>{if(r){if(r=void 0,!c){u(0,!0);return}l=!0,i(!0),u(64,!0),a.current().catch(()=>void 0).finally(()=>{l=!1,i(!1),u(0,!0)})}};return t.addEventListener(`touchend`,p,{signal:f}),t.addEventListener(`touchcancel`,p,{signal:f}),()=>d.abort()},[e]),(0,Q.jsx)(`div`,{ref:n,id:`pull-refresh`,className:r?`busy`:``,role:`status`,"aria-label":r?J(`mobile.refreshing`):void 0})}var mp=`lec-pending-switches`,hp=`lec-push-prompt-dismissed`;function gp(){try{return localStorage.getItem(hp)===`1`}catch{return!1}}function _p(){try{localStorage.setItem(hp,`1`)}catch{}}function vp(){try{let e=JSON.parse(sessionStorage.getItem(mp)||`{}`),t={};for(let[n,r]of Object.entries(e)){if(!/^\d+$/.test(n))continue;if(typeof r==`number`){t[n]={after:r,generation:0,destination:``,agent:``,model:``,profile:0};continue}if(!r||typeof r!=`object`)continue;let e=r,i=e.successor&&Number(e.successor.id)?{id:Number(e.successor.id),name:String(e.successor.name||``)}:void 0;t[n]={after:typeof e.after==`number`?e.after:0,generation:Number(e.generation)||0,destination:String(e.destination||``),agent:String(e.agent||``),model:String(e.model||``),profile:Number(e.profile)||0,error:e.error?String(e.error):void 0,successor:i}}return t}catch{return{}}}var yp={sessions:`nav.sessions`,approvals:`nav.approvals`,tasks:`nav.tasksPage`,terminals:`nav.terminals`,overview:`nav.overview`,issues:`nav.issues`,media:`nav.media`,evals:`nav.evals`,settings:`nav.settings`},bp=e=>J(yp[e]),xp=e=>e===`evals`,Sp=If,Cp={sessions:`sessions`,approvals:`approvals`,tasks:`board`,terminals:`terminals`,overview:`deck`,issues:`tasks`,media:`media`,evals:`evals`,settings:`targets`},wp={sessions:`nav.sessions`,approvals:`nav.approvals`,tasks:`nav.board`,terminals:`nav.terminals`,overview:`nav.deck`,issues:`nav.tasks`,media:`nav.media`,evals:`nav.evals`,settings:`nav.targets`},Tp=e=>{let t=/^#?media\/([1-9]\d*)$/.exec(e);return t?Number(t[1]):null};function Ep(){let[e,t]=(0,X.useState)(()=>matchMedia(`(min-width: 1024px)`).matches);(0,X.useEffect)(()=>{let e=matchMedia(`(min-width: 1024px)`),n=()=>t(e.matches);return e.addEventListener(`change`,n),n(),()=>e.removeEventListener(`change`,n)},[]),Y();let[n,r]=(0,X.useState)(zf),[i,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)([]),[d,f]=(0,X.useState)([]),[m,h]=(0,X.useState)([]),[g,v]=(0,X.useState)([]),[b,x]=(0,X.useState)([]),[S,C]=(0,X.useState)([]),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(null),[k,A]=(0,X.useState)(0),[j,N]=(0,X.useState)(!1),[P,I]=(0,X.useState)(!1),[L,R]=(0,X.useState)(!1),[V,W]=(0,X.useState)(!1),[te,G]=(0,X.useState)(He),[ne,K]=(0,X.useState)(0),[q,re]=(0,X.useState)(``),[ie,ae]=(0,X.useState)([]),[oe,ce]=(0,X.useState)(),[le,fe]=(0,X.useState)(0),[pe,he]=(0,X.useState)(0),[ge,_e]=(0,X.useState)(0),[ve,xe]=(0,X.useState)(),[Se,Ce]=(0,X.useState)({name:`basics`,version:0}),[we,Ee]=(0,X.useState)(),[Oe,ke]=(0,X.useState)(0),[je,Pe]=(0,X.useState)(!1),[Fe,Ie]=(0,X.useState)(),[Le,Re]=(0,X.useState)(),[ze,Be]=(0,X.useState)(),[Ve,Ge]=(0,X.useState)(),[Ke,qe]=(0,X.useState)(vp),[Je,Ye]=(0,X.useState)(void 0),[Xe,Ze]=(0,X.useState)(gp),[Qe,$e]=(0,X.useState)(),et=(0,X.useMemo)(()=>ue()?{available:!0}:ml(pl(window)),[]),tt=(0,X.useRef)(Ke),nt=(0,X.useRef)(new Set),rt=(0,X.useCallback)(e=>{tt.current=e,qe(e);try{sessionStorage.setItem(mp,JSON.stringify(e))}catch{}},[]),it=(0,X.useRef)(null),at=(0,X.useRef)(0),ot=(0,X.useRef)(0),st=(0,X.useRef)(n);st.current=n;let Z=(0,X.useCallback)((e,t=!1,n)=>{let r=++at.current;ae(i=>[...i,{id:r,text:e,error:t,action:n}]),window.setTimeout(()=>ae(e=>e.filter(e=>e.id!==r)),n?1e4:4200)},[]),$=(0,X.useMemo)(()=>ct({offline:up,onUnauthorized:()=>{if(!window.__lecternRelay){if(!He()){let e=!1;try{e=localStorage.getItem(`lec-paired`)===`1`}catch{}if(e){try{localStorage.removeItem(`lec-paired`)}catch{}window.location.href=`/pair`;return}}W(!0)}}}),[]),lt=(0,X.useCallback)(e=>{document.getElementById(`nav-overflow`)?.removeAttribute(`open`),e=Bf(e);let t=e.replace(/^#/,``).split(`/`)[0]||`sessions`;if(Sp(t)&&xp(t)){o(!0);return}Sp(t)&&(r(t),t===`media`&&D(Tp(e)),history.replaceState(null,``,e))},[]),ut=vf(lt);(0,X.useEffect)(()=>Rd(lt),[lt]),(0,X.useEffect)(()=>{let e=window.setTimeout(()=>Ld(`#`+n),0);return()=>clearTimeout(e)},[n]),Ad(!!Le,()=>Re(void 0)),Ad(!!ze,()=>Be(void 0));let dt=(0,X.useMemo)(()=>{let e={};for(let t of b)t.session_id!=null&&(e[t.session_id]=(e[t.session_id]||0)+1);return e},[b]),ft=(0,X.useCallback)(async()=>{let e=++ot.current,t=await Promise.allSettled([$.projects(),$.targets(),$.tasks(),$.request(`/sessions?include_setup_failures=true`),$.request(`/approvals?status=pending`),$.request(`/media?limit=200`),$.request(`/live`)]);if(e!==ot.current)return;let[n,r,i,a,o,s,l]=t;n.status===`fulfilled`&&c(n.value),r.status===`fulfilled`&&u(r.value),i.status===`fulfilled`&&f(i.value),a.status===`fulfilled`&&h(a.value),o.status===`fulfilled`&&v(o.value),s.status===`fulfilled`&&x(s.value),l.status===`fulfilled`&&(C(l.value.views),T(l.value.enabled)),A(e=>e+1);let d=t.find(e=>e.status===`rejected`);if(d?.status===`rejected`)throw d.reason},[$]),pt=(0,X.useCallback)(()=>void ft().catch(()=>void 0),[ft]),mt=(0,X.useCallback)(()=>document.getElementById(`view`),[]),ht=(0,X.useCallback)((e,t)=>{Ie(void 0),ut.open(e,t)},[ut.open]),gt=(0,X.useCallback)(async(e,t)=>{let n=tt.current[String(e)];if(n&&!nt.current.has(e)){nt.current.add(e);try{let n=await $.request(`/sessions/${t.id}/terminal`,{method:`POST`});ht(n.url,t.name),n.notice&&Z(n.notice),ut.close(`/terminal/session/${e}`);let r={...tt.current};delete r[String(e)],rt(r),Z(J(`app.switch.switched`))}catch(r){let i=tt.current[String(e)]||n;rt({...tt.current,[String(e)]:{...i,successor:{id:t.id,name:t.name},error:String(r)}}),Z(String(r),!0)}finally{nt.current.delete(e)}}},[$,ht,ut.close,Z,rt]),_t=(0,X.useCallback)(e=>{let t=tt.current[String(e)];t?.successor&>(e,t.successor)},[gt]),vt=(0,X.useCallback)((e,t)=>{let n=tt.current[String(e)];n&&(rt({...tt.current,[String(e)]:{...n,error:t}}),Z(t,!0))},[Z,rt]),yt=(0,X.useCallback)(async e=>{let t=tt.current[String(e)];if(t&&!t.successor)try{let n=await Nr($,e,{agent:t.agent,model:t.model,profile:t.profile,destination:t.destination}),r=tt.current[String(e)];rt({...tt.current,[String(e)]:{...r||t,after:n.after_wrap_id,generation:((r||t).generation||0)+1,error:void 0,successor:void 0}}),Z(J(`app.switch.waiting`)),ft().catch(e=>Z(String(e),!0))}catch(t){vt(e,String(t))}},[$,Z,ft,rt,vt]),bt=(0,X.useCallback)(e=>{let t={...tt.current};delete t[String(e)],rt(t)},[rt]),St=(0,X.useCallback)(async e=>{try{let t=await $.request(`/sessions/${e}/terminal`,{method:`POST`});ht(t.url,m.find(t=>t.id===e)?.name),t.notice&&Z(t.notice)}catch(e){Z(qo(e)??String(e),!0)}},[$,ht,m,Z]);(0,X.useEffect)(()=>{if(!Qe)return;let e=m.find(e=>e.id===Qe.id);e&&(Qe.action===`terminal`?St(e.id):Ie({kind:`session`,id:e.id,name:e.name,quickReply:!0}),$e(void 0))},[Qe,m,St]);let Ct=(0,X.useCallback)(async e=>{try{let t=e?.projectID?{project_id:e.projectID}:e?.machineID?{target_id:e.machineID}:{},n=await $.request(`/shells`,{method:`POST`,body:t});e?.projectID&&xr(e.projectID);let r=await $.request(`/sessions/${n.id}/terminal`,{method:`POST`});ht(r.url,n.name),r.notice&&Z(r.notice)}catch(e){Z(qo(e)??String(e),!0)}},[$,ht,Z]),wt=(0,X.useCallback)(e=>{ce(e),he(e=>e+1),lt(`#tasks`),r(`tasks`),history.replaceState(null,``,`#task/${e}`)},[lt]),Tt=()=>{lt(`#tasks`),fe(e=>e+1)},Et=(e,t)=>{lt(`#sessions`),xe({kind:e,version:Date.now(),projectId:t})},Dt=(e,t)=>{Ce({name:e,version:Date.now(),focus:t}),lt(`#settings`)},Ot=(0,X.useMemo)(()=>({api:$,sessions:m,notice:Z,attach:e=>void St(e),openPane:(e,t)=>{Ie(void 0),ut.openPane(e,t)},closePane:e=>ut.close(e)}),[$,m,Z,St,ut.openPane,ut.close]),kt=e=>p({theme:e}),At=e=>{let t=M().zoom,n=B.findIndex(e=>e>=t-1e-6);p({zoom:B[Math.max(0,Math.min(B.length-1,(n<0?2:n)+e))]})},jt=e=>()=>lt(e===`terminals`?ut.hash:`#`+e);Te({"palette.open":()=>I(e=>!e),"search.saved":()=>R(!0),"settings.open":()=>Dt(Se.name),"settings.shortcuts":()=>Dt(`shortcuts`),"settings.search":()=>Dt(Se.name,`search`),"theme.toggle":()=>kt(ee(M().theme,matchMedia(`(prefers-color-scheme: dark)`).matches)===`dark`?`light`:`dark`),"theme.system":()=>kt(`system`),"theme.dark":()=>kt(`dark`),"theme.light":()=>kt(`light`),"zoom.in":()=>At(1),"zoom.out":()=>At(-1),"zoom.reset":()=>p({zoom:1}),"accent.next":()=>{let e=_.findIndex(e=>e.value===M().accent);p({accent:_[(e+1)%_.length].value})},"nav.board":jt(`tasks`),"nav.sessions":jt(`sessions`),"nav.tasks":jt(`issues`),"nav.terminals":jt(`terminals`),"nav.media":jt(`media`),"nav.deck":jt(`overview`),"nav.approvals":jt(`approvals`),"nav.targets":jt(`settings`),"nav.evals":()=>o(!0),...Object.fromEntries([`machines`,`projects`,`notifications`,`devices`,`about`,`budgets`,`accounts`,`agents`,`plugins`,`appearance`,`workspace`].map(e=>[`settings.${e}`,()=>Dt(e)])),"session.new":()=>Et(`new`),"session.discover":()=>Et(`discover`),"task.new":()=>Tt(),"routines.open":()=>{lt(`#tasks`),_e(e=>e+1)},"profiles.manage":()=>Pe(!0),"terminal.new":()=>void Ct()}),(0,X.useEffect)(()=>{let e=()=>{document.getElementById(`nav-overflow`)?.removeAttribute(`open`);let e=Bf(location.hash);location.hash&&e!==location.hash&&history.replaceState(null,``,e);let t=``;try{t=decodeURIComponent(e.slice(1))}catch{return}let[n,i,a]=t.split(`/`);if(n===`settings`&&i&&yu.some(([e])=>e===i)){Dt(i);return}if(n===`terminals`&&/^(session|attempt|project)$/.test(i||``)&&/^[1-9]\d*$/.test(a||``)){ut.open(`/terminal/${i}/${a}`);return}if(n===`task`&&/^[1-9]\d*$/.test(i||``)){r(`tasks`),ce(Number(i)),he(e=>e+1);return}if(n===`sessions`&&i===`new`){Et(`new`,/^[1-9]\d*$/.test(a||``)?Number(a):void 0);return}if(n===`session`){r(`sessions`),/^[1-9]\d*$/.test(i||``)&&(a===`terminal`||a===`reply`)&&$e({id:Number(i),action:a,version:Date.now()});return}if(n&&Sp(n)&&xp(n)){o(!0);return}if(n&&Sp(n)){r(n),n===`media`&&D(Tp(t));return}r(zf)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[ut.open]),(0,X.useEffect)(()=>{let e=!0,t=t=>{e&&!up.state.stale&&Z(String(t),!0)};ft().catch(t),z().catch(()=>{}),F().catch(()=>{});let n=new EventSource(U(`/api/stream`));n.addEventListener(`ui_prefs`,()=>void z().catch(()=>{})),n.addEventListener(`plugins`,()=>void F().catch(()=>{}));let r=!1;n.onopen=()=>{N(!0),r&&ft().catch(t),r=!0},n.onerror=()=>N(!1);let i=()=>void ft().catch(t);for(let e of[`task`,`approval`,`session`,`session_dismissed`,`task_deleted`,`media`,`media_deleted`,`live`,`session.check`,`ci`,`target_reach`])n.addEventListener(e,i);n.addEventListener(`session_handoff`,e=>{try{let t=JSON.parse(e.data);if(t.session_id&&t.session_id in tt.current){t.ok&&t.successor?gt(t.session_id,t.successor):vt(t.session_id,t.error||J(`app.switch.incomplete`)),i();return}Z(t.ok?J(`app.handoff.written`)+(t.successor?J(`app.handoff.successorStarted`):``)+(t.remembered?J(`app.handoff.remembered`):``):J(`app.handoff.failed`,{error:t.error||J(`app.handoff.unknown`)}),!t.ok)}catch{Z(J(`app.handoff.unreadable`),!0)}i()});let a=()=>{document.visibilityState===`visible`&&i()};document.addEventListener(`visibilitychange`,a);let o=window.setInterval(()=>{document.visibilityState===`visible`&&i()},3e4);return()=>{e=!1,ot.current++,n.close(),clearInterval(o),document.removeEventListener(`visibilitychange`,a)}},[$,ne,ft,Z,gt,vt]),(0,X.useEffect)(()=>(document.body.classList.toggle(`terminals-open`,n===`terminals`),()=>document.body.classList.remove(`terminals-open`)),[n]),(0,X.useEffect)(()=>{let e=it.current;if(!e)return;let t=()=>document.documentElement.style.setProperty(`--terminal-top`,`${e.getBoundingClientRect().bottom/y()}px`),n=new ResizeObserver(t);return n.observe(e),t(),window.addEventListener(`resize`,t),()=>{n.disconnect(),window.removeEventListener(`resize`,t)}},[]);let Mt=(0,X.useRef)(n);Mt.current=n,(0,X.useEffect)(()=>{let e=Ne({contexts:[`global`,`workspace`],active:e=>e!==`workspace`||Mt.current===`terminals`}),t=ye();return()=>{e(),t()}},[]),(0,X.useEffect)(()=>{navigator.serviceWorker&&!ue()&&navigator.serviceWorker.register(`/sw.js`).catch(e=>Z(J(`app.offlineSupportError`,{error:String(e)}),!0))},[Z]),(0,X.useEffect)(()=>{if(!et.available){Ye(null);return}let e=!1;if(ue()){let t=()=>void $f($.request).then(t=>!e&&Ye(t??null)).catch(()=>!e&&Ye(null));return t(),window.addEventListener(Zf,t),()=>{e=!0,window.removeEventListener(Zf,t)}}return(async()=>{try{let t=await(await navigator.serviceWorker.getRegistration())?.pushManager.getSubscription();e||Ye(t?.endpoint??null)}catch{e||Ye(null)}})(),()=>{e=!0}},[et.available]),(0,X.useEffect)(()=>{let e=m.filter(e=>{let t=po(e);return t.state===`needs_you`&&t.reason!==`approval`}).length,t=tp({approvals:g.length,waitingSessions:e});np(navigator,t),navigator.serviceWorker?.controller?.postMessage({type:`lec-badge-count`,count:t})},[g,m]);async function Nt(){if(ue()){try{Ye(await ep($.request)),Ze(!0),_p(),Z(J(`app.pushPrompt.enabled`)),await $.request(`/settings/test-notification`,{method:`POST`})}catch(e){Z(J(`app.pushPrompt.error`,{error:String(e)}),!0)}return}try{if(!navigator.serviceWorker||!window.Notification)throw Error(J(`app.pushPrompt.unsupported`));let e=await navigator.serviceWorker.ready;if(await Notification.requestPermission()!==`granted`)throw Error(J(`app.pushPrompt.notGranted`));let{key:t}=await $.request(`/push/vapid`),n=atob(t.replace(/-/g,`+`).replace(/_/g,`/`)+`=`.repeat((4-t.length%4)%4)),r=Uint8Array.from(n,e=>e.charCodeAt(0)),i=(await e.pushManager.getSubscription()||await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:r})).toJSON();await $.request(`/push/subscribe`,{method:`POST`,body:{endpoint:i.endpoint||``,expirationTime:i.expirationTime??null,keys:i.keys||{}}}),Ye(i.endpoint||null),Ze(!0),_p(),Z(J(`app.pushPrompt.enabled`));try{await $.request(`/settings/test-notification`,{method:`POST`})}catch(e){Z(J(`app.pushPrompt.testError`,{error:String(e)}),!0)}}catch(e){Z(J(`app.pushPrompt.error`,{error:e instanceof Error?e.message:String(e)}),!0)}}async function Pt(e){try{if(await $.request(`/push/subscribe`,{method:`DELETE`,body:{endpoint:e}}),Je===e&&ue())Me()?.disablePush(),Ye(null);else if(Je===e){try{let t=await(await navigator.serviceWorker?.getRegistration())?.pushManager.getSubscription();t&&t.endpoint===e&&await t.unsubscribe()}catch{}Ye(null)}Z(J(`app.pushPrompt.unsubscribed`))}catch(e){Z(J(`app.pushPrompt.unsubscribeError`,{error:String(e)}),!0)}}async function Ft(){re(``),localStorage.setItem(`lec-token`,te);try{await $.projects(),W(!1),K(e=>e+1)}catch(e){re(String(e))}}let It=H(),Lt=[{id:`new-session`,shortcut:Ae(`session.new`),title:J(`app.commands.newSession`),category:J(`palette.actions`),detail:J(`app.commands.newSessionDetail`),keywords:`create launch`,run:()=>Et(`new`)},{id:`new-task`,shortcut:Ae(`task.new`),title:J(`app.newTask`),category:J(`palette.actions`),detail:J(`app.commands.newTaskDetail`),keywords:`create`,run:Tt},{id:`routines`,shortcut:Ae(`routines.open`),title:J(`app.commands.routines`),category:J(`palette.actions`),detail:J(`app.commands.routinesDetail`),keywords:`schedule takeover`,run:()=>{lt(`#tasks`),_e(e=>e+1)}},{id:`saved-search`,shortcut:Ae(`search.saved`),title:J(`app.commands.savedSearch`),category:J(`palette.actions`),keywords:`history messages content native`,run:()=>R(!0)},{id:`discover`,shortcut:Ae(`session.discover`),title:J(`app.commands.discover`),category:J(`palette.actions`),keywords:`adopt restore untracked`,run:()=>Et(`discover`)},{id:`launch-profiles`,shortcut:Ae(`profiles.manage`),title:J(`app.commands.launchProfiles`),category:J(`palette.actions`),keywords:`profiles accounts configuration`,run:()=>Pe(!0)},...Ff.map(e=>({id:`nav-${e}`,title:e===`terminals`?J(`app.commands.openTerminals`):bp(e),category:J(`app.commands.navigate`),keywords:`navigate view `+{tasks:`board`,overview:`deck live`,issues:`pull requests github`,settings:`preferences`}[e],shortcut:Ae(wp[e]),run:()=>lt(e===`terminals`?ut.hash:`#`+e)})),...[[`machines`,J(`app.commands.targets`),`ssh remote local machines`],[`projects`,J(`app.commands.projects`),`repositories workspaces`],[`notifications`,J(`app.commands.notifications`),`alerts push`],[`devices`,J(`app.commands.devices`),`pair phone tunnel qr code pairing`],[`about`,J(`app.commands.about`),`settings version costs`],[`agents`,J(`app.commands.agents`),`agent runners commands custom providers models`],[`plugins`,J(`app.commands.plugins`),`plugins extensions marketplace install skills mcp hooks themes`]].map(([e,t,n])=>({id:`settings-`+e,title:t,category:J(`app.commands.navigate`),detail:J(`palette.settings`),keywords:n,run:()=>Dt(e)})),...We.filter(e=>e.context!==`terminal`&&!e.id.startsWith(`nav.`)&&![`palette.open`,`search.saved`,`session.new`,`session.discover`,`task.new`,`routines.open`,`profiles.manage`].includes(e.id)&&!e.id.startsWith(`settings.`)&&se(e.id)).map(e=>({id:`action-`+e.id,title:J(`shortcut.`+e.id,void 0,e.title),category:J(`palette.actions`),detail:e.category,keywords:e.keywords,shortcut:Ae(e.id),run:()=>{e.context===`workspace`&&n!==`terminals`&<(ut.hash),requestAnimationFrame(()=>de(e.id))}})),...It.palette_commands.flatMap(e=>{let t=a(e.href);return t?[{id:`plugin-`+e.id,title:e.title,category:J(`app.commands.plugins`),detail:e.plugin,keywords:`plugin `+e.plugin,run:()=>{t.startsWith(`#`)?location.hash=t:window.open(t,`_blank`,`noopener,noreferrer`)}}]:[]}),...Su().filter(e=>[`appearance`,`workspace`,`shortcuts`].includes(e.section)).map(e=>({id:`setting-`+e.id,title:e.label,category:J(`palette.settings`),detail:e.sectionLabel,keywords:e.keywords,run:()=>Dt(e.section,e.id)})),...m.map(e=>({id:`session-${e.id}`,title:e.name||J(`app.lineage.session`,{id:e.id}),category:J(`app.commands.sessions`),detail:[go(po(e)),e.agent,e.group_path,e.project_name,e.target_name,e.workdir].filter(Boolean).join(` · `),keywords:`attach terminal `+(e.workspace?.branch||``),run:()=>St(e.id)})),...d.map(e=>({id:`task-${e.id}`,title:e.title||J(`app.commands.task`,{id:e.id}),category:J(`app.commands.tasks`),detail:[e.status,e.project_name].join(` · `),keywords:`task ${e.id}`,run:()=>wt(e.id)})),...s.map(e=>({id:`project-${e.id}`,title:J(`app.commands.editProject`,{name:e.name}),category:J(`app.commands.projectsCategory`),detail:e.repo_path,keywords:`repository workspace configuration`,run:()=>{Dt(`projects`),Ee({id:e.id,version:Date.now()})}}))],Rt=m.filter(e=>e.status!==`dead`&&!e.ended_at).length;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{id:`aurora`,"aria-hidden":`true`}),(0,Q.jsxs)(`header`,{id:`topbar`,ref:it,children:[(0,Q.jsxs)(`div`,{className:`brand`,children:[(0,Q.jsx)(`span`,{className:`brand-mark`,"aria-hidden":`true`,children:(0,Q.jsx)(Kf,{name:`brand`,size:22})}),(0,Q.jsxs)(`h1`,{children:[`lec`,(0,Q.jsx)(`b`,{children:`tern`})]}),(0,Q.jsx)(`span`,{className:`brand-sub`,children:J(`shell.brandSub`)})]}),(0,Q.jsxs)(`button`,{id:`command-open`,"aria-label":J(`shell.searchLabel`),"aria-haspopup":`dialog`,title:J(`shell.searchTitle`),onClick:()=>I(!0),children:[(0,Q.jsx)(Kf,{name:`search`,size:18}),(0,Q.jsx)(`span`,{className:`command-label`,children:J(`shell.searchAnything`)}),Ae(`palette.open`)[0]&&(0,Q.jsx)(`kbd`,{children:Ue(Ae(`palette.open`)[0])})]}),(0,Q.jsxs)(`div`,{className:`top-status`,children:[(0,Q.jsx)(`span`,{id:`conn-led`,className:`led ${j?`led-on`:`led-err`}`,title:J(`app.liveConnection`)}),(0,Q.jsx)(`span`,{id:`conn-label`,children:J(j?`shell.live`:`shell.reconnecting`)})]})]}),(0,Q.jsxs)(`main`,{id:`view`,hidden:n===`terminals`,children:[(0,Q.jsx)(dp,{onRetry:pt}),(0,Q.jsx)(pp,{target:mt,onRefresh:ft}),n===`tasks`&&(0,Q.jsx)(Kn,{api:$,refreshVersion:k,openTaskId:oe,newTaskVersion:le,openTaskVersion:pe,routinesVersion:ge,onExternalActionConsumed:e=>{e===`task`&&ce(void 0),e===`new`&&fe(0),e===`routines`&&_e(0)},onOpenTask:e=>{ce(e.id),history.replaceState(null,``,`#task/${e.id}`)},onChat:e=>Ie({kind:`task`,id:e.id,name:e.title}),onNotice:Z,onOpenSession:e=>Ie({kind:`session`,id:e,name:m.find(t=>t.id===e)?.name||J(`app.continuity.session`)}),onOpenTerminal:ht}),` `,n===`sessions`&&(0,Q.jsx)(Xo,{api:$,refreshVersion:k,action:ve,onActionConsumed:()=>xe(void 0),onMetadataRefresh:()=>void ft().catch(e=>Z(String(e),!0)),projects:s,targets:l,mediaCounts:dt,onMedia:e=>lt(`#media/`+e),onOpenTerminal:ht,onReview:Re,onMergeReview:Be,onOpenTask:wt,onSwitch:Ge,onNotice:Z,pushPrompt:{show:et.available&&Je===null&&!Xe,onEnable:()=>void Nt(),onDismiss:()=>{Ze(!0),_p()}}}),` `,n===`media`&&(0,Q.jsx)(xt,{api:$,rows:b,live:S,liveEnabled:w,targets:l,sessionFilter:E,onFilter:e=>lt(e==null?`#media`:`#media/`+e),onChanged:()=>void ft().catch(e=>Z(String(e),!0)),onNotice:Z}),` `,n===`issues`&&(0,Q.jsx)(wd,{api:$,projects:s,refreshVersion:k,onNotice:Z,onOpenSession:(e,t)=>Ie({kind:`session`,id:e,name:t}),onOpenTask:wt,onSettings:e=>{Dt(`projects`),Ee({id:e,version:Date.now()})}}),` `,n===`overview`&&(0,Q.jsx)(Wf,{tasks:d,api:$,onTask:wt}),` `,n===`approvals`&&(0,Q.jsx)(Gf,{rows:g,api:$,onChanged:()=>void ft().catch(e=>Z(String(e),!0)),onNotice:Z,onOpenSession:e=>{let t=m.find(t=>t.id===e);Ie({kind:`session`,id:e,name:t?.name||J(`app.continuity.session`)})},onOpenTask:wt,onSettings:()=>Dt(`basics`)}),` `,n===`settings`&&(0,Q.jsx)(Iu,{api:$,section:Se,projectEdit:we,launchProfilesVersion:Oe,onOpenTerminal:(e,t)=>ut.open(e,t),onMetadataRefresh:()=>void ft().catch(e=>Z(String(e),!0)),onNotice:Z,onEnablePush:()=>void Nt(),pushAvailable:et.available,pushUnavailableReason:et.reason,pushUnavailableReasonKind:et.reasonKind,pushEndpoint:Je,onUnsubscribePush:Pt})]}),(0,Q.jsx)(Cf,{controller:ut,visible:n===`terminals`,machines:l,projects:s,onNew:Ct,onBrowse:()=>lt(`#sessions`),onSearch:()=>I(!0),services:Ot,switcher:(()=>{let e=m.find(e=>ut.active===`/terminal/session/${e.id}`&&e.agent!==`shell`&&!e.ended_at&&e.status!==`dead`&&e.setup_state!==`creating`);if(!e)return null;let t=e.id in Ke||e.handoff_in_flight;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`button`,{className:`b terminal-agent-switch`,"aria-label":J(`app.switcher.label`),title:J(`app.switcher.title`,{model:Io(e)}),disabled:t,onClick:()=>Ge(e),children:t?J(`app.switcher.switching`):`⇄ ${Io(e)} ▾`}),(0,Q.jsx)(Ir,{api:$,session:e,pending:t,onOpen:e=>{e.ended_at?Ie({kind:`session`,id:e.id,name:e.name}):St(e.id)},onOpenChat:e=>Ie({kind:`session`,id:e.id,name:e.name})})]})})()}),(0,Q.jsx)(jf,{services:Ot,onDock:e=>ut.open(e.path,e.label)}),Ve&&(0,Q.jsx)(Lo,{api:$,session:Ve,onClose:()=>Ge(void 0),onStarted:(e,t,n)=>{rt({...tt.current,[String(e.id)]:{after:t,generation:1,destination:n.destination,agent:n.agent,model:n.model,profile:n.profile}}),Z(J(`app.switch.waiting`)),ft().catch(e=>Z(String(e),!0))},onProfiles:()=>{Ge(void 0),Pe(!0)}}),(0,Q.jsx)(Yf,{api:$,pending:Ke,onReady:gt,onFailed:vt,onRetry:e=>void yt(e),onReopen:_t,onDismiss:bt}),(0,Q.jsxs)(`button`,{id:`fab`,title:J(`app.fabTitle`),"aria-label":J(`app.newTask`),hidden:n!==`tasks`,onClick:Tt,children:[(0,Q.jsx)(Kf,{name:`plus`,size:24}),(0,Q.jsx)(`span`,{children:J(`board.newTask`)})]}),(0,Q.jsxs)(`nav`,{id:`tabbar`,"aria-label":J(`nav.label`),children:[Lf(ut.tabs.length>0,e).map(e=>(0,Q.jsxs)(`button`,{"data-tab":e,"data-nav-target":e,"aria-current":n===e?`page`:void 0,className:[`tab`,n===e?`on`:``].filter(Boolean).join(` `),onClick:()=>lt(e===`terminals`?ut.hash:`#`+e),children:[(0,Q.jsx)(`span`,{className:`tab-ic`,"aria-hidden":`true`,children:(0,Q.jsx)(Kf,{name:Cp[e]})}),bp(e),e===`sessions`&&(0,Q.jsx)(`b`,{id:`sess-badge`,className:`badge dim`,hidden:!Rt,title:J(`nav.liveSessions`,{n:Rt}),children:Rt}),e===`terminals`&&(0,Q.jsx)(`b`,{id:`terminal-badge`,className:`badge dim`,hidden:!ut.tabs.length,children:ut.tabs.length}),e===`media`&&(0,Q.jsx)(`b`,{id:`media-badge`,className:S.length?`badge`:`badge dim`,hidden:!b.length&&!S.length,title:S.length?J(`app.liveCount`,{n:S.length}):J(`nav.mediaCount`,{n:b.length}),children:b.length+S.length}),e===`approvals`&&(0,Q.jsx)(`b`,{id:`appr-badge`,className:`badge`,hidden:!g.length,title:J(`nav.approvalsWaiting`,{n:g.length}),children:g.length})]},e)),e&&[`machines`,`plugins`].map(e=>(0,Q.jsxs)(`button`,{className:`tab`+(n===`settings`&&Se.name===e?` on`:``),"data-nav-target":e,"aria-current":n===`settings`&&Se.name===e?`page`:void 0,onClick:()=>Dt(e),children:[(0,Q.jsx)(`span`,{className:`tab-ic`,"aria-hidden":`true`,children:(0,Q.jsx)(Kf,{name:Cp.settings})}),J(`nav.more.${e}`)]},e)),!e&&(0,Q.jsxs)(`details`,{id:`nav-overflow`,className:`action-menu ${Rf(ut.tabs.length>0).some(e=>`view`in e&&e.view===n)?`on`:``}`,children:[(0,Q.jsxs)(`summary`,{"aria-label":J(`app.morePages`),children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`···`}),J(`nav.more`),(0,Q.jsx)(`b`,{id:`media-badge`,className:S.length?`badge`:`badge dim`,hidden:!b.length&&!S.length,title:S.length?J(`app.liveCount`,{n:S.length}):J(`nav.mediaCount`,{n:b.length}),children:b.length+S.length})]}),(0,Q.jsx)(`div`,{className:`action-menu-panel`,children:Rf(ut.tabs.length>0).map(e=>{let t=`view`in e?e.view:e.section;return(0,Q.jsxs)(`button`,{"data-nav-target":t,"aria-current":`view`in e&&n===e.view?`page`:void 0,onClick:t=>{`view`in e?lt(e.view===`terminals`?ut.hash:`#`+e.view):Dt(e.section),t.currentTarget.closest(`details`)?.removeAttribute(`open`)},children:[(0,Q.jsx)(`span`,{className:`more-title`,children:`view`in e?bp(e.view):J(`nav.more.${e.section}`)}),(0,Q.jsx)(`span`,{className:`more-detail`,children:J(`nav.moreDetail.${t}`)})]},t)})})]})]}),(0,Q.jsx)(`div`,{id:`toasts`,"aria-live":`polite`,children:ie.map(e=>(0,Q.jsxs)(`div`,{className:`toast ${e.error?`err`:``}${e.action?` has-action`:``}`,children:[(0,Q.jsx)(`span`,{children:e.text}),e.action&&(0,Q.jsx)(`button`,{className:`toast-action`,onClick:()=>{let t=e.action;ae(t=>t.filter(t=>t.id!==e.id)),t.run()},children:e.action.label})]},e.id))}),P&&(0,Q.jsx)(Pf,{items:Lt,refresh:ft,onClose:()=>I(!1),onError:e=>Z(e,!0)}),` `,je&&(0,Q.jsx)(lr,{api:$,onClose:()=>Pe(!1),onChange:()=>void ft().catch(e=>Z(String(e),!0))}),L&&(0,Q.jsx)(De,{api:$,targets:l,onClose:()=>R(!1),onFork:e=>{R(!1),ft().catch(e=>Z(String(e),!0)),e.setup_state===`creating`?(lt(`#sessions`),Z(J(`app.forkStarted`))):St(e.id)},onNotice:Z}),` `,Fe&&(0,Q.jsx)(ro,{...Fe,session:Fe.kind===`session`?m.find(e=>e.id===Fe.id):void 0,onOpenSession:e=>Ie({kind:`session`,id:e.id,name:e.name}),onAttach:Fe.kind===`session`?()=>void St(Fe.id):void 0,api:$,onClose:()=>Ie(void 0),onNotice:Z,onSwitch:(()=>{let e=Fe.kind===`session`&&m.find(e=>e.id===Fe.id&&e.agent!==`shell`&&!e.ended_at&&e.status!==`dead`);return e?()=>{Ie(void 0),Ge(e)}:void 0})()},`${Fe.kind}-${Fe.id}`),` `,Le&&(0,Q.jsx)(be,{kind:`session`,id:String(Le.id),name:Le.name,onClose:()=>Re(void 0)}),` `,ze&&(0,Q.jsx)(me,{api:$,sessionId:ze.id,name:ze.name,onClose:()=>Be(void 0),onNotice:Z}),` `,i&&(0,Q.jsx)(Dd,{api:$,projects:s,onClose:()=>o(!1),onNotice:Z}),` `,V&&(0,Q.jsxs)(O,{className:`token-dialog`,"aria-label":J(`app.token.title`),onCancel:e=>e.preventDefault(),children:[(0,Q.jsx)(`h2`,{children:J(`app.token.title`)}),(0,Q.jsx)(`p`,{children:J(`app.token.required`)}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),Ft()},children:[(0,Q.jsx)(`label`,{htmlFor:`access-token`,children:J(`app.token.title`)}),(0,Q.jsx)(`input`,{id:`access-token`,type:`password`,autoComplete:`current-password`,value:te,onChange:e=>G(e.target.value)}),q&&(0,Q.jsx)(`p`,{role:`alert`,children:q}),(0,Q.jsx)(`button`,{className:`b ok`,type:`submit`,children:J(`app.token.connect`)})]})]})]})}function Dp(e){let t=/code=([^&]+)/.exec(e);return t?.[1]?decodeURIComponent(t[1]):``}function Op(e){let t=e||``;return/iPad/.test(t)?`iPad`:/iPhone/.test(t)?`iPhone`:/Android/.test(t)?/Mobile/.test(t)?J(`app.pair.androidPhone`):J(`app.pair.androidTablet`):/Macintosh/.test(t)?`Mac`:/Windows/.test(t)?J(`app.pair.windowsPc`):/Linux/.test(t)?`Linux`:J(`app.pair.myDevice`)}function kp(){Y();let[e,t]=(0,X.useState)(()=>Dp(window.location.hash)),[n]=(0,X.useState)(()=>!ue()&&as(navigator.userAgent)?is(window.location.href):void 0),[r,i]=(0,X.useState)(()=>Op(navigator.userAgent)),[a,o]=(0,X.useState)(`idle`),[s,c]=(0,X.useState)(``);(0,X.useEffect)(()=>{Dp(window.location.hash)&&history.replaceState(null,``,`/pair`)},[]);async function l(t){t.preventDefault(),o(`working`),c(``);try{let t=await fetch(`/api/pair/exchange`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({code:e.replace(/[-\s]/g,``),name:r.trim()})}),n=await t.json().catch(()=>({}));if(!t.ok)throw Error(n.detail||J(`app.pair.failed`,{status:t.status}));n.token&&Me()?.saveDeviceToken(n.token);try{localStorage.setItem(`lec-paired`,`1`)}catch{}window.location.href=`/`}catch(e){o(`error`),c(e instanceof Error?e.message:String(e))}}return(0,Q.jsx)(`main`,{className:`pair-page`,children:(0,Q.jsxs)(`div`,{className:`pair-card`,children:[(0,Q.jsx)(`h1`,{children:J(`app.pair.title`)}),(0,Q.jsx)(`p`,{children:J(`app.pair.intro`)}),(0,Q.jsx)(ss,{intent:n}),(0,Q.jsxs)(`form`,{onSubmit:e=>void l(e),children:[(0,Q.jsxs)(`label`,{children:[J(`app.pair.code`),(0,Q.jsx)(`input`,{id:`pair-code`,autoFocus:!0,autoCapitalize:`characters`,autoCorrect:`off`,autoComplete:`off`,spellCheck:!1,value:e,onChange:e=>t(e.target.value),placeholder:`XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXX`})]}),(0,Q.jsxs)(`label`,{children:[J(`app.pair.name`),(0,Q.jsx)(`input`,{id:`pair-name`,value:r,maxLength:120,onChange:e=>i(e.target.value)})]}),a===`error`&&(0,Q.jsx)(`p`,{role:`alert`,className:`pair-error`,children:s}),(0,Q.jsx)(`button`,{id:`pair-submit`,type:`submit`,disabled:a===`working`||!e.trim(),children:J(a===`working`?`app.pair.pairing`:`app.pair.submit`)})]})]})})}function Ap(e){let t=/[#&]p=([A-Za-z0-9_-]+)/.exec(e);if(t?.[1])try{let e=JSON.parse(new TextDecoder().decode(Se(t[1])));return typeof e.relay!=`string`||typeof e.ch!=`string`||typeof e.hk!=`string`||typeof e.sk!=`string`||typeof e.c!=`string`||typeof e.rt!=`string`||!/^wss?:\/\//.test(e.relay)?void 0:e}catch{return}}function jp(e){return Array.from(ke(Se(e)).slice(0,8),e=>e.toString(16).padStart(2,`0`)).join(``).match(/.{4}/g).join(` `)}function Mp(){Y();let[e]=(0,X.useState)(()=>Ap(window.location.hash)),[t]=(0,X.useState)(()=>!ue()&&as(navigator.userAgent)?is(window.location.href):void 0),[n,r]=(0,X.useState)(()=>Op(navigator.userAgent)),[i,a]=(0,X.useState)(`idle`),[o,s]=(0,X.useState)(``);(0,X.useEffect)(()=>{window.location.hash&&history.replaceState(null,``,`/relay-pair`),ue()||navigator.serviceWorker?.register(`/sw.js`).catch(()=>void 0)},[]);async function c(t){if(t.preventDefault(),e){a(`working`),s(``);try{ue()||(await w(e.sk),await Oe());let t=await P(e,n.trim()||J(`app.relayPair.defaultName`));await G(t),a(`done`),window.location.href=`/`}catch(e){a(`error`),s(e instanceof Error?e.message:String(e))}}}if(!e)return(0,Q.jsx)(`main`,{className:`pair-page`,children:(0,Q.jsxs)(`div`,{className:`pair-card`,children:[(0,Q.jsx)(`h1`,{children:J(`app.relayPair.titleShort`)}),(0,Q.jsx)(`p`,{role:`alert`,className:`pair-error`,children:J(`app.relayPair.noCode`)})]})});let l=e.relay;try{l=new URL(e.relay).host}catch{}return(0,Q.jsx)(`main`,{className:`pair-page`,children:(0,Q.jsxs)(`div`,{className:`pair-card`,"data-testid":`relay-pair`,children:[(0,Q.jsx)(`h1`,{children:J(`app.relayPair.title`)}),(0,Q.jsxs)(`p`,{children:[J(`app.relayPair.through`),(0,Q.jsx)(`strong`,{children:l}),J(`app.relayPair.throughAfter`)]}),(0,Q.jsx)(ss,{intent:t}),(0,Q.jsxs)(`p`,{children:[J(`app.relayPair.key`),(0,Q.jsx)(`code`,{className:`relay-fingerprint`,children:jp(e.hk)}),(0,Q.jsx)(`br`,{}),J(`app.relayPair.keyMatch`)]}),(0,Q.jsxs)(`form`,{onSubmit:e=>void c(e),children:[(0,Q.jsxs)(`label`,{children:[J(`app.pair.name`),(0,Q.jsx)(`input`,{id:`relay-pair-name`,value:n,maxLength:120,onChange:e=>r(e.target.value)})]}),i===`error`&&(0,Q.jsx)(`p`,{role:`alert`,className:`pair-error`,children:o}),(0,Q.jsx)(`button`,{id:`relay-pair-submit`,type:`submit`,disabled:i===`working`||i===`done`,children:J(i===`working`?`app.pair.pairing`:i===`done`?`app.relayPair.paired`:`app.pair.title`)})]})]})})}function Np({tunnel:e}){Y();let[,t]=(0,X.useState)(0),[n,r]=(0,X.useState)(!1);return(0,X.useEffect)(()=>{if(!e)return;let n=0,i=()=>{t(e=>e+1),window.clearTimeout(n),r(!1),e.status!==`connected`&&(n=window.setTimeout(()=>r(!0),3e3))};return e.addEventListener(`status`,i),i(),()=>{e.removeEventListener(`status`,i),window.clearTimeout(n)}},[e]),!e||e.status===`connected`||e.status===`idle`||e.status!==`revoked`&&!n?null:(0,Q.jsx)(`div`,{className:`relay-banner`,role:`status`,"data-status":e.status,children:e.status===`revoked`?(0,Q.jsx)(Q.Fragment,{children:J(`app.relayBanner.revoked`,{detail:e.detail})}):(0,Q.jsx)(Q.Fragment,{children:J(`app.relayBanner.reaching`,{detail:e.detail})})})}k();var Pp=(0,Z.createRoot)(document.getElementById(`root`)),Fp=window.location.pathname;Fp===`/native-action`?ot(()=>import(`./action-udnajeUM.js`).then(e=>e.runNativeAction()),__vite__mapDeps([7,2,1,3,4,5])):(0,st.flushSync)(()=>Pp.render(Fp===`/pair`?(0,Q.jsx)(kp,{}):Fp===`/relay-pair`?(0,Q.jsx)(Mp,{}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Np,{tunnel:W}),(0,Q.jsx)(Ep,{})]})));export{Xi as t};
\ No newline at end of file
diff --git a/web/static/react/assets/architectureDiagram-5GKGNRK7-kblFW2Q7.js b/web/static/react/assets/architectureDiagram-5GKGNRK7-DhTmmSs3.js
similarity index 99%
rename from web/static/react/assets/architectureDiagram-5GKGNRK7-kblFW2Q7.js
rename to web/static/react/assets/architectureDiagram-5GKGNRK7-DhTmmSs3.js
index e4b49c0c..8775e999 100644
--- a/web/static/react/assets/architectureDiagram-5GKGNRK7-kblFW2Q7.js
+++ b/web/static/react/assets/architectureDiagram-5GKGNRK7-DhTmmSs3.js
@@ -1,4 +1,4 @@
-import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{n}from"./mermaid-parser.core-DyaQCW3q.js";import{n as r}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as i,p as a}from"./src-B6xuSHsQ.js";import{H as o,J as s,K as c,U as l,a as u,b as d,f,v as p,w as m,x as h,y as g,z as _}from"./chunk-DU6HZSFF-C_e7FuEU.js";import{c as v,i as y}from"./chunk-75Z2AOVW-DQblLoc-.js";import{t as b}from"./chunk-JWPE2WC7-DVXcaiue.js";import{i as x,r as S,t as C}from"./chunk-PWAF6VOD-CO5TQ6iI.js";import{n as w}from"./chunk-GMAD6QVW-hT1nChK-.js";import{t as T}from"./cytoscape.esm-Yq6u8L66.js";import{f as E}from"./mermaid.core-RPGe421d.js";var D=t(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.layoutBase=r():n.layoutBase=r()})(e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=28)})([(function(e,t,n){function r(){}r.QUALITY=1,r.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,r.DEFAULT_INCREMENTAL=!1,r.DEFAULT_ANIMATION_ON_LAYOUT=!0,r.DEFAULT_ANIMATION_DURING_LAYOUT=!1,r.DEFAULT_ANIMATION_PERIOD=50,r.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,r.DEFAULT_GRAPH_MARGIN=15,r.NODE_DIMENSIONS_INCLUDE_LABELS=!1,r.SIMPLE_NODE_SIZE=40,r.SIMPLE_NODE_HALF_SIZE=r.SIMPLE_NODE_SIZE/2,r.EMPTY_COMPOUND_NODE_SIZE=40,r.MIN_EDGE_LENGTH=1,r.WORLD_BOUNDARY=1e6,r.INITIAL_WORLD_BOUNDARY=r.WORLD_BOUNDARY/1e3,r.WORLD_CENTER_X=1200,r.WORLD_CENTER_Y=900,e.exports=r}),(function(e,t,n){var r=n(2),i=n(8),a=n(9);function o(e,t,n){r.call(this,n),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=n,this.bendpoints=[],this.source=e,this.target=t}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.getSource=function(){return this.source},o.prototype.getTarget=function(){return this.target},o.prototype.isInterGraph=function(){return this.isInterGraph},o.prototype.getLength=function(){return this.length},o.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},o.prototype.getBendpoints=function(){return this.bendpoints},o.prototype.getLca=function(){return this.lca},o.prototype.getSourceInLca=function(){return this.sourceInLca},o.prototype.getTargetInLca=function(){return this.targetInLca},o.prototype.getOtherEnd=function(e){if(this.source===e)return this.target;if(this.target===e)return this.source;throw`Node is not incident with this edge`},o.prototype.getOtherEndInGraph=function(e,t){for(var n=this.getOtherEnd(e),r=t.getGraphManager().getRoot();;){if(n.getOwner()==t)return n;if(n.getOwner()==r)break;n=n.getOwner().getParent()}return null},o.prototype.updateLength=function(){var e=[,,,,];this.isOverlapingSourceAndTarget=i.getIntersection(this.target.getRect(),this.source.getRect(),e),this.isOverlapingSourceAndTarget||(this.lengthX=e[0]-e[2],this.lengthY=e[1]-e[3],Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},o.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},e.exports=o}),(function(e,t,n){function r(e){this.vGraphObject=e}e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(13),o=n(0),s=n(16),c=n(5);function l(e,t,n,o){n==null&&o==null&&(o=t),r.call(this,o),e.graphManager!=null&&(e=e.graphManager),this.estimatedSize=i.MIN_VALUE,this.inclusionTreeDepth=i.MAX_VALUE,this.vGraphObject=o,this.edges=[],this.graphManager=e,this.rect=n!=null&&t!=null?new a(t.x,t.y,n.width,n.height):new a}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.getEdges=function(){return this.edges},l.prototype.getChild=function(){return this.child},l.prototype.getOwner=function(){return this.owner},l.prototype.getWidth=function(){return this.rect.width},l.prototype.setWidth=function(e){this.rect.width=e},l.prototype.getHeight=function(){return this.rect.height},l.prototype.setHeight=function(e){this.rect.height=e},l.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},l.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},l.prototype.getCenter=function(){return new c(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},l.prototype.getLocation=function(){return new c(this.rect.x,this.rect.y)},l.prototype.getRect=function(){return this.rect},l.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},l.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},l.prototype.setRect=function(e,t){this.rect.x=e.x,this.rect.y=e.y,this.rect.width=t.width,this.rect.height=t.height},l.prototype.setCenter=function(e,t){this.rect.x=e-this.rect.width/2,this.rect.y=t-this.rect.height/2},l.prototype.setLocation=function(e,t){this.rect.x=e,this.rect.y=t},l.prototype.moveBy=function(e,t){this.rect.x+=e,this.rect.y+=t},l.prototype.getEdgeListToNode=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.target==e){if(r.source!=n)throw`Incorrect edge source!`;t.push(r)}}),t},l.prototype.getEdgesBetween=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.source!=n&&r.target!=n)throw`Incorrect edge source and/or target`;(r.target==e||r.source==e)&&t.push(r)}),t},l.prototype.getNeighborsList=function(){var e=new Set,t=this;return t.edges.forEach(function(n){if(n.source==t)e.add(n.target);else{if(n.target!=t)throw`Incorrect incidency!`;e.add(n.source)}}),e},l.prototype.withChildren=function(){var e=new Set,t,n;if(e.add(this),this.child!=null)for(var r=this.child.getNodes(),i=0;it?(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)):this.labelPosHorizontal==`right`&&this.setWidth(t+this.labelWidth)),this.labelHeight&&(this.labelPosVertical==`top`?(this.rect.y-=this.labelHeight,this.setHeight(n+this.labelHeight)):this.labelPosVertical==`center`&&this.labelHeight>n?(this.rect.y-=(this.labelHeight-n)/2,this.setHeight(this.labelHeight)):this.labelPosVertical==`bottom`&&this.setHeight(n+this.labelHeight))}}},l.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==i.MAX_VALUE)throw`assert failed`;return this.inclusionTreeDepth},l.prototype.transform=function(e){var t=this.rect.x;t>o.WORLD_BOUNDARY?t=o.WORLD_BOUNDARY:t<-o.WORLD_BOUNDARY&&(t=-o.WORLD_BOUNDARY);var n=this.rect.y;n>o.WORLD_BOUNDARY?n=o.WORLD_BOUNDARY:n<-o.WORLD_BOUNDARY&&(n=-o.WORLD_BOUNDARY);var r=new c(t,n),i=e.inverseTransformPoint(r);this.setLocation(i.x,i.y)},l.prototype.getLeft=function(){return this.rect.x},l.prototype.getRight=function(){return this.rect.x+this.rect.width},l.prototype.getTop=function(){return this.rect.y},l.prototype.getBottom=function(){return this.rect.y+this.rect.height},l.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},e.exports=l}),(function(e,t,n){var r=n(0);function i(){}for(var a in r)i[a]=r[a];i.MAX_ITERATIONS=2500,i.DEFAULT_EDGE_LENGTH=50,i.DEFAULT_SPRING_STRENGTH=.45,i.DEFAULT_REPULSION_STRENGTH=4500,i.DEFAULT_GRAVITY_STRENGTH=.4,i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,i.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,i.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,i.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,i.COOLING_ADAPTATION_FACTOR=.33,i.ADAPTATION_LOWER_NODE_LIMIT=1e3,i.ADAPTATION_UPPER_NODE_LIMIT=5e3,i.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,i.MAX_NODE_DISPLACEMENT=i.MAX_NODE_DISPLACEMENT_INCREMENTAL*3,i.MIN_REPULSION_DIST=i.DEFAULT_EDGE_LENGTH/10,i.CONVERGENCE_CHECK_PERIOD=100,i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,i.MIN_EDGE_LENGTH=1,i.GRID_CALCULATION_CHECK_PERIOD=10,e.exports=i}),(function(e,t,n){function r(e,t){e==null&&t==null?(this.x=0,this.y=0):(this.x=e,this.y=t)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(e){this.x=e},r.prototype.setY=function(e){this.y=e},r.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(0),o=n(7),s=n(3),c=n(1),l=n(13),u=n(12),d=n(11);function f(e,t,n){r.call(this,n),this.estimatedSize=i.MIN_VALUE,this.margin=a.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,t!=null&&t instanceof o?this.graphManager=t:t!=null&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var p in f.prototype=Object.create(r.prototype),r)f[p]=r[p];f.prototype.getNodes=function(){return this.nodes},f.prototype.getEdges=function(){return this.edges},f.prototype.getGraphManager=function(){return this.graphManager},f.prototype.getParent=function(){return this.parent},f.prototype.getLeft=function(){return this.left},f.prototype.getRight=function(){return this.right},f.prototype.getTop=function(){return this.top},f.prototype.getBottom=function(){return this.bottom},f.prototype.isConnected=function(){return this.isConnected},f.prototype.add=function(e,t,n){if(t==null&&n==null){var r=e;if(this.graphManager==null)throw`Graph has no graph mgr!`;if(this.getNodes().indexOf(r)>-1)throw`Node already in graph!`;return r.owner=this,this.getNodes().push(r),r}var i=e;if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(n)>-1))throw`Source or target not in graph!`;if(t.owner!=n.owner||t.owner!=this)throw`Both owners must be this graph!`;return t.owner==n.owner?(i.source=t,i.target=n,i.isInterGraph=!1,this.getEdges().push(i),t.edges.push(i),n!=t&&n.edges.push(i),i):null},f.prototype.remove=function(e){var t=e;if(e instanceof s){if(t==null)throw`Node is null!`;if(t.owner==null||t.owner!=this)throw`Owner graph is invalid!`;if(this.graphManager==null)throw`Owner graph manager is invalid!`;for(var n=t.edges.slice(),r,i=n.length,a=0;a-1&&u>-1))throw`Source and/or target doesn't know this edge!`;r.source.edges.splice(l,1),r.target!=r.source&&r.target.edges.splice(u,1);var o=r.source.owner.getEdges().indexOf(r);if(o==-1)throw`Not in owner's edge list!`;r.source.owner.getEdges().splice(o,1)}},f.prototype.updateLeftTop=function(){for(var e=i.MAX_VALUE,t=i.MAX_VALUE,n,r,a,o=this.getNodes(),s=o.length,c=0;cn&&(e=n),t>r&&(t=r)}return e==i.MAX_VALUE?null:(a=o[0].getParent().paddingLeft==null?this.margin:o[0].getParent().paddingLeft,this.left=t-a,this.top=e-a,new u(this.left,this.top))},f.prototype.updateBounds=function(e){for(var t=i.MAX_VALUE,n=-i.MAX_VALUE,r=i.MAX_VALUE,a=-i.MAX_VALUE,o,s,c,u,d,f=this.nodes,p=f.length,m=0;mo&&(t=o),nc&&(r=c),ao&&(t=o),nc&&(r=c),a=this.nodes.length){var c=0;n.forEach(function(t){t.owner==e&&c++}),c==this.nodes.length&&(this.isConnected=!0)}},e.exports=f}),(function(e,t,n){var r,i=n(1);function a(e){r=n(6),this.layout=e,this.graphs=[],this.edges=[]}a.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),n=this.add(e,t);return this.setRootGraph(n),this.rootGraph},a.prototype.add=function(e,t,n,r,i){if(n==null&&r==null&&i==null){if(e==null)throw`Graph is null!`;if(t==null)throw`Parent node is null!`;if(this.graphs.indexOf(e)>-1)throw`Graph already in this graph mgr!`;if(this.graphs.push(e),e.parent!=null)throw`Already has a parent!`;if(t.child!=null)throw`Already has a child!`;return e.parent=t,t.child=e,e}i=n,r=t,n=e;var a=r.getOwner(),o=i.getOwner();if(a==null||a.getGraphManager()!=this)throw`Source not in this graph mgr!`;if(o==null||o.getGraphManager()!=this)throw`Target not in this graph mgr!`;if(a==o)return n.isInterGraph=!1,a.add(n,r,i);if(n.isInterGraph=!0,n.source=r,n.target=i,this.edges.indexOf(n)>-1)throw`Edge already in inter-graph edge list!`;if(this.edges.push(n),n.source==null||n.target==null)throw`Edge source and/or target is null!`;if(n.source.edges.indexOf(n)!=-1||n.target.edges.indexOf(n)!=-1)throw`Edge already in source and/or target incidency list!`;return n.source.edges.push(n),n.target.edges.push(n),n},a.prototype.remove=function(e){if(e instanceof r){var t=e;if(t.getGraphManager()!=this)throw`Graph not in this graph mgr`;if(!(t==this.rootGraph||t.parent!=null&&t.parent.graphManager==this))throw`Invalid parent node!`;var n=[];n=n.concat(t.getEdges());for(var a,o=n.length,s=0;s=t.getRight()?n[0]+=Math.min(t.getX()-e.getX(),e.getRight()-t.getRight()):t.getX()<=e.getX()&&t.getRight()>=e.getRight()&&(n[0]+=Math.min(e.getX()-t.getX(),t.getRight()-e.getRight())),e.getY()<=t.getY()&&e.getBottom()>=t.getBottom()?n[1]+=Math.min(t.getY()-e.getY(),e.getBottom()-t.getBottom()):t.getY()<=e.getY()&&t.getBottom()>=e.getBottom()&&(n[1]+=Math.min(e.getY()-t.getY(),t.getBottom()-e.getBottom()));var a=Math.abs((t.getCenterY()-e.getCenterY())/(t.getCenterX()-e.getCenterX()));t.getCenterY()===e.getCenterY()&&t.getCenterX()===e.getCenterX()&&(a=1);var o=a*n[0],s=n[1]/a;n[0]o)return n[0]=r,n[1]=c,n[2]=a,n[3]=y,!1;if(ia)return n[0]=s,n[1]=i,n[2]=_,n[3]=o,!1;if(ra?(n[0]=u,n[1]=d,C=!0):(n[0]=l,n[1]=c,C=!0):T===D&&(r>a?(n[0]=s,n[1]=c,C=!0):(n[0]=f,n[1]=d,C=!0)),-E===D?a>r?(n[2]=v,n[3]=y,w=!0):(n[2]=_,n[3]=g,w=!0):E===D&&(a>r?(n[2]=h,n[3]=g,w=!0):(n[2]=b,n[3]=y,w=!0)),C&&w)return!1;if(r>a?i>o?(O=this.getCardinalDirection(T,D,4),k=this.getCardinalDirection(E,D,2)):(O=this.getCardinalDirection(-T,D,3),k=this.getCardinalDirection(-E,D,1)):i>o?(O=this.getCardinalDirection(-T,D,1),k=this.getCardinalDirection(-E,D,3)):(O=this.getCardinalDirection(T,D,2),k=this.getCardinalDirection(E,D,4)),!C)switch(O){case 1:j=c,A=r+-m/D,n[0]=A,n[1]=j;break;case 2:A=f,j=i+p*D,n[0]=A,n[1]=j;break;case 3:j=d,A=r+m/D,n[0]=A,n[1]=j;break;case 4:A=u,j=i+-p*D,n[0]=A,n[1]=j}if(!w)switch(k){case 1:N=g,M=a+-S/D,n[2]=M,n[3]=N;break;case 2:M=b,N=o+x*D,n[2]=M,n[3]=N;break;case 3:N=y,M=a+S/D,n[2]=M,n[3]=N;break;case 4:M=v,N=o+-x*D,n[2]=M,n[3]=N}}return!1},i.getCardinalDirection=function(e,t,n){return e>t?n:1+n%4},i.getIntersection=function(e,t,n,i){if(i==null)return this.getIntersection2(e,t,n);var a=e.x,o=e.y,s=t.x,c=t.y,l=n.x,u=n.y,d=i.x,f=i.y,p=void 0,m=void 0,h=void 0,g=void 0,_=void 0,v=void 0,y=void 0,b=void 0,x=void 0;return h=c-o,_=a-s,y=s*o-a*c,g=f-u,v=l-d,b=d*u-l*f,x=h*v-g*_,x===0?null:(p=(_*b-v*y)/x,m=(g*y-h*b)/x,new r(p,m))},i.angleOfVector=function(e,t,n,r){var i=void 0;return e===n?i=r=0){var u=(-c+Math.sqrt(c*c-4*s*l))/(2*s),d=(-c-Math.sqrt(c*c-4*s*l))/(2*s);return u>=0&&u<=1?[u]:d>=0&&d<=1?[d]:null}return null},i.HALF_PI=.5*Math.PI,i.ONE_AND_HALF_PI=1.5*Math.PI,i.TWO_PI=2*Math.PI,i.THREE_PI=3*Math.PI,e.exports=i}),(function(e,t,n){function r(){}r.sign=function(e){return e>0?1:e<0?-1:0},r.floor=function(e){return e<0?Math.ceil(e):Math.floor(e)},r.ceil=function(e){return e<0?Math.floor(e):Math.ceil(e)},e.exports=r}),(function(e,t,n){function r(){}r.MAX_VALUE=2147483647,r.MIN_VALUE=-2147483648,e.exports=r}),(function(e,t,n){var r=function(){function e(e,t){for(var n=0;n0&&t;){for(s.push(l[0]);s.length>0&&t;){var u=s[0];s.splice(0,1),o.add(u);for(var d=u.getEdges(),a=0;a-1&&l.splice(h,1)}o=new Set,c=new Map}}return e},f.prototype.createDummyNodesForBendpoints=function(e){for(var t=[],n=e.source,r=this.graphManager.calcLowestCommonAncestor(e.source,e.target),i=0;i0){for(var i=this.edgeToDummyNodes.get(n),a=0;a=0&&t.splice(d,1),s.getNeighborsList().forEach(function(e){if(n.indexOf(e)<0){var t=r.get(e)-1;t==1&&l.push(e),r.set(e,t)}})}n=n.concat(l),(t.length==1||t.length==2)&&(i=!0,a=t[0])}return a},f.prototype.setGraphManager=function(e){this.graphManager=e},e.exports=f}),(function(e,t,n){function r(){}r.seed=1,r.x=0,r.nextDouble=function(){return r.x=Math.sin(r.seed++)*1e4,r.x-Math.floor(r.x)},e.exports=r}),(function(e,t,n){var r=n(5);function i(e,t){this.lworldOrgX=0,this.lworldOrgY=0,this.ldeviceOrgX=0,this.ldeviceOrgY=0,this.lworldExtX=1,this.lworldExtY=1,this.ldeviceExtX=1,this.ldeviceExtY=1}i.prototype.getWorldOrgX=function(){return this.lworldOrgX},i.prototype.setWorldOrgX=function(e){this.lworldOrgX=e},i.prototype.getWorldOrgY=function(){return this.lworldOrgY},i.prototype.setWorldOrgY=function(e){this.lworldOrgY=e},i.prototype.getWorldExtX=function(){return this.lworldExtX},i.prototype.setWorldExtX=function(e){this.lworldExtX=e},i.prototype.getWorldExtY=function(){return this.lworldExtY},i.prototype.setWorldExtY=function(e){this.lworldExtY=e},i.prototype.getDeviceOrgX=function(){return this.ldeviceOrgX},i.prototype.setDeviceOrgX=function(e){this.ldeviceOrgX=e},i.prototype.getDeviceOrgY=function(){return this.ldeviceOrgY},i.prototype.setDeviceOrgY=function(e){this.ldeviceOrgY=e},i.prototype.getDeviceExtX=function(){return this.ldeviceExtX},i.prototype.setDeviceExtX=function(e){this.ldeviceExtX=e},i.prototype.getDeviceExtY=function(){return this.ldeviceExtY},i.prototype.setDeviceExtY=function(e){this.ldeviceExtY=e},i.prototype.transformX=function(e){var t=0,n=this.lworldExtX;return n!=0&&(t=this.ldeviceOrgX+(e-this.lworldOrgX)*this.ldeviceExtX/n),t},i.prototype.transformY=function(e){var t=0,n=this.lworldExtY;return n!=0&&(t=this.ldeviceOrgY+(e-this.lworldOrgY)*this.ldeviceExtY/n),t},i.prototype.inverseTransformX=function(e){var t=0,n=this.ldeviceExtX;return n!=0&&(t=this.lworldOrgX+(e-this.ldeviceOrgX)*this.lworldExtX/n),t},i.prototype.inverseTransformY=function(e){var t=0,n=this.ldeviceExtY;return n!=0&&(t=this.lworldOrgY+(e-this.ldeviceOrgY)*this.lworldExtY/n),t},i.prototype.inverseTransformPoint=function(e){return new r(this.inverseTransformX(e.x),this.inverseTransformY(e.y))},e.exports=i}),(function(e,t,n){function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);ta.ADAPTATION_LOWER_NODE_LIMIT&&(this.coolingFactor=Math.max(this.coolingFactor*a.COOLING_ADAPTATION_FACTOR,this.coolingFactor-(e-a.ADAPTATION_LOWER_NODE_LIMIT)/(a.ADAPTATION_UPPER_NODE_LIMIT-a.ADAPTATION_LOWER_NODE_LIMIT)*this.coolingFactor*(1-a.COOLING_ADAPTATION_FACTOR))),this.maxNodeDisplacement=a.MAX_NODE_DISPLACEMENT_INCREMENTAL):(this.coolingFactor=e>a.ADAPTATION_LOWER_NODE_LIMIT?Math.max(a.COOLING_ADAPTATION_FACTOR,1-(e-a.ADAPTATION_LOWER_NODE_LIMIT)/(a.ADAPTATION_UPPER_NODE_LIMIT-a.ADAPTATION_LOWER_NODE_LIMIT)*(1-a.COOLING_ADAPTATION_FACTOR)):1,this.initialCoolingFactor=this.coolingFactor,this.maxNodeDisplacement=a.MAX_NODE_DISPLACEMENT),this.maxIterations=Math.max(this.getAllNodes().length*5,this.maxIterations),this.displacementThresholdPerNode=3*a.DEFAULT_EDGE_LENGTH/100,this.totalDisplacementThreshold=this.displacementThresholdPerNode*this.getAllNodes().length,this.repulsionRange=this.calcRepulsionRange()},l.prototype.calcSpringForces=function(){for(var e=this.getAllEdges(),t,n=0;n0&&arguments[0]!==void 0?arguments[0]:!0,t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n,r,i,o,s=this.getAllNodes(),c;if(this.useFRGridVariant)for(this.totalIterations%a.GRID_CALCULATION_CHECK_PERIOD==1&&e&&this.updateGrid(),c=new Set,n=0;nc||s>c)&&(e.gravitationForceX=-this.gravityConstant*i,e.gravitationForceY=-this.gravityConstant*a)):(c=t.getEstimatedSize()*this.compoundGravityRangeFactor,(o>c||s>c)&&(e.gravitationForceX=-this.gravityConstant*i*this.compoundGravityConstant,e.gravitationForceY=-this.gravityConstant*a*this.compoundGravityConstant))},l.prototype.isConverged=function(){var e,t=!1;return this.totalIterations>this.maxIterations/3&&(t=Math.abs(this.totalDisplacement-this.oldTotalDisplacement)<2),e=this.totalDisplacement=c.length||u>=c[0].length)){for(var d=0;de}}]),e}()}),(function(e,t,n){function r(){}r.svd=function(e){this.U=null,this.V=null,this.s=null,this.m=0,this.n=0,this.m=e.length,this.n=e[0].length;var t=Math.min(this.m,this.n);this.s=function(e){for(var t=[];e-->0;)t.push(0);return t}(Math.min(this.m+1,this.n)),this.U=function(e){return function e(t){if(t.length==0)return 0;for(var n=[],r=0;r0;)t.push(0);return t}(this.n),i=function(e){for(var t=[];e-->0;)t.push(0);return t}(this.m),a=!0,o=!0,s=Math.min(this.m-1,this.n),c=Math.max(0,Math.min(this.n-2,this.m)),l=0;l=0;k--)if(this.s[k]!==0){for(var A=k+1;A=0;L--){if(function(e,t){return e&&t}(L0;){var U=void 0,W=void 0;for(U=E-2;U>=-1&&U!==-1;U--)if(Math.abs(n[U])<=re+ne*(Math.abs(this.s[U])+Math.abs(this.s[U+1]))){n[U]=0;break}if(U===E-2)W=4;else{var G=void 0;for(G=E-1;G>=U&&G!==U;G--){var ie=(G===E?0:Math.abs(n[G]))+(G===U+1?0:Math.abs(n[G-1]));if(Math.abs(this.s[G])<=re+ne*ie){this.s[G]=0;break}}G===U?W=3:G===E-1?W=1:(W=2,U=G)}switch(U++,W){case 1:var K=n[E-2];n[E-2]=0;for(var q=E-2;q>=U;q--){var ae=r.hypot(this.s[q],K),J=this.s[q]/ae,Y=K/ae;if(this.s[q]=ae,q!==U&&(K=-Y*n[q-1],n[q-1]=J*n[q-1]),o)for(var X=0;X=this.s[U+1]);){var De=this.s[U];if(this.s[U]=this.s[U+1],this.s[U+1]=De,o&&UMath.abs(t)?(n=t/e,n=Math.abs(e)*Math.sqrt(1+n*n)):t==0?n=0:(n=e/t,n=Math.abs(t)*Math.sqrt(1+n*n)),n},e.exports=r}),(function(e,t,n){var r=function(){function e(e,t){for(var n=0;n2&&arguments[2]!==void 0?arguments[2]:1,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:-1;i(this,e),this.sequence1=t,this.sequence2=n,this.match_score=r,this.mismatch_penalty=a,this.gap_penalty=o,this.iMax=t.length+1,this.jMax=n.length+1,this.grid=Array(this.iMax);for(var s=0;s=0;n--){var r=this.listeners[n];r.event===e&&r.callback===t&&this.listeners.splice(n,1)}},i.emit=function(e,t){for(var n=0;n{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(D()):typeof define==`function`&&define.amd?define([`layout-base`],r):typeof e==`object`?e.coseBase=r(D()):n.coseBase=r(n.layoutBase)})(e,function(e){return(()=>{var t={45:((e,t,n)=>{var r={};r.layoutBase=n(551),r.CoSEConstants=n(806),r.CoSEEdge=n(767),r.CoSEGraph=n(880),r.CoSEGraphManager=n(578),r.CoSELayout=n(765),r.CoSENode=n(991),r.ConstraintHandler=n(902),e.exports=r}),806:((e,t,n)=>{var r=n(551).FDLayoutConstants;function i(){}for(var a in r)i[a]=r[a];i.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,i.DEFAULT_RADIAL_SEPARATION=r.DEFAULT_EDGE_LENGTH,i.DEFAULT_COMPONENT_SEPERATION=60,i.TILE=!0,i.TILING_PADDING_VERTICAL=10,i.TILING_PADDING_HORIZONTAL=10,i.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,i.ENFORCE_CONSTRAINTS=!0,i.APPLY_LAYOUT=!0,i.RELAX_MOVEMENT_ON_CONSTRAINTS=!0,i.TREE_REDUCTION_ON_INCREMENTAL=!0,i.PURE_INCREMENTAL=i.DEFAULT_INCREMENTAL,e.exports=i}),767:((e,t,n)=>{var r=n(551).FDLayoutEdge;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),880:((e,t,n)=>{var r=n(551).LGraph;function i(e,t,n){r.call(this,e,t,n)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),578:((e,t,n)=>{var r=n(551).LGraphManager;function i(e){r.call(this,e)}for(var a in i.prototype=Object.create(r.prototype),r)i[a]=r[a];e.exports=i}),765:((e,t,n)=>{var r=n(551).FDLayout,i=n(578),a=n(880),o=n(991),s=n(767),c=n(806),l=n(902),u=n(551).FDLayoutConstants,d=n(551).LayoutConstants,f=n(551).Point,p=n(551).PointD,m=n(551).DimensionD,h=n(551).Layout,g=n(551).Integer,_=n(551).IGeometry,v=n(551).LGraph,y=n(551).Transform,b=n(551).LinkedList;function x(){r.call(this),this.toBeTiled={},this.constraints={}}for(var S in x.prototype=Object.create(r.prototype),r)x[S]=r[S];x.prototype.newGraphManager=function(){var e=new i(this);return this.graphManager=e,e},x.prototype.newGraph=function(e){return new a(null,this.graphManager,e)},x.prototype.newNode=function(e){return new o(this.graphManager,e)},x.prototype.newEdge=function(e){return new s(null,null,e)},x.prototype.initParameters=function(){r.prototype.initParameters.call(this,arguments),this.isSubLayout||(this.idealEdgeLength=c.DEFAULT_EDGE_LENGTH<10?10:c.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=c.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.gravityConstant=u.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=u.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=u.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1)},x.prototype.initSpringEmbedder=function(){r.prototype.initSpringEmbedder.call(this),this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/u.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=.04,this.coolingAdjuster=1},x.prototype.layout=function(){return d.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},x.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),!this.incremental){var e=this.getFlatForest();if(e.length>0)this.positionNodesRadially(e);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n),this.positionNodesRandomly()}}else if(c.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),n=this.nodesWithGravity.filter(function(e){return t.has(e)});this.graphManager.setAllNodesToApplyGravitation(n)}return Object.keys(this.constraints).length>0&&(l.handleConstraints(this),this.initConstraintVariables()),this.initSpringEmbedder(),c.APPLY_LAYOUT&&this.runSpringEmbedder(),!0},x.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0}if(this.totalIterations%u.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0}this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-this.coolingCycle**+(Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0){if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),t=this.nodesWithGravity.filter(function(t){return e.has(t)});this.graphManager.setAllNodesToApplyGravitation(t),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=c.PURE_INCREMENTAL?u.DEFAULT_COOLING_FACTOR_INCREMENTAL/2:u.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0}this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=c.PURE_INCREMENTAL?u.DEFAULT_COOLING_FACTOR_INCREMENTAL/2*((100-this.afterGrowthIterations)/100):u.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var n=!this.isTreeGrowing&&!this.isGrowthFinished,r=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(n,r),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},x.prototype.getPositionsData=function(){for(var e=this.graphManager.getAllNodes(),t={},n=0;n0&&this.updateDisplacements();for(var n=0;n0&&(r.fixedNodeWeight=a)}}if(this.constraints.relativePlacementConstraint){var o=new Map,s=new Map;if(this.dummyToNodeForVerticalAlignment=new Map,this.dummyToNodeForHorizontalAlignment=new Map,this.fixedNodesOnHorizontal=new Set,this.fixedNodesOnVertical=new Set,this.fixedNodeSet.forEach(function(t){e.fixedNodesOnHorizontal.add(t),e.fixedNodesOnVertical.add(t)}),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var l=this.constraints.alignmentConstraint.vertical,n=0;n=2*e.length/3;r--)t=Math.floor(Math.random()*(r+1)),n=e[r],e[r]=e[t],e[t]=n;return e},this.nodesInRelativeHorizontal=[],this.nodesInRelativeVertical=[],this.nodeToRelativeConstraintMapHorizontal=new Map,this.nodeToRelativeConstraintMapVertical=new Map,this.nodeToTempPositionMapHorizontal=new Map,this.nodeToTempPositionMapVertical=new Map,this.constraints.relativePlacementConstraint.forEach(function(t){if(t.left){var n=o.has(t.left)?o.get(t.left):t.left,r=o.has(t.right)?o.get(t.right):t.right;e.nodesInRelativeHorizontal.includes(n)||(e.nodesInRelativeHorizontal.push(n),e.nodeToRelativeConstraintMapHorizontal.set(n,[]),e.dummyToNodeForVerticalAlignment.has(n)?e.nodeToTempPositionMapHorizontal.set(n,e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(n)[0]).getCenterX()):e.nodeToTempPositionMapHorizontal.set(n,e.idToNodeMap.get(n).getCenterX())),e.nodesInRelativeHorizontal.includes(r)||(e.nodesInRelativeHorizontal.push(r),e.nodeToRelativeConstraintMapHorizontal.set(r,[]),e.dummyToNodeForVerticalAlignment.has(r)?e.nodeToTempPositionMapHorizontal.set(r,e.idToNodeMap.get(e.dummyToNodeForVerticalAlignment.get(r)[0]).getCenterX()):e.nodeToTempPositionMapHorizontal.set(r,e.idToNodeMap.get(r).getCenterX())),e.nodeToRelativeConstraintMapHorizontal.get(n).push({right:r,gap:t.gap}),e.nodeToRelativeConstraintMapHorizontal.get(r).push({left:n,gap:t.gap})}else{var i=s.has(t.top)?s.get(t.top):t.top,a=s.has(t.bottom)?s.get(t.bottom):t.bottom;e.nodesInRelativeVertical.includes(i)||(e.nodesInRelativeVertical.push(i),e.nodeToRelativeConstraintMapVertical.set(i,[]),e.dummyToNodeForHorizontalAlignment.has(i)?e.nodeToTempPositionMapVertical.set(i,e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(i)[0]).getCenterY()):e.nodeToTempPositionMapVertical.set(i,e.idToNodeMap.get(i).getCenterY())),e.nodesInRelativeVertical.includes(a)||(e.nodesInRelativeVertical.push(a),e.nodeToRelativeConstraintMapVertical.set(a,[]),e.dummyToNodeForHorizontalAlignment.has(a)?e.nodeToTempPositionMapVertical.set(a,e.idToNodeMap.get(e.dummyToNodeForHorizontalAlignment.get(a)[0]).getCenterY()):e.nodeToTempPositionMapVertical.set(a,e.idToNodeMap.get(a).getCenterY())),e.nodeToRelativeConstraintMapVertical.get(i).push({bottom:a,gap:t.gap}),e.nodeToRelativeConstraintMapVertical.get(a).push({top:i,gap:t.gap})}});else{var d=new Map,f=new Map;this.constraints.relativePlacementConstraint.forEach(function(e){if(e.left){var t=o.has(e.left)?o.get(e.left):e.left,n=o.has(e.right)?o.get(e.right):e.right;d.has(t)?d.get(t).push(n):d.set(t,[n]),d.has(n)?d.get(n).push(t):d.set(n,[t])}else{var r=s.has(e.top)?s.get(e.top):e.top,i=s.has(e.bottom)?s.get(e.bottom):e.bottom;f.has(r)?f.get(r).push(i):f.set(r,[i]),f.has(i)?f.get(i).push(r):f.set(i,[r])}});var p=function(e,t){var n=[],r=[],i=new b,a=new Set,o=0;return e.forEach(function(s,c){if(!a.has(c)){n[o]=[],r[o]=!1;var l=c;for(i.push(l),a.add(l),n[o].push(l);i.length!=0;)l=i.shift(),t.has(l)&&(r[o]=!0),e.get(l).forEach(function(e){a.has(e)||(i.push(e),a.add(e),n[o].push(e))});o++}}),{components:n,isFixed:r}},m=p(d,e.fixedNodesOnHorizontal);this.componentsOnHorizontal=m.components,this.fixedComponentsOnHorizontal=m.isFixed;var h=p(f,e.fixedNodesOnVertical);this.componentsOnVertical=h.components,this.fixedComponentsOnVertical=h.isFixed}}},x.prototype.updateDisplacements=function(){var e=this;if(this.constraints.fixedNodeConstraint&&this.constraints.fixedNodeConstraint.forEach(function(t){var n=e.idToNodeMap.get(t.nodeId);n.displacementX=0,n.displacementY=0}),this.constraints.alignmentConstraint){if(this.constraints.alignmentConstraint.vertical)for(var t=this.constraints.alignmentConstraint.vertical,n=0;n1)for(var s=0;sr&&(r=Math.floor(o.y)),a=Math.floor(o.x+c.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(d.WORLD_CENTER_X-o.x/2,d.WORLD_CENTER_Y-o.y/2))},x.radialLayout=function(e,t,n){var r=Math.max(this.maxDiagonalInTree(e),c.DEFAULT_RADIAL_SEPARATION);x.branchRadialLayout(t,null,0,359,0,r);var i=v.calculateBounds(e),a=new y;a.setDeviceOrgX(i.getMinX()),a.setDeviceOrgY(i.getMinY()),a.setWorldOrgX(n.x),a.setWorldOrgY(n.y);for(var o=0;o1;){var g=h[0];h.splice(0,1);var v=u.indexOf(g);v>=0&&u.splice(v,1),p--,d--}m=t==null?0:(u.indexOf(h[0])+1)%p;for(var y=Math.abs(r-n)/d,b=m;f!=d;b=++b%p){var S=u[b].getOtherEnd(e);if(S!=t){var C=(n+f*y)%360,w=(C+y)%360;x.branchRadialLayout(S,e,C,w,i+a,a),f++}}},x.maxDiagonalInTree=function(e){for(var t=g.MIN_VALUE,n=0;nt&&(t=r)}return t},x.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},x.prototype.groupZeroDegreeMembers=function(){var e=this,t={};this.memberGroups={},this.idToDummyNode={};for(var n=[],r=this.graphManager.getAllNodes(),i=0;i1){var r=`DummyCompound_`+n;e.memberGroups[r]=t[n];var i=t[n][0].getParent(),a=new o(e.graphManager);a.id=r,a.paddingLeft=i.paddingLeft||0,a.paddingRight=i.paddingRight||0,a.paddingBottom=i.paddingBottom||0,a.paddingTop=i.paddingTop||0,e.idToDummyNode[r]=a;var s=e.getGraphManager().add(e.newGraph(),a),c=i.getChild();c.add(a);for(var l=0;li?(r.rect.x-=(r.labelWidth-i)/2,r.setWidth(r.labelWidth),r.labelMarginLeft=(r.labelWidth-i)/2):r.labelPosHorizontal==`right`&&r.setWidth(i+r.labelWidth)),r.labelHeight&&(r.labelPosVertical==`top`?(r.rect.y-=r.labelHeight,r.setHeight(a+r.labelHeight),r.labelMarginTop=r.labelHeight):r.labelPosVertical==`center`&&r.labelHeight>a?(r.rect.y-=(r.labelHeight-a)/2,r.setHeight(r.labelHeight),r.labelMarginTop=(r.labelHeight-a)/2):r.labelPosVertical==`bottom`&&r.setHeight(a+r.labelHeight))}})},x.prototype.repopulateCompounds=function(){for(var e=this.compoundOrder.length-1;e>=0;e--){var t=this.compoundOrder[e],n=t.id,r=t.paddingLeft,i=t.paddingTop,a=t.labelMarginLeft,o=t.labelMarginTop;this.adjustLocations(this.tiledMemberPack[n],t.rect.x,t.rect.y,r,i,a,o)}},x.prototype.repopulateZeroDegreeMembers=function(){var e=this,t=this.tiledZeroDegreePack;Object.keys(t).forEach(function(n){var r=e.idToDummyNode[n],i=r.paddingLeft,a=r.paddingTop,o=r.labelMarginLeft,s=r.labelMarginTop;e.adjustLocations(t[n],r.rect.x,r.rect.y,i,a,o,s)})},x.prototype.getToBeTiled=function(e){var t=e.id;if(this.toBeTiled[t]!=null)return this.toBeTiled[t];var n=e.getChild();if(n==null)return this.toBeTiled[t]=!1,!1;for(var r=n.getNodes(),i=0;i0)return this.toBeTiled[t]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[t]=!1,!1}return this.toBeTiled[t]=!0,!0},x.prototype.getNodeDegree=function(e){e.id;for(var t=e.getEdges(),n=0,r=0;ru&&(u=f.rect.height)}n+=u+e.verticalPadding}},x.prototype.tileCompoundMembers=function(e,t){var n=this;this.tiledMemberPack=[],Object.keys(e).forEach(function(r){var i=t[r];if(n.tiledMemberPack[r]=n.tileNodes(e[r],i.paddingLeft+i.paddingRight),i.rect.width=n.tiledMemberPack[r].width,i.rect.height=n.tiledMemberPack[r].height,i.setCenter(n.tiledMemberPack[r].centerX,n.tiledMemberPack[r].centerY),i.labelMarginLeft=0,i.labelMarginTop=0,c.NODE_DIMENSIONS_INCLUDE_LABELS){var a=i.rect.width,o=i.rect.height;i.labelWidth&&(i.labelPosHorizontal==`left`?(i.rect.x-=i.labelWidth,i.setWidth(a+i.labelWidth),i.labelMarginLeft=i.labelWidth):i.labelPosHorizontal==`center`&&i.labelWidth>a?(i.rect.x-=(i.labelWidth-a)/2,i.setWidth(i.labelWidth),i.labelMarginLeft=(i.labelWidth-a)/2):i.labelPosHorizontal==`right`&&i.setWidth(a+i.labelWidth)),i.labelHeight&&(i.labelPosVertical==`top`?(i.rect.y-=i.labelHeight,i.setHeight(o+i.labelHeight),i.labelMarginTop=i.labelHeight):i.labelPosVertical==`center`&&i.labelHeight>o?(i.rect.y-=(i.labelHeight-o)/2,i.setHeight(i.labelHeight),i.labelMarginTop=(i.labelHeight-o)/2):i.labelPosVertical==`bottom`&&i.setHeight(o+i.labelHeight))}})},x.prototype.tileNodes=function(e,t){var n=this.tileNodesByFavoringDim(e,t,!0),r=this.tileNodesByFavoringDim(e,t,!1),i=this.getOrgRatio(n);return this.getOrgRatio(r)s&&(s=e.getWidth())});var l=a/i,u=o/i,d=(n-r)**2+4*(l+r)*(u+n)*i,f=(r-n+Math.sqrt(d))/(2*(l+r)),p;t?(p=Math.ceil(f),p==f&&p++):p=Math.floor(f);var m=p*(l+r)-r;return s>m&&(m=s),m+=r*2,m},x.prototype.tileNodesByFavoringDim=function(e,t,n){var r=c.TILING_PADDING_VERTICAL,i=c.TILING_PADDING_HORIZONTAL,a=c.TILING_COMPARE_BY,o={rows:[],rowWidth:[],rowHeight:[],width:0,height:t,verticalPadding:r,horizontalPadding:i,centerX:0,centerY:0};a&&(o.idealRowWidth=this.calcIdealRowWidth(e,n));var s=function(e){return e.rect.width*e.rect.height},l=function(e,t){return s(t)-s(e)};e.sort(function(e,t){var n=l;return o.idealRowWidth?(n=a,n(e.id,t.id)):n(e,t)});for(var u=0,d=0,f=0;f0&&(a+=e.horizontalPadding),e.rowWidth[n]=a,e.width0&&(o+=e.verticalPadding);var s=0;o>e.rowHeight[n]&&(s=e.rowHeight[n],e.rowHeight[n]=o,s=e.rowHeight[n]-s),e.height+=s,e.rows[n].push(t)},x.prototype.getShortestRowIndex=function(e){for(var t=-1,n=Number.MAX_VALUE,r=0;rn&&(t=r,n=e.rowWidth[r]);return t},x.prototype.canAddHorizontal=function(e,t,n){if(e.idealRowWidth){var r=e.rows.length-1;return e.rowWidth[r]+t+e.horizontalPadding<=e.idealRowWidth}var i=this.getShortestRowIndex(e);if(i<0)return!0;var a=e.rowWidth[i];if(a+e.horizontalPadding+t<=e.width)return!0;var o=0;e.rowHeight[i]0&&(o=n+e.verticalPadding-e.rowHeight[i]);var s=e.width-a>=t+e.horizontalPadding?(e.height+o)/(a+t+e.horizontalPadding):(e.height+o)/e.width;o=n+e.verticalPadding;var c=e.widtha&&t!=n){r.splice(-1,1),e.rows[n].push(i),e.rowWidth[t]=e.rowWidth[t]-a,e.rowWidth[n]=e.rowWidth[n]+a,e.width=e.rowWidth[instance.getLongestRowIndex(e)];for(var o=Number.MIN_VALUE,s=0;so&&(o=r[s].height);t>0&&(o+=e.verticalPadding);var c=e.rowHeight[t]+e.rowHeight[n];e.rowHeight[t]=o,e.rowHeight[n]0)for(var d=i;d<=a;d++)l[0]+=this.grid[d][o-1].length+this.grid[d][o].length-1;if(a0)for(var d=o;d<=s;d++)l[3]+=this.grid[i-1][d].length+this.grid[i][d].length-1;for(var f=g.MAX_VALUE,p,m,h=0;h{var r=n(551).FDLayoutNode,i=n(551).IMath;function a(e,t,n,i){r.call(this,e,t,n,i)}for(var o in a.prototype=Object.create(r.prototype),r)a[o]=r[o];a.prototype.calculateDisplacement=function(){var e=this.graphManager.getLayout();this.getChild()!=null&&this.fixedNodeWeight?(this.displacementX+=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.fixedNodeWeight,this.displacementY+=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.fixedNodeWeight):(this.displacementX+=e.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY+=e.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren),Math.abs(this.displacementX)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementX=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementX)),Math.abs(this.displacementY)>e.coolingFactor*e.maxNodeDisplacement&&(this.displacementY=e.coolingFactor*e.maxNodeDisplacement*i.sign(this.displacementY)),this.child&&this.child.getNodes().length>0&&this.propogateDisplacementToChildren(this.displacementX,this.displacementY)},a.prototype.propogateDisplacementToChildren=function(e,t){for(var n=this.getChild().getNodes(),r,i=0;i{function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0){var a=0;r.forEach(function(e){t==`horizontal`?(f.set(e,c.has(e)?l[c.get(e)]:i.get(e)),a+=f.get(e)):(f.set(e,c.has(e)?u[c.get(e)]:i.get(e)),a+=f.get(e))}),a/=r.length,e.forEach(function(e){n.has(e)||f.set(e,a)})}else{var o=0;e.forEach(function(e){o+=t==`horizontal`?c.has(e)?l[c.get(e)]:i.get(e):c.has(e)?u[c.get(e)]:i.get(e)}),o/=e.length,e.forEach(function(e){f.set(e,o)})}});for(var h=function(){var r=m.shift();e.get(r).forEach(function(e){if(f.get(e.id)o&&(o=v),ys&&(s=y)}}catch(e){p=!0,m=e}finally{try{!d&&h.return&&h.return()}finally{if(p)throw m}}var b=(r+o)/2-(a+s)/2,x=!0,S=!1,C=void 0;try{for(var w=e[Symbol.iterator](),T;!(x=(T=w.next()).done);x=!0){var E=T.value;f.set(E,f.get(E)+b)}}catch(e){S=!0,C=e}finally{try{!x&&w.return&&w.return()}finally{if(S)throw C}}})}return f},v=function(e){var t=0,n=0,r=0,i=0;if(e.forEach(function(e){e.left?l[c.get(e.left)]-l[c.get(e.right)]>=0?t++:n++:u[c.get(e.top)]-u[c.get(e.bottom)]>=0?r++:i++}),t>n&&r>i)for(var a=0;an)for(var o=0;oi)for(var s=0;s1)t.fixedNodeConstraint.forEach(function(e,t){S[t]=[e.position.x,e.position.y],C[t]=[l[c.get(e.nodeId)],u[c.get(e.nodeId)]]}),w=!0;else if(t.alignmentConstraint)(function(){var e=0;if(t.alignmentConstraint.vertical){for(var n=t.alignmentConstraint.vertical,i=function(t){var i=new Set;n[t].forEach(function(e){i.add(e)});var a=new Set([].concat(r(i)).filter(function(e){return E.has(e)})),o=void 0;o=a.size>0?l[c.get(a.values().next().value)]:g(i).x,n[t].forEach(function(t){S[e]=[o,u[c.get(t)]],C[e]=[l[c.get(t)],u[c.get(t)]],e++})},a=0;a0?l[c.get(i.values().next().value)]:g(n).y,o[t].forEach(function(t){S[e]=[l[c.get(t)],a],C[e]=[l[c.get(t)],u[c.get(t)]],e++})},d=0;dA&&(A=k[M].length,j=M);if(A0){var W={x:0,y:0};t.fixedNodeConstraint.forEach(function(e,t){var n={x:l[c.get(e.nodeId)],y:u[c.get(e.nodeId)]},r=e.position,i=h(r,n);W.x+=i.x,W.y+=i.y}),W.x/=t.fixedNodeConstraint.length,W.y/=t.fixedNodeConstraint.length,l.forEach(function(e,t){l[t]+=W.x}),u.forEach(function(e,t){u[t]+=W.y}),t.fixedNodeConstraint.forEach(function(e){l[c.get(e.nodeId)]=e.position.x,u[c.get(e.nodeId)]=e.position.y})}if(t.alignmentConstraint){if(t.alignmentConstraint.vertical)for(var G=t.alignmentConstraint.vertical,ie=function(e){var t=new Set;G[e].forEach(function(e){t.add(e)});var n=new Set([].concat(r(t)).filter(function(e){return E.has(e)})),i=void 0;i=n.size>0?l[c.get(n.values().next().value)]:g(t).x,t.forEach(function(e){E.has(e)||(l[c.get(e)]=i)})},K=0;K0?u[c.get(n.values().next().value)]:g(t).y,t.forEach(function(e){E.has(e)||(u[c.get(e)]=i)})},J=0;J{t.exports=e})},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}return r(45)})()})})),k=e(t(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r(O()):typeof define==`function`&&define.amd?define([`cose-base`],r):typeof e==`object`?e.cytoscapeFcose=r(O()):n.cytoscapeFcose=r(n.coseBase)})(e,function(e){return(()=>{var t={658:(e=>{e.exports=Object.assign==null?function(e){return[...arguments].slice(1).forEach(function(t){Object.keys(t).forEach(function(n){return e[n]=t[n]})}),e}:Object.assign.bind(Object)}),548:((e,t,n)=>{var r=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o=e[Symbol.iterator](),s;!(r=(s=o.next()).done)&&(n.push(s.value),!(t&&n.length===t));r=!0);}catch(e){i=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw TypeError(`Invalid attempt to destructure non-iterable instance`)}}(),i=n(140).layoutBase.LinkedList,a={};a.getTopMostNodes=function(e){for(var t={},n=0;n0&&l.merge(e)});for(var u=0;u1){l=s[0],u=l.connectedEdges().length,s.forEach(function(e){e.connectedEdges().length0&&r.set(`dummy`+(r.size+1),p),m},a.relocateComponent=function(e,t,n){if(!n.fixedNodeConstraint){var i=1/0,a=-1/0,o=1/0,s=-1/0;if(n.quality==`draft`){var c=!0,l=!1,u=void 0;try{for(var d=t.nodeIndexes[Symbol.iterator](),f;!(c=(f=d.next()).done);c=!0){var p=f.value,m=r(p,2),h=m[0],g=m[1],_=n.cy.getElementById(h);if(_){var v=_.boundingBox(),y=t.xCoords[g]-v.w/2,b=t.xCoords[g]+v.w/2,x=t.yCoords[g]-v.h/2,S=t.yCoords[g]+v.h/2;ya&&(a=b),xs&&(s=S)}}}catch(e){l=!0,u=e}finally{try{!c&&d.return&&d.return()}finally{if(l)throw u}}var C=e.x-(a+i)/2,w=e.y-(s+o)/2;t.xCoords=t.xCoords.map(function(e){return e+C}),t.yCoords=t.yCoords.map(function(e){return e+w})}else{Object.keys(t).forEach(function(e){var n=t[e],r=n.getRect().x,c=n.getRect().x+n.getRect().width,l=n.getRect().y,u=n.getRect().y+n.getRect().height;ra&&(a=c),ls&&(s=u)});var T=e.x-(a+i)/2,E=e.y-(s+o)/2;Object.keys(t).forEach(function(e){var n=t[e];n.setCenter(n.getCenterX()+T,n.getCenterY()+E)})}}},a.calcBoundingBox=function(e,t,n,r){for(var i=2**53-1,a=-(2**53-1),o=2**53-1,s=-(2**53-1),c=void 0,l=void 0,u=void 0,d=void 0,f=e.descendants().not(`:parent`),p=f.length,m=0;mc&&(i=c),au&&(o=u),s{var r=n(548),i=n(140).CoSELayout,a=n(140).CoSENode,o=n(140).layoutBase.PointD,s=n(140).layoutBase.DimensionD,c=n(140).layoutBase.LayoutConstants,l=n(140).layoutBase.FDLayoutConstants,u=n(140).CoSEConstants;e.exports={coseLayout:function(e,t){var n=e.cy,d=e.eles,f=d.nodes(),p=d.edges(),m=void 0,h=void 0,g=void 0,_={};e.randomize&&(m=t.nodeIndexes,h=t.xCoords,g=t.yCoords);var v=function(e){return typeof e==`function`},y=function(e,t){return v(e)?e(t):e},b=r.calcParentsWithoutChildren(n,d),x=function e(t,n,i,c){for(var l=n.length,u=0;u0){var S=void 0;S=i.getGraphManager().add(i.newGraph(),p),e(S,f,i,c)}}},S=function(t,n,r){for(var i=0,a=0,o=0;o0?i/a:v(e.idealEdgeLength)?50:e.idealEdgeLength,u.MIN_REPULSION_DIST=l.MIN_REPULSION_DIST=l.DEFAULT_EDGE_LENGTH/10,u.DEFAULT_RADIAL_SEPARATION=l.DEFAULT_EDGE_LENGTH)},C=function(e,t){t.fixedNodeConstraint&&(e.constraints.fixedNodeConstraint=t.fixedNodeConstraint),t.alignmentConstraint&&(e.constraints.alignmentConstraint=t.alignmentConstraint),t.relativePlacementConstraint&&(e.constraints.relativePlacementConstraint=t.relativePlacementConstraint)};e.nestingFactor!=null&&(u.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=l.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=e.nestingFactor),e.gravity!=null&&(u.DEFAULT_GRAVITY_STRENGTH=l.DEFAULT_GRAVITY_STRENGTH=e.gravity),e.numIter!=null&&(u.MAX_ITERATIONS=l.MAX_ITERATIONS=e.numIter),e.gravityRange!=null&&(u.DEFAULT_GRAVITY_RANGE_FACTOR=l.DEFAULT_GRAVITY_RANGE_FACTOR=e.gravityRange),e.gravityCompound!=null&&(u.DEFAULT_COMPOUND_GRAVITY_STRENGTH=l.DEFAULT_COMPOUND_GRAVITY_STRENGTH=e.gravityCompound),e.gravityRangeCompound!=null&&(u.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=l.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=e.gravityRangeCompound),e.initialEnergyOnIncremental!=null&&(u.DEFAULT_COOLING_FACTOR_INCREMENTAL=l.DEFAULT_COOLING_FACTOR_INCREMENTAL=e.initialEnergyOnIncremental),e.tilingCompareBy!=null&&(u.TILING_COMPARE_BY=e.tilingCompareBy),c.QUALITY=e.quality==`proof`?2:0,u.NODE_DIMENSIONS_INCLUDE_LABELS=l.NODE_DIMENSIONS_INCLUDE_LABELS=c.NODE_DIMENSIONS_INCLUDE_LABELS=e.nodeDimensionsIncludeLabels,u.DEFAULT_INCREMENTAL=l.DEFAULT_INCREMENTAL=c.DEFAULT_INCREMENTAL=!e.randomize,u.ANIMATE=l.ANIMATE=c.ANIMATE=e.animate,u.TILE=e.tile,u.TILING_PADDING_VERTICAL=typeof e.tilingPaddingVertical==`function`?e.tilingPaddingVertical.call():e.tilingPaddingVertical,u.TILING_PADDING_HORIZONTAL=typeof e.tilingPaddingHorizontal==`function`?e.tilingPaddingHorizontal.call():e.tilingPaddingHorizontal,u.DEFAULT_INCREMENTAL=l.DEFAULT_INCREMENTAL=c.DEFAULT_INCREMENTAL=!0,u.PURE_INCREMENTAL=!e.randomize,c.DEFAULT_UNIFORM_LEAF_NODE_SIZES=e.uniformNodeDimensions,e.step==`transformed`&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!0,u.ENFORCE_CONSTRAINTS=!1,u.APPLY_LAYOUT=!1),e.step==`enforced`&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,u.ENFORCE_CONSTRAINTS=!0,u.APPLY_LAYOUT=!1),e.step==`cose`&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!1,u.ENFORCE_CONSTRAINTS=!1,u.APPLY_LAYOUT=!0),e.step==`all`&&(u.TRANSFORM_ON_CONSTRAINT_HANDLING=!!e.randomize,u.ENFORCE_CONSTRAINTS=!0,u.APPLY_LAYOUT=!0),u.TREE_REDUCTION_ON_INCREMENTAL=!(e.fixedNodeConstraint||e.alignmentConstraint||e.relativePlacementConstraint);var w=new i,T=w.newGraphManager();return x(T.addRoot(),r.getTopMostNodes(f),w,e),S(w,T,p),C(w,e),w.runLayout(),_}}}),212:((e,t,n)=>{var r=function(){function e(e,t){for(var n=0;n0){if(f){var p=o.getTopMostNodes(t.eles.nodes());if(l=o.connectComponents(n,t.eles,p),l.forEach(function(e){var t=e.boundingBox();u.push({x:t.x1+t.w/2,y:t.y1+t.h/2})}),t.randomize&&l.forEach(function(e){t.eles=e,i.push(s(t))}),t.quality=="default"||t.quality==`proof`){var m=n.collection();if(t.tile){var h=new Map,g=[],_=[],v=0,y={nodeIndexes:h,xCoords:g,yCoords:_},b=[];if(l.forEach(function(e,t){e.edges().length==0&&(e.nodes().forEach(function(t,n){m.merge(e.nodes()[n]),t.isParent()||(y.nodeIndexes.set(e.nodes()[n].id(),v++),y.xCoords.push(e.nodes()[0].position().x),y.yCoords.push(e.nodes()[0].position().y))}),b.push(t))}),m.length>1){var x=m.boundingBox();u.push({x:x.x1+x.w/2,y:x.y1+x.h/2}),l.push(m),i.push(y);for(var S=b.length-1;S>=0;S--)l.splice(b[S],1),i.splice(b[S],1),u.splice(b[S],1)}}l.forEach(function(e,n){t.eles=e,a.push(c(t,i[n])),o.relocateComponent(u[n],a[n],t)})}else l.forEach(function(e,n){o.relocateComponent(u[n],i[n],t)});var C=new Set;if(l.length>1){var w=[],T=r.filter(function(e){return e.css(`display`)==`none`});l.forEach(function(e,n){var r=void 0;if(t.quality==`draft`&&(r=i[n].nodeIndexes),e.nodes().not(T).length>0){var s={};s.edges=[],s.nodes=[];var c=void 0;e.nodes().not(T).forEach(function(e){if(t.quality==`draft`){if(!e.isParent())c=r.get(e.id()),s.nodes.push({x:i[n].xCoords[c]-e.boundingbox().w/2,y:i[n].yCoords[c]-e.boundingbox().h/2,width:e.boundingbox().w,height:e.boundingbox().h});else{var l=o.calcBoundingBox(e,i[n].xCoords,i[n].yCoords,r);s.nodes.push({x:l.topLeftX,y:l.topLeftY,width:l.width,height:l.height})}}else a[n][e.id()]&&s.nodes.push({x:a[n][e.id()].getLeft(),y:a[n][e.id()].getTop(),width:a[n][e.id()].getWidth(),height:a[n][e.id()].getHeight()})}),e.edges().forEach(function(e){var c=e.source(),l=e.target();if(c.css(`display`)!=`none`&&l.css(`display`)!=`none`){if(t.quality==`draft`){var u=r.get(c.id()),d=r.get(l.id()),f=[],p=[];if(c.isParent()){var m=o.calcBoundingBox(c,i[n].xCoords,i[n].yCoords,r);f.push(m.topLeftX+m.width/2),f.push(m.topLeftY+m.height/2)}else f.push(i[n].xCoords[u]),f.push(i[n].yCoords[u]);if(l.isParent()){var h=o.calcBoundingBox(l,i[n].xCoords,i[n].yCoords,r);p.push(h.topLeftX+h.width/2),p.push(h.topLeftY+h.height/2)}else p.push(i[n].xCoords[d]),p.push(i[n].yCoords[d]);s.edges.push({startX:f[0],startY:f[1],endX:p[0],endY:p[1]})}else a[n][c.id()]&&a[n][l.id()]&&s.edges.push({startX:a[n][c.id()].getCenterX(),startY:a[n][c.id()].getCenterY(),endX:a[n][l.id()].getCenterX(),endY:a[n][l.id()].getCenterY()})}}),s.nodes.length>0&&(w.push(s),C.add(n))}});var E=d.packComponents(w,t.randomize).shifts;if(t.quality==`draft`)i.forEach(function(e,t){var n=e.xCoords.map(function(e){return e+E[t].dx}),r=e.yCoords.map(function(e){return e+E[t].dy});e.xCoords=n,e.yCoords=r});else{var D=0;C.forEach(function(e){Object.keys(a[e]).forEach(function(t){var n=a[e][t];n.setCenter(n.getCenterX()+E[D].dx,n.getCenterY()+E[D].dy)}),D++})}}}else{var O=t.eles.boundingBox();if(u.push({x:O.x1+O.w/2,y:O.y1+O.h/2}),t.randomize){var k=s(t);i.push(k)}t.quality=="default"||t.quality==`proof`?(a.push(c(t,i[0])),o.relocateComponent(u[0],a[0],t)):o.relocateComponent(u[0],i[0],t)}}var A=function(e,n){if(t.quality=="default"||t.quality==`proof`){typeof e==`number`&&(e=n);var r=void 0,o=void 0,s=e.data(`id`);return a.forEach(function(e){s in e&&(r={x:e[s].getRect().getCenterX(),y:e[s].getRect().getCenterY()},o=e[s])}),t.nodeDimensionsIncludeLabels&&(o.labelWidth&&(o.labelPosHorizontal==`left`?r.x+=o.labelWidth/2:o.labelPosHorizontal==`right`&&(r.x-=o.labelWidth/2)),o.labelHeight&&(o.labelPosVertical==`top`?r.y+=o.labelHeight/2:o.labelPosVertical==`bottom`&&(r.y-=o.labelHeight/2))),r??={x:e.position(`x`),y:e.position(`y`)},{x:r.x,y:r.y}}var c=void 0;return i.forEach(function(t){var n=t.nodeIndexes.get(e.id());n!=null&&(c={x:t.xCoords[n],y:t.yCoords[n]})}),c??={x:e.position(`x`),y:e.position(`y`)},{x:c.x,y:c.y}};if(t.quality=="default"||t.quality==`proof`||t.randomize){var j=o.calcParentsWithoutChildren(n,r),M=r.filter(function(e){return e.css(`display`)==`none`});t.eles=r.not(M),r.nodes().not(`:parent`).not(M).layoutPositions(e,t,A),j.length>0&&j.forEach(function(e){e.position(A(e))})}else console.log(`If randomize option is set to false, then quality option must be 'default' or 'proof'.`)}}]),e}()}),657:((e,t,n)=>{var r=n(548),i=n(140).layoutBase.Matrix,a=n(140).layoutBase.SVD;e.exports={spectralLayout:function(e){var t=e.cy,n=e.eles,o=n.nodes(),s=n.nodes(`:parent`),c=new Map,l=new Map,u=new Map,d=[],f=[],p=[],m=[],h=[],g=[],_=[],v=[],y=void 0,b=1e8,x=1e-9,S=e.piTol,C=e.samplingType,w=e.nodeSeparation,T=void 0,E=function(){for(var e=0,t=0,n=!1;t=i;){o=r[i++];for(var m=d[o],_=0;_u&&(u=h[x],f=x)}return f},O=function(e){var t=void 0;if(e){t=Math.floor(Math.random()*y);for(var n=0;n=1)break;u=l}for(var h=0;h=1)break;u=l}for(var b=0;b0&&(r.isParent()?d[t].push(u.get(r.id())):d[t].push(r.id()))})});var B=function(e){var n=l.get(e),r=void 0;c.get(e).forEach(function(i){r=t.getElementById(i).isParent()?u.get(i):i,d[n].push(r),d[l.get(r)].push(e)})},V=!0,ee=!1,te=void 0;try{for(var H=c.keys()[Symbol.iterator](),ne;!(V=(ne=H.next()).done);V=!0){var re=ne.value;B(re)}}catch(e){ee=!0,te=e}finally{try{!V&&H.return&&H.return()}finally{if(ee)throw te}}y=l.size;var U=void 0;if(y>2){T=y{var r=n(212),i=function(e){e&&e(`layout`,`fcose`,r)};typeof cytoscape<`u`&&i(cytoscape),e.exports=i}),140:(t=>{t.exports=e})},n={};function r(e){var i=n[e];if(i!==void 0)return i.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}return r(579)})()})}))(),1),A={L:`left`,R:`right`,T:`top`,B:`bottom`},j={L:r(e=>`${e},${e/2} 0,${e} 0,0`,`L`),R:r(e=>`0,${e/2} ${e},0 ${e},${e}`,`R`),T:r(e=>`0,0 ${e},0 ${e/2},${e}`,`T`),B:r(e=>`${e/2},0 ${e},${e} 0,${e}`,`B`)},M={L:r((e,t)=>e-t+2,`L`),R:r((e,t)=>e-2,`R`),T:r((e,t)=>e-t+2,`T`),B:r((e,t)=>e-2,`B`)},N=r(function(e){return F(e)?e===`L`?`R`:`L`:e===`T`?`B`:`T`},`getOppositeArchitectureDirection`),P=r(function(e){let t=e;return t===`L`||t===`R`||t===`T`||t===`B`},`isArchitectureDirection`),F=r(function(e){let t=e;return t===`L`||t===`R`},`isArchitectureDirectionX`),I=r(function(e){let t=e;return t===`T`||t===`B`},`isArchitectureDirectionY`),L=r(function(e,t){let n=F(e)&&I(t),r=I(e)&&F(t);return n||r},`isArchitectureDirectionXY`),R=r(function(e){let t=e[0],n=e[1],r=F(t)&&I(n),i=I(t)&&F(n);return r||i},`isArchitecturePairXY`),z=r(function(e){return e!==`LL`&&e!==`RR`&&e!==`TT`&&e!==`BB`},`isValidArchitectureDirectionPair`),B=r(function(e,t){let n=`${e}${t}`;return z(n)?n:void 0},`getArchitectureDirectionPair`),V=r(function([e,t],n){let r=n[0],i=n[1];return F(r)?I(i)?[e+(r===`L`?-1:1),t+(i===`T`?1:-1)]:[e+(r===`L`?-1:1),t]:F(i)?[e+(i===`L`?1:-1),t+(r===`T`?1:-1)]:[e,t+(r===`T`?1:-1)]},`shiftPositionByArchitectureDirectionPair`),ee=r(function(e){return e===`LT`||e===`TL`?[1,1]:e===`BL`||e===`LB`?[1,-1]:e===`BR`||e===`RB`?[-1,-1]:[-1,1]},`getArchitectureDirectionXYFactors`),te=r(function(e,t){return L(e,t)?`bend`:F(e)?`horizontal`:`vertical`},`getArchitectureDirectionAlignment`),H=r(function(e){return e.type===`service`},`isArchitectureService`),ne=r(function(e){return e.type===`junction`},`isArchitectureJunction`),re=r((e,t)=>{let[n,r]=[e,t].sort();return`${JSON.stringify(n)}-${JSON.stringify(r)}`},`architectureGroupAlignmentKey`),U=r(e=>e.data(),`edgeData`),W=r(e=>e.data(),`nodeData`),G=f.architecture,ie=class{constructor(){this.nodes=new Map,this.groups=new Map,this.edges=[],this.layoutHints=[],this.registeredIds=new Map,this.elements=new Map,this.diagramId=``,this.setAccTitle=l,this.getAccTitle=g,this.setDiagramTitle=c,this.getDiagramTitle=m,this.getAccDescription=p,this.setAccDescription=o,this.clear()}static{r(this,`ArchitectureDB`)}setDiagramId(e){this.diagramId=e}getDiagramId(){return this.diagramId}clear(){this.nodes=new Map,this.groups=new Map,this.edges=[],this.layoutHints=[],this.registeredIds=new Map,this.dataStructures=void 0,this.elements=new Map,this.diagramId=``,u()}addService({id:e,icon:t,in:n,title:r,iconText:i}){if(this.registeredIds.has(e))throw Error(`The service id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(n!==void 0){if(e===n)throw Error(`The service [${e}] cannot be placed within itself`);if(!this.registeredIds.has(n))throw Error(`The service [${e}]'s parent does not exist. Please make sure the parent is created before this service`);if(this.registeredIds.get(n)===`node`)throw Error(`The service [${e}]'s parent is not a group`)}this.registeredIds.set(e,`node`),this.nodes.set(e,{id:e,type:`service`,icon:t,iconText:i,title:r,edges:[],in:n})}getServices(){return[...this.nodes.values()].filter(H)}addJunction({id:e,in:t}){if(this.registeredIds.has(e))throw Error(`The junction id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(t!==void 0){if(e===t)throw Error(`The junction [${e}] cannot be placed within itself`);if(!this.registeredIds.has(t))throw Error(`The junction [${e}]'s parent does not exist. Please make sure the parent is created before this junction`);if(this.registeredIds.get(t)===`node`)throw Error(`The junction [${e}]'s parent is not a group`)}this.registeredIds.set(e,`node`),this.nodes.set(e,{id:e,type:`junction`,edges:[],in:t})}getJunctions(){return[...this.nodes.values()].filter(ne)}getNodes(){return[...this.nodes.values()]}getNode(e){return this.nodes.get(e)??null}addGroup({id:e,icon:t,in:n,title:r}){if(this.registeredIds.has(e))throw Error(`The group id [${e}] is already in use by another ${this.registeredIds.get(e)}`);if(n!==void 0){if(e===n)throw Error(`The group [${e}] cannot be placed within itself`);if(!this.registeredIds.has(n))throw Error(`The group [${e}]'s parent does not exist. Please make sure the parent is created before this group`);if(this.registeredIds.get(n)===`node`)throw Error(`The group [${e}]'s parent is not a group`)}this.registeredIds.set(e,`group`),this.groups.set(e,{id:e,icon:t,title:r,in:n})}getGroups(){return[...this.groups.values()]}addEdge({lhsId:e,rhsId:t,lhsDir:n,rhsDir:r,lhsInto:i,rhsInto:a,lhsGroup:o,rhsGroup:s,title:c}){if(!P(n))throw Error(`Invalid direction given for left hand side of edge ${e}--${t}. Expected (L,R,T,B) got ${String(n)}`);if(!P(r))throw Error(`Invalid direction given for right hand side of edge ${e}--${t}. Expected (L,R,T,B) got ${String(r)}`);if(!this.nodes.has(e)&&!this.groups.has(e))throw Error(`The left-hand id [${e}] does not yet exist. Please create the service/group before declaring an edge to it.`);if(!this.nodes.has(t)&&!this.groups.has(t))throw Error(`The right-hand id [${t}] does not yet exist. Please create the service/group before declaring an edge to it.`);let l=this.nodes.get(e).in,u=this.nodes.get(t).in;if(o&&l&&u&&l==u)throw Error(`The left-hand id [${e}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);if(s&&l&&u&&l==u)throw Error(`The right-hand id [${t}] is modified to traverse the group boundary, but the edge does not pass through two groups.`);let d={lhsId:e,lhsDir:n,lhsInto:i,lhsGroup:o,rhsId:t,rhsDir:r,rhsInto:a,rhsGroup:s,title:c};this.edges.push(d);let f=this.nodes.get(e),p=this.nodes.get(t);f&&p&&(f.edges.push(this.edges[this.edges.length-1]),p.edges.push(this.edges[this.edges.length-1]))}getEdges(){return this.edges}addLayoutHint(e){if(e.members.length<2)throw Error(`An align directive requires at least two members; got ${e.members.length}`);let t=new Set;e.members.forEach(n=>{if(this.registeredIds.get(n)!==`node`)throw Error(`align ${e.direction} references [${n}], which is not a service or junction`);if(t.has(n))throw Error(`align ${e.direction} lists [${n}] more than once`);t.add(n)}),this.layoutHints.push(e)}getLayoutHints(){return this.layoutHints}getDataStructures(){if(this.dataStructures===void 0){let e=new Map,t=new Map;for(let[n,r]of this.nodes.entries()){let i=new Map;for(let t of r.edges){let r=this.getNode(t.lhsId)?.in,a=this.getNode(t.rhsId)?.in;if(r&&a&&r!==a){let n=te(t.lhsDir,t.rhsDir);n!==`bend`&&e.set(re(r,a),n)}if(t.lhsId===n){let e=B(t.lhsDir,t.rhsDir);e&&i.set(e,t.rhsId)}else{let e=B(t.rhsDir,t.lhsDir);e&&i.set(e,t.lhsId)}}t.set(n,i)}let n=new Set,i=new Set(t.keys()),a=r(e=>{let r=new Map([[e,[0,0]]]),a=[e];for(;a.length>0;){let e=a.shift();if(e){n.add(e),i.delete(e);let o=t.get(e);if(!o)throw Error(`BFS error: adjacency list for id ${e} not found. Please report this as a bug.`);let s=r.get(e);if(!s)throw Error(`BFS error: position for id ${e} not found in spatial map. Please report this as a bug.`);let[c,l]=s;o.forEach((e,t)=>{n.has(e)||(r.set(e,V([c,l],t)),a.push(e))})}}return r},`BFS`),o=[];for(;i.size>0;){let e=i.values().next().value;o.push(a(e))}this.dataStructures={adjList:t,spatialMaps:o,groupAlignments:e}}return this.dataStructures}setElementForId(e,t){this.elements.set(e,t)}getElementById(e){return this.elements.get(e)}getConfig(){return y({...G,...d().architecture})}getConfigField(e){return this.getConfig()[e]}},K=r((e,t)=>{b(e,t),e.groups.map(e=>t.addGroup(e)),e.services.map(e=>t.addService({...e,type:`service`})),e.junctions.map(e=>t.addJunction({...e,type:`junction`})),e.edges.map(e=>t.addEdge(e)),e.alignments?.map(e=>t.addLayoutHint({direction:e.direction,members:[...e.members]}))},`populateDb`),q={parser:{yy:void 0},parse:r(async e=>{let t=await n(`architecture`,e);i.debug(t);let r=q.parser?.yy;if(!(r instanceof ie))throw Error(`parser.parser?.yy was not a ArchitectureDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.`);K(t,r)},`parse`)},ae=r(e=>`
+import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{n}from"./mermaid-parser.core-DyaQCW3q.js";import{n as r}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import{m as i,p as a}from"./src-B6xuSHsQ.js";import{H as o,J as s,K as c,U as l,a as u,b as d,f,v as p,w as m,x as h,y as g,z as _}from"./chunk-DU6HZSFF-CCRRBYqx.js";import{c as v,i as y}from"./chunk-75Z2AOVW-C6IW9Aj7.js";import{t as b}from"./chunk-JWPE2WC7-DVXcaiue.js";import{i as x,r as S,t as C}from"./chunk-PWAF6VOD-xvQF4vEp.js";import{n as w}from"./chunk-GMAD6QVW-Bo9mXLgH.js";import{t as T}from"./cytoscape.esm-Yq6u8L66.js";import{f as E}from"./mermaid.core-BAm9IrIs.js";var D=t(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define([],r):typeof e==`object`?e.layoutBase=r():n.layoutBase=r()})(e,function(){return(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,`a`,t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p=``,n(n.s=28)})([(function(e,t,n){function r(){}r.QUALITY=1,r.DEFAULT_CREATE_BENDS_AS_NEEDED=!1,r.DEFAULT_INCREMENTAL=!1,r.DEFAULT_ANIMATION_ON_LAYOUT=!0,r.DEFAULT_ANIMATION_DURING_LAYOUT=!1,r.DEFAULT_ANIMATION_PERIOD=50,r.DEFAULT_UNIFORM_LEAF_NODE_SIZES=!1,r.DEFAULT_GRAPH_MARGIN=15,r.NODE_DIMENSIONS_INCLUDE_LABELS=!1,r.SIMPLE_NODE_SIZE=40,r.SIMPLE_NODE_HALF_SIZE=r.SIMPLE_NODE_SIZE/2,r.EMPTY_COMPOUND_NODE_SIZE=40,r.MIN_EDGE_LENGTH=1,r.WORLD_BOUNDARY=1e6,r.INITIAL_WORLD_BOUNDARY=r.WORLD_BOUNDARY/1e3,r.WORLD_CENTER_X=1200,r.WORLD_CENTER_Y=900,e.exports=r}),(function(e,t,n){var r=n(2),i=n(8),a=n(9);function o(e,t,n){r.call(this,n),this.isOverlapingSourceAndTarget=!1,this.vGraphObject=n,this.bendpoints=[],this.source=e,this.target=t}for(var s in o.prototype=Object.create(r.prototype),r)o[s]=r[s];o.prototype.getSource=function(){return this.source},o.prototype.getTarget=function(){return this.target},o.prototype.isInterGraph=function(){return this.isInterGraph},o.prototype.getLength=function(){return this.length},o.prototype.isOverlapingSourceAndTarget=function(){return this.isOverlapingSourceAndTarget},o.prototype.getBendpoints=function(){return this.bendpoints},o.prototype.getLca=function(){return this.lca},o.prototype.getSourceInLca=function(){return this.sourceInLca},o.prototype.getTargetInLca=function(){return this.targetInLca},o.prototype.getOtherEnd=function(e){if(this.source===e)return this.target;if(this.target===e)return this.source;throw`Node is not incident with this edge`},o.prototype.getOtherEndInGraph=function(e,t){for(var n=this.getOtherEnd(e),r=t.getGraphManager().getRoot();;){if(n.getOwner()==t)return n;if(n.getOwner()==r)break;n=n.getOwner().getParent()}return null},o.prototype.updateLength=function(){var e=[,,,,];this.isOverlapingSourceAndTarget=i.getIntersection(this.target.getRect(),this.source.getRect(),e),this.isOverlapingSourceAndTarget||(this.lengthX=e[0]-e[2],this.lengthY=e[1]-e[3],Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY))},o.prototype.updateLengthSimple=function(){this.lengthX=this.target.getCenterX()-this.source.getCenterX(),this.lengthY=this.target.getCenterY()-this.source.getCenterY(),Math.abs(this.lengthX)<1&&(this.lengthX=a.sign(this.lengthX)),Math.abs(this.lengthY)<1&&(this.lengthY=a.sign(this.lengthY)),this.length=Math.sqrt(this.lengthX*this.lengthX+this.lengthY*this.lengthY)},e.exports=o}),(function(e,t,n){function r(e){this.vGraphObject=e}e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(13),o=n(0),s=n(16),c=n(5);function l(e,t,n,o){n==null&&o==null&&(o=t),r.call(this,o),e.graphManager!=null&&(e=e.graphManager),this.estimatedSize=i.MIN_VALUE,this.inclusionTreeDepth=i.MAX_VALUE,this.vGraphObject=o,this.edges=[],this.graphManager=e,this.rect=n!=null&&t!=null?new a(t.x,t.y,n.width,n.height):new a}for(var u in l.prototype=Object.create(r.prototype),r)l[u]=r[u];l.prototype.getEdges=function(){return this.edges},l.prototype.getChild=function(){return this.child},l.prototype.getOwner=function(){return this.owner},l.prototype.getWidth=function(){return this.rect.width},l.prototype.setWidth=function(e){this.rect.width=e},l.prototype.getHeight=function(){return this.rect.height},l.prototype.setHeight=function(e){this.rect.height=e},l.prototype.getCenterX=function(){return this.rect.x+this.rect.width/2},l.prototype.getCenterY=function(){return this.rect.y+this.rect.height/2},l.prototype.getCenter=function(){return new c(this.rect.x+this.rect.width/2,this.rect.y+this.rect.height/2)},l.prototype.getLocation=function(){return new c(this.rect.x,this.rect.y)},l.prototype.getRect=function(){return this.rect},l.prototype.getDiagonal=function(){return Math.sqrt(this.rect.width*this.rect.width+this.rect.height*this.rect.height)},l.prototype.getHalfTheDiagonal=function(){return Math.sqrt(this.rect.height*this.rect.height+this.rect.width*this.rect.width)/2},l.prototype.setRect=function(e,t){this.rect.x=e.x,this.rect.y=e.y,this.rect.width=t.width,this.rect.height=t.height},l.prototype.setCenter=function(e,t){this.rect.x=e-this.rect.width/2,this.rect.y=t-this.rect.height/2},l.prototype.setLocation=function(e,t){this.rect.x=e,this.rect.y=t},l.prototype.moveBy=function(e,t){this.rect.x+=e,this.rect.y+=t},l.prototype.getEdgeListToNode=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.target==e){if(r.source!=n)throw`Incorrect edge source!`;t.push(r)}}),t},l.prototype.getEdgesBetween=function(e){var t=[],n=this;return n.edges.forEach(function(r){if(r.source!=n&&r.target!=n)throw`Incorrect edge source and/or target`;(r.target==e||r.source==e)&&t.push(r)}),t},l.prototype.getNeighborsList=function(){var e=new Set,t=this;return t.edges.forEach(function(n){if(n.source==t)e.add(n.target);else{if(n.target!=t)throw`Incorrect incidency!`;e.add(n.source)}}),e},l.prototype.withChildren=function(){var e=new Set,t,n;if(e.add(this),this.child!=null)for(var r=this.child.getNodes(),i=0;it?(this.rect.x-=(this.labelWidth-t)/2,this.setWidth(this.labelWidth)):this.labelPosHorizontal==`right`&&this.setWidth(t+this.labelWidth)),this.labelHeight&&(this.labelPosVertical==`top`?(this.rect.y-=this.labelHeight,this.setHeight(n+this.labelHeight)):this.labelPosVertical==`center`&&this.labelHeight>n?(this.rect.y-=(this.labelHeight-n)/2,this.setHeight(this.labelHeight)):this.labelPosVertical==`bottom`&&this.setHeight(n+this.labelHeight))}}},l.prototype.getInclusionTreeDepth=function(){if(this.inclusionTreeDepth==i.MAX_VALUE)throw`assert failed`;return this.inclusionTreeDepth},l.prototype.transform=function(e){var t=this.rect.x;t>o.WORLD_BOUNDARY?t=o.WORLD_BOUNDARY:t<-o.WORLD_BOUNDARY&&(t=-o.WORLD_BOUNDARY);var n=this.rect.y;n>o.WORLD_BOUNDARY?n=o.WORLD_BOUNDARY:n<-o.WORLD_BOUNDARY&&(n=-o.WORLD_BOUNDARY);var r=new c(t,n),i=e.inverseTransformPoint(r);this.setLocation(i.x,i.y)},l.prototype.getLeft=function(){return this.rect.x},l.prototype.getRight=function(){return this.rect.x+this.rect.width},l.prototype.getTop=function(){return this.rect.y},l.prototype.getBottom=function(){return this.rect.y+this.rect.height},l.prototype.getParent=function(){return this.owner==null?null:this.owner.getParent()},e.exports=l}),(function(e,t,n){var r=n(0);function i(){}for(var a in r)i[a]=r[a];i.MAX_ITERATIONS=2500,i.DEFAULT_EDGE_LENGTH=50,i.DEFAULT_SPRING_STRENGTH=.45,i.DEFAULT_REPULSION_STRENGTH=4500,i.DEFAULT_GRAVITY_STRENGTH=.4,i.DEFAULT_COMPOUND_GRAVITY_STRENGTH=1,i.DEFAULT_GRAVITY_RANGE_FACTOR=3.8,i.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR=1.5,i.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION=!0,i.DEFAULT_USE_SMART_REPULSION_RANGE_CALCULATION=!0,i.DEFAULT_COOLING_FACTOR_INCREMENTAL=.3,i.COOLING_ADAPTATION_FACTOR=.33,i.ADAPTATION_LOWER_NODE_LIMIT=1e3,i.ADAPTATION_UPPER_NODE_LIMIT=5e3,i.MAX_NODE_DISPLACEMENT_INCREMENTAL=100,i.MAX_NODE_DISPLACEMENT=i.MAX_NODE_DISPLACEMENT_INCREMENTAL*3,i.MIN_REPULSION_DIST=i.DEFAULT_EDGE_LENGTH/10,i.CONVERGENCE_CHECK_PERIOD=100,i.PER_LEVEL_IDEAL_EDGE_LENGTH_FACTOR=.1,i.MIN_EDGE_LENGTH=1,i.GRID_CALCULATION_CHECK_PERIOD=10,e.exports=i}),(function(e,t,n){function r(e,t){e==null&&t==null?(this.x=0,this.y=0):(this.x=e,this.y=t)}r.prototype.getX=function(){return this.x},r.prototype.getY=function(){return this.y},r.prototype.setX=function(e){this.x=e},r.prototype.setY=function(e){this.y=e},r.prototype.getDifference=function(e){return new DimensionD(this.x-e.x,this.y-e.y)},r.prototype.getCopy=function(){return new r(this.x,this.y)},r.prototype.translate=function(e){return this.x+=e.width,this.y+=e.height,this},e.exports=r}),(function(e,t,n){var r=n(2),i=n(10),a=n(0),o=n(7),s=n(3),c=n(1),l=n(13),u=n(12),d=n(11);function f(e,t,n){r.call(this,n),this.estimatedSize=i.MIN_VALUE,this.margin=a.DEFAULT_GRAPH_MARGIN,this.edges=[],this.nodes=[],this.isConnected=!1,this.parent=e,t!=null&&t instanceof o?this.graphManager=t:t!=null&&t instanceof Layout&&(this.graphManager=t.graphManager)}for(var p in f.prototype=Object.create(r.prototype),r)f[p]=r[p];f.prototype.getNodes=function(){return this.nodes},f.prototype.getEdges=function(){return this.edges},f.prototype.getGraphManager=function(){return this.graphManager},f.prototype.getParent=function(){return this.parent},f.prototype.getLeft=function(){return this.left},f.prototype.getRight=function(){return this.right},f.prototype.getTop=function(){return this.top},f.prototype.getBottom=function(){return this.bottom},f.prototype.isConnected=function(){return this.isConnected},f.prototype.add=function(e,t,n){if(t==null&&n==null){var r=e;if(this.graphManager==null)throw`Graph has no graph mgr!`;if(this.getNodes().indexOf(r)>-1)throw`Node already in graph!`;return r.owner=this,this.getNodes().push(r),r}var i=e;if(!(this.getNodes().indexOf(t)>-1&&this.getNodes().indexOf(n)>-1))throw`Source or target not in graph!`;if(t.owner!=n.owner||t.owner!=this)throw`Both owners must be this graph!`;return t.owner==n.owner?(i.source=t,i.target=n,i.isInterGraph=!1,this.getEdges().push(i),t.edges.push(i),n!=t&&n.edges.push(i),i):null},f.prototype.remove=function(e){var t=e;if(e instanceof s){if(t==null)throw`Node is null!`;if(t.owner==null||t.owner!=this)throw`Owner graph is invalid!`;if(this.graphManager==null)throw`Owner graph manager is invalid!`;for(var n=t.edges.slice(),r,i=n.length,a=0;a-1&&u>-1))throw`Source and/or target doesn't know this edge!`;r.source.edges.splice(l,1),r.target!=r.source&&r.target.edges.splice(u,1);var o=r.source.owner.getEdges().indexOf(r);if(o==-1)throw`Not in owner's edge list!`;r.source.owner.getEdges().splice(o,1)}},f.prototype.updateLeftTop=function(){for(var e=i.MAX_VALUE,t=i.MAX_VALUE,n,r,a,o=this.getNodes(),s=o.length,c=0;cn&&(e=n),t>r&&(t=r)}return e==i.MAX_VALUE?null:(a=o[0].getParent().paddingLeft==null?this.margin:o[0].getParent().paddingLeft,this.left=t-a,this.top=e-a,new u(this.left,this.top))},f.prototype.updateBounds=function(e){for(var t=i.MAX_VALUE,n=-i.MAX_VALUE,r=i.MAX_VALUE,a=-i.MAX_VALUE,o,s,c,u,d,f=this.nodes,p=f.length,m=0;mo&&(t=o),nc&&(r=c),ao&&(t=o),nc&&(r=c),a=this.nodes.length){var c=0;n.forEach(function(t){t.owner==e&&c++}),c==this.nodes.length&&(this.isConnected=!0)}},e.exports=f}),(function(e,t,n){var r,i=n(1);function a(e){r=n(6),this.layout=e,this.graphs=[],this.edges=[]}a.prototype.addRoot=function(){var e=this.layout.newGraph(),t=this.layout.newNode(null),n=this.add(e,t);return this.setRootGraph(n),this.rootGraph},a.prototype.add=function(e,t,n,r,i){if(n==null&&r==null&&i==null){if(e==null)throw`Graph is null!`;if(t==null)throw`Parent node is null!`;if(this.graphs.indexOf(e)>-1)throw`Graph already in this graph mgr!`;if(this.graphs.push(e),e.parent!=null)throw`Already has a parent!`;if(t.child!=null)throw`Already has a child!`;return e.parent=t,t.child=e,e}i=n,r=t,n=e;var a=r.getOwner(),o=i.getOwner();if(a==null||a.getGraphManager()!=this)throw`Source not in this graph mgr!`;if(o==null||o.getGraphManager()!=this)throw`Target not in this graph mgr!`;if(a==o)return n.isInterGraph=!1,a.add(n,r,i);if(n.isInterGraph=!0,n.source=r,n.target=i,this.edges.indexOf(n)>-1)throw`Edge already in inter-graph edge list!`;if(this.edges.push(n),n.source==null||n.target==null)throw`Edge source and/or target is null!`;if(n.source.edges.indexOf(n)!=-1||n.target.edges.indexOf(n)!=-1)throw`Edge already in source and/or target incidency list!`;return n.source.edges.push(n),n.target.edges.push(n),n},a.prototype.remove=function(e){if(e instanceof r){var t=e;if(t.getGraphManager()!=this)throw`Graph not in this graph mgr`;if(!(t==this.rootGraph||t.parent!=null&&t.parent.graphManager==this))throw`Invalid parent node!`;var n=[];n=n.concat(t.getEdges());for(var a,o=n.length,s=0;s