@inkeep/open-knowledge 0.49.0-beta.27 → 0.49.0-beta.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/{acp-harness-probe-DYSjZblH.mjs → acp-harness-probe-DNUhLiYw.mjs} +2 -2
  2. package/dist/cli.mjs +6 -6
  3. package/dist/constants-C2XDlcS1.mjs +2 -0
  4. package/dist/index.d.mts +17 -17
  5. package/dist/index.mjs +1 -1
  6. package/dist/init-ClZSDo6l.mjs +1 -0
  7. package/dist/{init-BUIEpJX9.mjs → init-D1zZSW1w.mjs} +3 -3
  8. package/dist/{launch-json-removal-DqWNMLcl.mjs → launch-json-removal-83o3EGTO.mjs} +2 -2
  9. package/dist/{loader-CqgZy7s4.mjs → loader-DRfEZJJx.mjs} +2 -2
  10. package/dist/loader-s1KEG5BC.mjs +1 -0
  11. package/dist/preview-CvAKccSM.mjs +1 -0
  12. package/dist/{preview-CW1IxLsJ.mjs → preview-DynmdTIr.mjs} +2 -2
  13. package/dist/public/assets/{ChangedOutsideBadge-Cv8USc43.js → ChangedOutsideBadge-DEnLfcgW.js} +1 -1
  14. package/dist/public/assets/FeedbackForm-CMxe5Ck2.js +1 -0
  15. package/dist/public/assets/SessionsHost-unW7heC4.js +2 -0
  16. package/dist/public/assets/SettingsDialogBody-tqarK912.js +12 -0
  17. package/dist/public/assets/{SkillToolbarControls-BIhmBwAB.js → SkillToolbarControls-y2FNhFQy.js} +1 -1
  18. package/dist/public/assets/{TerminalWindowApp-CJOysYRr.js → TerminalWindowApp-BP796BPz.js} +1 -1
  19. package/dist/public/assets/agent-visibility-D5jwzmFA.js +1 -0
  20. package/dist/public/assets/{auth-state-cache-rhnmn74G.js → auth-state-cache-Cx_tsdYE.js} +1 -1
  21. package/dist/public/assets/{index-Cq2BuWd2.js → index-D3Eciye1.js} +6 -6
  22. package/dist/public/assets/{skill-actions-DwpN3-eB.js → skill-actions-BryscMLS.js} +1 -1
  23. package/dist/public/assets/{terminal-launch-events-94aIhofY.js → terminal-launch-events-rvma4jZd.js} +1 -1
  24. package/dist/public/assets/{terminal-telemetry-C9J9jNy9.js → terminal-telemetry-DV5mcRVf.js} +1 -1
  25. package/dist/public/assets/{use-terminal-enabled-BHdXkRUU.js → use-terminal-enabled-D05DXcuw.js} +1 -1
  26. package/dist/public/index.html +7 -7
  27. package/dist/{repair-launch-json-CooRfHHf.mjs → repair-launch-json-Dd_YKC4a.mjs} +2 -2
  28. package/dist/{repair-mcp-configs-9MXPCm8A.mjs → repair-mcp-configs-B4VLRlOf.mjs} +2 -2
  29. package/dist/src-CI4mQeWa.mjs +1 -0
  30. package/dist/{src-eJmU7tk9.mjs → src-DN-gWXIq.mjs} +2 -2
  31. package/dist/start-B2E2Vu3j.mjs +1 -0
  32. package/dist/{start-ffP2Ihoz.mjs → start-CO8ycP7q.mjs} +2 -2
  33. package/package.json +5 -5
  34. package/dist/constants-BEe0tuQx.mjs +0 -2
  35. package/dist/init-Be3isy7g.mjs +0 -1
  36. package/dist/loader-C7VKSyMe.mjs +0 -1
  37. package/dist/preview-6qIUkP7f.mjs +0 -1
  38. package/dist/public/assets/FeedbackForm-D16BkoQE.js +0 -1
  39. package/dist/public/assets/SessionsHost-CQB30dyD.js +0 -2
  40. package/dist/public/assets/SettingsDialogBody-DK9ene5l.js +0 -12
  41. package/dist/public/assets/agent-visibility-CvZ8XtPP.js +0 -1
  42. package/dist/src-DGawJ9va.mjs +0 -1
  43. package/dist/start-C_ESEIR_.mjs +0 -1
@@ -1,4 +1,4 @@
1
- import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Y as r}from"./sleep-DVOInM4H.mjs";import{Go as i,K as a,U as o,os as s,wo as c}from"./src-TKCctdpc.mjs";import{$t as l,Ca as u,En as d,Fr as f,Jr as p,Lr as m,Nr as h,Pr as g,_n as _,br as v,c as y,en as b,fr as x,hn as S,l as C,mn as ee,nr as te,rr as ne,tr as re,u as ie,ur as ae,xr as oe}from"./src-DfRHrkSZ.mjs";import{M as w,P as T}from"./fs-traced-DVpoNaQJ.mjs";import{_ as se,a as ce,b as E,c as le,d as ue,i as de,l as fe,o as D,r as pe,t as me,u as he,v as ge}from"./write-project-skill-D38t_B_r.mjs";import{i as O,n as k,o as A,r as _e,s as j,t as M}from"./colors-BsmVIwfM.mjs";import{t as ve}from"./constants-BEe0tuQx.mjs";import{t as N}from"./is-object-ByG7RnjH.mjs";import{t as ye}from"./preview-CW1IxLsJ.mjs";import{createRequire as be}from"node:module";import{execFileSync as xe}from"node:child_process";import Se,{dirname as P,isAbsolute as F,join as I,relative as L,resolve as Ce,sep as we}from"node:path";import R from"node:process";import{fileURLToPath as Te}from"node:url";import{existsSync as z,lstatSync as Ee,mkdirSync as De,readFileSync as B,readlinkSync as Oe,realpathSync as ke,statSync as Ae,writeFileSync as je}from"node:fs";import{homedir as Me}from"node:os";import*as Ne from"node:readline";import{inspect as Pe,stripVTControlCharacters as Fe,styleText as V}from"node:util";import{AsyncLocalStorage as Ie,AsyncResource as Le}from"node:async_hooks";const Re=new Set([`emacs`,`vim`]);function ze(e){return Re.has(e)}function Be(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(ze))):[]}const H=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ve=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,He=e=>e.name===`space`,Ue=e=>e.name===`backspace`,We=e=>`1234567890`.includes(e.name),Ge=e=>e.name===`enter`||e.name===`return`;var Ke=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},qe=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Je=class extends Error{name=`ExitPromptError`},Ye=class extends Error{name=`HookError`},Xe=class extends Error{name=`ValidationError`};const Ze=new Ie;function Qe(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function $e(e,t){let n=Qe(e);return Ze.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=Ze.getStore();if(!e)throw new Ye(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function et(){return U().rl}function tt(e){return Le.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function nt(e){let t=U(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function rt(){U().handleChange()}const W={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(et());if(r!=null&&typeof r!=`function`)throw new Xe(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();tt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function it(e){return typeof e==`function`}function G(e){return nt(t=>{let n=Le.bind(function(e){t.get()!==e&&(t.set(e),rt())});if(t.initialized)return[t.get(),n];let r=it(e)?e():e;return t.set(r),[r,n]})}function at(e,t){nt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&W.queue(e),n.set(t)})}function ot(){return R.platform.startsWith(`win`)?!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask===`{cmd::Cmder}`||R.env.TERM_PROGRAM===`Terminus-Sublime`||R.env.TERM_PROGRAM===`vscode`||R.env.TERM===`xterm-256color`||R.env.TERM===`alacritty`||R.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:R.env.TERM!==`linux`}const st={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},ct={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},lt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},ut={...st,...ct},dt={...st,...lt},K=ot()?ut:dt;Object.entries(ct);const ft={prefix:{idle:V(`blue`,`?`),done:V(`green`,K.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>V(`yellow`,e))},keybindings:[],style:{answer:e=>V(`cyan`,e),message:e=>V(`bold`,e),error:e=>V(`red`,`> ${e}`),defaultAnswer:e=>V(`dim`,`(${e})`),help:e=>V(`dim`,e),highlight:e=>V(`cyan`,e),key:e=>V(`cyan`,V(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:Be()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=gt(t);return at(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return nt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return G({current:e})[0]}function bt(e){let t=yt(e);t.current=e,at(e=>{let n=!1,r=tt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const St=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Dt?St(e.slice(p,n.lastIndex)):n===kt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ft,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=q(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=q(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
1
+ import{i as e,o as t,t as n}from"./chunk-DTipWd-i.mjs";import{Y as r}from"./sleep-DVOInM4H.mjs";import{Go as i,K as a,U as o,os as s,wo as c}from"./src-TKCctdpc.mjs";import{$t as l,Ca as u,En as d,Fr as f,Jr as p,Lr as m,Nr as h,Pr as g,_n as _,br as v,c as y,en as b,fr as x,hn as S,l as C,mn as ee,nr as te,rr as ne,tr as re,u as ie,ur as ae,xr as oe}from"./src-DfRHrkSZ.mjs";import{M as w,P as T}from"./fs-traced-DVpoNaQJ.mjs";import{_ as se,a as ce,b as E,c as le,d as ue,i as de,l as fe,o as D,r as pe,t as me,u as he,v as ge}from"./write-project-skill-D38t_B_r.mjs";import{i as O,n as k,o as A,r as _e,s as j,t as M}from"./colors-BsmVIwfM.mjs";import{t as ve}from"./constants-C2XDlcS1.mjs";import{t as N}from"./is-object-ByG7RnjH.mjs";import{t as ye}from"./preview-DynmdTIr.mjs";import{createRequire as be}from"node:module";import{execFileSync as xe}from"node:child_process";import Se,{dirname as P,isAbsolute as F,join as I,relative as L,resolve as Ce,sep as we}from"node:path";import R from"node:process";import{fileURLToPath as Te}from"node:url";import{existsSync as z,lstatSync as Ee,mkdirSync as De,readFileSync as B,readlinkSync as Oe,realpathSync as ke,statSync as Ae,writeFileSync as je}from"node:fs";import{homedir as Me}from"node:os";import*as Ne from"node:readline";import{inspect as Pe,stripVTControlCharacters as Fe,styleText as V}from"node:util";import{AsyncLocalStorage as Ie,AsyncResource as Le}from"node:async_hooks";const Re=new Set([`emacs`,`vim`]);function ze(e){return Re.has(e)}function Be(){let e=process.env.INQUIRER_KEYBINDINGS;return e?Array.from(new Set(e.toLowerCase().split(/[\s,]+/).filter(ze))):[]}const H=(e,t=[])=>e.name===`up`||t.includes(`vim`)&&e.name===`k`||t.includes(`emacs`)&&e.ctrl&&e.name===`p`,Ve=(e,t=[])=>e.name===`down`||t.includes(`vim`)&&e.name===`j`||t.includes(`emacs`)&&e.ctrl&&e.name===`n`,He=e=>e.name===`space`,Ue=e=>e.name===`backspace`,We=e=>`1234567890`.includes(e.name),Ge=e=>e.name===`enter`||e.name===`return`;var Ke=class extends Error{name=`AbortPromptError`;message=`Prompt was aborted`;constructor(e){super(),this.cause=e?.cause}},qe=class extends Error{name=`CancelPromptError`;message=`Prompt was canceled`},Je=class extends Error{name=`ExitPromptError`},Ye=class extends Error{name=`HookError`},Xe=class extends Error{name=`ValidationError`};const Ze=new Ie;function Qe(e){return{rl:e,hooks:[],hooksCleanup:[],hooksEffect:[],index:0,handleChange(){}}}function $e(e,t){let n=Qe(e);return Ze.run(n,()=>{function e(e){n.handleChange=()=>{n.index=0,e()},n.handleChange()}return t(e)})}function U(){let e=Ze.getStore();if(!e)throw new Ye(`[Inquirer] Hook functions can only be called from within a prompt`);return e}function et(){return U().rl}function tt(e){return Le.bind((...t)=>{let n=U(),r=!1,i=n.handleChange;n.handleChange=()=>{r=!0};let a=e(...t);return r&&i(),n.handleChange=i,a})}function nt(e){let t=U(),{index:n}=t,r=e({get(){return t.hooks[n]},set(e){t.hooks[n]=e},initialized:n in t.hooks});return t.index++,r}function rt(){U().handleChange()}const W={queue(e){let t=U(),{index:n}=t;t.hooksEffect.push(()=>{t.hooksCleanup[n]?.();let r=e(et());if(r!=null&&typeof r!=`function`)throw new Xe(`useEffect return value must be a cleanup function or nothing.`);t.hooksCleanup[n]=r})},run(){let e=U();tt(()=>{e.hooksEffect.forEach(e=>{e()}),e.hooksEffect.length=0})()},clearAll(){let e=U();e.hooksCleanup.forEach(e=>{e?.()}),e.hooksEffect.length=0,e.hooksCleanup.length=0}};function it(e){return typeof e==`function`}function G(e){return nt(t=>{let n=Le.bind(function(e){t.get()!==e&&(t.set(e),rt())});if(t.initialized)return[t.get(),n];let r=it(e)?e():e;return t.set(r),[r,n]})}function at(e,t){nt(n=>{let r=n.get();(!Array.isArray(r)||t.some((e,t)=>!Object.is(e,r[t])))&&W.queue(e),n.set(t)})}function ot(){return R.platform.startsWith(`win`)?!!R.env.CI||!!R.env.WT_SESSION||!!R.env.TERMINUS_SUBLIME||R.env.ConEmuTask===`{cmd::Cmder}`||R.env.TERM_PROGRAM===`Terminus-Sublime`||R.env.TERM_PROGRAM===`vscode`||R.env.TERM===`xterm-256color`||R.env.TERM===`alacritty`||R.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:R.env.TERM!==`linux`}const st={circleQuestionMark:`(?)`,questionMarkPrefix:`(?)`,square:`█`,squareDarkShade:`▓`,squareMediumShade:`▒`,squareLightShade:`░`,squareTop:`▀`,squareBottom:`▄`,squareLeft:`▌`,squareRight:`▐`,squareCenter:`■`,bullet:`●`,dot:`․`,ellipsis:`…`,pointerSmall:`›`,triangleUp:`▲`,triangleUpSmall:`▴`,triangleDown:`▼`,triangleDownSmall:`▾`,triangleLeftSmall:`◂`,triangleRightSmall:`▸`,home:`⌂`,heart:`♥`,musicNote:`♪`,musicNoteBeamed:`♫`,arrowUp:`↑`,arrowDown:`↓`,arrowLeft:`←`,arrowRight:`→`,arrowLeftRight:`↔`,arrowUpDown:`↕`,almostEqual:`≈`,notEqual:`≠`,lessOrEqual:`≤`,greaterOrEqual:`≥`,identical:`≡`,infinity:`∞`,subscriptZero:`₀`,subscriptOne:`₁`,subscriptTwo:`₂`,subscriptThree:`₃`,subscriptFour:`₄`,subscriptFive:`₅`,subscriptSix:`₆`,subscriptSeven:`₇`,subscriptEight:`₈`,subscriptNine:`₉`,oneHalf:`½`,oneThird:`⅓`,oneQuarter:`¼`,oneFifth:`⅕`,oneSixth:`⅙`,oneEighth:`⅛`,twoThirds:`⅔`,twoFifths:`⅖`,threeQuarters:`¾`,threeFifths:`⅗`,threeEighths:`⅜`,fourFifths:`⅘`,fiveSixths:`⅚`,fiveEighths:`⅝`,sevenEighths:`⅞`,line:`─`,lineBold:`━`,lineDouble:`═`,lineDashed0:`┄`,lineDashed1:`┅`,lineDashed2:`┈`,lineDashed3:`┉`,lineDashed4:`╌`,lineDashed5:`╍`,lineDashed6:`╴`,lineDashed7:`╶`,lineDashed8:`╸`,lineDashed9:`╺`,lineDashed10:`╼`,lineDashed11:`╾`,lineDashed12:`−`,lineDashed13:`–`,lineDashed14:`‐`,lineDashed15:`⁃`,lineVertical:`│`,lineVerticalBold:`┃`,lineVerticalDouble:`║`,lineVerticalDashed0:`┆`,lineVerticalDashed1:`┇`,lineVerticalDashed2:`┊`,lineVerticalDashed3:`┋`,lineVerticalDashed4:`╎`,lineVerticalDashed5:`╏`,lineVerticalDashed6:`╵`,lineVerticalDashed7:`╷`,lineVerticalDashed8:`╹`,lineVerticalDashed9:`╻`,lineVerticalDashed10:`╽`,lineVerticalDashed11:`╿`,lineDownLeft:`┐`,lineDownLeftArc:`╮`,lineDownBoldLeftBold:`┓`,lineDownBoldLeft:`┒`,lineDownLeftBold:`┑`,lineDownDoubleLeftDouble:`╗`,lineDownDoubleLeft:`╖`,lineDownLeftDouble:`╕`,lineDownRight:`┌`,lineDownRightArc:`╭`,lineDownBoldRightBold:`┏`,lineDownBoldRight:`┎`,lineDownRightBold:`┍`,lineDownDoubleRightDouble:`╔`,lineDownDoubleRight:`╓`,lineDownRightDouble:`╒`,lineUpLeft:`┘`,lineUpLeftArc:`╯`,lineUpBoldLeftBold:`┛`,lineUpBoldLeft:`┚`,lineUpLeftBold:`┙`,lineUpDoubleLeftDouble:`╝`,lineUpDoubleLeft:`╜`,lineUpLeftDouble:`╛`,lineUpRight:`└`,lineUpRightArc:`╰`,lineUpBoldRightBold:`┗`,lineUpBoldRight:`┖`,lineUpRightBold:`┕`,lineUpDoubleRightDouble:`╚`,lineUpDoubleRight:`╙`,lineUpRightDouble:`╘`,lineUpDownLeft:`┤`,lineUpBoldDownBoldLeftBold:`┫`,lineUpBoldDownBoldLeft:`┨`,lineUpDownLeftBold:`┥`,lineUpBoldDownLeftBold:`┩`,lineUpDownBoldLeftBold:`┪`,lineUpDownBoldLeft:`┧`,lineUpBoldDownLeft:`┦`,lineUpDoubleDownDoubleLeftDouble:`╣`,lineUpDoubleDownDoubleLeft:`╢`,lineUpDownLeftDouble:`╡`,lineUpDownRight:`├`,lineUpBoldDownBoldRightBold:`┣`,lineUpBoldDownBoldRight:`┠`,lineUpDownRightBold:`┝`,lineUpBoldDownRightBold:`┡`,lineUpDownBoldRightBold:`┢`,lineUpDownBoldRight:`┟`,lineUpBoldDownRight:`┞`,lineUpDoubleDownDoubleRightDouble:`╠`,lineUpDoubleDownDoubleRight:`╟`,lineUpDownRightDouble:`╞`,lineDownLeftRight:`┬`,lineDownBoldLeftBoldRightBold:`┳`,lineDownLeftBoldRightBold:`┯`,lineDownBoldLeftRight:`┰`,lineDownBoldLeftBoldRight:`┱`,lineDownBoldLeftRightBold:`┲`,lineDownLeftRightBold:`┮`,lineDownLeftBoldRight:`┭`,lineDownDoubleLeftDoubleRightDouble:`╦`,lineDownDoubleLeftRight:`╥`,lineDownLeftDoubleRightDouble:`╤`,lineUpLeftRight:`┴`,lineUpBoldLeftBoldRightBold:`┻`,lineUpLeftBoldRightBold:`┷`,lineUpBoldLeftRight:`┸`,lineUpBoldLeftBoldRight:`┹`,lineUpBoldLeftRightBold:`┺`,lineUpLeftRightBold:`┶`,lineUpLeftBoldRight:`┵`,lineUpDoubleLeftDoubleRightDouble:`╩`,lineUpDoubleLeftRight:`╨`,lineUpLeftDoubleRightDouble:`╧`,lineUpDownLeftRight:`┼`,lineUpBoldDownBoldLeftBoldRightBold:`╋`,lineUpDownBoldLeftBoldRightBold:`╈`,lineUpBoldDownLeftBoldRightBold:`╇`,lineUpBoldDownBoldLeftRightBold:`╊`,lineUpBoldDownBoldLeftBoldRight:`╉`,lineUpBoldDownLeftRight:`╀`,lineUpDownBoldLeftRight:`╁`,lineUpDownLeftBoldRight:`┽`,lineUpDownLeftRightBold:`┾`,lineUpBoldDownBoldLeftRight:`╂`,lineUpDownLeftBoldRightBold:`┿`,lineUpBoldDownLeftBoldRight:`╃`,lineUpBoldDownLeftRightBold:`╄`,lineUpDownBoldLeftBoldRight:`╅`,lineUpDownBoldLeftRightBold:`╆`,lineUpDoubleDownDoubleLeftDoubleRightDouble:`╬`,lineUpDoubleDownDoubleLeftRight:`╫`,lineUpDownLeftDoubleRightDouble:`╪`,lineCross:`╳`,lineBackslash:`╲`,lineSlash:`╱`},ct={tick:`✔`,info:`ℹ`,warning:`⚠`,cross:`✘`,squareSmall:`◻`,squareSmallFilled:`◼`,circle:`◯`,circleFilled:`◉`,circleDotted:`◌`,circleDouble:`◎`,circleCircle:`ⓞ`,circleCross:`ⓧ`,circlePipe:`Ⓘ`,radioOn:`◉`,radioOff:`◯`,checkboxOn:`☒`,checkboxOff:`☐`,checkboxCircleOn:`ⓧ`,checkboxCircleOff:`Ⓘ`,pointer:`❯`,triangleUpOutline:`△`,triangleLeft:`◀`,triangleRight:`▶`,lozenge:`◆`,lozengeOutline:`◇`,hamburger:`☰`,smiley:`㋡`,mustache:`෴`,star:`★`,play:`▶`,nodejs:`⬢`,oneSeventh:`⅐`,oneNinth:`⅑`,oneTenth:`⅒`},lt={tick:`√`,info:`i`,warning:`‼`,cross:`×`,squareSmall:`□`,squareSmallFilled:`■`,circle:`( )`,circleFilled:`(*)`,circleDotted:`( )`,circleDouble:`( )`,circleCircle:`(○)`,circleCross:`(×)`,circlePipe:`(│)`,radioOn:`(*)`,radioOff:`( )`,checkboxOn:`[×]`,checkboxOff:`[ ]`,checkboxCircleOn:`(×)`,checkboxCircleOff:`( )`,pointer:`>`,triangleUpOutline:`∆`,triangleLeft:`◄`,triangleRight:`►`,lozenge:`♦`,lozengeOutline:`◊`,hamburger:`≡`,smiley:`☺`,mustache:`┌─┐`,star:`✶`,play:`►`,nodejs:`♦`,oneSeventh:`1/7`,oneNinth:`1/9`,oneTenth:`1/10`},ut={...st,...ct},dt={...st,...lt},K=ot()?ut:dt;Object.entries(ct);const ft={prefix:{idle:V(`blue`,`?`),done:V(`green`,K.tick)},spinner:{interval:80,frames:[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`].map(e=>V(`yellow`,e))},keybindings:[],style:{answer:e=>V(`cyan`,e),message:e=>V(`bold`,e),error:e=>V(`red`,`> ${e}`),defaultAnswer:e=>V(`dim`,`(${e})`),help:e=>V(`dim`,e),highlight:e=>V(`cyan`,e),key:e=>V(`cyan`,V(`bold`,`<${e}>`))}};function pt(){return{...ft,keybindings:Be()}}function mt(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ht(...e){let t={};for(let n of e)for(let[e,r]of Object.entries(n)){let n=t[e];t[e]=mt(n)&&mt(r)?ht(n,r):r}return t}function gt(...e){return ht(pt(),...e.filter(e=>e!=null))}function _t({status:e=`idle`,theme:t}){let[n,r]=G(!1),[i,a]=G(0),{prefix:o,spinner:s}=gt(t);return at(()=>{if(e===`loading`){let e,t=-1,n=setTimeout(()=>{r(!0),e=setInterval(()=>{t+=1,a(t%s.frames.length)},s.interval)},300);return()=>{clearTimeout(n),clearInterval(e)}}else r(!1)},[e]),n?s.frames[i]:typeof o==`string`?o:o[e===`loading`?`idle`:e]??o.idle}function vt(e,t){return nt(n=>{let r=n.get();if(!r||r.dependencies.length!==t.length||r.dependencies.some((e,n)=>e!==t[n])){let r=e();return n.set({value:r,dependencies:t}),r}return r.value})}function yt(e){return G({current:e})[0]}function bt(e){let t=yt(e);t.current=e,at(e=>{let n=!1,r=tt((r,i)=>{n||t.current(i,e)});return e.input.on(`keypress`,r),()=>{n=!0,e.input.removeListener(`keypress`,r)}},[])}var xt=t(n(((t,n)=>{n.exports=i;function r(t){let n={defaultWidth:0,output:process.stdout,tty:e(`tty`)};return t?(Object.keys(n).forEach(function(e){t[e]||(t[e]=n[e])}),t):n}function i(e){let t=r(e);if(t.output.getWindowSize)return t.output.getWindowSize()[0]||t.defaultWidth;if(t.tty.getWindowSize)return t.tty.getWindowSize()[1]||t.defaultWidth;if(t.output.columns)return t.output.columns;if(process.env.CLI_WIDTH){let e=parseInt(process.env.CLI_WIDTH,10);if(!isNaN(e)&&e!==0)return e}return t.defaultWidth}}))(),1);const St=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),Ct=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,wt=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,Tt=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,Et=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,Dt=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,Ot=/\t{1,1000}/y,kt=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,At=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,jt=/\p{M}+/gu,Mt={limit:1/0,ellipsis:``},Nt=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Nt(i,Mt,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[At,l],[Tt,0],[Et,o],[Ot,s],[kt,c],[Dt,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(jt,``)){let t=e.codePointAt(0)||0;if(S=Ct(t)?2:wt(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===Dt?St(e.slice(p,n.lastIndex)):n===kt?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Pt={limit:1/0,ellipsis:``,ellipsisWidth:0},q=(e,t={})=>Nt(e,Pt,t).width,Ft=`]8;;`,It=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ft}(?<uri>.*))`,`y`),Lt=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Rt=e=>`[${e}m`,zt=e=>`${Ft}${e}`,Bt=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:q(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=q(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ft,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},Vt=e=>{let t=e.split(` `),n=t.length;for(;n&&!q(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ht=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=q(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=q(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Bt(s,r,t),c=q(s.at(-1)??``);continue}if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Bt(s,r,t),c=q(s.at(-1)??``);continue}s.push(``),c=0}if(c+i>t&&n.wordWrap===!1){Bt(s,r,t),c=q(s.at(-1)??``);continue}s[s.length-1]+=r,c+=i}n.trim!==!1&&(s=s.map(e=>Vt(e)));let l=s.join(`
2
2
  `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){It.lastIndex=e+1;let t=It.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
3
3
  `){a&&(r+=zt(``));let e=i?Lt(i):void 0;i&&e&&(r+=Rt(e))}else t===`
4
4
  `&&(i&&Lt(i)&&(r+=Rt(i)),a&&(r+=zt(a)))}return r},Ut=/\r?\n/;function Wt(e,t,n){return String(e).normalize().split(Ut).map(e=>Ht(e,t,n)).join(`
@@ -633,6 +633,6 @@ export default function okBridge(pi: {
633
633
  `));let f=`${a?``:``}${u}`;return f!==i&&T(e,f,{mode:Hn(e)}),{kind:l?`overwritten`:`written`}}const bi=e=>e!==`project`,xi=e=>e!==`user`;async function Si(){let e=await Zn({message:`Where should the MCP server be configured?
634
634
  `,required:!1,theme:{icon:{checked:`[x]`,unchecked:`[ ]`}},choices:[{name:`User-level (~/.claude.json, ~/.cursor/mcp.json, …)`,value:`user`,checked:!0},{name:`Project-level (.mcp.json, .cursor/mcp.json, …)`,value:`project`,checked:!0}]});return e.includes(`user`)&&e.includes(`project`)?`both`:e.includes(`user`)?`user`:e.includes(`project`)?`project`:null}async function Ci(e){return e.mcp===!1?null:e.scope?e.scope:e.isTTY??process.stdout.isTTY?(e.promptFn??Si)():`both`}async function wi(e){return nr({message:`How do you want to handle OpenKnowledge config files (.ok/, .mcp.json, project skills)?`,default:e,choices:[{name:`Share with my team (commit alongside content)`,value:`shared`,description:`OK config gets committed alongside your project content.`},{name:`Local only (keep out of git via .git/info/exclude)`,value:`local-only`,description:"OK config stays on this machine only; teammates do not see it. Safe escape hatch via `ok config-sharing share`."}]})}async function Ti(e){if(e.sharing!==void 0)return e.sharing;let t=kn(e.projectRoot)===`local-only`?`local-only`:`shared`;return e.isTTY??process.stdout.isTTY?(e.promptFn??wi)(t):t}var $=class extends Error{constructor(e){super(e),this.name=`ContentDirError`}};function Ei(e){if(e===void 0||e===!0)return new Set(oe);if(e===!1)return new Set;let t=e.split(`,`).map(e=>e.trim()).filter(Boolean);return new Set(oe.filter(e=>t.includes(e)))}function Di(e,t,n){let r=Ce(n,e),i;try{i=Ae(r)}catch(e){let t=e.code;throw t===`ENOENT`?new $(`--content-dir path does not exist: ${r}`):new $(`--content-dir path is not accessible (${t??`unknown error`}): ${r}`)}if(!i.isDirectory())throw new $(`--content-dir must be a directory: ${r}`);let a=L(Oi(t),Oi(r));if(a.startsWith(`..`)||F(a))throw new $(`--content-dir must be inside the project root (${t}); got ${r}`);return a===``?`.`:a}function Oi(e){try{return ke(e)}catch{return e}}const ki=`open-knowledge-ui`;function Ai(e,t,n){try{return z(e.detectPath?.(t,n)??P(e.configPath(t,n)))}catch{return!1}}function ji(e,t,n,r,i){let a=e.serverName(t),o;try{o=i??e.configPath(t,r)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:``,serverName:a,error:t instanceof Error?t.message:String(t)}}let s=!n.skipAvailabilityCheck||e.offerOnlyWhenDetected===!0;if(!i&&s&&!Ai(e,t,r))return{editorId:e.id,label:e.label,action:`skipped-missing`,configPath:o,serverName:a};if(i!==void 0)try{me(o,t)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),configScope:`project`}}if(e.format===`file`)return Ni(e,o,a,n,{isProjectScope:i!==void 0});let c;try{c=e.buildEntry(t,n)}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}try{De(P(o),{recursive:!0})}catch(t){return{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:t instanceof Error?t.message:String(t),...i===void 0?{}:{configScope:`project`}}}let l={action:`written`},u;try{w(`${o}.lock`,()=>{let t=Yr(o).writePath;if(De(P(t),{recursive:!0}),e.format===`toml`){let n=vi(ri(),t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}if(e.format===`yaml`){let n=yi(t,e.topLevelKey,a,c);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason);return}let n=_i(t,e.topLevelKey,a,c,e.serverMapSubKey);l.action=n.kind,n.kind===`declined`&&(l.declineReason=n.reason)},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){u=e instanceof Error?e:Error(String(e))}return u?{editorId:e.id,label:e.label,action:`failed`,configPath:o,serverName:a,error:u.message,...i===void 0?{}:{configScope:`project`}}:l.action===`declined`?{editorId:e.id,label:e.label,action:`declined`,configPath:o,serverName:a,declineReason:l.declineReason,...i===void 0?{}:{configScope:`project`}}:{editorId:e.id,label:e.label,action:l.action,configPath:o,serverName:a,...i===void 0?{}:{configScope:`project`}}}const Mi={pi:Lr};function Ni(e,t,n,r,i){let a=i.isProjectScope?{configScope:`project`}:{},o=r=>({editorId:e.id,label:e.label,action:`failed`,configPath:t,serverName:n,error:r instanceof Error?r.message:String(r),...a}),s=Mi[e.id];if(!s)return o(Error(`No managed-file builder registered for editor "${e.id}" (format: 'file' targets need a MANAGED_FILE_BUILDERS entry).`));let c;try{c=s(r)}catch(e){return o(e)}try{De(P(t),{recursive:!0})}catch(e){return o(e)}let l={action:`written`};try{w(`${t}.lock`,()=>{let e=null;try{e=B(t,`utf-8`)}catch{e=null}if(e===c){l.action=`overwritten`;return}T(t,c,e===null?void 0:{mode:Hn(t)}),l.action=e===null?`written`:`overwritten`},{onWarn:(e,t)=>process.stderr.write(`[ok] ${e} ${JSON.stringify(t)}\n`)})}catch(e){return o(e)}return{editorId:e.id,label:e.label,action:l.action,configPath:t,serverName:n,...a}}function Pi(e,t){let n=e.projectConfigPath?.(t);if(!(!n||!z(n)))return{editorId:e.id,label:e.label,path:n}}function Fi(e,t,n,r){let i=Li(e,t,n,r);return i.kind===`present`?i.entry:null}function Ii(e,t,n,r){let i=gi(e,t,r);if(!N(i))return{kind:`no-entry`};let a=i[n];return N(a)?{kind:`present`,entry:a}:{kind:`no-entry`}}function Li(e,t,n,r){let i;try{i=r??e.configPath(t,n)}catch{return{kind:`absent`}}if(!z(i))return{kind:`absent`};try{if(Ae(i).size>di)return{kind:`decline`,reason:`oversize`}}catch{return{kind:`decline`,reason:`unparseable`}}let a;try{a=B(i,`utf-8`)}catch{return{kind:`decline`,reason:`unparseable`}}if(a.trim()===``)return{kind:`absent`};if(e.format===`file`)return{kind:`present`,entry:Ir(a)};let o=e.serverName(t);if(e.format===`toml`){let t;try{t=ri().parseToObject(a)}catch{return{kind:`decline`,reason:`unparseable`}}return Ii(t,e.topLevelKey,o,e.serverMapSubKey)}if(e.format===`yaml`){let t=(0,Cn.parseDocument)(a.charCodeAt(0)===65279?a.slice(1):a);return t.errors.length>0?{kind:`decline`,reason:`unparseable`}:Ii(t.toJS()??{},e.topLevelKey,o,e.serverMapSubKey)}let s=oi(a);return s?si(s,e.topLevelKey)>1?{kind:`decline`,reason:`duplicate-container`}:Ii(g(s),e.topLevelKey,o,e.serverMapSubKey):{kind:`decline`,reason:`unparseable`}}async function Ri(e={}){let t=Ce(e.cwd??process.cwd()),n=Vr(t,{homeDir:e.home}),r=n.projectRoot,i=!z(I(r,`.ok`)),a=n.gitRootPromoted?L(r,t):void 0,o=e.contentDir===void 0?n.defaultContentDir:Di(e.contentDir,r,t);n.ancestorPromoted?console.log(`[ok] Opened existing project at ${r}`):n.gitRootPromoted&&i&&o===`.`&&process.stderr.write(`${j(`[ok] Content scope promoted to the git repo root: ${r}`)}\n Ran in ${a}/, but .ok/ lives at the git root (one .ok/ per git repo),\n so the whole repo is now the content scope. To narrow it, re-run with\n \`ok init --content-dir .\`, or set content.dir: ${a} in .ok/config.yml.\n`);let s={mode:e.devMcp?`dev`:`published`},l=await ie(r),u;try{u=S(r,{contentDir:o})}catch(t){let i=D.claude.configPath(r,e.home);return{projectRoot:r,contentCreated:[],contentUpdated:[],contentSkipped:[],editors:[],projectSkills:[],legacyProjectConfigs:[],didGitInit:l.didInit,rootGitignoreCreated:!1,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDirRequested:e.contentDir,contentScaffoldFailed:!0,mcpAction:`failed`,mcpPath:i,mcpError:`Content scaffolding failed: ${t instanceof Error?t.message:String(t)}`,sharing:{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:!1}}}let d=u.created.includes(ve),f=!1;if(l.didInit)try{f=_(r)===`created`}catch(e){console.warn(`[ok] Skipping .gitignore seed at ${r}: ${e instanceof Error?e.message:String(e)}`)}try{ee(r)}catch(e){console.warn(`[ok] Skipping project-skill .gitignore entry at ${r}: ${e instanceof Error?e.message:String(e)}`)}let p=await y(r);p.kind===`untracked`&&console.warn(`[ok] Untracked the OpenKnowledge project skill (${p.dirs.join(`, `)}) — it is now local-only. Teammates will see this as a deletion on their next pull.`);let m=await Ci({scope:e.scope,mcp:e.mcp,isTTY:e.isTTY,promptFn:e.promptFn}),h=e.editors??Wi(r,e.home),g=e.editors??de.filter(e=>D[e].projectConfigPath!==void 0||D[e].projectSkillPath!==void 0),b=se(h),C=se(g),w=e.mcp===!1||m===null,T=Array.from(new Map([...b,...w?[]:C].map(e=>[e.id,e])).values()),ce=b.filter(t=>Ai(t,r,e.home)),E=[],le=[],ue=new Set;for(let t of T){if(w){let n=``;try{n=t.configPath(r,e.home)}catch{}E.push({editorId:t.id,label:t.label,action:`skipped-flag`,configPath:n,serverName:t.serverName(r)});continue}if(bi(m)&&b.includes(t)&&t.scope===`global`&&E.push(ji(t,r,s,e.home)),xi(m)&&C.includes(t)&&t.projectConfigPath){let n=t.projectConfigPath(r),i=ji(t,r,s,e.home,n);E.push(i),(i.action===`written`||i.action===`overwritten`)&&ue.add(n)}}let fe=new Set;for(let t of C){let n=t.projectSkillPath?.(r);!n||fe.has(n)||(fe.add(n),le.push(pe(t,r,{home:e.home})))}let me=le.filter(e=>e.action===`written`||e.action===`overwritten`).map(e=>e.editorId);if(me.length>0){let t=e.home??Me();ne({source:c,skills:[v.project],agents:me,scope:r},{home:t,enabled:x(t).enabled})}let he=!w&&m!==null&&xi(m)?C.filter(e=>!e.projectConfigPath&&!e.projectSkillPath).map(e=>e.label):void 0,ge=w?[]:ce.map(e=>Pi(e,r)).filter(e=>e!==void 0).filter(e=>!ue.has(e.path)),O=e.installUserSkill??te,k=e.home??Me(),A=Ei(e.skills),_e=!1,M=!1,N=!1,ye=!1,be=!1;for(let t of oe){if(!A.has(t))continue;await ae(k,v[t],!0).catch(()=>{}),_e=!0;let n=await O({home:e.home,bundleId:t,force:!0});n===`installed`?M=!0:n===`failed`?N=!0:n===`no-hosts`?be=!0:ye=!0}let xe=N?`failed`:M?`installed`:_e&&ye?`skip-current`:_e&&be?`no-hosts`:`declined`,Se=M?re(k).map(e=>e.editorId):[],P=w?`skipped-flag`:`skipped-missing`,F=E.find(e=>e.editorId===`claude`)??E[0]??{action:P,configPath:D.claude.configPath(r,e.home)},we=await zi({projectRoot:r,desiredMode:await Ti({sharing:e.sharing,projectRoot:r,isTTY:e.isTTY,promptFn:e.sharingPromptFn}),explicitFlag:e.sharing});return{projectRoot:r,contentCreated:u.created,contentUpdated:u.updated,contentSkipped:u.skipped,editors:E,projectSkills:le,legacyProjectConfigs:ge,skillInstall:xe,skillHosts:Se,didGitInit:l.didInit,rootGitignoreCreated:f,gitRootPromoted:n.gitRootPromoted,promotedFromDir:a,contentDir:d?o:void 0,contentDirRequested:e.contentDir,contentScaffoldFailed:!1,mcpAction:F.action,mcpPath:F.configPath,mcpError:`error`in F?F.error:void 0,projectScopeUnsupportedLabels:he,sharing:we}}async function zi(e){let{projectRoot:t,desiredMode:n,explicitFlag:r}=e,i=kn(t);if(i===`no-git`)return{kind:`no-exclude`,reason:`no-git`,localOnlyRequested:r===`local-only`};let a=En(t);if(n===`local-only`){let e=Dn(t,a);if(e.kind===`refused-tracked`){let t=e;return{kind:`refused-tracked`,tracked:t.tracked,remediation:t.remediation}}return e.kind===`no-exclude`?{kind:`no-exclude`,reason:e.reason,localOnlyRequested:r===`local-only`}:Bi(t,e,`add`)}if(i===`shared`)return{kind:`applied`,mode:`shared`,action:`noop`,appended:[],alreadyPresent:[],removed:[]};let o=On(t,a);return o.kind===`no-exclude`?{kind:`no-exclude`,reason:o.reason,localOnlyRequested:!1}:Bi(t,o,`remove`)}function Bi(e,t,n){let r=kn(e);return n===`add`?{kind:`applied`,mode:r,action:t.appended.length>0?`added`:`noop`,appended:t.appended,alreadyPresent:t.alreadyPresent,removed:[]}:{kind:`applied`,mode:r,action:`removed`,appended:[],alreadyPresent:[],removed:t.removed}}function Vi(e){switch(e){case`oversize`:return`config too large to edit safely`;case`duplicate-container`:return`duplicate server block`;case`no-native-writer`:return`no format-preserving writer available`;default:return`config not readable`}}function Hi(e,t){let n=[],r=e.editors.some(e=>e.action===`written`||e.action===`overwritten`),i=e.editors.some(e=>e.action===`failed`)||e.projectSkills.some(e=>e.action===`failed`),a=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-flag`),o=e.editors.length>0&&e.editors.every(e=>e.action===`skipped-missing`);e.didGitInit&&n.push(`Initialized git repo at ${t}/.git/ (default branch: main)`),e.rootGitignoreCreated&&n.push(`Seeded .gitignore at ${t}/.gitignore (.DS_Store)`);let s=I(t,`.ok`);if(e.contentCreated.length>0||e.contentUpdated.length>0?(n.push(M(`Content scaffolded at ${s}/`)),e.contentCreated.length>0&&n.push(` Created: ${e.contentCreated.join(`, `)}`),e.contentUpdated.length>0&&n.push(` Updated: ${e.contentUpdated.join(`, `)}`)):n.push(M(`Content already present at ${s}/`)),e.contentSkipped.length>0&&n.push(` Skipped (already exist): ${e.contentSkipped.join(`, `)}`),n.push(``),e.mcpError&&e.editors.length===0)n.push(`Warning: ${e.mcpError}`);else if(e.editors.length===0)if(n.push(M(`MCP server configuration:`)),e.mcpAction===`skipped-flag`)n.push(` MCP config not written — use without --no-mcp to configure editors`);else if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}else n.push(` No supported editor config directories detected; skipped MCP registration`);else if(a)n.push(`MCP config not written — use without --no-mcp to configure editors`);else if(o)n.push(M(`MCP server configuration:`)),n.push(` No supported editor config directories detected; skipped MCP registration`);else{n.push(M(`MCP server configuration:`));for(let r of e.editors){let e=r.configPath.startsWith(t)?L(t,r.configPath):r.configPath.replace(/^\/Users\/[^/]+/,`~`),i=r.serverName===`open-knowledge`?``:` (${r.serverName})`,a=r.configScope===`project`?` (project)`:``,o=`${r.label}${a}`,s=` `.repeat(Math.max(1,20-o.length)),c=r.editorId===`claude-desktop`&&(r.action===`written`||r.action===`overwritten`)?` — quit and relaunch Claude Desktop to activate`:``;switch(r.action){case`written`:n.push(` ${o}${s}${e} ${A(`registered`)}${i}${c}`);break;case`overwritten`:n.push(` ${o}${s}${e} ${A(`updated`)}${i}${c}`);break;case`skipped-missing`:n.push(` ${o}${s}${e} config root missing; skipped`);break;case`failed`:n.push(` ${o}${s}${e} ${_e(`FAILED`)}: ${r.error}`);break;case`declined`:n.push(` ${o}${s}${e} left unchanged (${Vi(r.declineReason)})`);break;case`skipped-flag`:break;default:r.action}}if(e.projectScopeUnsupportedLabels&&e.projectScopeUnsupportedLabels.length>0){let t=e.projectScopeUnsupportedLabels.join(`, `),r=e.projectScopeUnsupportedLabels.length===1?`does`:`do`;n.push(` ${t} ${r} not support project-level config; skipped`)}}if(e.projectSkills.length>0){n.push(``),n.push(M(`Project-local skills:`));for(let r of e.projectSkills){let e=`${r.label} (project)`,i=` `.repeat(Math.max(1,20-e.length)),a=r.path?L(t,r.path):``;switch(r.action){case`written`:n.push(` ${e}${i}${a} ${A(`installed`)}`);break;case`overwritten`:n.push(` ${e}${i}${a} ${A(`updated`)}`);break;case`skipped-unsupported`:n.push(` ${e}${i}no known project skill surface; skipped`);break;case`skipped-prerequisite`:n.push(` ${e}${i}OpenKnowledge MCP is not configured; skipped`);break;case`failed`:n.push(` ${e}${i}${a} ${_e(`FAILED`)}: ${r.error}`);break}}}if(i&&(n.push(``),n.push(`For failed editors, add the MCP server entry or project skill manually. See:`),n.push(` https://github.com/inkeep/open-knowledge#mcp-setup`)),e.legacyProjectConfigs.length>0){n.push(``),n.push(`Project MCP configs found:`);for(let r of e.legacyProjectConfigs)n.push(` ${r.label} ${L(t,r.path)}`);n.push(` These project-local files may override the global config. Remove them if you want fully user-scoped MCP setup in this project.`)}if(e.skillInstall)switch(n.push(``),n.push(M(`User-global skill:`)),e.skillInstall){case`installed`:{let t=(e.skillHosts??[]).map(e=>ce[e]??e),r=t.length>0?t.join(`, `):`the shared ~/.agents store`;n.push(` open-knowledge ${A(`installed for ${r}`)}`),n.push(` ${k(`Counted on skills.sh (skill name + source repo, once per machine).`)}`),n.push(` ${k(`Opt out: DO_NOT_TRACK=1, or Settings → Preferences.`)}`);break}case`skip-current`:n.push(` open-knowledge ${A(`already installed at current version`)}`);break;case`declined`:n.push(` open-knowledge ${k(`skipped for this run (--no-skills)`)}`),n.push(` ${k(`Nothing was installed or removed. Any built-in skills already on this`)}`),n.push(` ${k(`machine are untouched. Run init without the flag to install them:`)}`),n.push(` ${k(` ok init`)}`);break;case`no-hosts`:n.push(` open-knowledge ${k(`skipped — no supported agent host detected in your home directory`)}`);break;case`failed`:n.push(` ${j(`open-knowledge install failed — MCP still configured; retry with:`)}`),n.push(` ${j(` ok repair-skills`)}`);break}if(e.contentDirRequested!==void 0&&e.contentDir===void 0&&!e.contentScaffoldFailed?(n.push(``),n.push(j(`⚠ --content-dir ${e.contentDirRequested} ignored — .ok/config.yml already exists`)),n.push(` Edit .ok/config.yml → content.dir directly to change the content scope.`)):e.contentDir!==void 0&&e.contentDir!==`.`?(n.push(``),n.push(`Content scope set to ${e.contentDir}/ (content.dir in .ok/config.yml).`)):e.gitRootPromoted&&e.contentDir===`.`&&e.contentDirRequested===void 0&&(n.push(``),n.push(j(`⚠ Content scope promoted to the git repo root`)),n.push(` .ok/ was initialized at ${t} because it contains a .git folder (one .ok/ per git repo),`),n.push(` not the sub-folder you ran \`ok init\` in${e.promotedFromDir?` (${e.promotedFromDir})`:``}. The whole repo is now the content scope.`),e.promotedFromDir&&(n.push(" To scope to just that sub-folder, re-run `ok init --content-dir .` from there, or set"),n.push(` content.dir: ${e.promotedFromDir} in .ok/config.yml.`))),e.preview?(n.push(``),n.push(ye(e.preview,t))):e.previewWarning&&(n.push(``),n.push(`Content preview unavailable: ${e.previewWarning}`)),n.push(``),n.push(...qi(e.sharing,t)),r){let t=new Set,r=e.editors.filter(e=>e.action===`written`||e.action===`overwritten`).filter(e=>!t.has(e.editorId)&&t.add(e.editorId)).map(e=>e.label);n.push(``),n.push(`${A(`✓`)} ${M(`Next steps:`)}`),n.push(` 1. Open your editor (${O(r.join(` / `))})`),n.push(` 2. Approve the MCP server when prompted`),n.push(` 3. (Optional) scaffold the starter knowledge-base structure:`),n.push(` - ${O(`ok seed --list-packs`)} — browse the starter packs`),n.push(` - ${O(`ok seed`)} — scaffold an empty repo`),n.push(` 4. Ask your agent to capture a source, research a topic, or build a wiki —`),n.push(` the procedures ship as skills alongside the MCP tools.`)}return n.join(`
635
635
  `)}function Ui(e,t){return{projectRoot:e.projectRoot,gitRootPromoted:e.gitRootPromoted,promotedFromDir:e.promotedFromDir??null,contentDir:t.contentDir,contentDirRequested:e.contentDirRequested??null,contentDirApplied:e.contentDir!==void 0,contentFileCount:t.contentFileCount,previewError:e.previewWarning??null,didGitInit:e.didGitInit,mcpAction:e.mcpAction,editors:e.editors.map(e=>({editorId:e.editorId,label:e.label,action:e.action,configPath:e.configPath,scope:e.configScope===`project`?`project`:`user`}))}}function Wi(e,t){let n=[];for(let r of de)Ai(D[r],e,t)&&n.push(r);return n}function Gi(){let e={log:console.log,info:console.info,debug:console.debug},t=(...e)=>{process.stderr.write(`${e.map(e=>typeof e==`string`?e:Pe(e)).join(` `)}\n`)};return console.log=t,console.info=t,console.debug=t,()=>{console.log=e.log,console.info=e.info,console.debug=e.debug}}function Ki(){return new ge(`init`).description(`Scaffold .ok/ in the current directory and register the MCP server for your editor(s)`).option(`--mcp`,`Register the MCP server for selected editors (default: true)`,!0).option(`--no-mcp`,`Scaffold the .ok/ directory but do not touch MCP config`).option(`--dev-mcp`,`Register a local dev MCP entry using node + packages/cli/dist/cli.mjs with debug logging`).option(`--content-dir <dir>`,`Limit content to <dir> instead of the whole project. <dir> is interpreted relative to your current directory (e.g. "." = the folder you run the command in), then saved to .ok/config.yml as content.dir.`).option(`--json`,`Emit a structured JSON summary to stdout (diagnostics stay on stderr)`).option(`--skills <ids>`,`Install only the named user-global skill bundles (comma list: discovery,write-skill)`).option(`--no-skills`,`Do not install any user-global skill bundles`).addOption(new E(`--scope <scope>`,`Write MCP config at user level, project level, or both`).choices([`user`,`project`,`both`])).addOption(new E(`--shared`,`Commit OK config alongside content (the default for fresh repos)`).conflicts(`localOnly`)).addOption(new E(`--local-only`,`Keep OK config out of git via .git/info/exclude (per-clone, not committed)`).conflicts(`shared`)).action(async e=>{let t=process.cwd(),n=e.shared?`shared`:e.localOnly?`local-only`:void 0,r=e.json?Gi():null;try{let r;try{r=await Ri({cwd:t,mcp:e.mcp,devMcp:e.devMcp,scope:e.scope,sharing:n,contentDir:e.contentDir,skills:e.skills})}catch(e){if(e instanceof $){process.stderr.write(`${e.message}\n`),process.exitCode=64;return}if(e instanceof l||e instanceof b){process.stderr.write(`${e.message}\n`),process.exitCode=78;return}if(e instanceof C){process.stderr.write(`open-knowledge could not initialize a git repo for this project. Re-run, or run 'git init' yourself in the project folder.
636
- `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-C7VKSyMe.mjs`),{resolveContentDir:s}=await import(`./src-B_Esv3oA.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-6qIUkP7f.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Ui(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Hi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function qi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
636
+ `),e.stderr&&process.stderr.write(`${e.stderr.trim()}\n`),process.exitCode=1;return}throw e}let i=r.contentDir??`.`,a=null,{loadConfig:o}=await import(`./loader-s1KEG5BC.mjs`),{resolveContentDir:s}=await import(`./src-B_Esv3oA.mjs`),c;try{c=o(r.projectRoot).config,i=c.content.dir}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}if(c)try{let{previewContent:e}=await import(`./preview-CvAKccSM.mjs`),t=s(c,r.projectRoot);r.preview=e({projectDir:r.projectRoot,contentDir:t}),a=r.preview.totalCount}catch(e){r.previewWarning=e instanceof Error?e.message:String(e)}e.json?process.stdout.write(`${JSON.stringify(Ui(r,{contentDir:i,contentFileCount:a}),null,2)}\n`):process.stdout.write(`${Hi(r,r.projectRoot)}\n`),(r.editors.some(e=>e.action===`failed`)||r.mcpAction===`failed`)&&(process.exitCode=1)}finally{r?.()}})}function qi(e,t){let n=[];switch(e.kind){case`applied`:return n.push(M(`Sharing mode:`)),e.mode===`local-only`?e.action===`added`?n.push(` ${A(`local-only`)} — appended ${e.appended.length} path(s) to ${M(`${t}/.git/info/exclude`)} (per-clone, not committed).`):e.action===`noop`&&e.alreadyPresent.length>0?n.push(` ${A(`local-only`)} — already excluded; nothing to do.`):n.push(` ${A(`local-only`)}`):e.action===`removed`?n.push(` ${A(`shared`)} — removed OK paths from ${M(`${t}/.git/info/exclude`)}; commit the files to share with teammates.`):n.push(` ${A(`shared`)} — OK config will be committed alongside content.`),n;case`refused-tracked`:n.push(j(`Sharing mode: switch to local-only deferred`));for(let t of e.remediation.split(`
637
637
  `))n.push(t.length>0?` ${t}`:``);return n.push(` Re-run ${O(`ok config-sharing unshare`)} after resolving to complete the switch.`),n;case`no-exclude`:if(e.localOnlyRequested)n.push(j(`Sharing mode: --local-only requested but no git repo found — option ignored`)),n.push(` Run ${O(`git init`)} (or open this folder via OK Desktop, which can scaffold a repo) and then ${O(`ok config-sharing unshare`)}.`);else if(e.reason===`no-git`)return[];else n.push(j(`Sharing mode unavailable: ${e.reason}.`));return n}}export{En as A,G as B,Zn as C,Dn as D,Un as E,Sn as F,un as I,bt as L,kn as M,jn as N,Nn as O,On as P,_t as R,nr as S,Vn as T,Ge as V,mi as _,Ui as a,Vr as b,Hi as c,Fi as d,Ei as f,Ri as g,Ti as h,zi as i,Mn as j,An as k,qi as l,Di as m,ki as n,Li as o,Ci as p,Mi as r,Wi as s,$ as t,Ki as u,ji as v,Hn as w,Fr as x,ri as y,gt as z};
638
- //# sourceMappingURL=init-BUIEpJX9.mjs.map
638
+ //# sourceMappingURL=init-D1zZSW1w.mjs.map
@@ -1,2 +1,2 @@
1
- import{Lr as e,Pr as t}from"./src-DfRHrkSZ.mjs";import{P as n}from"./fs-traced-DVpoNaQJ.mjs";import{E as r,w as i}from"./init-BUIEpJX9.mjs";import{t as a}from"./is-object-ByG7RnjH.mjs";import{join as o}from"node:path";import{existsSync as s,readFileSync as c,rmSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(f){let p=o(f,`.claude`,`launch.json`);if(!s(p))return{kind:`not-present`};let m;try{m=c(p,`utf-8`)}catch{return{kind:`declined`}}let h=[],g=e(m,h,u)??void 0;if(h.some(e=>!d(e,m))||!g||g.type!==`object`)return{kind:`declined`};let _=t(g).configurations;if(!Array.isArray(_))return{kind:`not-present`};let v=_.findIndex(e=>a(e)&&e.name===`open-knowledge-ui`);if(v===-1)return{kind:`not-present`};if(_.length===1)return l(p,{force:!0}),{kind:`removed-file`};let{text:y,changed:b}=r(m,[`configurations`,v]);return b?(n(p,y,{mode:i(p)}),{kind:`removed`}):{kind:`not-present`}}export{f as t};
2
- //# sourceMappingURL=launch-json-removal-DqWNMLcl.mjs.map
1
+ import{Lr as e,Pr as t}from"./src-DfRHrkSZ.mjs";import{P as n}from"./fs-traced-DVpoNaQJ.mjs";import{E as r,w as i}from"./init-D1zZSW1w.mjs";import{t as a}from"./is-object-ByG7RnjH.mjs";import{join as o}from"node:path";import{existsSync as s,readFileSync as c,rmSync as l}from"node:fs";const u={allowTrailingComma:!0,disallowComments:!1};function d(e,t){return e.error===1&&e.offset===0&&t.charCodeAt(0)===65279}function f(f){let p=o(f,`.claude`,`launch.json`);if(!s(p))return{kind:`not-present`};let m;try{m=c(p,`utf-8`)}catch{return{kind:`declined`}}let h=[],g=e(m,h,u)??void 0;if(h.some(e=>!d(e,m))||!g||g.type!==`object`)return{kind:`declined`};let _=t(g).configurations;if(!Array.isArray(_))return{kind:`not-present`};let v=_.findIndex(e=>a(e)&&e.name===`open-knowledge-ui`);if(v===-1)return{kind:`not-present`};if(_.length===1)return l(p,{force:!0}),{kind:`removed-file`};let{text:y,changed:b}=r(m,[`configurations`,v]);return b?(n(p,y,{mode:i(p)}),{kind:`removed`}):{kind:`not-present`}}export{f as t};
2
+ //# sourceMappingURL=launch-json-removal-83o3EGTO.mjs.map
@@ -1,2 +1,2 @@
1
- import{Y as e,c as t,d as n,o as r,s as i}from"./sleep-DVOInM4H.mjs";import"./src-TKCctdpc.mjs";import{_ as a}from"./src-DfRHrkSZ.mjs";import{F as o,O as s}from"./fs-traced-DVpoNaQJ.mjs";import{t as c}from"./constants-BEe0tuQx.mjs";import{t as l}from"./is-object-ByG7RnjH.mjs";import{resolve as u}from"node:path";import{existsSync as d,readFileSync as f}from"node:fs";import{realpath as p}from"node:fs/promises";var m=e();async function h(e){let t=u(e);try{return await p(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function g(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];l(a)&&l(i)?n[r]=g(i,a):a!==void 0&&(n[r]=a)}return n}function _(e){if(!d(e))return{value:null,path:e,source:null,doc:null};let t;try{t=f(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,m.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return l(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function y(e){let t=e??process.cwd(),l=[],d=[],f=[],p=s(`user`,t),m=o({absPath:p});d.push(...m.diagnostics),!m.valid&&m.sidelinedTo!==void 0&&f.push({from:p,to:m.sidelinedTo});let h={};m.valid&&m.source!==void 0?(h=g(h,m.value),l.push(p)):m.valid;let y=u(t,`.ok`,c),b=_(y);if(b.diagnostic!==void 0&&d.push(b.diagnostic),b.value!==null){let e=r({value:b.value,file:b.path,source:b.source,doc:b.doc});d.push(...e);let t=e.length>0?i(b.value):b.value;h=g(h,t),l.push(y)}let x=a.safeParse(h);if(!x.success){let e={code:`SCHEMA_INVALID`,issues:v(x.error.issues,b)};throw Error(n(e))}return{config:x.data,sources:l,diagnostics:d,sidelined:f}}function b(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??y,r=new Map,i=new Map,a=h(e.startupCwd);return async o=>{let s=await h(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{y as n,b as t};
2
- //# sourceMappingURL=loader-CqgZy7s4.mjs.map
1
+ import{Y as e,c as t,d as n,o as r,s as i}from"./sleep-DVOInM4H.mjs";import"./src-TKCctdpc.mjs";import{_ as a}from"./src-DfRHrkSZ.mjs";import{F as o,O as s}from"./fs-traced-DVpoNaQJ.mjs";import{t as c}from"./constants-C2XDlcS1.mjs";import{t as l}from"./is-object-ByG7RnjH.mjs";import{resolve as u}from"node:path";import{existsSync as d,readFileSync as f}from"node:fs";import{realpath as p}from"node:fs/promises";var m=e();async function h(e){let t=u(e);try{return await p(t)}catch(e){if(e.code!==`ENOENT`){let n=e instanceof Error?e.message:String(e);console.warn(`[normalize-cwd] realpath failed for ${t}: ${n}`)}return t}}function g(e,t){let n={...e};for(let r of Object.keys(t)){let i=e[r],a=t[r];l(a)&&l(i)?n[r]=g(i,a):a!==void 0&&(n[r]=a)}return n}function _(e){if(!d(e))return{value:null,path:e,source:null,doc:null};let t;try{t=f(e,`utf-8`)}catch(t){let n=t instanceof Error?t.message:String(t);return console.warn(`[config] Failed to read ${e}: ${n}`),{value:null,path:e,source:null,doc:null,diagnostic:{code:`UNREADABLE`,detail:`${e}: ${n}`}}}let n=(0,m.parseDocument)(t);if(n.errors.length>0){let r=n.errors.map(e=>e.message).join(`; `);return console.warn(`[config] Failed to parse ${e}: ${r}`),{value:null,path:e,source:t,doc:null,diagnostic:{code:`YAML_PARSE`,detail:`${e}: ${r}`}}}let r=n.toJSON();return l(r)?{value:r,path:e,source:t,doc:n}:{value:null,path:e,source:t,doc:n}}function v(e,n){return e.map(e=>{let r=e.path.map(e=>typeof e==`symbol`?String(e):e),i={path:r,message:e.message,issueCode:e.code};if(n.doc!==null&&n.source!==null){let e=t({file:n.path,source:n.source,doc:n.doc,path:r});if(e!==void 0)return{...i,source:e}}return i})}function y(e){let t=e??process.cwd(),l=[],d=[],f=[],p=s(`user`,t),m=o({absPath:p});d.push(...m.diagnostics),!m.valid&&m.sidelinedTo!==void 0&&f.push({from:p,to:m.sidelinedTo});let h={};m.valid&&m.source!==void 0?(h=g(h,m.value),l.push(p)):m.valid;let y=u(t,`.ok`,c),b=_(y);if(b.diagnostic!==void 0&&d.push(b.diagnostic),b.value!==null){let e=r({value:b.value,file:b.path,source:b.source,doc:b.doc});d.push(...e);let t=e.length>0?i(b.value):b.value;h=g(h,t),l.push(y)}let x=a.safeParse(h);if(!x.success){let e={code:`SCHEMA_INVALID`,issues:v(x.error.issues,b)};throw Error(n(e))}return{config:x.data,sources:l,diagnostics:d,sidelined:f}}function b(e){let t=e.cacheMs??1e3,n=e.loadConfigFn??y,r=new Map,i=new Map,a=h(e.startupCwd);return async o=>{let s=await h(o??e.startupCwd),c=Date.now(),l=r.get(s);if(l&&l.expiresAt>c)return l.config;let u=i.get(s);if(u)return await u;let d=(async()=>{if(s===await a)return r.set(s,{config:e.startupConfig,expiresAt:Date.now()+t}),e.startupConfig;let i=n(s).config;return r.set(s,{config:i,expiresAt:Date.now()+t}),i})();i.set(s,d);try{return await d}finally{i.delete(s)}}}export{y as n,b as t};
2
+ //# sourceMappingURL=loader-DRfEZJJx.mjs.map
@@ -0,0 +1 @@
1
+ import{n as e}from"./loader-DRfEZJJx.mjs";export{e as loadConfig};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./preview-DynmdTIr.mjs";export{t as formatPreviewBlock,e as previewContent};
@@ -1,3 +1,3 @@
1
- import{Rr as e}from"./src-DfRHrkSZ.mjs";import"./constants-BEe0tuQx.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
1
+ import{Rr as e}from"./src-DfRHrkSZ.mjs";import"./constants-C2XDlcS1.mjs";import{join as t,relative as n}from"node:path";import{existsSync as r,lstatSync as i,readdirSync as a,realpathSync as o,statSync as s}from"node:fs";function c(r){let{projectDir:c,contentDir:l,sampleCap:u=5}=r,d=[],f=[];try{i(l)}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[`cannot access content directory ${l}: ${e instanceof Error?e.message:String(e)}`]}}let p;try{p=e({projectDir:c,contentDir:l})}catch(e){return{totalCount:0,sample:[],contentDir:l,warnings:[e instanceof Error?e.message:String(e)]}}function m(e){let r;try{r=a(e,{withFileTypes:!0})}catch(t){let r=t instanceof Error?t.message:String(t);d.push(`could not read directory ${n(l,e)||`.`}: ${r}`);return}for(let i of r){let r=t(e,i.name);if(i.isSymbolicLink()){let e;try{e=o(r)}catch(e){let t=e.code;t===`ENOENT`||t===`ELOOP`?d.push(`broken or cyclic symlink: ${n(l,r)}`):d.push(`cannot resolve symlink ${n(l,r)}: ${t??`unknown error`}`);continue}let t;try{t=s(e)}catch{continue}if(t.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(t.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}else if(i.isDirectory()){let e=n(l,r);if(p.isDirExcluded(e))continue;m(r)}else if(i.isFile()){let e=n(l,r);if(p.isExcluded(e))continue;f.push(e)}}}return m(l),{totalCount:f.length,sample:f.slice(0,u),contentDir:l,warnings:d}}function l(e,i){let a=[],o=n(i,e.contentDir),s=o===``?`./`:`./${o}`;if(a.push(`Content:`),a.push(` Found ${e.totalCount} markdown files in ${s}`),e.sample.length>0){let t=e.sample.join(`, `),n=e.totalCount>e.sample.length?`, …`:``;a.push(` Sample: ${t}${n}`)}if(e.warnings.length>0)for(let t of e.warnings)a.push(` Warning: ${t}`);return a.push(``),r(t(i,`.ok`,`config.yml`))?(a.push(` To adjust scope, add patterns to .okignore at the project root.`),a.push(` To change the content root, edit .ok/config.yml → content.dir.`)):a.push(" Run `open-knowledge init` to scaffold config + .okignore."),a.push(``),a.push(` Re-check anytime: open-knowledge preview`),a.join(`
2
2
  `)}export{c as n,l as t};
3
- //# sourceMappingURL=preview-CW1IxLsJ.mjs.map
3
+ //# sourceMappingURL=preview-DynmdTIr.mjs.map
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{ir as n}from"./DocumentContext-nOyI-2M0.js";import{t as r}from"./react-f2sANaYj.js";import{n as i,r as a}from"./dist-Nvb76hAm.js";import{t as o}from"./compiler-runtime-BfE3aGVn.js";import{t as s}from"./utils-CPqDy6Hr.js";import{t as c}from"./mascot-outline-CtS592mc.js";import{t as l}from"./button-RQ5o7P7w.js";import{i as u,n as d,t as f}from"./tooltip-x7BNUa3s.js";import{a as p,c as ee,i as te,n as ne,o as re,r as m,s as h}from"./dialog-eak3pI7G.js";import{m as g,o as _}from"./agent-visibility-CvZ8XtPP.js";import{wa as v}from"./dist-CQI6-1xM2.js";import{t as y}from"./createLucideIcon-BbftclCc.js";import{t as b}from"./folder-Cnftw7jd.js";import{t as x}from"./loader-circle-Coob8S41.js";var S=t(),C=e(r(),1),w=o(),T=3100,E=3;function D(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??E;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var O={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:500,durationMin:1100,durationMax:2400}},k=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function A(e,t={}){let n=t.rng??Math.random,r=t.colors??k,i=O[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var j=1.8,M=90,N=16,ie=380,P=.025,F=.1,I=.18,L=400,R=9.2736,ae=18.1799,z=14.5244,oe={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function se(e,t){let{halfWidth:n,apexLift:r}=oe[t];return`M${e-n} ${z+.3} Q${e} ${z-r}, ${e+n} ${z+.3}`}function ce(e){let t=1.5,n=.3;return`M${e-t} ${z-n} Q${e} ${z+1.4}, ${e+t} ${z-n}`}var le=15,ue=15;function de(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function fe(e){let t=(0,w.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,l=n===void 0?48:n,u=i===void 0?!0:i,d=a===void 0?`default`:a,f=o===void 0?0:o,p=(0,C.useRef)(null),ee=(0,C.useRef)(null),te=(0,C.useRef)(null),ne;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ne={x:0,y:0},t[0]=ne):ne=t[0];let re=(0,C.useRef)(ne),[m,h]=(0,C.useState)(0),[g,_]=(0,C.useState)(0),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[1]=v):v=t[1];let[y,b]=(0,C.useState)(v),x=(0,C.useRef)(0),E=(0,C.useRef)(void 0),O=d===`sleeping`,k;t[2]!==m||t[3]!==O?(k=function(){if(O)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=x.current===0?1/0:e-x.current;x.current=e;let n=D(m,t);h(n),_(ge),b(A(n)),clearTimeout(E.current),E.current=setTimeout(()=>{h(0),b([])},T)},t[2]=m,t[3]=O,t[4]=k):k=t[4];let oe=k,le,ue;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>clearTimeout(E.current),ue=[],t[5]=le,t[6]=ue):(le=t[5],ue=t[6]),(0,C.useEffect)(le,ue);let de,fe;t[7]!==f||t[8]!==O?(de=()=>{f===0||O||(h(3),_(he),b(A(3)),clearTimeout(E.current),E.current=setTimeout(()=>{h(0),b([])},T))},fe=[f,O],t[7]=f,t[8]=O,t[9]=de,t[10]=fe):(de=t[9],fe=t[10]),(0,C.useEffect)(de,fe);let _e,ve;t[11]!==O||t[12]!==u?(_e=()=>{if(!u||O||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,c=function(){s===0&&(s=requestAnimationFrame(d))},l=function(r){e=r.clientX,t=r.clientY,n=!0,c()};function d(){s=0;let l=ee.current,u=p.current;if(!l||!u){c();return}let d=n;n=!1;let f=l.getBoundingClientRect(),ne=f.left+f.width/2,m=f.top+f.height*.48,h=e-ne,g=t-m,_=Math.hypot(h,g),v=Math.max(-1,Math.min(1,h/ie)),y=-Math.max(-1,Math.min(1,g/ie))*N,b=v*N,x=0,S=0;if(_>=1){let e=Math.min(_/M,1)*j;x=h/_*e,S=g/_*e}let C=Math.abs(y-r)<.01&&Math.abs(b-i)<.01&&Math.abs(x-a)<.01&&Math.abs(S-o)<.01;if(!d&&C)return;c(),r+=(y-r)*F,i+=(b-i)*F,u.style.transform=`perspective(${L}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`,a+=(x-a)*I,o+=(S-o)*I;let w=i*P,T=-r*P,E=a+w,D=o+T;re.current.x=E,re.current.y=D,te.current?.setAttribute(`transform`,`translate(${E.toFixed(3)} ${D.toFixed(3)})`)}return document.addEventListener(`mousemove`,l,{passive:!0}),c(),()=>{document.removeEventListener(`mousemove`,l),s!==0&&cancelAnimationFrame(s),s=0,p.current&&(p.current.style.transform=``),re.current={x:0,y:0},te.current?.removeAttribute(`transform`)}},ve=[u,O],t[11]=O,t[12]=u,t[13]=_e,t[14]=ve):(_e=t[13],ve=t[14]),(0,C.useEffect)(_e,ve);let B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{let e=te.current;if(!e)return;let{x:t,y:n}=re.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=B):B=t[15],(0,C.useLayoutEffect)(B);let V=m>0,H=V?m:1,ye=V?`ok-blob-clicked-${m}`:null,U;t[16]===r?U=t[17]:(U=s(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=U);let be=O?`cursor-default`:`cursor-pointer`,xe=`body-${g}`,Se=O&&`ok-blob-sleeping`,W;t[18]!==ye||t[19]!==Se?(W=s(`ok-blob-group`,Se,ye),t[18]=ye,t[19]=Se,t[20]=W):W=t[20];let Ce;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,S.jsx)(`path`,{d:c,className:`ok-blob-body`}),t[21]=Ce):Ce=t[21];let we=(V||O)&&`ok-blob-eye-hidden`,G;t[22]===we?G=t[23]:(G=s(`ok-blob-eye`,we),t[22]=we,t[23]=G);let K;t[24]===G?K=t[25]:(K=(0,S.jsx)(`ellipse`,{cx:R,cy:z,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=K);let Te=(V||O)&&`ok-blob-eye-hidden`,q;t[26]===Te?q=t[27]:(q=s(`ok-blob-eye ok-blob-eye-right`,Te),t[26]=Te,t[27]=q);let J;t[28]===q?J=t[29]:(J=(0,S.jsx)(`ellipse`,{cx:ae,cy:z,rx:1.2722,ry:1.9083,className:q}),t[28]=q,t[29]=J);let Y;t[30]===H?Y=t[31]:(Y=se(R,H),t[30]=H,t[31]=Y);let Ee=(!V||O)&&`ok-blob-eye-hidden`,X;t[32]===Ee?X=t[33]:(X=s(`ok-blob-happy-eye`,Ee),t[32]=Ee,t[33]=X);let Z;t[34]!==Y||t[35]!==X?(Z=(0,S.jsx)(`path`,{d:Y,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:X}),t[34]=Y,t[35]=X,t[36]=Z):Z=t[36];let Q;t[37]===H?Q=t[38]:(Q=se(ae,H),t[37]=H,t[38]=Q);let De=(!V||O)&&`ok-blob-eye-hidden`,Oe;t[39]===De?Oe=t[40]:(Oe=s(`ok-blob-happy-eye`,De),t[39]=De,t[40]=Oe);let ke;t[41]!==Q||t[42]!==Oe?(ke=(0,S.jsx)(`path`,{d:Q,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:Oe}),t[41]=Q,t[42]=Oe,t[43]=ke):ke=t[43];let Ae;t[44]===O?Ae=t[45]:(Ae=O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`path`,{d:ce(R),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,S.jsx)(`path`,{d:ce(ae),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=O,t[45]=Ae);let $;t[46]!==K||t[47]!==J||t[48]!==Z||t[49]!==ke||t[50]!==Ae?($=(0,S.jsxs)(`g`,{ref:te,children:[K,J,Z,ke,Ae]}),t[46]=K,t[47]=J,t[48]=Z,t[49]=ke,t[50]=Ae,t[51]=$):$=t[51];let je;t[52]!==xe||t[53]!==W||t[54]!==$?(je=(0,S.jsxs)(`g`,{className:W,children:[Ce,$]},xe),t[52]=xe,t[53]=W,t[54]=$,t[55]=je):je=t[55];let Me;t[56]===O?Me=t[57]:(Me=O?(0,S.jsxs)(`g`,{children:[(0,S.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,S.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=O,t[57]=Me);let Ne;t[58]!==g||t[59]!==y?(Ne=y.length>0&&(0,S.jsx)(`g`,{children:y.map(pe)},`firework-${g}`),t[58]=g,t[59]=y,t[60]=Ne):Ne=t[60];let Pe;t[61]!==oe||t[62]!==l||t[63]!==be||t[64]!==je||t[65]!==Me||t[66]!==Ne?(Pe=(0,S.jsxs)(`svg`,{ref:ee,width:l,height:l,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:be,"aria-hidden":`true`,onClick:oe,onMouseDown:me,children:[je,Me,Ne]}),t[61]=oe,t[62]=l,t[63]=be,t[64]=je,t[65]=Me,t[66]=Ne,t[67]=Pe):Pe=t[67];let Fe;return t[68]!==U||t[69]!==Pe?(Fe=(0,S.jsx)(`span`,{ref:p,className:U,children:Pe}),t[68]=U,t[69]=Pe,t[70]=Fe):Fe=t[70],Fe}function pe(e){return(0,S.jsx)(`circle`,{cx:le+e.originDx,cy:ue+e.originDy,r:e.size,className:`ok-blob-firework`,style:de(e)},e.id)}function me(e){return e.preventDefault()}function he(e){return e+1}function ge(e){return e+1}var _e=y(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ve=y(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),B=[...new Set(g.flatMap(e=>e.schemes))];function V(e,t){let n=t.now?.()??Date.now(),r={};for(let t of g){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function H(e){return V({},e)}async function ye(e){let t=e.schemes??B,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var U=Object.fromEntries(B.map(e=>[e,{installed:!1}]));async function be(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return U}if(!t.ok)return U;let n;try{n=await t.json()}catch{return U}if(typeof n!=`object`||!n||Array.isArray(n))return U;let r=n,i={};for(let e of B)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function xe(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Se(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=H({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=V(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!xe(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function W(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Ce(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>ye({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>be({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function we(){let e=(0,w.c)(5),[t,n]=(0,C.useState)(G),r=(0,C.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Se(Ce());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return window.addEventListener(`focus`,i),()=>{window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,C.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function G(){return H({isElectronHost:W(),now:Date.now})}var K=(0,C.createContext)(null);function Te(e){let t=(0,w.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,S.jsx)(K,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function q(){return(0,C.use)(K)}function J(e){let t=(0,w.c)(48),{itemName:n,isSubmitting:r,onDelete:o,customTitle:s,customDescription:c,customDetail:u,customConfirmLabel:d,customConfirmLabelBusy:f,children:g}=e,{_}=a(),v;t[0]!==_||t[1]!==n?(v=n??_({id:`L3CEC1`}),t[0]=_,t[1]=n,t[2]=v):v=t[2];let y=v,b;t[3]!==_||t[4]!==d?(b=d??_({id:`cnGeoo`}),t[3]=_,t[4]=d,t[5]=b):b=t[5];let C=b,T;t[6]!==_||t[7]!==d||t[8]!==f?(T=f??d??_({id:`s3caR3`}),t[6]=_,t[7]=d,t[8]=f,t[9]=T):T=t[9];let E=T,D;t[10]!==_||t[11]!==s||t[12]!==y?(D=s??_({id:`77SdEP`,values:{itemName:y}}),t[10]=_,t[11]=s,t[12]=y,t[13]=D):D=t[13];let O;t[14]===D?O=t[15]:(O=(0,S.jsx)(ee,{children:D}),t[14]=D,t[15]=O);let k;t[16]!==_||t[17]!==c||t[18]!==y?(k=c??_({id:`16D5Zj`,values:{itemName:y}}),t[16]=_,t[17]=c,t[18]=y,t[19]=k):k=t[19];let A;t[20]===k?A=t[21]:(A=(0,S.jsx)(p,{className:`whitespace-pre-wrap`,children:k}),t[20]=k,t[21]=A);let j;t[22]===u?j=t[23]:(j=u?(0,S.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`delete-confirmation-detail`,children:u}):null,t[22]=u,t[23]=j);let M;t[24]!==O||t[25]!==A||t[26]!==j?(M=(0,S.jsxs)(h,{children:[O,A,j]}),t[24]=O,t[25]=A,t[26]=j,t[27]=M):M=t[27];let N;t[28]===g?N=t[29]:(N=g?(0,S.jsx)(ne,{children:g}):null,t[28]=g,t[29]=N);let ie;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,S.jsx)(i,{id:`dEgA5A`}),t[30]=ie):ie=t[30];let P;t[31]===r?P=t[32]:(P=(0,S.jsx)(m,{asChild:!0,children:(0,S.jsx)(l,{variant:`outline`,disabled:r,children:ie})}),t[31]=r,t[32]=P);let F;t[33]!==C||t[34]!==E||t[35]!==r?(F=r?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x,{className:`size-4 animate-spin`}),` `,E]}):C,t[33]=C,t[34]=E,t[35]=r,t[36]=F):F=t[36];let I;t[37]!==r||t[38]!==o||t[39]!==F?(I=(0,S.jsx)(l,{variant:`destructive`,onClick:o,disabled:r,children:F}),t[37]=r,t[38]=o,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==P||t[42]!==I?(L=(0,S.jsxs)(re,{children:[P,I]}),t[41]=P,t[42]=I,t[43]=L):L=t[43];let R;return t[44]!==N||t[45]!==L||t[46]!==M?(R=(0,S.jsxs)(te,{children:[M,N,L]}),t[44]=N,t[45]=L,t[46]=M,t[47]=R):R=t[47],R}function Y(e){return e===`agents`||e===`.agents`||e.startsWith(`.agents/`)?`.agents`:e.includes(`/`)?e:v[e]??e}function Ee(e){return e===`claude`?`claude-code`:e}function X(e){let t=(0,w.c)(18),r,i;if(t[0]===e?(r=t[1],i=t[2]):({host:r,...i}=e,t[0]=e,t[1]=r,t[2]=i),r===`agents`){let e;return t[3]===i?e=t[4]:(e=(0,S.jsx)(n,{...i}),t[3]=i,t[4]=e),e}if(r.includes(`/`)){if(r===`.agents`||r.startsWith(`.agents/`)){let e;return t[5]===i?e=t[6]:(e=(0,S.jsx)(n,{...i}),t[5]=i,t[6]=e),e}if(r===`.ok`||r.startsWith(`.ok/`)){let e;if(t[7]!==i){let{className:n,...r}=i;e=r,t[7]=i,t[8]=e}else e=t[8];let n=e,r;return t[9]===n?r=t[10]:(r=(0,S.jsx)(fe,{size:14,...n}),t[9]=n,t[10]=r),r}let e;return t[11]===i?e=t[12]:(e=(0,S.jsx)(b,{...i}),t[11]=i,t[12]=e),e}let a;t[13]===r?a=t[14]:(a=Ee(r),t[13]=r,t[14]=a);let o;return t[15]!==i||t[16]!==a?(o=(0,S.jsx)(_,{...i,id:a}),t[15]=i,t[16]=a,t[17]=o):o=t[17],o}function Z(e){let t=(0,w.c)(14),{hosts:n,className:r,iconClassName:i}=e,a,o,c;if(t[0]!==r||t[1]!==n||t[2]!==i){let e=n.slice(0,2),l=n.slice(2);t[6]===r?a=t[7]:(a=s(`flex items-center gap-1`,r),t[6]=r,t[7]=a);let p;t[8]===i?p=t[9]:(p=e=>(0,S.jsxs)(f,{children:[(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex shrink-0 items-center`,children:(0,S.jsx)(X,{host:e,className:s(`size-3.5 shrink-0`,i),"aria-label":Y(e)})})}),(0,S.jsx)(d,{children:Y(e)})]},e),t[8]=i,t[9]=p),o=e.map(p),c=l.length>0?(0,S.jsxs)(f,{children:[(0,S.jsx)(u,{asChild:!0,children:(0,S.jsxs)(`span`,{className:`ml-0.5 cursor-default`,children:[`+`,l.length]})}),(0,S.jsx)(d,{children:l.map(Y).join(`, `)})]}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=c}else a=t[3],o=t[4],c=t[5];let l;return t[10]!==a||t[11]!==o||t[12]!==c?(l=(0,S.jsxs)(`span`,{className:a,children:[o,c]}),t[10]=a,t[11]=o,t[12]=c,t[13]=l):l=t[13],l}function Q(e){let t=(0,w.c)(6),{testId:n,title:r}=e,a;t[0]===r?a=t[1]:(a=r===void 0?{}:{title:r},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,S.jsx)(i,{id:`YjiZAs`}),t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==n?(s=(0,S.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-yellow-500/40 bg-yellow-500/10 px-1 text-[10px] text-yellow-600 uppercase tracking-wide`,"data-testid":n,...a,children:o}),t[3]=a,t[4]=n,t[5]=s):s=t[5],s}export{Te as a,ve as c,J as i,_e as l,X as n,q as o,Z as r,we as s,Q as t,fe as u};
1
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./jsx-runtime-BUgB2tll.js";import{ir as n}from"./DocumentContext-nOyI-2M0.js";import{t as r}from"./react-f2sANaYj.js";import{n as i,r as a}from"./dist-Nvb76hAm.js";import{t as o}from"./compiler-runtime-BfE3aGVn.js";import{t as s}from"./utils-CPqDy6Hr.js";import{t as c}from"./mascot-outline-CtS592mc.js";import{t as l}from"./button-RQ5o7P7w.js";import{i as u,n as d,t as f}from"./tooltip-x7BNUa3s.js";import{a as p,c as ee,i as te,n as ne,o as re,r as m,s as h}from"./dialog-eak3pI7G.js";import{m as g,o as _}from"./agent-visibility-D5jwzmFA.js";import{wa as v}from"./dist-CQI6-1xM2.js";import{t as y}from"./createLucideIcon-BbftclCc.js";import{t as b}from"./folder-Cnftw7jd.js";import{t as x}from"./loader-circle-Coob8S41.js";var S=t(),C=e(r(),1),w=o(),T=3100,E=3;function D(e,t,n){let r=n?.windowMs??600,i=n?.maxLevel??E;if(e===0||t>=r)return 1;let a=e+1;return a>i?i:a}var O={0:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},1:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},2:{count:0,startRadius:0,baseDistance:0,distanceVariance:0,sizeMin:0,sizeMax:0,maxDelay:0,durationMin:0,durationMax:0},3:{count:16,startRadius:11,baseDistance:7,distanceVariance:3,sizeMin:.45,sizeMax:1.2,maxDelay:500,durationMin:1100,durationMax:2400}},k=[`var(--color-azure-blue)`,`var(--color-sky-blue)`,`var(--color-violet-300)`,`var(--color-orange-light)`,`var(--color-crystal-blue)`,`var(--color-white-cream)`];function A(e,t={}){let n=t.rng??Math.random,r=t.colors??k,i=O[e];if(i.count===0||r.length===0)return[];let a=[],o=Math.PI*2/i.count;for(let e=0;e<i.count;e++){let t=e*o+(n()-.5)*o*.7,s=i.baseDistance+(n()-.5)*2*i.distanceVariance,c=i.sizeMin+n()*(i.sizeMax-i.sizeMin),l=n()*i.maxDelay,u=i.durationMin+n()*(i.durationMax-i.durationMin),d=Math.floor(n()*r.length),f=Math.cos(t),p=Math.sin(t);a.push({id:e,dx:f*s,dy:p*s,originDx:f*i.startRadius,originDy:p*i.startRadius,size:c,color:r[d]??`currentColor`,delay:l,duration:u})}return a}var j=1.8,M=90,N=16,ie=380,P=.025,F=.1,I=.18,L=400,R=9.2736,ae=18.1799,z=14.5244,oe={1:{halfWidth:1.5,apexLift:2.2},2:{halfWidth:1.4,apexLift:2.6},3:{halfWidth:1.25,apexLift:3}};function se(e,t){let{halfWidth:n,apexLift:r}=oe[t];return`M${e-n} ${z+.3} Q${e} ${z-r}, ${e+n} ${z+.3}`}function ce(e){let t=1.5,n=.3;return`M${e-t} ${z-n} Q${e} ${z+1.4}, ${e+t} ${z-n}`}var le=15,ue=15;function de(e){return{fill:e.color,"--fx-tx":`${e.dx}px`,"--fx-ty":`${e.dy}px`,"--fx-delay":`${e.delay}ms`,"--fx-duration":`${e.duration}ms`}}function fe(e){let t=(0,w.c)(71),{size:n,className:r,trackMouse:i,variant:a,celebrateSignal:o}=e,l=n===void 0?48:n,u=i===void 0?!0:i,d=a===void 0?`default`:a,f=o===void 0?0:o,p=(0,C.useRef)(null),ee=(0,C.useRef)(null),te=(0,C.useRef)(null),ne;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ne={x:0,y:0},t[0]=ne):ne=t[0];let re=(0,C.useRef)(ne),[m,h]=(0,C.useState)(0),[g,_]=(0,C.useState)(0),v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[1]=v):v=t[1];let[y,b]=(0,C.useState)(v),x=(0,C.useRef)(0),E=(0,C.useRef)(void 0),O=d===`sleeping`,k;t[2]!==m||t[3]!==O?(k=function(){if(O)return;let e=typeof performance<`u`&&typeof performance.now==`function`?performance.now():Date.now(),t=x.current===0?1/0:e-x.current;x.current=e;let n=D(m,t);h(n),_(ge),b(A(n)),clearTimeout(E.current),E.current=setTimeout(()=>{h(0),b([])},T)},t[2]=m,t[3]=O,t[4]=k):k=t[4];let oe=k,le,ue;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(le=()=>()=>clearTimeout(E.current),ue=[],t[5]=le,t[6]=ue):(le=t[5],ue=t[6]),(0,C.useEffect)(le,ue);let de,fe;t[7]!==f||t[8]!==O?(de=()=>{f===0||O||(h(3),_(he),b(A(3)),clearTimeout(E.current),E.current=setTimeout(()=>{h(0),b([])},T))},fe=[f,O],t[7]=f,t[8]=O,t[9]=de,t[10]=fe):(de=t[9],fe=t[10]),(0,C.useEffect)(de,fe);let _e,ve;t[11]!==O||t[12]!==u?(_e=()=>{if(!u||O||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let e=0,t=0,n=!1,r=0,i=0,a=0,o=0,s=0,c=function(){s===0&&(s=requestAnimationFrame(d))},l=function(r){e=r.clientX,t=r.clientY,n=!0,c()};function d(){s=0;let l=ee.current,u=p.current;if(!l||!u){c();return}let d=n;n=!1;let f=l.getBoundingClientRect(),ne=f.left+f.width/2,m=f.top+f.height*.48,h=e-ne,g=t-m,_=Math.hypot(h,g),v=Math.max(-1,Math.min(1,h/ie)),y=-Math.max(-1,Math.min(1,g/ie))*N,b=v*N,x=0,S=0;if(_>=1){let e=Math.min(_/M,1)*j;x=h/_*e,S=g/_*e}let C=Math.abs(y-r)<.01&&Math.abs(b-i)<.01&&Math.abs(x-a)<.01&&Math.abs(S-o)<.01;if(!d&&C)return;c(),r+=(y-r)*F,i+=(b-i)*F,u.style.transform=`perspective(${L}px) rotateX(${r.toFixed(3)}deg) rotateY(${i.toFixed(3)}deg)`,a+=(x-a)*I,o+=(S-o)*I;let w=i*P,T=-r*P,E=a+w,D=o+T;re.current.x=E,re.current.y=D,te.current?.setAttribute(`transform`,`translate(${E.toFixed(3)} ${D.toFixed(3)})`)}return document.addEventListener(`mousemove`,l,{passive:!0}),c(),()=>{document.removeEventListener(`mousemove`,l),s!==0&&cancelAnimationFrame(s),s=0,p.current&&(p.current.style.transform=``),re.current={x:0,y:0},te.current?.removeAttribute(`transform`)}},ve=[u,O],t[11]=O,t[12]=u,t[13]=_e,t[14]=ve):(_e=t[13],ve=t[14]),(0,C.useEffect)(_e,ve);let B;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{let e=te.current;if(!e)return;let{x:t,y:n}=re.current;e.setAttribute(`transform`,`translate(${t.toFixed(3)} ${n.toFixed(3)})`)},t[15]=B):B=t[15],(0,C.useLayoutEffect)(B);let V=m>0,H=V?m:1,ye=V?`ok-blob-clicked-${m}`:null,U;t[16]===r?U=t[17]:(U=s(`ok-blob-3d-wrapper`,r),t[16]=r,t[17]=U);let be=O?`cursor-default`:`cursor-pointer`,xe=`body-${g}`,Se=O&&`ok-blob-sleeping`,W;t[18]!==ye||t[19]!==Se?(W=s(`ok-blob-group`,Se,ye),t[18]=ye,t[19]=Se,t[20]=W):W=t[20];let Ce;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,S.jsx)(`path`,{d:c,className:`ok-blob-body`}),t[21]=Ce):Ce=t[21];let we=(V||O)&&`ok-blob-eye-hidden`,G;t[22]===we?G=t[23]:(G=s(`ok-blob-eye`,we),t[22]=we,t[23]=G);let K;t[24]===G?K=t[25]:(K=(0,S.jsx)(`ellipse`,{cx:R,cy:z,rx:1.2722,ry:1.9083,className:G}),t[24]=G,t[25]=K);let Te=(V||O)&&`ok-blob-eye-hidden`,q;t[26]===Te?q=t[27]:(q=s(`ok-blob-eye ok-blob-eye-right`,Te),t[26]=Te,t[27]=q);let J;t[28]===q?J=t[29]:(J=(0,S.jsx)(`ellipse`,{cx:ae,cy:z,rx:1.2722,ry:1.9083,className:q}),t[28]=q,t[29]=J);let Y;t[30]===H?Y=t[31]:(Y=se(R,H),t[30]=H,t[31]=Y);let Ee=(!V||O)&&`ok-blob-eye-hidden`,X;t[32]===Ee?X=t[33]:(X=s(`ok-blob-happy-eye`,Ee),t[32]=Ee,t[33]=X);let Z;t[34]!==Y||t[35]!==X?(Z=(0,S.jsx)(`path`,{d:Y,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:X}),t[34]=Y,t[35]=X,t[36]=Z):Z=t[36];let Q;t[37]===H?Q=t[38]:(Q=se(ae,H),t[37]=H,t[38]=Q);let De=(!V||O)&&`ok-blob-eye-hidden`,Oe;t[39]===De?Oe=t[40]:(Oe=s(`ok-blob-happy-eye`,De),t[39]=De,t[40]=Oe);let ke;t[41]!==Q||t[42]!==Oe?(ke=(0,S.jsx)(`path`,{d:Q,strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:Oe}),t[41]=Q,t[42]=Oe,t[43]=ke):ke=t[43];let Ae;t[44]===O?Ae=t[45]:(Ae=O?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(`path`,{d:ce(R),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`}),(0,S.jsx)(`path`,{d:ce(ae),strokeWidth:`1.2`,strokeLinecap:`round`,fill:`none`,className:`ok-blob-sleeping-eye`})]}):null,t[44]=O,t[45]=Ae);let $;t[46]!==K||t[47]!==J||t[48]!==Z||t[49]!==ke||t[50]!==Ae?($=(0,S.jsxs)(`g`,{ref:te,children:[K,J,Z,ke,Ae]}),t[46]=K,t[47]=J,t[48]=Z,t[49]=ke,t[50]=Ae,t[51]=$):$=t[51];let je;t[52]!==xe||t[53]!==W||t[54]!==$?(je=(0,S.jsxs)(`g`,{className:W,children:[Ce,$]},xe),t[52]=xe,t[53]=W,t[54]=$,t[55]=je):je=t[55];let Me;t[56]===O?Me=t[57]:(Me=O?(0,S.jsxs)(`g`,{children:[(0,S.jsx)(`text`,{x:21,y:7,className:`ok-blob-z ok-blob-z-1`,children:`z`}),(0,S.jsx)(`text`,{x:26,y:2,className:`ok-blob-z ok-blob-z-2`,children:`z`})]}):null,t[56]=O,t[57]=Me);let Ne;t[58]!==g||t[59]!==y?(Ne=y.length>0&&(0,S.jsx)(`g`,{children:y.map(pe)},`firework-${g}`),t[58]=g,t[59]=y,t[60]=Ne):Ne=t[60];let Pe;t[61]!==oe||t[62]!==l||t[63]!==be||t[64]!==je||t[65]!==Me||t[66]!==Ne?(Pe=(0,S.jsxs)(`svg`,{ref:ee,width:l,height:l,viewBox:`0 0 30 30`,fill:`none`,overflow:`visible`,xmlns:`http://www.w3.org/2000/svg`,className:be,"aria-hidden":`true`,onClick:oe,onMouseDown:me,children:[je,Me,Ne]}),t[61]=oe,t[62]=l,t[63]=be,t[64]=je,t[65]=Me,t[66]=Ne,t[67]=Pe):Pe=t[67];let Fe;return t[68]!==U||t[69]!==Pe?(Fe=(0,S.jsx)(`span`,{ref:p,className:U,children:Pe}),t[68]=U,t[69]=Pe,t[70]=Fe):Fe=t[70],Fe}function pe(e){return(0,S.jsx)(`circle`,{cx:le+e.originDx,cy:ue+e.originDy,r:e.size,className:`ok-blob-firework`,style:de(e)},e.id)}function me(e){return e.preventDefault()}function he(e){return e+1}function ge(e){return e+1}var _e=y(`ellipsis-vertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),ve=y(`file-plus`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M9 15h6`,key:`cctwl0`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}]]),B=[...new Set(g.flatMap(e=>e.schemes))];function V(e,t){let n=t.now?.()??Date.now(),r={};for(let t of g){let i=t.schemes[0],a=i===void 0?void 0:e[i];if(!a){r[t.id]={installed:null};continue}r[t.id]={installed:a.installed,...a.displayName===void 0?{}:{displayName:a.displayName},lastChecked:n}}return r}function H(e){return V({},e)}async function ye(e){let t=e.schemes??B,n=await Promise.all(t.map(async t=>{let n=t.replace(/:$/,``);try{return[t,await e.detectProtocol(n)]}catch{return[t,{installed:!1}]}}));return Object.fromEntries(n)}var U=Object.fromEntries(B.map(e=>[e,{installed:!1}]));async function be(e){let t;try{t=await e.fetch(`/api/installed-agents`,{signal:e.signal,headers:{Accept:`application/json`}})}catch(e){if(e.name===`AbortError`)throw e;return U}if(!t.ok)return U;let n;try{n=await t.json()}catch{return U}if(typeof n!=`object`||!n||Array.isArray(n))return U;let r=n,i={};for(let e of B)i[e]={installed:r[e.replace(/:$/,``)]===!0};return i}function xe(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(!n||!i||n.installed!==i.installed||n.displayName!==i.displayName)return!1}return!0}function Se(e){let t=e.throttleMs??1e4,n=!1,r=null,i=null,a={},o=H({isElectronHost:e.isElectronHost(),now:e.now}),s=new Set,c=()=>{if(!n)for(let e of s)e(o)},l=()=>{o=V(a,{isElectronHost:e.isElectronHost(),now:e.now})};return{probe:async()=>{if(n)return;if(i)return i;if(r!==null&&e.now()-r<t)return;let o=(async()=>{try{let t=await e.probe();if(n)return;let i=!xe(a,t);a=t,i&&(l(),c()),r=e.now()}catch{}finally{i=null}})();return i=o,o},getTargetStates:()=>o,subscribe:e=>(s.add(e),()=>{s.delete(e)}),cancel:()=>{n=!0,s.clear()}}}function W(e=typeof window<`u`?window:void 0){return e?.okDesktop!=null}function Ce(){let e=typeof window<`u`?window.okDesktop:void 0;if(e){let t=t=>e.shell.detectProtocol(t);return{probe:()=>ye({detectProtocol:t}),isElectronHost:()=>!0,now:Date.now}}let t=globalThis.fetch.bind(globalThis);return{probe:()=>be({fetch:t}),isElectronHost:()=>!1,now:Date.now}}function we(){let e=(0,w.c)(5),[t,n]=(0,C.useState)(G),r=(0,C.useRef)(null),i,a;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>{let e=Se(Ce());r.current=e;let t=e.subscribe(n);e.probe();let i=()=>{e.probe()};return window.addEventListener(`focus`,i),()=>{window.removeEventListener(`focus`,i),t(),e.cancel(),r.current=null}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),(0,C.useEffect)(i,a);let o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>r.current?.probe()??Promise.resolve(),e[2]=o):o=e[2];let s;return e[3]===t?s=e[4]:(s={states:t,refresh:o},e[3]=t,e[4]=s),s}function G(){return H({isElectronHost:W(),now:Date.now})}var K=(0,C.createContext)(null);function Te(e){let t=(0,w.c)(3),{value:n,children:r}=e,i;return t[0]!==r||t[1]!==n?(i=(0,S.jsx)(K,{value:n,children:r}),t[0]=r,t[1]=n,t[2]=i):i=t[2],i}function q(){return(0,C.use)(K)}function J(e){let t=(0,w.c)(48),{itemName:n,isSubmitting:r,onDelete:o,customTitle:s,customDescription:c,customDetail:u,customConfirmLabel:d,customConfirmLabelBusy:f,children:g}=e,{_}=a(),v;t[0]!==_||t[1]!==n?(v=n??_({id:`L3CEC1`}),t[0]=_,t[1]=n,t[2]=v):v=t[2];let y=v,b;t[3]!==_||t[4]!==d?(b=d??_({id:`cnGeoo`}),t[3]=_,t[4]=d,t[5]=b):b=t[5];let C=b,T;t[6]!==_||t[7]!==d||t[8]!==f?(T=f??d??_({id:`s3caR3`}),t[6]=_,t[7]=d,t[8]=f,t[9]=T):T=t[9];let E=T,D;t[10]!==_||t[11]!==s||t[12]!==y?(D=s??_({id:`77SdEP`,values:{itemName:y}}),t[10]=_,t[11]=s,t[12]=y,t[13]=D):D=t[13];let O;t[14]===D?O=t[15]:(O=(0,S.jsx)(ee,{children:D}),t[14]=D,t[15]=O);let k;t[16]!==_||t[17]!==c||t[18]!==y?(k=c??_({id:`16D5Zj`,values:{itemName:y}}),t[16]=_,t[17]=c,t[18]=y,t[19]=k):k=t[19];let A;t[20]===k?A=t[21]:(A=(0,S.jsx)(p,{className:`whitespace-pre-wrap`,children:k}),t[20]=k,t[21]=A);let j;t[22]===u?j=t[23]:(j=u?(0,S.jsx)(`p`,{className:`text-muted-foreground text-sm`,"data-testid":`delete-confirmation-detail`,children:u}):null,t[22]=u,t[23]=j);let M;t[24]!==O||t[25]!==A||t[26]!==j?(M=(0,S.jsxs)(h,{children:[O,A,j]}),t[24]=O,t[25]=A,t[26]=j,t[27]=M):M=t[27];let N;t[28]===g?N=t[29]:(N=g?(0,S.jsx)(ne,{children:g}):null,t[28]=g,t[29]=N);let ie;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(ie=(0,S.jsx)(i,{id:`dEgA5A`}),t[30]=ie):ie=t[30];let P;t[31]===r?P=t[32]:(P=(0,S.jsx)(m,{asChild:!0,children:(0,S.jsx)(l,{variant:`outline`,disabled:r,children:ie})}),t[31]=r,t[32]=P);let F;t[33]!==C||t[34]!==E||t[35]!==r?(F=r?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(x,{className:`size-4 animate-spin`}),` `,E]}):C,t[33]=C,t[34]=E,t[35]=r,t[36]=F):F=t[36];let I;t[37]!==r||t[38]!==o||t[39]!==F?(I=(0,S.jsx)(l,{variant:`destructive`,onClick:o,disabled:r,children:F}),t[37]=r,t[38]=o,t[39]=F,t[40]=I):I=t[40];let L;t[41]!==P||t[42]!==I?(L=(0,S.jsxs)(re,{children:[P,I]}),t[41]=P,t[42]=I,t[43]=L):L=t[43];let R;return t[44]!==N||t[45]!==L||t[46]!==M?(R=(0,S.jsxs)(te,{children:[M,N,L]}),t[44]=N,t[45]=L,t[46]=M,t[47]=R):R=t[47],R}function Y(e){return e===`agents`||e===`.agents`||e.startsWith(`.agents/`)?`.agents`:e.includes(`/`)?e:v[e]??e}function Ee(e){return e===`claude`?`claude-code`:e}function X(e){let t=(0,w.c)(18),r,i;if(t[0]===e?(r=t[1],i=t[2]):({host:r,...i}=e,t[0]=e,t[1]=r,t[2]=i),r===`agents`){let e;return t[3]===i?e=t[4]:(e=(0,S.jsx)(n,{...i}),t[3]=i,t[4]=e),e}if(r.includes(`/`)){if(r===`.agents`||r.startsWith(`.agents/`)){let e;return t[5]===i?e=t[6]:(e=(0,S.jsx)(n,{...i}),t[5]=i,t[6]=e),e}if(r===`.ok`||r.startsWith(`.ok/`)){let e;if(t[7]!==i){let{className:n,...r}=i;e=r,t[7]=i,t[8]=e}else e=t[8];let n=e,r;return t[9]===n?r=t[10]:(r=(0,S.jsx)(fe,{size:14,...n}),t[9]=n,t[10]=r),r}let e;return t[11]===i?e=t[12]:(e=(0,S.jsx)(b,{...i}),t[11]=i,t[12]=e),e}let a;t[13]===r?a=t[14]:(a=Ee(r),t[13]=r,t[14]=a);let o;return t[15]!==i||t[16]!==a?(o=(0,S.jsx)(_,{...i,id:a}),t[15]=i,t[16]=a,t[17]=o):o=t[17],o}function Z(e){let t=(0,w.c)(14),{hosts:n,className:r,iconClassName:i}=e,a,o,c;if(t[0]!==r||t[1]!==n||t[2]!==i){let e=n.slice(0,2),l=n.slice(2);t[6]===r?a=t[7]:(a=s(`flex items-center gap-1`,r),t[6]=r,t[7]=a);let p;t[8]===i?p=t[9]:(p=e=>(0,S.jsxs)(f,{children:[(0,S.jsx)(u,{asChild:!0,children:(0,S.jsx)(`span`,{className:`flex shrink-0 items-center`,children:(0,S.jsx)(X,{host:e,className:s(`size-3.5 shrink-0`,i),"aria-label":Y(e)})})}),(0,S.jsx)(d,{children:Y(e)})]},e),t[8]=i,t[9]=p),o=e.map(p),c=l.length>0?(0,S.jsxs)(f,{children:[(0,S.jsx)(u,{asChild:!0,children:(0,S.jsxs)(`span`,{className:`ml-0.5 cursor-default`,children:[`+`,l.length]})}),(0,S.jsx)(d,{children:l.map(Y).join(`, `)})]}):null,t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=c}else a=t[3],o=t[4],c=t[5];let l;return t[10]!==a||t[11]!==o||t[12]!==c?(l=(0,S.jsxs)(`span`,{className:a,children:[o,c]}),t[10]=a,t[11]=o,t[12]=c,t[13]=l):l=t[13],l}function Q(e){let t=(0,w.c)(6),{testId:n,title:r}=e,a;t[0]===r?a=t[1]:(a=r===void 0?{}:{title:r},t[0]=r,t[1]=a);let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,S.jsx)(i,{id:`YjiZAs`}),t[2]=o):o=t[2];let s;return t[3]!==a||t[4]!==n?(s=(0,S.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center rounded border border-yellow-500/40 bg-yellow-500/10 px-1 text-[10px] text-yellow-600 uppercase tracking-wide`,"data-testid":n,...a,children:o}),t[3]=a,t[4]=n,t[5]=s):s=t[5],s}export{Te as a,ve as c,J as i,_e as l,X as n,q as o,Z as r,we as s,Q as t,fe as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./index-D3Eciye1.js";export{e as FeedbackForm};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPanel-BAOlww8F.js","./chunk-CYidjpOJ.js","./dist-CQI6-1xM2.js","./preload-helper-Chd9yIcd.js","./trace-api-DH580DYm.js","./lib-DcrRfjuF.js","./html-void-elements-Bkr32DGT.js","./lib-BHGXbMkc.js","./markdownit-CIgVFnWs.js","./w3c-keyname-hgmz1BF7.js","./dist-Nvb76hAm.js","./jsx-runtime-BUgB2tll.js","./react-f2sANaYj.js","./button-RQ5o7P7w.js","./dist-DUWYPul7.js","./bundle-mjs-SHeFpKGC.js","./compiler-runtime-BfE3aGVn.js","./utils-CPqDy6Hr.js","./x-COTyTduF.js","./createLucideIcon-BbftclCc.js","./dist-PQ5KMVDh.js","./dist-CEwo98ia.js","./react-dom-DPxgxlDT.js","./file-tree-adapter-NC64LhE5.js","./file-tree-rename-validation-CEz8MVWM.js","./file-tree-utils-CBnjZ8_a.js","./navigation-targets-D-iDEja4.js","./doc-paths-D1ML_anF.js","./skill-scope-78Suy4sY.js","./terminal-command-events-BBYZtptJ.js","./use-live-xterm-theme-CcaaVudK.js","./config-context-Dqp-CwnJ.js","./TerminalPanel-BrP-ENHg.css","./ThreadView-DeyKw79l.js","./dist-C7IFraT6.js","./checkbox-V0IoPAe3.js","./dist-Bi80hc1t.js","./dist-CIv09IXf.js","./dist-CR6aO28t.js","./check-BLuQ2zvV.js","./minus-DPAjfzCa.js","./dropdown-menu-BhMtMvZp.js","./dist-G89kioZo.js","./dist-DpaqLIPT.js","./floating-ui.dom-C0wusa09.js","./dist-By2lAhKX.js","./dist-DY-494HN.js","./es2015-B2hWAwcf.js","./dist-DMj9iIHH.js","./chevron-right-BU8AeJST.js","./local-menu-action-bus-DLozq_c4.js","./separator-k0mwGcaM.js","./switch-0kSGDL9E.js","./tooltip-x7BNUa3s.js","./DocumentContext-nOyI-2M0.js","./cm-theme-BJSRL90r.js","./dist-BlH6jxEE.js","./dist-DndwauQ3.js","./dist-BCM06z1D.js","./dist-DJ3iQH0N.js","./dist-ClczuKkQ.js","./dist-DvtYFuZI.js","./dist-BDJLSjo2.js","./dist--4AcVRue.js","./dist-yYRRvtMr.js","./stex-CyLY7DTo.js","./config-provider-CA7jSjm6.js","./client-version-CyKndMN4.js","./i18n-CYjCal_m.js","./messages-CzRXVtjz.js","./propagation-api-DSg7UKuw.js","./select-CRztynyQ.js","./chevron-down-DrpHBSgH.js","./chevron-up-CsH_dTwv.js","./collapsible-OhEmjTXw.js","./dialog-eak3pI7G.js","./CodeMirrorPropInput-9fhI0VAh.js","./folder-open-DoQalFip.js","./trash-2-BSr7FcE8.js","./asset-dispatch-Dst62kKY.js","./external-link-BkNoUOYg.js","./documents-fetch-BTUkzxjd.js","./git-branch-BWBPTGqT.js","./Mermaid-Cr48L9fH.js","./triangle-alert-DNTyNeem.js","./CopyButton-DysciFW5.js","./prop-types-DyYLLIQb.js","./documents-events-CU1SZlDl.js","./parse-api-error-Cyn4P6OR.js","./startup-marks-BzFN1cqP.js","./eye-DYUvwA0Z.js","./hash-BZXl_HqD.js","./info-Jj1j2YxC.js","./loader-circle-Coob8S41.js","./paperclip-9gdTBktj.js","./badge-B89o8Vy9.js","./input-BKUcczSW.js","./use-collab-url-CxpQAoZ0.js","./skills-api-Dx4VSQB1.js","./DocumentContext-B0sQn39F.css","./libesm-DLjHMG6S.js","./chunk-BO2N2NFS-XrP3H1kD.js","./RegisteredAgentIcon-Cdt1gfjt.js","./cursor-Df-vt--2.js","./download-Bq4sKAdj.js","./history-BNEST2Cx.js","./list-plus-IYEFhKGU.js","./comment-chips-DTSyL-J1.js","./follow-file-w7JbrzZs.js","./square-pen-D3oI-YUs.js","./terminal-mGTI25Qq.js","./wrench-BPXVnAE5.js","./mascot-outline-CtS592mc.js","./skeleton-ColtBPsg.js","./textarea-C5-cm3M6.js","./thread-client-DSDduEdo.js","./thread-draft-staging-DZhf3sQU.js","./agent-presence-DntZZFlY.js","./use-workspace-C2xbCdck.js"])))=>i.map(i=>d[i]);
2
+ import{o as e}from"./chunk-CYidjpOJ.js";import{t}from"./preload-helper-Chd9yIcd.js";import{t as n}from"./jsx-runtime-BUgB2tll.js";import{t as r}from"./react-f2sANaYj.js";import{n as i,r as a}from"./dist-Nvb76hAm.js";import{t as o}from"./useQuery-ZeEDLtxh.js";import{t as s}from"./react-dom-DPxgxlDT.js";import{t as c}from"./compiler-runtime-BfE3aGVn.js";import{a as l,c as u,l as d,n as f,o as p,r as m,s as h}from"./local-menu-action-bus-DLozq_c4.js";import{t as g}from"./utils-CPqDy6Hr.js";import{t as _}from"./button-RQ5o7P7w.js";import{i as v,n as y,t as b}from"./tooltip-x7BNUa3s.js";import{a as x,i as S,m as C,o as w,r as T,t as E,u as D}from"./dropdown-menu-BhMtMvZp.js";import{i as O,n as ee,r as k,t as A}from"./tabs-CjOEhhKP.js";import{S as j,_ as M,a as N,f as te,i as P,n as ne,o as F,s as re,x as ie,y as ae}from"./agent-visibility-D5jwzmFA.js";import{i as oe}from"./terminal-telemetry-DV5mcRVf.js";import{Pt as se}from"./dist-CQI6-1xM2.js";import{n as ce,t as le}from"./RegisteredAgentIcon-Cdt1gfjt.js";import{t as I}from"./check-BLuQ2zvV.js";import{t as ue}from"./chevron-down-DrpHBSgH.js";import{t as L}from"./chevron-right-BU8AeJST.js";import{t as R}from"./history-BNEST2Cx.js";import{t as z}from"./loader-circle-Coob8S41.js";import{D as de,E as fe,I as B,M as V,O as pe,P as me,S as H,T as he,_ as U,a as ge,f as _e,i as ve,j as ye,k as be,s as xe,t as Se,x as Ce,y as we}from"./terminal-launch-events-rvma4jZd.js";import{t as W}from"./trash-2-BSr7FcE8.js";import{t as Te}from"./x-COTyTduF.js";import{n as Ee}from"./dist-CEwo98ia.js";import{t as G}from"./dist-C7IFraT6.js";import{i as De}from"./use-settings-route-DMLcMwjw.js";import{t as Oe}from"./overlay-layers-BqWhClsR.js";import{a as ke,d as Ae,g as je,h as Me,n as Ne,r as Pe,s as K,t as Fe}from"./sortable.esm-DlAqBM0z.js";import{r as Ie,t as Le}from"./input-group-H-ZoGiXT.js";import{c as Re,l as ze,o as Be,r as Ve,t as He}from"./thread-client-DSDduEdo.js";import{t as Ue}from"./thread-draft-staging-DZhf3sQU.js";import{n as q,t as We}from"./use-terminal-enabled-D05DXcuw.js";var Ge=e(s(),1),J=c(),Y=e(r(),1),X=n();function Ke(e){let t=(0,J.c)(26),{archived:n,openThreadIds:r,onOpenThread:i}=e,{_:o}=a(),s=Ve(),[c,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[h,x]=(0,Y.useState)(0),S=(0,Y.useId)(),C;t[0]===o?C=t[1]:(C=o({id:`V0mbgd`}),t[0]=o,t[1]=C);let w=C,T=m,E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>{u(e),e?x(Date.now()):f(null)},t[2]=E):E=t[2];let D;t[3]===o?D=t[4]:(D=o({id:`6FCixu`}),t[3]=o,t[4]=D);let O;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,X.jsx)(R,{"aria-hidden":`true`}),t[5]=O):O=t[5];let ee;t[6]===D?ee=t[7]:(ee=(0,X.jsx)(v,{asChild:!0,children:(0,X.jsx)(p,{asChild:!0,children:(0,X.jsx)(_,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0 cursor-pointer text-muted-foreground hover:text-foreground`,"aria-label":D,"data-testid":`agent-thread-history`,children:O})})}),t[6]=D,t[7]=ee);let k;t[8]===o?k=t[9]:(k=o({id:`6FCixu`}),t[8]=o,t[9]=k);let A;t[10]===k?A=t[11]:(A=(0,X.jsx)(y,{side:`bottom`,sideOffset:8,children:k}),t[10]=k,t[11]=A);let j;t[12]!==ee||t[13]!==A?(j=(0,X.jsxs)(b,{children:[ee,A]}),t[12]=ee,t[13]=A,t[14]=j):j=t[14];let M=l,N=n.map(e=>{let t=r.has(e.threadId);if(d===e.threadId&&!t)return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 rounded-md bg-destructive/5 px-2 py-1`,"data-testid":`agent-thread-history-confirm`,children:[(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:o({id:`kVgQUA`})}),(0,X.jsx)(_,{type:`button`,size:`sm`,variant:`destructive`,className:`h-6 px-2 text-xs`,onClick:()=>{s.deleteThread(e.threadId),f(null)},"data-testid":`agent-thread-history-confirm-delete`,children:o({id:`cnGeoo`})}),(0,X.jsx)(_,{type:`button`,size:`sm`,variant:`ghost`,className:`h-6 px-2 text-xs`,onClick:()=>f(null),children:o({id:`dEgA5A`})})]},e.threadId);let n=`${S}-${e.threadId}`;return(0,X.jsxs)(`div`,{className:`group flex items-center gap-0.5`,children:[(0,X.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-auto min-w-0 flex-1 justify-start gap-2 px-2 py-1.5`,onClick:()=>{i(e.threadId),u(!1)},"data-testid":`agent-thread-history-open-${e.threadId}`,children:[(0,X.jsx)(le,{agentId:e.agent.id,iconUrl:e.agent.iconUrl,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-xs`,children:e.title}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:Je(e.lastActivityAt,h)})]}),(0,X.jsxs)(b,{children:[(0,X.jsx)(v,{asChild:!0,children:(0,X.jsxs)(`span`,{className:g(`inline-flex`,t&&`cursor-not-allowed`),children:[(0,X.jsx)(_,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":o({id:`Y2tU6I`,values:{0:e.title}}),"aria-disabled":t||void 0,"aria-describedby":t?n:void 0,className:g(`opacity-0 transition-opacity focus-visible:opacity-100 group-hover:opacity-100`,t?`cursor-not-allowed text-muted-foreground/50`:`text-muted-foreground hover:text-destructive`),onClick:()=>{t||f(e.threadId)},"data-testid":`agent-thread-history-delete-${e.threadId}`,children:(0,X.jsx)(W,{className:`size-3`,"aria-hidden":`true`})}),t?(0,X.jsx)(`span`,{id:n,className:`sr-only`,children:w}):null]})}),(0,X.jsx)(y,{side:`bottom`,sideOffset:8,children:t?w:o({id:`Y2tU6I`,values:{0:e.title}})})]})]},e.threadId)}),te;t[15]===N?te=t[16]:(te=(0,X.jsx)(`div`,{className:`max-h-80 overflow-y-auto`,children:N}),t[15]=N,t[16]=te);let P;t[17]!==M||t[18]!==te?(P=(0,X.jsx)(M,{align:`end`,className:`w-72 p-1`,children:te}),t[17]=M,t[18]=te,t[19]=P):P=t[19];let ne;return t[20]!==T||t[21]!==c||t[22]!==P||t[23]!==E||t[24]!==j?(ne=(0,X.jsxs)(T,{open:c,onOpenChange:E,children:[j,P]}),t[20]=T,t[21]=c,t[22]=P,t[23]=E,t[24]=j,t[25]=ne):ne=t[25],ne}function qe(e){let t=(0,J.c)(18),{archived:n,onOpen:r}=e,{_:i}=a(),[o,s]=(0,Y.useState)(0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>{s(Date.now())},l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,Y.useEffect)(c,l);let u;t[2]===i?u=t[3]:(u=i({id:`Tq9kNX`}),t[2]=i,t[3]=u);let d;t[4]===u?d=t[5]:(d=(0,X.jsx)(`p`,{className:`px-1 text-muted-foreground text-xs`,children:u}),t[4]=u,t[5]=d);let f;if(t[6]!==n||t[7]!==o||t[8]!==r){let e;t[10]!==o||t[11]!==r?(e=e=>(0,X.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-auto w-full min-w-0 justify-start gap-2 px-2 py-1.5`,onClick:()=>r(e.threadId),"data-testid":`agent-thread-empty-open-${e.threadId}`,children:[(0,X.jsx)(le,{agentId:e.agent.id,iconUrl:e.agent.iconUrl,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-xs`,children:e.title}),(0,X.jsx)(`span`,{className:`shrink-0 text-[10px] text-muted-foreground`,children:Je(e.lastActivityAt,o)})]},e.threadId),t[10]=o,t[11]=r,t[12]=e):e=t[12],f=n.map(e),t[6]=n,t[7]=o,t[8]=r,t[9]=f}else f=t[9];let p;t[13]===f?p=t[14]:(p=(0,X.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:f}),t[13]=f,t[14]=p);let m;return t[15]!==d||t[16]!==p?(m=(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-3`,"data-testid":`agent-thread-empty-chooser`,children:[d,p]}),t[15]=d,t[16]=p,t[17]=m):m=t[17],m}function Je(e,t){let n=Math.max(0,t-e);if(n<6e4)return G._({id:`xOTzt5`});if(n<36e5){let e=Math.round(n/6e4);return G._({id:`_rP3HI`,values:{minutes:e}})}if(n<864e5){let e=Math.round(n/36e5);return G._({id:`nYeBmY`,values:{hours:e}})}let r=Math.round(n/864e5);return G._({id:`LPAv9E`,values:{days:r}})}var Z=new Set;function Ye(e,t,n,r,i){let a=`${e.source}:${e.id}`;Z.has(a)||(Z.add(a),Ve().createThread({agent:e,prompt:t??void 0,docName:n??void 0,titleHint:r??void 0}).then(e=>{if(i!=null)try{Ue(e.threadId,i)}catch(t){console.error(`[agent-threads] draft staging failed for`,e.threadId,t)}}).catch(e=>{console.error(`[agent-threads] launch failed:`,e),Ee.error(e instanceof He?G._({id:`aaI6cN`}):G._({id:`2rLM8r`}))}).finally(()=>{Z.delete(a)}))}function Xe(){return Z.size>0}var Ze={terminal:`ok-dock-session-order-v1`,agents:`ok-agent-session-order-v1`};function Q(e){return{order:Array.isArray(e.order)?e.order.filter(e=>typeof e==`string`):[],activeKey:typeof e.activeKey==`string`?e.activeKey:null}}function Qe(e){if(typeof window>`u`)return null;try{let t=window.localStorage.getItem(Ze[e]);return t===null?null:Q(JSON.parse(t))}catch{return null}}function $e(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(Ze[e],JSON.stringify(t))}catch{}}function et(e,t){return typeof e?.terminal?.getDockState==`function`?e.terminal.getDockState().then(e=>{let n=e[t];if(n==null)return null;let{order:r,activeKey:i}=Q(n);return r.length===0&&i===null?null:{order:r,activeKey:i}}).catch(e=>(console.warn(`[dock-session-persistence] getDockState failed; cold-starting:`,e),null)):Promise.resolve(Qe(t))}function tt(e,t,n){if(typeof e?.terminal?.setDockState==`function`){e.terminal.setDockState({surface:t,order:[...n.order],activeKey:n.activeKey});return}$e(t,n)}var nt=`ok-terminal-new-tab-bare-v1`;function rt(e){try{return(e??localStorage).getItem(nt)===`1`}catch{return!1}}function it(e,t){try{let n=t??localStorage;e?n.setItem(nt,`1`):n.removeItem(nt)}catch{}for(let e of at)e()}var at=new Set;function ot(){return ut()}function st(){for(let e of at)e()}typeof window<`u`&&typeof window.addEventListener==`function`&&window.addEventListener(`storage`,e=>{(e.key===`ok-terminal-new-tab-bare-v1`||e.key===null)&&st()});function ct(e){return at.add(e),()=>at.delete(e)}function lt(){return(0,Y.useSyncExternalStore)(ct,ot,ot)}function ut(){try{return typeof localStorage>`u`?!1:rt()}catch{return!1}}var dt=(0,Y.lazy)(()=>t(()=>import(`./TerminalPanel-BAOlww8F.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]),import.meta.url));function ft(e){let t=(0,J.c)(15),{bridge:n,onClose:r,onTitleChange:i,launch:o,commandId:s,adoptPtyId:c,onPtyId:l}=e,u=o===void 0?null:o,f=s===void 0?null:s,p=c===void 0?null:c,{enabled:m,synced:h}=We(),g=q(),{_}=a(),v=h&&m===!1,y;t[0]!==_||t[1]!==g?(y=function(){if(g===null){Ee.error(_({id:`V_6bJ4`}));return}let e=g(!0);e.ok||Ee.error(_({id:`jKd3AP`,values:{0:e.error}}))},t[0]=_,t[1]=g,t[2]=y):y=t[2];let b=y;if(h&&!v){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[3]=e):e=t[3];let a;return t[4]!==p||t[5]!==n||t[6]!==f||t[7]!==u||t[8]!==r||t[9]!==l||t[10]!==i?(a=(0,X.jsx)(d,{fallbackRender:mt,onError:pt,children:(0,X.jsx)(Y.Suspense,{fallback:e,children:(0,X.jsx)(dt,{bridge:n,className:`h-full`,onClose:r,onTitleChange:i,launch:u,commandId:f,adoptPtyId:p,onPtyId:l})})}),t[4]=p,t[5]=n,t[6]=f,t[7]=u,t[8]=r,t[9]=l,t[10]=i,t[11]=a):a=t[11],a}let x;return t[12]!==b||t[13]!==v?(x=v?(0,X.jsx)($,{onEnable:b}):(0,X.jsx)(`div`,{className:`h-full w-full bg-background`,"aria-hidden":`true`}),t[12]=b,t[13]=v,t[14]=x):x=t[14],x}function pt(e,t){console.error(`[TerminalGate] rendered fallback for the terminal panel`,e,t.componentStack)}function mt(e){return(0,X.jsx)(ht,{...e})}function ht(e){let t=(0,J.c)(15),{error:n}=e,{_:r}=a(),i;t[0]!==r||t[1]!==n?(i=n instanceof Error&&/dynamically imported module|Failed to fetch/i.test(n.message)?r({id:`Y8ViJx`}):r({id:`fbsiBw`}),t[0]=r,t[1]=n,t[2]=i):i=t[2];let o=i,s;t[3]===r?s=t[4]:(s=r({id:`6MnZEC`}),t[3]=r,t[4]=s);let c;t[5]===o?c=t[6]:(c=(0,X.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:o}),t[5]=o,t[6]=c);let l;t[7]===r?l=t[8]:(l=r({id:`HpK_8d`}),t[7]=r,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,X.jsx)(_,{onClick:gt,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==s||t[12]!==c||t[13]!==u?(d=(0,X.jsxs)(`section`,{"aria-label":s,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,role:`alert`,children:[c,u]}),t[11]=s,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function gt(){return window.location.reload()}function $(e){let t=(0,J.c)(20),{onEnable:n}=e,{_:r}=a(),i;t[0]===r?i=t[1]:(i=r({id:`_XWY2J`}),t[0]=r,t[1]=i);let o;t[2]===r?o=t[3]:(o=r({id:`oYepHb`}),t[2]=r,t[3]=o);let s;t[4]===o?s=t[5]:(s=(0,X.jsx)(`p`,{className:`max-w-sm text-sm text-foreground`,children:o}),t[4]=o,t[5]=s);let c;t[6]===r?c=t[7]:(c=r({id:`v2ZW0K`}),t[6]=r,t[7]=c);let l;t[8]!==n||t[9]!==c?(l=(0,X.jsx)(_,{onClick:n,children:c}),t[8]=n,t[9]=c,t[10]=l):l=t[10];let u;t[11]===r?u=t[12]:(u=r({id:`ICoNYz`}),t[11]=r,t[12]=u);let d;t[13]===u?d=t[14]:(d=(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u}),t[13]=u,t[14]=d);let f;return t[15]!==i||t[16]!==s||t[17]!==l||t[18]!==d?(f=(0,X.jsxs)(`section`,{"aria-label":i,className:`flex h-full w-full flex-col items-center justify-center gap-3 bg-background p-6 text-center`,children:[s,l,d]}),t[15]=i,t[16]=s,t[17]=l,t[18]=d,t[19]=f):f=t[19],f}function _t(e){let t=(0,J.c)(67),{selected:n,onLaunchSelected:r,showAgents:s,registeredAgents:c,onPickAgent:l,onOpenSettings:d,liveThreadCount:f,showClis:p,onPickCli:m,onPickTerminal:O,visibleClis:ee,className:k}=e,A=ee===void 0?P:ee,{_:j}=a(),[M,te]=(0,Y.useState)(!1),ne;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(ne=[`acp-catalog`],t[0]=ne):ne=t[0];let ie=M&&s,ae;t[1]===ie?ae=t[2]:(ae={queryKey:ne,queryFn:vt,enabled:ie,staleTime:3e5},t[1]=ie,t[2]=ae);let oe=f>=(o(ae).data?.maxThreads??8),ce=s||p,L;t[3]!==j||t[4]!==n.agent||t[5]!==n.cli||t[6]!==n.kind?(L=n.kind===`terminal`?j({id:`AB4qw9`}):n.kind===`cli`?j({id:`nP-KFo`,values:{0:se[n.cli].displayName}}):n.agent===null?j({id:`G7bn_N`}):j({id:`nP-KFo`,values:{0:n.agent.name}}),t[3]=j,t[4]=n.agent,t[5]=n.cli,t[6]=n.kind,t[7]=L):L=t[7];let R=L,z;t[8]===k?z=t[9]:(z=g(`flex shrink-0 items-center`,k),t[8]=k,t[9]=z);let de=ce&&`rounded-r-none`,fe;t[10]===de?fe=t[11]:(fe=g(`cursor-pointer gap-0.5 px-1.5 text-muted-foreground hover:text-foreground`,de),t[10]=de,t[11]=fe);let V;t[12]===n?V=t[13]:(V=n.kind===`terminal`?null:(0,X.jsx)(yt,{selected:n,className:`size-3.5`}),t[12]=n,t[13]=V);let pe;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,X.jsx)(u,{"aria-hidden":`true`,className:`size-3`}),t[14]=pe):pe=t[14];let me;t[15]!==r||t[16]!==R||t[17]!==fe||t[18]!==V?(me=(0,X.jsx)(v,{asChild:!0,children:(0,X.jsxs)(_,{type:`button`,variant:`ghost`,size:`xs`,"aria-label":R,"data-testid":`terminal-new-chat`,className:fe,onClick:r,children:[V,pe]})}),t[15]=r,t[16]=R,t[17]=fe,t[18]=V,t[19]=me):me=t[19];let H;t[20]===R?H=t[21]:(H=(0,X.jsx)(y,{side:`bottom`,sideOffset:8,children:R}),t[20]=R,t[21]=H);let he;t[22]!==me||t[23]!==H?(he=(0,X.jsxs)(b,{children:[me,H]}),t[22]=me,t[23]=H,t[24]=he):he=t[24];let U;t[25]!==j||t[26]!==ce?(U=ce?(0,X.jsx)(C,{asChild:!0,children:(0,X.jsx)(_,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":j({id:`l87Deg`}),"data-testid":`terminal-new-chat-menu`,className:`cursor-pointer rounded-l-none text-muted-foreground hover:text-foreground`,children:(0,X.jsx)(ue,{"aria-hidden":`true`,className:`size-3`})})}):null,t[25]=j,t[26]=ce,t[27]=U):U=t[27];let ge;t[28]!==j||t[29]!==oe||t[30]!==l||t[31]!==c||t[32]!==n.agent?.id||t[33]!==n.agent?.source||t[34]!==n.kind||t[35]!==s?(ge=s&&c.length>0?(0,X.jsxs)(S,{"aria-label":j({id:`vPKX2i`}),children:[(0,X.jsxs)(w,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(i,{id:`RXEbZy`}),(0,X.jsx)(re,{})]}),c.map(e=>{let t=n.kind===`agent`&&n.agent?.source===e.source&&n.agent?.id===e.id;return(0,X.jsxs)(x,{onSelect:()=>l(e),disabled:oe,"data-testid":`terminal-new-chat-agent-${e.id}`,"aria-current":t?`true`:void 0,children:[(0,X.jsx)(le,{agentId:e.id,iconUrl:e.iconUrl,className:`size-4`}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),t?(0,X.jsx)(I,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},`${e.source}:${e.id}`)}),oe?(0,X.jsx)(w,{className:`py-1 font-normal text-muted-foreground text-xs`,"data-testid":`terminal-new-chat-cap`,children:(0,X.jsx)(i,{id:`0QVrvp`})}):null]}):null,t[28]=j,t[29]=oe,t[30]=l,t[31]=c,t[32]=n.agent?.id,t[33]=n.agent?.source,t[34]=n.kind,t[35]=s,t[36]=ge):ge=t[36];let _e;t[37]!==c||t[38]!==s||t[39]!==p?(_e=s&&c.length>0&&p?(0,X.jsx)(D,{}):null,t[37]=c,t[38]=s,t[39]=p,t[40]=_e):_e=t[40];let ve;t[41]!==j||t[42]!==m||t[43]!==O||t[44]!==n.cli||t[45]!==n.kind||t[46]!==p||t[47]!==A?(ve=p?(0,X.jsxs)(S,{"aria-label":j({id:`ALhMYW`}),children:[(0,X.jsx)(w,{children:(0,X.jsx)(i,{id:`ALhMYW`})}),A.map(e=>{let{displayName:t}=se[e],r=n.kind===`cli`&&n.cli===e;return(0,X.jsxs)(x,{onSelect:()=>m(e),"data-testid":`terminal-new-chat-cli-${e}`,"aria-label":j({id:`9mEZeD`,values:{name:t}}),"aria-current":r?`true`:void 0,children:[(0,X.jsx)(F,{id:N(e),className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`flex-1`,children:t}),r?(0,X.jsx)(I,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]},e)}),(0,X.jsxs)(x,{onSelect:O,"data-testid":`terminal-new-chat-terminal`,"aria-current":n.kind===`terminal`?`true`:void 0,children:[(0,X.jsx)(B,{"aria-hidden":`true`,className:`size-4`}),(0,X.jsx)(`span`,{className:`flex-1`,children:(0,X.jsx)(i,{id:`ALhMYW`})}),n.kind===`terminal`?(0,X.jsx)(I,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}):null]})]}):null,t[41]=j,t[42]=m,t[43]=O,t[44]=n.cli,t[45]=n.kind,t[46]=p,t[47]=A,t[48]=ve):ve=t[48];let ye;t[49]!==d||t[50]!==c||t[51]!==s||t[52]!==p?(ye=s?(0,X.jsxs)(X.Fragment,{children:[c.length>0||p?(0,X.jsx)(D,{}):null,(0,X.jsxs)(x,{onSelect:d,"data-testid":`terminal-new-chat-settings`,children:[(0,X.jsx)(h,{"aria-hidden":`true`,className:`size-4 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`flex-1`,children:(0,X.jsx)(i,{id:`jRAGrQ`})})]})]}):null,t[49]=d,t[50]=c,t[51]=s,t[52]=p,t[53]=ye):ye=t[53];let be;t[54]!==ge||t[55]!==_e||t[56]!==ve||t[57]!==ye?(be=(0,X.jsxs)(T,{align:`start`,className:`max-h-80 min-w-[200px]`,children:[ge,_e,ve,ye]}),t[54]=ge,t[55]=_e,t[56]=ve,t[57]=ye,t[58]=be):be=t[58];let xe;t[59]!==M||t[60]!==U||t[61]!==be?(xe=(0,X.jsxs)(E,{open:M,onOpenChange:te,children:[U,be]}),t[59]=M,t[60]=U,t[61]=be,t[62]=xe):xe=t[62];let Se;return t[63]!==he||t[64]!==xe||t[65]!==z?(Se=(0,X.jsxs)(`div`,{className:z,children:[he,xe]}),t[63]=he,t[64]=xe,t[65]=z,t[66]=Se):Se=t[66],Se}function vt(e){let{signal:t}=e;return oe(t)}function yt(e){let t=(0,J.c)(13),{selected:n,className:r}=e;if(n.kind===`terminal`){let e;return t[0]===r?e=t[1]:(e=(0,X.jsx)(B,{"aria-hidden":`true`,className:r}),t[0]=r,t[1]=e),e}if(n.kind===`cli`){let e;t[2]===n.cli?e=t[3]:(e=N(n.cli),t[2]=n.cli,t[3]=e);let i;return t[4]!==r||t[5]!==e?(i=(0,X.jsx)(F,{id:e,className:r,"aria-hidden":`true`}),t[4]=r,t[5]=e,t[6]=i):i=t[6],i}if(n.agent!==null){let e;return t[7]!==r||t[8]!==n.agent.iconUrl||t[9]!==n.agent.id?(e=(0,X.jsx)(le,{agentId:n.agent.id,iconUrl:n.agent.iconUrl,className:r}),t[7]=r,t[8]=n.agent.iconUrl,t[9]=n.agent.id,t[10]=e):e=t[10],e}let i;return t[11]===r?i=t[12]:(i=(0,X.jsx)(ce,{"aria-hidden":`true`,className:r}),t[11]=r,t[12]=i),i}var bt=`[data-terminal-tab-sortable]`;function xt(e){let t=(0,J.c)(17),{id:n,disabled:r,isActive:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o={id:n,disabled:r},t[0]=r,t[1]=n,t[2]=o):o=t[2];let{setNodeRef:s,listeners:c,rect:l,transform:u,transition:d,isDragging:f}=ke(o),p=l.current?.width,m;t[3]!==f||t[4]!==p||t[5]!==u||t[6]!==d?(m=_e({activeWidth:p,isDragging:f,transform:u,transition:d}),t[3]=f,t[4]=p,t[5]=u,t[6]=d,t[7]=m):m=t[7];let h=m,_=i?`bg-muted`:`hover:bg-muted/50`,v=f&&`z-10`,y;t[8]!==_||t[9]!==v?(y=g(`group flex shrink-0 cursor-default items-center rounded-md pr-0.5 transition-colors`,_,v),t[8]=_,t[9]=v,t[10]=y):y=t[10];let b;return t[11]!==a||t[12]!==c||t[13]!==s||t[14]!==h||t[15]!==y?(b=(0,X.jsx)(`div`,{ref:s,"data-terminal-tab-sortable":``,style:h,className:y,...c,children:a}),t[11]=a,t[12]=c,t[13]=s,t[14]=h,t[15]=y,t[16]=b):b=t[16],b}function St(e){let t=(0,J.c)(86),{sessions:n,activeSessionId:r,onSelect:o,onTabActivate:s,newButton:c,trailingControls:l,onClose:u,onRename:d,onReorder:f,onDragActiveChange:p,edge:m,onCollapse:h,children:x,className:S,draggable:C}=e,{_:w}=a(),T=m===`right`,[E,D]=(0,Y.useState)(null),[ee,j]=(0,Y.useState)(``),M=(0,Y.useRef)(null),N=(0,Y.useRef)(!1),te=d!=null,P,ne;t[0]===E?(P=t[1],ne=t[2]):(P=()=>{E!=null&&(M.current?.focus(),M.current?.select())},ne=[E],t[0]=E,t[1]=P,t[2]=ne),(0,Y.useEffect)(P,ne);let F,re;t[3]!==E||t[4]!==n?(F=()=>{E!=null&&!n.some(e=>e.id===E)&&(N.current=!1,D(null),j(``))},re=[n,E],t[3]=E,t[4]=n,t[5]=F,t[6]=re):(F=t[5],re=t[6]),(0,Y.useEffect)(F,re);let ie=function(e){te&&(N.current=!1,D(e.id),j(e.label))},ae;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(ae=function(e){let t=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e;queueMicrotask(()=>{document.querySelector(`[role="tab"][data-tab-id="${t}"]`)?.focus()})},t[7]=ae):ae=t[7];let oe=ae,se=function(e){N.current||d?.(e,ee.trim()),N.current=!1,D(null),j(``),oe(e)},ce=(0,Y.useRef)(null),le=(0,Y.useRef)(null),[I,R]=(0,Y.useState)(null),z;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(z={activationConstraint:{distance:8}},t[8]=z):z=t[8];let de=je(Me(Ae,z)),fe=f!=null,B;t[9]===I?B=t[10]:(B=xe(I),t[9]=I,t[10]=B);let V;t[11]===B?V=t[12]:(V=[B],t[11]=B,t[12]=V);let pe=V,me;t[13]!==r||t[14]!==n?(me=r===``?null:`${r}\u0000${n.map(Tt).join(`\0`)}`,t[13]=r,t[14]=n,t[15]=me):me=t[15];let H=me,he,_e;t[16]===H?(he=t[17],_e=t[18]):(he=()=>{if(H===null)return;let[e]=H.split(`\0`,1),t=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e;le.current?.querySelector(`[data-tab-id="${t}"]`)?.scrollIntoView({block:`nearest`,inline:`nearest`})},_e=[H],t[16]=H,t[17]=he,t[18]=_e),(0,Y.useEffect)(he,_e);let ve;t[19]===p?ve=t[20]:(ve=function(){R(U(ce.current,bt)),p?.(!0)},t[19]=p,t[20]=ve);let ye=ve,be;t[21]!==p||t[22]!==f||t[23]!==n?(be=function(e){R(null),p?.(!1);let t=String(e.active.id),r=e.over?String(e.over.id):null;if(!r||t===r)return;let i=n.map(wt),a=i.indexOf(t),o=i.indexOf(r);a<0||o<0||a===o||f?.(Ne(i,a,o))},t[21]=p,t[22]=f,t[23]=n,t[24]=be):be=t[24];let Se=be,Ce;t[25]===p?Ce=t[26]:(Ce=function(){R(null),p?.(!1)},t[25]=p,t[26]=Ce);let W=Ce,Ee=A,G;t[27]===S?G=t[28]:(G=g(`flex min-h-0 min-w-0 flex-1 flex-col`,S),t[27]=S,t[28]=G);let De=C?``:void 0,Oe=C&&`h-[62px] [-webkit-app-region:drag] pr-[22px] pl-[calc(var(--ok-titlebar-reserve-left,1rem)+0.75rem)]`,ke;t[29]===Oe?ke=t[30]:(ke=g(`flex shrink-0 flex-row items-center gap-1 px-1.5 py-1`,Oe),t[29]=Oe,t[30]=ke);let Re=k,ze;t[31]!==w||t[32]!==T?(ze=w(T?{id:`GjsGAu`}:{id:`1MGRQl`}),t[31]=w,t[32]=T,t[33]=ze):ze=t[33];let Be=ge,Ve=C&&`[-webkit-app-region:no-drag]`,He;t[34]===Ve?He=t[35]:(He=g(`flex h-auto min-w-0 items-center justify-start gap-0.5 overflow-x-auto overflow-y-hidden bg-transparent p-0 [scrollbar-width:none] scroll-fade-mask-x`,Ve),t[34]=Ve,t[35]=He);let Ue=K,q=we,We;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(We={container:typeof document<`u`?document.body:void 0},t[36]=We):We=t[36];let Ge=Fe,Ke;t[37]===n?Ke=t[38]:(Ke=n.map(Ct),t[37]=n,t[38]=Ke);let qe=Pe,Je=n.map(e=>{let t=e.id===r;return(0,X.jsx)(xt,{id:e.id,disabled:!fe||E!=null,isActive:t,children:E===e.id?(0,X.jsx)(Le,{className:g(`h-7 w-40 rounded-md border-0 bg-transparent dark:bg-transparent`,C&&`[-webkit-app-region:no-drag]`),children:(0,X.jsx)(Ie,{ref:M,value:ee,"aria-label":w({id:`0TnCvC`,values:{0:e.label}}),"data-testid":`terminal-tab-rename-input`,className:`h-7 px-2 text-xs`,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),M.current?.blur()):e.key===`Escape`&&(e.preventDefault(),N.current=!0,M.current?.blur())},onBlur:()=>se(e.id)})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(b,{children:[(0,X.jsx)(v,{asChild:!0,children:(0,X.jsxs)(O,{value:e.id,"data-tab-id":e.id,onClick:t=>{t.detail>=2||s?.(e.id)},onDoubleClick:()=>ie(e),onKeyDown:t=>{t.key===`F2`&&(t.preventDefault(),ie(e))},className:g(`h-7 flex-none gap-1.5 rounded-md px-2 text-xs`,C&&`[-webkit-app-region:no-drag]`),children:[e.icon,(0,X.jsx)(`span`,{className:`max-w-40 truncate`,children:e.label})]})}),(0,X.jsx)(y,{side:`bottom`,sideOffset:8,children:e.label})]}),(0,X.jsx)(_,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":w({id:`nzHlj8`,values:{0:e.label}}),tabIndex:t?0:-1,className:g(`text-muted-foreground opacity-0 transition-opacity hover:text-foreground group-hover:opacity-100 group-focus-within:opacity-100`,t&&`opacity-100`,C&&`[-webkit-app-region:no-drag]`),onClick:t=>{t.stopPropagation(),u(e.id)},children:(0,X.jsx)(Te,{"aria-hidden":`true`})})]})},e.id)}),Z;t[39]!==Ge||t[40]!==Ke||t[41]!==qe||t[42]!==Je?(Z=(0,X.jsx)(Ge,{items:Ke,strategy:qe,children:Je}),t[39]=Ge,t[40]=Ke,t[41]=qe,t[42]=Je,t[43]=Z):Z=t[43];let Ye;t[44]!==Ue||t[45]!==W||t[46]!==Se||t[47]!==ye||t[48]!==pe||t[49]!==de||t[50]!==!1||t[51]!==q||t[52]!==We||t[53]!==Z?(Ye=(0,X.jsx)(Ue,{sensors:de,autoScroll:!1,collisionDetection:q,modifiers:pe,onDragStart:ye,onDragEnd:Se,onDragCancel:W,accessibility:We,children:Z}),t[44]=Ue,t[45]=W,t[46]=Se,t[47]=ye,t[48]=pe,t[49]=de,t[50]=!1,t[51]=q,t[52]=We,t[53]=Z,t[54]=Ye):Ye=t[54];let Xe;t[55]!==Re||t[56]!==ze||t[57]!==Be||t[58]!==He||t[59]!==Ye?(Xe=(0,X.jsx)(Re,{ref:le,variant:`line`,"aria-label":ze,onWheel:Be,className:He,children:Ye}),t[55]=Re,t[56]=ze,t[57]=Be,t[58]=He,t[59]=Ye,t[60]=Xe):Xe=t[60];let Ze;t[61]!==C||t[62]!==c?(Ze=c==null?null:(0,X.jsx)(`div`,{className:g(`shrink-0`,C&&`[-webkit-app-region:no-drag]`),children:c}),t[61]=C,t[62]=c,t[63]=Ze):Ze=t[63];let Q;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(Q=(0,X.jsx)(`div`,{className:`flex-1`}),t[64]=Q):Q=t[64];let Qe;t[65]!==C||t[66]!==l?(Qe=l==null?null:(0,X.jsx)(`div`,{className:g(`shrink-0`,C&&`[-webkit-app-region:no-drag]`),children:l}),t[65]=C,t[66]=l,t[67]=Qe):Qe=t[67];let $e;t[68]!==w||t[69]!==h||t[70]!==T?($e=h==null?null:(0,X.jsxs)(b,{children:[(0,X.jsx)(v,{asChild:!0,children:(0,X.jsx)(_,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":w({id:`o5jB-D`}),className:`shrink-0 cursor-pointer text-muted-foreground hover:text-foreground`,onClick:h,children:T?(0,X.jsx)(L,{"aria-hidden":`true`}):(0,X.jsx)(ue,{"aria-hidden":`true`})})}),(0,X.jsx)(y,{side:`bottom`,sideOffset:8,children:(0,X.jsx)(i,{id:`o5jB-D`})})]}),t[68]=w,t[69]=h,t[70]=T,t[71]=$e):$e=t[71];let et;t[72]!==De||t[73]!==ke||t[74]!==Xe||t[75]!==Ze||t[76]!==Qe||t[77]!==$e?(et=(0,X.jsxs)(`div`,{ref:ce,"data-electron-drag":De,className:ke,children:[Xe,Ze,Q,Qe,$e]}),t[72]=De,t[73]=ke,t[74]=Xe,t[75]=Ze,t[76]=Qe,t[77]=$e,t[78]=et):et=t[78];let tt;return t[79]!==Ee||t[80]!==r||t[81]!==x||t[82]!==o||t[83]!==G||t[84]!==et?(tt=(0,X.jsxs)(Ee,{value:r,onValueChange:o,className:G,children:[et,x]}),t[79]=Ee,t[80]=r,t[81]=x,t[82]=o,t[83]=G,t[84]=et,t[85]=tt):tt=t[85],tt}function Ct(e){return e.id}function wt(e){return e.id}function Tt(e){return e.id}var Et=(0,Y.lazy)(()=>t(()=>import(`./ThreadView-DeyKw79l.js`).then(e=>({default:e.ThreadView})),__vite__mapDeps([33,1,3,2,4,5,6,7,8,9,34,10,11,12,35,36,14,22,37,38,39,19,40,16,17,15,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,20,21,67,31,68,69,70,71,72,73,74,75,13,18,76,77,78,26,25,27,28,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,24,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118]),import.meta.url));function Dt(e){return`terminal-session-${e}`}function Ot(e){return typeof CSS<`u`&&CSS.escape?CSS.escape(e):e}function kt(e){e!==``&&document.querySelector(`[data-terminal-session="${Ot(e)}"] .xterm-helper-textarea`)?.focus()}function At(e){e!==``&&document.querySelector(`[data-session-id="${Ot(e)}"] [data-testid="agent-thread-composer"]`)?.focus()}function jt(e){e.kind===`terminal`?kt(e.id):At(e.id)}function Mt(e){return e?.contains(document.activeElement)??!1}function Nt(e,t){return t||Mt(e)}function Pt(e){switch(e){case`running`:return`bg-amber-500 animate-pulse`;case`installing`:case`spawning`:return`bg-sky-500 animate-pulse`;case`auth_required`:case`awaiting_permission`:return`bg-amber-500`;case`ready`:return`bg-emerald-500`;case`error`:return`bg-red-500`;default:return`bg-muted-foreground`}}function Ft(){return(0,X.jsx)(B,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`})}function It(e){return(0,X.jsxs)(`span`,{className:`relative inline-flex shrink-0`,children:[(0,X.jsx)(le,{agentId:e?.agent.id??``,iconUrl:e?.agent.iconUrl,className:`size-3.5`}),e==null?null:(0,X.jsx)(`span`,{className:g(`-right-0.5 -bottom-0.5 absolute size-1.5 rounded-full ring-1 ring-background`,Pt(e.status)),"aria-hidden":`true`})]})}var Lt={cli:!0,terminal:!0,desktop:!0};function Rt(e){let t=(0,J.c)(127),{bridge:n,terminalCapable:r,surface:i,visible:o,onVisibleChange:s,launch:c,commandLaunch:l,threadLaunch:u,installedClis:d,container:p,isShowing:m,onRequestEditorFocus:h}=e,_=r===void 0?!1:r,v=c===void 0?null:c,y=l===void 0?null:l,b=u===void 0?null:u,{_:x}=a(),S=i===`terminal-window`,C=i===`agents-panel`,w=!C,T=w&&_&&n?.terminal!=null,E=C?`right`:`bottom`,D=C?`agents`:`terminal`,O=!S,[k]=(0,Y.useState)(on),A,N;t[0]!==p||t[1]!==k?(A=()=>{k==null||p==null||k.parentElement!==p&&p.appendChild(k)},N=[k,p],t[0]=p,t[1]=k,t[2]=A,t[3]=N):(A=t[2],N=t[3]),(0,Y.useLayoutEffect)(A,N);let P=w&&typeof n?.terminal?.list==`function`,F=!P&&T&&o,re;t[4]!==n?.terminal?.getDockState||t[5]!==P||t[6]!==F||t[7]!==D||t[8]!==O?(re=()=>P||!O||F||typeof n?.terminal?.getDockState==`function`?null:Qe(D),t[4]=n?.terminal?.getDockState,t[5]=P,t[6]=F,t[7]=D,t[8]=O,t[9]=re):re=t[9];let[oe]=(0,Y.useState)(re),ce;t[10]===oe?.order?ce=t[11]:(ce=oe?.order??[],t[10]=oe?.order,t[11]=ce);let le=(0,Y.useRef)(ce),I=(0,Y.useRef)(oe?.activeKey??null),ue;t[12]!==F||t[13]!==v?(ue=()=>F?[{kind:`terminal`,id:Dt(1),launch:v,commandId:null,title:null,customLabel:null,ordinal:1,adoptPtyId:null}]:[],t[12]=F,t[13]=v,t[14]=ue):ue=t[14];let[L,R]=(0,Y.useState)(ue),z;t[15]===F?z=t[16]:(z=()=>F?Dt(1):``,t[15]=F,t[16]=z);let[B,U]=(0,Y.useState)(z),[ge,_e]=(0,Y.useState)(!P),xe=(0,Y.useRef)(!1),we=(0,Y.useRef)(B),W=(0,Y.useRef)(L),Te=(0,Y.useRef)(+!!F),Ee=(0,Y.useRef)(F&&v?v.nonce:null),G=(0,Y.useRef)(null),ke=(0,Y.useRef)(null),Ae=(0,Y.useRef)(!1),je=(0,Y.useRef)(null),Me=(0,Y.useRef)(S?!1:o),Ne=(0,Y.useRef)(new Map),Pe=(0,Y.useRef)(0),K=ze(),Fe=Re(),Ie=Be(),Le=Ie===`connecting`||Ie===`closed`,He=j(),q=te(),We;t[17]===q?We=t[18]:(We=e=>ne(q,e.source,e.id,!0,e.supported),t[17]=q,t[18]=We);let Je=He.filter(We),Z=M(Je,ie()),Ze;t[19]===K?Ze=t[20]:(Ze=K.filter(an),t[19]=K,t[20]=Ze);let Q=Ze.length,$e=new Map(K.map(rn)),nt=new Set($e.keys()),rt;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(rt=function(e){Ve().openArchivedThread(e)},t[21]=rt):rt=t[21];let at=rt,ot=function(){if(!O)return;let e=Ne.current,t=W.current.map(t=>un(t,e)).filter(nn),r=W.current.find(e=>e.id===we.current);tt(n,D,{order:t,activeKey:r==null?null:un(r,e)})},st=function(e,t){if(t===null){Ne.current.delete(e),cn(W.current,we.current);return}Ne.current.set(e,t),cn(W.current,we.current);let r=W.current.find(t=>t.id===e);r!=null&&r.kind===`terminal`&&n?.terminal?.setMeta?.(t,{ordinal:r.ordinal,customLabel:r.customLabel}),ot()},ct=function(e,t){let n=t===void 0?null:t;I.current=null,Te.current+=1;let r=Dt(Te.current);R(t=>[...t,{kind:`terminal`,id:r,launch:e,commandId:n,title:null,customLabel:null,ordinal:Te.current,adoptPtyId:null}]),U(r)},ut=be(),dt=lt(),pt;t[22]===d?pt=t[23]:(pt=d??{},t[22]=d,t[23]=pt);let mt;t[24]===d?mt=t[25]:(mt=d??{},t[24]=d,t[25]=mt);let ht=H({sticky:ut,effectiveThreadAgent:Z,enabledClis:Ce(q,pt),enabledDesktopTargets:[],installedClis:mt,terminalAvailable:T,threadsAvailable:C,desktopSelectable:!1,preferBareTerminal:dt,bareTerminalFallback:!0}),gt=he(ut),$=ht.kind===`thread`?{kind:`agent`,agent:ht.agent}:ht.kind===`cli`?ht.cli===gt?{kind:`cli`,cli:ht.cli}:{kind:`terminal`}:ht.kind===`terminal`?{kind:`terminal`}:{kind:`agent`,agent:null},vt=function(e){Pe.current+=1,ct({prompt:null,cli:e,nonce:Pe.current})},yt=function(){$.kind===`terminal`?ct(null):$.kind===`cli`?vt($.cli):$.kind===`agent`&&$.agent!=null?Ye({source:$.agent.source,id:$.agent.id},null,null,null):De()},bt=function(){return C?$.kind!==`agent`||$.agent==null?!1:(Ye({source:$.agent.source,id:$.agent.id},null,null,null),!0):($.kind===`terminal`?ct(null):$.kind===`cli`&&vt($.cli),!0)},xt;t[26]===d?xt=t[27]:(xt=d??{},t[26]=d,t[27]=xt);let Ct;t[28]===d?Ct=t[29]:(Ct=d??{},t[28]=d,t[29]=Ct);let wt=H({sticky:ut,effectiveThreadAgent:Z,enabledClis:Ce(q,xt),enabledDesktopTargets:[],installedClis:Ct,terminalAvailable:_,threadsAvailable:!S,desktopSelectable:!1,preferBareTerminal:!1,bareTerminalFallback:!1}),Tt;t[30]===d?Tt=t[31]:(Tt=d??{},t[30]=d,t[31]=Tt);let Et;t[32]===d?Et=t[33]:(Et=d??{},t[32]=d,t[33]=Et);let Ot=H({sticky:ut,effectiveThreadAgent:Z,enabledClis:Ce(q,Tt),enabledDesktopTargets:[],installedClis:Et,terminalAvailable:_,threadsAvailable:!S,desktopSelectable:!1,preferBareTerminal:dt,bareTerminalFallback:!0}),Pt;t[34]!==C||t[35]!==S?(Pt=function(e){return S?!0:C?e===`thread`||e===`none`:e in Lt},t[34]=C,t[35]=S,t[36]=Pt):Pt=t[36];let Rt=Pt;function cn(e,t){let r=e.find(e=>e.id===t);if(r==null){V(null);return}if(r.kind===`thread`){let e=$e.get(r.threadId);V({id:r.id,kind:`thread`,label:e?.agent.name??x({id:`bcm0pR`}),agentId:e?.agent.id??``,iconUrl:e?.agent.iconUrl});return}let i=Ne.current.get(r.id),a=r.launch?.cli;if(i==null||n?.terminal==null||a==null){V(null);return}V({id:r.id,kind:`terminal`,label:se[a].displayName,cli:a})}let fn;t[37]!==B||t[38]!==K||t[39]!==L?(fn=[B,L,K],t[37]=B,t[38]=K,t[39]=L,t[40]=fn):fn=t[40],(0,Y.useEffect)(()=>{cn(L,B)},fn);let pn;t[41]!==s||t[42]!==o?(pn=function(){o||s(!0)},t[41]=s,t[42]=o,t[43]=pn):pn=t[43];let mn=pn,hn=function(e){let{text:t,newTab:r,submit:i}=e;if(!Rt(wt.kind))return;o||s(!0);let a=we.current,c=W.current.find(e=>e.id===a);if(!r&&c!=null){if(c.kind===`thread`){Ue(c.threadId,t),mn(),queueMicrotask(()=>jt(c));return}let e=Ne.current.get(c.id),r=n?.terminal;if(e!=null&&r!=null&&c.launch?.cli!=null){r.input(e,t),mn(),queueMicrotask(()=>kt(a));return}}if(wt.kind===`thread`){let e={source:wt.agent.source,id:wt.agent.id};i?Ye(e,t,null,null,null):Ye(e,null,null,null,t)}else wt.kind===`cli`?Se(t,wt.cli,{stage:!i}):De()},gn=function(e){it(!1),fe(de(e)),vt(e)},_n=function(){it(!0),ct(null)},vn;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(vn=function(e){ae(e),it(!1),fe(pe(e)),Ye({source:e.source,id:e.id},null,null,null)},t[44]=vn):vn=t[44];let yn=vn,bn;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(bn=function(e,t){let n=t.trim()===``?null:t.trim();R(t=>t.some(t=>t.id===e&&t.kind===`terminal`&&t.title!==n)?t.map(t=>t.id===e&&t.kind===`terminal`?{...t,title:n}:t):t)},t[45]=bn):bn=t[45];let xn=bn,Sn=function(e,t){let r=W.current.find(t=>t.id===e);if(r==null)return;if(r.kind===`thread`){Ve().renameThread(r.threadId,t);return}let i=t.trim()===``?null:t.trim();R(t=>t.some(t=>t.id===e&&t.kind===`terminal`&&t.customLabel!==i)?t.map(t=>t.id===e&&t.kind===`terminal`?{...t,customLabel:i}:t):t);let a=Ne.current.get(e);a!=null&&n?.terminal?.setMeta?.(a,{customLabel:i})},Cn=function(e){return e.kind===`terminal`?e.customLabel??e.title??x({id:`OVjNeX`,values:{0:e.ordinal}}):$e.get(e.threadId)?.title??x({id:`iEQQyu`})},wn=(0,Y.useRef)(!1),Tn=(0,Y.useRef)(null),En=(0,Y.useRef)(null),Dn=function(e){R(t=>{if(e.length!==t.length)return t;let n=new Map(t.map(tn)),r=[];for(let i of e){let e=n.get(i);if(e==null)return t;r.push(e)}return r.every((e,n)=>e===t[n])?t:r});let t=e.map(e=>Ne.current.get(e)).filter(en);t.length>0&&n?.terminal?.setOrder?.(t)},On=function(e){let t=W.current,n=t.findIndex(e=>e.id===we.current);if(n<0)return null;let r=n+e;if(r<0||r>=t.length)return null;let i=t.map($t),[a]=i.splice(n,1);return i.splice(r,0,a),Dn(i),{label:Cn(t[n]),position:r+1,total:t.length}},kn=function(){Rt(Ot.kind)&&(o||s(!0),yt())},An=(0,Y.useRef)(On),jn=(0,Y.useRef)(ct),Mn=(0,Y.useRef)(bt),Nn=(0,Y.useRef)(hn),Pn=(0,Y.useRef)(kn),Fn=function(e){let t=W.current,n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n],i=t.length===1;if(I.current=null,e===we.current){let e=t[n-1]??t[n+1];U(e?.id??``),e!=null&&queueMicrotask(()=>jt(e))}r.kind===`thread`?Ve().closeThread(r.threadId):R(t.filter(t=>t.id!==e)),i&&(s(!1),h())},In=(0,Y.useRef)(Qt);(0,Y.useEffect)(()=>{jn.current=ct,Mn.current=bt,Nn.current=hn,Pn.current=kn,An.current=On,we.current=B,W.current=L,In.current=()=>{let e=W.current.find(e=>e.id===we.current);if(e?.kind===`terminal`){Fn(e.id);return}let t=[...W.current].reverse().find(Zt);t!=null&&Fn(t.id)}});let Ln;t[46]!==B||t[47]!==n||t[48]!==D||t[49]!==O||t[50]!==L?(Ln=[L,B,O,D,n],t[46]=B,t[47]=n,t[48]=D,t[49]=O,t[50]=L,t[51]=Ln):Ln=t[51],(0,Y.useEffect)(()=>{if(!O)return;let e=Ne.current,t=L.map(t=>un(t,e)).filter(Xt),r=L.find(e=>e.id===B);tt(n,D,{order:t,activeKey:r==null?null:un(r,e)})},Ln);let Rn;t[52]!==C||t[53]!==K?(Rn=[K,C],t[52]=C,t[53]=K,t[54]=Rn):Rn=t[54],(0,Y.useEffect)(()=>{if(!C)return;let e=new Set(K.map(Yt)),t=W.current,n=new Set(t.filter(Jt).map(qt)),r=[];for(let e of K)n.has(e.threadId)||(Te.current+=1,r.push({kind:`thread`,id:e.threadId,threadId:e.threadId,ordinal:Te.current}));let i=t.some(t=>t.kind===`thread`&&!e.has(t.threadId));r.length===0&&!i||R(t=>{let n=t.filter(t=>t.kind!==`thread`||e.has(t.threadId)),i=new Set(n.filter(Kt).map(Gt)),a=r.filter(e=>!i.has(e.threadId)),o=Ne.current,s=a.length>0?dn(n,a,le.current,e=>un(e,o)):n;return s.length===t.length&&s.every((e,n)=>e===t[n])?t:s})},Rn);let zn;t[55]===Symbol.for(`react.memo_cache_sentinel`)?(zn=[],t[55]=zn):zn=t[55];let Bn=(0,Y.useRef)(zn),Vn,Hn;t[56]!==C||t[57]!==K?(Vn=()=>{if(!C)return;let e=K.map(Wt),t=Bn.current;if(Bn.current=e,I.current!=null)return;let n=e.filter(e=>!t.includes(e)),r=n[n.length-1];r!=null&&(U(r),queueMicrotask(()=>At(r)))},Hn=[K,C],t[56]=C,t[57]=K,t[58]=Vn,t[59]=Hn):(Vn=t[58],Hn=t[59]),(0,Y.useEffect)(Vn,Hn);let Un=(0,Y.useRef)(Q),Wn,Gn;t[60]!==C||t[61]!==Q||t[62]!==s||t[63]!==o?(Wn=()=>{if(!C)return;let e=Un.current;Un.current=Q,Q>e&&!o&&s(!0)},Gn=[Q,o,C,s],t[60]=C,t[61]=Q,t[62]=s,t[63]=o,t[64]=Wn,t[65]=Gn):(Wn=t[64],Gn=t[65]),(0,Y.useEffect)(Wn,Gn);let Kn;t[66]!==B||t[67]!==L?(Kn=[L,B],t[66]=B,t[67]=L,t[68]=Kn):Kn=t[68],(0,Y.useEffect)(()=>{let e=I.current;if(e!=null){let t=Ne.current,n=L.find(n=>un(n,t)===e);if(n!=null){I.current=null,U(n.id);return}if(L.some(e=>e.id===B))return}if(!(B!==``&&L.some(e=>e.id===B))){if(L.length===0){B!==``&&U(``);return}U(L[L.length-1].id)}},Kn),(0,Y.useEffect)(()=>{if(!ge)return;let e=Me.current;if(Me.current=o,v!=null&&v.nonce!==Ee.current){Ee.current=v.nonce,jn.current(v);return}if(y!=null&&y.nonce!==je.current){je.current=y.nonce,jn.current(null,y.id);return}let t=C&&b!=null&&b.nonce!==G.current;if(o&&!e&&L.length===0&&!t&&!(C&&Xe())){Ae.current=!Mn.current();return}if(Ae.current){if(!o||L.length>0||t){Ae.current=!1;return}Z!==null&&Mn.current()&&(Ae.current=!1)}},[o,v,y,b,L.length,ge,C,Z]);let qn;t[69]!==Z||t[70]!==C||t[71]!==b?(qn=[b,C,Z],t[69]=Z,t[70]=C,t[71]=b,t[72]=qn):qn=t[72],(0,Y.useEffect)(()=>{if(!C||b==null||b.nonce===G.current)return;let e=b.agentId===``?null:{source:b.agentSource,id:b.agentId};if(e===null&&Z!==null&&(e={source:Z.source,id:Z.id}),e===null){ke.current!==b.nonce&&(ke.current=b.nonce,De());return}G.current=b.nonce,Ye(e,b.prompt,b.docName,b.titleHint)},qn);let Jn;t[73]!==n||t[74]!==w||t[75]!==D?(Jn=[n,w,D],t[73]=n,t[74]=w,t[75]=D,t[76]=Jn):Jn=t[76],(0,Y.useEffect)(()=>{if(!w||typeof n?.terminal?.list!=`function`||xe.current)return;xe.current=!0;let e=!1;return(async()=>{let t=await et(n,D).catch(Ut);!e&&t!=null&&(le.current=t.order,I.current=t.activeKey);let r;try{r=await n.terminal.list()??[]}catch(e){console.error(`[terminal] reload session list() failed; cold-starting:`,e),r=[]}if(!e){if(r.length>0){let e=le.current,t=t=>{let n=e.indexOf(t);return n===-1?1/0:n},n=r.map(Ht).sort((e,n)=>{let r=t(e.adoptPtyId),i=t(n.adoptPtyId);return r===i?0:r-i});Te.current=Math.max(n.length,...n.map(Vt)),R(n)}_e(!0),window.setTimeout(()=>{e||(I.current=null)},9e3)}})(),()=>{e=!0,xe.current=!1}},Jn);let Yn,Xn;t[77]!==n||t[78]!==P||t[79]!==D||t[80]!==O?(Yn=()=>{if(P||!O||typeof n?.terminal?.getDockState!=`function`)return;let e=!1;return et(n,D).then(t=>{e||t==null||(le.current=t.order,I.current===null&&(I.current=t.activeKey))}),()=>{e=!0}},Xn=[n,P,O,D],t[77]=n,t[78]=P,t[79]=D,t[80]=O,t[81]=Yn,t[82]=Xn):(Yn=t[81],Xn=t[82]),(0,Y.useEffect)(Yn,Xn);let Zn,Qn;t[83]===P?(Zn=t[84],Qn=t[85]):(Zn=()=>{if(P)return;let e=window.setTimeout(()=>{I.current=null},9e3);return()=>window.clearTimeout(e)},Qn=[P],t[83]=P,t[84]=Zn,t[85]=Qn),(0,Y.useEffect)(Zn,Qn);let $n;t[86]!==C||t[87]!==T?($n=[T,C],t[86]=C,t[87]=T,t[88]=$n):$n=t[88],(0,Y.useEffect)(()=>{if(!(!T&&!C))return ye(e=>Nn.current(e))},$n);let er;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(er=[],t[89]=er):er=t[89],(0,Y.useEffect)(()=>ve(()=>Pn.current()),er);let tr;t[90]!==w||t[91]!==S||t[92]!==T?(tr=[S,w,T],t[90]=w,t[91]=S,t[92]=T,t[93]=tr):tr=t[93],(0,Y.useEffect)(()=>{if(w)return f(e=>{e===`new-terminal`?T&&jn.current(null):(e===`kill-terminal`||e===`close-active-tab-or-window`&&S)&&In.current()})},tr);let nr;t[94]!==k||t[95]!==S?(nr=[k,S],t[94]=k,t[95]=S,t[96]=nr):nr=t[96],(0,Y.useEffect)(()=>{let e=function(e){if(!e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||!/^[1-9]$/.test(e.key)||!Nt(k,S)||Oe())return;let t=W.current[Number(e.key)-1];t!=null&&(e.preventDefault(),e.stopPropagation(),U(t.id),queueMicrotask(()=>jt(t)))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},nr);let rr;t[97]!==x||t[98]!==k||t[99]!==S?(rr=[k,S,x],t[97]=x,t[98]=k,t[99]=S,t[100]=rr):rr=t[100],(0,Y.useEffect)(()=>{let e=function(e){if(!e.metaKey||!e.shiftKey||e.ctrlKey||e.altKey)return;let t=e.key===`ArrowLeft`?-1:+(e.key===`ArrowRight`);if(t===0||!Nt(k,S)||Oe()||wn.current)return;let n=e.target;if(n?.tagName===`INPUT`||n?.isContentEditable)return;let r=An.current(t);if(r==null)return;e.preventDefault(),e.stopPropagation();let i=we.current,a=W.current.find(e=>e.id===i);a!=null&&queueMicrotask(()=>jt(a));let o=x({id:`CoHvYd`,values:{0:r.label,1:r.position,2:r.total}});En.current!=null&&window.clearTimeout(En.current),En.current=window.setTimeout(()=>{En.current=null,Tn.current!=null&&(Tn.current.textContent=o)},60)};return window.addEventListener(`keydown`,e,{capture:!0}),()=>{window.removeEventListener(`keydown`,e,{capture:!0}),En.current!=null&&(window.clearTimeout(En.current),En.current=null)}},rr);let ir;t[101]!==n?.editor||t[102]!==w||t[103]!==L?(ir=()=>{if(!w)return;let e=L.some(Bt);me({terminalLive:e}),n?.editor.notifyViewMenuStateChanged({terminalLive:e})},t[101]=n?.editor,t[102]=w,t[103]=L,t[104]=ir):ir=t[104];let ar;t[105]!==n||t[106]!==w||t[107]!==L?(ar=[n,L,w],t[105]=n,t[106]=w,t[107]=L,t[108]=ar):ar=t[108],(0,Y.useEffect)(ir,ar);let or,sr;t[109]!==k||t[110]!==m||t[111]!==h||t[112]!==o?(or=()=>{m||o||Mt(k)&&h()},sr=[m,o,k,h],t[109]=k,t[110]=m,t[111]=h,t[112]=o,t[113]=or,t[114]=sr):(or=t[113],sr=t[114]),(0,Y.useLayoutEffect)(or,sr);let cr;t[115]===m?cr=t[116]:(cr=[m],t[115]=m,t[116]=cr),(0,Y.useEffect)(()=>{if(!m)return;let e=W.current.find(e=>e.id===we.current);e!=null&&jt(e)},cr);let lr=L.map(e=>({id:e.id,label:Cn(e),icon:e.kind===`terminal`?Ft():It($e.get(e.threadId))})),ur=[...L].sort(zt),dr;t[117]===d?dr=t[118]:(dr=d??{},t[117]=d,t[118]=dr);let fr;t[119]!==q||t[120]!==dr?(fr=Ce(q,dr),t[119]=q,t[120]=dr,t[121]=fr):fr=t[121];let pr=(0,X.jsx)(_t,{selected:$,onLaunchSelected:yt,showAgents:C,registeredAgents:Je,onPickAgent:yn,onOpenSettings:De,liveThreadCount:Q,showClis:T,onPickCli:gn,onPickTerminal:_n,visibleClis:fr}),mr=C&&Fe.length>0?(0,X.jsx)(Ke,{archived:Fe,openThreadIds:nt,onOpenThread:at}):null,hr=L.length>0||o&&!S?(0,X.jsx)(St,{sessions:lr,activeSessionId:B,onSelect:e=>{I.current=null,U(e)},onTabActivate:e=>{let t=W.current.find(t=>t.id===e);t!=null&&queueMicrotask(()=>jt(t))},newButton:pr,trailingControls:mr,onClose:Fn,onRename:Sn,onReorder:Dn,onDragActiveChange:e=>{wn.current=e},edge:E,onCollapse:S?void 0:()=>s(!1),draggable:S,className:`h-full`,children:L.length===0?T?null:C&&Fe.length>0?(0,X.jsx)(qe,{archived:Fe,onOpen:at}):(0,X.jsx)(ln,{}):ur.map(e=>(0,X.jsx)(ee,{value:e.id,forceMount:!0,"data-session-id":e.id,...e.kind===`terminal`?{"data-terminal-session":e.id}:{},className:g(`m-0 flex min-h-0 flex-1 flex-col overflow-hidden data-[state=inactive]:hidden`,S&&`px-[22px] pb-[22px]`),children:e.kind===`terminal`?n!=null&&T?(0,X.jsx)(ft,{bridge:n,launch:e.launch,commandId:e.commandId,adoptPtyId:e.adoptPtyId,onPtyId:t=>st(e.id,t),onTitleChange:t=>xn(e.id,t),onClose:()=>Fn(e.id)}):null:(0,X.jsx)(sn,{threadId:e.threadId,info:$e.get(e.threadId),showConnectionBanner:Le&&e.id===B,active:o&&e.id===B})},e.id))}):null,gr;t[122]!==k||t[123]!==hr?(gr=k==null?null:(0,Ge.createPortal)((0,X.jsxs)(X.Fragment,{children:[hr,(0,X.jsx)(`span`,{ref:Tn,"aria-live":`polite`,"aria-atomic":`true`,className:`sr-only`,"data-testid":`terminal-reorder-announcer`})]}),k),t[122]=k,t[123]=hr,t[124]=gr):gr=t[124];let _r;return t[125]===gr?_r=t[126]:(_r=(0,X.jsx)(X.Fragment,{children:gr}),t[125]=gr,t[126]=_r),_r}function zt(e,t){return e.ordinal-t.ordinal}function Bt(e){return e.kind===`terminal`}function Vt(e){return e.ordinal}function Ht(e,t){return{kind:`terminal`,commandId:null,id:Dt(t+1),launch:null,title:null,customLabel:e.customLabel??null,ordinal:e.ordinal??t+1,adoptPtyId:e.ptyId}}function Ut(){return null}function Wt(e){return e.threadId}function Gt(e){return e.threadId}function Kt(e){return e.kind===`thread`}function qt(e){return e.threadId}function Jt(e){return e.kind===`thread`}function Yt(e){return e.threadId}function Xt(e){return e!=null}function Zt(e){return e.kind===`terminal`}function Qt(){}function $t(e){return e.id}function en(e){return e!=null}function tn(e){return[e.id,e]}function nn(e){return e!=null}function rn(e){return[e.threadId,e]}function an(e){return e.archived!==!0}function on(){if(typeof document>`u`)return null;let e=document.createElement(`div`);return e.className=`flex min-h-0 flex-1 flex-col overflow-hidden`,e}function sn(e){let t=(0,J.c)(10),{threadId:n,info:r,showConnectionBanner:i,active:a}=e;if(r===void 0)return null;let o;t[0]===i?o=t[1]:(o=i?(0,X.jsx)(cn,{}):null,t[0]=i,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(`div`,{role:`status`,"aria-busy":`true`,className:`flex min-h-0 flex-1 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(z,{className:`size-5 animate-spin`,"aria-hidden":`true`})}),t[2]=s):s=t[2];let c;t[3]!==a||t[4]!==r||t[5]!==n?(c=(0,X.jsx)(Y.Suspense,{fallback:s,children:(0,X.jsx)(Et,{info:r,active:a},n)}),t[3]=a,t[4]=r,t[5]=n,t[6]=c):c=t[6];let l;return t[7]!==o||t[8]!==c?(l=(0,X.jsxs)(X.Fragment,{children:[o,c]}),t[7]=o,t[8]=c,t[9]=l):l=t[9],l}function cn(){let e=(0,J.c)(4),{_:t}=a(),n;e[0]===t?n=e[1]:(n=t({id:`k0dL2I`}),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,X.jsx)(`div`,{className:`shrink-0 border-amber-500/30 border-b bg-amber-500/5 px-3 py-1 text-amber-700 text-xs dark:text-amber-400`,"data-testid":`agent-thread-reconnecting`,children:n}),e[2]=n,e[3]=r),r}function ln(){let e=(0,J.c)(4),{_:t}=a(),n;e[0]===t?n=e[1]:(n=t({id:`-l6jM7`}),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center px-6 text-center text-muted-foreground text-sm`,"data-testid":`sessions-dock-empty`,children:n}),e[2]=n,e[3]=r),r}function un(e,t){return e.kind===`thread`?e.threadId:e.adoptPtyId??t.get(e.id)??null}function dn(e,t,n,r){let i=e=>{let t=r(e);if(t==null)return 1/0;let i=n.indexOf(t);return i===-1?1/0:i},a=[...e];for(let e of t){let t=i(e);if(t===1/0){a.push(e);continue}let n=a.length;for(let e=0;e<a.length;e++)if(i(a[e])>t){n=e;break}a.splice(n,0,e)}return a}export{Rt as SessionsHost};